Commit b8ee9250 authored by zhangsen's avatar zhangsen

水源相关物联趋势等修改

parent 1de5fd91
...@@ -6,6 +6,7 @@ import java.util.stream.Collectors; ...@@ -6,6 +6,7 @@ import java.util.stream.Collectors;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.equipmanage.common.constant.Constant; import com.yeejoin.equipmanage.common.constant.Constant;
import com.yeejoin.equipmanage.common.entity.vo.EquiplistSpecificBySystemVO; import com.yeejoin.equipmanage.common.entity.vo.EquiplistSpecificBySystemVO;
import com.yeejoin.equipmanage.common.entity.vo.IotIndexInfoVo;
import com.yeejoin.equipmanage.common.utils.*; import com.yeejoin.equipmanage.common.utils.*;
import com.yeejoin.equipmanage.fegin.IotFeign; import com.yeejoin.equipmanage.fegin.IotFeign;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -430,35 +431,39 @@ public class EquipmentSpecificController extends AbstractBaseController { ...@@ -430,35 +431,39 @@ public class EquipmentSpecificController extends AbstractBaseController {
public ResponseModel getEquipmentIotIndexInfo(@PathVariable String equipSpeId, @RequestParam String beginDate, @RequestParam String endDate, public ResponseModel getEquipmentIotIndexInfo(@PathVariable String equipSpeId, @RequestParam String beginDate, @RequestParam String endDate,
@RequestParam(required = false) Integer isTrend, @RequestParam(required = false) String fieldKey) { @RequestParam(required = false) Integer isTrend, @RequestParam(required = false) String fieldKey) {
// 1.根据 equipSpeId 查询装备iotCode List<IotIndexInfoVo> indexInfoList = new ArrayList<>();
EquipmentSpecific equipmentSpecific = equipmentSpecificMapper.selectById(equipSpeId); List<String> split= Arrays.asList(equipSpeId.split(","));
if (ObjectUtils.isEmpty(equipmentSpecific)) { for (String s : split) {
return CommonResponseUtil.failure("未查询到装备信息!"); // 1.根据 equipSpeId 查询装备iotCode
EquipmentSpecific equipmentSpecific = equipmentSpecificMapper.selectById(equipSpeId);
if (ObjectUtils.isEmpty(equipmentSpecific)) {
return CommonResponseUtil.failure("未查询到装备信息!");
}
String iotCode = equipmentSpecific.getIotCode();
String prefix = null;
String suffix = null;
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码错误,请确认!");
}
ResponseModel entity = null;
try {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix, null);
} catch (Exception e) {
e.printStackTrace();
log.error("调用iot服务出错");
return CommonResponseUtil.failure("请求失败");
}
if (RESULT_SUCCESS_CODE != entity.getStatus() && ObjectUtils.isEmpty(entity.getResult())) {
log.error("查询物联日志数据为空或iotCode为 (" + iotCode + ") 的装备不存在于物联系统中!");
return CommonResponseUtil.failure("物联日志数据为空");
}
indexInfoList.addAll(equipmentSpecificSerivce.getIndexInfoList(iotCode, entity, isTrend, fieldKey));
} }
String iotCode = equipmentSpecific.getIotCode(); return CommonResponseUtil.success(indexInfoList);
String prefix = null;
String suffix = null;
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码错误,请确认!");
}
ResponseModel entity = null;
try {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix, null);
} catch (Exception e) {
e.printStackTrace();
log.error("调用iot服务出错");
return CommonResponseUtil.failure("请求失败");
}
if (RESULT_SUCCESS_CODE != entity.getStatus() && ObjectUtils.isEmpty(entity.getResult())) {
log.error("查询物联日志数据为空或iotCode为 (" + iotCode + ") 的装备不存在于物联系统中!");
return CommonResponseUtil.failure("物联日志数据为空");
}
return CommonResponseUtil.success(equipmentSpecificSerivce.getIndexInfoList(iotCode, entity, isTrend, fieldKey));
} }
......
...@@ -101,6 +101,9 @@ public class TopographyController extends AbstractBaseController { ...@@ -101,6 +101,9 @@ public class TopographyController extends AbstractBaseController {
@Value("${iot.vehicle.track}") @Value("${iot.vehicle.track}")
private String iotServerName; private String iotServerName;
@Value("${water.level.indexKey}")
private String waterLevelIndexKey;
// /** // /**
// * 拓扑图-树 // * 拓扑图-树
// * // *
...@@ -840,136 +843,209 @@ public class TopographyController extends AbstractBaseController { ...@@ -840,136 +843,209 @@ public class TopographyController extends AbstractBaseController {
@RequestParam(required = false) String fieldKey, @RequestParam(required = false) String fieldKey,
@RequestParam(required = false) String isTrend, @RequestParam(required = false) String isTrend,
@RequestParam(required = false) String endDate) throws ParseException { @RequestParam(required = false) String endDate) throws ParseException {
String eqpId;
String iotCode = null; Map<String, List<IotIndexResVo>> resultMap = new HashMap<>();
if(null != fieldKey || null != isTrend) { List<String> split= Arrays.asList(equipSpeId.split(","));
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(equipSpeId); List<IotIndexResVo> finalRes = new ArrayList<>();
iotCode = equipmentSpecific.getIotCode(); List<IotIndexResVo> finalResContainsWaterLevel = new ArrayList<>();
List<IotIndexResVo> resultResContainsWater = new ArrayList<>();
List<EquipmentIndex> equipmentSpecifics = equipmentIndexService.getPerfQutoaIotList(Long.valueOf(equipSpeId)); for (String specId : split) {
String eqpId;
if (equipmentSpecifics.size() == 0) { String iotCode = null;
return CommonResponseUtil.success(); if(null != fieldKey || null != isTrend) {
} EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(specId);
if ("true".equals(isTrend)) { iotCode = equipmentSpecific.getIotCode();
fieldKey = equipmentSpecifics.stream().filter(equipmentIndex -> equipmentIndex.getIsTrend()).map(EquipmentIndex::getPerfQuotaDefinitionId).collect(Collectors.joining(","));
} List<EquipmentIndex> equipmentSpecifics = equipmentIndexService.getPerfQutoaIotList(Long.valueOf(specId));
if (equipmentSpecifics.size() == 0) {
return CommonResponseUtil.success();
}
if ("true".equals(isTrend)) {
fieldKey = equipmentSpecifics.stream().filter(equipmentIndex -> equipmentIndex.getIsTrend()).map(EquipmentIndex::getPerfQuotaDefinitionId).collect(Collectors.joining(","));
}
} else {
if (StringUtil.isNotEmpty(equipSpeId)) {
eqpId = equipSpeId;
} else { } else {
TopographyNodeDetailDTO detailDTO = topographyNodeDetailService.queryByNodeid(id); if (StringUtil.isNotEmpty(specId)) {
if (null == detailDTO || !StringUtil.isNotEmpty(detailDTO.getEqpId())) { eqpId = specId;
throw new RuntimeException("节点信息错误或此节点下未绑定装备!"); } else {
TopographyNodeDetailDTO detailDTO = topographyNodeDetailService.queryByNodeid(id);
if (null == detailDTO || !StringUtil.isNotEmpty(detailDTO.getEqpId())) {
throw new RuntimeException("节点信息错误或此节点下未绑定装备!");
}
eqpId = detailDTO.getEqpId();
} }
eqpId = detailDTO.getEqpId();
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId);
iotCode = equipmentSpecific.getIotCode();
} }
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId); String prefix = null;
iotCode = equipmentSpecific.getIotCode(); String suffix = null;
} if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码不存在或编码错误,请确认!");
}
ResponseModel entity = null;
try {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix, fieldKey);
} catch (Exception e) {
throw new RuntimeException("调用AMOS-API-IOT服务失败,请检查服务是否正常!");
}
if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
String json = JSON.toJSONString(entity.getResult());
List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json);
List<IotDataVO> vos = new ArrayList<>();
for (Map<String, String> mapList : listObject) {
for (Map.Entry entry : mapList.entrySet()) {
if (!"name".equals(entry.getKey()) && !"deviceName".equals(entry.getKey())) {
IotDataVO vo = new IotDataVO();
vo.setKey(String.valueOf(entry.getKey()));
vo.setValue(String.valueOf(entry.getValue()));
vos.add(vo);
}
}
}
// List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList());
// List<Date> dates = new ArrayList<>();
Map<String, List<Date>> dateMap = new HashMap<>();
String indexKey = null;
String useDate = null;
for (IotDataVO vo : vos) {
if (!vo.getKey().equals("time")) {
indexKey = vo.getKey();
if (useDate != null) {
SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
if (!dateMap.containsKey(indexKey)) {
ArrayList<Date> dates1 = new ArrayList<>();
dates1.add(sdf1.parse(useDate));
dateMap.put(indexKey, dates1);
} else {
dateMap.get(indexKey).add(sdf1.parse(useDate));
}
}
} else {
String value = String.valueOf(vo.getValue());
String strDate = value.substring(0, 19);
SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC);
SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN);
logger.info("返回时间===================================(" + vo.getValue() + ") =======================================");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = sdf.parse(strDate);
String time = DateTimeUtil.format(date, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC);
if (indexKey == null) {
useDate = time;
}
// dates.add(sdf1.parse(time));
logger.info("返回时间===================================(" + sdf1.parse(time) + ") =======================================");
}
}
List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCodeAndTrend(iotCode);
if (0 < indexes.size()) {
List<TopographyIotIndexTrendVo> list = new ArrayList<>();
vos.forEach(iotDataVO -> {
indexes.forEach(x -> {
if (x.getNameKey().equals(iotDataVO.getKey())) {
TopographyIotIndexTrendVo vo = new TopographyIotIndexTrendVo();
vo.setId(x.getId());
vo.setName(x.getIndexName());
vo.setNameKey(x.getNameKey());
vo.setUnit(x.getIndexUnitName());
vo.setTimes(dateMap.get(x.getNameKey()));
vo.setIotData(iotDataVO);
list.add(vo);
}
});
});
Map<String, List<TopographyIotIndexTrendVo>> maps = list.stream().collect(Collectors.groupingBy(x -> x.getIotData().getKey()));
Map<String, List<IotDataVO>> map = new HashMap<>();
for (String str : maps.keySet()) {
map.put(str, maps.get(str).stream().map(TopographyIotIndexTrendVo::getIotData).collect(Collectors.toList()));
}
Map<String, Long> mapIndex = new HashMap<>();
String prefix = null; for (String str : maps.keySet()) {
String suffix = null; mapIndex.put(str, maps.get(str).get(0).getId());
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码不存在或编码错误,请确认!");
}
ResponseModel entity = null;
try {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix, fieldKey);
} catch (Exception e) {
throw new RuntimeException("调用AMOS-API-IOT服务失败,请检查服务是否正常!");
}
if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
String json = JSON.toJSONString(entity.getResult());
List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json);
List<IotDataVO> vos = new ArrayList<>();
for (Map<String, String> mapList : listObject) {
for (Map.Entry entry : mapList.entrySet()) {
if (!"name".equals(entry.getKey()) && !"deviceName".equals(entry.getKey())) {
IotDataVO vo = new IotDataVO();
vo.setKey(String.valueOf(entry.getKey()));
vo.setValue(String.valueOf(entry.getValue()));
vos.add(vo);
} }
}
}
List<IotDataVO> timeList = vos.stream().filter(x -> x.getKey().equals("time")).collect(Collectors.toList()); List<IotIndexResVo> res = new ArrayList<>();
List<Date> dates = new ArrayList<>(); List<IotIndexResVo> resContainsWaterLevelList = new ArrayList<>();
for (IotDataVO vo : timeList) { for (String s : mapIndex.keySet()) {
String value = String.valueOf(vo.getValue()); IotIndexResVo vo = new IotIndexResVo();
String strDate = value.substring(0, 19); LambdaQueryWrapper<EquipmentIndex> queryWrapper = new LambdaQueryWrapper<>();
SimpleDateFormat sdf = new SimpleDateFormat(ISO8601_DATE_HOUR_MIN_SEC); queryWrapper.eq(EquipmentIndex::getId, mapIndex.get(s));
SimpleDateFormat sdf1 = new SimpleDateFormat(DateUtils.DATE_TIME_PATTERN); EquipmentIndex index = iEquipmentIndexService.getOne(queryWrapper);
logger.info("返回时间===================================(" + vo.getValue() + ") ======================================="); vo.setIotData(map.get(s));
sdf.setTimeZone(TimeZone.getTimeZone("UTC")); vo.setId(index.getId());
Date date = sdf.parse(strDate); vo.setName(index.getPerfQuotaName());
vo.setNameKey(index.getPerfQuotaDefinitionId());
// String time= sdf.format(date); vo.setUnit(index.getUnitName());
String time = DateTimeUtil.format(date, DateTimeUtil.ISO_DATE_HOUR24_MIN_SEC); vo.setTimes(dateMap.get(index.getPerfQuotaDefinitionId()));
dates.add(sdf1.parse(time)); if (waterLevelIndexKey.contains(vo.getNameKey())) {
logger.info("返回时间===================================(" + sdf1.parse(time) + ") ======================================="); resContainsWaterLevelList.add(vo);
} } else {
List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCodeAndTrend(iotCode); res.add(vo);
if (0 < indexes.size()) {
List<TopographyIotIndexTrendVo> list = new ArrayList<>();
vos.forEach(iotDataVO -> {
indexes.forEach(x -> {
if (x.getNameKey().equals(iotDataVO.getKey())) {
TopographyIotIndexTrendVo vo = new TopographyIotIndexTrendVo();
vo.setId(x.getId());
vo.setName(x.getIndexName());
vo.setNameKey(x.getNameKey());
vo.setUnit(x.getIndexUnitName());
vo.setTimes(dates);
vo.setIotData(iotDataVO);
list.add(vo);
} }
}); }
});
Map<String, List<TopographyIotIndexTrendVo>> maps = list.stream().collect(Collectors.groupingBy(x -> x.getIotData().getKey())); for (IotIndexResVo s : res) {
Map<String, List<IotDataVO>> map = new HashMap<>(); s.setIotData(map.get(s.getNameKey()));
for (String str : maps.keySet()) { s.setTimes(dateMap.get(s.getNameKey()));
map.put(str, maps.get(str).stream().map(TopographyIotIndexTrendVo::getIotData).collect(Collectors.toList())); }
finalRes.addAll(res);
finalResContainsWaterLevel.addAll(resContainsWaterLevelList);
} }
}
}
List<Date> containsWaterDates = new ArrayList<>();
Map<Long, Map<Date, IotDataVO>> iotDataAndDateMap= new HashMap<>();
finalResContainsWaterLevel.stream().forEach(item -> {
containsWaterDates.addAll(item.getTimes());
Map<Date, IotDataVO> dateDataMap = new HashMap<>();
for (int i = 0; i < item.getTimes().size(); i++) {
dateDataMap.put(item.getTimes().get(i), item.getIotData().get(i));
}
iotDataAndDateMap.put(item.getId(), dateDataMap);
});
Map<String, Long> mapIndex = new HashMap<>();
for (String str : maps.keySet()) { List<Date> collect = containsWaterDates.stream().distinct().sorted(Comparator.comparing(t -> t)).collect(Collectors.toList());
mapIndex.put(str, maps.get(str).get(0).getId());
}
List<IotIndexResVo> res = new ArrayList<>();
for (String s : mapIndex.keySet()) {
IotIndexResVo vo = new IotIndexResVo();
LambdaQueryWrapper<EquipmentIndex> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(EquipmentIndex::getId, mapIndex.get(s));
EquipmentIndex index = iEquipmentIndexService.getOne(queryWrapper);
vo.setIotData(map.get(s));
vo.setId(index.getId());
vo.setName(index.getPerfQuotaName());
vo.setNameKey(index.getPerfQuotaDefinitionId());
vo.setUnit(index.getUnitName());
vo.setTimes(dates);
res.add(vo);
}
for (IotIndexResVo s : res) { for (IotIndexResVo indexResVo : finalResContainsWaterLevel) {
s.setIotData(map.get(s.getNameKey())); IotIndexResVo iotIndexRes = new IotIndexResVo();
s.setTimes(dates); iotIndexRes.setName(indexResVo.getName());
iotIndexRes.setTimes(collect);
iotIndexRes.setId(indexResVo.getId());
iotIndexRes.setNameKey(indexResVo.getNameKey());
iotIndexRes.setUnit(indexResVo.getUnit());
Map<Date, IotDataVO> dateIotDataVOMap = iotDataAndDateMap.get(indexResVo.getId());
List<IotDataVO> list = new ArrayList<>();
collect.forEach(item -> {
IotDataVO iotDataVO = new IotDataVO();
iotDataVO.setValue(0);
iotDataVO.setKey(indexResVo.getIotData().get(0).getKey());
if (dateIotDataVOMap.containsKey(item)) {
iotDataVO.setValue(dateIotDataVOMap.get(item).getValue());
} }
return CommonResponseUtil.success(res); list.add(iotDataVO);
} });
iotIndexRes.setIotData(list);
resultResContainsWater.add(iotIndexRes);
} }
return CommonResponseUtil.success(); resultMap.put("noMergeList", finalRes);
resultMap.put("mergeList", resultResContainsWater);
return CommonResponseUtil.success(resultMap);
} }
...@@ -990,59 +1066,92 @@ public class TopographyController extends AbstractBaseController { ...@@ -990,59 +1066,92 @@ public class TopographyController extends AbstractBaseController {
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(equipId); List<String> split= Arrays.asList(equipId.split(","));
String iotCode = equipmentSpecific.getIotCode(); String allKeys = null;
String names = null;
List<IotIndexItemVo> iotIndexItemVos = new ArrayList<>();
List<IotIndexItemVo> iotIndexItemVoListNew = new ArrayList<>();
Map<String, String> keyIotMap = new HashMap<>();
Map<String, String> map = new HashMap<>();
Map<String, String> typeNameMap = new HashMap<>();
Map<String, String> typeCodeAndIndexKeyMap = new HashMap<>();
List<String> typeCodeList = new ArrayList<>();
List<String> typeNameList = new ArrayList<>();
List<EquipmentIndex> equipmentSpecifics = equipmentIndexService.getPerfQutoaIotList(Long.valueOf(equipId)); List<String> indexKeyList = new ArrayList<>();
for (String specificId : split) {
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(specificId);
String iotCode = equipmentSpecific.getIotCode();
if (equipmentSpecifics.size() == 0) { List<EquipmentIndex> equipmentSpecifics = equipmentIndexService.getPerfQutoaIotList(Long.valueOf(specificId));
return CommonResponseUtil.success();
}
String allKeys;
String names;
Map<String, String> map = new HashMap<>();
List<IotIndexItemVo> iotIndexItemVos = new ArrayList<>();
equipmentSpecifics.stream().forEach((e)->{ if (equipmentSpecifics.size() == 0) {
IotIndexItemVo itemVo = new IotIndexItemVo(); return CommonResponseUtil.success();
if(!e.getIsTrend()) {
map.put(e.getPerfQuotaDefinitionId(),e.getPerfQuotaName());
itemVo.setKey(e.getPerfQuotaDefinitionId());
itemVo.setName(e.getPerfQuotaName());
itemVo.setColor(e.getEmergencyLevelColor());
iotIndexItemVos.add(itemVo);
} }
});
equipmentSpecifics.stream().forEach((e)->{
IotIndexItemVo itemVo = new IotIndexItemVo();
IotIndexItemVo indexItemVo = new IotIndexItemVo();
if(!e.getIsTrend()) {
allKeys = equipmentSpecifics.stream().filter(equipmentIndex -> !equipmentIndex.getIsTrend()).map(EquipmentIndex::getPerfQuotaDefinitionId).collect(Collectors.joining(",")); if (!typeNameMap.containsKey(e.getTypeCode())) {
names = equipmentSpecifics.stream().filter(equipmentIndex -> !equipmentIndex.getIsTrend()).map(EquipmentIndex::getPerfQuotaName).collect(Collectors.joining(",")); indexItemVo.setKey(e.getTypeCode());
indexItemVo.setName(e.getTypeName());
indexItemVo.setColor(e.getEmergencyLevelColor());
iotIndexItemVoListNew.add(indexItemVo);
}
map.put(e.getPerfQuotaDefinitionId(),e.getPerfQuotaName());
typeNameMap.put(e.getTypeCode(), e.getTypeName());
itemVo.setKey(e.getPerfQuotaDefinitionId());
itemVo.setName(e.getPerfQuotaName());
itemVo.setColor(e.getEmergencyLevelColor());
keyIotMap.put(e.getPerfQuotaDefinitionId() + iotCode, iotCode);
iotIndexItemVos.add(itemVo);
typeCodeAndIndexKeyMap.put(e.getPerfQuotaDefinitionId(), e.getTypeCode());
}
});
typeCodeList.addAll(equipmentSpecifics.stream().filter(equipmentIndex -> !equipmentIndex.getIsTrend()).map(EquipmentIndex::getTypeCode).distinct().collect(Collectors.toList()));
typeNameList.addAll(equipmentSpecifics.stream().filter(equipmentIndex -> !equipmentIndex.getIsTrend()).map(EquipmentIndex::getTypeName).distinct().collect(Collectors.toList()));
indexKeyList.addAll(equipmentSpecifics.stream().filter(equipmentIndex -> !equipmentIndex.getIsTrend()).map(t -> {
return t.getPerfQuotaDefinitionId() + iotCode;
}).distinct().collect(Collectors.toList()));
}
allKeys = typeCodeList.stream().distinct().collect(Collectors.joining(","));
names = typeNameList.stream().distinct().collect(Collectors.joining(","));
String parmfieldKey = ""; String parmfieldKey = "";
String parmfieldName = ""; String parmfieldName = "";
if(StringUtils.isEmpty(fieldKey) ) { if(StringUtils.isEmpty(fieldKey) ) {
parmfieldKey = allKeys; parmfieldKey = allKeys;
parmfieldName = names;
} else { } else {
parmfieldKey = fieldKey; parmfieldKey = fieldKey;
for(String s: fieldKey.split(",") ) { for(String s: fieldKey.split(",") ) {
parmfieldName = parmfieldName + map.get(s) + ","; parmfieldName = parmfieldName + typeNameMap.get(s) + ",";
} }
} }
String prefix = null;
String suffix = null;
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码不存在或编码错误,请确认!");
}
ResponseModel entity = null; ResponseModel entity = null;
String[] filedKeyArr = parmfieldKey.split(","); String[] filedKeyArr = parmfieldKey.split(",");
List<IotIndexResMinotVo> res = new ArrayList<>(); List<IotIndexResMinotVo> res = new ArrayList<>();
IotIndexResMinotFinalVo indexResMinotFinalVo = new IotIndexResMinotFinalVo(); IotIndexResMinotFinalVo indexResMinotFinalVo = new IotIndexResMinotFinalVo();
List<Date> datesFinal = new ArrayList<>(); List<Date> datesFinal = new ArrayList<>();
for (String st : filedKeyArr) { for (String indexKey : indexKeyList) {
String prefix = null;
String suffix = null;
String iotCode = keyIotMap.get(indexKey);
String st = "";
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
st = indexKey.substring(0, indexKey.length() - 16);
} else {
return CommonResponseUtil.failure("装备物联编码不存在或编码错误,请确认!");
}
try { try {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix, st); entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix, st);
} catch (Exception e) { } catch (Exception e) {
...@@ -1154,17 +1263,43 @@ public class TopographyController extends AbstractBaseController { ...@@ -1154,17 +1263,43 @@ public class TopographyController extends AbstractBaseController {
if(iotData.size() == 0) { if(iotData.size() == 0) {
fullData(iotIndexItemVos,iotData,times,map); fullData(iotIndexItemVos,iotData,times,map);
} }
List<IotIndexResItemVo> iotIndexResItemVos = doIndexData(iotData, typeNameMap, typeCodeAndIndexKeyMap);
indexResMinotFinalVo.setTimes(times); indexResMinotFinalVo.setTimes(times);
indexResMinotFinalVo.setNameKey(StringUtils.isEmpty(fieldKey) ? allKeys.split(",") : fieldKey.split(",")); indexResMinotFinalVo.setNameKey(StringUtils.isEmpty(fieldKey) ? allKeys.toString().split(",") : fieldKey.split(","));
indexResMinotFinalVo.setName(StringUtils.isEmpty(fieldKey) ? names.split(",") : parmfieldName.split(",")); indexResMinotFinalVo.setName(StringUtils.isEmpty(fieldKey) ? names.toString().split(",") : parmfieldName.split(","));
indexResMinotFinalVo.setItems(iotIndexItemVos); indexResMinotFinalVo.setItems(iotIndexItemVoListNew);
indexResMinotFinalVo.setIotData(iotData); indexResMinotFinalVo.setIotData(iotIndexResItemVos);
} }
return CommonResponseUtil.success(indexResMinotFinalVo); return CommonResponseUtil.success(indexResMinotFinalVo);
} }
private List<IotIndexResItemVo> doIndexData(List<IotIndexResItemVo> iotData, Map<String, String> typeNameMap, Map<String, String> typeCodeAndIndexKeyMap) {
iotData.stream().forEach(item -> {
item.setKey(typeCodeAndIndexKeyMap.get(item.getKey()));
item.setName(typeNameMap.get(item.getKey()));
});
Map<String, IotIndexResItemVo> map = new HashMap<>();
List<IotIndexResItemVo> iotDataNew = new ArrayList<>();
for (IotIndexResItemVo iotDatum : iotData) {
if (!map.containsKey(iotDatum.getKey())) {
map.put(iotDatum.getKey(), iotDatum);
} else {
IotIndexResItemVo iotIndexResItemVo = map.get(iotDatum.getKey());
int i = 0;
for (int datum : iotIndexResItemVo.getData()) {
iotIndexResItemVo.getData()[i] = datum + iotDatum.getData()[i];
i++;
}
}
}
for (Map.Entry<String, IotIndexResItemVo> stringIotIndexResItemVoEntry : map.entrySet()) {
iotDataNew.add(stringIotIndexResItemVoEntry.getValue());
}
return iotDataNew;
}
private void fullData(List<IotIndexItemVo> iotIndexItemVos, List<IotIndexResItemVo> iotData, List<String> times, Map<String, String> map ) { private void fullData(List<IotIndexItemVo> iotIndexItemVos, List<IotIndexResItemVo> iotData, List<String> times, Map<String, String> map ) {
for(IotIndexItemVo iVo: iotIndexItemVos) { for(IotIndexItemVo iVo: iotIndexItemVos) {
IotIndexResItemVo itVo = new IotIndexResItemVo(); IotIndexResItemVo itVo = new IotIndexResItemVo();
...@@ -1232,7 +1367,7 @@ public class TopographyController extends AbstractBaseController { ...@@ -1232,7 +1367,7 @@ public class TopographyController extends AbstractBaseController {
for (String dat : dates) { for (String dat : dates) {
if (DateUtils.belongCalendar(dateParse(dat), bDate, dDate)) { if (DateUtils.belongCalendar(dateParse(dat), bDate, dDate)) {
if ("true".equals(timeAndValue.get(dat))) { if (("true".equals(timeAndValue.get(dat))) || (!"true".equals(timeAndValue.get(dat)) && !"false".equals(timeAndValue.get(dat)))) {
num++; num++;
} }
} }
......
...@@ -121,4 +121,7 @@ state.code=GW190301 ...@@ -121,4 +121,7 @@ state.code=GW190301
state.name=\u9526\u5c4f\u6362\u6d41\u7ad9 state.name=\u9526\u5c4f\u6362\u6d41\u7ad9
# 是否开启遥测数据上报 # 是否开启遥测数据上报
is.open.telemetering=false is.open.telemetering=false
\ No newline at end of file
# 水池液位相关信号
water.level.indexKey=FHS_FirePoolDevice_WaterLevel,FHS_LevelDetector_WaterLevel,FHS_WirelessliquidDetector_WaterLevel,CAFS_FoamTank_FoamTankLevel,CAFS_WaterTank_WaterTankLevel
\ No newline at end of file
...@@ -225,7 +225,7 @@ ...@@ -225,7 +225,7 @@
group_name group_name
</select> </select>
<select id="getPerfQutoaIotList" resultType="com.yeejoin.equipmanage.common.entity.EquipmentIndex"> <select id="getPerfQutoaIotList" resultType="com.yeejoin.equipmanage.common.entity.EquipmentIndex">
select id,name as perfQuotaName, name_key as perfQuotaDefinitionId,is_trend as isTrend,emergency_level_color as emergencyLevelColor from wl_equipment_index s where equipment_id = ( select id,name as perfQuotaName, name_key as perfQuotaDefinitionId,is_trend as isTrend,emergency_level_color as emergencyLevelColor, type_name as typeName, type_code as typeCode from wl_equipment_index s where equipment_id = (
select equipment_id from wl_equipment_detail wei where id = ( select equipment_id from wl_equipment_detail wei where id = (
select equipment_detail_id from wl_equipment_specific where id = #{id}) select equipment_detail_id from wl_equipment_specific where id = #{id})
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment