Commit b1af2f42 authored by tianyiming's avatar tianyiming

四横八纵稳压泵统计添加定时向缓存中存昨日启动次数任务

parent f8e7f6a4
...@@ -18,6 +18,7 @@ public enum PressurePumpRelateEnum { ...@@ -18,6 +18,7 @@ public enum PressurePumpRelateEnum {
TWO_HOUR("2.0", "2小时"), TWO_HOUR("2.0", "2小时"),
FOUR_HOUR("4.0", "4小时"), FOUR_HOUR("4.0", "4小时"),
DAY_AVG("-3", "今日累计启停次数,取前3天平均值"), DAY_AVG("-3", "今日累计启停次数,取前3天平均值"),
CRON_BEFORE_DAY("-1", "昨天定时任务"),
START_FIVE("5", "稳压泵启动5分钟"), START_FIVE("5", "稳压泵启动5分钟"),
PIPE_PRESSURE_DIFF("0.05", "管网压力差判定标准,> 0.05Mpa 异常, <= 0.05 正常"), PIPE_PRESSURE_DIFF("0.05", "管网压力差判定标准,> 0.05Mpa 异常, <= 0.05 正常"),
PRESSURE_PUMP_START_BEFORE_MINUTE("-5", "稳压泵启泵前分钟数"), PRESSURE_PUMP_START_BEFORE_MINUTE("-5", "稳压泵启泵前分钟数"),
......
...@@ -613,6 +613,24 @@ public class EmergencyController extends AbstractBaseController { ...@@ -613,6 +613,24 @@ public class EmergencyController extends AbstractBaseController {
@PersonIdentify @PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/getPressurePumpDay")
@ApiOperation(httpMethod = "GET", value = "四横八纵-稳压泵诊断分析", notes = "四横八纵-稳压泵诊断分析")
public ResponseModel getPressurePumpDay(@RequestParam(required = false) String bizOrgCode) {
if(StringUtils.isEmpty(bizOrgCode)) {
ReginParams reginParams = getSelectedOrgInfo();
ReginParams.PersonIdentity personIdentity = reginParams.getPersonIdentity();
if (!ValidationUtil.isEmpty(personIdentity)) {
bizOrgCode = personIdentity.getBizOrgCode();
if (bizOrgCode == null) {
return CommonResponseUtil.success(Collections.EMPTY_LIST);
}
}
}
return CommonResponseUtil.success(iEmergencyService.getPressurePumpDay(bizOrgCode));
}
@PersonIdentify
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/alarmList") @GetMapping(value = "/alarmList")
@ApiOperation(httpMethod = "GET", value = "消防告警信息", notes = "消防告警信息") @ApiOperation(httpMethod = "GET", value = "消防告警信息", notes = "消防告警信息")
public ResponseModel alarmList(@RequestParam Integer pageNumber, public ResponseModel alarmList(@RequestParam Integer pageNumber,
......
package com.yeejoin.equipmanage.service; package com.yeejoin.equipmanage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.vo.PressurePumpCountVo;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -59,4 +60,6 @@ public interface IEmergencyService { ...@@ -59,4 +60,6 @@ public interface IEmergencyService {
List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String bizOrgCode); List<Map<String, Object>> getPressurePumpDiagnosticAnalysis(String bizOrgCode);
Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus); Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page,String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus);
List<PressurePumpCountVo> getPressurePumpDay(String bizOrgCode);
} }
...@@ -135,4 +135,6 @@ public interface IPressurePumpService { ...@@ -135,4 +135,6 @@ public interface IPressurePumpService {
Object mapToObject(Map<String,String> map,Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException; Object mapToObject(Map<String,String> map,Class<?> aClass, String indexKey) throws IllegalAccessException, InstantiationException;
List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String countRedisKey, String equipmentCode, String nameKey, String bizOrgCode, long countExpire); List<PressurePumpCountVo> getDayAvgDataList(List<Map<String, Object>> pumpInfoList, String infoCode, String countRedisKey, String equipmentCode, String nameKey, String bizOrgCode, long countExpire);
List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire);
} }
...@@ -2,6 +2,8 @@ package com.yeejoin.equipmanage.service.impl; ...@@ -2,6 +2,8 @@ package com.yeejoin.equipmanage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog; import com.yeejoin.equipmanage.common.entity.EquipmentSpecificAlarmLog;
import com.yeejoin.equipmanage.common.enums.IndexStatusEnum; import com.yeejoin.equipmanage.common.enums.IndexStatusEnum;
import com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum; import com.yeejoin.equipmanage.common.enums.PressurePumpAnalysisEnum;
...@@ -19,9 +21,12 @@ import lombok.extern.slf4j.Slf4j; ...@@ -19,9 +21,12 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists; import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.text.ParseException;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -55,6 +60,9 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -55,6 +60,9 @@ public class EmergencyServiceImpl implements IEmergencyService {
@Value("${equipment.pressurepump.pipepressure}") @Value("${equipment.pressurepump.pipepressure}")
private String pressurePumpPipePressure; private String pressurePumpPipePressure;
@Value("${equipment.pressurepump.start.cron}")
private String pumpYesterdayStart;
@Override @Override
public List<Map<String, Object>> getSystemState(String bizOrgCode) { public List<Map<String, Object>> getSystemState(String bizOrgCode) {
List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode); List<Map<String, Object>> list = emergencyMapper.getSystemState(bizOrgCode);
...@@ -394,4 +402,38 @@ public class EmergencyServiceImpl implements IEmergencyService { ...@@ -394,4 +402,38 @@ public class EmergencyServiceImpl implements IEmergencyService {
public Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page, String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus) { public Page<Map<String, Object>> alarmList(Page<Map<String, Object>> page, String bizOrgCode, List<String> types, List<String> emergencyLevels, String name, Integer cleanStatus, Integer handleStatus) {
return emergencyMapper.alarmList(page, bizOrgCode, types, emergencyLevels, name, cleanStatus, handleStatus); return emergencyMapper.alarmList(page, bizOrgCode, types, emergencyLevels, name, cleanStatus, handleStatus);
} }
//稳压泵定时向缓存中存昨日启动次数任务
@Scheduled(cron = "${equipment.pressurepump.start.cron}")
private void stationDoubleReport() {
System.out.println("开始定时存储昨日稳压泵启动次数,定时时间为:" + pumpYesterdayStart);
getPressurePumpDay(null);
}
@Override
public List<PressurePumpCountVo> getPressurePumpDay(String bizOrgCode) {
// 从 json 配置文件获取配置信息
List<Map> infoList = pressurePumpService.getNameKeyInfoList(PressurePumpRelateEnum.PRESSURE_PUMP.getValue());
List<PressurePumpCountVo> dataList = new ArrayList<>();
if (!CollectionUtils.isEmpty(infoList)) {
try {
Date dateNow = DateUtils.convertStrToDate(DateUtils.getDateNowString(), DateUtils.DATE_PATTERN);
Date beforeDate = DateUtils.dateAddDays(dateNow, Integer.parseInt(PressurePumpRelateEnum.CRON_BEFORE_DAY.getValue()));
// iot获取数据,返回并存储redis
String startTime = DateUtils.convertDateToString(beforeDate, DateUtils.DATE_TIME_PATTERN);
String endTime = DateUtils.convertDateToString(dateNow, DateUtils.DATE_TIME_PATTERN);
Map map = infoList.get(0);
String equipmentCode = map.get("equipmentCode").toString();
String countRedisKey = map.get("countRedisKey").toString();
long countExpire = Long.parseLong(map.get("countExpire").toString());
List<Map<String, Object>> pumpInfoList = equipmentSpecificSerivce.getFirePumpInfoEQ(equipmentCode, bizOrgCode);
Object iotCode = pumpInfoList.get(0).get("iotCode");
String prefix = ObjectUtils.isEmpty(iotCode) ? "" : iotCode.toString().substring(0, 8);
dataList = pressurePumpService.getIotCountData(startTime, endTime, PressurePumpRelateEnum.PRESSURE_PUMP.getValue(), countRedisKey, prefix, null, PressurePumpRelateEnum.IOT_INDEX_VALUE_TRUE.getValue(), pressurePumpStart, countExpire);
} catch (ParseException e) {
log.error("redis存稳压泵昨天启动次数失败:{}", e.getMessage());
}
}
return dataList;
}
} }
...@@ -310,7 +310,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService { ...@@ -310,7 +310,8 @@ public class PressurePumpServiceImpl implements IPressurePumpService {
return Collections.emptyList(); return Collections.emptyList();
} }
private List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire) { @Override
public List<PressurePumpCountVo> getIotCountData(String startTime, String endTime, String infoCode, String countRedisKey, String prefix, String suffix, String key, String fieldKey, long expire) {
List<Map<String, String>> dataMapList = getIotCommonListData(startTime, endTime, prefix, suffix, key, fieldKey); List<Map<String, String>> dataMapList = getIotCommonListData(startTime, endTime, prefix, suffix, key, fieldKey);
if (CollectionUtils.isNotEmpty(dataMapList) && StringUtils.isNotBlank(key)) { if (CollectionUtils.isNotEmpty(dataMapList) && StringUtils.isNotBlank(key)) {
Map<String, List<Map<String, String>>> dataMap = dataMapList.stream().filter(y -> y.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && y.get(fieldKey) != null && key.equalsIgnoreCase(y.get(fieldKey))).collect(Collectors.groupingBy(e -> e.get(PressurePumpRelateEnum.CREATED_TIME.getValue()).substring(0, 10))); Map<String, List<Map<String, String>>> dataMap = dataMapList.stream().filter(y -> y.containsKey(PressurePumpRelateEnum.CREATED_TIME.getValue()) && y.get(fieldKey) != null && key.equalsIgnoreCase(y.get(fieldKey))).collect(Collectors.groupingBy(e -> e.get(PressurePumpRelateEnum.CREATED_TIME.getValue()).substring(0, 10)));
......
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