whycxzp
2021-09-27 aebf48caa06d2831c56d66ba2f946800dff0b3a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package com.whyc.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.whyc.dto.Response;
import com.whyc.pojo.DeviceInf;
import com.whyc.pojo.TestPlan;
import com.whyc.service.DeviceInfService;
import com.whyc.service.TestPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
 
@RestController
@RequestMapping("testPlan")
@Api(tags = "试验计划、试验结论")
@Slf4j
public class TestPlanController {
    @Autowired
    private TestPlanService service;
    @Autowired
    private DeviceInfService deviceInfService;
 
 
    @GetMapping("all")
    @ApiOperation(value = "查询所有-分页")
    public Response<IPage<TestPlan>> getAll(@RequestParam int pageNum, @RequestParam int pageSize){
        return service.getAll(pageNum,pageSize);
    }
    @PostMapping("search")
    @ApiOperation(value = "查询分页-根据筛选条件")
    public Response<IPage<TestPlan>> getPageByCondition(@RequestParam int pageNum, @RequestParam int pageSize, @RequestBody TestPlan testPlan){
        return service.getPageByCondition(pageNum,pageSize,testPlan);
    }
 
    @PostMapping("conclusion")
    @ApiOperation(value = "试验结论查询分页-根据筛选条件")
    public Response<IPage<TestPlan>> getConclusion(@RequestParam int pageNum, @RequestParam int pageSize, @RequestBody TestPlan testPlan){
        return service.getConclusion(pageNum,pageSize,testPlan);
    }
 
    @GetMapping
    @ApiOperation(value = "查看详情")
    public Response getOne(@RequestParam Integer num){
        return service.getOne(num);
    }
 
    @GetMapping("getDeviceInf")
    @ApiOperation(value = "设备信息")
    public Response getDeviceInf(@RequestParam Integer num){
        TestPlan testPlan = service.getOneById(num);
        String devices = testPlan.getDevices();
        String[] ids = devices.split(",");
        List<DeviceInf> list = new ArrayList<>();
        for (String deviceId:ids) {
            DeviceInf deviceInf = deviceInfService.getOneByDeviceId(Integer.valueOf(deviceId));
            list.add(deviceInf);
        }
        return new Response().set(1,list);
    }
 
 
    @PostMapping
    @ApiOperation(value = "新增")
    public Response add(@RequestBody TestPlan testPlan){
        return service.add(testPlan);
    }
    @PutMapping
    @ApiOperation(value = "编辑")
    public Response update(@RequestBody TestPlan testPlan){
        return service.update(testPlan);
    }
    @PutMapping("startPlan")
    @ApiOperation(value = "启动计划")
    public Response startPlan(@RequestParam int num){
        return service.startPlan(num);
    }
 
    @PutMapping("delete")
    @ApiOperation(value = "删除作废")
    public Response deletePlan(@RequestParam int num){
        return service.deletePlan(num);
    }
    @PutMapping("stop")
    @ApiOperation(value = "停止计划")
    public Response stopPlan(@RequestParam int num){
        return service.stopPlan(num);
    }
    @PutMapping("verified")
    @ApiOperation(value = "审核计划")
    public Response verifiedPlan(@RequestParam int num,@RequestParam String verifier){
        return service.verifiedPlan(num,verifier);
    }
 
 
 
 
 
}