|
@@ -151,7 +151,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
|
|
|
if ("out".equals(createReqVO.getMaintain().getType())){
|
|
|
String processInstanceId = processInstanceApi.createProcessInstance(SecurityFrameworkUtils.getLoginUserId(),
|
|
|
new BpmProcessInstanceCreateReqDTO().setProcessDefinitionKey(PROCESS_KEY).setBusinessKey(String.valueOf(iotMaintain.getId())));
|
|
|
- // 将流程实例id 更新到 供应商主数据表
|
|
|
+ // 将流程实例id 更新到维修工单主数据表
|
|
|
iotMaintainMapper.updateById(new IotMaintainDO().setId(iotMaintain.getId()).setProcessInstanceId(processInstanceId).setAuditStatus(FailureAuditStatusEnum.PROCESS.getStatus()));
|
|
|
}
|
|
|
//异步写入故障知识库
|
|
@@ -214,7 +214,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
|
|
|
//本地库存减少且记录出库
|
|
|
localStockAndOut(updateReqVO);
|
|
|
if ("in".equals(updateReqVO.getMaintain().getType())) {
|
|
|
- sendMessage(BeanUtils.toBean(updateReqVO, IotMaintainDO.class));
|
|
|
+ sendMessage(BeanUtils.toBean(updateReqVO.getMaintain(), IotMaintainDO.class));
|
|
|
}
|
|
|
//委外发起流程
|
|
|
if ("out".equals(updateReqVO.getMaintain().getType())){
|
|
@@ -230,38 +230,36 @@ public class IotMaintainServiceImpl implements IotMaintainService {
|
|
|
List<IotMaintainBomSaveReqVO> maintainMaterials = maintainSaveVO.getMaintainMaterials();
|
|
|
//判断物料不为空
|
|
|
if (CollUtil.isNotEmpty(maintainMaterials)) {
|
|
|
- maintainMaterials.forEach(f ->{
|
|
|
- f.getMaterials().forEach(e ->{
|
|
|
- String code = e.getMaterialCode();
|
|
|
- //减去本地库存
|
|
|
- if ("本地库存".equals(e.getMaterialSource())){
|
|
|
- List<IotLockStockDO> stockDOS = iotLockStockMapper.selectByMap(ImmutableMap.of("material_code", code, "dept_id", maintainSaveVO.getMaintain().getDeptId()));
|
|
|
- if (CollUtil.isNotEmpty(stockDOS)) {
|
|
|
- IotLockStockDO iotLockStockDO = stockDOS.get(0);
|
|
|
- BigDecimal quantity = iotLockStockDO.getQuantity();
|
|
|
- BigDecimal subtract = quantity.subtract(e.getQuantity());
|
|
|
- if (subtract.compareTo(BigDecimal.ZERO) < 0){
|
|
|
- throw new ServiceException(IOT_LOCK_STOCK_FUSHU);
|
|
|
- }
|
|
|
- iotLockStockDO.setQuantity(subtract);
|
|
|
- iotLockStockMapper.updateById(iotLockStockDO);
|
|
|
- }
|
|
|
+ maintainMaterials.forEach(f -> f.getMaterials().forEach(e ->{
|
|
|
+ String code = e.getMaterialCode();
|
|
|
+ //减去本地库存
|
|
|
+ if ("本地库存".equals(e.getMaterialSource())){
|
|
|
+ List<IotLockStockDO> stockDOS = iotLockStockMapper.selectByMap(ImmutableMap.of("material_code", code, "factory_id", e.getFactoryId(),"cost_center_id", e.getCostCenterId()));
|
|
|
+ if (CollUtil.isNotEmpty(stockDOS)) {
|
|
|
+ IotLockStockDO iotLockStockDO = stockDOS.get(0);
|
|
|
+ BigDecimal quantity = iotLockStockDO.getQuantity();
|
|
|
+ BigDecimal subtract = quantity.subtract(e.getQuantity());
|
|
|
+// if (subtract.compareTo(BigDecimal.ZERO) < 0){
|
|
|
+// throw new ServiceException(IOT_LOCK_STOCK_FUSHU);
|
|
|
+// }
|
|
|
+ iotLockStockDO.setQuantity(subtract);
|
|
|
+ iotLockStockMapper.updateById(iotLockStockDO);
|
|
|
}
|
|
|
- //记录出库
|
|
|
- IotOutboundDO outboundDO = new IotOutboundDO();
|
|
|
- outboundDO.setDeptId(maintainSaveVO.getMaintain().getDeptId());
|
|
|
- outboundDO.setMaterialCode(code);
|
|
|
- outboundDO.setMaterialName(e.getMaterialName());
|
|
|
- outboundDO.setDeliveryTime(LocalDateTimeUtil.now());
|
|
|
- outboundDO.setReason("故障维修");
|
|
|
- outboundDO.setStatus(0);
|
|
|
- outboundDO.setType(1);
|
|
|
- outboundDO.setDeleted(false);
|
|
|
- outboundDO.setUnit(e.getUnit());
|
|
|
- outboundDO.setUnitPrice(e.getUnitPrice());
|
|
|
- iotOutboundMapper.insert(outboundDO);
|
|
|
- });
|
|
|
- });
|
|
|
+ }
|
|
|
+ //记录出库
|
|
|
+ IotOutboundDO outboundDO = new IotOutboundDO();
|
|
|
+ outboundDO.setDeptId(maintainSaveVO.getMaintain().getDeptId());
|
|
|
+ outboundDO.setMaterialCode(code);
|
|
|
+ outboundDO.setMaterialName(e.getMaterialName());
|
|
|
+ outboundDO.setDeliveryTime(LocalDateTimeUtil.now());
|
|
|
+ outboundDO.setReason("故障维修");
|
|
|
+ outboundDO.setStatus(0);
|
|
|
+ outboundDO.setType(1);
|
|
|
+ outboundDO.setDeleted(false);
|
|
|
+ outboundDO.setUnit(e.getUnit());
|
|
|
+ outboundDO.setUnitPrice(e.getUnitPrice());
|
|
|
+ iotOutboundMapper.insert(outboundDO);
|
|
|
+ }));
|
|
|
}
|
|
|
//更新故障上报的状态为工单处理完成
|
|
|
IotMaintainSaveReqVO iotMaintain = maintainSaveVO.getMaintain();
|