| | |
| | | import java.util.Map; |
| | | import java.util.concurrent.CountDownLatch; |
| | | |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import com.yssh.dao.*; |
| | | import com.yssh.entity.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.google.common.collect.Lists; |
| | | import com.yssh.dao.AlertConfigMapper; |
| | | import com.yssh.dao.DictRecordMapper; |
| | | import com.yssh.dao.SuYuanMapper; |
| | | import com.yssh.dao.WarningDetailMapper; |
| | | import com.yssh.entity.DictRecord; |
| | | import com.yssh.entity.MonitorPointPosition; |
| | | import com.yssh.entity.SuYuan2d; |
| | | import com.yssh.entity.SuYuanMonitorData; |
| | | import com.yssh.entity.WarningDetail; |
| | | import com.yssh.entity.vo.WarningVo; |
| | | import com.yssh.service.IAsyncService; |
| | | import com.yssh.service.ICommonService; |
| | |
| | | |
| | | @Service |
| | | public class WarningAnalyseServiceImpl implements IWarningAnalyseService { |
| | | |
| | | protected final Log logger = LogFactory.getLog(this.getClass()); |
| | | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); |
| | | |
| | | @Resource |
| | | private WarningDetailMapper warningDetailMapper; |
| | | |
| | | @Resource |
| | | private AlertConfigMapper alertConfigMapper; |
| | | |
| | | @Resource |
| | | private ICommonService commonService; |
| | |
| | | |
| | | @Resource |
| | | private IAsyncService asyncService; |
| | | |
| | | @Resource |
| | | private QxshMapper qxshMapper; |
| | | |
| | | private SimpleDateFormat ym = new SimpleDateFormat("yyyyMM%"); |
| | | |
| | | private SimpleDateFormat ymdh = new SimpleDateFormat("yyyyMMddHH"); |
| | | |
| | |
| | | try { |
| | | insertWarningDetails(allData); |
| | | } catch (Exception e) { |
| | | logger.error("批量插入告警数据出现异常!!!"); |
| | | logger.error("批量插入告警数据出现异常!!!", e); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | |
| | | public Map<String, Integer> countThisMonthAlarmAndWarning() { |
| | | Map<String, Integer> result = new HashMap<>(); |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("startTime", ymdhms.format(DateUtils.getMonthStart())); |
| | | param.put("endTime", ymdhms.format(DateUtils.getMonthEnd())); |
| | | |
| | | param.put("type", 0); |
| | | param.put("startTime", DateUtils.getMonthStart()); |
| | | param.put("endTime", DateUtils.getMonthEnd()); |
| | | List<WarningVo> alarms = warningDetailMapper.selectWarningDetailByMap(param); |
| | | if (StringUtils.isNull(alarms)) { |
| | | alarms = new ArrayList<>(); |
| | | } |
| | | result.put("alarmNumber", alarms.size()); |
| | | |
| | | param.put("type", 1); |
| | | List<WarningVo> warnings = warningDetailMapper.selectWarningDetailByMap(param); |
| | | if (StringUtils.isNull(warnings)) { |
| | | warnings = new ArrayList<>(); |
| | | } |
| | | result.put("warningNumber", warnings.size()); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, List<Map<String, Object>>> countEverydayAlarmAndWarning() { |
| | | Map<String, List<Map<String, Object>>> result = new HashMap<>(); |
| | | |
| | | Map<String, Object> param = new HashMap<String, Object>(); |
| | | Date now = new Date(); |
| | | Date last = DateUtils.getAPeriodOfTime(now, -7, Calendar.DATE); // 上周的今天 |
| | | param.put("startTime", ymdhms.format(last)); |
| | | param.put("endTime", ymdhms.format(now)); |
| | | |
| | | param.put("type", 0); |
| | | Date endTime = DateUtils.getNowDate(); |
| | | //上周的今天 |
| | | param.put("startTime", DateUtils.getAPeriodOfTime(endTime, -7, Calendar.DATE)); |
| | | param.put("endTime", endTime); |
| | | List<Map<String, Object>> alarmDayCount = warningDetailMapper.selectWarningDayCountByMap(param); |
| | | result.put("alarmDayCount", alarmDayCount); |
| | | |
| | | param.put("type", 1); |
| | | List<Map<String, Object>> warningDayCount = warningDetailMapper.selectWarningDayCountByMap(param); |
| | | result.put("warningDayCount", warningDayCount); |
| | | |
| | | return result; |
| | | } |
| | | |
| | |
| | | List<MonitorPointPosition> checkPoints = commonService.getCheckPoints3d(); |
| | | Long startTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthStart())); |
| | | Long endTime = Long.parseLong(DateUtils.parseDateToStr(DateUtils.YYYYMMDDHH, DateUtils.getMonthEnd())); |
| | | //startTime = 2023040100L; |
| | | //endTime = 2023043023L; |
| | | |
| | | List<DictRecord> recordList = dictRecordMapper.selectByTimeDictRecordList(startTime, endTime); |
| | | |
| | | List<String> tableNames = new ArrayList<>(); |
| | |
| | | //map.put("name", commonService.select3dCheckPointById(suYuanId).getName()); |
| | | //map.remove("id"); |
| | | map.put("name", c.getName()); |
| | | result.add(map); |
| | | } |
| | | result.add(map); |
| | | } |
| | | |
| | | return CalculateUtils.sort(result, "value", true).subList(0, 10); |
| | | } |
| | | |
| | | @Override |
| | | public List<Qxsh> selectMonthTop10() { |
| | | String time = ym.format(new Date()); |
| | | |
| | | List<Qxsh> list = qxshMapper.selectMonthTop10(time); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, List<Double>> select3Hours() { |
| | | Map<String, List<Double>> map = new LinkedHashMap<>(); |
| | | |
| | | List<String> times = DateUtils.get3Hours(); |
| | | List<Qxsh> list = qxshMapper.select3Hours(times); |
| | | if (null == list || list.isEmpty()) { |
| | | return map; |
| | | } |
| | | |
| | | for (Qxsh qxsh : list) { |
| | | String name = qxsh.getName(); |
| | | |
| | | List<Double> values = map.computeIfAbsent(name, k -> new ArrayList<>()); |
| | | values.add(qxsh.getValue()); |
| | | } |
| | | |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<WarningVo> getAlarmAndWarnByTime(Date begin, Date end) { |
| | | List<WarningVo> list = new ArrayList<>(); |
| | | List<String> ids = CalculateUtils.assembleId(commonService.getCheckPoints3d()); |