Merge remote-tracking branch 'origin/jtdev' into jtdev
| | |
| | | return R.data(alarmRecordService.statisticAlarmRecord(alarmRecord)); |
| | | } |
| | | |
| | | /** |
| | | * 告警统计按告警分类-等级统计 |
| | | * @param alarmRecord |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录-告警统计按告警分类-等级统计", notes="告警记录-告警统计按告警分类-等级统计") |
| | | @GetMapping(value = "/statisticAlaByTypeAndLev") |
| | | public R statisticAlaByTypeAndLev(AlarmRecordVO alarmRecord) { |
| | | return R.data(alarmRecordService.statisticAlaByTypeAndLev(alarmRecord)); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | List<StatisticAlarmRecord> statisticsPie(@Param("alarmRecord") AlarmRecordVO alarmRecordVO); |
| | | |
| | | /** |
| | | * 告警统计按告警分类-等级统计 |
| | | * @param alarmRecord |
| | | * @return |
| | | */ |
| | | List<StatisticAlarmRecord> statisticAlaByTypeAndLev(@Param("alarmRecord") AlarmRecordVO alarmRecord); |
| | | } |
| | |
| | | order by field(rule.alarm_level,'蓝色预警','黄色预警','橙色预警','红色预警') |
| | | </select> |
| | | |
| | | <!--告警统计按告警分类-等级统计--> |
| | | <select id="statisticAlaByTypeAndLev" resultType="cn.gistack.alerts.alarmRule.vo.StatisticAlarmRecord"> |
| | | SELECT |
| | | count(*) num,type as ruleName,rule.alarm_level alarmLevel |
| | | FROM YWXT.sm_alarm_record record |
| | | LEFT JOIN ywxt.SM_ALARM_RULE rule on rule.id = record.alarm_rule_id |
| | | LEFT JOIN SJZT_MD."att_res_base" arb on arb."guid" = record.reservoir_number |
| | | LEFT JOIN SJZT_MD."rel_res_bas_loc" rrbl ON rrbl."res_guid" = record.reservoir_number |
| | | LEFT JOIN SJZT_MD."att_bas_base" abb ON abb."code" = rrbl."bas_guid" |
| | | LEFT JOIN SJZT_MD."att_bas_base" pabb ON abb."p_code" = pabb."code" |
| | | where |
| | | record.is_deleted = 0 |
| | | and rule.type in ('渗压监测','渗流监测','变形监测','水情监测','雨情监测') |
| | | <if test="alarmRecord.reservoirName!=null and alarmRecord.reservoirName!=''"> |
| | | and arb."name" like concat('%',#{alarmRecord.reservoirName},'%') |
| | | </if> |
| | | <if test="alarmRecord.alarmRuleType!=null and alarmRecord.alarmRuleType!=''"> |
| | | and rule.alarm_rule_type = #{alarmRecord.alarmRuleType} |
| | | </if> |
| | | <if test="alarmRecord.createAlarmType!=null and alarmRecord.createAlarmType!=''"> |
| | | and rule.create_alarm_type = #{alarmRecord.createAlarmType} |
| | | </if> |
| | | <if test="alarmRecord.ruleName!=null and alarmRecord.ruleName!=''"> |
| | | and rule.rule_name = #{alarmRecord.ruleName} |
| | | </if> |
| | | <if test="alarmRecord.startTime!=null and alarmRecord.startTime!=''"> |
| | | and record.create_time >= #{alarmRecord.startTime} |
| | | </if> |
| | | <if test="alarmRecord.endTime!=null and alarmRecord.endTime!=''"> |
| | | and record.create_time <= #{alarmRecord.endTime} |
| | | </if> |
| | | <if test="alarmRecord.resGuids != null and alarmRecord.resGuids !=''"> |
| | | AND record.reservoir_number in |
| | | <foreach collection="alarmRecord.resGuids.split(',')" item="item" index="index" open="(" separator="," close=")"> |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | group by type,rule.alarm_level |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | Boolean updateStatus(AlarmRecord alarmRecord); |
| | | |
| | | Object statisticsPie(AlarmRecordVO alarmRecordVO); |
| | | |
| | | /** |
| | | * 告警统计按告警分类-等级统计 |
| | | * @param alarmRecord |
| | | * @return |
| | | */ |
| | | Object statisticAlaByTypeAndLev(AlarmRecordVO alarmRecord); |
| | | } |
| | |
| | | List<StatisticAlarmRecord> list = baseMapper.statisticsPie(alarmRecordVO); |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 告警统计按告警分类-等级统计 |
| | | * @param alarmRecord |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object statisticAlaByTypeAndLev(AlarmRecordVO alarmRecord) { |
| | | Map<String, Object> map = new HashMap<>(4); |
| | | List<StatisticAlarmRecord> recordList = baseMapper.statisticAlaByTypeAndLev(alarmRecord); |
| | | if (recordList.size()>0){ |
| | | map.put("水情监测",setAlaStatisticListByData(recordList,"水情监测")); |
| | | map.put("雨情监测",setAlaStatisticListByData(recordList,"雨情监测")); |
| | | map.put("渗压监测",setAlaStatisticListByData(recordList,"渗压监测")); |
| | | map.put("渗流监测",setAlaStatisticListByData(recordList,"渗流监测")); |
| | | map.put("变形监测",setAlaStatisticListByData(recordList,"变形监测")); |
| | | }else { |
| | | map.put("水情监测",setAlaStatisticList()); |
| | | map.put("雨情监测",setAlaStatisticList()); |
| | | map.put("渗压监测",setAlaStatisticList()); |
| | | map.put("渗流监测",setAlaStatisticList()); |
| | | map.put("变形监测",setAlaStatisticList()); |
| | | } |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 设置组装预警统计数据-带参数 |
| | | * @return |
| | | */ |
| | | private List<StatisticAlarmRecord> setAlaStatisticListByData(List<StatisticAlarmRecord> recordList, String typeName) { |
| | | List<StatisticAlarmRecord> list = new ArrayList<>(); |
| | | List<String> levelList = new ArrayList<>(){{ |
| | | add("蓝色预警"); |
| | | add("黄色预警"); |
| | | add("橙色预警"); |
| | | add("红色预警"); |
| | | }}; |
| | | List<String> alarmLevelList = recordList.stream() |
| | | .filter(a -> a.getRuleName().equals(typeName)) |
| | | .map(StatisticAlarmRecord::getAlarmLevel) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | | // 先取差集 |
| | | List<String> diffList = levelList.stream().filter(item -> !alarmLevelList.contains(item)).collect(Collectors.toList()); |
| | | for (StatisticAlarmRecord alarmRecord : recordList) { |
| | | if (alarmRecord.getRuleName().equals(typeName)){ |
| | | StatisticAlarmRecord statisticAlarmRecord = new StatisticAlarmRecord(); |
| | | statisticAlarmRecord.setAlarmLevel(alarmRecord.getAlarmLevel()); |
| | | statisticAlarmRecord.setNum(alarmRecord.getNum()); |
| | | list.add(statisticAlarmRecord); |
| | | } |
| | | } |
| | | if (diffList.size()>0){ |
| | | for (String level : diffList) { |
| | | StatisticAlarmRecord statisticAlarmRecord = new StatisticAlarmRecord(); |
| | | statisticAlarmRecord.setAlarmLevel(level); |
| | | statisticAlarmRecord.setNum(0); |
| | | list.add(statisticAlarmRecord); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 设置组装预警统计数据 |
| | | * @return |
| | | */ |
| | | private List<StatisticAlarmRecord> setAlaStatisticList() { |
| | | List<StatisticAlarmRecord> list = new ArrayList<>(); |
| | | StatisticAlarmRecord statisticAlarmRecord1 = new StatisticAlarmRecord(); |
| | | statisticAlarmRecord1.setAlarmLevel("蓝色预警"); |
| | | statisticAlarmRecord1.setNum(0); |
| | | |
| | | StatisticAlarmRecord statisticAlarmRecord2 = new StatisticAlarmRecord(); |
| | | statisticAlarmRecord2.setAlarmLevel("黄色预警"); |
| | | statisticAlarmRecord2.setNum(0); |
| | | |
| | | StatisticAlarmRecord statisticAlarmRecord3 = new StatisticAlarmRecord(); |
| | | statisticAlarmRecord3.setAlarmLevel("橙色预警"); |
| | | statisticAlarmRecord3.setNum(0); |
| | | |
| | | StatisticAlarmRecord statisticAlarmRecord4 = new StatisticAlarmRecord(); |
| | | statisticAlarmRecord4.setAlarmLevel("红色预警"); |
| | | statisticAlarmRecord4.setNum(0); |
| | | |
| | | list.add(statisticAlarmRecord1); |
| | | list.add(statisticAlarmRecord2); |
| | | list.add(statisticAlarmRecord3); |
| | | list.add(statisticAlarmRecord4); |
| | | return list; |
| | | } |
| | | } |
| | |
| | | import cn.gistack.alerts.sms.vo.SmsResultVO; |
| | | import cn.gistack.resource.feign.IOssClient; |
| | | import cn.gistack.resource.vo.MyMultipartFile; |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttResBase; |
| | | import cn.gistack.sm.sjztmd.feign.IAttResBaseClient; |
| | | import cn.gistack.sm.sjztmd.feign.ISjztMdClient; |
| | |
| | | |
| | | private final ISmsRecordClient smsRecordClient; |
| | | |
| | | private final CallService callService; |
| | | |
| | | @Override |
| | | @GetMapping(GENERATE_DAY_REPORT_FLOOD) |
| | | public String generateDayReportFlood(String isShow) throws Exception{ |
| | | |
| | | |
| | | |
| | | //获取总览、大中库、明细数据 |
| | |
| | | vo.setResCode("0"); |
| | | List<SmsResultVO> dxyjList = smsRecordClient.smsSuccessList(vo); |
| | | |
| | | //外呼统计 |
| | | CallTaskResultVO callTaskResult = new CallTaskResultVO(); |
| | | callTaskResult.setStartTime(yesterday.format(formatter)); |
| | | callTaskResult.setEndTime(yesterday.format(formatter)); |
| | | List<CallTaskResultVO> whtjList = (List<CallTaskResultVO>) callService.getCallResultListTemp(null, callTaskResult); |
| | | |
| | | HashMap<String,String> over10Params = new HashMap<>(); |
| | | //small_start_stag=0&small_end_stag=2&mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2 |
| | | over10Params.put("small_start_stag", "0.1"); |
| | |
| | | List<TotalInfo> totalOver10List = sjztmdService.getTotalOverInfo(isShow,over10Params); |
| | | byte[] data = null; |
| | | if (MyDateUtils.isTodayInFloodSeason()){ |
| | | data = WordUtil.GetOverInfo(totalList,dzkList,overDetailList,szInfoList,dxyjList); |
| | | data = WordUtil.GetOverInfo(totalList, dzkList, overDetailList, szInfoList, dxyjList, whtjList); |
| | | }else { |
| | | data= WordUtil.GetNotInSeasonOverInfo(totalList,dzkList,overDetailList,szInfoList,totalOverList,totalOver10List); |
| | | |
| | |
| | | |
| | | import cn.gistack.alerts.sms.feign.ISmsRecordClient; |
| | | import cn.gistack.alerts.sms.vo.SmsResultVO; |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.sjztmd.util.MyDateUtils; |
| | | import cn.gistack.sm.sjztmd.word.service.ISjztmdService; |
| | | import cn.gistack.sm.sjztmd.word.util.BriefReportUtil; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.core.io.InputStreamResource; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | |
| | | private final ISjztmdService sjztmdService; |
| | | |
| | | private final ISmsRecordClient smsRecordClient; |
| | | |
| | | private final CallService callService; |
| | | @GetMapping(value = "/getBriefReport") |
| | | public R getBriefReport() { |
| | | //获取总览、大中库、明细数据 |
| | |
| | | //短信预警数量 |
| | | SmsResultVO vo = new SmsResultVO(); |
| | | // 获取当前日期 |
| | | LocalDate today = LocalDate.now(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 获取前一天日期 |
| | | LocalDate yesterday = today.minusDays(1); |
| | | LocalDateTime oneDayBefore = now.minusDays(1); |
| | | // 格式化日期并打印 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | vo.setStartTime(yesterday.format(formatter)); |
| | | vo.setEndTime(yesterday.format(formatter)); |
| | | // 定义日期时间格式,包含年-月-日 时:分:秒 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | vo.setStartTime(oneDayBefore.format(formatter)); |
| | | vo.setEndTime(now.format(formatter)); |
| | | vo.setSmsType("2"); |
| | | vo.setResCode("0"); |
| | | vo.setIsExport(1); |
| | | List<SmsResultVO> dxyjList = smsRecordClient.smsSuccessList(vo); |
| | | |
| | | //外呼统计 |
| | | CallTaskResultVO callTaskResult = new CallTaskResultVO(); |
| | | callTaskResult.setStartTime(oneDayBefore.format(formatter)); |
| | | callTaskResult.setEndTime(now.format(formatter)); |
| | | List<CallTaskResultVO> whtjList = (List<CallTaskResultVO>) callService.getCallResultListTemp(null,callTaskResult); |
| | | |
| | | HashMap<String,String> over10Params = new HashMap<>(); |
| | | //small_start_stag=0&small_end_stag=2&mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2 |
| | |
| | | List<TotalInfo> totalOver10List = sjztmdService.getTotalOverInfo(isShow,over10Params); |
| | | byte[] data = null; |
| | | if (MyDateUtils.isTodayInFloodSeason()){ |
| | | data = WordUtil.GetOverInfo(totalList,dzkList,overDetailList,szInfoList,dxyjList); |
| | | data = WordUtil.GetOverInfo(totalList,dzkList,overDetailList,szInfoList,dxyjList,whtjList); |
| | | }else { |
| | | data= WordUtil.GetNotInSeasonOverInfo(totalList,dzkList,overDetailList,szInfoList,totalOverList,totalOver10List); |
| | | |
| | |
| | | package cn.gistack.sm.sjztmd.word.util; |
| | | |
| | | import cn.gistack.alerts.sms.vo.SmsResultVO; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.sjztmd.util.MyDateUtils; |
| | | import cn.gistack.sm.sjztmd.word.vo.*; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | |
| | | } |
| | | |
| | | |
| | | public static byte[] GetOverInfo(List<TotalInfo> totalList, List<DzkInfo> dzkList, List<OverDetail> overDetailList,List<SzInfo> szInfoList,List<SmsResultVO> dxyjList) throws Exception { |
| | | public static byte[] GetOverInfo(List<TotalInfo> totalList, List<DzkInfo> dzkList, List<OverDetail> overDetailList, List<SzInfo> szInfoList, List<SmsResultVO> dxyjList, List<CallTaskResultVO> whtjList) throws Exception { |
| | | InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/doc/overFloodTemplate.docx"); |
| | | ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
| | | OverWord overWord = new OverWord(totalList, dzkList, overDetailList, szInfoList, dxyjList); |
| | | OverWord overWord = new OverWord(totalList, dzkList, overDetailList, szInfoList, dxyjList, whtjList,null); |
| | | XWPFTemplate template = XWPFTemplate.compile(inputStream).render(createOverWordParam(overWord)); |
| | | template.write(outputStream); |
| | | outputStream.flush(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param totalList 全省水库超汛 |
| | | * @param dzkList 大中库超汛 |
| | | * @param overDetailList 超汛明细 |
| | |
| | | package cn.gistack.sm.sjztmd.word.vo; |
| | | |
| | | import cn.gistack.alerts.sms.vo.SmsResultVO; |
| | | import cn.gistack.sm.intelligentCall.entity.CallTask; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import lombok.Data; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springblade.core.tool.utils.ObjectUtil; |
| | |
| | | |
| | | private String smsResultInfo; |
| | | |
| | | public OverWord(List<TotalInfo> totalList, List<DzkInfo> dzkList, List<OverDetail> overDetailList,List<SzInfo> szInfoList,List<SmsResultVO> resultVOList){ |
| | | public OverWord(List<TotalInfo> totalList, List<DzkInfo> dzkList, List<OverDetail> overDetailList, List<SzInfo> szInfoList, List<SmsResultVO> resultVOList, List<CallTaskResultVO> whtjList,String isNew) { |
| | | this.tm = new SimpleDateFormat("MM月dd日H时").format(new Date()); |
| | | this.hour = new SimpleDateFormat("H时").format(new Date()); |
| | | |
| | | formatTotalInfo(totalList); |
| | | formatDzkInfo(dzkList); |
| | | formatSzInfo(szInfoList); |
| | | formatSmsResultInfo(resultVOList); |
| | | formatSmsResultInfo(resultVOList, whtjList); |
| | | } |
| | | |
| | | private void formatSmsResultInfo(List<SmsResultVO> resultVOList) { |
| | | private void formatSmsResultInfo(List<SmsResultVO> resultVOList, List<CallTaskResultVO> whtjList) { |
| | | // 短信预警处理 |
| | | int dxyjCount = 0; |
| | | for (SmsResultVO vo : resultVOList) { |
| | | int number = null == vo.getNumber()?0:vo.getNumber(); |
| | | dxyjCount = dxyjCount + number; |
| | | } |
| | | |
| | | String str = StringUtil.format("过去24小时内,发送水库短信预警{}条,抽查黄冈、襄阳、随州、荆门水库防汛责任人XX人次,应答率XX,责任人履职情况总体较好。", |
| | | dxyjCount); |
| | | // 外呼统计处理 |
| | | int cityNameIndex = 0; //记录增加行政区划次数 |
| | | String cityNames = ""; //行政区划集合 |
| | | int jtCount = 0; //接通的数量 |
| | | for (CallTaskResultVO callTaskResultVO : whtjList) { |
| | | |
| | | if (StringUtil.isNotBlank(callTaskResultVO.getCityName())) { |
| | | if (StringUtil.isBlank(cityNames)) { |
| | | cityNames = cityNames + callTaskResultVO.getCityName(); |
| | | } else { |
| | | //如果存在不添加 |
| | | if (cityNames.indexOf(callTaskResultVO.getCityName()) < 0 && cityNameIndex <4) { |
| | | cityNames = cityNames + "、" + callTaskResultVO.getCityName(); |
| | | cityNameIndex = cityNameIndex + 1; |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | if (callTaskResultVO.getCallResult().equals("200000")) { |
| | | jtCount = jtCount + 1; |
| | | } |
| | | |
| | | } |
| | | double jtl = Double.valueOf(jtCount) / whtjList.size() * 100; |
| | | String str = StringUtil.format("过去24小时内,发送水库短信预警{}条,抽查{}等水库防汛责任人{}人次,应答率{},责任人履职情况总体较好。", |
| | | dxyjCount,cityNames,whtjList.size(),String.format("%.2f", jtl) + "%"); |
| | | this.smsResultInfo = str; |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * 构建超正常信息 |
| | | * |
| | | * @param totalOverList |
| | | * @param totalOver10List |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 构建省直信息 |
| | | * |
| | | * @param szInfoList |
| | | */ |
| | | private void formatSzInfo(List<SzInfo> szInfoList) { |
| | |
| | | |
| | | /** |
| | | * 构建大中库信息 |
| | | * |
| | | * @param dzkList |
| | | */ |
| | | private void formatDzkInfo(List<DzkInfo> dzkList) { |
| | |
| | | |
| | | /** |
| | | * 构建全省水库超汛限信息 |
| | | * |
| | | * @param totalList |
| | | * @return |
| | | */ |