增加 保养计划
parent
c584701c32
commit
67955cae03
@ -0,0 +1,93 @@
|
||||
package com.glxp.api.controller.dev;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import com.glxp.api.controller.BaseController;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepQuery;
|
||||
import com.glxp.api.res.PageSimpleResponse;
|
||||
import com.glxp.api.service.dev.DeviceUpkeepService;
|
||||
import com.glxp.api.vo.dev.DeviceCheckPrintVo;
|
||||
import com.glxp.api.vo.dev.DeviceUpkeepPrintVo;
|
||||
import com.glxp.api.vo.dev.DeviceUpkeepVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@RequestMapping
|
||||
public class DeviceUpkeepController extends BaseController {
|
||||
|
||||
private final DeviceUpkeepService deviceUpkeepService;
|
||||
|
||||
/**
|
||||
* 保养任务单列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udi/device/upkeep/page")
|
||||
public BaseResponse page(@RequestBody DeviceUpkeepQuery query) {
|
||||
List<DeviceUpkeepVo> list = deviceUpkeepService.pageList(query);
|
||||
PageInfo pageInfo = new PageInfo<>(list);
|
||||
PageSimpleResponse page = new PageSimpleResponse();
|
||||
page.setTotal(pageInfo.getTotal());
|
||||
page.setList(pageInfo.getList());
|
||||
return ResultVOUtils.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本部门巡检任务单列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
// */
|
||||
// @AuthRuleAnnotation("")
|
||||
// @PostMapping("/udi/device/check/pageByDept")
|
||||
// public BaseResponse pageByDept(@RequestBody DeviceCheckQuery query) {
|
||||
// AuthAdmin user = super.getUser();
|
||||
// query.setChargeDeptCode(user.getLocDeptCode());
|
||||
// List<DeviceCheckVo> list = deviceCheckService.pageList(query);
|
||||
// PageInfo pageInfo = new PageInfo<>(list);
|
||||
// PageSimpleResponse page = new PageSimpleResponse();
|
||||
// page.setTotal(pageInfo.getTotal());
|
||||
// page.setList(pageInfo.getList());
|
||||
// return ResultVOUtils.success(page);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 根据计划id生成巡检任务单
|
||||
*
|
||||
* @param planId 计划id
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udi/device/upkeep/gen/{planId}")
|
||||
public BaseResponse genDeviceUpkeep(@PathVariable Long planId) {
|
||||
AuthAdmin user = super.getUser();
|
||||
deviceUpkeepService.genByPlanId(planId, false, user);
|
||||
return ResultVOUtils.successMsg("操作成功");
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udi/device/upkeep/info/print/{taskId}")
|
||||
public BaseResponse checkInfoPrint(@PathVariable Long taskId) {
|
||||
DeviceUpkeepPrintVo vo = deviceUpkeepService.checkInfoPrint(taskId, null);
|
||||
return ResultVOUtils.success(vo);
|
||||
}
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udi/device/upkeep/info/print/{taskId}/{deviceCode}")
|
||||
public BaseResponse checkInfoPrint(@PathVariable Long taskId, @PathVariable String deviceCode) {
|
||||
DeviceUpkeepPrintVo vo = deviceUpkeepService.checkInfoPrint(taskId, deviceCode);
|
||||
return ResultVOUtils.success(vo);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.glxp.api.controller.dev;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import com.glxp.api.controller.BaseController;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.*;
|
||||
import com.glxp.api.req.dev.*;
|
||||
import com.glxp.api.res.PageSimpleResponse;
|
||||
import com.glxp.api.service.dev.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@RequestMapping
|
||||
public class DeviceUpkeepDetailController extends BaseController {
|
||||
|
||||
|
||||
private final DeviceUpkeepDetailService deviceUpkeepDetailService;
|
||||
|
||||
private final DevicePlanService devicePlanService;
|
||||
|
||||
private final DeviceInfoService deviceInfoService;
|
||||
private final DevicePlanDetailService devicePlanDetailService;
|
||||
private final DeviceUpkeepDetailItemService deviceUpkeepDetailItemService;
|
||||
/**
|
||||
* 保养任务单明细列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udi/device/upkeep/detail/page")
|
||||
public BaseResponse page(@RequestBody @Valid DeviceUpkeepDetailQuery query) {
|
||||
List<DeviceUpkeepDetailEntity> list = deviceUpkeepDetailService.pageList(query);
|
||||
PageInfo pageInfo = new PageInfo<>(list);
|
||||
PageSimpleResponse page = new PageSimpleResponse();
|
||||
page.setTotal(pageInfo.getTotal());
|
||||
page.setList(pageInfo.getList());
|
||||
return ResultVOUtils.success(page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设备保养计划明细新增
|
||||
*
|
||||
* @param param 参数
|
||||
* @return 计划id
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udi/device/upkeep/detail/add")
|
||||
public BaseResponse add(@RequestBody @Valid DevicePlanDetailParam param) {
|
||||
|
||||
|
||||
DevicePlanEntity entity = null;
|
||||
if (!param.valid(devicePlanService)) {
|
||||
AuthAdmin user = super.getUser();
|
||||
entity = param.getDevicePlanParam().getEntity(user);
|
||||
devicePlanService.save(entity);
|
||||
param.getDevicePlanParam().setPlanId(entity.getPlanId());
|
||||
param.setPlanId(entity.getPlanId());
|
||||
} else {
|
||||
entity = devicePlanService.getById(param.getPlanId());
|
||||
}
|
||||
param.valid(devicePlanService);
|
||||
List<DevicePlanDetailEntity> list = param.getEntity(deviceInfoService);
|
||||
devicePlanDetailService.replaceBatch(list);
|
||||
return ResultVOUtils.success(entity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package com.glxp.api.controller.dev;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.glxp.api.annotation.AuthRuleAnnotation;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import com.glxp.api.controller.BaseController;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.DeviceCheckDetailItemEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailItemEntity;
|
||||
import com.glxp.api.req.dev.DeviceCheckDetailItemFinishParam;
|
||||
import com.glxp.api.req.dev.DeviceCheckDetailItemQuery;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepDetailItemFinishParam;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepDetailItemQuery;
|
||||
import com.glxp.api.res.PageSimpleResponse;
|
||||
import com.glxp.api.service.dev.DeviceCheckDetailItemService;
|
||||
import com.glxp.api.service.dev.DeviceUpkeepDetailItemService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备巡检单明细
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
@RequestMapping
|
||||
public class DeviceUpkeepDetailItemController extends BaseController {
|
||||
|
||||
private final DeviceUpkeepDetailItemService deviceUpkeepDetailItemService;
|
||||
|
||||
/**
|
||||
* 巡检任务单明细项目列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* 保养任务单明细项目列表
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udi/device/upkeep/detail/item/page")
|
||||
public BaseResponse page(@RequestBody @Valid DeviceUpkeepDetailItemQuery query) {
|
||||
List<DeviceUpkeepDetailItemEntity> list = deviceUpkeepDetailItemService.pageList(query);
|
||||
PageInfo pageInfo = new PageInfo<>(list);
|
||||
PageSimpleResponse page = new PageSimpleResponse();
|
||||
page.setTotal(pageInfo.getTotal());
|
||||
page.setList(pageInfo.getList());
|
||||
return ResultVOUtils.success(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成巡检任务单明细项目
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udi/device/upkeep/detail/item/finish")
|
||||
public BaseResponse page(@RequestBody @Valid DeviceUpkeepDetailItemFinishParam param) {
|
||||
AuthAdmin user = super.getUser();
|
||||
deviceUpkeepDetailItemService.finish(param, user);
|
||||
return ResultVOUtils.successMsg("操作成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.glxp.api.dao.dev;
|
||||
|
||||
import com.glxp.api.dao.BaseMapperPlus;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailItemEntity;
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep_detail_item(设备保养项目)】的数据库操作Mapper
|
||||
*/
|
||||
public interface DeviceUpkeepDetailItemMapper extends BaseMapperPlus<DeviceUpkeepDetailItemMapper, DeviceUpkeepDetailItemEntity,DeviceUpkeepDetailItemEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.glxp.api.dao.dev;
|
||||
|
||||
import com.glxp.api.dao.BaseMapperPlus;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailEntity;
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep_detail(保养任务明细)】的数据库操作Mapper
|
||||
*/
|
||||
public interface DeviceUpkeepDetailMapper extends BaseMapperPlus<DeviceUpkeepDetailMapper, DeviceUpkeepDetailEntity,DeviceUpkeepDetailEntity> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.glxp.api.dao.dev;
|
||||
|
||||
import com.glxp.api.dao.BaseMapperPlus;
|
||||
import com.glxp.api.entity.dev.DeviceCheckEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepEntity;
|
||||
import com.glxp.api.req.dev.DeviceCheckQuery;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepQuery;
|
||||
import com.glxp.api.vo.dev.DeviceCheckVo;
|
||||
import com.glxp.api.vo.dev.DeviceUpkeepVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep(保养任务表)】的数据库操作Mapper
|
||||
*/
|
||||
public interface DeviceUpkeepMapper extends BaseMapperPlus<DeviceUpkeepMapper, DeviceUpkeepEntity,DeviceUpkeepEntity> {
|
||||
|
||||
List<DeviceUpkeepVo> pageVo(DeviceUpkeepQuery query);
|
||||
|
||||
|
||||
DeviceUpkeepVo getVoById(@Param("taskId") Long taskId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,192 @@
|
||||
package com.glxp.api.entity.dev;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 巡检任务明细
|
||||
*
|
||||
* @TableName device_upkeep_detail
|
||||
*/
|
||||
@TableName(value = "device_upkeep_detail")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class DeviceUpkeepDetailEntity {
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
@TableField(value = "taskId")
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@TableField(value = "deviceCode")
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 部门编码
|
||||
*/
|
||||
@TableField(value = "deptCode")
|
||||
private String deptCode;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@TableField(value = "deptName")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 是否完成
|
||||
*/
|
||||
@TableField(value = "finishFlag")
|
||||
private Boolean finishFlag;
|
||||
|
||||
/**
|
||||
* 产品id
|
||||
*/
|
||||
@TableField(value = "productId")
|
||||
private Long productId;
|
||||
|
||||
/**
|
||||
* UDI码
|
||||
*/
|
||||
@TableField(value = "udi")
|
||||
private String udi;
|
||||
|
||||
/**
|
||||
* DI码
|
||||
*/
|
||||
@TableField(value = "nameCode")
|
||||
private String nameCode;
|
||||
|
||||
/**
|
||||
* 产品名称
|
||||
*/
|
||||
@TableField(value = "productName")
|
||||
private String productName;
|
||||
|
||||
/**
|
||||
* 规格型号
|
||||
*/
|
||||
@TableField(value = "ggxh")
|
||||
private String ggxh;
|
||||
|
||||
/**
|
||||
* 批次号
|
||||
*/
|
||||
@TableField(value = "batchNo")
|
||||
private String batchNo;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
@TableField(value = "serialNo")
|
||||
private String serialNo;
|
||||
|
||||
/**
|
||||
* 生产日期
|
||||
*/
|
||||
@TableField(value = "productionDate")
|
||||
private String productionDate;
|
||||
|
||||
/**
|
||||
* 失效日期
|
||||
*/
|
||||
@TableField(value = "expireDate")
|
||||
private String expireDate;
|
||||
|
||||
/**
|
||||
* 生产厂家
|
||||
*/
|
||||
@TableField(value = "manufactory")
|
||||
private String manufactory;
|
||||
|
||||
/**
|
||||
* 计量单位
|
||||
*/
|
||||
@TableField(value = "measname")
|
||||
private String measname;
|
||||
|
||||
/**
|
||||
* 注册/备案凭证号
|
||||
*/
|
||||
@TableField(value = "zczbhhzbapzbh")
|
||||
private String zczbhhzbapzbh;
|
||||
|
||||
/**
|
||||
* 供应商ID
|
||||
*/
|
||||
@TableField(value = "supId")
|
||||
private String supId;
|
||||
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
@TableField(value = "supName")
|
||||
private String supName;
|
||||
|
||||
/**
|
||||
* 巡检项目数量
|
||||
*/
|
||||
@TableField(value = "itemCount")
|
||||
private Integer itemCount;
|
||||
|
||||
/**
|
||||
* 完成项目数量
|
||||
*/
|
||||
@TableField(value = "finishCount")
|
||||
private Integer finishCount;
|
||||
|
||||
/**
|
||||
* 异常项目数量
|
||||
*/
|
||||
@TableField(value = "exceptionCount")
|
||||
private Integer exceptionCount;
|
||||
|
||||
/**
|
||||
* 完成时间
|
||||
*/
|
||||
@TableField(value = "finishTime")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
/**
|
||||
* 维修单id
|
||||
*/
|
||||
// @TableField(value = "repairId")
|
||||
// private Long repairId;
|
||||
|
||||
/**
|
||||
* 巡检建议
|
||||
*/
|
||||
@TableField(value = "suggestion")
|
||||
private String suggestion;
|
||||
/**
|
||||
* 现场照片
|
||||
*/
|
||||
@TableField(value = "livePath")
|
||||
private String livePath;
|
||||
/**
|
||||
* 正常标识
|
||||
*/
|
||||
@TableField(value = "normalFlag")
|
||||
private Boolean normalFlag;
|
||||
|
||||
|
||||
/**
|
||||
* 更改时间
|
||||
*/
|
||||
@TableField(value = "updateTime")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.glxp.api.entity.dev;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 设备保养项目
|
||||
*
|
||||
* @TableName device_upkeep_detail_item
|
||||
*/
|
||||
@TableName(value = "device_upkeep_detail_item")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class DeviceUpkeepDetailItemEntity {
|
||||
/**
|
||||
* 任务id
|
||||
*/
|
||||
@TableField(value = "taskId")
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 设备编码
|
||||
*/
|
||||
@TableField(value = "deviceCode")
|
||||
private String deviceCode;
|
||||
|
||||
/**
|
||||
* 项目编码
|
||||
*/
|
||||
@TableField(value = "itemCode")
|
||||
private String itemCode;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@TableField(value = "itemName")
|
||||
private String itemName;
|
||||
|
||||
/**
|
||||
* 项目内容
|
||||
*/
|
||||
@TableField(value = "itemContent")
|
||||
private String itemContent;
|
||||
|
||||
/**
|
||||
* 正常标识
|
||||
*/
|
||||
@TableField(value = "normalFlag")
|
||||
private Boolean normalFlag;
|
||||
|
||||
|
||||
/**
|
||||
* 项目完成标识
|
||||
*/
|
||||
@TableField(value = "finishFlag")
|
||||
private Boolean finishFlag;
|
||||
|
||||
|
||||
/**
|
||||
* 项目完成时间
|
||||
*/
|
||||
@TableField(value = "finishTime")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
/**
|
||||
* 保养建议
|
||||
*/
|
||||
@TableField(value = "suggestion")
|
||||
private String suggestion;
|
||||
|
||||
/**
|
||||
* 保养人id
|
||||
*/
|
||||
@TableField(value = "upkeepUserId")
|
||||
private Long upkeepUserId;
|
||||
|
||||
/**
|
||||
* 保养人姓名
|
||||
*/
|
||||
@TableField(value = "upkeepUserName")
|
||||
private String upkeepUserName;
|
||||
|
||||
/**
|
||||
* 保养部门
|
||||
*/
|
||||
@TableField(value = "upkeepDeptCode")
|
||||
private String upkeepDeptCode;
|
||||
|
||||
/**
|
||||
* 保养部门名称
|
||||
*/
|
||||
@TableField(value = "upkeepDeptName")
|
||||
private String upkeepDeptName;
|
||||
|
||||
/**
|
||||
* 更改时间
|
||||
*/
|
||||
@TableField(value = "updateTime")
|
||||
private LocalDateTime updateTime;
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package com.glxp.api.entity.dev;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 保养任务表
|
||||
*
|
||||
* @TableName device_upkeep
|
||||
*/
|
||||
@TableName(value = "device_upkeep")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class DeviceUpkeepEntity {
|
||||
/**
|
||||
* 保养任务id
|
||||
*/
|
||||
@TableId(value = "taskId")
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 计划id
|
||||
*/
|
||||
@TableField(value = "planId")
|
||||
private Long planId;
|
||||
|
||||
/**
|
||||
* 计划名称
|
||||
*/
|
||||
@TableField(value = "planName")
|
||||
private String planName;
|
||||
|
||||
/**
|
||||
* 负责部门编码
|
||||
*/
|
||||
@TableField(value = "chargeDeptCode")
|
||||
private String chargeDeptCode;
|
||||
|
||||
/**
|
||||
* 保养人id
|
||||
*/
|
||||
@TableField(value = "upkeepUserId")
|
||||
private Long upkeepUserId;
|
||||
|
||||
/**
|
||||
* 保养人姓名
|
||||
*/
|
||||
@TableField(value = "upkeepUserName")
|
||||
private String upkeepUserName;
|
||||
|
||||
/**
|
||||
* 保养人电话
|
||||
*/
|
||||
@TableField(value = "upkeepUserPhone")
|
||||
private String upkeepUserPhone;
|
||||
|
||||
/**
|
||||
* 设备数量
|
||||
*/
|
||||
@TableField(value = "deviceCount")
|
||||
private Integer deviceCount;
|
||||
|
||||
/**
|
||||
* 完成设备数量
|
||||
*/
|
||||
@TableField(value = "finishCount")
|
||||
private Integer finishCount;
|
||||
|
||||
/**
|
||||
* 异常设备数量
|
||||
*/
|
||||
@TableField(value = "exceptionCount")
|
||||
private Integer exceptionCount;
|
||||
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 任务备注
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 是否系统创建 1/true 是 0/false 否
|
||||
*/
|
||||
@TableField(value = "sysFlag")
|
||||
private Boolean sysFlag;
|
||||
|
||||
/**
|
||||
* 是否已完成 1/true 是 0/false 否
|
||||
*/
|
||||
@TableField(value = "finishFlag")
|
||||
private Boolean finishFlag;
|
||||
|
||||
/**
|
||||
* 完成时间
|
||||
*/
|
||||
@TableField(value = "finishTime")
|
||||
private LocalDateTime finishTime;
|
||||
|
||||
/**
|
||||
* 创建时间 updateTime
|
||||
*/
|
||||
@TableField(value = "createTime")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(value = "createUserId")
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人姓名
|
||||
*/
|
||||
@TableField(value = "createUserName")
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(value = "updateTime")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.glxp.api.req.dev;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeviceUpkeepDetailItemFinishParam {
|
||||
|
||||
@NotNull(message = "任务单标识不能为空")
|
||||
private Long taskId;
|
||||
|
||||
@NotBlank(message = "设备标识不能为空")
|
||||
private String deviceCode;
|
||||
|
||||
@NotNull(message = "项目标识不能为空")
|
||||
private String itemCode;
|
||||
|
||||
@NotNull(message = "请标记巡检状态")
|
||||
private Boolean normalFlag;
|
||||
|
||||
@NotBlank(message = "巡检意见不能为空")
|
||||
private String suggestion;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.glxp.api.req.dev;
|
||||
|
||||
import com.glxp.api.util.page.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
public class DeviceUpkeepDetailItemQuery extends ListPageRequest {
|
||||
|
||||
/**
|
||||
* 任务单标识
|
||||
*/
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
* 设备标识
|
||||
*/
|
||||
@NotBlank(message = "设备标识不能为空")
|
||||
private String deviceCode;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.glxp.api.req.dev;
|
||||
|
||||
import com.glxp.api.util.page.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
public class DeviceUpkeepDetailQuery extends ListPageRequest {
|
||||
|
||||
@NotNull(message = "任务单标识不能为空")
|
||||
private Long taskId;
|
||||
|
||||
private String deviceCode;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.glxp.api.req.dev;
|
||||
|
||||
import com.glxp.api.util.page.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceUpkeepQuery extends ListPageRequest {
|
||||
|
||||
String taskId;
|
||||
String chargeDeptCode;
|
||||
Boolean finishFlag;
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.glxp.api.service.dev;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.DeviceCheckDetailItemEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailItemEntity;
|
||||
import com.glxp.api.req.dev.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep_detail_item(设备保养项目)】的数据库操作Service
|
||||
*/
|
||||
public interface DeviceUpkeepDetailItemService extends IService<DeviceUpkeepDetailItemEntity> {
|
||||
|
||||
|
||||
List<DeviceUpkeepDetailItemEntity> listByTaskId(Long taskId, String deviceCode);
|
||||
|
||||
List<DeviceUpkeepDetailItemEntity> pageList(DeviceUpkeepDetailItemQuery query);
|
||||
|
||||
void finish(DeviceUpkeepDetailItemFinishParam param, AuthAdmin user);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.glxp.api.service.dev;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.DeviceCheckDetailEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailEntity;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepDetailQuery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep_detail(保养任务明细)】的数据库操作Service
|
||||
*/
|
||||
public interface DeviceUpkeepDetailService extends IService<DeviceUpkeepDetailEntity> {
|
||||
|
||||
|
||||
List<DeviceUpkeepDetailEntity> pageList(DeviceUpkeepDetailQuery query);
|
||||
|
||||
|
||||
|
||||
|
||||
List<DeviceUpkeepDetailEntity> listByTaskId(Long taskId, String deviceCode);
|
||||
DeviceUpkeepDetailEntity getOne(Long taskId, String deviceCode);
|
||||
|
||||
|
||||
void finishItem(Long taskId, String deviceCode, String deptCode, Boolean normalFlag, AuthAdmin user);
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.glxp.api.service.dev;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepEntity;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepQuery;
|
||||
import com.glxp.api.vo.dev.DeviceCheckPrintVo;
|
||||
import com.glxp.api.vo.dev.DeviceCheckVo;
|
||||
import com.glxp.api.vo.dev.DeviceUpkeepPrintVo;
|
||||
import com.glxp.api.vo.dev.DeviceUpkeepVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author : zhangsan
|
||||
* @date : 2024/5/12 15:16
|
||||
* @modyified By :
|
||||
*/
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep(保养任务表)】的数据库操作Service
|
||||
*/
|
||||
public interface DeviceUpkeepService extends IService<DeviceUpkeepEntity> {
|
||||
|
||||
List<DeviceUpkeepVo> pageList(DeviceUpkeepQuery query);
|
||||
|
||||
void genByPlanId(Long planId, boolean b, AuthAdmin user);
|
||||
|
||||
|
||||
|
||||
DeviceUpkeepPrintVo checkInfoPrint(Long taskId, String deviceCode);
|
||||
|
||||
void finishUpkeep(Long taskId, String deviceCode);
|
||||
|
||||
/**
|
||||
* 完成一个保养设备
|
||||
*
|
||||
* @param taskId 任务id
|
||||
* @param deviceCode 设备编码
|
||||
* @return
|
||||
*/
|
||||
// void finishDevice(Long taskId, String deviceCode);
|
||||
|
||||
// void finishUpkeep(String deviceCode, String deptCode, Long taskId, AuthAdmin user);
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package com.glxp.api.service.dev.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.glxp.api.dao.dev.DeviceUpkeepDetailItemMapper;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.*;
|
||||
import com.glxp.api.exception.JsonException;
|
||||
import com.glxp.api.req.dev.DeviceCheckDetailItemFinishParam;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepDetailItemFinishParam;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepDetailItemQuery;
|
||||
import com.glxp.api.service.dev.DeviceUpkeepDetailItemService;
|
||||
import com.glxp.api.service.dev.DeviceUpkeepDetailService;
|
||||
import com.glxp.api.service.dev.DeviceUpkeepService;
|
||||
import com.glxp.api.util.IntUtil;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【device_Upkeep_detail_item(设备保养项目)】的数据库操作Service实现
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceUpkeepDetailItemServiceImpl extends ServiceImpl<DeviceUpkeepDetailItemMapper, DeviceUpkeepDetailItemEntity>
|
||||
implements DeviceUpkeepDetailItemService {
|
||||
|
||||
@Resource
|
||||
DeviceUpkeepService deviceUpkeepService;
|
||||
@Resource
|
||||
DeviceUpkeepDetailService deviceUpkeepDetailService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<DeviceUpkeepDetailItemEntity> listByTaskId(Long taskId, String deviceCode) {
|
||||
List<DeviceUpkeepDetailItemEntity> list = super.list(Wrappers.lambdaQuery(DeviceUpkeepDetailItemEntity.class)
|
||||
.eq(DeviceUpkeepDetailItemEntity::getTaskId, taskId)
|
||||
.eq(deviceCode != null, DeviceUpkeepDetailItemEntity::getDeviceCode, deviceCode)
|
||||
.orderByAsc(DeviceUpkeepDetailItemEntity::getDeviceCode, DeviceUpkeepDetailItemEntity::getItemCode)
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceUpkeepDetailItemEntity> pageList(DeviceUpkeepDetailItemQuery query) {
|
||||
List<DeviceUpkeepDetailItemEntity> list = super.list(Wrappers.lambdaQuery(DeviceUpkeepDetailItemEntity.class)
|
||||
.eq(DeviceUpkeepDetailItemEntity::getTaskId, query.getTaskId())
|
||||
.eq(DeviceUpkeepDetailItemEntity::getDeviceCode, query.getDeviceCode())
|
||||
.orderByAsc(DeviceUpkeepDetailItemEntity::getFinishFlag, DeviceUpkeepDetailItemEntity::getNormalFlag, DeviceUpkeepDetailItemEntity::getDeviceCode, DeviceUpkeepDetailItemEntity::getItemCode)
|
||||
);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finish(DeviceUpkeepDetailItemFinishParam param, AuthAdmin user) {
|
||||
DeviceUpkeepEntity upkeepEntity = deviceUpkeepService.getById(param.getTaskId());
|
||||
if (upkeepEntity == null) {
|
||||
return;
|
||||
}
|
||||
// DeviceUpkeepDetailEntity detailEntity = deviceUpkeepDetailService.getOne(param.getTaskId(), param.getDeviceCode());
|
||||
//// DeviceCheckDetailEntity detailEntity = deviceCheckDetailService.getOne(param.getTaskId(), param.getDeviceCode());
|
||||
|
||||
DeviceUpkeepDetailEntity detailEntity = deviceUpkeepDetailService.getOne(param.getTaskId(), param.getDeviceCode());
|
||||
if (detailEntity == null) {
|
||||
return;
|
||||
}
|
||||
boolean updated = super.update(Wrappers.lambdaUpdate(DeviceUpkeepDetailItemEntity.class)
|
||||
.set(DeviceUpkeepDetailItemEntity::getFinishFlag, true)
|
||||
.set(DeviceUpkeepDetailItemEntity::getFinishTime, LocalDateTime.now())
|
||||
.set(DeviceUpkeepDetailItemEntity::getSuggestion, param.getSuggestion())
|
||||
.set(DeviceUpkeepDetailItemEntity::getNormalFlag, param.getNormalFlag())
|
||||
.set(DeviceUpkeepDetailItemEntity::getUpkeepUserId, user.getId())
|
||||
.set(DeviceUpkeepDetailItemEntity::getUpkeepUserName, user.getEmployeeName())
|
||||
.set(DeviceUpkeepDetailItemEntity::getUpkeepDeptCode, user.getLocDeptCode())
|
||||
.set(DeviceUpkeepDetailItemEntity::getUpkeepDeptName, user.getDeptName())
|
||||
.set(DeviceUpkeepDetailItemEntity::getUpdateTime,LocalDateTime.now())
|
||||
.eq(DeviceUpkeepDetailItemEntity::getTaskId, param.getTaskId())
|
||||
.eq(DeviceUpkeepDetailItemEntity::getDeviceCode, param.getDeviceCode())
|
||||
.eq(DeviceUpkeepDetailItemEntity::getItemCode, param.getItemCode())
|
||||
.eq(DeviceUpkeepDetailItemEntity::getFinishFlag, false)
|
||||
);
|
||||
if (updated) {
|
||||
deviceUpkeepDetailService.finishItem(param.getTaskId(), param.getDeviceCode(), detailEntity.getDeptCode(), param.getNormalFlag(), user);
|
||||
} else {
|
||||
throw new JsonException("操作失败,该项目可能已经被其他人完成,请刷新重试");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,100 @@
|
||||
package com.glxp.api.service.dev.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.dao.dev.DeviceUpkeepDetailMapper;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.DeviceCheckDetailEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailEntity;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepDetailQuery;
|
||||
import com.glxp.api.service.dev.*;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep_detail(保养任务明细)】的数据库操作Service实现
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceUpkeepDetailServiceImpl extends ServiceImpl<DeviceUpkeepDetailMapper, DeviceUpkeepDetailEntity>
|
||||
implements DeviceUpkeepDetailService {
|
||||
|
||||
final DeviceUpkeepService deviceUpkeepService;
|
||||
final DeviceInfoService deviceInfoService;
|
||||
|
||||
@Override
|
||||
public List<DeviceUpkeepDetailEntity> pageList(DeviceUpkeepDetailQuery query) {
|
||||
if (query.getPage() != null) {
|
||||
PageHelper.startPage(query.getPage(), query.getLimit());
|
||||
}
|
||||
List<DeviceUpkeepDetailEntity> list = super.list(Wrappers.lambdaQuery(DeviceUpkeepDetailEntity.class)
|
||||
.eq(DeviceUpkeepDetailEntity::getTaskId, query.getTaskId())
|
||||
.eq(StrUtil.isNotBlank(query.getDeviceCode()), DeviceUpkeepDetailEntity::getDeviceCode, query.getDeviceCode())
|
||||
.orderBy(true, true, DeviceUpkeepDetailEntity::getFinishFlag)
|
||||
.orderBy(true, false, DeviceUpkeepDetailEntity::getExceptionCount)
|
||||
.orderBy(true, true, DeviceUpkeepDetailEntity::getDeptCode)
|
||||
.orderBy(true, true, DeviceUpkeepDetailEntity::getFinishTime)
|
||||
.orderBy(true, true, DeviceUpkeepDetailEntity::getDeptCode)
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceUpkeepDetailEntity> listByTaskId(Long taskId, String deviceCode) {
|
||||
List<DeviceUpkeepDetailEntity> list = super.list(Wrappers.lambdaQuery(DeviceUpkeepDetailEntity.class)
|
||||
.eq(DeviceUpkeepDetailEntity::getTaskId, taskId)
|
||||
.eq(deviceCode != null, DeviceUpkeepDetailEntity::getDeviceCode, deviceCode)
|
||||
.orderByAsc(DeviceUpkeepDetailEntity::getDeptCode, DeviceUpkeepDetailEntity::getDeviceCode)
|
||||
);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceUpkeepDetailEntity getOne(Long taskId, String deviceCode) {
|
||||
return super.getOne(Wrappers.lambdaQuery(DeviceUpkeepDetailEntity.class)
|
||||
.eq(DeviceUpkeepDetailEntity::getTaskId, taskId)
|
||||
.eq(DeviceUpkeepDetailEntity::getDeviceCode, deviceCode)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishItem(Long taskId, String deviceCode, String deptCode, Boolean normalFlag, AuthAdmin user) {
|
||||
boolean updated = super.update(Wrappers.lambdaUpdate(DeviceUpkeepDetailEntity.class)
|
||||
.setSql("finishCount = finishCount + 1")
|
||||
.setSql(!normalFlag, "exceptionCount = exceptionCount + 1")
|
||||
.eq(DeviceUpkeepDetailEntity::getTaskId, taskId)
|
||||
.eq(DeviceUpkeepDetailEntity::getDeviceCode, deviceCode)
|
||||
.last("and finishCount+1<=itemCount")
|
||||
);
|
||||
if (updated) {
|
||||
updated = super.update(Wrappers.lambdaUpdate(DeviceUpkeepDetailEntity.class)
|
||||
.set(DeviceUpkeepDetailEntity::getFinishFlag, true)
|
||||
.set(DeviceUpkeepDetailEntity::getFinishTime, LocalDateTime.now())
|
||||
.set(DeviceUpkeepDetailEntity::getUpdateTime, LocalDateTime.now())
|
||||
.eq(DeviceUpkeepDetailEntity::getTaskId, taskId)
|
||||
.eq(DeviceUpkeepDetailEntity::getDeviceCode, deviceCode)
|
||||
.last("and finishCount = itemCount")
|
||||
);
|
||||
if (updated) {
|
||||
// 所有项目全部完成。。。修改任务单完成设备 and 关闭设备的巡检锁
|
||||
deviceUpkeepService.finishUpkeep(taskId, deviceCode);
|
||||
deviceInfoService.finishCheck(deviceCode, deptCode, taskId, user);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,215 @@
|
||||
package com.glxp.api.service.dev.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.dao.dev.DeviceUpkeepMapper;
|
||||
import com.glxp.api.entity.auth.AuthAdmin;
|
||||
import com.glxp.api.entity.dev.*;
|
||||
import com.glxp.api.enums.dev.DeviceStatusEnum;
|
||||
import com.glxp.api.exception.JsonException;
|
||||
import com.glxp.api.req.dev.DeviceUpkeepQuery;
|
||||
import com.glxp.api.service.dev.*;
|
||||
import com.glxp.api.util.SnowflakeUtil;
|
||||
import com.glxp.api.vo.dev.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author : zhangsan
|
||||
* @date : 2024/5/12 15:19
|
||||
* @modyified By :
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 针对表【device_upkeep(保养任务表)】的数据库操作Service
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceUpkeepServiceImpl extends ServiceImpl<DeviceUpkeepMapper, DeviceUpkeepEntity>
|
||||
implements DeviceUpkeepService {
|
||||
|
||||
|
||||
@Resource
|
||||
DevicePlanService devicePlanService;
|
||||
@Resource
|
||||
DeviceUpkeepDetailService deviceUpkeepDetailService;
|
||||
@Resource
|
||||
DevicePlanDetailItemService devicePlanDetailItemService;
|
||||
@Resource
|
||||
DeviceInfoService deviceInfoService;
|
||||
@Resource
|
||||
DeviceUpkeepDetailItemService deviceUpkeepDetailItemService;
|
||||
@Resource
|
||||
DevicePlanDetailService devicePlanDetailService;
|
||||
|
||||
private final ThreadPoolTaskExecutor taskExecutor;
|
||||
|
||||
@Override
|
||||
public List<DeviceUpkeepVo> pageList(DeviceUpkeepQuery query) {
|
||||
if (query.getPage() != null){
|
||||
PageHelper.startPage(query.getPage(),query.getLimit());
|
||||
}
|
||||
List<DeviceUpkeepVo> list = super.baseMapper.pageVo(query);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genByPlanId(Long planId, boolean b, AuthAdmin user) {
|
||||
DevicePlanEntity plan = devicePlanService.getById(planId);
|
||||
if (plan == null) {
|
||||
throw new JsonException("保养计划不存在");
|
||||
}
|
||||
List<DevicePlanDetailVo> planDetailList = devicePlanDetailService.listByPlanId(planId);
|
||||
if (CollectionUtil.isEmpty(planDetailList)) {
|
||||
throw new JsonException("计划保养产品为空,不创建任务单");
|
||||
}
|
||||
List<DevicePlanDetailItemEntity> itemList = devicePlanDetailItemService.listByPlanId(planId);
|
||||
Map<String, List<DevicePlanDetailItemEntity>> itemMap = new HashMap<>();
|
||||
if (CollectionUtil.isNotEmpty(itemList)) {
|
||||
itemMap = itemList.stream().collect(Collectors.groupingBy(i -> i.getProductId() + "_" + i.getDeviceCode()));
|
||||
}
|
||||
|
||||
DeviceUpkeepEntity deviceUpkeepEntity = DeviceUpkeepEntity.builder()
|
||||
.taskId(SnowflakeUtil.getId())
|
||||
.planId(plan.getPlanId())
|
||||
.planName(plan.getName())
|
||||
.chargeDeptCode(plan.getChargeDeptCode())
|
||||
.name(plan.getName())
|
||||
.finishCount(0)
|
||||
.sysFlag(b)
|
||||
.createTime(LocalDateTime.now())
|
||||
.updateTime(LocalDateTime.now())
|
||||
.createUserId(b ? null : user.getId())
|
||||
.createUserName(b ? null : user.getEmployeeName())
|
||||
.build();
|
||||
|
||||
List<DeviceUpkeepDetailEntity> upkeepDetailList = new ArrayList<>();
|
||||
List<DeviceUpkeepDetailItemEntity> upkeepDetailItemList = new ArrayList<>();
|
||||
Map<String, List<DevicePlanDetailItemEntity>> finalItemMap = itemMap;
|
||||
planDetailList.forEach(d -> {
|
||||
List<DevicePlanDetailItemEntity> items = finalItemMap.get(d.getProductId() + "_" + d.getDeviceCode());
|
||||
if (CollectionUtil.isEmpty(items)) {
|
||||
items = new ArrayList<>();
|
||||
}
|
||||
List<DevicePlanDetailItemEntity> productItems = finalItemMap.get(d.getProductId() + "_");
|
||||
if (CollectionUtil.isNotEmpty(productItems)) {
|
||||
items.addAll(productItems);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(items)) {
|
||||
DeviceUpkeepDetailEntity detailEntity = DeviceUpkeepDetailEntity.builder()
|
||||
.taskId(deviceUpkeepEntity.getTaskId())
|
||||
.updateTime(LocalDateTime.now())
|
||||
.finishFlag(false)
|
||||
.build();
|
||||
BeanUtil.copyProperties(d, detailEntity);
|
||||
boolean opened = deviceInfoService.openCheckLock(d.getDeviceCode(), d.getDeptCode());
|
||||
if (opened) {
|
||||
items.forEach(item -> {
|
||||
DeviceUpkeepDetailItemEntity deviceCheckDetailItem = DeviceUpkeepDetailItemEntity.builder()
|
||||
.taskId(deviceUpkeepEntity.getTaskId())
|
||||
.deviceCode(d.getDeviceCode())
|
||||
.itemCode(item.getItemCode())
|
||||
.itemName(item.getName())
|
||||
.itemContent(item.getContent())
|
||||
.finishFlag(false)
|
||||
.updateTime(LocalDateTime.now())
|
||||
.build();
|
||||
// deviceCheckDetailItem.setUpdateTime(LocalDateTime.now());
|
||||
upkeepDetailItemList.add(deviceCheckDetailItem);
|
||||
});
|
||||
detailEntity.setItemCount(items.size());
|
||||
upkeepDetailList.add(detailEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (CollectionUtil.isNotEmpty(upkeepDetailList)) {
|
||||
devicePlanService.addExecCount(planId);
|
||||
deviceUpkeepEntity.setDeviceCount(upkeepDetailList.size());
|
||||
super.save(deviceUpkeepEntity);
|
||||
deviceUpkeepDetailService.saveBatch(upkeepDetailList);
|
||||
if (CollectionUtil.isNotEmpty(upkeepDetailItemList)) {
|
||||
deviceUpkeepDetailItemService.saveBatch(upkeepDetailItemList);
|
||||
}
|
||||
} else {
|
||||
throw new JsonException(String.format("没有配置保养项目 或者 没有找到处于[%s]状态的设备,无法生成保养单", DeviceStatusEnum.NORMAL.getDesc()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceUpkeepPrintVo checkInfoPrint(Long taskId, String deviceCode) {
|
||||
CompletableFuture<DeviceUpkeepVo> infoFuture = CompletableFuture.supplyAsync(() -> {
|
||||
return super.baseMapper.getVoById(taskId);
|
||||
}, taskExecutor);
|
||||
CompletableFuture<List<DeviceUpkeepDetailEntity>> detailFuture = CompletableFuture.supplyAsync(() -> {
|
||||
return deviceUpkeepDetailService.listByTaskId(taskId, deviceCode);
|
||||
}, taskExecutor);
|
||||
CompletableFuture<List<DeviceUpkeepDetailItemEntity>> detailItemFuture = CompletableFuture.supplyAsync(() -> {
|
||||
return deviceUpkeepDetailItemService.listByTaskId(taskId, deviceCode);
|
||||
}, taskExecutor);
|
||||
|
||||
try {
|
||||
CompletableFuture.allOf(detailItemFuture).get();
|
||||
DeviceUpkeepVo upkeepVo = infoFuture.get();
|
||||
List<DeviceUpkeepDetailEntity> details = detailFuture.get();
|
||||
List<DeviceUpkeepDetailItemEntity> items = detailItemFuture.get();
|
||||
if (upkeepVo == null || details == null || items == null) {
|
||||
throw new JsonException("任务单不存在");
|
||||
}
|
||||
List<DeviceUpkeepPrintVo.DetailVo> detailVos = BeanUtil.copyToList(details, DeviceUpkeepPrintVo.DetailVo.class);
|
||||
Map<String, List<DeviceUpkeepDetailItemEntity>> itemsMap = items.stream().collect(Collectors.groupingBy(DeviceUpkeepDetailItemEntity::getDeviceCode));
|
||||
detailVos.forEach(i -> {
|
||||
i.setDetailItems(itemsMap.get(i.getDeviceCode()));
|
||||
});
|
||||
DeviceUpkeepPrintVo vo = DeviceUpkeepPrintVo.builder()
|
||||
.printTime(LocalDateTime.now())
|
||||
.info(upkeepVo)
|
||||
.details(detailVos)
|
||||
.build();
|
||||
return vo;
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void finishUpkeep(Long taskId, String deviceCode) {
|
||||
boolean updated = super.update(Wrappers.lambdaUpdate(DeviceUpkeepEntity.class)
|
||||
.setSql("finishCount = finishCount + 1")
|
||||
.setSql(String.format("exceptionCount = exceptionCount + (select exceptionCount>0 from device_check_detail where taskId = %s and deviceCode = '%s')", taskId, deviceCode))
|
||||
.eq(DeviceUpkeepEntity::getTaskId, taskId)
|
||||
.last("and finishCount+1 <= deviceCount")
|
||||
);
|
||||
if (updated) {
|
||||
updated = super.update(Wrappers.lambdaUpdate(DeviceUpkeepEntity.class)
|
||||
.set(DeviceUpkeepEntity::getFinishFlag, true)
|
||||
.set(DeviceUpkeepEntity::getFinishTime, LocalDateTime.now())
|
||||
.set(DeviceUpkeepEntity::getUpdateTime,LocalDateTime.now())
|
||||
.eq(DeviceUpkeepEntity::getTaskId, taskId)
|
||||
.eq(DeviceUpkeepEntity::getFinishFlag, false)
|
||||
.last("and finishCount = deviceCount")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.glxp.api.vo.dev;
|
||||
|
||||
import com.glxp.api.entity.dev.DeviceCheckDetailEntity;
|
||||
import com.glxp.api.entity.dev.DeviceCheckDetailItemEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepDetailItemEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeviceUpkeepPrintVo {
|
||||
|
||||
LocalDateTime printTime;
|
||||
|
||||
DeviceUpkeepVo info;
|
||||
|
||||
List<DetailVo> details;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DetailVo extends DeviceCheckDetailEntity {
|
||||
public List<DeviceUpkeepDetailItemEntity> detailItems;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.glxp.api.vo.dev;
|
||||
|
||||
import com.glxp.api.entity.dev.DeviceCheckEntity;
|
||||
import com.glxp.api.entity.dev.DeviceUpkeepEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class DeviceUpkeepVo extends DeviceUpkeepEntity {
|
||||
|
||||
String chargeDeptName;
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
<?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.glxp.api.dao.dev.DeviceUpkeepMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.glxp.api.entity.dev.DeviceUpkeepEntity">
|
||||
<id property="taskId" column="taskId" jdbcType="BIGINT"/>
|
||||
<result property="planId" column="planId" jdbcType="BIGINT"/>
|
||||
<result property="planName" column="planName" jdbcType="VARCHAR"/>
|
||||
<result property="upkeepUserId" column="upkeepUserId" jdbcType="BIGINT"/>
|
||||
<result property="upkeepUserName" column="upkeepUserName" jdbcType="VARCHAR"/>
|
||||
<result property="upkeepUserPhone" column="upkeepUserPhone" jdbcType="VARCHAR"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="remark" column="remark" jdbcType="VARCHAR"/>
|
||||
<result property="sysFlag" column="sysFlag" jdbcType="BIT"/>
|
||||
<result property="createTime" column="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result property="createUserId" column="createUserId" jdbcType="BIGINT"/>
|
||||
<result property="createUserName" column="createUserName" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
taskId,planId,planName,
|
||||
upkeepUserId,upkeepUserName,upkeepUserPhone,
|
||||
name,remark,sysFlag,
|
||||
createTime,createUserId,createUserName
|
||||
</sql>
|
||||
<select id="pageVo" resultType="com.glxp.api.vo.dev.DeviceUpkeepVo">
|
||||
select c.*, d.name chargeDeptName
|
||||
from device_upkeep c
|
||||
left join auth_dept d on d.code = c.chargeDeptCode
|
||||
<where>
|
||||
<if test="taskId!=null">
|
||||
and c.taskId = #{taskId}
|
||||
</if>
|
||||
<if test="chargeDeptCode!=null and chargeDeptCode!=''">
|
||||
and c.chargeDeptCode = #{chargeDeptCode}
|
||||
</if>
|
||||
<if test="finishFlag!=null">
|
||||
and c.finishFlag = #{finishFlag}
|
||||
</if>
|
||||
</where>
|
||||
order by c.createTime desc
|
||||
</select>
|
||||
<select id="getVoById" resultType="com.glxp.api.vo.dev.DeviceUpkeepVo">
|
||||
select u.*, d.name chargeDeptName
|
||||
from device_upkeep u
|
||||
left join auth_dept d on d.code = u.chargeDeptCode
|
||||
where u.taskId = #{taskId}
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue