Explorar o código

pms 保养计划/工单选择设备 区分是否已经有设备BOM 避免无效操作

zhangcl hai 1 semana
pai
achega
8b97ebbb04

+ 24 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/IotDeviceController.java

@@ -32,7 +32,6 @@ import cn.iocoder.yudao.module.pms.util.IotDeviceConvert;
 import cn.iocoder.yudao.module.supplier.dal.dataobject.product.SupplierDO;
 import cn.iocoder.yudao.module.supplier.service.product.SupplierService;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
-import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
 import cn.iocoder.yudao.module.system.service.dict.DictDataService;
 import com.google.common.collect.ImmutableList;
@@ -184,12 +183,36 @@ public class IotDeviceController {
         }
         Map<Long, DeptDO> deptMap = deptService.getDeptMap(
                 convertList(pageResult.getList(), IotDeviceDO::getDeptId));
+        // 查询当前分页的设备是否已经设置了 保养BOM
+        List<Long> deviceIds = convertList(pageResult.getList(), IotDeviceDO::getId);
+        IotDevicePageReqVO reqVO = new IotDevicePageReqVO();
+        reqVO.setDeviceIds(deviceIds);
+        reqVO.setBomFlag("b");
+        List<IotDeviceRespVO> devicesWithBoms = iotDeviceService.deviceAssociateBomList(reqVO);
+        Map<Long, List<IotDeviceRespVO>> devicesWithBomsPair = new HashMap<>();
+        if (CollUtil.isNotEmpty(devicesWithBoms)) {
+            devicesWithBoms.forEach(bom -> {
+                if (devicesWithBomsPair.containsKey(bom.getId())) {
+                    List<IotDeviceRespVO> tempDevices = devicesWithBomsPair.get(bom.getId());
+                    tempDevices.add(bom);
+                    devicesWithBomsPair.put(bom.getId(), tempDevices);
+                } else {
+                    List<IotDeviceRespVO> tempDevices = new ArrayList<>();
+                    tempDevices.add(bom);
+                    devicesWithBomsPair.put(bom.getId(), tempDevices);
+                }
+            });
+        }
         List<IotDeviceRespVO> iotDeviceRespVOS = IotDeviceConvert.INSTANCE.convertList(pageResult.getList(), deptMap);
         iotDeviceRespVOS.forEach(e ->{
             SupplierDO supplierDO = supplierService.get(e.getManufacturerId());
             if (Objects.nonNull(supplierDO)) {
                 e.setManufacturer(supplierDO.getName());
             }
+            // 设置保养项标识
+            if (devicesWithBomsPair.containsKey(e.getId())) {
+                e.setHasSetMaintenanceBom(true);
+            }
         });
         return success(new PageResult<>(iotDeviceRespVOS,
                 pageResult.getTotal()));

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/vo/IotDeviceRespVO.java

@@ -161,6 +161,8 @@ public class IotDeviceRespVO {
     private String type;
     @Schema(description = "设备分类BOM同步状态 1已同步 0未同步")
     private Integer bomSyncStatus;
+    @Schema(description = "当前设备是否已经配置了保养BOM")
+    private boolean hasSetMaintenanceBom = false;
 
     /**
      * 计算字段