|
@@ -20,6 +20,7 @@ import cn.iocoder.yudao.module.pms.controller.admin.vo.IotDeviceSaveReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotDeviceDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotInfoClassifyDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.IotTreeDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotZHBD.DeviceZHBDDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotdeviceperson.IotDevicePersonDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodel.IotModelDO;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotmodeltemplateattrs.IotModelTemplateAttrsDO;
|
|
@@ -29,6 +30,7 @@ import cn.iocoder.yudao.module.pms.dal.mysql.IotTreeMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.TDDeviceMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotdevicerunlog.IotDeviceRunLogMapper;
|
|
|
import cn.iocoder.yudao.module.pms.dal.mysql.iotmodel.IotModelMapper;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.mysql.iotopeationfill.IotOpeationFillMapper;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotbom.IotBomService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotdevicebom.IotDeviceBomService;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotdeviceperson.IotDevicePersonService;
|
|
@@ -115,7 +117,9 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|
|
private AdminUserApi adminUserApi;
|
|
|
@Autowired
|
|
|
private IotDevicePersonService iotDevicePersonService;
|
|
|
- private final static String parameter = "lng,lat,today_distance,distance,todayoil,totaloil,online,oil1,oil2,oil3,oil4";
|
|
|
+ @Autowired
|
|
|
+ private IotOpeationFillMapper zhbdmapper;
|
|
|
+ private final static String parameter = "lng~~经度,lat~~纬度,today_distance~~当日里程,distance~~总里程,todayoil~~当日油量,totaloil~~总油量,online~~是否在线,oil1~~1路油量,oil2~~2路油量,oil3~~3路油量,oil4~~4路油量,vehicle_name~~车牌号码";
|
|
|
|
|
|
@Override
|
|
|
public List<IotDeviceDO> getMapDevice() {
|
|
@@ -140,39 +144,55 @@ public class IotDeviceServiceImpl implements IotDeviceService {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<ThingsModelDTO> rows = JSON.parseArray(JSON.toJSONString(tableDataInfo.getRows()), ThingsModelDTO.class);
|
|
|
- List<String> zhbds = Arrays.stream(parameter.split(",")).collect(Collectors.toList());
|
|
|
- rows.forEach(e ->{
|
|
|
- //如果在中行北斗的话取redis
|
|
|
- if (zhbds.contains(e.getIdentifier())) {
|
|
|
- Object o = redisTemplate.opsForHash().get("TSLV:" + iotDeviceDO.getDeviceCode(), e.getIdentifier());
|
|
|
+ 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 (!identifiers.contains(zhbds.get(2))||!identifiers.contains(zhbds.get(4))&&carCodes.contains(iotDeviceDO.getDeviceCode())) {
|
|
|
+ for (String s : split1) {
|
|
|
+ String[] split = s.split("~~");
|
|
|
+ Object o = redisTemplate.opsForHash().get("TSLV:" + iotDeviceDO.getDeviceCode(), split[0]);
|
|
|
if (Objects.nonNull(o)) {
|
|
|
JSONObject jsonObject = JSON.parseObject(o.toString());
|
|
|
- if ("online".equals(e.getIdentifier())){
|
|
|
+ ThingsModelDTO modelDTO = new ThingsModelDTO();
|
|
|
+ modelDTO.setIdentifier(split[0]);
|
|
|
+ modelDTO.setModelName(split[1]);
|
|
|
+ if ("online".equals(split[0])){
|
|
|
String value = String.valueOf(jsonObject.get("value"));
|
|
|
- e.setValue("true".equals(value)?"是":"否");
|
|
|
+ modelDTO.setValue("true".equals(value)?"是":"否");
|
|
|
} else {
|
|
|
String value = String.valueOf(jsonObject.get("value"));
|
|
|
- e.setValue(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<YfDeviceDO> yfDeviceDO = yfDeviceService.getAllDeviceByColumn("serial_number", iotDeviceDO.getDeviceCode());
|
|
|
-// if (CollUtil.isEmpty(yfDeviceDO)) {
|
|
|
-// throw new ServiceException(IOT_DEVICE_NOT_EXISTS);
|
|
|
-// }
|
|
|
-// Long productId = yfDeviceDO.get(0).getProductId();
|
|
|
-// //点位参数
|
|
|
-// List<ThingsModelDO> productId1 = thingsModelService.selectList("product_id", productId.toString());
|
|
|
-// List<String> collect = productId1.stream().map(ThingsModelDO::getIdentifier).collect(Collectors.toList());
|
|
|
-// //td数据
|
|
|
-// List<DeviceVO> deviceVOS = deviceMapper.selectLastParam(iotDeviceDO.getDeviceCode(), collect);
|
|
|
-// productId1.forEach(deviceVO -> deviceVOS.stream().filter(e -> e.getIdentity().equals(deviceVO.getIdentifier())).findFirst().ifPresent(ab ->{
|
|
|
-// deviceVO.setValueType(ab.getLogValue());
|
|
|
-// deviceVO.setCode(iotDeviceDO.getDeviceCode());
|
|
|
-// }));
|
|
|
return 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());
|
|
|
}
|
|
|
|