| | |
| | | * @param columnsList 列名集合信息 |
| | | * @param flag 是否包含日期 |
| | | * @param adCode 行政区编号 |
| | | * @param uuid 本次执行临时编号 |
| | | * @return |
| | | */ |
| | | public SmsRequestTemplate getSendSmsTemplate(JSONArray jsonArray, |
| | |
| | | AlarmRule alarmRule, |
| | | List<String> columnsList, |
| | | Boolean flag, |
| | | String adCode) { |
| | | String adCode, |
| | | String uuid) { |
| | | // 通过模板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); |
| | | getColumnData(jsonArray, columnsList,smsRequestTemplate,alarmRule,flag,adCode,uuid); |
| | | //返回 |
| | | return smsRequestTemplate; |
| | | } |
| | |
| | | * @param smsRequestTemplate |
| | | * @param flag |
| | | * @param adCode |
| | | * @param uuid |
| | | * @return |
| | | */ |
| | | private void getColumnData(JSONArray jsonArray, |
| | |
| | | SmsRequestTemplate smsRequestTemplate, |
| | | AlarmRule alarmRule, |
| | | Boolean flag, |
| | | String adCode) { |
| | | String adCode, |
| | | String uuid) { |
| | | List<PersonVO> personLists = new ArrayList<>(); |
| | | List<List<String>> lists = new ArrayList<>(); |
| | | Set<String> set = new HashSet<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | if (null!=adCode){ |
| | | // 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); |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i,uuid,set); |
| | | } |
| | | }else { |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i); |
| | | jointData(jsonArray, columnsList, alarmRule, flag, personLists, lists, i,uuid,set); |
| | | } |
| | | } |
| | | // 设置信息 |
| | | smsRequestTemplate.setPersonVOList(personLists); |
| | | smsRequestTemplate.setTemplateContent(lists); |
| | | } |
| | | |
| | | /** |
| | | * 列名数据转换-- 需合并水库名称 |
| | | * @param jsonArray |
| | | * @param columnsList |
| | | * @param smsRequestTemplate |
| | | * @param flag |
| | | * @param adCode |
| | | * @return |
| | | */ |
| | | private void getMergeColumnData(JSONArray jsonArray, |
| | | List<String> columnsList, |
| | | SmsRequestTemplate smsRequestTemplate, |
| | | AlarmRule alarmRule, |
| | | Boolean flag, |
| | | String adCode) { |
| | | Set<String> resCdSet = new HashSet<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | String res_cd = jsonArray.getJSONObject(i).getString("res_cd"); |
| | | resCdSet.add(res_cd); |
| | | } |
| | | // 查询对应的人员 |
| | | getPersonListByResList(resCdSet,alarmRule); |
| | | // 设置信息 |
| | | // smsRequestTemplate.setPersonVOList(personLists); |
| | | // smsRequestTemplate.setTemplateContent(lists); |
| | | } |
| | | |
| | | /** |
| | | * 查询对应的用户及水库信息 |
| | | * @param resCdSet |
| | | * @param alarmRule |
| | | */ |
| | | private void getPersonListByResList(Set<String> resCdSet, AlarmRule alarmRule) { |
| | | // 查询对应的用户及水库信息 |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param i |
| | | * @return |
| | | */ |
| | | private void jointData(JSONArray jsonArray, List<String> columnsList, AlarmRule alarmRule, Boolean flag, List<PersonVO> personLists, List<List<String>> lists, int i) { |
| | | private void jointData(JSONArray jsonArray, |
| | | List<String> columnsList, |
| | | AlarmRule alarmRule, |
| | | Boolean flag, |
| | | List<PersonVO> personLists, |
| | | List<List<String>> lists, |
| | | int i, |
| | | String uuid, |
| | | Set<String> set) { |
| | | // 根据水库编号,所在区域查询需要发送的人员手机号及设置 |
| | | String res_cd = jsonArray.getJSONObject(i).getString("res_cd"); |
| | | // 取出测站编码 |
| | | String stcd = jsonArray.getJSONObject(i).getString("stcd"); |
| | | // 判断时间是否存在 |
| | | String tm = jsonArray.getJSONObject(i).getString("tm"); |
| | | String day = ""; |
| | | String hour = ""; |
| | | String minute = ""; |
| | | if (null != tm && !tm.equals("") && flag) { |
| | | flag = true; |
| | | // 加入天,时,分 |
| | | day = tm.substring(8, 10); |
| | | hour =tm.substring(11, 13); |
| | | minute = tm.substring(14, 16); |
| | | } else { |
| | | flag = false; |
| | | String tempStr = uuid + res_cd; |
| | | // 去重水库操作,如果有重复的水库则不操作 |
| | | if (!set.contains(tempStr)) { |
| | | set.add(tempStr); |
| | | // 取出测站编码 |
| | | String stcd = jsonArray.getJSONObject(i).getString("stcd"); |
| | | // 判断时间是否存在 |
| | | String tm = jsonArray.getJSONObject(i).getString("tm"); |
| | | String day = ""; |
| | | String hour = ""; |
| | | String minute = ""; |
| | | if (null != tm && !tm.equals("") && flag) { |
| | | flag = true; |
| | | // 加入天,时,分 |
| | | day = tm.substring(8, 10); |
| | | hour = tm.substring(11, 13); |
| | | minute = tm.substring(14, 16); |
| | | } else { |
| | | 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); |
| | | } |
| | | |
| | | /** |