Merge remote-tracking branch 'origin/jtdev' into jtdev
12 files modified
24 files added
| New file |
| | |
| | | package cn.gistack.sm.alarmRule.controller; |
| | | |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecordDetail; |
| | | import cn.gistack.sm.alarmRule.service.AlarmRecordDetailService; |
| | | import cn.gistack.sm.alarmRule.vo.AlarmRecordDetailVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * 告警记录详情控制层 |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/alarmRecordDetail/alarmRecordDetail") |
| | | public class AlarmRecordDetailController{ |
| | | |
| | | private final AlarmRecordDetailService alarmRecordDetailService; |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | | * |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-分页列表查询", notes="告警记录详情-分页列表查询") |
| | | @GetMapping(value = "/list") |
| | | public R queryPageList(AlarmRecordDetail alarmRecordDetail, Query query) { |
| | | IPage<AlarmRecordDetail> pageList = alarmRecordDetailService.page(Condition.getPage(query), Condition.getQueryWrapper(alarmRecordDetail)); |
| | | return R.data(pageList); |
| | | } |
| | | |
| | | /** |
| | | * 自定义分页列表查询 |
| | | * @param query |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-自定义分页列表查询", notes="告警记录详情-自定义分页列表查询") |
| | | @GetMapping(value = "/page") |
| | | public R page(AlarmRecordDetailVO alarmRecordDetail, Query query) { |
| | | return R.data( alarmRecordDetailService.selectAlarmRecordDetailPage(Condition.getPage(query),alarmRecordDetail)); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-添加", notes="告警记录详情-添加") |
| | | @PostMapping(value = "/add") |
| | | public R add(@RequestBody AlarmRecordDetail alarmRecordDetail) { |
| | | return R.data(alarmRecordDetailService.save(alarmRecordDetail)); |
| | | } |
| | | |
| | | /** |
| | | * 编辑 |
| | | * |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-编辑", notes="告警记录详情-编辑") |
| | | @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
| | | public R edit(@RequestBody AlarmRecordDetail alarmRecordDetail) { |
| | | return R.data(alarmRecordDetailService.updateById(alarmRecordDetail)); |
| | | } |
| | | |
| | | /** |
| | | * 通过id删除 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-通过id删除", notes="告警记录详情-通过id删除") |
| | | @DeleteMapping(value = "/delete") |
| | | public R delete(@RequestParam(name="id",required=true) String id) { |
| | | return R.data(alarmRecordDetailService.removeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-批量删除", notes="告警记录详情-批量删除") |
| | | @DeleteMapping(value = "/deleteBatch") |
| | | public R deleteBatch(@RequestParam(name="ids",required=true) String ids) { |
| | | return R.data(this.alarmRecordDetailService.removeByIds(Arrays.asList(ids.split(",")))); |
| | | } |
| | | |
| | | /** |
| | | * 通过id查询 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ApiOperation(value="告警记录详情-通过id查询", notes="告警记录详情-通过id查询") |
| | | @GetMapping(value = "/queryById") |
| | | public R queryById(@RequestParam(name="id",required=true) String id) { |
| | | AlarmRecordDetail alarmRecordDetail = alarmRecordDetailService.getById(id); |
| | | return R.data(alarmRecordDetail); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.alarmRule.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| | | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * 告警记录详情 |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | @Data |
| | | @TableName("sm_alarm_record_detail") |
| | | public class AlarmRecordDetail implements Serializable { |
| | | |
| | | /** |
| | | * 主键id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | @TableId(value = "id",type = IdType.ASSIGN_ID) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 告警记录id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long alarmRecordId; |
| | | |
| | | /** |
| | | * 发送记录id |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long sendRecordId; |
| | | |
| | | /** |
| | | * 告警模式 短信,电话,站内信 |
| | | */ |
| | | private String alarmMode; |
| | | |
| | | /** |
| | | * 水库编号 |
| | | */ |
| | | private String reservoirNumber; |
| | | |
| | | /** |
| | | * 告警内容 |
| | | */ |
| | | private String alarmContent; |
| | | |
| | | /** |
| | | * 创建人 |
| | | */ |
| | | @JsonSerialize(using = ToStringSerializer.class) |
| | | private Long createUser; |
| | | |
| | | /** |
| | | * 创建时间 |
| | | */ |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.alarmRule.mapper; |
| | | |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecordDetail; |
| | | import cn.gistack.sm.alarmRule.vo.AlarmRecordDetailVO; |
| | | import cn.gistack.sm.alarmRule.vo.AlarmRecordVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 告警记录详情mapper映射层 |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | public interface AlarmRecordDetailMapper extends BaseMapper<AlarmRecordDetail> { |
| | | |
| | | /** |
| | | * 自定义分页列表查询 |
| | | * @param page |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | List<AlarmRecordDetailVO> selectAlarmRecordDetailPage(IPage<AlarmRecordDetailVO> page,@Param("alarmRecordDetail") AlarmRecordDetailVO alarmRecordDetail); |
| | | } |
| New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="cn.gistack.sm.alarmRule.mapper.AlarmRecordDetailMapper"> |
| | | |
| | | <!--自定义分页列表查询--> |
| | | <select id="selectAlarmRecordDetailPage" resultType="cn.gistack.sm.alarmRule.vo.AlarmRecordDetailVO"> |
| | | select * from sm_alarm_record_detail |
| | | where 1=1 |
| | | </select> |
| | | |
| | | </mapper> |
| New file |
| | |
| | | package cn.gistack.sm.alarmRule.service; |
| | | |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecordDetail; |
| | | import cn.gistack.sm.alarmRule.vo.AlarmRecordDetailVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * 告警记录详情服务层 |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | public interface AlarmRecordDetailService extends IService<AlarmRecordDetail> { |
| | | |
| | | /** |
| | | * 自定义分页列表查询 |
| | | * @param page |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | Object selectAlarmRecordDetailPage(IPage<AlarmRecordDetailVO> page, AlarmRecordDetailVO alarmRecordDetail); |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.alarmRule.service.impl; |
| | | |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecordDetail; |
| | | import cn.gistack.sm.alarmRule.mapper.AlarmRecordDetailMapper; |
| | | import cn.gistack.sm.alarmRule.service.AlarmRecordDetailService; |
| | | import cn.gistack.sm.alarmRule.vo.AlarmRecordDetailVO; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springblade.core.mp.base.BaseServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 告警记录详情服务实现层 |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | @Service |
| | | public class AlarmRecordDetailServiceImpl extends ServiceImpl<AlarmRecordDetailMapper, AlarmRecordDetail> implements AlarmRecordDetailService { |
| | | |
| | | /** |
| | | * 自定义分页列表查询 |
| | | * @param page |
| | | * @param alarmRecordDetail |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object selectAlarmRecordDetailPage(IPage<AlarmRecordDetailVO> page, AlarmRecordDetailVO alarmRecordDetail) { |
| | | if (null != alarmRecordDetail.getIsExport()){ |
| | | return baseMapper.selectAlarmRecordDetailPage(null,alarmRecordDetail); |
| | | } |
| | | return page.setRecords(baseMapper.selectAlarmRecordDetailPage(page,alarmRecordDetail)); |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.alarmRule.vo; |
| | | |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecordDetail; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 告警记录详情vo |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | @Data |
| | | public class AlarmRecordDetailVO extends AlarmRecordDetail { |
| | | |
| | | private Integer isExport; |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.constant; |
| | | |
| | | /** |
| | | * 平台服务信息常量 |
| | | * @author zhongrj |
| | | * @since 2023-04-21 |
| | | */ |
| | | public class PtInfoConstant { |
| | | |
| | | /** |
| | | * 平台服务电话 |
| | | */ |
| | | public static final String serverPhone = "01234567890"; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.constant; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 中台接口响应列常量 |
| | | * @author zhongrj |
| | | * @since 2023-04-21 |
| | | */ |
| | | public class ZtApiDataColumnConstant { |
| | | |
| | | |
| | | /** |
| | | * 水位数据缺失字段(不包含责任人相关信息) |
| | | */ |
| | | public static List<String> waterInfoNotList = new ArrayList<String>() |
| | | {{ |
| | | add("county_nm,town_nm"); |
| | | add("res_nm"); |
| | | }}; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.constant; |
| | | |
| | | /** |
| | | * 中台接口请求信息常量 |
| | | * @author zhongrj |
| | | * @since 2023-04-21 |
| | | */ |
| | | public class ZtApiUrlConstant { |
| | | |
| | | |
| | | /** |
| | | * 水位数据缺失 |
| | | */ |
| | | public static final String res_z_null_api = "http://10.42.6.192/services/1234567890ABCDEFGHIJKLMN/res/z_null"; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.constant; |
| | | |
| | | /** |
| | | * 中台接口请求信息常量 |
| | | * @author zhongrj |
| | | * @since 2023-04-21 |
| | | */ |
| | | public class ZtConfigConstant { |
| | | |
| | | /** |
| | | * 请求头 key |
| | | */ |
| | | public static final String header_key = "apiKey"; |
| | | |
| | | /** |
| | | * 请求头 value |
| | | */ |
| | | public static final String header_value = "F1DBECD719108635189480CF60E6553ADB3109616426BD537F25A430DFC613B491A025C4A51E77FD08C6E5B7CBE05917A461286E7B6D69F1AB1B14F946149D2065B0C675F8FEDF4B9B05C1496881BC5A"; |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.controller; |
| | | |
| | | import cn.gistack.sm.notice.strategy.NoticeStrategyContext; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * 通知信息控制层 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/notice/notice") |
| | | public class NoticeController { |
| | | |
| | | private final NoticeStrategyContext applicationContext; |
| | | |
| | | // /** |
| | | // * 调用任务通知 |
| | | // * @param type 策略分类 |
| | | // * @param name 任务名称 |
| | | // * @param content 内容(可以不传) |
| | | // * @return |
| | | // */ |
| | | // @GetMapping("/toNotice") |
| | | // public Object toNotice(String type,String name,String content){ |
| | | // return applicationContext.doSomethingByStrategy(name, content, type); |
| | | // } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.controller; |
| | | |
| | | import cn.gistack.sm.notice.entity.Notice; |
| | | import cn.gistack.sm.notice.strategy.NoticeTypeStrategyContext; |
| | | import cn.gistack.sm.notice.strategy.service.INoticeService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * 通知信息控制层 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | @RestController |
| | | @AllArgsConstructor |
| | | @RequestMapping("/noticeType/noticeType") |
| | | public class NoticeTypeController { |
| | | |
| | | private final NoticeTypeStrategyContext applicationContext; |
| | | |
| | | @GetMapping("/toNotice") |
| | | public Object toNotice(Notice notice){ |
| | | INoticeService noticeService = applicationContext.getResource(notice); |
| | | return noticeService.toNotice(notice); |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * 通知类 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | @Data |
| | | public class Notice implements Serializable { |
| | | |
| | | /** |
| | | * 通知类型 |
| | | */ |
| | | private String type; |
| | | |
| | | /** |
| | | * 通知内容 |
| | | */ |
| | | private String content; |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.enums; |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.Getter; |
| | | |
| | | /** |
| | | * 责任人枚举类 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum PersonEnum { |
| | | |
| | | /** |
| | | * 行政责任人 |
| | | */ |
| | | AREA_TYPE("行政责任人",1), |
| | | /** |
| | | * 主管部门责任人 |
| | | */ |
| | | SUPERVISOR_TYPE("主管部门责任人",2), |
| | | /** |
| | | * 管理单位责任人 |
| | | */ |
| | | MANAGE_TYPE("管理单位责任人",3), |
| | | /** |
| | | * 技术责任人 |
| | | */ |
| | | TECHNOLOGY_TYPE("技术责任人",4), |
| | | |
| | | /** |
| | | * 巡查责任人 |
| | | */ |
| | | PERSON_TYPE("巡查责任人",5), |
| | | ; |
| | | |
| | | final String name; |
| | | |
| | | final Integer type; |
| | | |
| | | /** |
| | | * findByType |
| | | * @param name |
| | | * @return |
| | | */ |
| | | public static PersonEnum findByName(String name) { |
| | | //循环遍历对应的 PersonEnum |
| | | for (PersonEnum item : values()) { |
| | | if(item.getName().equals(name)) { |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy; |
| | | |
| | | import cn.gistack.sm.notice.strategy.service.impl.NoticeStrategyImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import javax.annotation.PostConstruct; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.function.BiFunction; |
| | | |
| | | /** |
| | | * 通知方式策略 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | * |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class NoticeStrategyContext { |
| | | |
| | | /** |
| | | * 存放所有策略. |
| | | */ |
| | | private Map<String, BiFunction<String, String, String>> strategyMap = new HashMap<>(18); |
| | | |
| | | /** |
| | | * 具体的策略细节. |
| | | */ |
| | | @Autowired |
| | | private NoticeStrategyImpl noticeStrategyImpl; |
| | | |
| | | /** |
| | | * 加载所有策略 |
| | | */ |
| | | @PostConstruct |
| | | public void initStrategies() { |
| | | strategyMap.put("waterInfoNotHandle", (arg1, arg2) -> noticeStrategyImpl.waterInfoNotHandle(arg1, arg2)); |
| | | strategyMap.put("waterDataExcHandle", (arg1, arg2) -> noticeStrategyImpl.waterDataExcHandle(arg1, arg2)); |
| | | } |
| | | |
| | | /** |
| | | * 指派具体的策略去执行. |
| | | * |
| | | * @param arg1 参数1 |
| | | * @param arg2 参数2 |
| | | * @param key 根据key 来获取不同的策略 |
| | | * @return |
| | | */ |
| | | public String doSomethingByStrategy(String arg1, String arg2, String key) { |
| | | BiFunction<String, String, String> biFunction = strategyMap.get(key); |
| | | if (Objects.isNull(biFunction)) { |
| | | // 没有找到特定的策略,则采用默认实现(一般只有加了新的类型,但是没有配置对应的处理策略才会走到这里) |
| | | log.warn("========= 没有配置该处理策略,采用默认实现,key {} ====== " + key); |
| | | return noticeStrategyImpl.doSomethingDefault(arg1, arg2); |
| | | } |
| | | return biFunction.apply(arg1, arg2); |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy; |
| | | |
| | | import cn.gistack.sm.notice.entity.Notice; |
| | | import cn.gistack.sm.notice.strategy.service.INoticeService; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * 通知策略 |
| | | * @author zhongrj |
| | | * @date 2023-05-30 |
| | | * @Description : 利用Spring的发现机制,将实现了NoticeStrategyService的类都put到noticeStrategyMap里面。 |
| | | * 后面只需要根据type对应好 各个实现类的注解 如: @Component("tel") 就可以取出不同的业务实现类 |
| | | */ |
| | | @Service |
| | | public class NoticeTypeStrategyContext { |
| | | |
| | | private final Map<String, INoticeService> noticeStrategyMap = new ConcurrentHashMap<>(); |
| | | |
| | | public NoticeTypeStrategyContext(Map<String, INoticeService> strategyMap) { |
| | | this.noticeStrategyMap.clear(); |
| | | strategyMap.forEach((k, v)-> this.noticeStrategyMap.put(k, v)); |
| | | } |
| | | |
| | | public INoticeService getResource(Notice notice){ |
| | | return noticeStrategyMap.get(notice.getType()); |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy.service; |
| | | |
| | | import cn.gistack.sm.notice.entity.Notice; |
| | | import org.aspectj.weaver.ast.Not; |
| | | |
| | | /** |
| | | * 通知策略接口 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | public interface INoticeService { |
| | | |
| | | /** |
| | | * 通知接口 |
| | | * @param notice |
| | | * @return |
| | | */ |
| | | Object toNotice(Notice notice); |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy.service.impl; |
| | | |
| | | import cn.gistack.sm.notice.entity.Notice; |
| | | import cn.gistack.sm.notice.strategy.service.INoticeService; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 站内信通知 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | @Component("inStation") |
| | | public class InStationNoticeServiceImpl implements INoticeService { |
| | | |
| | | /** |
| | | * 站内信通知实现 |
| | | * @param notice |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object toNotice(Notice notice) { |
| | | return "inStation"; |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy.service.impl; |
| | | |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecord; |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRule; |
| | | import cn.gistack.sm.alarmRule.service.AlarmRecordService; |
| | | import cn.gistack.sm.alarmRule.service.AlarmRuleDetailService; |
| | | import cn.gistack.sm.alarmRule.service.AlarmRuleService; |
| | | import cn.gistack.sm.intelligentCall.constant.ZtConstant; |
| | | import cn.gistack.sm.notice.constant.PtInfoConstant; |
| | | import cn.gistack.sm.notice.constant.ZtApiDataColumnConstant; |
| | | import cn.gistack.sm.notice.constant.ZtApiUrlConstant; |
| | | import cn.gistack.sm.notice.enums.PersonEnum; |
| | | import cn.gistack.sm.notice.util.FormatUtil; |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.service.IAttAdBaseService; |
| | | import cn.gistack.sm.sjztmd.service.IAttResManagePersonService; |
| | | import cn.gistack.sm.sms.entity.SmsTemplate; |
| | | import cn.gistack.sm.sms.service.ISmsTemplateService; |
| | | import cn.gistack.sm.sms.service.SmsService; |
| | | import cn.gistack.sm.sms.vo.SmsRequestTemplate; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 通知策略 |
| | | * |
| | | * @author zhongrj |
| | | * @date 2023-05-30 |
| | | */ |
| | | @Component |
| | | public class NoticeStrategyImpl { |
| | | |
| | | @Autowired |
| | | private SmsService smsService; |
| | | |
| | | @Autowired |
| | | private AlarmRuleService alarmRuleService; |
| | | |
| | | @Autowired |
| | | private AlarmRecordService alarmRecordService; |
| | | |
| | | @Autowired |
| | | private ISmsTemplateService smsTemplateService; |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Autowired |
| | | private IAttAdBaseService attAdBaseService; |
| | | |
| | | @Autowired |
| | | private IAttResManagePersonService attResManagePersonService; |
| | | |
| | | |
| | | /** |
| | | * 短信发送数据组装 |
| | | * |
| | | * @param jsonArray |
| | | * @param templateId |
| | | * @param columnsList 列名集合信息 |
| | | * @return |
| | | */ |
| | | private SmsRequestTemplate getSendSmsTemplate(JSONArray jsonArray, String templateId,AlarmRule alarmRule,List<String> columnsList) { |
| | | // 通过模板id 查询模板相关信息 |
| | | SmsTemplate smsTemplate = smsTemplateService.getOne(new QueryWrapper<SmsTemplate>().eq("template_id", templateId).eq("is_deleted", 0)); |
| | | if (null != smsTemplate) { |
| | | SmsRequestTemplate smsRequestTemplate = new SmsRequestTemplate(); |
| | | // 设置短信模板信息 |
| | | smsRequestTemplate.setSmsTemplate(smsTemplate); |
| | | // 解析模板并设置 title |
| | | smsRequestTemplate.setTitle(FormatUtil.composeMessage(smsTemplate.getContent())); |
| | | getColumnData(jsonArray, columnsList,smsRequestTemplate,templateId,alarmRule); |
| | | //返回 |
| | | return smsRequestTemplate; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 列名数据转换 |
| | | * @param jsonArray |
| | | * @param columnsList |
| | | * @param smsRequestTemplate |
| | | * @param templateId |
| | | * @return |
| | | */ |
| | | private void getColumnData(JSONArray jsonArray, |
| | | List<String> columnsList, |
| | | SmsRequestTemplate smsRequestTemplate, |
| | | String templateId, |
| | | AlarmRule alarmRule) { |
| | | List<PersonVO> personLists = new ArrayList<>(); |
| | | List<List<String>> lists = new ArrayList<>(); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | // 根据水库编号,所在区域查询需要发送的人员手机号及设置 |
| | | String res_cd = jsonArray.getJSONObject(i).getString("res_cd"); |
| | | // 查询告警人员信息 |
| | | List<PersonVO> personVOList = getPersonListByResGuid(res_cd,templateId,alarmRule); |
| | | if (personVOList.size() > 0) { |
| | | for (PersonVO personVO : personVOList) { |
| | | List<String> list = new ArrayList<>(); |
| | | list.add(res_cd); |
| | | list.add(personVO.getPhone()); |
| | | // 变量将值放入集合中 |
| | | for (String column : columnsList) { |
| | | String[] split = column.split(","); |
| | | String format = ""; |
| | | for (String s : split) { |
| | | format = format + jsonArray.getJSONObject(i).getString(s); |
| | | } |
| | | list.add(format); |
| | | } |
| | | lists.add(list); |
| | | } |
| | | } |
| | | personLists.addAll(personVOList); |
| | | } |
| | | // 设置信息 |
| | | smsRequestTemplate.setPersonVOList(personLists); |
| | | smsRequestTemplate.setTemplateContent(lists); |
| | | } |
| | | |
| | | /** |
| | | * 保存告警记录信息 |
| | | * @param list |
| | | * @param alarmRule 告警规则 |
| | | * @return |
| | | */ |
| | | private AlarmRecord saveAlarmRecord(List<String> list,AlarmRule alarmRule) { |
| | | AlarmRecord alarmRecord = new AlarmRecord(); |
| | | // 设置相关信息 |
| | | alarmRecord.setAlarmRuleId(alarmRule.getId().toString()); |
| | | alarmRecord.setReservoirNumber(list.get(0)); |
| | | alarmRecord.setAlarmCondition(alarmRule.getRuleRemark()); |
| | | // 新增 |
| | | boolean save = alarmRecordService.save(alarmRecord); |
| | | if (save){ |
| | | return alarmRecord; |
| | | } |
| | | // 返回 |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 查询告警人员信息 |
| | | * @param res_cd 水库 guid |
| | | * @param templateId |
| | | * @param alarmRule |
| | | * @return |
| | | */ |
| | | private List<PersonVO> getPersonListByResGuid(String res_cd,String templateId,AlarmRule alarmRule) { |
| | | // 查询对应的角色信息 |
| | | String roles = alarmRule.getAlarmPerson(); |
| | | String[] roleArray = roles.split(","); |
| | | List<String> personList = new ArrayList<>(); |
| | | List<String> areaList = new ArrayList<>(); |
| | | // 遍历 |
| | | for (String role : roleArray) { |
| | | if (role.contains("责任人")){ |
| | | personList.add(PersonEnum.findByName(role).getType().toString()); |
| | | }else { |
| | | areaList.add(role); |
| | | } |
| | | } |
| | | // 根据角色,水库编号查询对应的告警人员信息 |
| | | //1. 根据水库编号查询除责任人之外的人员信息 |
| | | List<PersonVO> personVOList = attAdBaseService.getPersonListByResGuid(res_cd); |
| | | //2. 根据水库编号及责任人类型查询相关责任人信息 |
| | | List<PersonVO> personVOList1 = attResManagePersonService.getPersonListByResGuid(res_cd,personList); |
| | | // 合并人员数据 |
| | | personVOList.addAll(personVOList1); |
| | | // 返回数据 |
| | | return personVOList; |
| | | } |
| | | |
| | | /** |
| | | * 默认实现 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String doSomethingDefault(String arg1, String arg2) { |
| | | // 默认业务逻辑处理... |
| | | return "默认实现"; |
| | | } |
| | | |
| | | /** |
| | | * 策略1: 水位信息接收不到 |
| | | * |
| | | * @param arg1 告警规则名称 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterInfoNotHandle(String arg1, String arg2) { |
| | | // 查询当前策略对应的告警规则信息 |
| | | AlarmRule alarmRule = alarmRuleService.getOne(new QueryWrapper<AlarmRule>().eq("rule_name", arg1)); |
| | | if (null!=alarmRule) { |
| | | // 调用中台服务接口查询数据 |
| | | JSONArray ztData = getZtData("", ZtApiUrlConstant.res_z_null_api); |
| | | // 只发短信,将发短信信息组装好 |
| | | SmsRequestTemplate smsRequestTemplate = getSendSmsTemplate(ztData, "2431012216668",alarmRule, ZtApiDataColumnConstant.waterInfoNotList); |
| | | // 拼接内容后面的联系方式,当前模板拼接平台服务电话 |
| | | // 遍历,拼接平台服务电话 |
| | | for (List<String> list : smsRequestTemplate.getTemplateContent()) { |
| | | // 添加平台电话 |
| | | list.add(PtInfoConstant.serverPhone); |
| | | // 保存告警记录信息 |
| | | AlarmRecord alarmRecord = saveAlarmRecord(list,alarmRule); |
| | | if (null != alarmRecord) { |
| | | list.add(alarmRecord.getId().toString()); |
| | | } |
| | | } |
| | | // 调用短信服务 |
| | | smsService.sendSignMsg(smsRequestTemplate); |
| | | } |
| | | // 保存预警记录 |
| | | return "水位信息接收不到"; |
| | | } |
| | | |
| | | /** |
| | | * 策略2: 水位数据异常 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterDataExcHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return "水位数据异常"; |
| | | } |
| | | |
| | | /** |
| | | * 策略3: 水位超低于死水位 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterLessDeadHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略4: 水位高于死水位,低于旱警水位 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterMoreDeadLessHJHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略5: 水位接近汛限告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterComeOverHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略6: 水位初次超汛限告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterFirstOverHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略7: 水位小幅超汛限告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterSmallScaleOverHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略8: 水位大幅超汛限告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterBigScaleOverHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略9: 水位接近设计洪水位告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterComeDesignHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略10: 水位超设计洪水位告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterMoreDesignHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略11: 水位超校核洪水位告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterMoreCheckHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略12: 近1h水位陡升 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterComeOneHourUpHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略13: 近1h水位陡降 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String waterComeOneHourDownHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略14: 暴雨降雨预警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String rainstormHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略15: 已降大雨告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String alreadyHeavyRainHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略16: 已降暴雨告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String alreadyRainstormHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略17: 2小时降雨告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String twoHourRainHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 策略18: 6小时降雨告警 |
| | | * |
| | | * @param arg1 |
| | | * @param arg2 |
| | | * @return |
| | | */ |
| | | public String sixHourRainHandle(String arg1, String arg2) { |
| | | // 业务逻辑处理 2... |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 调用中台接口查询数据 |
| | | * |
| | | * @param params |
| | | * @param url |
| | | * @return |
| | | */ |
| | | private JSONArray getZtData(String params, String url) { |
| | | //设置请求头 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add(ZtConstant.header_key, ZtConstant.header_value); |
| | | //封装请求头 |
| | | HttpEntity<MultiValueMap<String, Object>> formEntity = new HttpEntity<MultiValueMap<String, Object>>(headers); |
| | | try { |
| | | //有请求头,有参数请求 |
| | | ResponseEntity<String> responseEntity = |
| | | restTemplate.exchange(url + params, |
| | | HttpMethod.GET, |
| | | formEntity, |
| | | String.class); |
| | | JSONObject jsonObject = JSON.parseObject(responseEntity.getBody()); |
| | | JSONArray jsonArray = JSONArray.parseArray(jsonObject.get("data").toString()); |
| | | // 返回 |
| | | return jsonArray; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy.service.impl; |
| | | |
| | | import cn.gistack.sm.notice.entity.Notice; |
| | | import cn.gistack.sm.notice.strategy.service.INoticeService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | /** |
| | | * 短信通知 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | @Component("sms") |
| | | public class SmsNoticeServiceImpl implements INoticeService { |
| | | |
| | | /** |
| | | * 短信通知实现 |
| | | * @param notice |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object toNotice(Notice notice) { |
| | | // 短信发送 |
| | | return "sms"; |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.strategy.service.impl; |
| | | |
| | | import cn.gistack.sm.notice.entity.Notice; |
| | | import cn.gistack.sm.notice.strategy.service.INoticeService; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 电话通知 |
| | | * @author zhongrj |
| | | * @date 2023-05-29 |
| | | */ |
| | | @Component("tel") |
| | | public class TelNoticeServiceImpl implements INoticeService { |
| | | |
| | | /** |
| | | * 电话通知实现 |
| | | * @param notice |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object toNotice(Notice notice) { |
| | | return "tel"; |
| | | } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.util; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * 格式化转换工具 |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | public class FormatUtil { |
| | | |
| | | /** |
| | | * 取出{}中的内容 |
| | | * @param content |
| | | * @return |
| | | */ |
| | | public static String composeMessage(String content){ |
| | | // 正则 ,匹配 {}及内所有内容 |
| | | String regex = "\\{.+?\\}"; |
| | | Pattern pattern = Pattern.compile(regex); |
| | | Matcher matcher = pattern.matcher(content); |
| | | List<String> list = new ArrayList<>(); |
| | | list.add("手机号码"); |
| | | while (matcher.find()) { |
| | | // 键名 |
| | | String key = matcher.group(); |
| | | // 去除首尾大括号 |
| | | String title = key.substring(1,key.length()-1).split(",")[0]; |
| | | // 放入集合 |
| | | list.add(title); |
| | | } |
| | | // 转换为以逗号分隔的字符串 |
| | | return String.join(",",list); |
| | | } |
| | | |
| | | |
| | | |
| | | // public static void main(String[] args) { |
| | | // String data = "黄色预警:{日期,2}日{小时,2}时{分钟,2}分,{乡镇,10}乡镇{村,10}村{水库名称,25}水位{水库水位值,6}米过去一小时陡降{水位降值,6}米。过去24小时坝前点雨量{雨量值,6}毫米。请巡查责任人{姓名,4}做好巡查值守,发现险情及时上报;请技术责任人{姓名,4}密切关注。如为数据误报,请及时联系市县水利部门人员{姓名联系电话,16}(电话号码)。"; |
| | | // String message = composeMessage(data); |
| | | // System.out.println("message = " + message); |
| | | // |
| | | // String s = "黄色预警:{日期,2}{小时,2}{分钟,2}分数据误报,"; |
| | | // String s1 = s.replaceAll("\\{.+?\\}", "%s"); |
| | | // System.out.println(s1); |
| | | // |
| | | // String s2 = "1,2,3"; |
| | | // |
| | | // |
| | | // String format = String.format(s1, Arrays.asList(s2.split(","))); |
| | | // System.out.println("format = " + format); |
| | | // } |
| | | } |
| New file |
| | |
| | | package cn.gistack.sm.notice.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * 人员信息vo |
| | | * @author zhongrj |
| | | * @date 2023-05-31 |
| | | */ |
| | | @Data |
| | | public class PersonVO { |
| | | |
| | | /** |
| | | * 姓名 |
| | | */ |
| | | private String name; |
| | | |
| | | /** |
| | | * 角色 |
| | | */ |
| | | private String roleName; |
| | | |
| | | /** |
| | | * 手机号 |
| | | */ |
| | | private String phone; |
| | | } |
| | |
| | | package cn.gistack.sm.sjztmd.mapper; |
| | | |
| | | import cn.gistack.common.node.TreeNode; |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttAdBase; |
| | | import cn.gistack.sm.sjztmd.vo.AttAdBaseVO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.MapKey; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @MapKey("id") |
| | | Map<String, TreeNode> selectAttAdBaseTree(String parentCode, Map<String, Object> param); |
| | | |
| | | /** |
| | | * 根据水库编号查询除责任人之外的人员信息 |
| | | * @param res_cd |
| | | * @return |
| | | */ |
| | | List<PersonVO> getPersonListByResGuid(@Param("res_cd")String res_cd); |
| | | } |
| | |
| | | ORDER BY region."ad_code" |
| | | </select> |
| | | |
| | | <!--根据水库编号查询除责任人之外的人员信息--> |
| | | <select id="getPersonListByResGuid" resultType="cn.gistack.sm.notice.vo.PersonVO"> |
| | | select bu.real_name,bu.phone,bd.ad_code from YWXT.blade_user bu left join YWXT.blade_dept bd on instr(bu.dept_id,bd.id)>0 and bd.is_deleted = 0 |
| | | where bu.is_deleted = 0 |
| | | and bd.ad_code in ( |
| | | select "ad_code" from SJZT_MD."att_ad_base" |
| | | start with "ad_code" = (select "interior_ad_guid" from SJZT_MD."att_res_base" where "guid" = #{res_cd} ) |
| | | CONNECT BY PRIOR "p_ad_code" = "ad_code" |
| | | ) |
| | | and bu.phone is not null and bu.phone!='' |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | package cn.gistack.sm.sjztmd.mapper; |
| | | |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttResManagePerson; |
| | | import cn.gistack.sm.sjztmd.entity.PatrolResponsiblePerson; |
| | | import com.baomidou.dynamic.datasource.annotation.DS; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | |
| | | |
| | | List<PatrolResponsiblePerson> getPatrolResponsiblePersonAll(); |
| | | |
| | | /** |
| | | * 根据水库编号及责任人类型查询相关责任人信息 |
| | | * @param res_cd |
| | | * @param personList |
| | | * @return |
| | | */ |
| | | @DS("zt") |
| | | List<PersonVO> getPersonListByResGuid(@Param("res_cd")String res_cd,@Param("list") List<String> personList); |
| | | } |
| | |
| | | #{attResManagePerson.sysResource}) |
| | | </insert> |
| | | |
| | | |
| | | <!--根据水库编号及责任人类型查询相关责任人信息--> |
| | | <select id="getPersonListByResGuid" resultType="cn.gistack.sm.notice.vo.PersonVO"> |
| | | select "user_name" as name,"user_phone" as phone |
| | | from "SJZT_MD"."att_res_manage_person" |
| | | where "res_guid" = #{res_cd} |
| | | <choose> |
| | | <when test="list!=null and list.size()>0"> |
| | | and "type" in |
| | | <foreach collection="list" item="type" separator ="," open="(" close=")"> |
| | | #{type} |
| | | </foreach> |
| | | </when> |
| | | <otherwise> |
| | | and "type" in ('') |
| | | </otherwise> |
| | | </choose> |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | package cn.gistack.sm.sjztmd.service; |
| | | |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttAdBase; |
| | | import cn.gistack.sm.sjztmd.vo.AttAdBaseVO; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | |
| | | * @return |
| | | */ |
| | | Object selectAttAdBaseTree(String parentCode, Map<String, Object> obj); |
| | | |
| | | /** |
| | | * 根据水库编号查询除责任人之外的人员信息 |
| | | * @param res_cd |
| | | * @return |
| | | */ |
| | | List<PersonVO> getPersonListByResGuid(String res_cd); |
| | | } |
| | |
| | | package cn.gistack.sm.sjztmd.service; |
| | | |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttResManagePerson; |
| | | import cn.gistack.sm.sjztmd.entity.PatrolResponsiblePerson; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | |
| | | */ |
| | | List<PatrolResponsiblePerson> getPatrolResponsiblePersonAll(); |
| | | |
| | | /** |
| | | * 根据水库编号及责任人类型查询相关责任人信息 |
| | | * @param res_cd |
| | | * @param personList |
| | | * @return |
| | | */ |
| | | List<PersonVO> getPersonListByResGuid(String res_cd, List<String> personList); |
| | | } |
| | |
| | | |
| | | import cn.gistack.common.node.TreeNode; |
| | | import cn.gistack.common.utils.NodeTreeUtil; |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttAdBase; |
| | | import cn.gistack.sm.sjztmd.mapper.AttAdBaseMapper; |
| | | import cn.gistack.sm.sjztmd.service.IAttAdBaseService; |
| | |
| | | } |
| | | return nodeTree; |
| | | } |
| | | |
| | | /** |
| | | * 根据水库编号查询除责任人之外的人员信息 |
| | | * @param res_cd |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PersonVO> getPersonListByResGuid(String res_cd) { |
| | | return baseMapper.getPersonListByResGuid(res_cd); |
| | | } |
| | | } |
| | |
| | | package cn.gistack.sm.sjztmd.service.impl; |
| | | |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttResManagePerson; |
| | | import cn.gistack.sm.sjztmd.entity.PatrolResponsiblePerson; |
| | | import cn.gistack.sm.sjztmd.mapper.AttResManagePersonMapper; |
| | |
| | | public List<PatrolResponsiblePerson> getPatrolResponsiblePersonAll() { |
| | | return baseMapper.getPatrolResponsiblePersonAll(); |
| | | } |
| | | |
| | | /** |
| | | * 根据水库编号及责任人类型查询相关责任人信息 |
| | | * @param res_cd |
| | | * @param personList |
| | | * @return |
| | | */ |
| | | @Override |
| | | @DS("zt") |
| | | public List<PersonVO> getPersonListByResGuid(String res_cd, List<String> personList) { |
| | | return baseMapper.getPersonListByResGuid(res_cd,personList); |
| | | } |
| | | } |
| | |
| | | return R.status(true); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 发送 xx 变量模板短信 |
| | | * @param smsRequest 发送对象 |
| | |
| | | */ |
| | | @PostMapping("/sendSignMsg") |
| | | public R sendSignMsg(@RequestBody SmsRequestTemplate smsRequest){ |
| | | return R.data(smsService.sendSignMsg(smsRequest.getTitle(),smsRequest.getContent(),smsRequest.getSmsRequest(),smsRequest.getType())); |
| | | return R.data(smsService.sendSignMsg(smsRequest)); |
| | | } |
| | | } |
| | |
| | | package cn.gistack.sm.sms.service; |
| | | |
| | | import cn.com.flaginfo.sdk.cmc.api.sms.send.SMSSendRequest; |
| | | import cn.gistack.sm.sms.entity.SmsTemplate; |
| | | import cn.gistack.sm.sms.vo.SmsRequestTemplate; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @param request 内容对象 |
| | | * @return |
| | | */ |
| | | Object sendXXMsg(SMSSendRequest request,List<String> phoneNumbers); |
| | | Object sendXXMsg(SMSSendRequest request, |
| | | List<String> phoneNumbers); |
| | | |
| | | /** |
| | | * 发送 具名 变量模板短信 |
| | | * @param title 具名变量头 |
| | | * @param content 内容详情 |
| | | * @param request 内容对象 |
| | | * @param smsRequestTemplate |
| | | * @return |
| | | */ |
| | | Object sendSignMsg(String title,String content,SMSSendRequest request,Integer type); |
| | | Object sendSignMsg(SmsRequestTemplate smsRequestTemplate); |
| | | } |
| | |
| | | import cn.com.flaginfo.sdk.cmc.api.sms.dynsend.DynSMSSendRequest; |
| | | import cn.com.flaginfo.sdk.cmc.api.sms.send.SMSSendDataResult; |
| | | import cn.com.flaginfo.sdk.cmc.api.sms.send.SMSSendRequest; |
| | | import cn.gistack.sm.alarmRule.entity.AlarmRecordDetail; |
| | | import cn.gistack.sm.alarmRule.service.AlarmRecordDetailService; |
| | | import cn.gistack.sm.sms.entity.SmsRecord; |
| | | import cn.gistack.sm.sms.entity.SmsResult; |
| | | import cn.gistack.sm.sms.entity.SmsTemplate; |
| | | import cn.gistack.sm.sms.service.ISmsRecordService; |
| | | import cn.gistack.sm.sms.service.ISmsResultService; |
| | | import cn.gistack.sm.sms.service.SmsService; |
| | | import cn.gistack.sm.sms.util.SmsUtils; |
| | | import cn.gistack.sm.sms.vo.SmsRequestTemplate; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 短信发送服务实现层 |
| | |
| | | |
| | | @Autowired |
| | | private ISmsRecordService smsRecordService; |
| | | |
| | | @Autowired |
| | | private AlarmRecordDetailService alarmRecordDetailService; |
| | | |
| | | @Autowired |
| | | private ISmsResultService smsResultService; |
| | |
| | | |
| | | /** |
| | | * 发送 具名 变量模板短信 |
| | | * @param title 具名变量头 |
| | | * @param content 内容对象 |
| | | * @param smsRequestTemplate |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Object sendSignMsg(String title, String content, SMSSendRequest request,Integer type) { |
| | | if (type==1){ |
| | | String[] rows = content.split(";"); |
| | | // 先保存结果记录 |
| | | SmsResult smsResult = saveSendResult(request, rows.length); |
| | | List<SmsRecord> list = new ArrayList<>(); |
| | | // 遍历发送短信 |
| | | for (String row : rows) { |
| | | String[][] dyns = new String[][]{{title}, {row}}; |
| | | //请求参数 |
| | | DynSMSSendRequest sendRequest = new DynSMSSendRequest(); |
| | | sendRequest.setTemplateId(request.getTemplateId()); |
| | | sendRequest.setDynData(dyns); |
| | | // 发送 |
| | | ComResult<DynSMSSendDataResult> resultComResult = SmsUtils.dynSendMethod(sendRequest); |
| | | |
| | | SmsRecord smsRecord = new SmsRecord(); |
| | | if (null != smsResult){ |
| | | // 保存记录 |
| | | smsRecord = saveSmsRecord(request, resultComResult.getCode(), resultComResult.getMsg(), smsResult.getId()); |
| | | } |
| | | list.add(smsRecord); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("smsRecord",list); |
| | | map.put("smsResult",smsResult); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | if (type==2){ |
| | | String[] titleArr = title.split(","); |
| | | String[] rows = content.split(";"); |
| | | String[][] dyns = new String[rows.length + 1][titleArr.length]; |
| | | dyns[0] = titleArr; |
| | | int rowNum = 1; |
| | | for (String row : rows) { |
| | | String[] cols = row.split(","); |
| | | dyns[rowNum++] = cols; |
| | | } |
| | | public Object sendSignMsg(SmsRequestTemplate smsRequestTemplate) { |
| | | // 取出数据 |
| | | SMSSendRequest request = new SMSSendRequest(); |
| | | SmsTemplate smsTemplate = smsRequestTemplate.getSmsTemplate(); |
| | | request.setTemplateId(smsTemplate.getTemplateId()); |
| | | List<List<String>> templateContent = smsRequestTemplate.getTemplateContent(); |
| | | // 先保存结果记录 |
| | | SmsResult smsResult = saveSendResult(request, templateContent.size()); |
| | | List<SmsRecord> smsRecordList = new ArrayList<>(); |
| | | // 遍历处理 |
| | | for (List<String> list : templateContent) { |
| | | AlarmRecordDetail alarmRecordDetail = new AlarmRecordDetail(); |
| | | alarmRecordDetail.setReservoirNumber(list.get(0)); |
| | | alarmRecordDetail.setAlarmRecordId(Long.parseLong(list.get(list.size() - 1))); |
| | | alarmRecordDetail.setAlarmMode("短信"); |
| | | // 删除 最后一个 告警记录id |
| | | list.remove(list.size() - 1); |
| | | // 删除 0 水库编码 |
| | | list.remove(0); |
| | | // 转换字符串 |
| | | String row = String.join(",", list); |
| | | // 组装数据 |
| | | String[][] dyns = new String[][]{{smsRequestTemplate.getTitle()}, {row}}; |
| | | //请求参数 |
| | | DynSMSSendRequest sendRequest = new DynSMSSendRequest(); |
| | | sendRequest.setTemplateId(request.getTemplateId()); |
| | | sendRequest.setTemplateId(smsTemplate.getTemplateId()); |
| | | sendRequest.setDynData(dyns); |
| | | // 发送 |
| | | ComResult<DynSMSSendDataResult> resultComResult = SmsUtils.dynSendMethod(sendRequest); |
| | | // 先保存结果记录 |
| | | SmsResult smsResult = saveSendResult(request, rows.length); |
| | | |
| | | SmsRecord smsRecord = new SmsRecord(); |
| | | if (null != smsResult){ |
| | | // 设置手机号 |
| | | request.setUserNumber(list.get(0)); |
| | | // 内容处理 |
| | | String s = smsTemplate.getContent().replaceAll("\\{.+?\\}", "%s"); |
| | | // 短信内容拼接(完成发送的结果信息) |
| | | // 需要删除最前面的手机号 |
| | | list.remove(0); |
| | | // 格式转换 |
| | | String format = String.format(s, list.toArray()); |
| | | // 设置内容 |
| | | request.setMessageContent(format); |
| | | // 保存记录 |
| | | smsRecord = saveSmsRecord(request, resultComResult.getCode(), resultComResult.getMsg(), smsResult.getId()); |
| | | if (null != smsRecord){ |
| | | alarmRecordDetail.setAlarmContent(format); |
| | | alarmRecordDetail.setSendRecordId(smsRecord.getId()); |
| | | alarmRecordDetail.setCreateTime(new Date()); |
| | | // 保存告警记录详情信息 |
| | | boolean save = alarmRecordDetailService.save(alarmRecordDetail); |
| | | } |
| | | } |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("smsRecord",smsRecord); |
| | | map.put("smsResult",smsResult); |
| | | // 返回 |
| | | return map; |
| | | smsRecordList.add(smsRecord); |
| | | } |
| | | return null; |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("smsRecord",smsRecordList); |
| | | map.put("smsResult",smsResult); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送 具名 变量模板短信--批量一次发送 |
| | | * @param title 具名变量头 |
| | | * @return |
| | | */ |
| | | public Object sendSignMsg(String title, String datas, SMSSendRequest request, Integer type, SmsTemplate smsTemplate) { |
| | | String[] titleArr = title.split(","); |
| | | String[] rows = datas.split(";"); |
| | | String[][] dyns = new String[rows.length + 1][titleArr.length]; |
| | | dyns[0] = titleArr; |
| | | int rowNum = 1; |
| | | for (String row : rows) { |
| | | String[] cols = row.split(","); |
| | | dyns[rowNum++] = cols; |
| | | } |
| | | //请求参数 |
| | | DynSMSSendRequest sendRequest = new DynSMSSendRequest(); |
| | | sendRequest.setTemplateId(request.getTemplateId()); |
| | | sendRequest.setDynData(dyns); |
| | | // 发送 |
| | | ComResult<DynSMSSendDataResult> resultComResult = SmsUtils.dynSendMethod(sendRequest); |
| | | // 先保存结果记录 |
| | | SmsResult smsResult = saveSendResult(request, rows.length); |
| | | SmsRecord smsRecord = new SmsRecord(); |
| | | if (null != smsResult){ |
| | | // 保存记录 |
| | | smsRecord = saveSmsRecord(request, resultComResult.getCode(), resultComResult.getMsg(), smsResult.getId()); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("smsRecord",smsRecord); |
| | | map.put("smsResult",smsResult); |
| | | // 返回 |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | |
| | | package cn.gistack.sm.sms.vo; |
| | | |
| | | import cn.com.flaginfo.sdk.cmc.api.sms.send.SMSSendRequest; |
| | | import cn.gistack.sm.notice.vo.PersonVO; |
| | | import cn.gistack.sm.sms.entity.SmsTemplate; |
| | | import lombok.Data; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | |
| | | private SMSSendRequest smsRequest; |
| | | |
| | | /** |
| | | * 发送标题 |
| | | * 发送标题(值key) |
| | | */ |
| | | private String title; |
| | | |
| | | /** |
| | | * 内容 |
| | | * 发送数据内容(值字符串) |
| | | */ |
| | | private String content; |
| | | private String datas; |
| | | |
| | | /** |
| | | * 内容(短信内容) |
| | | */ |
| | | private List<String> content; |
| | | |
| | | /** |
| | | * 号码集合 |
| | |
| | | private List<String> phoneNumbers; |
| | | |
| | | /** |
| | | * 告警人 |
| | | */ |
| | | private List<PersonVO> personVOList; |
| | | |
| | | |
| | | /** |
| | | * 内容(短信内容)--临时 |
| | | */ |
| | | private List<List<String>> templateContent; |
| | | |
| | | /** |
| | | * 类型 1:遍历发送 2:批量发送(一次发多个) |
| | | */ |
| | | private Integer type; |
| | | |
| | | /** |
| | | * 短信模板对象信息 |
| | | */ |
| | | private SmsTemplate smsTemplate; |
| | | } |