|
|
@@ -1876,9 +1876,7 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
}
|
|
|
// 不是必填项:推迟保养;委外保养
|
|
|
List<IotMainWorkOrderBomMaterialSaveReqVO> workOrderMaterials = saveVO.getMainWorkOrderMaterials();
|
|
|
- /* if (ObjectUtil.isEmpty(workOrderMaterials)) {
|
|
|
- throw exception(IOT_MAIN_WORK_ORDER_NOT_EXISTS);
|
|
|
- } */
|
|
|
+
|
|
|
// 保养工单 主表 还有 保养费用 、人工费用 、其他费用
|
|
|
IotMainWorkOrderDO updateObj = BeanUtils.toBean(mainWorkOrder, IotMainWorkOrderDO.class);
|
|
|
|
|
|
@@ -1995,19 +1993,8 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
if (ObjUtil.isNotEmpty(bom.getStatus()) && 0 == bom.getStatus()) {
|
|
|
// 兼容保养工单中部分保养项保养完成 部分保养项 延期保养的情况 这里只更新延期保养 或正常 保养的物料
|
|
|
// 如果工单明细中任何一个保养项设置了 任何一种推迟保养规则 工单结果 不能设置为 已执行
|
|
|
- /* if (bom.getDelayKilometers().compareTo(BigDecimal.ZERO)>0
|
|
|
- || bom.getDelayDuration().compareTo(BigDecimal.ZERO)>0 || bom.getDelayNaturalDate().compareTo(BigDecimal.ZERO)>0) { */
|
|
|
tempBom.setStatus(0);
|
|
|
mainCompleted.set(false);
|
|
|
- // }
|
|
|
- /* if (bom.getDelayKilometers().compareTo(BigDecimal.ZERO)==0
|
|
|
- && bom.getDelayDuration().compareTo(BigDecimal.ZERO)==0 && bom.getDelayNaturalDate().compareTo(BigDecimal.ZERO)==0) {
|
|
|
- // 如果保养项没有设置延时保养 则查询当前设备的 累计运行公里数 累计运行时间 当前时间日期 赋值到 关联保养计划 明细 的 对应保养规则数据上
|
|
|
- deviceIds.add(bom.getDeviceId());
|
|
|
- // 保养项下如果已经添加了物料 说明该保养项已经保养完成
|
|
|
- bomNodeIds.add(bom.getBomNodeId());
|
|
|
- tempBom.setStatus(1);
|
|
|
- } */
|
|
|
}
|
|
|
if ((ObjUtil.isNotEmpty(bom.getStatus()) && 1 == bom.getStatus()) /* || bomMaterialsPair.containsKey(bom.getBomNodeId()) */) {
|
|
|
// 当前保养项已经保养完成 查询当前设备的 累计运行公里数 累计运行时间 当前时间日期 赋值到 关联保养计划 明细 的 对应保养规则数据上
|
|
|
@@ -2022,27 +2009,13 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
deviceBomPair.put(uniqueKey, bom);
|
|
|
}
|
|
|
workOrderBomDOS.add(tempBom);
|
|
|
-
|
|
|
- // 兼容APP未优化完的情况 所有保养项都设置了物料 设置保养工单 为 已执行
|
|
|
- /* if (!bomMaterialsPair.containsKey(bom.getBomNodeId())){
|
|
|
- // 存在未添加物料的保养项
|
|
|
- appCompleted.set(false);
|
|
|
- } */
|
|
|
});
|
|
|
if (CollUtil.isNotEmpty(workOrderBOMs)) {
|
|
|
// 组装bom关联的设备信息
|
|
|
- /* Map<Long, IotDeviceRespVO> deviceMap = iotDeviceService.getDeviceMap(convertListByFlatMap(workOrderBOMs,
|
|
|
- bom -> Stream.of(bom.getDeviceId())));
|
|
|
- if (CollUtil.isNotEmpty(deviceMap)) {
|
|
|
- deviceMap.forEach((k,v) -> {
|
|
|
- deviceCategoryIds.add(v.getAssetClass());
|
|
|
- deviceCategoryPair.put(k, v.getAssetClass());
|
|
|
- });
|
|
|
- } */
|
|
|
}
|
|
|
iotMainWorkOrderBomMapper.updateBatch(workOrderBomDOS);
|
|
|
// 只有工单明细中所有保养项的物料都选择完成,才会将工单结果设置为 ‘已执行’
|
|
|
- if (mainCompleted.get() /* || appCompleted.get() */) {
|
|
|
+ if (mainCompleted.get()) {
|
|
|
// 兼容APP未优化完成的情况 所有保养项都添加了物料 设置 保养工单 为 已执行
|
|
|
updateObj.setResult(2);
|
|
|
}
|
|
|
@@ -2062,22 +2035,22 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
boundedMultiAttrNames.add(bom.getType());
|
|
|
}
|
|
|
});
|
|
|
- /* List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
+ List<IotDeviceRunLogRespVO> multipleAccumulatedData = new ArrayList<>();
|
|
|
if (CollUtil.isNotEmpty(deviceIds) && CollUtil.isNotEmpty(boundedMultiAttrNames)) {
|
|
|
multipleAccumulatedData = iotDeviceRunLogService.multipleAccumulatedData(deviceIds, boundedMultiAttrNames, null);
|
|
|
- } */
|
|
|
+ }
|
|
|
// key(设备id-累计时长属性名称) value时长属性累计时长数值
|
|
|
- /* Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
+ Map<String, BigDecimal> tempTotalRunDataPair = new HashMap<>();
|
|
|
if (CollUtil.isNotEmpty(multipleAccumulatedData)) {
|
|
|
multipleAccumulatedData.forEach(data -> {
|
|
|
String uniqueKey = StrUtil.join("-", data.getDeviceId(), data.getPointName());
|
|
|
tempTotalRunDataPair.put(uniqueKey, data.getTotalRunTime());
|
|
|
});
|
|
|
- } */
|
|
|
+ }
|
|
|
|
|
|
// 单一累计属性集合
|
|
|
- /* Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
- new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null); */
|
|
|
+ Map<Long, IotDeviceRunLogRespVO> deviceRunLogMap = iotDeviceRunLogService.getDeviceRunLogMapAlone(new ArrayList<>(deviceIds),
|
|
|
+ new ArrayList<>(deviceCategoryIds), deviceCategoryPair, null);
|
|
|
// 查询保养工单关联的保养计划 明细
|
|
|
IotMaintenanceBomPageReqVO reqVO = new IotMaintenanceBomPageReqVO();
|
|
|
reqVO.setPlanId(updateObj.getPlanId());
|
|
|
@@ -2085,42 +2058,58 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
reqVO.setBomNodeIds(new ArrayList<>(bomNodeIds));
|
|
|
List<IotMaintenanceBomDO> maintenanceBomS = iotMaintenanceBomService.getIotMainPlanBomList(reqVO);
|
|
|
// 根据保养工单 保养项 保养数据 更新对应的 保养计划 保养项 数据
|
|
|
+ // 如果没有填写 保养时的累计运行时长 累计运行公里数 则使用 运行记录的累计值 如果都没有值 则不反写
|
|
|
if (CollUtil.isNotEmpty(maintenanceBomS)) {
|
|
|
List<IotMaintenanceBomDO> tobeUpdatedMainBomS = new ArrayList<>();
|
|
|
maintenanceBomS.forEach(bom -> {
|
|
|
String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
if (ObjUtil.isNotEmpty(bom.getMileageRule()) && 0 == bom.getMileageRule()) {
|
|
|
- // BigDecimal totalMileage = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalMileage = BigDecimal.ZERO;
|
|
|
// 设置了 运行里程 保养规则
|
|
|
- /* if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
- IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
|
- totalMileage = deviceRunLog.getTotalMileage();
|
|
|
- } else {
|
|
|
- // 保养项绑定的 累计公里数类型的属性值
|
|
|
- String uniqueKeyType = StrUtil.join("-", bom.getDeviceId(), bom.getType());
|
|
|
- if (tempTotalRunDataPair.containsKey(uniqueKeyType)) {
|
|
|
- totalMileage = tempTotalRunDataPair.get(uniqueKeyType);
|
|
|
- }
|
|
|
- } */
|
|
|
if (mainMileagePair.containsKey(uniqueKey)) {
|
|
|
- bom.setLastRunningKilometers(mainMileagePair.get(uniqueKey));
|
|
|
+ BigDecimal tempMainMileage = mainMileagePair.get(uniqueKey);
|
|
|
+ if (ObjUtil.isNotEmpty(tempMainMileage) && tempMainMileage.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ bom.setLastRunningKilometers(tempMainMileage);
|
|
|
+ } else {
|
|
|
+ // 没有填写 保养时的 累计运行时长 累计运行公里数 使用运行记录中的累计运行数据反写
|
|
|
+ if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
+ IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
|
+ totalMileage = deviceRunLog.getTotalMileage();
|
|
|
+ } else {
|
|
|
+ // 保养项绑定的 累计公里数类型的属性值
|
|
|
+ String uniqueKeyType = StrUtil.join("-", bom.getDeviceId(), bom.getType());
|
|
|
+ if (tempTotalRunDataPair.containsKey(uniqueKeyType)) {
|
|
|
+ totalMileage = tempTotalRunDataPair.get(uniqueKeyType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(totalMileage) && totalMileage.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ bom.setLastRunningKilometers(totalMileage);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (ObjUtil.isNotEmpty(bom.getRunningTimeRule()) && 0 == bom.getRunningTimeRule()) {
|
|
|
- // BigDecimal totalRunTime = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalRunTime = BigDecimal.ZERO;
|
|
|
// 设置了 运行时间 保养规则
|
|
|
- /* if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
- IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
|
- totalRunTime = deviceRunLog.getTotalRunTime();
|
|
|
- } else {
|
|
|
- // 保养项绑定的 累计时长 类型的属性值
|
|
|
- String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getCode());
|
|
|
- if (tempTotalRunDataPair.containsKey(uniqueKey)) {
|
|
|
- totalRunTime = tempTotalRunDataPair.get(uniqueKey);
|
|
|
- }
|
|
|
- } */
|
|
|
if (mainRuntimePair.containsKey(uniqueKey)) {
|
|
|
- bom.setLastRunningTime(mainRuntimePair.get(uniqueKey));
|
|
|
+ BigDecimal tempRuntime = mainRuntimePair.get(uniqueKey);
|
|
|
+ if (ObjUtil.isNotEmpty(tempRuntime) && tempRuntime.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ bom.setLastRunningTime(tempRuntime);
|
|
|
+ } else {
|
|
|
+ if (deviceRunLogMap.containsKey(bom.getDeviceId())) {
|
|
|
+ IotDeviceRunLogRespVO deviceRunLog = deviceRunLogMap.get(bom.getDeviceId());
|
|
|
+ totalRunTime = deviceRunLog.getTotalRunTime();
|
|
|
+ } else {
|
|
|
+ // 保养项绑定的 累计时长 类型的属性值
|
|
|
+ String uniqueKeyCode = StrUtil.join("-", bom.getDeviceId(), bom.getCode());
|
|
|
+ if (tempTotalRunDataPair.containsKey(uniqueKeyCode)) {
|
|
|
+ totalRunTime = tempTotalRunDataPair.get(uniqueKeyCode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ObjUtil.isNotEmpty(totalRunTime) && totalRunTime.compareTo(BigDecimal.ZERO)>0) {
|
|
|
+ bom.setLastRunningTime(totalRunTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if (ObjUtil.isNotEmpty(bom.getNaturalDateRule()) && 0 == bom.getNaturalDateRule()) {
|