Ver código fonte

Merge remote-tracking branch 'origin/master'

zhangcl 6 dias atrás
pai
commit
61649fa7c3

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

@@ -770,9 +770,35 @@ public class IotDeviceController {
     @GetMapping("/map")
     @Operation(summary = "查询地图设备")
     public CommonResult<List<IotDeviceDO>> getMap(@Valid IotDevicePageReqVO pageReqVO){
-        List<IotDeviceDO> mapDevice = iotDeviceService.getMapDevice(pageReqVO);
-        List<IotDeviceDO> collect = mapDevice.stream().filter(e -> Objects.nonNull(e.getLng()) && Objects.nonNull(e.getLat())).collect(Collectors.toList());
-        return CommonResult.success(collect);
+        if ("ly".equals(pageReqVO.getSource())){
+            //获取数采yf里面的设备
+            DevicePageReqVO devicePageReqVO = new DevicePageReqVO();
+            devicePageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+            //连油设备
+            devicePageReqVO.setProductId(649L);
+            List<String> codes = yfDeviceService.getDevicePage(devicePageReqVO).getList().stream().map(YfDeviceDO::getSerialNumber).collect(Collectors.toList());
+            List<IotDeviceDO> iotDeviceDOS;
+            Long deptId = null;
+            if (Objects.isNull(pageReqVO.getDeptId())) {
+                deptId = SecurityFrameworkUtils.getLoginUserDeptId();
+            }else {
+                deptId = pageReqVO.getDeptId();
+            }
+            Set<Long> ids;
+            ids = deptService.getChildDeptIdListFromCache(deptId);
+            ids.add(deptId);
+            IotDevicePageReqVO reqVO = new IotDevicePageReqVO();
+            reqVO.setDeptIds(new ArrayList<>(ids));
+            List<IotDeviceDO> devicesByDepts = iotDeviceService.getDevicesByDepts(reqVO);
+            iotDeviceDOS = devicesByDepts.stream().filter(e -> codes.contains(e.getDeviceCode())).collect(Collectors.toList());
+            return success(iotDeviceDOS);
+        } else{
+            List<IotDeviceDO> mapDevice = iotDeviceService.getMapDevice(pageReqVO);
+            List<IotDeviceDO> collect = mapDevice.stream().filter(e -> Objects.nonNull(e.getLng()) && Objects.nonNull(e.getLat())).collect(Collectors.toList());
+            return success(collect);
+        }
+
+
     }
 
     @PermitAll

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

@@ -160,4 +160,6 @@ public class IotDevicePageReqVO extends PageParam {
     private String address;
     @Schema(description = "设备等级")
     private String deviceGrade;
+    @Schema(description = "来源,区分连油或者注气之类的")
+    private String source;
 }

+ 13 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/hazard/IotHazardServiceImpl.java

@@ -49,7 +49,12 @@ public class IotHazardServiceImpl implements IotHazardService {
         iotHazard.setDeleted(false);
         //未整改
         iotHazard.setStatus("todo");
-        Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
+        Long deptId;
+        if (createReqVO.getDeptId()==null) {
+            deptId = SecurityFrameworkUtils.getLoginUserDeptId();
+        } else {
+            deptId = createReqVO.getDeptId();
+        }
         iotHazard.setDeptId(deptId);
         if (Objects.nonNull(createReqVO.getClassify())&& StringUtils.isNotBlank(createReqVO.getClassify())) {
             IotHazardTypeDO iotHazardTypeDO = iotHazardTypeMapper.selectById(Long.valueOf(createReqVO.getClassify()));
@@ -65,6 +70,13 @@ public class IotHazardServiceImpl implements IotHazardService {
 
     @Override
     public void updateIotHazard(IotHazardSaveReqVO updateReqVO) {
+        Long deptId;
+        if (updateReqVO.getDeptId()==null) {
+            deptId = SecurityFrameworkUtils.getLoginUserDeptId();
+        } else {
+            deptId = updateReqVO.getDeptId();
+        }
+        updateReqVO.setDeptId(deptId);
         // 校验存在
         validateIotHazardExists(updateReqVO.getId());
         // 更新