|
|
@@ -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) {
|