whycxzp
2021-06-03 0ed39bd9a35a51a118f54b6c3fea792294431a2f
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package com.whyc.controller;
 
import com.github.pagehelper.PageInfo;
import com.whyc.dto.ExperimentConditionDTO;
import com.whyc.dto.Response;
import com.whyc.pojo.Experiment;
import com.whyc.pojo.ExperimentBaseData;
import com.whyc.pojo.ExperimentBaseDataKZ;
import com.whyc.pojo.ExperimentPoint;
import com.whyc.service.ExperimentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping("experiment")
@Api(tags = "试验")
public class ExperimentController {
 
    @Autowired
    private ExperimentService service;
 
    @GetMapping("exist")
    @ApiOperation(value = "查询当前是否有正在进行的试验",notes = "如果有,code=1,返回试验的基础数据;如果没有,code=-1")
    public Response exist(){
        return service.exist();
    }
 
    @GetMapping("experimentId")
    @ApiOperation(value = "查询当前试验编号",notes = "传入的type选择其一:" +
            "绕组:rz,\n" +
            "空载:kz,\n" +
            "负载:fz,\n" +
            "升温:sw,\n" +
            "超速:cs,\n" +
            "空载反电动势:kzfdds,\n" +
            "振动:zd,\n" +
            "耐压:ny,\n" +
            "转动惯量:zdgl,\n")
    public Response getExperimentId(@RequestParam String type){
        return service.getExperimentId(type);
    }
 
    @PostMapping("kzfz")
    @ApiOperation(value = "新增试验-空载/负载")
    public Response addKZFZ(@RequestBody Experiment<ExperimentBaseDataKZ, ExperimentPoint> experiment){
        return service.addKZFZ(experiment);
    }
 
    @GetMapping("checkPrecondition")
    @ApiOperation(value = "检查前置条件",notes = "传入的type选择其一:" +
            "绕组:rz,\n" +
            "空载:kz,\n" +
            "负载:fz,\n" +
            "升温:sw,\n" +
            "超速:cs,\n" +
            "空载反电动势:kzfdds,\n" +
            "振动:zd,\n" +
            "耐压:ny,\n" +
            "转动惯量:zdgl,\n")
    public Response checkPrecondition(@RequestParam String type){
        return service.checkPrecondition(type);
    }
 
    @PutMapping("precondition")
    @ApiOperation(value = "设置前置条件",notes = "id:进线屏开关状态-1,大功率整流电源-2,..." +
            "value:开关信号:关-0,开-1,数值信号:电源-开-500-关-400,A排-开-500-关-400,B排-开-0-关-100")
    public Response setPrecondition(@RequestParam Integer id,@RequestParam Integer value){
        return service.setPrecondition(id,value);
    }
 
    /**
     * 开始试验,请求接口1,获取试验测试点
     */
    @GetMapping("point")
    @ApiOperation(value = "查询测试点列表")
    public Response getPoint(@RequestParam String experimentId){
        return service.getPoint(experimentId);
    }
 
    /**
     * 开始试验,检查中置条件
     * @return
     */
    @GetMapping("checkPreconditionStep1")
    @ApiOperation(value = "步骤1,检查升温情况")
    public Response checkPreconditionStep1(@RequestParam String experimentId){
        return service.checkPreconditionStep1(experimentId);
    }
 
    @PostMapping("startExperimentPoint")
    @ApiOperation(value = "启动测试点",notes = "传入id,duration")
    public Response StartExperimentPoint(@RequestBody ExperimentPoint point){
        return service.startExperimentPoint(point);
    }
 
    @PostMapping("finishExperiment")
    @ApiOperation(value = "完成实验")
    public Response finishExperiment(@RequestParam String experimentId){
        return service.finishExperiment(experimentId);
    }
 
    @PostMapping("finishExperimentPoint")
    @ApiOperation(value = "结束测试点")
    public Response finishExperimentPoint(@RequestParam Integer id){
        return service.finishExperimentPoint(id);
    }
 
    @PostMapping("restartExperimentPoint")
    @ApiOperation(value = "重做测试点")
    public Response restartExperimentPoint(@RequestParam Integer id){
        return service.restartExperimentPoint(id);
    }
 
    /*======History======*/
 
    @PostMapping("page")
    @ApiOperation(value = "查询历史分页-根据条件筛选")
    public Response<PageInfo<Experiment>> getPage(@RequestParam Integer pageNum,
                                                  @RequestParam Integer pageSize,
                                                  @RequestBody ExperimentConditionDTO condition){
 
        return service.getPage(pageNum,pageSize,condition);
    }
 
}