Commit 268d94f5 authored by KeYong's avatar KeYong

接口更新参数

parent 79218d84
...@@ -13,6 +13,8 @@ import lombok.Data; ...@@ -13,6 +13,8 @@ import lombok.Data;
@Data @Data
public class TopographyIotDataVO { public class TopographyIotDataVO {
private Long id;
private String name; private String name;
private Object value; private Object value;
......
package com.yeejoin.equipmanage.common.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author keyong
* @title: TopographyAlarmVo
* <pre>
* @description: TODO
* </pre>
* @date 2022/01/12 18:57
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TopographyIotIndexTrendVo {
private Long id;
private String name;
private String nameKey;
private String unit;
private IotDataVO iotData;
}
...@@ -38,6 +38,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -38,6 +38,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -785,6 +786,7 @@ public class TopographyController extends AbstractBaseController { ...@@ -785,6 +786,7 @@ public class TopographyController extends AbstractBaseController {
iotVo.setTime(x.getUpdateDate()); iotVo.setTime(x.getUpdateDate());
if (x.getNameKey().equals(iotDataVO.getKey())) { if (x.getNameKey().equals(iotDataVO.getKey())) {
TopographyIotDataVO dataVO = new TopographyIotDataVO(); TopographyIotDataVO dataVO = new TopographyIotDataVO();
dataVO.setId(x.getId());
dataVO.setName(x.getIndexName()); dataVO.setName(x.getIndexName());
dataVO.setValue(x.getValue()); dataVO.setValue(x.getValue());
dataVO.setUnit(x.getIndexUnitName()); dataVO.setUnit(x.getIndexUnitName());
...@@ -826,8 +828,71 @@ public class TopographyController extends AbstractBaseController { ...@@ -826,8 +828,71 @@ public class TopographyController extends AbstractBaseController {
eqpId = detailDTO.getEqpId(); eqpId = detailDTO.getEqpId();
} }
EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId); EquipmentSpecific equipmentSpecific = equipmentSpecificService.getById(eqpId);
String iotCode = equipmentSpecific.getIotCode();
String prefix = null;
String suffix = null;
if (iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
return CommonResponseUtil.failure("装备物联编码错误,请确认!");
}
LonAndLatEntityVo lonAndLatEntityVo = new LonAndLatEntityVo();
String url = iotServerName;
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("Content-Type", "application/json");
headers.set("product", getProduct());
headers.set("token", getToken());
headers.set("appKey", getAppKey());
HttpEntity httpEntity = new HttpEntity<>(lonAndLatEntityVo, headers);
ResponseEntity<FeignClientResult> feignClientResult = null;
try {
feignClientResult = restTemplate.exchange("http://" + url
+ "/iot/v1/livedata/list?timeStart=" + beginDate + "&timeEnd=" + endDate + "&productKey=" + prefix + "&deviceName=" + suffix,
HttpMethod.GET, httpEntity, FeignClientResult.class);
} catch (Exception e) {
e.printStackTrace();
}
if (null != feignClientResult && feignClientResult.getBody().getStatus() == 200) {
if (null != feignClientResult.getBody().getResult()) {
String json = JSON.toJSONString(feignClientResult.getBody().getResult());
JSONObject jsonObject = JSONObject.parseObject(json);
Iterator it = jsonObject.entrySet().iterator();
List<IotDataVO> iotDatalist = new ArrayList<IotDataVO>();
while (it.hasNext()) {
IotDataVO iotDataVO = new IotDataVO();
Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next();
if (!"name".equals(entry.getKey()) || !"deviceName".equals(entry.getKey()) || !"time".equals(entry.getKey())) {
iotDataVO.setKey(entry.getKey());
iotDataVO.setValue(entry.getValue());
}
iotDatalist.add(iotDataVO);
}
List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCodeAndTrend(iotCode);
if (0 <indexes.size()) {
List<TopographyIotIndexTrendVo> list = new ArrayList<>();
indexes.forEach(x -> {
iotDatalist.forEach(iotDataVO -> {
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.setIotData(iotDataVO);
list.add(vo);
}
});
});
Map<Long, List<TopographyIotIndexTrendVo>> resMap = list.stream().collect(Collectors.groupingBy(x -> x.getId()));
return CommonResponseUtil.success(resMap);
}
}
} else {
logger.error("注:iotCode为 (" + iotCode + ") 的装备不存在于物联系统中!");
return CommonResponseUtil.success();
}
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
......
...@@ -46,6 +46,8 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif ...@@ -46,6 +46,8 @@ public interface EquipmentSpecificIndexMapper extends BaseMapper<EquipmentSpecif
*/ */
List<EquipmentSpecificIndex> getEquipmentSpeIndexByIotCode(String iotCode); List<EquipmentSpecificIndex> getEquipmentSpeIndexByIotCode(String iotCode);
List<EquipmentSpecificIndex> getEquipmentSpeIndexByIotCodeAndTrend(String iotCode);
List<EquipmentSpecificIndex> getEquipmentSpeIndexDataByIotCode(String iotCode); List<EquipmentSpecificIndex> getEquipmentSpeIndexDataByIotCode(String iotCode);
/** /**
......
...@@ -88,6 +88,30 @@ ...@@ -88,6 +88,30 @@
wes.iot_code = #{iotCode} wes.iot_code = #{iotCode}
</select> </select>
<select id="getEquipmentSpeIndexByIotCodeAndTrend" resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT
wei.id AS id,
wei.name_key AS nameKey,
wesi.value AS value,
wesi.equipment_specific_id AS equipmentSpecificId,
wesi.equipment_index_id AS equipmentIndexId,
wes.org_code AS code,
wes.iot_code AS iotCode,
wes.org_code AS orgCode,
wei.type_code AS typeCode,
wei.name AS indexName,
wei.unit AS indexUnitName,
wesi.update_date AS updateDate
FROM
wl_equipment_specific_index AS wesi
LEFT JOIN wl_equipment_specific AS wes ON wes.id = wesi.equipment_specific_id
LEFT JOIN wl_equipment_index AS wei ON wei.id = wesi.equipment_index_id
WHERE
wes.iot_code = #{iotCode}
AND
wei.is_trend = 1
</select>
<select id="getEquipmentSpeIndexDataByIotCode" <select id="getEquipmentSpeIndexDataByIotCode"
resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex"> resultType="com.yeejoin.equipmanage.common.entity.EquipmentSpecificIndex">
SELECT SELECT
......
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