| | |
| | | } |
| | | |
| | | @PostMapping("page2") |
| | | @ApiOperation(value = "查询计划分页") |
| | | @ApiIgnore |
| | | @ApiOperation(value = "查询计划分页2") |
| | | public Response getPageByCondition2(@RequestParam Integer pageNum, @RequestParam Integer pageSize, |
| | | @RequestBody DeviceMaintainDTO maintainDTO |
| | | ) { |
| | |
| | | package com.whyc.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | |
| | | import java.util.Date; |
| | | |
| | | public class DeviceMaintainDTO { |
| | | |
| | | /**入库时间*/ |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") |
| | | private Date createTime; |
| | | /**最后维护时间*/ |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") |
| | | private Date lastMaintainTime; |
| | | /**设备类型*/ |
| | | private Integer deviceTypeId; |
| | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.apache.ibatis.type.Alias; |
| | | |
| | | import java.beans.Transient; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | private String actualOwner2; |
| | | /**主要维护内容*/ |
| | | private String content; |
| | | /**最后维护时间,动态计算*/ |
| | | @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") |
| | | private Date lastMaintainTime; |
| | | |
| | | public Integer getNum() { |
| | | return num; |
| | |
| | | public void setPlan(Integer plan) { |
| | | this.plan = plan; |
| | | } |
| | | |
| | | public Date getLastMaintainTime() { |
| | | return lastMaintainTime; |
| | | } |
| | | |
| | | public void setLastMaintainTime(Date lastMaintainTime) { |
| | | this.lastMaintainTime = lastMaintainTime; |
| | | } |
| | | } |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | @Service |
| | | public class DeviceMaintainService { |
| | |
| | | } |
| | | |
| | | public Response getPageByCondition2(Integer pageNum, Integer pageSize, DeviceMaintainDTO maintainDTO) { |
| | | //1.查询出所有的维保计划及对应的最后实际维保时间 |
| | | //2.如果没有维保时间的,按照首保时间+cycle得到预计的最后维保时间 |
| | | // 有实际维保时间的,按照最后实际维保时间+cycle得到预计的最后维保时间 |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<DeviceMaintain> deviceMaintainList = mapper.getPageByCondition2(maintainDTO); |
| | | PageInfo<DeviceMaintain> deviceMaintainPageInfo = new PageInfo<>(deviceMaintainList); |
| | | |
| | | List<DeviceMaintain> newDeviceMaintainList =null; |
| | | if(maintainDTO.getLastMaintainTime()!=null) { |
| | | newDeviceMaintainList = deviceMaintainList.stream().filter(deviceMaintain -> deviceMaintain.getLastMaintainTime().equals(maintainDTO.getLastMaintainTime())) |
| | | .collect(Collectors.toList()); |
| | | }else{ |
| | | newDeviceMaintainList = deviceMaintainList; |
| | | } |
| | | PageInfo<DeviceMaintain> deviceMaintainPageInfo = new PageInfo<>(newDeviceMaintainList); |
| | | |
| | | return new Response().set(1,deviceMaintainPageInfo); |
| | | } |
| | | } |
| | |
| | | public Response add(DeviceManage deviceManage) { |
| | | //新增入库 |
| | | deviceManage.setStatus((byte) 1); |
| | | deviceManage.setCreateTime(new Date()); |
| | | mapper.insert(deviceManage); |
| | | return new Response().setMsg(1,"添加成功"); |
| | | } |
| | |
| | | <result property="firstTime" column="first_time"/> |
| | | <result property="reminderAheadUnit" column="reminder_ahead_unit"/> |
| | | <result property="reminderType" column="reminder_type"/> |
| | | <result property="lastMaintainTime" column="last_maintain_time"/> |
| | | <association property="deviceManage" javaType="DeviceManage" resultMap="DeviceManageResultMap" /> |
| | | </resultMap> |
| | | |
| | |
| | | WHERE |
| | | n.device_id = #{deviceId} |
| | | </select> |
| | | <select id="getPageByCondition2" resultType="com.whyc.pojo.DeviceMaintain"> |
| | | |
| | | <select id="getPageByCondition2" resultMap="DeviceMaintainResultMap"> |
| | | SELECT |
| | | m1.device_name, |
| | | m1.device_brand, |
| | | m1.device_version, |
| | | t.device_type_name, |
| | | t.device_type_id, |
| | | m1.device_id, |
| | | m1.useful_life, |
| | | m1.debug_time, |
| | | m1.site, |
| | | m1.OWNER, |
| | | m2.first_time, |
| | | m2.cycle, |
| | | DATE_SUB(IFNULL(temp.actual_time,m2.first_time),interval -m2.cycle MONTH) as "last_maintain_time" |
| | | FROM |
| | | ( |
| | | (db_experiment.tb_device_manage m1 INNER JOIN db_experiment.tb_device_maintain m2 ON m1.device_id = m2.device_id |
| | | <if test="createTime != null"> |
| | | AND m1.first_time=#{createTime} |
| | | </if> |
| | | <if test="deviceTypeId != null"> |
| | | AND m1.device_type_id =#{deviceTypeId} |
| | | </if> |
| | | <if test="site != null"> |
| | | AND m1.site =#{site} |
| | | </if> |
| | | ) |
| | | INNER JOIN db_experiment.tb_device_type t ON m1.device_type_id = t.device_type_id |
| | | ) |
| | | LEFT JOIN |
| | | ( |
| | | SELECT |
| | | * |
| | | FROM |
| | | ( SELECT device_id, actual_time FROM db_experiment.tb_device_maintain WHERE is_plan = 0 ORDER BY device_id, actual_time DESC ) t |
| | | GROUP BY |
| | | t.device_id |
| | | ) temp ON temp.device_id = m1.device_id |
| | | WHERE |
| | | m2.is_plan = 1 |
| | | </select> |
| | | </mapper> |