Commit 4fc4df38 authored by KeYong's avatar KeYong

Merge remote-tracking branch 'origin/develop_dl' into develop_dl

parents 62347008 e8e18567
...@@ -8,7 +8,7 @@ public class EquipTrendResultVo { ...@@ -8,7 +8,7 @@ public class EquipTrendResultVo {
private List<String> legends; private List<String> legends;
private String yAxisName; private String yAxisName;
private List<String> xAxisData; private List<String> xAxisData;
private List<List<String>> yAxisData; private List<List<Object>> yAxisData;
private List<List<String>> threshold; private List<List<String>> threshold;
public List<String> getLegends() { public List<String> getLegends() {
...@@ -35,11 +35,11 @@ public class EquipTrendResultVo { ...@@ -35,11 +35,11 @@ public class EquipTrendResultVo {
this.xAxisData = xAxisData; this.xAxisData = xAxisData;
} }
public List<List<String>> getyAxisData() { public List<List<Object>> getyAxisData() {
return yAxisData; return yAxisData;
} }
public void setyAxisData(List<List<String>> yAxisData) { public void setyAxisData(List<List<Object>> yAxisData) {
this.yAxisData = yAxisData; this.yAxisData = yAxisData;
} }
......
...@@ -873,4 +873,27 @@ public class SupervisionConfigureController extends AbstractBaseController { ...@@ -873,4 +873,27 @@ public class SupervisionConfigureController extends AbstractBaseController {
EquipTrendResultVo equipTrendResultVo = equipmentSpecificService.operatingTrendPressurePump(startTime, endTime, bizOrgCode, equipCode, indexKey); EquipTrendResultVo equipTrendResultVo = equipmentSpecificService.operatingTrendPressurePump(startTime, endTime, bizOrgCode, equipCode, indexKey);
return CommonResponseUtil.success(equipTrendResultVo); return CommonResponseUtil.success(equipTrendResultVo);
} }
@PersonIdentify
@RequestMapping(value = "/operatingTrendWater", method = RequestMethod.GET)
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "设备平台运行趋势 水池液位趋势API", produces = "application/json;charset=UTF-8", notes = "设备平台运行趋势 水池液位趋势API")
public ResponseModel operatingTrendWater(@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "bizOrgCode", required = false) String bizOrgCode,
@RequestParam(value = "equipCode", required = false) String equipCode,
@RequestParam(value = "indexKey", required = false) String indexKey) throws ParseException {
if (ObjectUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(null);
}
}
}
EquipTrendResultVo equipTrendResultVo = equipmentSpecificService.operatingTrendWater(startTime, endTime, bizOrgCode, equipCode, indexKey);
return CommonResponseUtil.success(equipTrendResultVo);
}
} }
...@@ -75,18 +75,20 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -75,18 +75,20 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
/** /**
* 根据画布id获取画布绑定设备最新指标状态 * 根据画布id获取画布绑定设备最新指标状态
*
* @param sceneId * @param sceneId
* @return * @return
*/ */
List<EquipmentSpecificIndex> getEquipLatestStatusBySceneId(String sceneId); List<EquipmentSpecificIndex> getEquipLatestStatusBySceneId(String sceneId);
List<Map<String, Object>> getStatusAll(@Param("sceneId")String sceneId);
List<Map<String, Object>> getStatusAll(@Param("sceneId") String sceneId);
List<String> getEquipmentIotCodeLists(); List<String> getEquipmentIotCodeLists();
List<HashMap<String, Object>> getEquipBySourceId(@Param("sourceIds") List<Long> sourceIds, @Param("categoryId") List<Long> categoryId, @Param("equipCode") String equipCode, @Param("equipName") String equipName,@Param("companyId") String companyId,@Param("current") Long current,@Param("size") Long size); List<HashMap<String, Object>> getEquipBySourceId(@Param("sourceIds") List<Long> sourceIds, @Param("categoryId") List<Long> categoryId, @Param("equipCode") String equipCode, @Param("equipName") String equipName, @Param("companyId") String companyId, @Param("current") Long current, @Param("size") Long size);
int getEquipBySourceIdCount(@Param("sourceIds") List<Long> sourceIds, @Param("categoryId") List<Long> categoryId, @Param("equipCode") String equipCode, @Param("equipName") String equipName,@Param("companyId") String companyId); int getEquipBySourceIdCount(@Param("sourceIds") List<Long> sourceIds, @Param("categoryId") List<Long> categoryId, @Param("equipCode") String equipCode, @Param("equipName") String equipName, @Param("companyId") String companyId);
List getMenuChildren(@Param("id") Long id); List getMenuChildren(@Param("id") Long id);
...@@ -167,18 +169,19 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -167,18 +169,19 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List<MaintenanceResourceData> getSysEquipClassifyDataList(); List<MaintenanceResourceData> getSysEquipClassifyDataList();
IPage<MaintenanceResourceDataVo> getSysEquipClassifyDataPage(Page page, Long fireFightSysId, String fireFacilityName, String classifyId, Long fireFacilityId, List<Long> buildingId,List<String> bandWbCompany); IPage<MaintenanceResourceDataVo> getSysEquipClassifyDataPage(Page page, Long fireFightSysId, String fireFacilityName, String classifyId, Long fireFacilityId, List<Long> buildingId, List<String> bandWbCompany);
IPage<MaintenanceResourceDataVo> getEquipClassifyDataPage(Page page, Long fireFightSysId, String fireFacilityName, String classifyId, Long fireFacilityId, List<Long> buildingId,List<String> bandWbCompany); IPage<MaintenanceResourceDataVo> getEquipClassifyDataPage(Page page, Long fireFightSysId, String fireFacilityName, String classifyId, Long fireFacilityId, List<Long> buildingId, List<String> bandWbCompany);
List<UserDto> getEquipSpecificLocationInfo(Long equipmentSpecificId, String[] fieldName); List<UserDto> getEquipSpecificLocationInfo(Long equipmentSpecificId, String[] fieldName);
Map<String,Double> getEquipLocationInfo(Long equipmentSpecificId); Map<String, Double> getEquipLocationInfo(Long equipmentSpecificId);
Map<String, Object> getEquipSpeInfo(@Param("equipmentSpecificId") Long equipmentSpecificId); Map<String, Object> getEquipSpeInfo(@Param("equipmentSpecificId") Long equipmentSpecificId);
/** /**
* 根据specificId删除装备相关数据 * 根据specificId删除装备相关数据
*
* @param specificId specificId * @param specificId specificId
*/ */
// void deleteEquipDataBySpecificId(@Param("specificId") Long specificId, @Param("equipDetailId") Long equipDetailId); // void deleteEquipDataBySpecificId(@Param("specificId") Long specificId, @Param("equipDetailId") Long equipDetailId);
...@@ -202,31 +205,36 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -202,31 +205,36 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
/** /**
* 根据库存id删除装备相关库存数据 * 根据库存id删除装备相关库存数据
*
* @param stockDetailId 库存明细id * @param stockDetailId 库存明细id
* @param specificId specificId * @param specificId specificId
*/ */
void deleteEquipDataByStockDetailId(@Param("stockDetailId") Long stockDetailId, @Param("specificId") Long specificId); void deleteEquipDataByStockDetailId(@Param("stockDetailId") Long stockDetailId, @Param("specificId") Long specificId);
/** /**
* 获取雨淋阀室指标详情 * 获取雨淋阀室指标详情
*
* @return 指标详情 * @return 指标详情
*/ */
List<Map<String, String>> getRainRoomIndexDetails(); List<Map<String, String>> getRainRoomIndexDetails();
/** /**
* 消防管网指标详情 * 消防管网指标详情
*
* @return 指标详情 * @return 指标详情
*/ */
List<Map<String, String>> getTropicsIndexDetails(); List<Map<String, String>> getTropicsIndexDetails();
/** /**
* 选择阀室指标详情 * 选择阀室指标详情
*
* @return 指标详情 * @return 指标详情
*/ */
List<Map<String, String>> getChoiceRoomIndexDetails(); List<Map<String, String>> getChoiceRoomIndexDetails();
/** /**
* 消防炮伴热带指标详情 * 消防炮伴热带指标详情
*
* @return 指标详情 * @return 指标详情
*/ */
List<Map<String, String>> getBoxTropicsIndexDetails(); List<Map<String, String>> getBoxTropicsIndexDetails();
...@@ -234,6 +242,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -234,6 +242,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
/** /**
* 统计数据 * 统计数据
*
* @return * @return
*/ */
List<Map<String, Object>> queryCompanyStaData(); List<Map<String, Object>> queryCompanyStaData();
...@@ -241,21 +250,21 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -241,21 +250,21 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
Equipment getEquipmentBySpecificId(@Param("specificId") Long specificId); Equipment getEquipmentBySpecificId(@Param("specificId") Long specificId);
/** /**
*
* @param floorId 建筑id * @param floorId 建筑id
* @param isIot 是否物联设备 * @param isIot 是否物联设备
* @return * @return
*/ */
List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId(Long floorId, Integer isIot); List<EquiplistSpecificBySystemVO> getListByWarehouseStructureId(Long floorId, Integer isIot);
List<Map<String,String>> getStationInfo(); List<Map<String, String>> getStationInfo();
List<Map<String, Object>> getFireMonitorInfo(@Param("equipmentId") Long fireEquipmentId, @Param("list") String[] strings); List<Map<String, Object>> getFireMonitorInfo(@Param("equipmentId") Long fireEquipmentId, @Param("list") String[] strings);
List<Map<String, Object>> getFirePumpInfo(@Param("list") String[] strings,@Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> getFirePumpInfo(@Param("list") String[] strings, @Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getFirePumpInfoEQ(@Param("list") String[] strings,@Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getFirePumpInfoEQ(@Param("list") String[] strings, @Param("bizOrgCode") String bizOrgCode);
List<Map<String, Object>> getListByEquipmentCode(@Param("list") String[] strings, @Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> getListByEquipmentCode(@Param("list") String[] strings, @Param("bizOrgCode") String bizOrgCode);
...@@ -264,7 +273,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -264,7 +273,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List<Map<String, Object>> normalIndexInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate); List<Map<String, Object>> normalIndexInfoList(@Param("startDate") String startDate, @Param("endDate") String endDate);
Page<Map<String, Object>> normalIndexInfoListByPage(@Param("Page")Page<Map<String, Object>> page, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("systemCode") String systemCode, @Param("name") String name); Page<Map<String, Object>> normalIndexInfoListByPage(@Param("Page") Page<Map<String, Object>> page, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("systemCode") String systemCode, @Param("name") String name);
Map<String, Object> getFireAutoSysInfo(); Map<String, Object> getFireAutoSysInfo();
...@@ -280,11 +289,11 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -280,11 +289,11 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
List<Map> getWater(@Param("id") Long id); List<Map> getWater(@Param("id") Long id);
Map<String, Object> getStationCode(@Param("id")Long id); Map<String, Object> getStationCode(@Param("id") Long id);
EquipmentSpecific getEquipSpecificEntityByCode(@Param("code") String code); EquipmentSpecific getEquipSpecificEntityByCode(@Param("code") String code);
Integer updateEquipSpecificStatus(String status,String id); Integer updateEquipSpecificStatus(String status, String id);
String getEquipStatusList(@Param("id") String id); String getEquipStatusList(@Param("id") String id);
...@@ -298,15 +307,15 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -298,15 +307,15 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
String updateEquipSpecificStatusByCheckInput(String id); String updateEquipSpecificStatusByCheckInput(String id);
Page<Map<String,Object>> selectListByPatrolCheck(Page<Map<String,Object>> page, String id); Page<Map<String, Object>> selectListByPatrolCheck(Page<Map<String, Object>> page, String id);
List<String> selectIdsByPatrolCheck(String id); List<String> selectIdsByPatrolCheck(String id);
List<Map<String, Object>> queryCheckInputItemsByCheckId(@Param(value="checkId") String checkId); List<Map<String, Object>> queryCheckInputItemsByCheckId(@Param(value = "checkId") String checkId);
Map<String, Object> getPointById(@Param(value = "pointId") Long id); Map<String, Object> getPointById(@Param(value = "pointId") Long id);
Map<String, Object> getPatrolData(@Param(value = "checkId") Long checkId); Map<String, Object> getPatrolData(@Param(value = "checkId") Long checkId);
List<Map<String, Object>> getListByIds(@Param("list") String[] list, @Param("bizOrgCode") String bizOrgCode); List<Map<String, Object>> getListByIds(@Param("list") String[] list, @Param("bizOrgCode") String bizOrgCode);
...@@ -318,9 +327,9 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -318,9 +327,9 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
@Param("useSource") String useSource @Param("useSource") String useSource
); );
List<Map<String, Object >> getMonitoringCount(String bizOrgCode); List<Map<String, Object>> getMonitoringCount(String bizOrgCode);
String getEquipIdByCheckInputId(@Param(value = "id") String id); String getEquipIdByCheckInputId(@Param(value = "id") String id);
Map<String, Object> getMonitoringEquip(String id); Map<String, Object> getMonitoringEquip(String id);
...@@ -328,7 +337,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -328,7 +337,7 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
void updateEquipQrCode(List<String> ids, String status); void updateEquipQrCode(List<String> ids, String status);
String selectEquipRealtimeSignal(@Param(value = "id") long id); String selectEquipRealtimeSignal(@Param(value = "id") long id);
List<Map<String, Object>> getPatrolInfo(String bizOrgCode); List<Map<String, Object>> getPatrolInfo(String bizOrgCode);
...@@ -347,4 +356,10 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> { ...@@ -347,4 +356,10 @@ public interface EquipmentSpecificMapper extends BaseMapper<EquipmentSpecific> {
Integer selectEquipmentCountBySystemId(@Param("systemId") Long systemId); Integer selectEquipmentCountBySystemId(@Param("systemId") Long systemId);
List<EquipTrendInfoVo> getEquipListByCode(@Param("code") String code, @Param("indexKey") String indexKey, @Param("bizOrgCode") String bizOrgCode); List<EquipTrendInfoVo> getEquipListByCode(@Param("code") String code, @Param("indexKey") String indexKey, @Param("bizOrgCode") String bizOrgCode);
List<EquipTrendInfoVo> getWaterList(@Param("bizOrgCode") String bizOrgCode);
List<Map<String, String>> getIndexKeyByIotCode(@Param("list") Set<String> list);
List<Map<String, String>> getIndexKeyByIotCodeWaterTank(@Param("list") Set<String> list);
} }
...@@ -334,4 +334,6 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> { ...@@ -334,4 +334,6 @@ public interface IEquipmentSpecificSerivce extends IService<EquipmentSpecific> {
EquipTrendResultVo operatingTrendIot(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey); EquipTrendResultVo operatingTrendIot(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey);
EquipTrendResultVo operatingTrendPressurePump(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey) throws ParseException; EquipTrendResultVo operatingTrendPressurePump(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey) throws ParseException;
EquipTrendResultVo operatingTrendWater(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey) throws ParseException;
} }
package com.yeejoin.equipmanage.service.impl; package com.yeejoin.equipmanage.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
...@@ -62,6 +63,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -62,6 +63,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -2300,9 +2302,12 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2300,9 +2302,12 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
if (200 == entity.getStatus() && !ObjectUtils.isEmpty(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);
// 使用Stream API进行排序
List<Map<String, String>> sortedList = listObject.stream()
.sorted(Comparator.comparing(t -> t.get("time")))
.collect(Collectors.toList());
Map<String, String> timeAndValue = new HashMap<>(); Map<String, String> timeAndValue = new HashMap<>();
for (Map<String, String> mapList : listObject) { for (Map<String, String> mapList : sortedList) {
if (mapList.containsKey(indexKey)) { if (mapList.containsKey(indexKey)) {
timeAndValue.put(mapList.get("time"), mapList.get(indexKey)); timeAndValue.put(mapList.get("time"), mapList.get(indexKey));
allTimeList.add(mapList.get("time")); allTimeList.add(mapList.get("time"));
...@@ -2316,11 +2321,11 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2316,11 +2321,11 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
equipTrendResultVo.setLegends(legends); equipTrendResultVo.setLegends(legends);
equipTrendResultVo.setThreshold(threshold); equipTrendResultVo.setThreshold(threshold);
List<List<String>> yaxisList = new ArrayList<>(); List<List<Object>> yaxisList = new ArrayList<>();
for (EquipTrendInfoVo info : equipList) { for (EquipTrendInfoVo info : equipList) {
//key:时间 value:数值 //key:时间 value:数值
Map<String, String> dateValueDataMap = dateValueMapInfo.get(info.getId()); Map<String, String> dateValueDataMap = dateValueMapInfo.get(info.getId());
List<String> values = new ArrayList<>(); List<Object> values = new ArrayList<>();
String lastValue = "0"; String lastValue = "0";
List<String> allTimeListNew = new ArrayList<>(); List<String> allTimeListNew = new ArrayList<>();
for (int i = 0; i < allTimeList.size(); i++) { for (int i = 0; i < allTimeList.size(); i++) {
...@@ -2359,7 +2364,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2359,7 +2364,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
List<String> legends = new ArrayList<>(); List<String> legends = new ArrayList<>();
List<List<String>> threshold = new ArrayList<>(); List<List<String>> threshold = new ArrayList<>();
List<List<String>> yaxisList = new ArrayList<>(); List<List<Object>> yaxisList = new ArrayList<>();
EquipTrendResultVo equipTrendResultVo = new EquipTrendResultVo(); EquipTrendResultVo equipTrendResultVo = new EquipTrendResultVo();
//横坐标数据 //横坐标数据
List<String> allTimeListNew = new ArrayList<>(); List<String> allTimeListNew = new ArrayList<>();
...@@ -2403,7 +2408,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2403,7 +2408,7 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
} }
List<String> values = new ArrayList<>(); List<Object> values = new ArrayList<>();
for (int i = 0; i < allTimeList.size(); i++) { for (int i = 0; i < allTimeList.size(); i++) {
values.add(stringIntegerHashMap.getOrDefault(allTimeList.get(i), 0).toString()); values.add(stringIntegerHashMap.getOrDefault(allTimeList.get(i), 0).toString());
} }
...@@ -2417,6 +2422,144 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2417,6 +2422,144 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
return equipTrendResultVo; return equipTrendResultVo;
} }
@Override
public EquipTrendResultVo operatingTrendWater(String startTime, String endTime, String bizOrgCode, String equipCode, String indexKey) throws ParseException {
//横坐标数据
List<String> allTimeList = getTimePoints(startTime, endTime);
List<EquipTrendInfoVo> equipList = new ArrayList<>();
// iot服务查到的数据,存储为map key:iotCode value: iot查询的液位数据
HashMap<String, List<Map<String, String>>> iotDataInfoMap = new HashMap<>();
Map<String, String> iotCodeIndexKeyMap = new HashMap<>();
Set<String> strings = new HashSet<>();
if (StrUtil.isEmpty(equipCode)) {
equipList = equipmentSpecificMapper.getWaterList(bizOrgCode);
equipList.forEach(item -> {
String[] split = item.getIotCode().split(",");
strings.addAll(Arrays.asList(split));
});
List<Map<String, String>> indexKeyByIotCode = equipmentSpecificMapper.getIndexKeyByIotCode(strings);
iotCodeIndexKeyMap = indexKeyByIotCode.stream().collect(Collectors.toMap(t -> t.get("iotCode"), t -> t.get("indexKey")));
} else {
equipList = equipmentSpecificMapper.getEquipListByCode(equipCode, indexKey, bizOrgCode);
equipList.forEach(item -> {
String[] split = item.getIotCode().split(",");
strings.addAll(Arrays.asList(split));
});
List<Map<String, String>> indexKeyByIotCode = equipmentSpecificMapper.getIndexKeyByIotCodeWaterTank(strings);
iotCodeIndexKeyMap = indexKeyByIotCode.stream().collect(Collectors.toMap(t -> t.get("iotCode"), t -> t.get("indexKey")));
}
for (String iotCode : strings) {
//iot数据查询组装
String prefix = null;
String suffix = null;
if (StringUtil.isNotEmpty(iotCode) && iotCode.length() > 8) {
prefix = iotCode.substring(0, 8);
suffix = iotCode.substring(8);
} else {
throw new BadRequest("装备物联编码不存在或编码错误,请确认!");
}
ResponseModel entity = null;
try {
if (iotCodeIndexKeyMap.containsKey(iotCode) && StringUtil.isNotEmpty(iotCodeIndexKeyMap.get(iotCode))) {
String[] split = iotCodeIndexKeyMap.get(iotCode).split(",");
for (String indexKeyNew : split) {
entity = iotFeign.selectList(getAppKey(), getProduct(), getToken(), startTime, endTime, prefix, suffix, indexKeyNew);
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);
if (!CollectionUtils.isEmpty(listObject)) {
if (iotDataInfoMap.containsKey(iotCode)) {
iotDataInfoMap.get(iotCode).addAll(listObject);
} else {
iotDataInfoMap.put(iotCode, listObject);
}
}
}
}
}
} catch (Exception e) {
throw new RuntimeException("调用AMOS-API-IOT服务失败,请检查服务是否正常!");
}
}
//返回数据组装定义
List<String> legends = new ArrayList<>();
List<List<String>> threshold = new ArrayList<>();
List<List<Object>> yaxisList = new ArrayList<>();
EquipTrendResultVo equipTrendResultVo = new EquipTrendResultVo();
for (EquipTrendInfoVo equipInfo : equipList) {
//返回数据组装
List<String> maxMinInfo = new ArrayList<>();
maxMinInfo.add(equipInfo.getMinNum());
maxMinInfo.add(equipInfo.getMaxNum());
threshold.add(maxMinInfo);
legends.add(equipInfo.getName());
equipTrendResultVo.setyAxisName(equipInfo.getUnit());
HashMap<String, List<BigDecimal>> stringIntegerHashMap = new HashMap<>();
String[] split = equipInfo.getIotCode().split(",");
for (String iotCode : split) {
String equipIndexKey = iotCodeIndexKeyMap.get(iotCode);
String[] equipIndexKeyNew = equipIndexKey.split(",");
if (!ObjectUtils.isEmpty(iotDataInfoMap) && iotDataInfoMap.containsKey(iotCode)) {
List<Map<String, String>> listObject = iotDataInfoMap.get(iotCode);
for (Map<String, String> mapList : listObject) {
String time = change(mapList.get("time"));
String dateX = roundToNextFiveMinutes(time);
if (stringIntegerHashMap.containsKey(dateX)){
for (String key : equipIndexKeyNew) {
if (mapList.containsKey(key) && !ObjectUtils.isEmpty(mapList.get(key))) {
stringIntegerHashMap.get(dateX).add(new BigDecimal(mapList.get(key)));
}
}
} else {
stringIntegerHashMap.put(dateX, new ArrayList<>());
}
}
}
}
List<Object> values = new ArrayList<>();
for (int i = 0; i < allTimeList.size(); i++) {
List<BigDecimal> orDefault = stringIntegerHashMap.getOrDefault(allTimeList.get(i), new ArrayList<>());
// 计算非空值的总和
BigDecimal sum = orDefault.stream()
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
// 计算非空值的数量
long count = orDefault.stream().filter(Objects::nonNull).count();
// 检查除数是否为0
BigDecimal divide;
if (count == 0) {
// 如果非空值数量为0,可以选择返回0或其他默认值
divide = BigDecimal.ZERO;
} else {
// 否则,进行除法运算
divide = sum.divide(new BigDecimal(count), 2, RoundingMode.HALF_UP);
}
values.add(divide);
}
yaxisList.add(values);
}
List<String> collect = allTimeList.stream().map(item -> item + ":00").collect(Collectors.toList());
equipTrendResultVo.setxAxisData(collect);
equipTrendResultVo.setLegends(legends);
equipTrendResultVo.setThreshold(threshold);
equipTrendResultVo.setyAxisData(yaxisList);
return equipTrendResultVo;
}
private String change(String time) throws ParseException { private String change(String time) throws ParseException {
Date date1 = null; Date date1 = null;
try { try {
...@@ -2453,4 +2596,85 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM ...@@ -2453,4 +2596,85 @@ public class EquipmentSpecificSerivceImpl extends ServiceImpl<EquipmentSpecificM
} }
return hourlyTimes; return hourlyTimes;
} }
private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
/**
* 根据开始时间和结束时间,每隔五分钟获取一个时间点
*
* @param startTimeStr 开始时间字符串,格式为"yyyy-MM-dd HH:mm:ss"
* @param endTimeStr 结束时间字符串,格式为"yyyy-MM-dd HH:mm:ss"
* @return 时间点列表,每个时间点格式为"yyyy-MM-dd HH:mm"
*/
public static List<String> getTimePoints(String startTimeStr, String endTimeStr) {
List<String> timePoints = new ArrayList<>();
try {
// 将字符串时间转换为Date对象
// 注意:这里我们直接解析startTimeStr的完整格式,但只使用年和月日时分来计算下一个五分钟节点
Date startTime = sdf.parse(startTimeStr);
Date endTime = sdf.parse(endTimeStr);
// 计算起始时间的下一个五分钟节点
Calendar calendar = Calendar.getInstance();
calendar.setTime(startTime);
int minute = calendar.get(Calendar.MINUTE);
int nextFiveMinute = (minute / 5 + 1) * 5; // 计算下一个五分钟节点的分钟数
calendar.set(Calendar.MINUTE, nextFiveMinute);
calendar.set(Calendar.SECOND, 0); // 重置秒为0
calendar.set(Calendar.MILLISECOND, 0); // 重置毫秒为0
// 初始时间点为起始时间的下一个五分钟节点
Date currentTime = calendar.getTime();
// 循环直到当前时间超过结束时间
while (currentTime.before(endTime) || currentTime.equals(endTime)) {
// 格式化当前时间并添加到列表中
timePoints.add(sdf.format(currentTime));
// 计算下一个时间点(五分钟后的时间)
calendar.add(Calendar.MINUTE, 5);
currentTime = calendar.getTime();
}
} catch (Exception e) {
e.printStackTrace();
}
return timePoints;
}
// 定义一个DateTimeFormatter用于解析输入时间(包含秒)
// 注意:虽然在这个方法中我们不会直接使用它,但保留它以备将来需要
private static final DateTimeFormatter parserWithSeconds = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 定义一个DateTimeFormatter用于格式化输出时间(不包含秒)
private static final DateTimeFormatter formatterFive = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
/**
* 将给定的时间调整为下一个5分钟节点
*
* @param timeStr 输入的时间字符串,格式为"yyyy-MM-dd HH:mm:ss"
* @return 转换后的时间字符串,格式为"yyyy-MM-dd HH:mm"
*/
public static String roundToNextFiveMinutes(String timeStr) {
// 直接解析包含秒的时间字符串(虽然在这个方法中我们不需要秒)
LocalDateTime dateTime = LocalDateTime.parse(timeStr, parserWithSeconds);
// 获取分钟数
int minute = dateTime.getMinute();
// 计算到下一个5分钟节点的分钟数
int nextFiveMinutes = (minute / 5 + 1) * 5; // 总是向上调整到下一个5分钟倍数
// 计算需要增加的分钟数
int adjustment = nextFiveMinutes - minute;
// 加上差值以调整到下一个5分钟节点,并保留小时和日期部分,但重置秒为0
LocalDateTime roundedDateTime = dateTime.plusMinutes(adjustment).withSecond(0);
// 格式化并返回结果
return roundedDateTime.format(formatterFive);
}
} }
...@@ -235,12 +235,12 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting ...@@ -235,12 +235,12 @@ public class FireFightingSystemGroupServiceImpl extends ServiceImpl<FireFighting
} }
} }
// 查询装备定义的图片 List to Map -> key: systemId@equipmentId, value: 装备定义数量Map // 查询装备定义的图片 List to Map -> key: equipmentId, value: equipmentEntity
Set<Long> equipmentIds = systemEquipmentMap.values().stream().flatMap(list -> list.stream().map(SystemEquipmentRelationEntity::getEquipmentId)).collect(Collectors.toSet()); Set<Long> equipmentIds = systemEquipmentMap.values().stream().flatMap(list -> list.stream().map(SystemEquipmentRelationEntity::getEquipmentId)).collect(Collectors.toSet());
Map<Long, Equipment> equipmentImageMap = equipmentService.list( Map<Long, Equipment> equipmentImageMap = equipmentService.list(
Wrappers.<Equipment>lambdaQuery() Wrappers.<Equipment>lambdaQuery()
.select(Equipment::getId, Equipment::getShbzImg, Equipment::getImg) .select(Equipment::getId, Equipment::getShbzImg, Equipment::getImg)
.in(Equipment::getId, equipmentIds) .in(!equipmentIds.isEmpty(), Equipment::getId, equipmentIds)
).stream().map(equipmentEntity -> new HashMap<Long, Equipment>() {{ ).stream().map(equipmentEntity -> new HashMap<Long, Equipment>() {{
put(equipmentEntity.getId(), equipmentEntity); put(equipmentEntity.getId(), equipmentEntity);
}}).collect(Collectors.toMap(map -> map.keySet().iterator().next(), map -> map.values().iterator().next())); }}).collect(Collectors.toMap(map -> map.keySet().iterator().next(), map -> map.values().iterator().next()));
......
...@@ -3034,4 +3034,67 @@ ...@@ -3034,4 +3034,67 @@
GROUP BY GROUP BY
a.id a.id
</select> </select>
<select id="getWaterList" resultType="com.yeejoin.equipmanage.common.entity.vo.EquipTrendInfoVo">
SELECT
a.sequence_nbr AS id,
a.`name` AS `name`,
GROUP_CONCAT( c.iot_code ) AS iotCode,
b.min_water_level AS minNum,
b.max_water_level AS maxNum,
'液位(M)' AS unit
FROM
`cb_water_resource` AS a
LEFT JOIN cb_water_resource_pool b ON a.sequence_nbr = b.resource_id
LEFT JOIN wl_equipment_specific c ON FIND_IN_SET( c.id, b.level_device_id )
WHERE
b.level_device_id IS NOT NULL
AND b.level_device_id != ''
AND a.resource_type IN ( 'pool', 'industryPool' )
<if test="bizOrgCode != null and bizOrgCode != ''">
AND a.biz_org_code LIKE concat(#{bizOrgCode}, '%')
</if>
GROUP BY
a.sequence_nbr
HAVING
iotCode IS NOT NULL
AND iotCode != ''
</select>
<select id="getIndexKeyByIotCode" resultType="java.util.Map">
SELECT
a.iot_code as iotCode,
max(case when b.type_code = 'LiquidLevel' then equipment_index_key end) as indexKey
FROM
wl_equipment_specific a
LEFT JOIN wl_equipment_specific_index b ON a.id = b.equipment_specific_id
WHERE
a.iot_code
IN
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
GROUP BY
a.iot_code
</select>
<select id="getIndexKeyByIotCodeWaterTank" resultType="java.util.Map">
SELECT
a.iot_code AS iotCode,
GROUP_CONCAT( b.equipment_index_key ) AS indexKey
FROM
wl_equipment_specific a
LEFT JOIN ( SELECT * FROM wl_equipment_specific_index WHERE type_code = 'LiquidLevel' ) b ON a.id = b.equipment_specific_id
WHERE
a.iot_code IN
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
GROUP BY
a.iot_code
HAVING
indexKey IS NOT NULL
AND indexKey != ''
</select>
</mapper> </mapper>
\ No newline at end of file
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