whycxzp
2021-03-29 06a1363d34d5ea9a4cb1453c3c795e39f2713fc2
更新接口
5个文件已修改
109 ■■■■ 已修改文件
src/main/java/com/whyc/controller/DeviceMaintainController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DeviceMaintainMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/DeviceMaintain.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DeviceMaintainService.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/DeviceMaintainMapper.xml 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/DeviceMaintainController.java
@@ -26,7 +26,7 @@
    @Autowired
    private DeviceMaintainService service;
    @GetMapping("page")
    @PostMapping("page")
    @ApiOperation(value = "查询计划分页")
    public Response getPageByCondition(@RequestParam Integer pageNum, @RequestParam Integer pageSize,
                                       @RequestBody DeviceMaintainDTO maintainDTO
src/main/java/com/whyc/mapper/DeviceMaintainMapper.java
@@ -7,4 +7,6 @@
public interface DeviceMaintainMapper extends CustomMapper<DeviceMaintain> {
    List<DeviceMaintain> getPageByCondition(DeviceMaintainDTO maintainDTO);
    DeviceMaintain get(Integer deviceId);
}
src/main/java/com/whyc/pojo/DeviceMaintain.java
@@ -7,6 +7,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.ibatis.type.Alias;
import java.beans.Transient;
import java.util.Date;
/**
@@ -33,13 +34,13 @@
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
    private Date firstTime;
    /**提前提醒时间,单位为天*/
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
    private Date reminderTime;
    private Integer reminderAheadUnit;
    /**提醒方式:1-列表提醒,2-页面弹窗,3-短信提醒*/
    private Integer  reminderType;
    /**状态:1-有效,0-失效*/
    private Integer status;
    /**记录类型:1-计划,0-记录*/
    @TableField("is_plan")
    private Integer plan;
    /**实际维护时间*/
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai")
@@ -97,12 +98,12 @@
        this.cycle = cycle;
    }
    public Date getReminderTime() {
        return reminderTime;
    public Integer getReminderAheadUnit() {
        return reminderAheadUnit;
    }
    public void setReminderTime(Date reminderTime) {
        this.reminderTime = reminderTime;
    public void setReminderAheadUnit(Integer reminderAheadUnit) {
        this.reminderAheadUnit = reminderAheadUnit;
    }
    public Integer getReminderType() {
src/main/java/com/whyc/service/DeviceMaintainService.java
@@ -21,9 +21,10 @@
    private DeviceMaintainMapper mapper;
    public Response get(Integer deviceId) {
        QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.eq("status",1).eq("plan",1).eq("device_id",deviceId);
        DeviceMaintain deviceMaintain = mapper.selectOne(wrapper);
        /*QueryWrapper<DeviceMaintain> wrapper = Wrappers.query();
        wrapper.eq("status",1).eq("is_plan",1).eq("device_id",deviceId);
        DeviceMaintain deviceMaintain = mapper.selectOne(wrapper);*/
        DeviceMaintain deviceMaintain = mapper.get(deviceId);
        return new Response().set(1,deviceMaintain);
    }
@@ -38,16 +39,15 @@
    }
    public Response confirm(DeviceMaintain deviceMaintain) {
        //确认维护,维护状态更新为0
        deviceMaintain.setStatus(0);
        deviceMaintain.setActualTime(new Date());
        mapper.updateById(deviceMaintain);
        //新增一条进记录,plan字段为0
        deviceMaintain.setPlan(0);
        mapper.insert(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);
        wrapper.select("actual_time","actual_owner2","content").eq("is_plan",0).eq("device_id",deviceId);
        List<DeviceMaintain> deviceMaintains = mapper.selectList(wrapper);
        return new Response().set(1,deviceMaintains);
    }
src/main/resources/mapper/DeviceMaintainMapper.xml
@@ -3,9 +3,79 @@
<mapper namespace="com.whyc.mapper.DeviceMaintainMapper" >
    <resultMap id="DeviceMaintainResultMap" type="DeviceMaintain">
        <result property="deviceId" column="device_id"/>
        <result property="owner" column="owner1" />
        <result property="owner2" column="owner2"/>
        <result property="phone" column="phone"/>
        <result property="cycle" column="cycle"/>
        <result property="firstTime" column="first_time"/>
        <result property="reminderAheadUnit" column="reminder_ahead_unit"/>
        <result property="reminderType" column="reminder_type"/>
        <association property="deviceManage" javaType="DeviceManage" resultMap="DeviceManageResultMap" />
    </resultMap>
    <select id="getPageByCondition" resultMap="DeviceMaintainResultMap">
        select * from
    <!--DeviceManage封装-->
    <resultMap id="DeviceManageResultMap" type="DeviceManage">
        <result property="deviceId" column="device_id"/>
        <result property="deviceName" column="device_name"/>
        <result property="deviceBrand" column="device_brand"/>
        <result property="deviceVersion" column="device_version"/>
        <result property="deviceId" column="device_id"/>
        <result property="usefulLife" column="useful_life"/>
        <result property="debugTime" column="debug_time"/>
        <result property="site" column="site"/>
        <result property="owner" column="owner"/>
        <result property="createTime" column="create_time"/>
        <association property="deviceType" javaType="DeviceType">
            <result property="deviceTypeId" column="device_type_id" />
            <result property="deviceTypeName" column="device_type_name"/>
        </association>
    </resultMap>
    <select id="getPageByCondition" resultMap="DeviceManageResultMap">
        SELECT
            n.device_name,
            n.device_brand,
            n.device_version,
            t.device_type_name,
            t.device_type_id,
            n.device_id,
            n.useful_life,
            n.debug_time,
            n.site,
            n.owner
        FROM
            db_experiment.tb_device_manage n ,
            db_experiment.tb_device_type t
        WHERE
            n.device_type_id = t.device_type_id
    </select>
    <select id="get" resultMap="DeviceMaintainResultMap">
        SELECT
            n.device_name,
            n.device_brand,
            n.device_version,
            t.device_type_name,
            t.device_type_id,
            n.device_id,
            n.useful_life,
            n.debug_time,
            n.site,
            n.owner,
            m.owner as owner1,
            m.owner2,
            m.phone,
            m.cycle,
            m.first_time,
            m.reminder_ahead_unit,
            m.reminder_type
        FROM
            db_experiment.tb_device_maintain m,
            db_experiment.tb_device_manage n ,
            db_experiment.tb_device_type t
        WHERE
            m.device_id = n.device_id
            AND n.device_type_id = t.device_type_id
            AND m.is_plan=1
    </select>
</mapper>