更新设备信息字段(添加参数字段),更新在线设备接口,添加测试配置接口
1个文件已添加
4个文件已修改
173 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/DeviceInfController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/TestConfigController.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceInf.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceInfService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceTypeService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceInfController.java
@@ -1,7 +1,9 @@
package com.whyc.controller;
import com.whyc.dto.DeviceInfDTO;
import com.whyc.dto.DeviceTypeDTO;
import com.whyc.dto.Response;
import com.whyc.pojo.DeviceInf;
import com.whyc.service.DeviceInfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -29,4 +31,10 @@
        return service.getAll();
    }
    @GetMapping("getListBySystemId")
    @ApiOperation(value = "设备信息by设备类别")
    public Response<List<DeviceInf>> getListBySystemId(Integer systemId){
        return service.getListBySystemId(systemId);
    }
}
src/main/java/com/whyc/controller/TestConfigController.java
New file
@@ -0,0 +1,45 @@
package com.whyc.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.pojo.DeviceInf;
import com.whyc.pojo.DeviceType;
import com.whyc.service.DeviceInfService;
import com.whyc.service.DeviceTypeService;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("testConfig")
@Slf4j
@Api(tags = "试验配置")
public class TestConfigController {
    @Autowired
    private DeviceInfService deviceInfService;
    @Autowired
    private DeviceTypeService deviceTypeService;
    @PutMapping
    @ApiOperation("加载默认配置参数")
    public Response setDefautlTestConfig(@RequestParam Integer deviceId){
        DeviceInf deviceInf = deviceInfService.getOneByDeviceId(deviceId);
        DeviceType deviceType = deviceTypeService.getOneByDeviceTypeId(deviceInf.getSystemId());
        deviceInf.setLoadStartType(deviceType.getLoadStartType());
        deviceInf.setLoadRuntime(deviceType.getLoadRuntime());
        deviceInf.setLoadCurrStd(deviceType.getLoadCurrStd());
        deviceInf.setLoadVolStd(deviceType.getLoadVolStd());
        deviceInf.setLoadRpm(deviceType.getLoadRpm());
        deviceInf.setLoadTorque(deviceType.getLoadTorque());
        deviceInf.setLoadPropulsionShaft(deviceType.getLoadPropulsionShaft());
        return deviceInfService.update(deviceInf);
    }
}
src/main/java/com/whyc/pojo/DeviceInf.java
@@ -21,9 +21,28 @@
    private String   deviceIp          ; //设备ip
    private Integer  maintCycle    ; //维护周期
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
    private Date      useStartTime      ; //开始使用时间
    private Date      useStarttime      ; //开始使用时间
    private Integer  userId            ; //录入用户
    private String   note;
    /**
     * 在线设备,设备部件参数获取
     */
    /**负载电机-启动方式:1-自启动,2-手动启动*/
    private Integer loadStartType;
    /**负载电机-运行时长*/
    private Float loadRuntime;
    /**负载电机-电流标准*/
    private Float loadCurrStd;
    /**负载电机--电压标准*/
    private Float loadVolStd;
    /**负载电机-转速*/
    private Integer loadRpm;
    /**负载电机-转矩*/
    private Integer loadTorque;
    /**负载电机-推进轴*/
    private Integer loadPropulsionShaft;
    public Long getNum() {
        return num;
@@ -81,12 +100,12 @@
        this.maintCycle = maintCycle;
    }
    public Date getUseStartTime() {
        return useStartTime;
    public Date getUseStarttime() {
        return useStarttime;
    }
    public void setUseStartTime(Date useStartTime) {
        this.useStartTime = useStartTime;
    public void setUseStarttime(Date useStarttime) {
        this.useStarttime = useStarttime;
    }
    public Integer getUserId() {
@@ -104,4 +123,60 @@
    public void setNote(String note) {
        this.note = note;
    }
    public Integer getLoadStartType() {
        return loadStartType;
    }
    public void setLoadStartType(Integer loadStartType) {
        this.loadStartType = loadStartType;
    }
    public Float getLoadRuntime() {
        return loadRuntime;
    }
    public void setLoadRuntime(Float loadRuntime) {
        this.loadRuntime = loadRuntime;
    }
    public Float getLoadCurrStd() {
        return loadCurrStd;
    }
    public void setLoadCurrStd(Float loadCurrStd) {
        this.loadCurrStd = loadCurrStd;
    }
    public Float getLoadVolStd() {
        return loadVolStd;
    }
    public void setLoadVolStd(Float loadVolStd) {
        this.loadVolStd = loadVolStd;
    }
    public Integer getLoadRpm() {
        return loadRpm;
    }
    public void setLoadRpm(Integer loadRpm) {
        this.loadRpm = loadRpm;
    }
    public Integer getLoadTorque() {
        return loadTorque;
    }
    public void setLoadTorque(Integer loadTorque) {
        this.loadTorque = loadTorque;
    }
    public Integer getLoadPropulsionShaft() {
        return loadPropulsionShaft;
    }
    public void setLoadPropulsionShaft(Integer loadPropulsionShaft) {
        this.loadPropulsionShaft = loadPropulsionShaft;
    }
}
src/main/java/com/whyc/service/DeviceInfService.java
@@ -1,12 +1,17 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.dto.DeviceTypeDTO;
import com.whyc.mapper.DeviceInfMapper;
import com.whyc.pojo.DeviceInf;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;
@Service
@@ -26,4 +31,29 @@
        return new Response<List<DeviceTypeDTO>>().set(1,systemList);
    }
    public DeviceInf getOneByDeviceId(Integer deviceId){
        QueryWrapper<DeviceInf> queryWrapper = Wrappers.query();
        queryWrapper.eq("device_id",deviceId);
        DeviceInf deviceInf = mapper.selectOne(queryWrapper);
        return deviceInf;
    }
    public Response<List<DeviceInf>> getListBySystemId(Integer systemId){
        QueryWrapper<DeviceInf> queryWrapper = Wrappers.query();
        queryWrapper.eq("system_id",systemId);
        List<DeviceInf> list = mapper.selectList(queryWrapper);
        return new Response<List<DeviceInf>>().set(1,list);
    }
    public Response update(@NotNull @NotNull DeviceInf deviceInf){
        UpdateWrapper<DeviceInf> updateWrapper = Wrappers.update();
        updateWrapper.eq("device_id",deviceInf.getDeviceId());
        Response res = new Response();
        if(mapper.update(deviceInf,updateWrapper)>0){
            res.set(1,deviceInf,"加载默认参数成功!");
        }
        return res;
    }
}
src/main/java/com/whyc/service/DeviceTypeService.java
@@ -28,4 +28,9 @@
        DeviceType deviceType = mapper.selectById(deviceTypeId);
        return new Response<DeviceType>().set(1,deviceType);
    }
    public DeviceType getOneByDeviceTypeId(Integer deviceTypeId){
        DeviceType deviceType = mapper.selectById(deviceTypeId);
        return deviceType;
    }
}