浏览代码

设备运行监控将数采及中航北斗区分开

lipenghui 1 天之前
父节点
当前提交
a39ceab142

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

@@ -160,6 +160,26 @@ public class IotDeviceController {
         return success(tdParams);
     }
 
+    @GetMapping("/get/gateway/td")
+    @Operation(summary = "获得网关属性")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
+    public CommonResult<List<ThingsModelDTO>> getIotDeviceTdGateway(@RequestParam("id") Long id) {
+        IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
+        List<ThingsModelDTO> tdParams = iotDeviceService.getTdGatewayParams(iotDevice);
+        return success(tdParams);
+    }
+
+    @GetMapping("/get/zhbd/td")
+    @Operation(summary = "获得网关属性")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-device:query')")
+    public CommonResult<List<ThingsModelDTO>> getIotDeviceTdZhbd(@RequestParam("id") Long id) {
+        IotDeviceDO iotDevice = iotDeviceService.getIotDevice(id);
+        List<ThingsModelDTO> tdParams = iotDeviceService.getTdZhbdParams(iotDevice);
+        return success(tdParams);
+    }
+
     @GetMapping("/get")
     @Operation(summary = "获得设备台账")
     @Parameter(name = "id", description = "编号", required = true, example = "1024")

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

@@ -238,4 +238,5 @@ public class IotDeviceRespVO {
 
     @Schema(description = "油服设备编码")
     private String yfDeviceCode;
+    private String carOnline;
 }

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

@@ -28,7 +28,6 @@ public class IotDeviceSaveReqVO {
 
     @Schema(description = "规格型号")
     private String model;
-
     @Schema(description = "所在部门", requiredMode = Schema.RequiredMode.REQUIRED, example = "8581")
     @NotNull(message = "所在部门不能为空")
     private Long deptId;

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/IotDeviceDO.java

@@ -175,4 +175,5 @@ public class IotDeviceDO extends BaseDO {
      */
     private String yfClass;
     private String yfDeviceCode;
+    private String carOnline;
 }

+ 1 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/ZhbdJob.java

@@ -130,6 +130,7 @@ public class ZhbdJob implements JobHandler {
                         if (CollUtil.isNotEmpty(iotDeviceDOS)) {
                             IotDeviceDO iotDeviceDO = iotDeviceDOS.get(0);
                             iotDeviceDO.setVehicleName(String.valueOf(location.get("vehicle_name")));
+                            iotDeviceDO.setCarOnline(String.valueOf(location.get("online")));
                             iotDeviceMapper.updateById(iotDeviceDO);
                         }
                     });

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceService.java

@@ -29,6 +29,8 @@ public interface IotDeviceService {
     void importDevice(List<DeviceImportExcelVO> list);
     List<IotDeviceDO> getMapDevice(IotDevicePageReqVO pageReqVO);
     List<ThingsModelDTO> getTdParams(IotDeviceDO iotDeviceDO);
+    List<ThingsModelDTO> getTdGatewayParams(IotDeviceDO iotDeviceDO);
+    List<ThingsModelDTO> getTdZhbdParams(IotDeviceDO iotDeviceDO);
     /**
      * 创建设备台账
      *

+ 125 - 3
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/IotDeviceServiceImpl.java

@@ -314,9 +314,6 @@ public class IotDeviceServiceImpl implements IotDeviceService {
             for (String s : split1) {
                 String[] split = s.split("~~");
 //                if (!identifiers.contains(zhbds.get(2))||!identifiers.contains(zhbds.get(4))){
-                if (split[0].equals(zhbds.get(2))) {
-
-                }
                     Object o = redisTemplate.opsForHash().get("TSLV:" + iotDeviceDO.getDeviceCode(), split[0]);
                     if (Objects.nonNull(o)) {
                         JSONObject jsonObject = JSON.parseObject(o.toString());
@@ -375,6 +372,131 @@ public class IotDeviceServiceImpl implements IotDeviceService {
         return collect;
     }
 
+    @Override
+    public List<ThingsModelDTO> getTdGatewayParams(IotDeviceDO iotDeviceDO) {
+        List<IotTdParamsDO> paramsDOS1 = iotTdParamsMapper.selectList("device_id", iotDeviceDO.getId());
+        TableDataInfo tableDataInfo = restTemplate.getForObject(yanfanUrl + "/prod-api/iot/device/listThingsModel?deviceId="+iotDeviceDO.getYfDeviceId()+"&pageNum=1&pageSize=200", TableDataInfo.class);
+        if (tableDataInfo == null) {
+            return new ArrayList<>();
+        }
+        List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
+        rows.forEach(e ->{
+            IotTdParamsDO paramsDO = paramsDOS1.stream().filter(f -> f.getIdentifier().equals(e.getIdentifier())).findFirst().orElse(null);
+            if (Objects.nonNull(paramsDO)) {
+                if ("alarm".equals(paramsDO.getIfAlarm())) {
+                    e.setIfAlarm("alarm");
+                }
+            }
+        });
+        List<ThingsModelDTO> collect = rows.stream().filter(e -> !"lac".equals(e.getIdentifier()) && !"cell_id".equals(e.getIdentifier()) && !"mcc_mnc".equals(e.getIdentifier())).sorted(Comparator.comparing(ThingsModelDTO::getIdentifier)).collect(Collectors.toList());
+        CompletableFuture.runAsync(()->{
+            collect.forEach(thingsModelDTO -> {
+                List<IotTdParamsDO> paramsDOS = iotTdParamsMapper.selectByMap(ImmutableMap.of("device_id", iotDeviceDO.getId(), "identifier", thingsModelDTO.getIdentifier()));
+                if (CollUtil.isEmpty(paramsDOS)) {
+                    IotTdParamsDO iotTdParamsDO = new IotTdParamsDO();
+                    iotTdParamsDO.setDeviceId(iotDeviceDO.getId());
+                    iotTdParamsDO.setDeviceCode(iotDeviceDO.getDeviceCode());
+                    iotTdParamsDO.setDeviceName(iotDeviceDO.getDeviceName());
+                    iotTdParamsDO.setYfCode(iotDeviceDO.getYfDeviceCode());
+                    iotTdParamsDO.setIdentifier(thingsModelDTO.getIdentifier());
+                    iotTdParamsDO.setModelName(thingsModelDTO.getModelName());
+                    iotTdParamsDO.setModelOrder(Long.valueOf(thingsModelDTO.getModelOrder()));
+                    iotTdParamsDO.setDeleted(false);
+                    iotTdParamsMapper.insert(iotTdParamsDO);
+                }
+            });
+        });
+        return collect;
+    }
+
+    @Override
+    public List<ThingsModelDTO> getTdZhbdParams(IotDeviceDO iotDeviceDO) {
+//        List<IotTdParamsDO> paramsDOS1 = iotTdParamsMapper.selectList("device_id", iotDeviceDO.getId());
+//        TableDataInfo tableDataInfo = restTemplate.getForObject(yanfanUrl + "/prod-api/iot/device/listThingsModel?deviceId="+iotDeviceDO.getYfDeviceId()+"&pageNum=1&pageSize=200", TableDataInfo.class);
+//        if (tableDataInfo == null) {
+//            return new ArrayList<>();
+//        }
+//        List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
+        List<ThingsModelDTO> rows = new ArrayList<>();
+//        rows.forEach(e ->{
+//            IotTdParamsDO paramsDO = paramsDOS1.stream().filter(f -> f.getIdentifier().equals(e.getIdentifier())).findFirst().orElse(null);
+//            if (Objects.nonNull(paramsDO)) {
+//                if ("alarm".equals(paramsDO.getIfAlarm())) {
+//                    e.setIfAlarm("alarm");
+//                }
+//            }
+//        });
+        LinkedList<String> zhbds = new LinkedList<>();
+        String[] split1 = parameter.split(",");
+        Arrays.stream(split1).collect(Collectors.toList()).forEach(e ->{
+            String[] split = e.split("~~");
+            zhbds.add(split[0]);
+        });
+//        List<String> identifiers = rows.stream().map(ThingsModelDTO::getIdentifier).collect(Collectors.toList());
+        //有数采
+        List<String> carCodes = zhbdmapper.carList().stream().map(DeviceZHBDDO::getDeviceCode).collect(Collectors.toList());
+//        if (carCodes.contains(iotDeviceDO.getDeviceCode())) {
+            for (String s : split1) {
+                String[] split = s.split("~~");
+//                if (!identifiers.contains(zhbds.get(2))||!identifiers.contains(zhbds.get(4))){
+                Object o = redisTemplate.opsForHash().get("TSLV:" + iotDeviceDO.getDeviceCode(), split[0]);
+                if (Objects.nonNull(o)) {
+                    JSONObject jsonObject = JSON.parseObject(o.toString());
+                    ThingsModelDTO modelDTO = new ThingsModelDTO();
+                    modelDTO.setIdentifier(split[0]);
+                    modelDTO.setModelName(split[1]);
+                    if ("online".equals(split[0])){
+                        String value = String.valueOf(jsonObject.get("value"));
+                        modelDTO.setValue("true".equals(value)?"是":"否");
+                    } else {
+                        String value = String.valueOf(jsonObject.get("value"));
+                        modelDTO.setValue(value);
+                    }
+                    rows.add(modelDTO);
+                }
+//                }
+            }
+//        } else {
+//            rows.forEach(e ->{
+//                //如果在中行北斗的话取redis
+//                if (zhbds.contains(e.getIdentifier())) {
+//                    Object o = redisTemplate.opsForHash().get("TSLV:" + iotDeviceDO.getDeviceCode(), e.getIdentifier());
+//                    if (Objects.nonNull(o)) {
+//                        JSONObject jsonObject = JSON.parseObject(o.toString());
+//                        if ("online".equals(e.getIdentifier())){
+//                            String value = String.valueOf(jsonObject.get("value"));
+//                            e.setValue("true".equals(value)?"是":"否");
+//                        } else {
+//                            String value = String.valueOf(jsonObject.get("value"));
+//                            e.setValue(value);
+//                        }
+//
+//                    }
+//                }
+//
+//            });
+//        }
+        List<ThingsModelDTO> collect = rows.stream().filter(e -> !"lac".equals(e.getIdentifier()) && !"cell_id".equals(e.getIdentifier()) && !"mcc_mnc".equals(e.getIdentifier())).sorted(Comparator.comparing(ThingsModelDTO::getIdentifier)).collect(Collectors.toList());
+        CompletableFuture.runAsync(()->{
+            collect.forEach(thingsModelDTO -> {
+                List<IotTdParamsDO> paramsDOS = iotTdParamsMapper.selectByMap(ImmutableMap.of("device_id", iotDeviceDO.getId(), "identifier", thingsModelDTO.getIdentifier()));
+                if (CollUtil.isEmpty(paramsDOS)) {
+                    IotTdParamsDO iotTdParamsDO = new IotTdParamsDO();
+                    iotTdParamsDO.setDeviceId(iotDeviceDO.getId());
+                    iotTdParamsDO.setDeviceCode(iotDeviceDO.getDeviceCode());
+                    iotTdParamsDO.setDeviceName(iotDeviceDO.getDeviceName());
+                    iotTdParamsDO.setYfCode(iotDeviceDO.getYfDeviceCode());
+                    iotTdParamsDO.setIdentifier(thingsModelDTO.getIdentifier());
+                    iotTdParamsDO.setModelName(thingsModelDTO.getModelName());
+                    iotTdParamsDO.setModelOrder(Long.valueOf(thingsModelDTO.getModelOrder()));
+                    iotTdParamsDO.setDeleted(false);
+                    iotTdParamsMapper.insert(iotTdParamsDO);
+                }
+            });
+        });
+        return collect;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Long createIotDevice(IotDeviceSaveReqVO createReqVO) {

+ 8 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java

@@ -103,4 +103,12 @@ public class DictDataController {
                 BeanUtils.toBean(list, DictDataRespVO.class));
     }
 
+    @GetMapping(value = "/type/{type}")
+    @Operation(summary = "/查询特定字典类型的字典")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('system:dict:query')")
+    public CommonResult<List<DictDataDO>> getDictTypeData(@PathVariable("type") String type) {
+        List<DictDataDO> dictDataListByDictType = dictDataService.getDictDataListByDictType(type);
+        return success(dictDataListByDictType);
+    }
 }