Răsfoiți Sursa

设备资料库初始化处理,维修工单记录出库id

lipenghui 1 săptămână în urmă
părinte
comite
e16e746bbc

+ 14 - 18
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotTreeServiceImpl.java

@@ -71,31 +71,27 @@ public class IotTreeServiceImpl implements IotTreeService {
         List<Long> idds = new ArrayList<>(ids);
         iotDevicePageReqVO.setDeptIds((idds));
         List<Long> deviceIds = iotDeviceMapper.selectList(iotDevicePageReqVO).stream().map(IotDeviceDO::getId).collect(Collectors.toList());
+
         devices.forEach(device -> {
             if (deviceIds.contains(device.getOriginId())) {
+                //更新设备资料库的名称
                 IotDeviceDO iotDevice = iotDeviceService.getIotDevice(device.getOriginId());
                 device.setName(iotDevice.getDeviceCode()+iotDevice.getDeviceName());
+
+                //设备的部门id
+                Long deptId = iotDevice.getDeptId();
+                IotTreeListReqVO iotTreeListReqVO = new IotTreeListReqVO();
+                iotTreeListReqVO.setOriginId(deptId);
+                iotTreeListReqVO.setType("dept");
+                List<IotTreeDO> iotTreeDOS1 = iotTreeMapper.selectList(iotTreeListReqVO);
+                if (CollUtil.isNotEmpty(iotTreeDOS1)&&iotTreeDOS1.size()==1) {
+                    if (!device.getParentId().equals(iotTreeDOS1.get(0).getId())) {
+                        device.setParentId(iotTreeDOS1.get(0).getId());
+                    }
+                }
                 iotTreeMapper.updateById(device);
             }
         });
-
-//        }
-//        List<IotTreeDO> rh = devices.stream().filter(e -> e.getName().contains("RH")).collect(Collectors.toList());
-//        rh.forEach(e -> {
-//            IotDeviceDO iotDevice = iotDeviceService.getIotDevice(e.getOriginId());
-//            if (Objects.nonNull(iotDevice)) {
-//                e.setDeviceCode(iotDevice.getDeviceCode());
-//                e.setName(iotDevice.getDeviceCode()+iotDevice.getDeviceName());
-//                iotTreeMapper.updateById(e);
-//            }
-//        });
-//        devices.forEach(device -> {
-//            Long deviceOriginId = device.getOriginId();
-//            IotDeviceDO iotDevice = iotDeviceService.getIotDevice(deviceOriginId);
-//            device.setDeviceCode(iotDevice.getDeviceCode());
-//            device.setName(device.getDeviceCode()+iotDevice.getDeviceName());
-//            iotTreeMapper.updateById(device);
-//        });
     }
 
     @Override

+ 5 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/maintain/IotMaintainServiceImpl.java

@@ -205,7 +205,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
         }
 
         //本地库存减少且记录出库
-        localStockAndOut(createReqVO);
+        localStockAndOut(createReqVO, iotMaintain.getId());
 //        if ("in".equals(createReqVO.getMaintain().getType())) {
 //            String msg = "【PMS】维修工单 - "+createReqVO.getMaintain().getFailureName()+"已处理。"+"["+new Date()+"]";
 //            sendMessage(BeanUtils.toBean(iotMaintain, IotMaintainDO.class), "maintain-report", msg);
@@ -291,7 +291,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
         }
 
         //本地库存减少且记录出库
-        localStockAndOut(updateReqVO);
+        localStockAndOut(updateReqVO, updateObj.getId());
         if ("in".equals(updateReqVO.getMaintain().getType())) {
             String msg = "【PMS】维修工单 - "+updateReqVO.getMaintain().getFailureName()+"已处理。"+"["+new Date()+"]";
 //            sendMessage(BeanUtils.toBean(updateReqVO.getMaintain(), IotMaintainDO.class), "maintain-report", msg);
@@ -322,7 +322,7 @@ public class IotMaintainServiceImpl implements IotMaintainService {
      * 减少本地库存并记录出库
      * @param maintainSaveVO 维修工单信息
      */
-    private void localStockAndOut(IotMaintainSaveVO maintainSaveVO) {
+    private void localStockAndOut(IotMaintainSaveVO maintainSaveVO, Long id) {
         List<IotMaintainBomSaveReqVO> maintainMaterials = maintainSaveVO.getMaintainMaterials();
         //判断物料不为空
         if (CollUtil.isNotEmpty(maintainMaterials)) {
@@ -349,6 +349,8 @@ public class IotMaintainServiceImpl implements IotMaintainService {
                 outboundDO.setMaterialName(e.getMaterialName());
                 outboundDO.setDeliveryTime(LocalDateTimeUtil.now());
                 outboundDO.setReason("故障维修");
+                //将维修工单的id设置到bizId
+                outboundDO.setBizId(id);
                 outboundDO.setStatus(0);
                 outboundDO.setType(1);
                 outboundDO.setDeleted(false);