|
@@ -1436,12 +1436,19 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
order.setOrderNumber(createWorkOrderNumber());
|
|
|
order.setType(2);
|
|
|
order.setResult(2);
|
|
|
- // order.setActualStartTime(LocalDateTime.now());
|
|
|
- // order.setActualEndTime(LocalDateTime.now());
|
|
|
iotMainWorkOrderMapper.insert(order);
|
|
|
// 保养工单明细
|
|
|
+ Set<Long> bomNodeIds = new HashSet<>();
|
|
|
+ Set<Long> deviceIds = new HashSet<>();
|
|
|
+ Set<String> bomNodeNames = new HashSet<>();
|
|
|
+ // key设备id-保养项id value保养工单明细对象(包含累计公里/时长)
|
|
|
+ Map<String, IotMainWorkOrderBomSaveReqVO> bomAccumulatedValuePair = new HashMap<>();
|
|
|
+ // key设备id-保养项名称 value保养工单明细对象(包含累计公里/时长)
|
|
|
+ Map<String, IotMainWorkOrderBomSaveReqVO> bomNameAccumulatedValuePair = new HashMap<>();
|
|
|
List<IotMainWorkOrderBomDO> workOrderBomDOS = new ArrayList<>();
|
|
|
workOrderBOMs.forEach(bom -> {
|
|
|
+ bomAccumulatedValuePair.put(StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId()), bom);
|
|
|
+ bomNameAccumulatedValuePair.put(StrUtil.join("-", bom.getDeviceId(), bom.getName()), bom);
|
|
|
IotMainWorkOrderBomDO tempBom = BeanUtils.toBean(bom, IotMainWorkOrderBomDO.class);
|
|
|
tempBom.setWorkOrderId(order.getId());
|
|
|
tempBom.setLastRunningTime(bom.getTotalRunTime());
|
|
@@ -1450,8 +1457,63 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
tempBom.setDeviceCategoryId(bom.getAssetClass());
|
|
|
tempBom.setStatus(1);
|
|
|
workOrderBomDOS.add(tempBom);
|
|
|
+ bomNodeIds.add(bom.getBomNodeId());
|
|
|
+ deviceIds.add(bom.getDeviceId());
|
|
|
+ bomNodeNames.add(bom.getName());
|
|
|
});
|
|
|
iotMainWorkOrderBomMapper.insertBatch(workOrderBomDOS);
|
|
|
+ // 查找各保养项对应的保养计划中的保养项 根据保养计划中的保养规则 更新 上次保养里程 or 上次保养时长 or 上次保养时间
|
|
|
+ if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(bomNodeIds) && CollUtil.isNotEmpty(bomNodeNames)
|
|
|
+ && CollUtil.isNotEmpty(bomAccumulatedValuePair)) {
|
|
|
+ IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
|
|
|
+ reqVO.setDeviceIds(new ArrayList<>(deviceIds));
|
|
|
+ reqVO.setBomNodeIds(new ArrayList<>(bomNodeIds)); // 保养项id 可能变化 重新生成设备BOM
|
|
|
+ List<IotMaintenanceBomDO> planBomS = iotMaintenanceBomService.getIotMainPlanBomList(reqVO);
|
|
|
+ if (CollUtil.isNotEmpty(planBomS)) {
|
|
|
+ planBomS.forEach(bom -> {
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
+ if (bomAccumulatedValuePair.containsKey(uniqueKey)) {
|
|
|
+ IotMainWorkOrderBomSaveReqVO saveReqVO = bomAccumulatedValuePair.get(uniqueKey);
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0==bom.getRunningTimeRule()) {
|
|
|
+ bom.setLastRunningTime(saveReqVO.getTotalRunTime());
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0==bom.getMileageRule()) {
|
|
|
+ bom.setLastRunningKilometers(saveReqVO.getTotalMileage());
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0==bom.getNaturalDateRule()) {
|
|
|
+ bom.setLastNaturalDate(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 批量更新保养计划明细
|
|
|
+ iotMaintenanceBomMapper.updateBatch(planBomS);
|
|
|
+ }
|
|
|
+ // 根据保养项名称更新上次保养 公里数 时长
|
|
|
+ IotMaintenanceBomPageReqVO bomReqVO = new IotMaintenanceBomPageReqVO();
|
|
|
+ bomReqVO.setDeviceIds(new ArrayList<>(deviceIds));
|
|
|
+ bomReqVO.setBomNodeNames(new ArrayList<>(bomNodeNames)); // 保养项id 可能变化 重新生成设备BOM
|
|
|
+ List<IotMaintenanceBomDO> planBomNames = iotMaintenanceBomService.getIotMainPlanBomList(bomReqVO);
|
|
|
+ if (CollUtil.isNotEmpty(planBomNames)) {
|
|
|
+ planBomNames.forEach(bom -> {
|
|
|
+ String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getName());
|
|
|
+ if (bomNameAccumulatedValuePair.containsKey(uniqueKey)) {
|
|
|
+ IotMainWorkOrderBomSaveReqVO saveReqVO = bomNameAccumulatedValuePair.get(uniqueKey);
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0==bom.getRunningTimeRule()) {
|
|
|
+ bom.setLastRunningTime(saveReqVO.getTotalRunTime());
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0==bom.getMileageRule()) {
|
|
|
+ bom.setLastRunningKilometers(saveReqVO.getTotalMileage());
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0==bom.getNaturalDateRule()) {
|
|
|
+ bom.setLastNaturalDate(LocalDateTime.now());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 批量更新保养计划明细
|
|
|
+ iotMaintenanceBomMapper.updateBatch(planBomNames);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 保养工单 bom 明细关联的物料消耗
|
|
|
List<IotMainWorkOrderBomMaterialDO> workOrderBomMaterialDOS = new ArrayList<>();
|
|
|
Set<Long> factoryIds = new HashSet<>();
|
|
@@ -1495,6 +1557,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
reqVO.setCostCenterIds(costCenterIds);
|
|
|
reqVO.setMaterialCodes(materialCodes);
|
|
|
processLockStock(reqVO, lockStockPair);
|
|
|
+ // 记录出库
|
|
|
}
|
|
|
}
|
|
|
|