| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.DeviceMaintainDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.DeviceMaintain; |
| | | import com.whyc.service.DeviceMaintainService; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * 这里维保计划创建后, |
| | | * 存在首次维保时间和维保周期,从理论上来说,创建了一次维保计划后是永久循环生效的,计划维保时间一次次按周期推 |
| | | * 从表结构上说,存在维保计划表和维保记录表; |
| | | * |
| | | * demo,采取一张表进行功能实现 |
| | | * |
| | | */ |
| | | |
| | | @RestController |
| | | @RequestMapping("deviceMaintain") |
| | |
| | | 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 = "查询") |
| | | @ApiOperation(value = "查询计划") |
| | | public Response get(@RequestParam Integer deviceId){ |
| | | return service.get(deviceId); |
| | | } |
| | | |
| | | @PostMapping |
| | | @ApiOperation(value = "创建") |
| | | @ApiOperation(value = "创建计划") |
| | | public Response add(@RequestBody DeviceMaintain deviceMaintain){ |
| | | return service.add(deviceMaintain); |
| | | } |
| | | |
| | | @PutMapping |
| | | @ApiOperation(value = "修改") |
| | | @ApiOperation(value = "修改计划") |
| | | public Response update(@RequestBody DeviceMaintain deviceMaintain){ |
| | | return service.update(deviceMaintain); |
| | | } |
| | |
| | | } |
| | | |
| | | @GetMapping("record") |
| | | @ApiOperation(value = "查询维保记录") |
| | | @ApiOperation(value = "查询记录") |
| | | public Response getRecord(@RequestParam Integer deviceId){ |
| | | return service.getRecord(deviceId); |
| | | } |
New file |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | private Integer num; |
| | | @TableId(type = IdType.INPUT) |
| | | private Integer deviceId; |
| | | /**设备在库信息*/ |
| | | @TableField(exist = false) |
| | | private DeviceManage deviceManage; |
| | | /**维护厂家*/ |
| | | private String owner; |
| | | /**维护人员*/ |
| | |
| | | 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; |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | |
| | | 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); |
| | | } |
| | |
| | | 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); |
| | | } |
| | | } |
New file |
| | |
| | | <?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> |
| | |
| | | </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"/> |
| | |
| | | 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 |