|
@@ -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;
|
|
@@ -72,6 +74,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
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;
|
|
@@ -91,30 +94,35 @@ 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() + "被占用");
|
|
|
}
|
|
|
|
|
|
+ Date startDate = DateUtils.addDays(todayDate,-5);
|
|
|
+ computerWetBallTempMap(projectDTO,startDate,todayDate);
|
|
|
+
|
|
|
long start = System.currentTimeMillis();
|
|
|
- AsyncResult<String> projectDTOBack = computeProjectMaintenanceData(todayDate, projectId);
|
|
|
- if (projectDTOBack != null) {
|
|
|
- return projectDTOBack;
|
|
|
- }
|
|
|
+// 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();
|
|
|
}
|
|
|
}
|
|
@@ -383,23 +391,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();
|
|
@@ -413,7 +421,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;
|
|
|
}
|
|
@@ -454,15 +462,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);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -622,7 +630,7 @@ 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);
|
|
@@ -630,7 +638,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
// Map<Date, List<Date>> dateRunDataMap = getCoolTowerContinuedRunDateMap(allDateRunDataMap);
|
|
|
|
|
|
Date runDate = null;
|
|
|
- Map<Date, List<TimeDataDTO>> dayTimeDataMap = getServiceDataFromCenterDataService(projectId, cTObjId, EnumCoolWaterPointNameType.RunStatus.getCode(), startDate, endDate);
|
|
|
+ Map<Date, List<TimeDataDTO>> dayTimeDataMap = getServiceDataFromCenterDataService(projectDTO.getProjectId(), cTObjId, EnumCoolWaterPointNameType.RunStatus.getCode(), startDate, endDate);
|
|
|
//获取日 对应运行时间集合
|
|
|
Map<Date, List<Date>> dateRunDataMap = getContinuedRunDateMap(dayTimeDataMap);
|
|
|
//获取冷却水回水干管温度数据集合
|
|
@@ -640,19 +648,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)) {
|
|
@@ -663,7 +673,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;
|
|
@@ -990,7 +1000,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) {
|
|
@@ -1132,4 +1142,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("温度:"+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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|