|
@@ -1340,30 +1340,36 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
// key设备id-保养项BOM节点id value保养工单明细对象 用于更新关联的保养计划保养项
|
|
|
Map<String, IotMainWorkOrderBomSaveReqVO> deviceBomPair = new HashMap<>();
|
|
|
workOrderBOMs.forEach(bom -> {
|
|
|
+ IotMainWorkOrderBomDO tempBom = BeanUtils.toBean(bom, IotMainWorkOrderBomDO.class);
|
|
|
if (ObjUtil.isNotEmpty(bom.getStatus()) && 0 == bom.getStatus()) {
|
|
|
// 兼容保养工单中部分保养项保养完成 部分保养项 延期保养的情况 这里只更新延期保养 或正常 保养的物料
|
|
|
- IotMainWorkOrderBomDO tempBom = BeanUtils.toBean(bom, IotMainWorkOrderBomDO.class);
|
|
|
// 如果工单明细中任何一个保养项设置了 任何一种推迟保养规则 工单结果 不能设置为 已执行
|
|
|
- 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
|
|
|
+ /* 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);
|
|
|
- }
|
|
|
- workOrderBomDOS.add(tempBom);
|
|
|
+ } */
|
|
|
+ } else if (ObjUtil.isNotEmpty(bom.getStatus()) && 1 == bom.getStatus()) {
|
|
|
+ // 当前保养项已经保养完成 查询当前设备的 累计运行公里数 累计运行时间 当前时间日期 赋值到 关联保养计划 明细 的 对应保养规则数据上
|
|
|
+ deviceIds.add(bom.getDeviceId());
|
|
|
+ // 保养项下如果已经添加了物料 说明该保养项已经保养完成
|
|
|
+ bomNodeIds.add(bom.getBomNodeId());
|
|
|
+ tempBom.setStatus(1);
|
|
|
// 设置需要更新 关联保养计划 保养项 运行时间周期(H) 的设备id 保养项id 集合
|
|
|
mctDeviceIds.add(bom.getDeviceId());
|
|
|
mctBomNodeIds.add(bom.getBomNodeId());
|
|
|
String uniqueKey = StrUtil.join("-", bom.getDeviceId(), bom.getBomNodeId());
|
|
|
deviceBomPair.put(uniqueKey, bom);
|
|
|
}
|
|
|
+ workOrderBomDOS.add(tempBom);
|
|
|
});
|
|
|
if (CollUtil.isNotEmpty(workOrderBOMs)) {
|
|
|
// 组装bom关联的设备信息
|
|
@@ -1463,16 +1469,16 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
if (2 == updateObj.getResult()) {
|
|
|
if (CollUtil.isNotEmpty(filteredOrders)) {
|
|
|
// 将关联工单设置为 已执行 直接删除
|
|
|
- filteredOrders.forEach(order -> {order.setResult(2); order.setDeleted(true);});
|
|
|
+ filteredOrders.forEach(order -> { order.setResult(2); order.setDeleted(true); });
|
|
|
iotMainWorkOrderMapper.updateBatch(filteredOrders);
|
|
|
List<Long> workOrderIds = filteredOrders.stream()
|
|
|
.map(IotMainWorkOrderDO::getId)
|
|
|
.collect(Collectors.toList());
|
|
|
- // 将关联工单的明细 status 设置为 1
|
|
|
+ // 将关联工单的明细 status 设置为 1 直接删除
|
|
|
IotMainWorkOrderBomPageReqVO reqVO = new IotMainWorkOrderBomPageReqVO();
|
|
|
reqVO.setWorkOrderIds(workOrderIds);
|
|
|
List<IotMainWorkOrderBomDO> associateOrderBomS = iotMainWorkOrderBomMapper.selectList(reqVO);
|
|
|
- associateOrderBomS.forEach(order -> order.setStatus(1));
|
|
|
+ associateOrderBomS.forEach(order -> { order.setStatus(1); order.setDeleted(true); });
|
|
|
iotMainWorkOrderBomMapper.updateBatch(associateOrderBomS);
|
|
|
}
|
|
|
}
|
|
@@ -1488,10 +1494,10 @@ public class IotMainWorkOrderServiceImpl implements IotMainWorkOrderService {
|
|
|
order.setLaborCost(updateObj.getLaborCost());
|
|
|
order.setRemark(updateObj.getRemark());
|
|
|
});
|
|
|
+ // 更新 关联保养工单的相关数据
|
|
|
+ iotMainWorkOrderMapper.updateBatch(filteredOrders);
|
|
|
}
|
|
|
}
|
|
|
- // 如果在填报工单时 填写了 保养项 中的 ‘运行时间周期(H)’ 保存时需要同步到 保养工单 关联的 保养计划的 对应的保养项的 ‘运行时间周期(H)’
|
|
|
- // 包含 延时保养 的情况
|
|
|
// 只扣减本地库存 不处理SAP库存
|
|
|
// 保养基于单设备 出库时记录 单设备所属的部门id(即保养工单的部门id)
|
|
|
if (CollUtil.isNotEmpty(factoryIds) && CollUtil.isNotEmpty(costCenterIds) && CollUtil.isNotEmpty(materialCodes)) {
|