|
@@ -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()));
|