whycrzg
2021-05-26 bf7833def6436a4100f15d179717190d9574666c
src/main/java/com/whyc/controller/WindingExperimentController.java
@@ -1,13 +1,16 @@
package com.whyc.controller;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.pojo.Experiment;
import com.whyc.pojo.ExperimentWindingStep1;
import com.whyc.pojo.ExperimentWindingStep2;
import com.whyc.pojo.Project;
import com.whyc.service.ExperimentService;
import com.whyc.service.WindingExperimentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -18,74 +21,99 @@
@Api(tags = "绕组试验")
public class WindingExperimentController {
    /**
     * 绕组试验
     * winding
     * 电流 电压
     * Current
     * 电阻
     *
     * 温度
     */
    @Autowired
    private WindingExperimentService service;
    @Autowired
    private ExperimentService experimentService;
    @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 experimentService.getExperimentId(type);
    }
    @GetMapping("getProjectName")
    @ApiOperation(value = "获取实验项目名")
    @ApiOperation(value = "获取实验项目名称")
    public Response<List<Project>> getProjectName(){
        return service.getProjectName();
    }
    @GetMapping("getRealName")
    @ApiOperation(value = "获取测试名")
    public Response<Object> getRealName(@ApiParam(value = "用户id",required = true)@RequestParam Integer id){
        return service.getRealName(id);
    }
    @PostMapping("")
    @ApiOperation(value = "开始实验")
    @ApiOperation(value = "开始实验",notes = "GET /experiment/exist接口查询当前是否有正在进行的试验;  {\n" +
            "  \"id\": \"\",\n" +
            "  \"name\": \"\",\n" +
            "  \"type\": \"\",\n" +
            "  \"projectId\": 0,\n" +
            "  \"deviceSn\": \"\",\n" +
            "  \"deviceId\": \"\",\n" +
            "  \"rz_link\": 0,\n" +
            "  \"startTime\": \"2021-05-21 10:54:25\",\n" +
            "  \"endTime\": \"2021-05-21 10:54:25\",\n" +
            "  \"duration\": \"\",\n" +
            "  \"userId\": 0,\n" +
            "  \"username\": \"\",\n" +
            "}")
    public Response addWindingExperiment(@RequestBody Experiment experiment){
        return service.addWindingExperiment(experiment);
    }
    @PostMapping("addWindingStep1")
    @ApiOperation(value = "实验步骤1",notes = "[\n" +
            "  {\n" +
            "    \"winding\": \"绕组1\",\n" +
            "    \"electricCurrent\": 10.0,\n" +
            "    \"vol\": 10.0,\n" +
            "    \"resistance\": 20.0,\n" +
            "    \"temperature\": 10.0,\n" +
            "    \"saveTime\": \"2021-05-19 08:16:20\",\n" +
            "    \"experimentId\": \"RZ_20210518132332\",\n" +
            "    \"status\": 0\n" +
            "  },\n" +
            "  {\n" +
            "    \"winding\": \"绕组2\",\n" +
            "    \"electricCurrent\": 10.0,\n" +
            "    \"vol\": 10.0,\n" +
            "    \"resistance\": 20.0,\n" +
            "    \"temperature\": 10.0,\n" +
            "    \"saveTime\": \"2021-05-19 08:16:20\",\n" +
            "    \"experimentId\": \"RZ_20210518132332\",\n" +
            "    \"status\": 0\n" +
            "  }\n" +
            "]")
    @GetMapping("getRZStep")
    @ApiOperation(value = "实验数据",notes = "step参数 1 2 对应实验步骤1、2 ")
    public Response<PageInfo<ExperimentWindingStep1>> getExperimentWindingStep1(@ApiParam(value = "试验编号",required = true)@RequestParam String  experimentId ,
                                                                                @ApiParam(value = "各相绕组连接情况: 0 引出; 1 内部连接",required = true)@RequestParam int rzLink,
                                                                                @ApiParam(value = "实验步骤: 1 实验步骤1; 2 实验步骤2",required = true)@RequestParam int step,
                                                                                @RequestParam int pageNum, @RequestParam int pageSize){
        return service.getExperimentWindingStep1(experimentId,rzLink,step,pageNum,pageSize);
    }
    @PostMapping("saveRZStep")
    @ApiOperation(value = "保存数据",notes = "step参数 1 2 对应实验步骤1、2 不需要传value的参数  测试人realName 保存时间saveTime、状态status、设备类型deviceId、note")
    public Response addExperimentWindingStep1(@RequestBody List<ExperimentWindingStep1> windingStep1s){
        return service.addExperimentWindingStep1(windingStep1s);
    }
    @PostMapping("addWindingStep2")
    @ApiOperation(value = "实验步骤2",notes = "[\n" +
            "  {\n" +
            "    \"winding\": \"绕组\",\n" +
            "    \"electricCurrent\": 10.0,\n" +
            "    \"vol\": 10.0,\n" +
            "    \"resistance\": 20.0,\n" +
            "    \"temperature\": 10.0,\n" +
            "    \"saveTime\": \"2021-05-18 08:16:20\",\n" +
            "    \"experimentId\": \"RZ_20210518132332\",\n" +
            "    \"status\": 0\n" +
            "  }\n" +
            "]")
    public Response addExperimentWindingStep2(@RequestBody List<ExperimentWindingStep2> windingStep2s){
        return service.addExperimentWindingStep2(windingStep2s);
    @DeleteMapping("delRZExperiment")
    @ApiOperation(value = "删除绕组实验数据",notes = "根据唯一试验编号删除试验数据")
    public Response delExperimentWindingbyId(@ApiParam(value = "试验编号",required = true) @RequestParam String experimentId,@ApiParam(value = "唯一标识",required = true) @RequestParam String uuid){
        return service.delExperimentWindingbyId(experimentId,uuid);
    }
    @PostMapping("updateRZStep")
    @ApiOperation(value = "编辑试验数据",notes = "根据试验编号experimentId编辑试验数据 step参数 1 2 对应实验步骤1、2")
    public Response updateExperimentWindingStep1ById(@RequestBody List<ExperimentWindingStep1> windingStep1s){
        return service.updateExperimentWindingStep1(windingStep1s);
    }
    @PostMapping("finishRZExperiment")
    @ApiOperation(value = "完成试验")
    public Response updateFlag(@ApiParam(value = "试验编号", required = true) @RequestParam String id) {
        return service.updateFlag(id);
    }
}