|
@@ -11,10 +11,12 @@ import com.persagy.apm.diagnose.indicatorrecord.model.dto.QueryMonitorIndicatorR
|
|
|
import com.persagy.apm.diagnose.indicatorrecord.service.IMonitorIndicatorRecordService;
|
|
|
import com.persagy.apm.diagnose.maintenance.constant.*;
|
|
|
import com.persagy.apm.diagnose.maintenance.model.dto.CalculateMethodDTO;
|
|
|
+import com.persagy.apm.diagnose.maintenance.model.dto.WeatherDTO;
|
|
|
import com.persagy.apm.diagnose.maintenance.service.IProjectDataRecordService;
|
|
|
import com.persagy.apm.diagnose.service.CenterDataService;
|
|
|
import com.persagy.apm.diagnose.service.EnergyAlarmServiceImpl;
|
|
|
import com.persagy.apm.diagnose.service.SaasService;
|
|
|
+import com.persagy.apm.diagnose.service.WeatherServiceImpl;
|
|
|
import com.persagy.apm.diagnose.service.dto.AlarmRuleDTO;
|
|
|
import com.persagy.apm.diagnose.service.dto.ProjectDTO;
|
|
|
import com.persagy.apm.diagnose.service.dto.TimeDataDTO;
|
|
@@ -27,9 +29,7 @@ import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.AddAla
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.BatchUpdateAlarmRecordDTO;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.QueryAlarmRecordDTO;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.UpdateAlarmRecordDTO;
|
|
|
-import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmConfigItem;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmRecordItem;
|
|
|
-import com.persagy.apm.energyalarmstarter.alarmdata.service.AlarmConfigServiceImpl;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.service.AlarmRecordServiceImpl;
|
|
|
import com.persagy.apm.energyalarmstarter.collectdata.websocket.AlarmWebSocketServer;
|
|
|
import com.persagy.framework.ems.data.core.enumeration.SpecialOperator;
|
|
@@ -61,10 +61,17 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
@Value(value = "${energy.eq.run.system.code}")
|
|
|
private String systemCode;
|
|
|
+
|
|
|
+ //测试环境 运行状态 上下限值
|
|
|
+ @Value(value = "${energy.eq.run.state.up.limit}")
|
|
|
+ private Double runStateUpLimit;
|
|
|
+ @Value(value = "${energy.eq.run.state.down.limit}")
|
|
|
+ private Double runStateDownLimit;
|
|
|
+
|
|
|
//报警分类
|
|
|
public final static String alarmSplit = "_";
|
|
|
- private final static Long ConfigItemKeyTime = 60 * 60 * 1000L;
|
|
|
private final static Long SendDataTimeKeyTime = 24 * 60 * 60 * 1000L;
|
|
|
+ private final static Double TwdTemp_Limit = 0.1;
|
|
|
|
|
|
@Autowired
|
|
|
private AlarmRecordServiceImpl alarmRecordService;
|
|
@@ -84,30 +91,32 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
private ComputePropertiesConfig computePropertiesConfig;
|
|
|
@Autowired
|
|
|
private EnergyAlarmServiceImpl energyAlarmService;
|
|
|
+ @Autowired
|
|
|
+ private WeatherServiceImpl weatherService;
|
|
|
|
|
|
@Resource(name = "ZillionDao")
|
|
|
private CoreDao coredao;
|
|
|
|
|
|
@Override
|
|
|
@Async("asyncComputeMaintenanceDataExecutor")
|
|
|
- public Future<String> computeMaintenanceData(Date todayDate, String projectId, CountDownLatch latch) throws Exception {
|
|
|
+ public Future<String> computeMaintenanceData(Date todayDate,ProjectDTO projectDTO, CountDownLatch latch)throws Exception {
|
|
|
long time = System.currentTimeMillis() + (20 * 1000);
|
|
|
try {
|
|
|
- if (!lockUtil.lock(projectId + "_computeMaintenance", String.valueOf(time))) {
|
|
|
+ if (!lockUtil.lock(projectDTO.getProjectId() + "_computeMaintenance", String.valueOf(time))) {
|
|
|
// 获取不到锁,略过
|
|
|
- return new AsyncResult<>("【监测维保数据计算线程】项目:" + projectId + "被占用");
|
|
|
+ return new AsyncResult<>("【监测维保数据计算线程】项目:" + projectDTO.getProjectId() + "被占用");
|
|
|
}
|
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
- AsyncResult<String> projectDTOBack = computeProjectMaintenanceData(todayDate, projectId);
|
|
|
+ AsyncResult<String> projectDTOBack = computeProjectMaintenanceData(todayDate, projectDTO);
|
|
|
if (projectDTOBack != null) {
|
|
|
return projectDTOBack;
|
|
|
}
|
|
|
long end = System.currentTimeMillis();
|
|
|
- return new AsyncResult<>("【监测维保数据计算线程】计算项目指标数据用时:" + projectId + ";" + (end - start));
|
|
|
+ return new AsyncResult<>("【监测维保数据计算线程】计算项目指标数据用时:" + projectDTO.getProjectId() + ";" + (end - start));
|
|
|
} finally {
|
|
|
// 释放锁
|
|
|
- lockUtil.unlock(projectId + "_computeMaintenance", String.valueOf(time));
|
|
|
+ lockUtil.unlock(projectDTO.getProjectId() + "_computeMaintenance", String.valueOf(time));
|
|
|
latch.countDown();
|
|
|
}
|
|
|
}
|
|
@@ -135,7 +144,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
@Override
|
|
|
@Async("asyncGoingDestroyEquipExecutor")
|
|
|
- public Future<String> syncGoingDestroyEquip(String projectId, CountDownLatch latch) throws Exception {
|
|
|
+ public Future<String> syncGoingDestroyEquip(String projectId, CountDownLatch latch) {
|
|
|
long time = System.currentTimeMillis() + (20 * 1000);
|
|
|
try {
|
|
|
if (!lockUtil.lock(projectId + "_syncEquip", String.valueOf(time))) {
|
|
@@ -170,11 +179,8 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
List<UpdateAlarmRecordDTO> updateAlarmRecordDTOList = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(equipSet)) {
|
|
|
for (String equipId : equipSet) {
|
|
|
- if (null != alarmRecordItemMap && alarmRecordItemMap.containsKey(equipId)) {
|
|
|
- if (null != equipInfoMap && equipInfoMap.containsKey(equipId)) {
|
|
|
- //同时存在于 报废记录和报警记录,跳过不处理
|
|
|
- continue;
|
|
|
- } else {
|
|
|
+ if (alarmRecordItemMap.containsKey(equipId)) {
|
|
|
+ if (!equipInfoMap.containsKey(equipId)) {
|
|
|
//存在于报警记录和但不在报废记录,将报警状态修改为 已恢复
|
|
|
AlarmRecordItem alarmRecordItem = alarmRecordItemMap.get(equipId);
|
|
|
if (EnumAlarmState.UN_HANDLE.getCode().equals(alarmRecordItem.getState())) {
|
|
@@ -186,9 +192,10 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
updateAlarmRecordDTOList.add(updateAlarmRecordDTO);
|
|
|
}
|
|
|
}
|
|
|
+ //同时存在于 报废记录和报警记录,跳过不处理
|
|
|
} else {
|
|
|
//不存在于报警列表 在即将报废列表 新产生报警信息
|
|
|
- if (null != equipInfoMap && equipInfoMap.containsKey(equipId)) {
|
|
|
+ if (equipInfoMap.containsKey(equipId)) {
|
|
|
saveAlarmEquipIdList.add(equipId);
|
|
|
}
|
|
|
}
|
|
@@ -292,22 +299,24 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
}
|
|
|
Map<String, List<MonitorIndicatorRecord>> timeKeyAndRecordList = new LinkedHashMap<>();
|
|
|
for (MonitorIndicatorRecord record : list) {
|
|
|
- String timeKey = com.persagy.apm.diagnose.utils.DateUtils.date2Str(record.getDataTime(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
|
|
|
+ String timeKey = com.persagy.apm.diagnose.utils.DateUtils.date2Str(record.getDataTime(), com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
if (!timeKeyAndRecordList.containsKey(timeKey)) {
|
|
|
timeKeyAndRecordList.put(timeKey, new ArrayList<>());
|
|
|
}
|
|
|
timeKeyAndRecordList.get(timeKey).add(record);
|
|
|
}
|
|
|
+ Map<String, List<MonitorIndicatorRecord>> sendTimeKeyAndDataList = new LinkedHashMap<>();
|
|
|
for (Map.Entry<String, List<MonitorIndicatorRecord>> dateListEntry : timeKeyAndRecordList.entrySet()) {
|
|
|
List<MonitorIndicatorRecord> value = dateListEntry.getValue();
|
|
|
if (CollectionUtils.isEmpty(value) || value.size() != infCodeList.size()) {
|
|
|
continue;
|
|
|
}
|
|
|
- String sentValue = CollectDataUtil.buildSendParam(value,alarmItemCode);
|
|
|
- AlarmWebSocketServer.sendMsgToClients(projectId, CollectDataUtil.buildSendParam(value,alarmItemCode));
|
|
|
- log.info("设备维保发送数据服务数据:" + projectId+";"+ sentValue);
|
|
|
- endTime = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dateListEntry.getKey(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
|
|
|
+ sendTimeKeyAndDataList.put(dateListEntry.getKey(),value);
|
|
|
+ endTime = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dateListEntry.getKey(), com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
}
|
|
|
+ String sentValue = CollectDataUtil.batchBuildSendParam(sendTimeKeyAndDataList,alarmItemCode);
|
|
|
+ AlarmWebSocketServer.sendMsgToClients(projectId, sentValue);
|
|
|
+ log.info("设备维保发送数据服务数据:" + projectId+";"+ sentValue);
|
|
|
configItemSendTimeDTO.setLastSendTime(endTime);
|
|
|
configItemSendTimeDTO.setUpdateTime(new Date());
|
|
|
updateRedisConfigItemSendTimeDTO(projectId, objIdAndAlarmItemCode, configItemSendTimeDTO);
|
|
@@ -340,7 +349,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
for (String objId : objIds) {
|
|
|
String key = objId + "_" + alarmItemCode;
|
|
|
if (!objIdAlarmItemCodeAndInfoCodes.containsKey(key)) {
|
|
|
- objIdAlarmItemCodeAndInfoCodes.put(key, new ArrayList<String>());
|
|
|
+ objIdAlarmItemCodeAndInfoCodes.put(key, new ArrayList<>());
|
|
|
}
|
|
|
objIdAlarmItemCodeAndInfoCodes.get(key).add(infoCode);
|
|
|
}
|
|
@@ -374,23 +383,23 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
/**
|
|
|
* 计算维保数据
|
|
|
*/
|
|
|
- private AsyncResult<String> computeProjectMaintenanceData(Date todayDate, String projectId) {
|
|
|
+ private AsyncResult<String> computeProjectMaintenanceData(Date todayDate, ProjectDTO projectDTO) {
|
|
|
try {
|
|
|
//通过报警服务查询报警规则
|
|
|
List<String> itemCodeList = new ArrayList<>();
|
|
|
itemCodeList.add(EnumAlarmItem.CondAbnormal.getCode());
|
|
|
itemCodeList.add(EnumAlarmItem.EvapAbnormal.getCode());
|
|
|
itemCodeList.add(EnumAlarmItem.CoolTowerApproachTempAbnormal.getCode());
|
|
|
- List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectId,itemCodeList);
|
|
|
+ List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectDTO.getProjectId(),itemCodeList);
|
|
|
if (CollectionUtils.isEmpty(projectAlarmRules)) {
|
|
|
- return new AsyncResult<>("【监测维保数据计算线程】当前项目:" + projectId + "未设置设备维保报警规则");
|
|
|
+ return new AsyncResult<>("【监测维保数据计算线程】当前项目:" + projectDTO.getProjectId() + "未设置设备维保报警规则");
|
|
|
}
|
|
|
Set<String> objIdAndIndicatorId = getObjIdAndInfoCodeFromRules(projectAlarmRules);
|
|
|
if (CollectionUtils.isEmpty(objIdAndIndicatorId)) {
|
|
|
- return new AsyncResult<>("【监测维保数据计算线程】当前项目:" + projectId + "报警规则未关联对象");
|
|
|
+ return new AsyncResult<>("【监测维保数据计算线程】当前项目:" + projectDTO.getProjectId() + "报警规则未关联对象");
|
|
|
}
|
|
|
//Map<objId_monitorIndicatorId, Date>
|
|
|
- Map<String, Date> objId_indicatorIdAndComputeTime = getObjId_IndicatorIdAndComputeTIme(projectId);
|
|
|
+ Map<String, Date> objId_indicatorIdAndComputeTime = getObjId_IndicatorIdAndComputeTIme(projectDTO.getProjectId());
|
|
|
//循环计算
|
|
|
for (AlarmRuleDTO alarmRuleDTO:projectAlarmRules) {
|
|
|
String itemCode = alarmRuleDTO.getAlarmItemCode();
|
|
@@ -404,7 +413,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
continue;
|
|
|
}
|
|
|
for (String objId:objIdList) {
|
|
|
- List<AlarmCondition> alarmConditionList = energyAlarmService.getProjectAlarmCondition(projectId,objId,enumAlarmItem.getCode());
|
|
|
+ List<AlarmCondition> alarmConditionList = energyAlarmService.getProjectAlarmCondition(projectDTO.getProjectId(),objId,enumAlarmItem.getCode());
|
|
|
if (CollectionUtils.isEmpty(alarmConditionList)){
|
|
|
continue;
|
|
|
}
|
|
@@ -445,15 +454,15 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
Date computeTime;
|
|
|
if (indicatorType == EnumMaintenanceIndicatorType.ACCCOT_DayAvg) {//冷却塔
|
|
|
//冷却塔 日均 数据计算
|
|
|
- computeTime = computeCoolTowerData(lastComputeTime, todayDate, projectId, objId, indicatorType);
|
|
|
+ computeTime = computeCoolTowerData(lastComputeTime, todayDate, projectDTO, objId, indicatorType);
|
|
|
} else {//冷水机组
|
|
|
//冷却水组 日均 数据计算
|
|
|
- computeTime = computeCoolWaterData(lastComputeTime, todayDate, projectId, objId, indicatorType);
|
|
|
+ computeTime = computeCoolWaterData(lastComputeTime, todayDate, projectDTO.getProjectId(), objId, indicatorType);
|
|
|
}
|
|
|
//计算 运行持续时长
|
|
|
- computeAlarmDay(projectId, objId, infoCode, indicatorType, lastComputeTime, todayDate,monitorIndicatorMap);
|
|
|
+ computeAlarmDay(projectDTO.getProjectId(), objId, infoCode, indicatorType, lastComputeTime, todayDate,monitorIndicatorMap);
|
|
|
//更新计算 时间记录
|
|
|
- saveOrUpdateComputeTime(projectId, objId, infoCode, computeTime);
|
|
|
+ saveOrUpdateComputeTime(projectDTO.getProjectId(), objId, infoCode, computeTime);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -560,7 +569,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
if (!CollectionUtils.isEmpty(recordList)) {
|
|
|
//倒序排
|
|
|
recordList.sort(Comparator.comparing(MonitorIndicatorRecord::getDataTime).reversed());
|
|
|
-
|
|
|
+ Date checkDate = alarmDate;
|
|
|
if (!StringUtils.isBlank(tempFormula)) {
|
|
|
if (!CollectionUtils.isEmpty(recordList)) {
|
|
|
for (MonitorIndicatorRecord record : recordList) {
|
|
@@ -568,11 +577,12 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
if (!isFlag) {
|
|
|
return record.getDataTime();
|
|
|
}
|
|
|
+ checkDate = record.getDataTime();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//继续往前找报警开始日期
|
|
|
- return getStartAlarmDate(checkStartDate, projectId, objId, indicatorId, operator, tempFormula);
|
|
|
+ return getStartAlarmDate(checkDate, projectId, objId, indicatorId, operator, tempFormula);
|
|
|
}
|
|
|
return alarmDate;
|
|
|
}
|
|
@@ -613,12 +623,17 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
/**
|
|
|
* 冷却塔 日均计算
|
|
|
*/
|
|
|
- Date computeCoolTowerData(Date startDate, Date endDate, String projectId, String cTObjId, EnumMaintenanceIndicatorType indicatorType) throws Exception {
|
|
|
+ Date computeCoolTowerData(Date startDate, Date endDate, ProjectDTO projectDTO, String cTObjId, EnumMaintenanceIndicatorType indicatorType) throws Exception {
|
|
|
+// Date runDate = null;
|
|
|
+// //获取冷却塔下所有风机运行时时间列表(所有风机运行时间合并为一组时间列表)
|
|
|
+// Map<Date, List<Date>> allDateRunDataMap = getCoolTowerRunDateMap(projectId, startDate, endDate);
|
|
|
+// //获取持续运行2小时之后的 时间点集合
|
|
|
+// Map<Date, List<Date>> dateRunDataMap = getCoolTowerContinuedRunDateMap(allDateRunDataMap);
|
|
|
+
|
|
|
Date runDate = null;
|
|
|
- //获取冷却塔下所有风机运行时时间列表(所有风机运行时间合并为一组时间列表)
|
|
|
- Map<Date, List<Date>> allDateRunDataMap = getCoolTowerRunDateMap(projectId, startDate, endDate);
|
|
|
- //获取持续运行2小时之后的 时间点集合
|
|
|
- Map<Date, List<Date>> dateRunDataMap = getCoolTowerContinuedRunDateMap(allDateRunDataMap);
|
|
|
+ Map<Date, List<TimeDataDTO>> dayTimeDataMap = getServiceDataFromCenterDataService(projectDTO.getProjectId(), cTObjId, EnumCoolWaterPointNameType.RunStatus.getCode(), startDate, endDate);
|
|
|
+ //获取日 对应运行时间集合
|
|
|
+ Map<Date, List<Date>> dateRunDataMap = getContinuedRunDateMap(dayTimeDataMap);
|
|
|
//获取冷却水回水干管温度数据集合
|
|
|
Map<Date, List<TimeDataDTO>> dayCoolWaterMainReturnTempMap = null;
|
|
|
//获取室外湿球温度数据集合
|
|
@@ -626,19 +641,21 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
//计算日均
|
|
|
if (dateRunDataMap.size() > 0) {
|
|
|
//获取中央供冷系统对象
|
|
|
- List<JSONObject> object2List = getEqObjectList(projectId, "ACCC");
|
|
|
+ List<JSONObject> object2List = getEqObjectList(projectDTO.getProjectId(), "ACCC");
|
|
|
if (!CollectionUtils.isEmpty(object2List)) {
|
|
|
JSONObject object = object2List.get(0);
|
|
|
String objId = object.getString("id");
|
|
|
- dayCoolWaterMainReturnTempMap = getServiceDataFromCenterDataService(projectId, objId, EnumCoolTowerPointNameType.CoolWaterMainReturnTemp.getCode(), startDate, endDate);
|
|
|
+ dayCoolWaterMainReturnTempMap = getServiceDataFromCenterDataService(projectDTO.getProjectId(), objId, EnumCoolTowerPointNameType.CoolWaterMainReturnTemp.getCode(), startDate, endDate);
|
|
|
}
|
|
|
+ //计算出 湿球温度数据集合
|
|
|
+ dayTwdTempMap = computerWetBallTempMap(projectDTO,startDate,endDate);
|
|
|
//获取中央供冷系统对象
|
|
|
- List<JSONObject> object3List = getEqObjectList(projectId, "WEMMMS");
|
|
|
- if (!CollectionUtils.isEmpty(object3List)) {
|
|
|
- JSONObject object = object3List.get(0);
|
|
|
- String objId = object.getString("id");
|
|
|
- dayTwdTempMap = getServiceDataFromCenterDataService(projectId, objId, EnumCoolTowerPointNameType.Twb.getCode(), startDate, endDate);
|
|
|
- }
|
|
|
+// List<JSONObject> object3List = getEqObjectList(projectDTO.getProjectId(), "WEMMMS");
|
|
|
+// if (!CollectionUtils.isEmpty(object3List)) {
|
|
|
+// JSONObject object = object3List.get(0);
|
|
|
+// String objId = object.getString("id");
|
|
|
+// dayTwdTempMap = getServiceDataFromCenterDataService(projectDTO.getProjectId(), objId, EnumCoolTowerPointNameType.Twb.getCode(), startDate, endDate);
|
|
|
+// }
|
|
|
}
|
|
|
//循环计算日均
|
|
|
for (Date dayDate = startDate; dayDate.before(endDate); dayDate = DateUtils.addDays(dayDate, 1)) {
|
|
@@ -649,7 +666,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
monitorIndicatorRecord.setMonitorIndicatorId(indicatorType.getCode());
|
|
|
monitorIndicatorRecord.setDataTime(dayDate);
|
|
|
monitorIndicatorRecord.setObjId(cTObjId);
|
|
|
- monitorIndicatorRecord.setProject(projectId);
|
|
|
+ monitorIndicatorRecord.setProject(projectDTO.getProjectId());
|
|
|
monitorIndicatorRecord.setDataValue(dayAvg);
|
|
|
monitorIndicatorRecordService.saveOrUpdateByPk(monitorIndicatorRecord);
|
|
|
runDate = dayDate;
|
|
@@ -723,7 +740,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
//冷凝温度、冷凝器出口水温 均不为空
|
|
|
if (firstDateDataMap.containsKey(date) && null != firstDateDataMap.get(date)
|
|
|
&& secondDateDataMap.containsKey(date) && null != secondDateDataMap.get(date)) {
|
|
|
- Double divideTemp = DataUtils.divide(firstDateDataMap.get(date), secondDateDataMap.get(date));
|
|
|
+ Double divideTemp = DataUtils.subtract(firstDateDataMap.get(date), secondDateDataMap.get(date));
|
|
|
totalVal = totalVal == null ? divideTemp : DataUtils.plus(totalVal, divideTemp);
|
|
|
num++;
|
|
|
}
|
|
@@ -789,10 +806,17 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
}
|
|
|
List<Date> dateList = new ArrayList<>();
|
|
|
for (TimeDataDTO dto : dataDTOList) {
|
|
|
+ if (null == dto.getData()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
String time = dto.getTime();
|
|
|
Date getDate = com.persagy.apm.diagnose.utils.DateUtils.str2Date(time, com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
if (getDate.compareTo(twoHourDate) > 0) {
|
|
|
- if (Objects.equals(EnumRunStatusType.Open.getCode(), dto.getData())) {
|
|
|
+// if (Objects.equals(EnumRunStatusType.Open.getCode(), dto.getData())) {
|
|
|
+// dateList.add(getDate);
|
|
|
+// }
|
|
|
+ //TODO 测试 运行状态
|
|
|
+ if (dto.getData() > runStateDownLimit && dto.getData() < runStateUpLimit) {
|
|
|
dateList.add(getDate);
|
|
|
}
|
|
|
}
|
|
@@ -862,8 +886,14 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
dateList = dateRunDataMap.get(dayDate);
|
|
|
}
|
|
|
for (TimeDataDTO dto : dataDTOList) {
|
|
|
+ if (null == dto.getData()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Date getDate = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dto.getTime(), com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
- if (Objects.equals(EnumRunStatusType.Open.getCode(), dto.getData())) {
|
|
|
+// if (Objects.equals(EnumRunStatusType.Open.getCode(), dto.getData())) {
|
|
|
+// dateList.add(getDate);
|
|
|
+// }
|
|
|
+ if (dto.getData() > runStateDownLimit && dto.getData() < runStateUpLimit) {
|
|
|
dateList.add(getDate);
|
|
|
}
|
|
|
}
|
|
@@ -888,9 +918,16 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
String time = dto.getTime();
|
|
|
Date getDate = com.persagy.apm.diagnose.utils.DateUtils.str2Date(time, com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
if (getDate.compareTo(firstDate) >= 0 && getDate.compareTo(twoHourDate) <= 0) {
|
|
|
- if (Objects.equals(EnumRunStatusType.Close.getCode(), dto.getData())) {
|
|
|
+ if (null == dto.getData()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //TODO 测试 运行状态
|
|
|
+ if (dto.getData() < runStateDownLimit || dto.getData() > runStateUpLimit) {
|
|
|
return false;
|
|
|
}
|
|
|
+// if (Objects.equals(EnumRunStatusType.Close.getCode(), dto.getData())) {
|
|
|
+// return false;
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -905,10 +942,14 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
public String getFirstRunDate(List<TimeDataDTO> dataDTOList) {
|
|
|
try {
|
|
|
for (TimeDataDTO dto : dataDTOList) {
|
|
|
- //
|
|
|
- if (Objects.equals(EnumRunStatusType.Open.getCode(), dto.getData())) {
|
|
|
+ if (null == dto.getData()){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+// if (Objects.equals(EnumRunStatusType.Open.getCode(), dto.getData())) {
|
|
|
+// return dto.getTime();
|
|
|
+// }
|
|
|
+ if (dto.getData() > runStateDownLimit && dto.getData() < runStateUpLimit) {
|
|
|
return dto.getTime();
|
|
|
- //return com.persagy.apm.diagnose.utils.DateUtils.str2Date(dto.getTime(), com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -952,7 +993,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
List<JSONObject> jsonToList = new ArrayList<>();
|
|
|
try {
|
|
|
List<String> classCodeList = new ArrayList<>();
|
|
|
- classCodeList.add(classCode);//获取冷却塔下所有风机设备
|
|
|
+ classCodeList.add(classCode);
|
|
|
JSONArray jsonArray = centerDataService.queryObjListByObjType(projectId, classCodeList);
|
|
|
jsonToList = JSON.parseArray(jsonArray.toJSONString(), JSONObject.class);
|
|
|
} catch (Exception e) {
|
|
@@ -962,55 +1003,6 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * redis中查询报警条件上次发数时间, 如果查询为空, 则初始化当前时间
|
|
|
- */
|
|
|
-// private ConfigItemDataSendTimeDTO getConfigItemSendTimeDTO(String projectId, AlarmConfigItem alarmConfigItem, Date defaultDate) {
|
|
|
-// ConfigItemDataSendTimeDTO sendTimeDTO = (ConfigItemDataSendTimeDTO) redisUtil.hget(RedisUtil.PROJECT_ITEM_SEND_TIME + ":" + projectId, alarmConfigItem.getId());
|
|
|
-//// ConfigItemDataSendTimeDTO sendTimeDTO = null;
|
|
|
-// if (sendTimeDTO == null) {
|
|
|
-// sendTimeDTO = ConfigItemDataSendTimeDTO.builder().objId(alarmConfigItem.getObjId()).configItemid(alarmConfigItem.getId()).lastSendTime(defaultDate).build();
|
|
|
-// }
|
|
|
-// return sendTimeDTO;
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
- * 从缓存中获取报警条件, 如果缓存不存在, 则查询报警服务, 报警条件配置
|
|
|
- */
|
|
|
-// private List<AlarmConfigItem> getAlarmConfigItemList(String projectId) throws Exception {
|
|
|
-// List<AlarmConfigItem> itemList = (List<AlarmConfigItem>) redisUtil.hget(RedisUtil.PROJECT_ALARM_ITEM, projectId);
|
|
|
-// if (CollectionUtils.isEmpty(itemList)) {
|
|
|
-// QueryAlarmConfigDTO queryAlarmConfigDTO = new QueryAlarmConfigDTO();
|
|
|
-// queryAlarmConfigDTO.setProjectId(projectId);
|
|
|
-// queryAlarmConfigDTO.setGroupCode(systemCode);
|
|
|
-// queryAlarmConfigDTO.setCategory(Collections.singletonList(EnumAlarmCategory.EQWB.getCode()));
|
|
|
-// queryAlarmConfigDTO.setOpen(1);
|
|
|
-// DmpResult<List<AlarmConfigItem>> configItemResult = alarmConfigService.query(queryAlarmConfigDTO);
|
|
|
-// itemList = DmpResultUtil.getData(configItemResult);
|
|
|
-// redisUtil.hset(RedisUtil.PROJECT_ALARM_ITEM, projectId, itemList, ConfigItemKeyTime);
|
|
|
-// } else {
|
|
|
-// List<AlarmConfigItem> newItemList = new ArrayList<>();
|
|
|
-// itemList.forEach(alarmConfigItem -> {
|
|
|
-// if (alarmConfigItem.getCategory().equals(EnumAlarmCategory.EQWB.getCode())) {
|
|
|
-// newItemList.add(alarmConfigItem);
|
|
|
-// }
|
|
|
-// });
|
|
|
-// if (CollectionUtils.isEmpty(newItemList)) {
|
|
|
-// QueryAlarmConfigDTO queryAlarmConfigDTO = new QueryAlarmConfigDTO();
|
|
|
-// queryAlarmConfigDTO.setProjectId(projectId);
|
|
|
-// queryAlarmConfigDTO.setGroupCode(systemCode);
|
|
|
-// queryAlarmConfigDTO.setCategory(Collections.singletonList(EnumAlarmCategory.EQWB.getCode()));
|
|
|
-// queryAlarmConfigDTO.setOpen(1);
|
|
|
-// DmpResult<List<AlarmConfigItem>> configItemResult = alarmConfigService.query(queryAlarmConfigDTO);
|
|
|
-// itemList = DmpResultUtil.getData(configItemResult);
|
|
|
-// redisUtil.hset(RedisUtil.PROJECT_ALARM_ITEM, projectId, itemList, ConfigItemKeyTime);
|
|
|
-// } else {
|
|
|
-// itemList = newItemList;
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return itemList;
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
* 获取报警记录
|
|
|
*/
|
|
|
private Map<String, AlarmRecordItem> getAlarmRecordItemMap(String projectId) throws Exception {
|
|
@@ -1023,7 +1015,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
DmpResult<List<AlarmRecordItem>> configItemResultList = alarmRecordService.query(queryAlarmRecordDTO);
|
|
|
List<AlarmRecordItem> alarmRecordItemList = DmpResultUtil.getData(configItemResultList);
|
|
|
if (!CollectionUtils.isEmpty(alarmRecordItemList)){
|
|
|
- alarmRecordItemList.stream().collect(Collectors.toMap(AlarmRecordItem::getObjId, Function.identity(), (a, b) -> b));
|
|
|
+ return alarmRecordItemList.stream().collect(Collectors.toMap(AlarmRecordItem::getObjId, Function.identity(), (a, b) -> b));
|
|
|
}
|
|
|
return new HashMap<>();
|
|
|
}
|
|
@@ -1094,4 +1086,74 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
}
|
|
|
return objIdAndInfoCode;
|
|
|
}
|
|
|
+
|
|
|
+ public Map<Date, List<TimeDataDTO>> computerWetBallTempMap(ProjectDTO projectDTO,Date startDate,Date endDate){
|
|
|
+ try {
|
|
|
+ //根据室外天气数据计算出湿球温度数据
|
|
|
+ Map<Date, List<WeatherDTO>> dayWeatherDataMap = getWeatherTemp(projectDTO,startDate,endDate);
|
|
|
+ if (null != dayWeatherDataMap && dayWeatherDataMap.size() > 0){
|
|
|
+ Map<Date, List<TimeDataDTO>> dayTwdTempMap = new HashMap<>();
|
|
|
+ for (Date dayDate:dayWeatherDataMap.keySet()) {
|
|
|
+ List<WeatherDTO> dtoList = dayWeatherDataMap.get(dayDate);
|
|
|
+ if (CollectionUtils.isEmpty(dtoList)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<TimeDataDTO> timeDataDTOList = new ArrayList<>();
|
|
|
+ for (WeatherDTO dto:dtoList) {
|
|
|
+ //根据温度和湿度 计算出湿空气焓值
|
|
|
+ Double hVal = TwdTempUtil.getHVal(dto.getTemperature(),dto.getHumidity());
|
|
|
+ //根据允许范围推出Tw值
|
|
|
+ Double Tw = TwdTempUtil.getTw(dto.getTemperature(),hVal,TwdTemp_Limit);
|
|
|
+ log.info("项目编号为:"+projectDTO.getProjectId()+"日期为:"+dto.getHourTime()+"温度:"+dto.getTemperature()+"湿度:"+dto.getHumidity()+"湿球温度:"+Tw);
|
|
|
+ //小时时间
|
|
|
+ Date hour = dto.getHourTime();
|
|
|
+ Date nextHour = com.persagy.apm.diagnose.utils.DateUtils.addHours(hour,1);
|
|
|
+ for (Date starthour = hour; starthour.before(nextHour) ; starthour = com.persagy.apm.diagnose.utils.DateUtils.addMinutes(starthour,15)) {
|
|
|
+ TimeDataDTO timeDataDTO = new TimeDataDTO();
|
|
|
+ timeDataDTO.setTime(com.persagy.apm.diagnose.utils.DateUtils.date2Str(starthour, com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND));
|
|
|
+ timeDataDTO.setData(Tw);
|
|
|
+ timeDataDTOList.add(timeDataDTO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dayTwdTempMap.put(dayDate,timeDataDTOList);
|
|
|
+ }
|
|
|
+ return dayTwdTempMap;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取项目 天气数据
|
|
|
+ */
|
|
|
+ public Map<Date, List<WeatherDTO>> getWeatherTemp(ProjectDTO projectDTO,Date startDate,Date endDate){
|
|
|
+ try {
|
|
|
+ String startTime = com.persagy.apm.diagnose.utils.DateUtils.date2Str(startDate, com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
|
|
|
+ String endTime = com.persagy.apm.diagnose.utils.DateUtils.date2Str(endDate, com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
|
|
|
+ List<WeatherDTO> weatherDTOList = weatherService.hourHistoryData(projectDTO.getCity(),startTime,endTime,true,2);
|
|
|
+ if (!CollectionUtils.isEmpty(weatherDTOList)){
|
|
|
+ Map<Date, List<WeatherDTO>> dayTimeWeatherDataMap = new HashMap<>();
|
|
|
+ for (WeatherDTO dto : weatherDTOList) {
|
|
|
+// String time = dto.getHourTime();
|
|
|
+// Date timeDate = com.persagy.apm.diagnose.utils.DateUtils.str2Date(time, com.persagy.apm.diagnose.utils.DateUtils.SDF_SECOND);
|
|
|
+ Date dayDate = DateUtils.truncate(dto.getHourTime(), Calendar.DATE);
|
|
|
+ if (dayTimeWeatherDataMap.containsKey(dayDate)) {
|
|
|
+ dayTimeWeatherDataMap.get(dayDate).add(dto);
|
|
|
+ } else {
|
|
|
+ List<WeatherDTO> dataDTOS = new ArrayList<>();
|
|
|
+ dataDTOS.add(dto);
|
|
|
+ dayTimeWeatherDataMap.put(dayDate, dataDTOS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return dayTimeWeatherDataMap;
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|