Commit 77c46594 authored by KeYong's avatar KeYong

修复bug

parent cfcfc6de
...@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray; ...@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.equipmanage.common.entity.*; import com.yeejoin.equipmanage.common.entity.*;
import com.yeejoin.equipmanage.common.entity.dto.TopographyLineDTO; import com.yeejoin.equipmanage.common.entity.dto.TopographyLineDTO;
import com.yeejoin.equipmanage.common.entity.dto.TopographyNodeDTO; import com.yeejoin.equipmanage.common.entity.dto.TopographyNodeDTO;
...@@ -23,16 +22,14 @@ import com.yeejoin.equipmanage.service.impl.TopographyService; ...@@ -23,16 +22,14 @@ import com.yeejoin.equipmanage.service.impl.TopographyService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import liquibase.pro.packaged.S;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.*; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -84,8 +81,6 @@ public class TopographyController extends AbstractBaseController { ...@@ -84,8 +81,6 @@ public class TopographyController extends AbstractBaseController {
@Autowired @Autowired
EquipmentSpecificAlarmMapper equipmentSpecificAlarmMapper; EquipmentSpecificAlarmMapper equipmentSpecificAlarmMapper;
@Autowired @Autowired
private RestTemplate restTemplate;
@Autowired
FireFightingSystemMapper fireFightingSystemMapper; FireFightingSystemMapper fireFightingSystemMapper;
@Autowired @Autowired
IEquipmentSpecificAlarmService iEquipmentSpecificAlarmService; IEquipmentSpecificAlarmService iEquipmentSpecificAlarmService;
...@@ -96,6 +91,8 @@ public class TopographyController extends AbstractBaseController { ...@@ -96,6 +91,8 @@ public class TopographyController extends AbstractBaseController {
@Autowired @Autowired
IEquipmentService iEquipmentService; IEquipmentService iEquipmentService;
@Autowired @Autowired
IEquipmentIndexService iEquipmentIndexService;
@Autowired
IotFeign iotFeign; IotFeign iotFeign;
@Value("${iot.vehicle.track}") @Value("${iot.vehicle.track}")
private String iotServerName; private String iotServerName;
...@@ -750,63 +747,64 @@ public class TopographyController extends AbstractBaseController { ...@@ -750,63 +747,64 @@ public class TopographyController extends AbstractBaseController {
} else { } else {
return CommonResponseUtil.failure("装备物联编码错误,请确认!"); return CommonResponseUtil.failure("装备物联编码错误,请确认!");
} }
LonAndLatEntityVo lonAndLatEntityVo = new LonAndLatEntityVo(); ResponseModel entity = null;
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 { try {
feignClientResult = restTemplate.exchange("http://" + url entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix);
+ "/iot/v1/livedata/list?timeStart=" + beginDate + "&timeEnd=" + endDate + "&productKey=" + prefix + "&deviceName=" + suffix,
HttpMethod.GET, httpEntity, FeignClientResult.class);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (null != feignClientResult && feignClientResult.getBody().getStatus() == 200) { if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
List<TopographyIotVo> list = new ArrayList<>(); List<TopographyIotVo> list = new ArrayList<>();
if (null != feignClientResult.getBody().getResult()) { String json = JSON.toJSONString(entity.getResult());
String json = JSON.toJSONString(feignClientResult.getBody().getResult()); List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json);
JSONObject jsonObject = JSONObject.parseObject(json); List<IotDataVO> iotDatalist = new ArrayList<>();
Iterator it = jsonObject.entrySet().iterator(); for(Map<String, String> mapList : listObject) {
List<IotDataVO> iotDatalist = new ArrayList<IotDataVO>(); for (Map.Entry entry : mapList.entrySet()) {
while (it.hasNext()) { if (!"name".equals(entry.getKey()) && !"deviceName".equals(entry.getKey())) {
IotDataVO iotDataVO = new IotDataVO(); IotDataVO iotDataVO = new IotDataVO();
Map.Entry<String, Object> entry = (Map.Entry<String, Object>) it.next(); iotDataVO.setKey(String.valueOf(entry.getKey()));
if (!"name".equals(entry.getKey()) || !"deviceName".equals(entry.getKey()) || !"time".equals(entry.getKey())) {
iotDataVO.setKey(entry.getKey());
iotDataVO.setValue(entry.getValue()); iotDataVO.setValue(entry.getValue());
iotDatalist.add(iotDataVO);
} }
iotDatalist.add(iotDataVO);
} }
List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCode(iotCode); }
if (0 <indexes.size()) { List<IotDataVO> timeList = iotDatalist.stream().filter(x -> "time".equals(x.getKey())).collect(Collectors.toList());
iotDatalist.forEach(iotDataVO -> { List<EquipmentSpecificIndex> indexes = equipmentSpecificIndexMapper.getEquipmentSpeIndexByIotCode(iotCode);
TopographyIotVo iotVo = new TopographyIotVo(); if (0 <indexes.size()) {
List<TopographyIotDataVO> lists = new ArrayList<TopographyIotDataVO>(); int j = 0;
indexes.forEach(x -> { Map<String, Object> map = new HashMap<>();
iotVo.setTime(x.getUpdateDate()); for (int i=0; i<iotDatalist.size(); i++) {
if (x.getNameKey().equals(iotDataVO.getKey())) { TopographyIotVo iotVo = new TopographyIotVo();
TopographyIotDataVO dataVO = new TopographyIotDataVO(); List<TopographyIotDataVO> lists = new ArrayList<>();
dataVO.setId(x.getId()); if (i == 0) {
dataVO.setName(x.getIndexName()); map.put(iotDatalist.get(i).getKey(), iotDatalist.get(i).getValue());
dataVO.setValue(x.getValue()); }
dataVO.setUnit(x.getIndexUnitName()); if (map.containsKey(iotDatalist.get(i).getKey())) {
lists.add(dataVO); j++;
} }
}); for (EquipmentSpecificIndex x : indexes) {
if (x.getNameKey().equals(iotDatalist.get(i).getKey())) {
TopographyIotDataVO dataVO = new TopographyIotDataVO();
dataVO.setId(x.getId());
dataVO.setName(x.getIndexName());
dataVO.setValue(x.getValue());
dataVO.setUnit(x.getIndexUnitName());
lists.add(dataVO);
iotVo.setList(lists); iotVo.setList(lists);
try {
Date date = DateUtils.dateParse(String.valueOf(timeList.get(j-1).getValue()), DateUtils.DATE_TIME_T_PATTERN);
iotVo.setTime(date);
} catch (Exception e) {
e.printStackTrace();
}
list.add(iotVo); list.add(iotVo);
}); }
}
} }
} }
return CommonResponseUtil.success(list); return CommonResponseUtil.success(list);
} else { } else {
logger.error("注:iotCode为 (" + iotCode + ") 的装备不存在于物联系统中!"); logger.error("查询物联日志数据为空或iotCode为 (" + iotCode + ") 的装备不存在于物联系统中!");
return CommonResponseUtil.success(); return CommonResponseUtil.success();
} }
} }
...@@ -843,21 +841,13 @@ public class TopographyController extends AbstractBaseController { ...@@ -843,21 +841,13 @@ public class TopographyController extends AbstractBaseController {
} else { } else {
return CommonResponseUtil.failure("装备物联编码错误,请确认!"); 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());
ResponseModel entity = null; ResponseModel entity = null;
try { try {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix); entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), beginDate, endDate, prefix, suffix);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (200 == entity.getStatus() && StringUtil.isNotEmpty(entity.getResult())) { if (200 == entity.getStatus() && !ObjectUtils.isEmpty(entity.getResult())) {
String json = JSON.toJSONString(entity.getResult()); String json = JSON.toJSONString(entity.getResult());
List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json); List<Map<String, String>> listObject = (List<Map<String, String>>) JSONArray.parse(json);
List<IotDataVO> vos = new ArrayList<>(); List<IotDataVO> vos = new ArrayList<>();
...@@ -895,29 +885,25 @@ public class TopographyController extends AbstractBaseController { ...@@ -895,29 +885,25 @@ public class TopographyController extends AbstractBaseController {
} }
}); });
}); });
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()));
}
List<IotIndexResVo> res = new ArrayList<>(); List<IotIndexResVo> res = new ArrayList<>();
Long equId = 0L; for (String s : map.keySet()) {
String name = ""; IotIndexResVo vo = new IotIndexResVo();
String nameKey = ""; LambdaQueryWrapper <EquipmentIndex> queryWrapper = new LambdaQueryWrapper<>();
String unit = ""; queryWrapper.eq(EquipmentIndex::getPerfQuotaDefinitionId, s);
IotIndexResVo vo = new IotIndexResVo(); EquipmentIndex index = iEquipmentIndexService.getOne(queryWrapper);
if (0 < list.size()) { vo.setIotData(map.get(s));
List<IotDataVO> dataVOS = new ArrayList<>(); vo.setId(index.getId());
for (TopographyIotIndexTrendVo trendVo : list) { vo.setName(index.getPerfQuotaName());
dataVOS.add(trendVo.getIotData()); vo.setNameKey(index.getPerfQuotaDefinitionId());
equId = trendVo.getId(); vo.setUnit(index.getUnitName());
name = trendVo.getName(); vo.setTimes(dates);
nameKey = trendVo.getNameKey(); res.add(vo);
unit = trendVo.getUnit(); }
}
vo.setId(equId);
vo.setName(name);
vo.setNameKey(nameKey);
vo.setUnit(unit);
vo.setTimes(dates);
vo.setIotData(dataVOS);
res.add(vo);
}
return CommonResponseUtil.success(res); return CommonResponseUtil.success(res);
} }
} }
......
...@@ -252,8 +252,8 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec ...@@ -252,8 +252,8 @@ public class EquipmentSpecificAlarmServiceImpl extends ServiceImpl<EquipmentSpec
|| AlarmTypeEnum.PB.getCode().equals(type)) { || AlarmTypeEnum.PB.getCode().equals(type)) {
dataVO.setAlarmType(AlarmTypeEnum.getTypeByCode(String.valueOf(type))); dataVO.setAlarmType(AlarmTypeEnum.getTypeByCode(String.valueOf(type)));
} }
dataVO.setAlarmContent(x.get("fireEquipmentName") + dataVO.getAlarmType()); dataVO.setAlarmContent(String.valueOf(x.get("alamContent")));
dataVO.setHandleType(null == x.get("handleType") ? null : String.valueOf(x.get("handleType"))); dataVO.setHandleType(null == x.get("handleType") ? null : ConfirmAlamEnum.getTypeByCode(String.valueOf(x.get("handleType"))));
res.add(dataVO); res.add(dataVO);
}); });
} }
......
...@@ -336,7 +336,7 @@ ...@@ -336,7 +336,7 @@
wlesal.create_date AS createDate, wlesal.create_date AS createDate,
wlesal.build_id AS buildId, wlesal.build_id AS buildId,
wlesa.recovery_date AS recoveryDate, wlesa.recovery_date AS recoveryDate,
wlesal.location AS warehouseStructureName, CONCAT_WS(' ',ware.full_name,wsd.description) AS warehouseStructureName,
( (
SELECT SELECT
group_concat(fet.`name`) group_concat(fet.`name`)
...@@ -349,7 +349,12 @@ ...@@ -349,7 +349,12 @@
FROM FROM
wl_equipment_specific_alarm_log wlesal wl_equipment_specific_alarm_log wlesal
LEFT JOIN wl_equipment we ON wlesal.equipment_code = we.code LEFT JOIN wl_equipment we ON wlesal.equipment_code = we.code
LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id) d LEFT JOIN wl_equipment_specific wles ON wlesal.equipment_specific_id = wles.id
LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id
LEFT JOIN wl_stock_detail as wsd on wsd.equipment_specific_id = wlesal.equipment_specific_id
LEFT JOIN wl_warehouse_structure as ware on wsd.warehouse_structure_id = ware.id
LEFT JOIN wl_equipment_detail wled ON wles.equipment_detail_id = wled.id
) d
WHERE d.fireEquipmentName IS NOT NULL WHERE d.fireEquipmentName IS NOT NULL
<if test="param.warehouseStructureName != null and param.warehouseStructureName != ''">and <if test="param.warehouseStructureName != null and param.warehouseStructureName != ''">and
d.warehouseStructureName like d.warehouseStructureName like
......
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