|
@@ -5,16 +5,21 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.apm.diagnose.config.ComputePropertiesConfig;
|
|
|
import com.persagy.apm.diagnose.config.RabbitConfig;
|
|
|
+import com.persagy.apm.diagnose.constant.AlarmConstants;
|
|
|
import com.persagy.apm.diagnose.constant.DiAgnoseConst;
|
|
|
import com.persagy.apm.diagnose.constant.EnumDataTimeType;
|
|
|
import com.persagy.apm.diagnose.indicatorrecord.model.dto.ConfigItemDataSendTimeDTO;
|
|
|
import com.persagy.apm.diagnose.indicatorrecord.model.dto.QueryMonitorIndicatorRecordDTO;
|
|
|
import com.persagy.apm.diagnose.indicatorrecord.service.IMonitorIndicatorRecordService;
|
|
|
import com.persagy.apm.diagnose.maintenance.constant.*;
|
|
|
+import com.persagy.apm.diagnose.maintenance.model.dto.AlarmCondition;
|
|
|
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.*;
|
|
|
+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;
|
|
@@ -22,7 +27,6 @@ import com.persagy.apm.diagnose.timerecord.model.CalculateTimeRecord;
|
|
|
import com.persagy.apm.diagnose.timerecord.service.ICalculateTimeRecordService;
|
|
|
import com.persagy.apm.diagnose.utils.*;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
|
|
|
-import com.persagy.apm.diagnose.maintenance.model.dto.AlarmCondition;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.AddAlarmRecordDTO;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.BatchUpdateAlarmRecordDTO;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.QueryAlarmRecordDTO;
|
|
@@ -98,7 +102,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
@Override
|
|
|
@Async("asyncComputeMaintenanceDataExecutor")
|
|
|
- public Future<String> computeMaintenanceData(Date todayDate,ProjectDTO projectDTO, 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(projectDTO.getProjectId() + "_computeMaintenance", String.valueOf(time))) {
|
|
@@ -152,7 +156,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
long start = System.currentTimeMillis();
|
|
|
syncProjectGoingDestroyEquip(projectId);
|
|
|
long end = System.currentTimeMillis();
|
|
|
- return new AsyncResult<>("【监测同步即将报废设备线程】同步项目即将报废设备用时:" +projectId + ";" + (end - start));
|
|
|
+ return new AsyncResult<>("【监测同步即将报废设备线程】同步项目即将报废设备用时:" + projectId + ";" + (end - start));
|
|
|
} finally {
|
|
|
lockUtil.unlock(projectId + "_syncEquip", String.valueOf(time));
|
|
|
latch.countDown();
|
|
@@ -245,18 +249,18 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
alarmRecordItem.setTriggerTime(new Date());
|
|
|
alarmRecordItem.setSupplement(supplementObject);
|
|
|
alarmRecordItem.setTreatState(EnumAlarmTreatState.UN_HANDLE.getCode());
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return alarmRecordItem;
|
|
|
}
|
|
|
|
|
@@ -269,13 +273,13 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
itemCodeList.add(EnumAlarmItem.EvapAbnormal.getCode());
|
|
|
itemCodeList.add(EnumAlarmItem.CoolTowerApproachTempAbnormal.getCode());
|
|
|
|
|
|
- List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectId,itemCodeList);
|
|
|
+ List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectId, itemCodeList);
|
|
|
if (CollectionUtils.isEmpty(projectAlarmRules)) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
Map<String, List<String>> objIdAlarmItemCodeAndInfoCodes = getObjIdAlarmItemCodeAndInfoCodes(projectAlarmRules);
|
|
|
- if (CollectionUtils.isEmpty(objIdAlarmItemCodeAndInfoCodes) || objIdAlarmItemCodeAndInfoCodes.size() == 0){
|
|
|
+ if (CollectionUtils.isEmpty(objIdAlarmItemCodeAndInfoCodes) || objIdAlarmItemCodeAndInfoCodes.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
for (Map.Entry<String, List<String>> entry : objIdAlarmItemCodeAndInfoCodes.entrySet()) {
|
|
@@ -283,9 +287,9 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
int indexOf = objIdAndAlarmItemCode.indexOf("_");
|
|
|
String objId = objIdAndAlarmItemCode.substring(0, indexOf);
|
|
|
String alarmItemCode = objIdAndAlarmItemCode.substring(indexOf + 1);
|
|
|
- String lockKey = objId+"-"+alarmItemCode;
|
|
|
+ String lockKey = AlarmConstants.alarmDataLockPrefix + objId + "-" + alarmItemCode;
|
|
|
Object isLock = redisUtil.get(lockKey);
|
|
|
- if (null == isLock){
|
|
|
+ if (null == isLock) {
|
|
|
continue;
|
|
|
}
|
|
|
long time = System.currentTimeMillis() + (10 * 1000);
|
|
@@ -315,14 +319,14 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
if (CollectionUtils.isEmpty(value) || value.size() != infCodeList.size()) {
|
|
|
continue;
|
|
|
}
|
|
|
- sendTimeKeyAndDataList.put(dateListEntry.getKey(),value);
|
|
|
+ sendTimeKeyAndDataList.put(dateListEntry.getKey(), value);
|
|
|
endTime = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dateListEntry.getKey(), com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
}
|
|
|
- JSONArray sendArray = CollectDataUtil.batchBuildSendJsonParam(sendTimeKeyAndDataList,alarmItemCode);
|
|
|
+ JSONArray sendArray = CollectDataUtil.batchBuildSendJsonParam(sendTimeKeyAndDataList, alarmItemCode);
|
|
|
rabbitConfig.sendMsg(sendArray);
|
|
|
-
|
|
|
-
|
|
|
- log.info("设备维保发送数据服务数据:" + projectId+";"+ sendArray);
|
|
|
+
|
|
|
+
|
|
|
+ log.info("设备维保发送数据服务数据:" + projectId + ";" + sendArray);
|
|
|
configItemSendTimeDTO.setLastSendTime(endTime);
|
|
|
configItemSendTimeDTO.setUpdateTime(new Date());
|
|
|
updateRedisConfigItemSendTimeDTO(projectId, objIdAndAlarmItemCode, configItemSendTimeDTO);
|
|
@@ -337,7 +341,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
MonitorIndicatorRecord monitorIndicatorRecord = new MonitorIndicatorRecord();
|
|
|
monitorIndicatorRecord.setProject(projectId);
|
|
|
monitorIndicatorRecord.setObjId(objId);
|
|
|
-
|
|
|
+
|
|
|
monitorIndicatorRecord.setSpecialOperation("monitorIndicatorId", SpecialOperator.$in, infoCodes);
|
|
|
monitorIndicatorRecord.setSpecialOperation("dataTime", SpecialOperator.$gte, lastSendTime);
|
|
|
monitorIndicatorRecord.setSpecialOperation("dataTime", SpecialOperator.$lt, endTime);
|
|
@@ -351,7 +355,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
String alarmItemCode = projectAlarmRule.getAlarmItemCode();
|
|
|
List<String> objIds = projectAlarmRule.getObjIds();
|
|
|
List<String> infoCodes = projectAlarmRule.getInfoCodes();
|
|
|
- if (!CollectionUtils.isEmpty(infoCodes) && !CollectionUtils.isEmpty(objIds)){
|
|
|
+ if (!CollectionUtils.isEmpty(infoCodes) && !CollectionUtils.isEmpty(objIds)) {
|
|
|
for (String infoCode : infoCodes) {
|
|
|
for (String objId : objIds) {
|
|
|
String key = objId + "_" + alarmItemCode;
|
|
@@ -398,7 +402,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
itemCodeList.add(EnumAlarmItem.CondAbnormal.getCode());
|
|
|
itemCodeList.add(EnumAlarmItem.EvapAbnormal.getCode());
|
|
|
itemCodeList.add(EnumAlarmItem.CoolTowerApproachTempAbnormal.getCode());
|
|
|
- List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectDTO.getProjectId(),itemCodeList);
|
|
|
+ List<AlarmRuleDTO> projectAlarmRules = energyAlarmService.getProjectAlarmRules(projectDTO.getProjectId(), itemCodeList);
|
|
|
if (CollectionUtils.isEmpty(projectAlarmRules)) {
|
|
|
return new AsyncResult<>("【监测维保数据计算线程】当前项目:" + projectDTO.getProjectId() + "未设置设备维保报警规则");
|
|
|
}
|
|
@@ -409,34 +413,34 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
Map<String, Date> objId_indicatorIdAndComputeTime = getObjId_IndicatorIdAndComputeTIme(projectDTO.getProjectId());
|
|
|
|
|
|
- for (AlarmRuleDTO alarmRuleDTO:projectAlarmRules) {
|
|
|
+ for (AlarmRuleDTO alarmRuleDTO : projectAlarmRules) {
|
|
|
String itemCode = alarmRuleDTO.getAlarmItemCode();
|
|
|
EnumAlarmItem enumAlarmItem = EnumAlarmItem.getEnumAlarmLevel(itemCode);
|
|
|
- if (enumAlarmItem == null){
|
|
|
+ if (enumAlarmItem == null) {
|
|
|
continue;
|
|
|
}
|
|
|
List<String> objIdList = alarmRuleDTO.getObjIds();
|
|
|
List<String> infoCodeList = alarmRuleDTO.getInfoCodes();
|
|
|
- if (CollectionUtils.isEmpty(objIdList) || CollectionUtils.isEmpty(infoCodeList)){
|
|
|
+ if (CollectionUtils.isEmpty(objIdList) || CollectionUtils.isEmpty(infoCodeList)) {
|
|
|
continue;
|
|
|
}
|
|
|
- for (String objId:objIdList) {
|
|
|
- List<AlarmCondition> alarmConditionList = energyAlarmService.getProjectAlarmCondition(projectDTO.getProjectId(),objId,enumAlarmItem.getCode());
|
|
|
- if (CollectionUtils.isEmpty(alarmConditionList)){
|
|
|
+ for (String objId : objIdList) {
|
|
|
+ List<AlarmCondition> alarmConditionList = energyAlarmService.getProjectAlarmCondition(projectDTO.getProjectId(), objId, enumAlarmItem.getCode());
|
|
|
+ if (CollectionUtils.isEmpty(alarmConditionList)) {
|
|
|
continue;
|
|
|
}
|
|
|
- Map<String,CalculateMethodDTO> monitorIndicatorMap = new HashMap<>();
|
|
|
+ Map<String, CalculateMethodDTO> monitorIndicatorMap = new HashMap<>();
|
|
|
AlarmCondition condition = alarmConditionList.get(0);
|
|
|
List<List<CalculateMethodDTO>> calculateMethodDTOLists = condition.getTriggerFrontend();
|
|
|
- if (!CollectionUtils.isEmpty(calculateMethodDTOLists)){
|
|
|
- for (List<CalculateMethodDTO> dtoList:calculateMethodDTOLists) {
|
|
|
- for (CalculateMethodDTO dto:dtoList) {
|
|
|
- monitorIndicatorMap.put(dto.getMonitorIndicatorId(),dto);
|
|
|
+ if (!CollectionUtils.isEmpty(calculateMethodDTOLists)) {
|
|
|
+ for (List<CalculateMethodDTO> dtoList : calculateMethodDTOLists) {
|
|
|
+ for (CalculateMethodDTO dto : dtoList) {
|
|
|
+ monitorIndicatorMap.put(dto.getMonitorIndicatorId(), dto);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- for (String infoCode:infoCodeList) {
|
|
|
+ for (String infoCode : infoCodeList) {
|
|
|
EnumMaintenanceIndicatorType indicatorType = EnumMaintenanceIndicatorType.getEnumMaintenanceDataType(infoCode);
|
|
|
if (indicatorType == null) {
|
|
|
continue;
|
|
@@ -453,7 +457,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
EnumMaintenanceIndicatorType.ACCCOT_ContinuousOperation == indicatorType) {
|
|
|
continue;
|
|
|
}
|
|
|
- String objIdIndicatorId = objId+alarmSplit+infoCode;
|
|
|
+ String objIdIndicatorId = objId + alarmSplit + infoCode;
|
|
|
|
|
|
Date lastComputeTime = objId_indicatorIdAndComputeTime.get(objIdIndicatorId);
|
|
|
if (lastComputeTime == null) {
|
|
@@ -468,7 +472,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
computeTime = computeCoolWaterData(lastComputeTime, todayDate, projectDTO.getProjectId(), objId, indicatorType);
|
|
|
}
|
|
|
|
|
|
- computeAlarmDay(projectDTO.getProjectId(), objId, infoCode, indicatorType, lastComputeTime, todayDate,monitorIndicatorMap);
|
|
|
+ computeAlarmDay(projectDTO.getProjectId(), objId, infoCode, indicatorType, lastComputeTime, todayDate, monitorIndicatorMap);
|
|
|
|
|
|
saveOrUpdateComputeTime(projectDTO.getProjectId(), objId, infoCode, computeTime);
|
|
|
}
|
|
@@ -483,7 +487,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
* 计算报警持续时长
|
|
|
*/
|
|
|
- public void computeAlarmDay(String projectId, String objId, String indicatorId, EnumMaintenanceIndicatorType indicatorType, Date lastComputeTime, Date todayDate, Map<String,CalculateMethodDTO> configMap) throws Exception {
|
|
|
+ public void computeAlarmDay(String projectId, String objId, String indicatorId, EnumMaintenanceIndicatorType indicatorType, Date lastComputeTime, Date todayDate, Map<String, CalculateMethodDTO> configMap) throws Exception {
|
|
|
|
|
|
CalculateMethodDTO thresholdConfig = null, timeConfig = null;
|
|
|
EnumMaintenanceIndicatorType saveIndicatorType = null;
|
|
@@ -632,11 +636,11 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
* 冷却塔 日均计算
|
|
|
*/
|
|
|
Date computeCoolTowerData(Date startDate, Date endDate, ProjectDTO projectDTO, String cTObjId, EnumMaintenanceIndicatorType indicatorType) throws Exception {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
Date runDate = null;
|
|
|
Map<Date, List<TimeDataDTO>> dayTimeDataMap = getServiceDataFromCenterDataService(projectDTO.getProjectId(), cTObjId, EnumCoolWaterPointNameType.RunStatus.getCode(), startDate, endDate);
|
|
@@ -656,14 +660,14 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
dayCoolWaterMainReturnTempMap = getServiceDataFromCenterDataService(projectDTO.getProjectId(), objId, EnumCoolTowerPointNameType.CoolWaterMainReturnTemp.getCode(), startDate, endDate);
|
|
|
}
|
|
|
|
|
|
- dayTwdTempMap = computerWetBallTempMap(projectDTO,startDate,endDate);
|
|
|
+ dayTwdTempMap = computerWetBallTempMap(projectDTO, startDate, endDate);
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
for (Date dayDate = startDate; dayDate.before(endDate); dayDate = DateUtils.addDays(dayDate, 1)) {
|
|
@@ -692,7 +696,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
Map<Date, List<Date>> dateRunDataMap = getContinuedRunDateMap(dayTimeDataMap);
|
|
|
Map<Date, List<TimeDataDTO>> firstDayTempDataMap = new HashMap<>();
|
|
|
Map<Date, List<TimeDataDTO>> secondDayTempDataMap = new HashMap<>();
|
|
|
- if (null != dateRunDataMap && dateRunDataMap.size() > 0){
|
|
|
+ if (null != dateRunDataMap && dateRunDataMap.size() > 0) {
|
|
|
|
|
|
if (EnumMaintenanceIndicatorType.ACCCAC_CondHeatTransferDayAvg == indicatorType ||
|
|
|
EnumMaintenanceIndicatorType.ACCCCC_CondHeatTransferDayAvg == indicatorType ||
|
|
@@ -732,13 +736,14 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
* 计算日均构造实体对象 存储更新数据库表记录
|
|
|
*/
|
|
|
- public Double computeDayAvg(Date dayDate, Map<Date, List<Date>> dateRunDataMap, Map<Date, List<TimeDataDTO>> firstDataMap,
|
|
|
- Map<Date, List<TimeDataDTO>> secondDataMap) {
|
|
|
+ public Double computeDayAvg(
|
|
|
+ Date dayDate, Map<Date, List<Date>> dateRunDataMap, Map<Date, List<TimeDataDTO>> firstDataMap,
|
|
|
+ Map<Date, List<TimeDataDTO>> secondDataMap) {
|
|
|
Double avg = null;
|
|
|
try {
|
|
|
- if (null != dateRunDataMap && dateRunDataMap.containsKey(dayDate)){
|
|
|
+ if (null != dateRunDataMap && dateRunDataMap.containsKey(dayDate)) {
|
|
|
List<Date> runDateList = dateRunDataMap.get(dayDate);
|
|
|
- if (!CollectionUtils.isEmpty(runDateList)){
|
|
|
+ if (!CollectionUtils.isEmpty(runDateList)) {
|
|
|
Map<Date, Double> firstDateDataMap = getTimePointDataMap(dayDate, firstDataMap);
|
|
|
Map<Date, Double> secondDateDataMap = getTimePointDataMap(dayDate, secondDataMap);
|
|
|
|
|
@@ -814,15 +819,15 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
}
|
|
|
List<Date> dateList = new ArrayList<>();
|
|
|
for (TimeDataDTO dto : dataDTOList) {
|
|
|
- if (null == dto.getData()){
|
|
|
+ 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 (dto.getData() > runStateDownLimit && dto.getData() < runStateUpLimit) {
|
|
|
dateList.add(getDate);
|
|
@@ -894,13 +899,13 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
dateList = dateRunDataMap.get(dayDate);
|
|
|
}
|
|
|
for (TimeDataDTO dto : dataDTOList) {
|
|
|
- if (null == dto.getData()){
|
|
|
+ if (null == dto.getData()) {
|
|
|
continue;
|
|
|
}
|
|
|
Date getDate = com.persagy.apm.diagnose.utils.DateUtils.str2Date(dto.getTime(), com.persagy.apm.diagnose.utils.DateUtils.SDFSECOND);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (dto.getData() > runStateDownLimit && dto.getData() < runStateUpLimit) {
|
|
|
dateList.add(getDate);
|
|
|
}
|
|
@@ -926,16 +931,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 (null == dto.getData()){
|
|
|
+ if (null == dto.getData()) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if (dto.getData() < runStateDownLimit || dto.getData() > runStateUpLimit) {
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -950,12 +955,12 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
public String getFirstRunDate(List<TimeDataDTO> dataDTOList) {
|
|
|
try {
|
|
|
for (TimeDataDTO dto : dataDTOList) {
|
|
|
- if (null == dto.getData()){
|
|
|
+ if (null == dto.getData()) {
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
if (dto.getData() > runStateDownLimit && dto.getData() < runStateUpLimit) {
|
|
|
return dto.getTime();
|
|
|
}
|
|
@@ -970,8 +975,9 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
* 获取数据
|
|
|
*/
|
|
|
- private Map<Date, List<TimeDataDTO>> getServiceDataFromCenterDataService(String projectId, String objId, String computeCode,
|
|
|
- Date startTime, Date endTime) throws Exception {
|
|
|
+ private Map<Date, List<TimeDataDTO>> getServiceDataFromCenterDataService(
|
|
|
+ String projectId, String objId, String computeCode,
|
|
|
+ Date startTime, Date endTime) throws Exception {
|
|
|
List<TimeDataDTO> dataList = centerDataService.queryObjTimeDataList(projectId, objId, computeCode, startTime, endTime, EnumDataTimeType.MIN15);
|
|
|
if (CollectionUtils.isEmpty(dataList)) {
|
|
|
log.error("【维保计算线程】:查询数据中台对象历史数据为空,projectId:" + projectId + ";objId:" + objId + ";信息点:" + computeCode
|
|
@@ -1022,7 +1028,7 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
queryAlarmRecordDTO.setCategory(cateGoryList);
|
|
|
DmpResult<List<AlarmRecordItem>> configItemResultList = alarmRecordService.query(queryAlarmRecordDTO);
|
|
|
List<AlarmRecordItem> alarmRecordItemList = DmpResultUtil.getData(configItemResultList);
|
|
|
- if (!CollectionUtils.isEmpty(alarmRecordItemList)){
|
|
|
+ if (!CollectionUtils.isEmpty(alarmRecordItemList)) {
|
|
|
return alarmRecordItemList.stream().collect(Collectors.toMap(AlarmRecordItem::getObjId, Function.identity(), (a, b) -> b));
|
|
|
}
|
|
|
return new HashMap<>();
|
|
@@ -1056,10 +1062,9 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
* 更新缓存中报警配置发数时间
|
|
|
*/
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void saveOrUpdateComputeTime(String projectId, String objId, String indicatorId, Date computeTime) {
|
|
|
if (computeTime == null) {
|
|
|
return;
|
|
@@ -1079,11 +1084,11 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
Set<String> objIdAndInfoCode = new HashSet<>();
|
|
|
for (AlarmRuleDTO projectAlarmRule : projectAlarmRules) {
|
|
|
List<String> objIds = projectAlarmRule.getObjIds();
|
|
|
- if(CollectionUtils.isEmpty(objIds)){
|
|
|
+ if (CollectionUtils.isEmpty(objIds)) {
|
|
|
continue;
|
|
|
}
|
|
|
List<String> infoCodes = projectAlarmRule.getInfoCodes();
|
|
|
- if (CollectionUtils.isEmpty(infoCodes)){
|
|
|
+ if (CollectionUtils.isEmpty(infoCodes)) {
|
|
|
continue;
|
|
|
}
|
|
|
for (String infoCode : infoCodes) {
|
|
@@ -1095,35 +1100,35 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
return objIdAndInfoCode;
|
|
|
}
|
|
|
|
|
|
- public Map<Date, List<TimeDataDTO>> computerWetBallTempMap(ProjectDTO projectDTO,Date startDate,Date endDate){
|
|
|
+ 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<WeatherDTO>> dayWeatherDataMap = getWeatherTemp(projectDTO, startDate, endDate);
|
|
|
+ if (null != dayWeatherDataMap && dayWeatherDataMap.size() > 0) {
|
|
|
Map<Date, List<TimeDataDTO>> dayTwdTempMap = new HashMap<>();
|
|
|
- for (Date dayDate:dayWeatherDataMap.keySet()) {
|
|
|
+ for (Date dayDate : dayWeatherDataMap.keySet()) {
|
|
|
List<WeatherDTO> dtoList = dayWeatherDataMap.get(dayDate);
|
|
|
- if (CollectionUtils.isEmpty(dtoList)){
|
|
|
+ if (CollectionUtils.isEmpty(dtoList)) {
|
|
|
continue;
|
|
|
}
|
|
|
List<TimeDataDTO> timeDataDTOList = new ArrayList<>();
|
|
|
- for (WeatherDTO dto:dtoList) {
|
|
|
+ for (WeatherDTO dto : dtoList) {
|
|
|
|
|
|
- Double hVal = getHVal(dto.getTemperature(),dto.getHumidity());
|
|
|
+ Double hVal = getHVal(dto.getTemperature(), dto.getHumidity());
|
|
|
|
|
|
- Double Tw = getTw(dto.getTemperature(),hVal,TwdTemp_Limit);
|
|
|
- log.info("项目编号为:"+projectDTO.getProjectId()+"日期为:"+dto.getHourTime()+"温度:"+dto.getTemperature()+"湿度:"+dto.getHumidity()+"湿球温度:"+Tw);
|
|
|
+ Double Tw = 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)) {
|
|
|
+ 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);
|
|
|
+ dayTwdTempMap.put(dayDate, timeDataDTOList);
|
|
|
}
|
|
|
return dayTwdTempMap;
|
|
|
}
|
|
@@ -1136,16 +1141,16 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
* 获取项目 天气数据
|
|
|
*/
|
|
|
- public Map<Date, List<WeatherDTO>> getWeatherTemp(ProjectDTO projectDTO,Date startDate,Date endDate){
|
|
|
+ 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)){
|
|
|
+ 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) {
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
Date dayDate = DateUtils.truncate(dto.getHourTime(), Calendar.DATE);
|
|
|
if (dayTimeWeatherDataMap.containsKey(dayDate)) {
|
|
|
dayTimeWeatherDataMap.get(dayDate).add(dto);
|
|
@@ -1167,39 +1172,39 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
* 根据允许范围推出Tw值
|
|
|
*/
|
|
|
public Double getTw(Double Td, Double hVal, Double limit) throws InterruptedException {
|
|
|
- Double Tw = Td-3;
|
|
|
+ Double Tw = Td - 3;
|
|
|
Double num = 0.0;
|
|
|
Boolean isOk = false;
|
|
|
Boolean isTrueVal = false;
|
|
|
- Integer zNum = 0,jNum = 0;
|
|
|
- while (!isOk){
|
|
|
+ Integer zNum = 0, jNum = 0;
|
|
|
+ while (!isOk) {
|
|
|
|
|
|
Double hwVal = getHwVal(Tw);
|
|
|
|
|
|
- Double hc = DataUtils.subtract(hVal,hwVal);
|
|
|
+ Double hc = DataUtils.subtract(hVal, hwVal);
|
|
|
|
|
|
- if (hc<limit && hc > 0.0){
|
|
|
+ if (hc < limit && hc > 0.0) {
|
|
|
isOk = true;
|
|
|
isTrueVal = true;
|
|
|
- }else if (hc > 0){
|
|
|
+ } else if (hc > 0) {
|
|
|
Tw = Tw + 0.25;
|
|
|
zNum++;
|
|
|
- }else if (hc < 0){
|
|
|
+ } else if (hc < 0) {
|
|
|
Tw = Tw - 0.25;
|
|
|
jNum++;
|
|
|
}
|
|
|
num++;
|
|
|
- if (num > 10){
|
|
|
+ if (num > 10) {
|
|
|
isOk = true;
|
|
|
}
|
|
|
}
|
|
|
- if (isTrueVal){
|
|
|
+ if (isTrueVal) {
|
|
|
return Tw;
|
|
|
- }else {
|
|
|
- if (zNum > 0 && jNum > 0){
|
|
|
+ } else {
|
|
|
+ if (zNum > 0 && jNum > 0) {
|
|
|
return Tw;
|
|
|
- }else{
|
|
|
- return getTw(Tw,hVal,limit+0.5);
|
|
|
+ } else {
|
|
|
+ return getTw(Tw, hVal, limit + 0.5);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1207,29 +1212,29 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
|
|
|
|
|
|
* 根据湿球温度计算出湿空气焓值
|
|
|
*/
|
|
|
- public double getHwVal(Double Tw){
|
|
|
- Double eVal = (18.678-Tw/234.5)*Tw/(Tw+257.14);
|
|
|
- Double ev= Math.exp(eVal);
|
|
|
+ public double getHwVal(Double Tw) {
|
|
|
+ Double eVal = (18.678 - Tw / 234.5) * Tw / (Tw + 257.14);
|
|
|
+ Double ev = Math.exp(eVal);
|
|
|
Double Pv = 611.2 * ev;
|
|
|
|
|
|
- Double dw = 0.6219*(Pv/(101326-Pv));
|
|
|
+ Double dw = 0.6219 * (Pv / (101326 - Pv));
|
|
|
|
|
|
- Double hw = 1.01*Tw + (2500+1.84*Tw)*dw;
|
|
|
+ Double hw = 1.01 * Tw + (2500 + 1.84 * Tw) * dw;
|
|
|
return hw;
|
|
|
}
|
|
|
|
|
|
|
|
|
* 根据温度和湿度 计算出湿空气焓值
|
|
|
*/
|
|
|
- public double getHVal(Double Td,Double Hr){
|
|
|
- Double eVal = (18.678-Td/234.5)*Td/(Td+257.14);
|
|
|
- Double ev= Math.exp(eVal);
|
|
|
- Double Pv = 611.2*ev;
|
|
|
- Double hrPv = 0.01*Hr*Pv;
|
|
|
+ public double getHVal(Double Td, Double Hr) {
|
|
|
+ Double eVal = (18.678 - Td / 234.5) * Td / (Td + 257.14);
|
|
|
+ Double ev = Math.exp(eVal);
|
|
|
+ Double Pv = 611.2 * ev;
|
|
|
+ Double hrPv = 0.01 * Hr * Pv;
|
|
|
|
|
|
- Double d = 0.6219*(hrPv/(101326-hrPv));
|
|
|
+ Double d = 0.6219 * (hrPv / (101326 - hrPv));
|
|
|
|
|
|
- Double h = 1.01*Td + (2500+1.84*Td)*d;
|
|
|
+ Double h = 1.01 * Td + (2500 + 1.84 * Td) * d;
|
|
|
return h;
|
|
|
}
|
|
|
|