whycxzp
2021-03-27 6b0b66f359b1991ecfd7cbccc01cdf8370763bb9
更新 设备参数设置和维保计划/记录
3个文件已添加
4个文件已修改
136 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/DeviceMaintainController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceTypeController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DeviceMaintainMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceMaintain.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceType.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceMaintainService.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceTypeService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceMaintainController.java
New file
@@ -0,0 +1,52 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.DeviceMaintain;
import com.whyc.service.DeviceMaintainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@RestController
@RequestMapping("deviceMaintain")
@Api(tags = "设备维保")
public class DeviceMaintainController {
    @Autowired
    private DeviceMaintainService service;
    @GetMapping
    @ApiOperation(value = "查询")
    public Response get(@RequestParam Integer deviceId){
        return service.get(deviceId);
    }
    @PostMapping
    @ApiOperation(value = "创建")
    public Response add(@RequestBody DeviceMaintain deviceMaintain){
        return service.add(deviceMaintain);
    }
    @PutMapping
    @ApiOperation(value = "修改")
    public Response update(@RequestBody DeviceMaintain deviceMaintain){
        return service.update(deviceMaintain);
    }
    @PutMapping("confirm")
    @ApiOperation(value = "确认记录",notes = "传入deviceId(设备id),actualTime(实际维护日期),actualOwner2(实际维护人员),content(主要维护内容)")
    public Response confirm(@RequestBody DeviceMaintain deviceMaintain){
        return service.confirm(deviceMaintain);
    }
    @GetMapping("record")
    @ApiOperation(value = "查询维保记录")
    public Response getRecord(@RequestParam Integer deviceId){
        return service.getRecord(deviceId);
    }
}
src/main/java/com/whyc/controller/DeviceTypeController.java
@@ -6,18 +6,16 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 设备类型
 * 设备类型及通用参数
 */
@RestController
@RequestMapping("deviceType")
@Api(tags = "设备类型")
@Api(tags = "设备类型及通用参数")
public class DeviceTypeController {
    @Autowired
@@ -29,4 +27,10 @@
        return service.getAll();
    }
    @PutMapping
    @ApiOperation(value = "修改设备类型参数")
    public Response update(@RequestBody DeviceType deviceType){
        return service.update(deviceType);
    }
}
src/main/java/com/whyc/mapper/DeviceMaintainMapper.java
New file
@@ -0,0 +1,6 @@
package com.whyc.mapper;
import com.whyc.pojo.DeviceMaintain;
public interface DeviceMaintainMapper extends CustomMapper<DeviceMaintain> {
}
src/main/java/com/whyc/pojo/DeviceMaintain.java
@@ -1,5 +1,8 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.ibatis.type.Alias;
@@ -13,6 +16,7 @@
@TableName(schema = "db_experiment",value = "tb_device_maintain")
public class DeviceMaintain {
    private Integer num;
    @TableId(type = IdType.INPUT)
    private Integer deviceId;
    /**维护厂家*/
    private String  owner;
src/main/java/com/whyc/pojo/DeviceType.java
@@ -5,15 +5,15 @@
import org.apache.ibatis.type.Alias;
/**
 * 设备类,型及通用参数
 * 设备类型及通用参数
 */
@Alias("DeviceType")
@TableName(schema = "db_experiment",value = "tb_device_type")
public class DeviceType {
    @TableId
    private Integer num;
    @TableId
    private Integer deviceTypeId;
    private String deviceTypeName;
src/main/java/com/whyc/service/DeviceMaintainService.java
New file
@@ -0,0 +1,51 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.whyc.dto.Response;
import com.whyc.mapper.DeviceMaintainMapper;
import com.whyc.pojo.DeviceMaintain;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class DeviceMaintainService {
    @Resource
    private DeviceMaintainMapper mapper;
    public Response get(Integer deviceId) {
        QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.eq("status",1).eq("device_id",deviceId);
        DeviceMaintain deviceMaintain = mapper.selectOne(wrapper);
        return new Response().set(1,deviceMaintain);
    }
    public Response add(DeviceMaintain deviceMaintain) {
        mapper.insert(deviceMaintain);
        return new Response().set(1,"创建成功");
    }
    public Response update(DeviceMaintain deviceMaintain) {
        mapper.updateById(deviceMaintain);
        return new Response().set(1,"修改成功");
    }
    public Response confirm(DeviceMaintain deviceMaintain) {
        //确认维护,维护状态更新为0
        deviceMaintain.setStatus(0);
        deviceMaintain.setActualTime(new Date());
        mapper.updateById(deviceMaintain);
        return new Response().set(1,"确认成功");
    }
    public Response getRecord(Integer deviceId) {
        QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.select("actual_time","actual_owner2","content").eq("status",0).eq("device_id",deviceId);
        List<DeviceMaintain> deviceMaintains = mapper.selectList(wrapper);
        return new Response().set(1,deviceMaintains);
    }
}
src/main/java/com/whyc/service/DeviceTypeService.java
@@ -18,4 +18,9 @@
        List<DeviceType> deviceTypes = mapper.selectList(null);
        return new Response<List<DeviceType>>().set(1,deviceTypes);
    }
    public Response update(DeviceType deviceType) {
        mapper.updateById(deviceType);
        return new Response().setMsg(1,"修改成功");
    }
}