Merge remote-tracking branch 'origin/jtdev' into jtdev
6 files modified
1 files added
| New file |
| | |
| | | /* |
| | | * Copyright (c) 2018-2028, Chill Zhuang All rights reserved. |
| | | * |
| | | * Redistribution and use in source and binary forms, with or without |
| | | * modification, are permitted provided that the following conditions are met: |
| | | * |
| | | * Redistributions of source code must retain the above copyright notice, |
| | | * this list of conditions and the following disclaimer. |
| | | * Redistributions in binary form must reproduce the above copyright |
| | | * notice, this list of conditions and the following disclaimer in the |
| | | * documentation and/or other materials provided with the distribution. |
| | | * Neither the name of the dreamlu.net developer nor the names of its |
| | | * contributors may be used to endorse or promote products derived from |
| | | * this software without specific prior written permission. |
| | | * Author: Chill 庄骞 (smallchill@163.com) |
| | | */ |
| | | package cn.gistack.alerts.notice.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | import org.springblade.core.tool.utils.StringPool; |
| | | |
| | | /** |
| | | * 水库/病险水库枚举 |
| | | * @author zhongrj |
| | | * @date 2023-07-26 |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum DangerEnum { |
| | | |
| | | /** |
| | | * 距离 |
| | | */ |
| | | DISTANCE("validate", "距离"), |
| | | |
| | | /** |
| | | * 超过 |
| | | */ |
| | | OVER("over", "超过"), |
| | | |
| | | /** |
| | | * 已超过 |
| | | */ |
| | | ALREADY_OVER("validate", "已超过"), |
| | | |
| | | /** |
| | | * 已大幅度超过 |
| | | */ |
| | | ALREADY_BIG_OVER("over", "已大幅度超过"), |
| | | ; |
| | | |
| | | final String name; |
| | | final String value; |
| | | |
| | | } |
| | |
| | | }}; |
| | | |
| | | /** |
| | | * 水位接近汛限告警 |
| | | */ |
| | | public static List<String> waterComeOverList = new ArrayList<String>() |
| | | {{ |
| | | add("town_nm"); |
| | | add("res_nm"); |
| | | add("rz"); |
| | | add("over_1h"); |
| | | add("over_z"); |
| | | add("drp_24"); |
| | | }}; |
| | | |
| | | /** |
| | | * 水位初次超汛限告警(水库技术责任人、巡查责任人) |
| | | */ |
| | | public static List<String> waterFirstOverList = new ArrayList<String>() |
| | |
| | | }}; |
| | | |
| | | /** |
| | | * 水位初次超汛限告警(水库技术责任人、巡查责任人) |
| | | * 水位超设计洪水位告警处理 |
| | | */ |
| | | public static List<String> waterMoreDesignList = new ArrayList<String>() |
| | | {{ |
| | |
| | | public static final String res_diff_dead_z_api = "/services/1234567890ABCDEFGHIJKLMN/res/diff_dead_z"; |
| | | |
| | | /** |
| | | * 水位接近汛限告警 |
| | | */ |
| | | public static final String res_z_is_warn_over_flse_api = "/services/1234567890ABCDEFGHIJKLMN/res_z_is_warn/over_flse"; |
| | | |
| | | /** |
| | | * 水位初次超汛限告警 |
| | | */ |
| | | public static final String over_z_res_api = "/services/1234567890ABCDEFGHIJKLMN/over_z_res"; |
| | | |
| | | /** |
| | | * 水位小幅超汛限告警 |
| | | */ |
| | | public static final String res_over_z_small_over_api = "/services/1234567890ABCDEFGHIJKLMN/res_over_z/small_over"; |
| | | |
| | | /** |
| | | * 水位大幅超汛限告警 |
| | | */ |
| | | public static final String res_over_z_big_over_api = "/services/1234567890ABCDEFGHIJKLMN/res_over_z/big_over"; |
| | | |
| | | /** |
| | | * 水位超设计洪水位告警处理 |
| | | */ |
| | | public static final String over_des_rz_warn_api = "/services/1234567890ABCDEFGHIJKLMN/over_des_rz/warn"; |
| | |
| | | import cn.gistack.alerts.alarmRule.entity.AlarmRule; |
| | | import cn.gistack.alerts.notice.constant.ZtApiDataColumnConstant; |
| | | import cn.gistack.alerts.notice.constant.ZtApiUrlConstant; |
| | | import cn.gistack.alerts.notice.enums.DangerEnum; |
| | | import cn.gistack.alerts.sms.service.SmsService; |
| | | import cn.gistack.alerts.sms.vo.SmsRequestTemplate; |
| | | import com.alibaba.fastjson.JSONArray; |
| | |
| | | // 调用中台服务接口查询数据 |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.no_z_last_api_all); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterInfoNotList,false,adCode,uuid); |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterInfoNotList,false,adCode,uuid,null); |
| | | smsRequestTemplate.setIsSendStation(isSendStation); |
| | | // 遍历 |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | | // 保存告警记录信息 |
| | |
| | | // 调用中台服务接口查询数据 |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.res_z_not_normal_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterDataExcList,false,adCode,uuid); |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterDataExcList,false,adCode,uuid,null); |
| | | smsRequestTemplate.setIsSendStation(isSendStation); |
| | | // 遍历 |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | | // 保存告警记录信息 |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | // 调用中台服务接口查询数据 |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.res_diff_dead_z_api); |
| | | // 只发送站内信 |
| | | SmsRequestTemplate smsRequestTemplate = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterLessDeadList,true,adCode,uuid); |
| | | // 获取需要发送的信息 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterLessDeadList,true,adCode,uuid,null); |
| | | smsRequestTemplate.setIsSendStation(isSendStation); |
| | | // 拼接内容后面的联系方式,当前模板县水利部人员姓名电话 |
| | | if (smsRequestTemplate.getPersonVOList().size()>0) { |
| | | // 遍历,拼接县水利部人员电话 |
| | |
| | | * @param adCode |
| | | */ |
| | | @Async |
| | | public void waterComeOverHandle(String templateId, String uuid, AlarmRule alarmRule, String adCode) { |
| | | public void waterComeOverHandle(String templateId, String uuid, AlarmRule alarmRule, String adCode,Boolean isSendStation) { |
| | | // 调用中台服务接口查询数据 |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.res_diff_dead_z_api); |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.res_z_is_warn_over_flse_api); |
| | | // 只发送站内信 |
| | | SmsRequestTemplate smsRequestTemplate = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterLessDeadList,true,null,uuid); |
| | | SmsRequestTemplate smsRequestTemplate = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterComeOverList,true,adCode,uuid, DangerEnum.DISTANCE.getValue()); |
| | | smsRequestTemplate.setIsSendStation(isSendStation); |
| | | // 拼接内容后面的联系方式,当前模板县水利部人员姓名电话 |
| | | if (smsRequestTemplate.getPersonVOList().size()>0) { |
| | | // 遍历,拼接县水利部人员电话 |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | | // 后面依次拼接 巡查责任人姓名,技术责任人姓名,市县水利部门人员姓名电话(暂时不要) |
| | | // 后面依次拼接 巡查责任人姓名,技术责任人姓名, |
| | | noticeHandle.addPatrolTechnologyInfo(list); |
| | | // 市县水利部门人员姓名电话(暂时不要) |
| | | // list.add("测试:13112341234"); |
| | | // 拼接市县水利部人员姓名及联系方式 |
| | | noticeHandle.addCityCountyBusinessPersonInfo(list); |
| | | // 保存告警记录信息 |
| | | // AlarmRecord alarmRecord = noticeHandle.saveAlarmRecord(list,alarmRule,uuid); |
| | | // if (null != alarmRecord) { |
| | | // list.add(alarmRecord.getId().toString()); |
| | | list.add("999"); |
| | | // } |
| | | AlarmRecord alarmRecord = noticeHandle.saveAlarmRecord(list,alarmRule,uuid); |
| | | if (null != alarmRecord) { |
| | | list.add(alarmRecord.getId().toString()); |
| | | } |
| | | } |
| | | } |
| | | // 保存站内信记录信息 |
| | |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.over_z_res_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterFirstOverList,true,adCode,uuid); |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId,alarmRule, ZtApiDataColumnConstant.waterFirstOverList,true,adCode,uuid,DangerEnum.OVER.getValue()); |
| | | smsRequestTemplate.setIsSendStation(isSendStation); |
| | | |
| | | // 拼接后面内容 |
| | |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.over_des_rz_warn_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.waterMoreDesignList, true, null,uuid); |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.waterMoreDesignList, true, null,uuid,null); |
| | | // 拼接后面内容 |
| | | if (smsRequestTemplate.getPersonVOList().size() > 0) { |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.alarm_rain_dy_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.alreadyHeavyRainList, false, adCode,uuid); |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.alreadyHeavyRainList, false, adCode,uuid,null); |
| | | // 拼接后面内容 |
| | | if (smsRequestTemplate.getPersonVOList().size() > 0) { |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.alarm_rain_by_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.alreadyRainstormList, false, adCode,uuid); |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.alreadyRainstormList, false, adCode,uuid,null); |
| | | // 拼接后面内容 |
| | | if (smsRequestTemplate.getPersonVOList().size() > 0) { |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | |
| | | JSONArray ztData = noticeHandle.getZtData("", ZtApiUrlConstant.alarm_rain_6_over_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.sixHourRainList, false, adCode,uuid); |
| | | = noticeHandle.getSendSmsTemplate(ztData, templateId, alarmRule, ZtApiDataColumnConstant.sixHourRainList, false, adCode,uuid,null); |
| | | // 拼接后面内容 |
| | | if (smsRequestTemplate.getPersonVOList().size() > 0) { |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | |
| | | List<String> columnsList, |
| | | Boolean flag, |
| | | String adCode, |
| | | String uuid) { |
| | | String uuid, |
| | | String dangerValue) { |
| | | // 通过模板id 查询模板相关信息 |
| | | SmsTemplate smsTemplate = smsTemplateService.getOne(new QueryWrapper<SmsTemplate>().eq("template_id",templateId).eq("is_deleted",0)); |
| | | if (null != smsTemplate) { |
| | |
| | | // 解析模板并设置 title |
| | | smsRequestTemplate.setTitle(FormatUtil.composeMessage(smsTemplate.getContent())); |
| | | // 列名数据转换 |
| | | getColumnData(jsonArray, columnsList,smsRequestTemplate,alarmRule,flag,adCode,uuid); |
| | | getColumnData(jsonArray, columnsList,smsRequestTemplate,alarmRule,flag,adCode,uuid,dangerValue); |
| | | //返回 |
| | | return smsRequestTemplate; |
| | | } |
| | |
| | | AlarmRule alarmRule, |
| | | Boolean flag, |
| | | String adCode, |
| | | String uuid) { |
| | | String uuid, |
| | | String dangerValue) { |
| | | List<PersonVO> personLists = new ArrayList<>(); |
| | | List<List<String>> lists = new ArrayList<>(); |
| | | Set<String> set = new HashSet<>(); |
| | |
| | | // city_cd,county_cd 过滤数据 |
| | | String county_cd = jsonArray.getJSONObject(i).getString("county_cd"); |
| | | if (null!= county_cd && county_cd.equals(adCode)) { |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i,uuid,set); |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i,uuid,set,dangerValue); |
| | | } |
| | | }else { |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i,uuid,set); |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i,uuid,set,dangerValue); |
| | | } |
| | | } |
| | | // 设置信息 |
| | |
| | | List<List<String>> lists, |
| | | int i, |
| | | String uuid, |
| | | Set<String> set) { |
| | | Set<String> set, |
| | | String dangerValue) { |
| | | // 根据水库编号,所在区域查询需要发送的人员手机号及设置 |
| | | String res_cd = jsonArray.getJSONObject(i).getString("res_cd"); |
| | | String tempStr = uuid + res_cd; |
| | |
| | | flag = false; |
| | | } |
| | | // 获取告警人员信息 |
| | | getAlarmPersonList(jsonArray, columnsList, alarmRule, flag, personLists, lists, i, res_cd, day, hour, minute, stcd); |
| | | getAlarmPersonList(jsonArray, columnsList, alarmRule, flag, personLists, lists, i, res_cd, day, hour, minute, stcd,dangerValue); |
| | | } |
| | | } |
| | | |
| | |
| | | String day, |
| | | String hour, |
| | | String minute, |
| | | String stcd) { |
| | | String stcd, |
| | | String dangerValue) { |
| | | // 查询告警人员信息 |
| | | List<PersonVO> personVOList = getPersonListByResGuid(res_cd, alarmRule); |
| | | if (personVOList.size() > 0) { |
| | |
| | | if (s.equals("over_z")) { |
| | | String is_danger_res = "is_danger_res"; |
| | | if (jsonArray.getJSONObject(i).getString(is_danger_res).equals("true")) { |
| | | format = format + "超过控制运用水位" + jsonArray.getJSONObject(i).getString(s); |
| | | format = format + dangerValue + "控制运用水位" + jsonArray.getJSONObject(i).getString(s); |
| | | } else if (jsonArray.getJSONObject(i).getString(is_danger_res).equals("false")) { |
| | | format = format + "超过汛限水位" + jsonArray.getJSONObject(i).getString(s); |
| | | format = format + dangerValue + "汛限水位" + jsonArray.getJSONObject(i).getString(s); |
| | | } else { |
| | | format = format + jsonArray.getJSONObject(i).getString(s); |
| | | } |
| | |
| | | } |
| | | // 保存告警记录详情信息 |
| | | if (smsRequestTemplate.getIsSendStation()) { |
| | | saveMessageRecord(messageRecordList); |
| | | // saveMessageRecord(messageRecordList); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | // 返回 |
| | |
| | | R<List<User>> listR = userClient.userInfoByPhone("000000", messageRecord.getRecipient()); |
| | | messageRecord.setRecipient(listR.getData().get(0).getId().toString()); |
| | | } |
| | | |
| | | // List<MessageRecord> messageRecordList1 = new ArrayList<>(); |
| | | // addSendMsgTest(messageRecordList1); |
| | | //给app推送消息 |
| | | // pushService.pushMessageList(messageRecordList1); |
| | | pushService.pushMessageList(messageRecordList); |
| | | |
| | | // 保存记录 |
| | |
| | | SSEServer.sendMessage("web:"+messageRecord.getRecipient(),new JSONObject(map).toJSONString()); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增测试信息 |
| | | * @param messageRecordList |
| | | */ |
| | | private void addSendMsgTest(List<MessageRecord> messageRecordList) { |
| | | MessageRecord messageRecord = new MessageRecord(); |
| | | messageRecord.setRecipient("1654164141753593858"); |
| | | messageRecord.setContent("cs12121212=========="); |
| | | messageRecord.setTheme("接近超汛告警"); |
| | | messageRecord.setSender(AuthUtil.getUserId().toString()); |
| | | messageRecord.setSource("智能告警"); |
| | | messageRecord.setStatus(0); |
| | | // 加入集合 |
| | | messageRecordList.add(messageRecord); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 策略5: 水位接近汛限告警 |
| | | * 策略5: 水位接近汛限告警(站内信) |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | |
| | | // 查询当前策略对应的告警规则信息 |
| | | AlarmRule alarmRule = alarmRuleService.getOne(new QueryWrapper<AlarmRule>().eq("rule_name", arg1)); |
| | | if (null!=alarmRule) { |
| | | asyncNoticeHandle.waterComeOverHandle(templateId,uuid,alarmRule, null); |
| | | asyncNoticeHandle.waterComeOverHandle(templateId,uuid,alarmRule, adCode,true); |
| | | } |
| | | return "水位接近汛限告警"; |
| | | } |
| | |
| | | <if test="attResFlseLim.tbFlseLimStag !=null and attResFlseLim.tbFlseLimStag != ''"> |
| | | "tb_flse_lim_stag" = #{attResFlseLim.tbFlseLimStag}, |
| | | </if> |
| | | <if test="attResFlseLim.tbFloodSeasonStart !=null and attResFlseLim.tbFloodSeasonStart != ''"> |
| | | <if test="attResFlseLim.tbFlseLimStag == null or attResFlseLim.tbFlseLimStag == ''"> |
| | | "tb_flse_lim_stag" = '', |
| | | </if> |
| | | <if test="attResFlseLim.tbFloodSeasonStart != null and attResFlseLim.tbFloodSeasonStart != ''"> |
| | | "tb_flood_season_start" = #{attResFlseLim.tbFloodSeasonStart}, |
| | | </if> |
| | | <if test="attResFlseLim.tbFloodSeasonStart == null or attResFlseLim.tbFloodSeasonStart == ''"> |
| | | "tb_flood_season_start" = '', |
| | | </if> |
| | | <if test="attResFlseLim.tbFloodSeasonEnd !=null and attResFlseLim.tbFloodSeasonEnd != ''"> |
| | | "tb_flood_season_end" = #{attResFlseLim.tbFloodSeasonEnd}, |
| | | </if> |
| | | <if test="attResFlseLim.tbFloodSeasonEnd == null or attResFlseLim.tbFloodSeasonEnd == ''"> |
| | | "tb_flood_season_end" = '', |
| | | </if> |
| | | "update_by" = concat("update_by",',',#{attResFlseLim.updateBy}), |
| | | "update_time" = #{attResFlseLim.updateTime} |
| | | WHERE "res_guid" = #{attResFlseLim.resGuid} and "flood_season_name" = #{type} |