|
@@ -192,7 +192,7 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean processOrder(Long orderId, String handleResult, String solution, Long operUserId, String operUserName) {
|
|
|
|
|
|
|
+ public boolean processOrder(Long orderId, String handleResult, String solution, String maintenanceBeforeImg, Long operUserId, String operUserName) {
|
|
|
WorkOrder order = this.getById(orderId);
|
|
WorkOrder order = this.getById(orderId);
|
|
|
if (order == null) throw new ServiceException("工单不存在");
|
|
if (order == null) throw new ServiceException("工单不存在");
|
|
|
if (!Arrays.asList(3, 4).contains(order.getOrderStatus())) throw new ServiceException("当前工单状态不允许处理");
|
|
if (!Arrays.asList(3, 4).contains(order.getOrderStatus())) throw new ServiceException("当前工单状态不允许处理");
|
|
@@ -201,6 +201,9 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
entity.setOrderId(orderId);
|
|
entity.setOrderId(orderId);
|
|
|
entity.setOrderStatus(4);
|
|
entity.setOrderStatus(4);
|
|
|
entity.setRepairResult(solution);
|
|
entity.setRepairResult(solution);
|
|
|
|
|
+ if (StringUtils.isNotBlank(maintenanceBeforeImg)) {
|
|
|
|
|
+ entity.setMaintenanceBeforeImg(maintenanceBeforeImg);
|
|
|
|
|
+ }
|
|
|
this.updateById(entity);
|
|
this.updateById(entity);
|
|
|
|
|
|
|
|
// 工单处理中 → 同步隐患状态为"整改中"
|
|
// 工单处理中 → 同步隐患状态为"整改中"
|
|
@@ -219,7 +222,7 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean completeOrder(Long orderId, String result, Long operUserId, String operUserName) {
|
|
|
|
|
|
|
+ public boolean completeOrder(Long orderId, String result, String maintenanceAfterImg, Long operUserId, String operUserName) {
|
|
|
WorkOrder order = this.getById(orderId);
|
|
WorkOrder order = this.getById(orderId);
|
|
|
if (order == null) throw new ServiceException("工单不存在");
|
|
if (order == null) throw new ServiceException("工单不存在");
|
|
|
if (order.getOrderStatus() != 4)
|
|
if (order.getOrderStatus() != 4)
|
|
@@ -229,6 +232,9 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
entity.setOrderId(orderId);
|
|
entity.setOrderId(orderId);
|
|
|
entity.setOrderStatus(5);
|
|
entity.setOrderStatus(5);
|
|
|
entity.setRepairResult(result);
|
|
entity.setRepairResult(result);
|
|
|
|
|
+ if (StringUtils.isNotBlank(maintenanceAfterImg)) {
|
|
|
|
|
+ entity.setMaintenanceAfterImg(maintenanceAfterImg);
|
|
|
|
|
+ }
|
|
|
this.updateById(entity);
|
|
this.updateById(entity);
|
|
|
|
|
|
|
|
WorkOrderLog logEntry = new WorkOrderLog();
|
|
WorkOrderLog logEntry = new WorkOrderLog();
|
|
@@ -245,6 +251,9 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long createWorkOrderFromHazard(String hazardId, String hazardNo, String hazardDesc, String equipmentId, String hazardLevel, String hazardImages, Date planFinishTime) {
|
|
public Long createWorkOrderFromHazard(String hazardId, String hazardNo, String hazardDesc, String equipmentId, String hazardLevel, String hazardImages, Date planFinishTime) {
|
|
|
|
|
+ // 同一设备存在进行中工单(状态非 6 已结案/7 已驳回)时禁止重复建单
|
|
|
|
|
+ checkDeviceOrderConflict(equipmentId);
|
|
|
|
|
+
|
|
|
// 隐患等级映射到工单优先级:0-重大→紧急(1) 1-较大→一般(2) 2-一般→一般(2) 3-轻微→低(3)
|
|
// 隐患等级映射到工单优先级:0-重大→紧急(1) 1-较大→一般(2) 2-一般→一般(2) 3-轻微→低(3)
|
|
|
Integer orderLevel;
|
|
Integer orderLevel;
|
|
|
if ("0".equals(hazardLevel)) {
|
|
if ("0".equals(hazardLevel)) {
|
|
@@ -271,7 +280,10 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
workOrder.setOrderLevel(orderLevel);
|
|
workOrder.setOrderLevel(orderLevel);
|
|
|
workOrder.setOrderDesc(hazardDesc);
|
|
workOrder.setOrderDesc(hazardDesc);
|
|
|
workOrder.setOrderStatus(1); // 待派单
|
|
workOrder.setOrderStatus(1); // 待派单
|
|
|
- workOrder.setWorkImage(hazardImages);
|
|
|
|
|
|
|
+ // 隐患图片作为维修前图片(如有)
|
|
|
|
|
+ if (StringUtils.isNotEmpty(hazardImages)) {
|
|
|
|
|
+ workOrder.setMaintenanceBeforeImg(hazardImages);
|
|
|
|
|
+ }
|
|
|
workOrder.setPlanFinishTime(planFinishTime);
|
|
workOrder.setPlanFinishTime(planFinishTime);
|
|
|
workOrder.setCreateTime(new Date());
|
|
workOrder.setCreateTime(new Date());
|
|
|
this.save(workOrder);
|
|
this.save(workOrder);
|
|
@@ -291,6 +303,9 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long createWorkOrder(WorkOrder workOrder) {
|
|
public Long createWorkOrder(WorkOrder workOrder) {
|
|
|
|
|
+ // 同一设备存在进行中工单(状态非 6 已结案/7 已驳回)时禁止重复建单
|
|
|
|
|
+ checkDeviceOrderConflict(workOrder.getDeviceId());
|
|
|
|
|
+
|
|
|
if (workOrder.getOrderType() == null) {
|
|
if (workOrder.getOrderType() == null) {
|
|
|
workOrder.setOrderType(1);
|
|
workOrder.setOrderType(1);
|
|
|
}
|
|
}
|
|
@@ -321,6 +336,23 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
return workOrder.getOrderId();
|
|
return workOrder.getOrderId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 校验设备是否存在进行中工单(状态 1-5/8/9),存在则禁止再次创建工单
|
|
|
|
|
+ * 业务规则:同一设备同一时间只能有一个进行中的工单,结案(6)或驳回(7)后方可再次创建
|
|
|
|
|
+ */
|
|
|
|
|
+ private void checkDeviceOrderConflict(String deviceId) {
|
|
|
|
|
+ if (StringUtils.isEmpty(deviceId)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Long count = this.lambdaQuery()
|
|
|
|
|
+ .eq(WorkOrder::getDeviceId, deviceId)
|
|
|
|
|
+ .notIn(WorkOrder::getOrderStatus, 6, 7)
|
|
|
|
|
+ .count();
|
|
|
|
|
+ if (count > 0) {
|
|
|
|
|
+ throw new ServiceException("该设备已有处理中的工单,需结案或驳回后才能创建新工单");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 生成工单编号:WO-yyyyMMddHHmmssSSS
|
|
* 生成工单编号:WO-yyyyMMddHHmmssSSS
|
|
|
*/
|
|
*/
|
|
@@ -351,6 +383,30 @@ public class BusinessWorkOrderServiceImpl extends ServiceImpl<WorkOrderMapper, W
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ public boolean rejectOrder(Long orderId, String reason, Long operUserId, String operUserName) {
|
|
|
|
|
+ WorkOrder order = this.getById(orderId);
|
|
|
|
|
+ if (order == null) throw new ServiceException("工单不存在");
|
|
|
|
|
+ // 仅待派单/待接单可驳回,已流转的工单请使用取消
|
|
|
|
|
+ if (!Arrays.asList(1, 2).contains(order.getOrderStatus())) throw new ServiceException("当前工单状态不允许驳回");
|
|
|
|
|
+
|
|
|
|
|
+ WorkOrder entity = new WorkOrder();
|
|
|
|
|
+ entity.setOrderId(orderId);
|
|
|
|
|
+ entity.setOrderStatus(7);
|
|
|
|
|
+ this.updateById(entity);
|
|
|
|
|
+
|
|
|
|
|
+ WorkOrderLog logEntry = new WorkOrderLog();
|
|
|
|
|
+ logEntry.setOrderId(orderId);
|
|
|
|
|
+ logEntry.setOperType(7);
|
|
|
|
|
+ logEntry.setOperDesc("驳回工单,原因:" + (reason != null ? reason : ""));
|
|
|
|
|
+ logEntry.setOperUserId(operUserId);
|
|
|
|
|
+ logEntry.setOperUserName(operUserName);
|
|
|
|
|
+ logEntry.setOperTime(new Date());
|
|
|
|
|
+ workOrderLogMapper.insert(logEntry);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean closeOrder(Long orderId, String result, Long operUserId, String operUserName) {
|
|
public boolean closeOrder(Long orderId, String result, Long operUserId, String operUserName) {
|