whycxzp
2021-03-29 ebab5a2e4a5041d5ac08032221f24076238a33bb
修改设备列表接口
2个文件已添加
5个文件已修改
139 ■■■■ 已修改文件
src/main/java/com/whyc/controller/DeviceMaintainController.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/DeviceMaintainDTO.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DeviceMaintainMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceMaintain.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceMaintainService.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DeviceMaintainMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DeviceManageMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceMaintainController.java
@@ -1,5 +1,6 @@
package com.whyc.controller;
import com.whyc.dto.DeviceMaintainDTO;
import com.whyc.dto.Response;
import com.whyc.pojo.DeviceMaintain;
import com.whyc.service.DeviceMaintainService;
@@ -7,6 +8,15 @@
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 这里维保计划创建后,
 * 存在首次维保时间和维保周期,从理论上来说,创建了一次维保计划后是永久循环生效的,计划维保时间一次次按周期推
 * 从表结构上说,存在维保计划表和维保记录表;
 *
 * demo,采取一张表进行功能实现
 *
 */
@RestController
@RequestMapping("deviceMaintain")
@@ -17,38 +27,40 @@
    private DeviceMaintainService service;
    @GetMapping("page")
    @ApiOperation(value = "查询维保分页")
    public Response getPageByCondition(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        return service.getPage(pageNum,pageSize);
    @ApiOperation(value = "查询计划分页")
    public Response getPageByCondition(@RequestParam Integer pageNum, @RequestParam Integer pageSize,
                                       @RequestBody DeviceMaintainDTO maintainDTO
    ) {
        return service.getPageByCondition(pageNum, pageSize,maintainDTO);
    }
    @GetMapping
    @ApiOperation(value = "查询")
    public Response get(@RequestParam Integer deviceId){
    @ApiOperation(value = "查询计划")
    public Response get(@RequestParam Integer deviceId) {
        return service.get(deviceId);
    }
    @PostMapping
    @ApiOperation(value = "创建")
    public Response add(@RequestBody DeviceMaintain deviceMaintain){
    @ApiOperation(value = "创建计划")
    public Response add(@RequestBody DeviceMaintain deviceMaintain) {
        return service.add(deviceMaintain);
    }
    @PutMapping
    @ApiOperation(value = "修改")
    public Response update(@RequestBody DeviceMaintain deviceMaintain){
    @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){
    @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){
    @ApiOperation(value = "查询记录")
    public Response getRecord(@RequestParam Integer deviceId) {
        return service.getRecord(deviceId);
    }
src/main/java/com/whyc/dto/DeviceMaintainDTO.java
New file
@@ -0,0 +1,47 @@
package com.whyc.dto;
import java.util.Date;
public class DeviceMaintainDTO {
    /**入库时间*/
    private Date createTime;
    /**最后维护时间*/
    private Date lastMaintainTime;
    /**设备类型*/
    private Integer deviceTypeId;
    /**所在区域*/
    private String site;
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getLastMaintainTime() {
        return lastMaintainTime;
    }
    public void setLastMaintainTime(Date lastMaintainTime) {
        this.lastMaintainTime = lastMaintainTime;
    }
    public Integer getDeviceTypeId() {
        return deviceTypeId;
    }
    public void setDeviceTypeId(Integer deviceTypeId) {
        this.deviceTypeId = deviceTypeId;
    }
    public String getSite() {
        return site;
    }
    public void setSite(String site) {
        this.site = site;
    }
}
src/main/java/com/whyc/mapper/DeviceMaintainMapper.java
@@ -1,6 +1,10 @@
package com.whyc.mapper;
import com.whyc.dto.DeviceMaintainDTO;
import com.whyc.pojo.DeviceMaintain;
import java.util.List;
public interface DeviceMaintainMapper extends CustomMapper<DeviceMaintain> {
    List<DeviceMaintain> getPageByCondition(DeviceMaintainDTO maintainDTO);
}
src/main/java/com/whyc/pojo/DeviceMaintain.java
@@ -18,6 +18,9 @@
    private Integer num;
    @TableId(type = IdType.INPUT)
    private Integer deviceId;
    /**设备在库信息*/
    @TableField(exist = false)
    private DeviceManage deviceManage;
    /**维护厂家*/
    private String  owner;
    /**维护人员*/
@@ -34,8 +37,10 @@
    private Date reminderTime;
    /**提醒方式:1-列表提醒,2-页面弹窗,3-短信提醒*/
    private Integer  reminderType;
    /**维护状态:1-待维护,0-已维护*/
    /**状态:1-有效,0-失效*/
    private Integer status;
    /**记录类型:1-计划,0-记录*/
    private Integer plan;
    /**实际维护时间*/
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
    private Date actualTime;
@@ -147,4 +152,20 @@
    public void setContent(String content) {
        this.content = content;
    }
    public DeviceManage getDeviceManage() {
        return deviceManage;
    }
    public void setDeviceManage(DeviceManage deviceManage) {
        this.deviceManage = deviceManage;
    }
    public Integer getPlan() {
        return plan;
    }
    public void setPlan(Integer plan) {
        this.plan = plan;
    }
}
src/main/java/com/whyc/service/DeviceMaintainService.java
@@ -3,6 +3,8 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.pagehelper.PageHelper;
import com.whyc.dto.DeviceMaintainDTO;
import com.whyc.dto.Response;
import com.whyc.mapper.DeviceMaintainMapper;
import com.whyc.pojo.DeviceMaintain;
@@ -20,7 +22,7 @@
    public Response get(Integer deviceId) {
        QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.eq("status",1).eq("device_id",deviceId);
        wrapper.eq("status",1).eq("plan",1).eq("device_id",deviceId);
        DeviceMaintain deviceMaintain = mapper.selectOne(wrapper);
        return new Response().set(1,deviceMaintain);
    }
@@ -50,8 +52,9 @@
        return new Response().set(1,deviceMaintains);
    }
    public Response getPage(Integer pageNum, Integer pageSize) {
        QueryWrapper<Object> wrapper = Wrappers.query();
        return null;
    public Response getPageByCondition(Integer pageNum, Integer pageSize, DeviceMaintainDTO maintainDTO) {
        PageHelper.startPage(pageNum,pageSize);
        List<DeviceMaintain> deviceMaintainList = mapper.getPageByCondition(maintainDTO);
        return new Response().set(1,deviceMaintainList);
    }
}
src/main/resources/mapper/DeviceMaintainMapper.xml
New file
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.whyc.mapper.DeviceMaintainMapper" >
    <resultMap id="DeviceMaintainResultMap" type="DeviceMaintain">
    </resultMap>
    <select id="getPageByCondition" resultMap="DeviceMaintainResultMap">
        select * from
    </select>
</mapper>
src/main/resources/mapper/DeviceManageMapper.xml
@@ -23,6 +23,7 @@
    </resultMap>
    <resultMap id="DeviceTypeResultMap2" type="DeviceTypeDTO">
        <result property="deviceTypeId" column="device_type_id"/>
        <result property="deviceTypeName" column="device_type_name"/>
        <collection property="devices" ofType="Device">
            <result property="deviceName" column="device_name"/>
@@ -35,8 +36,8 @@
        where manage.device_type_id = type.device_type_id order by manage.create_time desc
    </select>-->
    <select id="getList" resultMap="DeviceTypeResultMap2">
        select manage.device_name,manage.device_id,type.device_type_name from db_experiment.tb_device_manage manage,db_experiment.tb_device_type type
        where manage.device_type_id = type.device_type_id
        select manage.device_name,manage.device_id,type.device_type_id,type.device_type_name from db_experiment.tb_device_manage manage,db_experiment.tb_device_type type
        where manage.device_type_id = type.device_type_id order by type.device_type_id asc
    </select>
    <select id="getAllByCondition" resultMap="DeviceManageResultMap">
        select manage.*,type.device_type_id,type.device_type_name from db_experiment.tb_device_manage manage,db_experiment.tb_device_type type