Commit 4599f732 authored by 李腾威's avatar 李腾威

融合调度规则 任务 4318 4326 4327

parent 633446fe
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils; import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr; import com.yeejoin.amos.boot.module.common.api.entity.OrgUsr;
import com.yeejoin.amos.boot.module.common.api.mapper.DynamicFormInstanceMapper; import com.yeejoin.amos.boot.module.common.api.mapper.DynamicFormInstanceMapper;
import com.yeejoin.amos.boot.module.common.api.service.IFireTeamService; import com.yeejoin.amos.boot.module.common.api.service.IFireTeamService;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCallePowerTransferRo; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCallePowerTransferRo;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyResourcesDto;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException; import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.alibaba.fastjson.JSONException; import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary; import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl; import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils; import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto; import com.yeejoin.amos.boot.module.common.api.dto.FirefightersDto;
import com.yeejoin.amos.boot.module.common.api.dto.FormValue; import com.yeejoin.amos.boot.module.common.api.dto.FormValue;
import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient; import com.yeejoin.amos.boot.module.common.api.feign.EquipFeignClient;
import com.yeejoin.amos.boot.module.common.api.service.IDutyPersonService; import com.yeejoin.amos.boot.module.common.api.service.IDutyPersonService;
import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.FirefightersServiceImpl;
import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl; import com.yeejoin.amos.boot.module.common.biz.service.impl.OrgUsrServiceImpl;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledFormDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledFormDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledObjsDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledObjsDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledRo; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertCalledRo;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedExtDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedExtDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedSMSDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedSMSDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedZHDto; import com.yeejoin.amos.boot.module.jcs.api.dto.AlertSubmittedZHDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto; import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.InstructionsZHDto; import com.yeejoin.amos.boot.module.jcs.api.dto.InstructionsZHDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyZHDto; import com.yeejoin.amos.boot.module.jcs.api.dto.PowerTransferCompanyZHDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.SchedulingReportingDto; import com.yeejoin.amos.boot.module.jcs.api.dto.SchedulingReportingDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateDto; import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateDto;
import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto; import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmitted; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmitted;
import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmittedObject; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertSubmittedObject;
import com.yeejoin.amos.boot.module.jcs.api.entity.Template; import com.yeejoin.amos.boot.module.jcs.api.entity.Template;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertBusinessTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSchedulingTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStageEnums;
import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSubmitTypeEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertSubmitTypeEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.FireCarStatusEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.FireCarStatusEnum;
import com.yeejoin.amos.boot.module.jcs.api.enums.SubmissionMethodEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.SubmissionMethodEnum;
import com.yeejoin.amos.boot.module.jcs.api.mapper.AlertSubmittedMapper; import com.yeejoin.amos.boot.module.jcs.api.mapper.AlertSubmittedMapper;
import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferCompanyMapper; import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferCompanyMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertSubmittedObjectService; import com.yeejoin.amos.boot.module.jcs.api.service.IAlertSubmittedObjectService;
import com.yeejoin.amos.boot.module.jcs.api.service.IAlertSubmittedService; import com.yeejoin.amos.boot.module.jcs.api.service.IAlertSubmittedService;
import com.yeejoin.amos.boot.module.jcs.biz.rule.action.AlertCalledAction; import com.yeejoin.amos.boot.module.jcs.biz.rule.action.AlertCalledAction;
import com.yeejoin.amos.component.rule.config.RuleConfig; import com.yeejoin.amos.component.rule.config.RuleConfig;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
/** /**
*
* 警情报送记录 服务实现类 * 警情报送记录 服务实现类
* *
*
*
* @author tb * @author tb
*
* @date 2021-06-17 * @date 2021-06-17
*
*/ */
@Service @Service
public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, AlertSubmitted, AlertSubmittedMapper> implements IAlertSubmittedService {
public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, AlertSubmitted, AlertSubmittedMapper>
implements IAlertSubmittedService {
@Autowired @Autowired
IAlertSubmittedObjectService iAlertSubmittedObjectService; IAlertSubmittedObjectService iAlertSubmittedObjectService;
@Autowired @Autowired
AlertSubmittedObjectServiceImpl alertSubmittedObjectServiceImpl; AlertSubmittedObjectServiceImpl alertSubmittedObjectServiceImpl;
@Autowired @Autowired
AlertCalledServiceImpl alertCalledService; AlertCalledServiceImpl alertCalledService;
@Autowired @Autowired
DataDictionaryServiceImpl dataDictionaryService; DataDictionaryServiceImpl dataDictionaryService;
@Autowired @Autowired
TemplateServiceImpl templateService; TemplateServiceImpl templateService;
@Autowired @Autowired
PowerTransferServiceImpl powerTransferService; PowerTransferServiceImpl powerTransferService;
@Autowired @Autowired
RuleAlertCalledService ruleAlertCalledService; RuleAlertCalledService ruleAlertCalledService;
@Autowired @Autowired
AlertCalledAction alertCalledAction; AlertCalledAction alertCalledAction;
@Autowired @Autowired
OrgUsrServiceImpl orgUsrService; OrgUsrServiceImpl orgUsrService;
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
private FirefightersServiceImpl firefightersService; private FirefightersServiceImpl firefightersService;
@Autowired @Autowired
OrgUsrServiceImpl iOrgUsrService; OrgUsrServiceImpl iOrgUsrService;
@Autowired @Autowired
IDutyPersonService iDutyPersonService; IDutyPersonService iDutyPersonService;
@Autowired
@Autowired
private EmqKeeper emqKeeper; private EmqKeeper emqKeeper;
@Value("${mqtt.topic.alert.reporting}") @Value("${mqtt.topic.alert.reporting}")
private String topic; private String topic;
@Value("${mqtt.topic.command.power.deployment}") @Value("${mqtt.topic.command.power.deployment}")
private String powertopic; private String powertopic;
@Autowired @Autowired
EquipFeignClient equipFeignClient; EquipFeignClient equipFeignClient;
@Autowired @Autowired
FireTeamServiceImpl fireTeamServiceImpl; FireTeamServiceImpl fireTeamServiceImpl;
@Autowired @Autowired
IFireTeamService fireTeamService; IFireTeamService fireTeamService;
@Autowired
@Autowired
PowerTransferCompanyResourcesServiceImpl powerTransferCompanyResourcesService; PowerTransferCompanyResourcesServiceImpl powerTransferCompanyResourcesService;
@Autowired @Autowired
AlertSubmittedMapper alertSubmittedMapper; AlertSubmittedMapper alertSubmittedMapper;
@Autowired @Autowired
PowerTransferCompanyMapper powerTransferCompanyMapper; PowerTransferCompanyMapper powerTransferCompanyMapper;
@Autowired @Autowired
DynamicFormInstanceMapper dynamicFormInstanceMapper; DynamicFormInstanceMapper dynamicFormInstanceMapper;
@Override @Override
public SchedulingReportingDto listSchedulingByParam(AlertSubmittedDto queryParam) { public SchedulingReportingDto listSchedulingByParam(AlertSubmittedDto queryParam) {
SchedulingReportingDto schedulingReportingDto = new SchedulingReportingDto(); SchedulingReportingDto schedulingReportingDto = new SchedulingReportingDto();
List<AlertSubmittedExtDto> alertSubmittedExtDtoList = this.baseMapper.listSchedulingByParam(queryParam); List<AlertSubmittedExtDto> alertSubmittedExtDtoList = this.baseMapper.listSchedulingByParam(queryParam);
schedulingReportingDto.setSchedulingReportingList(alertSubmittedExtDtoList); schedulingReportingDto.setSchedulingReportingList(alertSubmittedExtDtoList);
Map<String, List<AlertSubmittedExtDto>> groupMap = Map<String, List<AlertSubmittedExtDto>> groupMap =
alertSubmittedExtDtoList.stream().collect(Collectors.groupingBy(AlertSubmittedExtDto::getSubmissionMethodCode));
alertSubmittedExtDtoList.stream()
.collect(Collectors.groupingBy(AlertSubmittedExtDto::getSubmissionMethodCode));
int phoneSize = 0; int phoneSize = 0;
int smsSize = 0; int smsSize = 0;
if (ObjectUtils.isNotEmpty(groupMap.get(SubmissionMethodEnum.PHONE.getCode()))) { if (ObjectUtils.isNotEmpty(groupMap.get(SubmissionMethodEnum.PHONE.getCode()))) {
phoneSize = groupMap.get(SubmissionMethodEnum.PHONE.getCode()).size(); phoneSize = groupMap.get(SubmissionMethodEnum.PHONE.getCode()).size();
} }
if (ObjectUtils.isNotEmpty(groupMap.get(SubmissionMethodEnum.SMS.getCode()))) { if (ObjectUtils.isNotEmpty(groupMap.get(SubmissionMethodEnum.SMS.getCode()))) {
smsSize = groupMap.get(SubmissionMethodEnum.SMS.getCode()).size(); smsSize = groupMap.get(SubmissionMethodEnum.SMS.getCode()).size();
} }
String extraInfo = String.format("已调度电话%s起,短信%d批", phoneSize, smsSize); String extraInfo = String.format("已调度电话%s起,短信%d批", phoneSize, smsSize);
schedulingReportingDto.setExtraInfo(extraInfo); schedulingReportingDto.setExtraInfo(extraInfo);
return schedulingReportingDto; return schedulingReportingDto;
} }
@Override @Override
public SchedulingReportingDto listReportingByParam(AlertSubmittedDto queryParam) { public SchedulingReportingDto listReportingByParam(AlertSubmittedDto queryParam) {
SchedulingReportingDto schedulingReportingDto = new SchedulingReportingDto(); SchedulingReportingDto schedulingReportingDto = new SchedulingReportingDto();
List<AlertSubmittedExtDto> alertSubmittedExtDtoList = this.baseMapper.listReportingByParam(queryParam); List<AlertSubmittedExtDto> alertSubmittedExtDtoList = this.baseMapper.listReportingByParam(queryParam);
if (ObjectUtils.isNotEmpty(alertSubmittedExtDtoList)) { if (ObjectUtils.isNotEmpty(alertSubmittedExtDtoList)) {
// 组装额外信息 // 组装额外信息
String _extraInfo = "报送给%s、%s"; String _extraInfo = "报送给%s、%s";
alertSubmittedExtDtoList.forEach(alertSubmittedExtDto -> { alertSubmittedExtDtoList.forEach(alertSubmittedExtDto -> {
try { try {
alertSubmittedExtDto.setExtraInfo(String.format(_extraInfo, alertSubmittedExtDto.getCompanyName(), alertSubmittedExtDto.setExtraInfo(String.format(_extraInfo, alertSubmittedExtDto.getCompanyName(),
alertSubmittedExtDto.getUserName())); alertSubmittedExtDto.getUserName()));
TemplateExtendDto template = templateService.getByType(alertSubmittedExtDto.getBusinessTypeCode()); TemplateExtendDto template = templateService.getByType(alertSubmittedExtDto.getBusinessTypeCode());
AlertCalledObjsDto alertCalledVo = (AlertCalledObjsDto) alertCalledService AlertCalledObjsDto alertCalledVo = (AlertCalledObjsDto) alertCalledService.selectAlertCalledByIdNoRedisNew(queryParam.getAlertCalledId());
.selectAlertCalledByIdNoRedisNew(queryParam.getAlertCalledId());
AlertCalled alertCalled = alertCalledVo.getAlertCalled(); AlertCalled alertCalled = alertCalledVo.getAlertCalled();
/** /**
*
* 构建警情报送规则对象 * 构建警情报送规则对象
*
*/ */
AlertCalledRo alertCalledRo = new AlertCalledRo(); AlertCalledRo alertCalledRo = new AlertCalledRo();
String replaceContent = RuleAlertCalledService.init(alertCalledRo, alertCalledVo); String replaceContent = RuleAlertCalledService.init(alertCalledRo,alertCalledVo);
Map<String, String> definitions = new HashMap<>(); Map<String, String> definitions = new HashMap<>();
definitions.put("$type",alertCalled.getAlertType());
definitions.put("$callTime",DateUtils.dateTimeToDateString(alertCalled.getCallTime()));
definitions.put("$replaceContent",replaceContent);
definitions.put("$address",alertCalled.getAddress());
String content = getTaskInformation( template.getRichContent(),definitions);
definitions.put("$type", alertCalled.getAlertType()); alertSubmittedExtDto.setSubmissionContentValue(JSONObject.parseObject(alertSubmittedExtDto.getSubmissionContent()));
definitions.put("$callTime", DateUtils.dateTimeToDateString(alertCalled.getCallTime()));
definitions.put("$replaceContent", replaceContent);
definitions.put("$address", alertCalled.getAddress());
String content = getTaskInformation(template.getRichContent(), definitions);
alertSubmittedExtDto.setSubmissionContentValue(
JSONObject.parseObject(alertSubmittedExtDto.getSubmissionContent()));
alertSubmittedExtDto.setSubmissionContent(content); alertSubmittedExtDto.setSubmissionContent(content);
} catch (JSONException e) { } catch (JSONException e) {
alertSubmittedExtDto.setSubmissionContentValue(alertSubmittedExtDto.getSubmitContent()); alertSubmittedExtDto.setSubmissionContentValue(alertSubmittedExtDto.getSubmitContent());
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
schedulingReportingDto.setSchedulingReportingList(alertSubmittedExtDtoList); schedulingReportingDto.setSchedulingReportingList(alertSubmittedExtDtoList);
String extraInfo = String.format("已报送%d条", alertSubmittedExtDtoList.size()); String extraInfo = String.format("已报送%d条", alertSubmittedExtDtoList.size());
schedulingReportingDto.setExtraInfo(extraInfo); schedulingReportingDto.setExtraInfo(extraInfo);
} }
return schedulingReportingDto; return schedulingReportingDto;
} }
@Override @Override
public Boolean save(AlertSubmittedDto alertSubmittedDto, String userName) throws Exception { public Boolean save(AlertSubmittedDto alertSubmittedDto, String userName) throws Exception {
try { try {
Map<String,String> map = saveAlertSubmitted(alertSubmittedDto, userName);
Map<String, String> map = saveAlertSubmitted(alertSubmittedDto, userName);
// 组装规则入参 // 组装规则入参
AlertCalled alertCalled = alertCalledService.getById(alertSubmittedDto.getAlertCalledId()); AlertCalled alertCalled = alertCalledService.getById(alertSubmittedDto.getAlertCalledId());
AlertCalledObjsDto alertCalledVo = (AlertCalledObjsDto) alertCalledService.selectAlertCalledByIdNoRedisNew(alertCalled.getSequenceNbr());
AlertCalledObjsDto alertCalledVo = (AlertCalledObjsDto) alertCalledService
.selectAlertCalledByIdNoRedisNew(alertCalled.getSequenceNbr());
alertCalledVo.setAlertCalled(alertCalled); alertCalledVo.setAlertCalled(alertCalled);
// 调用规则 // 调用规则
ruleAlertCalledService.fireAlertCalledRule(alertCalledVo, map.get("alertWay"),map.get("mobiles"), map.get("usIds"), map.get("feedBack"));
ruleAlertCalledService.fireAlertCalledRule(alertCalledVo, map.get("alertWay"), map.get("mobiles"), //通知实战指挥页面发送mqtt 默认发送 String 类型 0, 新警情 1 警情状态变化
map.get("usIds"), map.get("feedBack"));
// 通知实战指挥页面发送mqtt 默认发送 String 类型 0, 新警情 1 警情状态变化
emqKeeper.getMqttClient().publish(powertopic, "0".getBytes(), RuleConfig.DEFAULT_QOS, true); emqKeeper.getMqttClient().publish(powertopic, "0".getBytes(), RuleConfig.DEFAULT_QOS, true);
} catch (MqttException e) { } catch (MqttException e) {
throw new RuntimeException(); throw new RuntimeException();
} }
return true; return true;
} }
/** /**
*
* 规则回调 * 规则回调
*
*/ */
public void ruleCallbackAction(String smsCode, List<Map<String,Object>> sendIds, Object object) throws Exception {
public void ruleCallbackAction(String smsCode, List<Map<String, Object>> sendIds, Object object) throws Exception {
// 获取报送对象列表 // 获取报送对象列表
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList(); List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
Set<String> mobiles = new HashSet<>(); Set<String> mobiles = new HashSet<>();
HashMap<String, String> smsParams = new HashMap<>(); HashMap<String, String> smsParams = new HashMap<>();
String alertCalledId = null; String alertCalledId = null;
List<Map<String, Object>> orgUsers = new LinkedList<>(); List<Map<String, Object>> orgUsers = new LinkedList<>();
String sCode = ""; String sCode = "";
String alertWay = ""; String alertWay = "";
if (object instanceof AlertCalledRo) { if (object instanceof AlertCalledRo) {
AlertCalledRo calledRo = (AlertCalledRo) object; AlertCalledRo calledRo = (AlertCalledRo) object;
String alertSubmittedId = calledRo.getAlertSubmittedId(); String alertSubmittedId = calledRo.getAlertSubmittedId();
alertCalledId = calledRo.getSequenceNbr(); alertCalledId = calledRo.getSequenceNbr();
String alertTypeCode = calledRo.getAlertTypeCode(); String alertTypeCode = calledRo.getAlertTypeCode();
alertWay = calledRo.getAlertWay(); alertWay = calledRo.getAlertWay();
String unitInvolved = calledRo.getUnitInvolved(); String unitInvolved = calledRo.getUnitInvolved();
// 警情续报 警情结案,非警情确认选择人员电话号码 // 警情续报 警情结案,非警情确认选择人员电话号码
String ids = calledRo.getIds(); String ids = calledRo.getIds();
if(!ValidationUtil.isEmpty(ids)) {
if (!ValidationUtil.isEmpty(ids)) {
List<String> ls = Arrays.asList(ids.split(",")); List<String> ls = Arrays.asList(ids.split(","));
ls.stream().forEach(e->mobiles.add(e));
ls.stream().forEach(e -> mobiles.add(e));
} }
// 获取报送规则 // 获取报送规则
sendIds.stream().forEach(e->{
sendIds.stream().forEach(e -> {
// 一般火灾 // 航空器救援 // 一般火灾 // 航空器救援
if(alertTypeCode.equals(AlertStageEnums.YBHZ.getCode()) || alertTypeCode.equals(AlertStageEnums.HKJY.getCode())) {
if (alertTypeCode.equals(AlertStageEnums.YBHZ.getCode()) if(e.containsKey("onDuty")) {
|| alertTypeCode.equals(AlertStageEnums.HKJY.getCode())) {
if (e.containsKey("onDuty")) {
// 当日值班人员:获值班表中包括消救部、综合办公室、消防支队、应急指挥科的值班人员。 // 当日值班人员:获值班表中包括消救部、综合办公室、消防支队、应急指挥科的值班人员。
String [] arr = e.get("onDuty").toString().split(",");
String[] arr = e.get("onDuty").toString().split(",");
List<String> list = Arrays.asList(arr); List<String> list = Arrays.asList(arr);
List<Map<String, Object>> mapList = iDutyPersonService.queryByCompanyId(list); List<Map<String, Object>> mapList = iDutyPersonService.queryByCompanyId(list);
orgUsers.addAll(mapList); orgUsers.addAll(mapList);
} }
if(e.containsKey("fireBrigade")) {
if (e.containsKey("fireBrigade")) {
// 根据人员岗位:班组长、队长、通讯员; 消防队伍--消防人员 中,对应岗位的人员 // 根据人员岗位:班组长、队长、通讯员; 消防队伍--消防人员 中,对应岗位的人员
List<FirefightersDto> fireBrigade = firefightersService.queryById(e.get("fireBrigade").toString().split(","));
List<FirefightersDto> fireBrigade = firefightersService fireBrigade.stream().forEach(f->{
.queryById(e.get("fireBrigade").toString().split(",")); HashMap<String,Object> map = new HashMap<>();
map.put("telephone",f.getMobilePhone());
fireBrigade.stream().forEach(f -> { map.put("sequenceNbr",f.getSequenceNbr());
map.put("bizOrgName",f.getName());
HashMap<String, Object> map = new HashMap<>();
map.put("telephone", f.getMobilePhone());
map.put("sequenceNbr", f.getSequenceNbr());
map.put("bizOrgName", f.getName());
orgUsers.add(map); orgUsers.add(map);
}); });
} }
if (e.containsKey("name")) { if(e.containsKey("name")) {
// 消防救援保障部 // 消防救援保障部
List<Map<String, Object>> mapList = iOrgUsrService.queryCompanyIdNew(e.get("name").toString()); List<Map<String, Object>> mapList = iOrgUsrService.queryCompanyIdNew(e.get("name").toString());
orgUsers.addAll(mapList); orgUsers.addAll(mapList);
} }
// 安运部 // 安运部
if(e.get("type").toString().equals("AY")) {
if (e.get("type").toString().equals("AY")) { if(e.containsKey("name")) {
String [] arr = e.get("airportPost").toString().split(",");
if (e.containsKey("name")) {
String[] arr = e.get("airportPost").toString().split(",");
List<String> list = Arrays.asList(arr); List<String> list = Arrays.asList(arr);
List<Map<String, Object>> mapList = iOrgUsrService.queryCompanyId(e.get("name").toString(), List<Map<String, Object>> mapList = iOrgUsrService.queryCompanyId(e.get("name").toString(),list);
list);
orgUsers.addAll(mapList); orgUsers.addAll(mapList);
} }
} }
// 事发单位 // 事发单位
if(e.get("type").toString().equals("SF")) {
if (e.get("type").toString().equals("SF")) { if(e.containsKey("airportPost")) {
String [] arr = e.get("airportPost").toString().split(",");
if (e.containsKey("airportPost")) {
String[] arr = e.get("airportPost").toString().split(",");
List<String> list = Arrays.asList(arr); List<String> list = Arrays.asList(arr);
List<Map<String, Object>> mapList = iOrgUsrService.queryCompanyId(unitInvolved,list);
List<Map<String, Object>> mapList = iOrgUsrService.queryCompanyId(unitInvolved, list);
orgUsers.addAll(mapList); orgUsers.addAll(mapList);
} }
} }
} }
// 突发事件救援 // 漏油现场安全保障 // 专机保障 // 其他 // 突发事件救援 // 漏油现场安全保障 // 专机保障 // 其他
if(alertTypeCode.equals(AlertStageEnums.HKJY.getCode()) || alertTypeCode.equals(AlertStageEnums.LYXC.getCode())
if (alertTypeCode.equals(AlertStageEnums.HKJY.getCode()) || alertTypeCode.equals(AlertStageEnums.ZJBZ.getCode()) || alertTypeCode.equals(AlertStageEnums.QTJQ.getCode())) {
|| alertTypeCode.equals(AlertStageEnums.LYXC.getCode()) if(e.containsKey("onDuty")) {
List<Map<String, Object>> mapList = iDutyPersonService.queryByCompanyNew(e.get("name").toString());
|| alertTypeCode.equals(AlertStageEnums.ZJBZ.getCode()) orgUsers.addAll(mapList);
|| alertTypeCode.equals(AlertStageEnums.QTJQ.getCode())) { }
}
if (e.containsKey("onDuty")) {
List<Map<String, Object>> mapList = iDutyPersonService
.queryByCompanyNew(e.get("name").toString());
orgUsers.addAll(mapList);
}
}
// 120急救 // 120急救
if(alertTypeCode.equals(AlertStageEnums.JJJQ.getCode())) {
if (alertTypeCode.equals(AlertStageEnums.JJJQ.getCode())) {
if (e.containsKey("name")) { if (e.containsKey("name")) {
List<Map<String, Object>> mapList = iDutyPersonService.queryByCompanyNew(e.get("name").toString());
List<Map<String, Object>> mapList = iDutyPersonService
.queryByCompanyNew(e.get("name").toString());
orgUsers.addAll(mapList); orgUsers.addAll(mapList);
List<Map<String, Object>> mapList1 = iOrgUsrService.queryCompanyIdNew(e.get("name").toString()); List<Map<String, Object>> mapList1 = iOrgUsrService.queryCompanyIdNew(e.get("name").toString());
orgUsers.addAll(mapList1); orgUsers.addAll(mapList1);
} }
} }
}); });
// 警情初报 续报 结案 // 警情初报 续报 结案
// 1.保存警情记录主表 // 1.保存警情记录主表
AlertSubmitted alertSubmitted = new AlertSubmitted(); AlertSubmitted alertSubmitted = new AlertSubmitted();
alertSubmitted.setAlertCalledId(Long.valueOf(calledRo.getSequenceNbr())); alertSubmitted.setAlertCalledId(Long.valueOf(calledRo.getSequenceNbr()));
// 保存初报细分类型(一般火灾、航空器救援等) // 保存初报细分类型(一般火灾、航空器救援等)
alertSubmitted.setBusinessTypeCode(calledRo.getAlertTypeCode()); alertSubmitted.setBusinessTypeCode(calledRo.getAlertTypeCode());
// 警情初报 --- 续报 结案 // 警情初报 --- 续报 结案
if(alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
if (alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
alertSubmitted.setBusinessType(AlertBusinessTypeEnum.警情初报.getName()); alertSubmitted.setBusinessType(AlertBusinessTypeEnum.警情初报.getName());
Optional<SubmissionMethodEnum> submissionMethodEnum = Optional.of(SubmissionMethodEnum.SMS); Optional<SubmissionMethodEnum> submissionMethodEnum = Optional.of(SubmissionMethodEnum.SMS);
alertSubmitted.setSubmissionMethodCode(submissionMethodEnum.get().getCode()); alertSubmitted.setSubmissionMethodCode(submissionMethodEnum.get().getCode());
alertSubmitted.setSubmissionMethod(submissionMethodEnum.get().getName()); alertSubmitted.setSubmissionMethod(submissionMethodEnum.get().getName());
Optional<AlertSchedulingTypeEnum> alertSchedulingTypeEnum = Optional.of(AlertSchedulingTypeEnum.融合调度); Optional<AlertSchedulingTypeEnum> alertSchedulingTypeEnum = Optional.of(AlertSchedulingTypeEnum.融合调度);
alertSubmitted.setSchedulingTypeCode(alertSchedulingTypeEnum.get().getCode()); alertSubmitted.setSchedulingTypeCode(alertSchedulingTypeEnum.get().getCode());
alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName()); alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName());
alertSubmitted.setSubmissionContent(JSONObject.toJSONString(objectToMap(calledRo))); alertSubmitted.setSubmissionContent(JSONObject.toJSONString(objectToMap(calledRo)));
alertSubmitted.setUpdateTime(new Date()); alertSubmitted.setUpdateTime(new Date());
alertSubmitted.setSubmissionTime(new Date()); alertSubmitted.setSubmissionTime(new Date());
this.baseMapper.insert(alertSubmitted); this.baseMapper.insert(alertSubmitted);
alertSubmittedId = alertSubmitted.getSequenceNbr().toString(); alertSubmittedId = alertSubmitted.getSequenceNbr().toString();
} else if (alertWay.equals(AlertBusinessTypeEnum.警情续报.getCode())) { } else if(alertWay.equals(AlertBusinessTypeEnum.警情续报.getCode())) {
alertSubmitted.setBusinessType(AlertBusinessTypeEnum.警情续报.getName()); alertSubmitted.setBusinessType(AlertBusinessTypeEnum.警情续报.getName());
sCode = "SMS_JCS_XB"; sCode = "SMS_JCS_XB";
} else if(alertWay.equals(AlertBusinessTypeEnum.警情结案.getCode())) {
} else if (alertWay.equals(AlertBusinessTypeEnum.警情结案.getCode())) {
alertSubmitted.setBusinessType(AlertBusinessTypeEnum.警情结案.getName()); alertSubmitted.setBusinessType(AlertBusinessTypeEnum.警情结案.getName());
sCode = "SMS_JCS_JA"; sCode = "SMS_JCS_JA";
} else { } else {
alertSubmitted.setBusinessType(AlertBusinessTypeEnum.非警情确认.getName()); alertSubmitted.setBusinessType(AlertBusinessTypeEnum.非警情确认.getName());
sCode = "SMS_JCS_QR"; sCode = "SMS_JCS_QR";
} }
AlertSubmitted alertSubmittedNew = null; AlertSubmitted alertSubmittedNew = null;
Optional<AlertBusinessTypeEnum> alertBusinessTypeEnum = Optional<AlertBusinessTypeEnum> alertBusinessTypeEnum =
EnumsUtils.getEnumObject(AlertBusinessTypeEnum.class, EnumsUtils.getEnumObject(AlertBusinessTypeEnum.class,
e -> e.getCode().equals(calledRo.getAlertTypeCode())); e -> e.getCode().equals(calledRo.getAlertTypeCode()));
smsCode = alertBusinessTypeEnum.get().getSms_code(); smsCode = alertBusinessTypeEnum.get().getSms_code();
if (!alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
if(!alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
LambdaQueryWrapper<AlertSubmitted> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AlertSubmitted> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AlertSubmitted::getAlertCalledId,alertCalledId);
queryWrapper.eq(AlertSubmitted::getAlertCalledId, alertCalledId);
queryWrapper.orderByDesc(AlertSubmitted::getSequenceNbr); queryWrapper.orderByDesc(AlertSubmitted::getSequenceNbr);
List<AlertSubmitted> alertSubmitteds = alertSubmittedMapper.selectList(queryWrapper); List<AlertSubmitted> alertSubmitteds = alertSubmittedMapper.selectList(queryWrapper);
alertSubmittedNew = alertSubmitteds.get(0); alertSubmittedNew = alertSubmitteds.get(0);
} }
// 组装人员信息 // 组装人员信息
for (Map<String, Object> orgUser : orgUsers) { for (Map<String, Object> orgUser : orgUsers) {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
if(!alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
if (!alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
alertSubmittedObject.setAlertSubmittedId(alertSubmittedNew.getSequenceNbr()); alertSubmittedObject.setAlertSubmittedId(alertSubmittedNew.getSequenceNbr());
} else { } else {
alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId)); alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId));
} }
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setUserId(Long.valueOf(String.valueOf(orgUser.get("sequenceNbr")))); alertSubmittedObject.setUserId(Long.valueOf(String.valueOf(orgUser.get("sequenceNbr"))));
alertSubmittedObject.setUserName((String) orgUser.get("bizOrgName")); alertSubmittedObject.setUserName((String) orgUser.get("bizOrgName"));
if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) { if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone")); mobiles.add((String) orgUser.get("telephone"));
alertSubmittedObject.setUserPhone((String) orgUser.get("telephone")); alertSubmittedObject.setUserPhone((String) orgUser.get("telephone"));
} }
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
} }
// 组装报送内容 // 组装报送内容
smsParams.put("callTimeStr", calledRo.getCallTimeStr()); smsParams.put("callTimeStr", calledRo.getCallTimeStr());
smsParams.put("address", calledRo.getAddress()); smsParams.put("address", calledRo.getAddress());
smsParams.put("fireLocation", calledRo.getFireLocation()); smsParams.put("fireLocation", calledRo.getFireLocation());
smsParams.put("burningMaterial", calledRo.getBurningMaterial()); smsParams.put("burningMaterial", calledRo.getBurningMaterial());
smsParams.put("fireSituation", calledRo.getFireSituation()); smsParams.put("fireSituation", calledRo.getFireSituation());
smsParams.put("trappedNum", calledRo.getTrappedNum()); smsParams.put("trappedNum", calledRo.getTrappedNum());
smsParams.put("casualtiesNum", calledRo.getCasualtiesNum()); smsParams.put("casualtiesNum", calledRo.getCasualtiesNum());
smsParams.put("dangerousExplosives", calledRo.getDangerousExplosives()); smsParams.put("dangerousExplosives", calledRo.getDangerousExplosives());
smsParams.put("companyName", calledRo.getCompanyName()); smsParams.put("companyName", calledRo.getCompanyName());
smsParams.put("contactUser", calledRo.getContactUser()); smsParams.put("contactUser", calledRo.getContactUser());
smsParams.put("contactPhone", calledRo.getContactPhone()); smsParams.put("contactPhone", calledRo.getContactPhone());
smsParams.put("replaceContent", calledRo.getReplaceContent()); smsParams.put("replaceContent", calledRo.getReplaceContent());
smsParams.put("alertType", calledRo.getAlertType()); smsParams.put("alertType", calledRo.getAlertType());
smsParams.put("feedback", calledRo.getFeedback()); smsParams.put("feedback", calledRo.getFeedback());
} }
// 短信报送对象 // 短信报送对象
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息 // 发送任务消息
// 组织短信内容 // 组织短信内容
// 调用短信发送接口 // 调用短信发送接口
if (alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) { if(alertWay.equals(AlertBusinessTypeEnum.警情初报.getCode())) {
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
} else { } else {
alertCalledAction.sendAlertCalleCmd(sCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(sCode, mobiles, smsParams);
} }
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
/** /**
*
* 短信报送 * 短信报送
* *
*
*
* @param alertSubmittedDto 警情信息 * @param alertSubmittedDto 警情信息
*
* @param userName 用户名 * @param userName 用户名
*
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Map<String,String> saveAlertSubmitted(AlertSubmittedDto alertSubmittedDto, String userName) {
public Map<String, String> saveAlertSubmitted(AlertSubmittedDto alertSubmittedDto, String userName) {
Long alertSubmittedId = alertSubmittedDto.getSequenceNbr(); Long alertSubmittedId = alertSubmittedDto.getSequenceNbr();
String alertWay = ""; String alertWay = "";
Map<String,String> map = new HashMap<>();
Map<String, String> map = new HashMap<>();
Set<String> mobiles = new HashSet<>(); Set<String> mobiles = new HashSet<>();
List<Long> userIds = new ArrayList<>(); List<Long> userIds = new ArrayList<>();
if (alertSubmittedId == null) { if (alertSubmittedId == null) {
// 1.保存警情记录主表 // 1.保存警情记录主表
AlertSubmitted alertSubmitted = new AlertSubmitted(); AlertSubmitted alertSubmitted = new AlertSubmitted();
String bussTypeCode; String bussTypeCode;
alertSubmitted.setAlertCalledId(alertSubmittedDto.getAlertCalledId()); alertSubmitted.setAlertCalledId(alertSubmittedDto.getAlertCalledId());
// 任务 4174 日常值班---融合调度----短信模版中的内容用户可以全部删除掉,按照自定义内容重新录入发送内容 by litw 2021年10月27日 // 任务 4174 日常值班---融合调度----短信模版中的内容用户可以全部删除掉,按照自定义内容重新录入发送内容 by litw 2021年10月27日
alertSubmitted.setBusinessTypeCode(alertSubmittedDto.getBusinessTypeCode()); alertSubmitted.setBusinessTypeCode(alertSubmittedDto.getBusinessTypeCode());
bussTypeCode = alertSubmittedDto.getBusinessTypeCode(); bussTypeCode = alertSubmittedDto.getBusinessTypeCode();
Optional<AlertBusinessTypeEnum> businessTypeEnum = EnumsUtils.getEnumObject(AlertBusinessTypeEnum.class, Optional<AlertBusinessTypeEnum> businessTypeEnum = EnumsUtils.getEnumObject(AlertBusinessTypeEnum.class,
e -> e.getCode().equals(bussTypeCode)); e -> e.getCode().equals(bussTypeCode));
alertSubmitted.setBusinessType(businessTypeEnum.get().getName()); alertSubmitted.setBusinessType(businessTypeEnum.get().getName());
alertSubmitted.setCallLogId(alertSubmittedDto.getCallLogId()); alertSubmitted.setCallLogId(alertSubmittedDto.getCallLogId());
alertSubmitted.setSubmissionMethodCode(alertSubmittedDto.getSubmissionMethodCode()); alertSubmitted.setSubmissionMethodCode(alertSubmittedDto.getSubmissionMethodCode());
Optional<SubmissionMethodEnum> submissionMethodEnum = EnumsUtils.getEnumObject(SubmissionMethodEnum.class, Optional<SubmissionMethodEnum> submissionMethodEnum = EnumsUtils.getEnumObject(SubmissionMethodEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getSubmissionMethodCode())); e -> e.getCode().equals(alertSubmittedDto.getSubmissionMethodCode()));
alertSubmitted.setSubmissionMethod(submissionMethodEnum.get().getName()); alertSubmitted.setSubmissionMethod(submissionMethodEnum.get().getName());
Optional<AlertSchedulingTypeEnum> alertSchedulingTypeEnum = Optional<AlertSchedulingTypeEnum> alertSchedulingTypeEnum =
EnumsUtils.getEnumObject(AlertSchedulingTypeEnum.class, EnumsUtils.getEnumObject(AlertSchedulingTypeEnum.class,
e -> e.getCode().equals(alertSubmittedDto.getSchedulingTypeCode())); e -> e.getCode().equals(alertSubmittedDto.getSchedulingTypeCode()));
alertSubmitted.setSchedulingTypeCode(alertSubmittedDto.getSchedulingTypeCode()); alertSubmitted.setSchedulingTypeCode(alertSubmittedDto.getSchedulingTypeCode());
alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName()); alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName());
// 任务 4174 日常值班---融合调度----短信模版中的内容用户可以全部删除掉,按照自定义内容重新录入发送内容 by litw 2021年10月27日 // 任务 4174 日常值班---融合调度----短信模版中的内容用户可以全部删除掉,按照自定义内容重新录入发送内容 by litw 2021年10月27日
alertSubmitted.setBusinessTypeCode(alertSubmittedDto.getBusinessTypeCode()); alertSubmitted.setBusinessTypeCode(alertSubmittedDto.getBusinessTypeCode());
alertSubmitted.setSubmissionContent(alertSubmittedDto.getSubmitContent().toJSONString()); alertSubmitted.setSubmissionContent(alertSubmittedDto.getSubmitContent().toJSONString());
alertSubmitted.setSender(userName); alertSubmitted.setSender(userName);
alertSubmitted.setRecUserName(userName); alertSubmitted.setRecUserName(userName);
alertSubmitted.setUpdateTime(new Date()); alertSubmitted.setUpdateTime(new Date());
alertSubmitted.setSubmissionTime(new Date()); alertSubmitted.setSubmissionTime(new Date());
this.baseMapper.insert(alertSubmitted); this.baseMapper.insert(alertSubmitted);
alertSubmittedId = alertSubmitted.getSequenceNbr(); alertSubmittedId = alertSubmitted.getSequenceNbr();
} }
// 2.保存任务表 // 2.保存任务表
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList(); List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
Long finalAlertSubmittedId = alertSubmittedId; Long finalAlertSubmittedId = alertSubmittedId;
// 报送给单位 // 报送给单位
if (AlertSubmitTypeEnum.Org.getKey().equals(alertSubmittedDto.getType())) { if (AlertSubmitTypeEnum.Org.getKey().equals(alertSubmittedDto.getType())) {
alertSubmittedDto.getSubmitCompanyList().forEach(company -> { alertSubmittedDto.getSubmitCompanyList().forEach(company -> {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(finalAlertSubmittedId); alertSubmittedObject.setAlertSubmittedId(finalAlertSubmittedId);
alertSubmittedObject.setType(true); alertSubmittedObject.setType(true);
alertSubmittedObject.setCompanyId(company.getCompanyId()); alertSubmittedObject.setCompanyId(company.getCompanyId());
alertSubmittedObject.setCompanyName(company.getCompanyName()); alertSubmittedObject.setCompanyName(company.getCompanyName());
alertSubmittedObject.setRecUserName(userName); alertSubmittedObject.setRecUserName(userName);
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
}); });
} else { } else {
// 报送给个人 // 报送给个人
alertSubmittedDto.getSubmitCompanyList().forEach(company -> { alertSubmittedDto.getSubmitCompanyList().forEach(company -> {
company.getPersonList().forEach(person -> { company.getPersonList().forEach(person -> {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(finalAlertSubmittedId); alertSubmittedObject.setAlertSubmittedId(finalAlertSubmittedId);
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setCompanyId(company.getCompanyId()); alertSubmittedObject.setCompanyId(company.getCompanyId());
alertSubmittedObject.setCompanyName(company.getCompanyName()); alertSubmittedObject.setCompanyName(company.getCompanyName());
alertSubmittedObject.setUserId(person.getPersonId()); alertSubmittedObject.setUserId(person.getPersonId());
userIds.add(person.getPersonId()); userIds.add(person.getPersonId());
alertSubmittedObject.setUserName(person.getPersonName()); alertSubmittedObject.setUserName(person.getPersonName());
alertSubmittedObject.setUserPhone(person.getPersonPhone()); alertSubmittedObject.setUserPhone(person.getPersonPhone());
alertSubmittedObject.setRecUserName(userName); alertSubmittedObject.setRecUserName(userName);
if (!ValidationUtil.isEmpty(person.getPersonPhone())) { if (!ValidationUtil.isEmpty(person.getPersonPhone())) {
mobiles.add(person.getPersonPhone()); mobiles.add(person.getPersonPhone());
} }
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
}); });
}); });
} }
// 查询AmousUserId // 查询AmousUserId
LambdaQueryWrapper<OrgUsr> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<OrgUsr> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(true, OrgUsr::getSequenceNbr, userIds); queryWrapper.in(true, OrgUsr::getSequenceNbr, userIds);
List<String> usIds = new ArrayList<>(); List<String> usIds = new ArrayList<>();
List<OrgUsr> list = orgUsrService.getBaseMapper().selectList(queryWrapper); List<OrgUsr> list = orgUsrService.getBaseMapper().selectList(queryWrapper);
if(null != list && list.size() > 0) {
if (null != list && list.size() > 0) { list.stream().forEach(e->{
if(!ValidationUtil.isEmpty(e.getAmosOrgId())) {
list.stream().forEach(e -> {
if (!ValidationUtil.isEmpty(e.getAmosOrgId())) {
usIds.add(e.getAmosOrgId()); usIds.add(e.getAmosOrgId());
} }
}); });
map.put("usIds", StringUtils.join(usIds.toArray(new String[userIds.size()]), ",")); map.put("usIds", StringUtils.join(usIds.toArray(new String[userIds.size()]),","));
} else { } else {
map.put("usIds", ""); map.put("usIds", "");
} }
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 3.更新警情状态 // 3.更新警情状态
alertCalledService.updateAlertCalled(alertSubmittedDto.getAlertCalledId(), alertCalledService.updateAlertCalled(alertSubmittedDto.getAlertCalledId(),
alertSubmittedDto.getBusinessTypeCode()); alertSubmittedDto.getBusinessTypeCode());
// 警情续报 // 警情续报
if(AlertBusinessTypeEnum.警情续报.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) {
if (AlertBusinessTypeEnum.警情续报.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) {
alertWay = AlertBusinessTypeEnum.警情续报.getCode(); alertWay = AlertBusinessTypeEnum.警情续报.getCode();
} }
if (AlertBusinessTypeEnum.警情结案.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) { if(AlertBusinessTypeEnum.警情结案.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) {
alertWay =AlertBusinessTypeEnum.警情结案.getCode();
alertWay = AlertBusinessTypeEnum.警情结案.getCode();
} }
if (AlertBusinessTypeEnum.非警情确认.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) { if(AlertBusinessTypeEnum.非警情确认.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) {
alertWay = AlertBusinessTypeEnum.非警情确认.getCode(); alertWay = AlertBusinessTypeEnum.非警情确认.getCode();
} }
if (AlertBusinessTypeEnum.警情结案.getCode().equals(alertSubmittedDto.getBusinessTypeCode())
if (AlertBusinessTypeEnum.警情结案.getCode().equals(alertSubmittedDto.getBusinessTypeCode())
|| AlertBusinessTypeEnum.非警情确认.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) { || AlertBusinessTypeEnum.非警情确认.getCode().equals(alertSubmittedDto.getBusinessTypeCode())) {
// 查询本次警情调派的车辆 // 查询本次警情调派的车辆
List<String> transferCarIdList = List<String> transferCarIdList =
powerTransferService.queryTransferCarIdsByAlertCalledId(alertSubmittedDto.getAlertCalledId()); powerTransferService.queryTransferCarIdsByAlertCalledId(alertSubmittedDto.getAlertCalledId());
List<Object> carStatusInfoDtoList = Lists.newArrayList(); List<Object> carStatusInfoDtoList = Lists.newArrayList();
if (!ValidationUtil.isEmpty(transferCarIdList)) { if (!ValidationUtil.isEmpty(transferCarIdList)) {
transferCarIdList.forEach(carId -> { transferCarIdList.forEach(carId -> {
CarStatusInfoDto carStatusInfo = new CarStatusInfoDto(); CarStatusInfoDto carStatusInfo = new CarStatusInfoDto();
carStatusInfo.setSequenceNbr(carId); carStatusInfo.setSequenceNbr(carId);
carStatusInfo.setStatus(FireCarStatusEnum.执勤.getCode()); carStatusInfo.setStatus(FireCarStatusEnum.执勤.getCode());
carStatusInfoDtoList.add(carStatusInfo); carStatusInfoDtoList.add(carStatusInfo);
}); });
} }
// 修改调派车辆任务 //修改调派车辆任务
powerTransferCompanyResourcesService.updateByAlertCalledId(alertSubmittedDto.getAlertCalledId()); powerTransferCompanyResourcesService.updateByAlertCalledId(alertSubmittedDto.getAlertCalledId());
// 更新所有车辆状态为执勤 // 更新所有车辆状态为执勤
equipFeignClient.updateCarStatus(carStatusInfoDtoList); equipFeignClient.updateCarStatus(carStatusInfoDtoList);
// //跟车辆状态 // //跟车辆状态
// powerTransferCompanyResourcesService.update(new UpdateWrapper<PowerTransferCompanyResources>().eq("resources_id", transferCarIdList).set("status", FireCarStatusEnum.返队.getCode())); // powerTransferCompanyResourcesService.update(new UpdateWrapper<PowerTransferCompanyResources>().eq("resources_id", transferCarIdList).set("status", FireCarStatusEnum.返队.getCode()));
} }
// 4.发送任务消息 // 4.发送任务消息
// 4.1组织短信内容 废弃 // 4.1组织短信内容 废弃
JSONObject submitContent = alertSubmittedDto.getSubmitContent(); JSONObject submitContent = alertSubmittedDto.getSubmitContent();
String feedBack = submitContent.get("editContent") != null ? submitContent.get("editContent").toString() : ""; String feedBack = submitContent.get("editContent") != null ? submitContent.get("editContent").toString(): "";
// 4.2调用短信发送接口 废弃
// 4.2调用短信发送接口 废弃
// alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);\ // alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);\
map.put("feedBack", feedBack); map.put("feedBack",feedBack);
map.put("alertWay",alertWay);
map.put("alertWay", alertWay); map.put("mobiles", StringUtils.join(mobiles,","));
map.put("mobiles", StringUtils.join(mobiles, ","));
return map; return map;
} }
/** /**
*
* 短信报送对象 * 短信报送对象
* *
*
*
* @param alertSubmittedObjectList 报送对象列表 * @param alertSubmittedObjectList 报送对象列表
*
* @param smsCode 短信模板code * @param smsCode 短信模板code
*
* @param mobiles 电话号码列表 * @param mobiles 电话号码列表
*
* @param smsParams 报送内容 * @param smsParams 报送内容
*
*/ */
public void saveAlertSubmittedObject(List<AlertSubmittedObject> alertSubmittedObjectList, String smsCode, public void saveAlertSubmittedObject(List<AlertSubmittedObject> alertSubmittedObjectList, String smsCode,
Set<String> mobiles, HashMap<String, String> smsParams) { Set<String> mobiles, HashMap<String, String> smsParams) {
// alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息 // 发送任务消息
// 组织短信内容 // 组织短信内容
// 调用短信发送接口 // 调用短信发送接口
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
} }
public void getAlertSubmittedContent(Long alertCalledId, ArrayList<TemplateDto> templateDtos, String companyName) public void getAlertSubmittedContent(Long alertCalledId, ArrayList<TemplateDto> templateDtos, String companyName) throws IllegalAccessException, ParseException {
throws IllegalAccessException, ParseException {
AlertCalled alertCalled = alertCalledService.getById(alertCalledId); AlertCalled alertCalled = alertCalledService.getById(alertCalledId);
Map<String, Object> map = objectToMap(alertCalled); Map<String, Object> map = objectToMap(alertCalled);
map.put("companyName", companyName); map.put("companyName", companyName);
map.put("editContent", "可自编辑续报内容"); map.put("editContent", "可自编辑续报内容");
AlertCalledObjsDto alertCalledVo = (AlertCalledObjsDto) alertCalledService AlertCalledObjsDto alertCalledVo = (AlertCalledObjsDto) alertCalledService.selectAlertCalledByIdNoRedisNew(alertCalled.getSequenceNbr());
.selectAlertCalledByIdNoRedisNew(alertCalled.getSequenceNbr());
/** /**
*
* 构建警情报送规则对象 * 构建警情报送规则对象
*
*/ */
AlertCalledRo alertCalledRo = new AlertCalledRo(); AlertCalledRo alertCalledRo = new AlertCalledRo();
String replaceContent = RuleAlertCalledService.init(alertCalledRo, alertCalledVo); String replaceContent = RuleAlertCalledService.init(alertCalledRo,alertCalledVo);
// 获取模板内容 // 获取模板内容
List<DataDictionary> dataDictionaries = List<DataDictionary> dataDictionaries =
dataDictionaryService.list(new QueryWrapper<DataDictionary>().eq("type", dataDictionaryService.list(new QueryWrapper<DataDictionary>().eq("type",
"JQBSLX")); "JQBSLX"));
for (DataDictionary dataDictionary : dataDictionaries) { for (DataDictionary dataDictionary : dataDictionaries) {
Template template = templateService.getOne(new QueryWrapper<Template>().eq("type_code", Template template = templateService.getOne(new QueryWrapper<Template>().eq("type_code",
dataDictionary.getCode()).eq("format", true)); dataDictionary.getCode()).eq("format", true));
Map<String, String> definitions = new HashMap<>(); Map<String, String> definitions = new HashMap<>();
definitions.put("$type",alertCalled.getAlertType());
definitions.put("$type", alertCalled.getAlertType()); definitions.put("$callTime",DateUtils.dateTimeToDateString(alertCalled.getCallTime()));
definitions.put("$replaceContent",replaceContent);
definitions.put("$callTime", DateUtils.dateTimeToDateString(alertCalled.getCallTime())); definitions.put("$address",alertCalled.getAddress());
String content = getTaskInformation( template.getContent(),definitions);
definitions.put("$replaceContent", replaceContent);
definitions.put("$address", alertCalled.getAddress());
String content = getTaskInformation(template.getContent(), definitions);
template.setContent(content); template.setContent(content);
TemplateDto templateDto = new TemplateDto(); TemplateDto templateDto = new TemplateDto();
BeanUtils.copyProperties(template, templateDto); BeanUtils.copyProperties(template, templateDto);
templateDto.setData(map); templateDto.setData(map);
templateDtos.add(templateDto); templateDtos.add(templateDto);
} }
} }
private String getTaskInformation(String content, Map<String, String> definitions) { private String getTaskInformation(String content, Map<String, String> definitions) {
int size = definitions.size(); int size = definitions.size();
String[] keys = definitions.keySet().toArray(new String[size]); String[] keys = definitions.keySet().toArray(new String[size]);
String[] values = definitions.values().toArray(new String[size]); String[] values = definitions.values().toArray(new String[size]);
return StringUtils.replaceEach(content, keys, values); return StringUtils.replaceEach(content, keys, values);
} }
@Override @Override
public AlertSubmittedSMSDto getSchedulingContent(Long id) { public AlertSubmittedSMSDto getSchedulingContent(Long id) {
return this.baseMapper.getSchedulingContent(id); return this.baseMapper.getSchedulingContent(id);
} }
@Override @Override
public List<InstructionsZHDto> getInstructionsZHDtoList(Long id) { public List<InstructionsZHDto> getInstructionsZHDtoList(Long id) {
List<InstructionsZHDto> listInstructionsZHDto = new ArrayList<>(); List<InstructionsZHDto> listInstructionsZHDto = new ArrayList<>();
// 获取调派记录 //获取调派记录
List<PowerTransferCompanyZHDto> listPowerTransferCompanyZHDto = powerTransferCompanyMapper.listPowerTransferCompanyZHDto(id);
List<PowerTransferCompanyZHDto> listPowerTransferCompanyZHDto = powerTransferCompanyMapper
.listPowerTransferCompanyZHDto(id);
listPowerTransferCompanyZHDto.stream().forEach(PowerTransferCompanyZHDto -> { listPowerTransferCompanyZHDto.stream().forEach(PowerTransferCompanyZHDto -> {
String content = ""; String content = "";
if (PowerTransferCompanyZHDto.getIsDistributionAgencies()) { if (PowerTransferCompanyZHDto.getIsDistributionAgencies()) {
content = "调派" + PowerTransferCompanyZHDto.getCompanyName() + "前往" + PowerTransferCompanyZHDto.getAddress();
content = "调派" + PowerTransferCompanyZHDto.getCompanyName() + "前往"
+ PowerTransferCompanyZHDto.getAddress();
} else { } else {
content = "调派" + PowerTransferCompanyZHDto.getCompanyName() + PowerTransferCompanyZHDto.getSubmissionContent() + "前往" + PowerTransferCompanyZHDto.getAddress();
content = "调派" + PowerTransferCompanyZHDto.getCompanyName()
+ PowerTransferCompanyZHDto.getSubmissionContent() + "前往"
+ PowerTransferCompanyZHDto.getAddress();
} }
InstructionsZHDto instruct = new InstructionsZHDto(PowerTransferCompanyZHDto.getSequenceNbr(), PowerTransferCompanyZHDto.getDispatchType(), PowerTransferCompanyZHDto.getRecDate(), content, null);
InstructionsZHDto instruct = new InstructionsZHDto(PowerTransferCompanyZHDto.getSequenceNbr(),
PowerTransferCompanyZHDto.getDispatchType(), PowerTransferCompanyZHDto.getRecDate(), content, null);
listInstructionsZHDto.add(instruct); listInstructionsZHDto.add(instruct);
}); });
// 获取融合调度信息
//获取融合调度信息
List<AlertSubmittedZHDto> listAlertSubmittedZHDto = alertSubmittedMapper.listAlertSubmittedZHDto(id); List<AlertSubmittedZHDto> listAlertSubmittedZHDto = alertSubmittedMapper.listAlertSubmittedZHDto(id);
listAlertSubmittedZHDto.stream().forEach(AlertSubmittedZHDto -> { listAlertSubmittedZHDto.stream().forEach(AlertSubmittedZHDto -> {
JSONObject js = JSONObject.parseObject(AlertSubmittedZHDto.getSubmissionContent()); JSONObject js = JSONObject.parseObject(AlertSubmittedZHDto.getSubmissionContent());
String content = ""; String content = "";
switch (AlertSubmittedZHDto.getBusinessType()) { switch (AlertSubmittedZHDto.getBusinessType()) {
case "警情初报": case "警情初报":
content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + ","
+ js.getString("address") + "发生" + js.getString("alertType");
break; content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + "," + js.getString("address") + "发生" + js.getString("alertType");
break;
case "警情续报": case "警情续报":
content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + "," content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + "," + "现场被困人数:" + js.getString("trappedNum") + "人伤亡人数:" + js.getString("casualtiesNum") + "人。";
+ "现场被困人数:" + js.getString("trappedNum") + "人伤亡人数:" + js.getString("casualtiesNum") + "人。";
break; break;
case "非警情确认": case "非警情确认":
content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + "," content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + "," + "此警情现场确认为假警情。";
+ "此警情现场确认为假警情。";
break; break;
case "警情结案": case "警情结案":
content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + "," + "此警情已完场警情处置,警情已结案。";
content = "通知" + AlertSubmittedZHDto.getCompanyName() + ":" + AlertSubmittedZHDto.getUserName() + ","
+ "此警情已完场警情处置,警情已结案。";
break; break;
default: default:
break; break;
} }
InstructionsZHDto instruct = new InstructionsZHDto(AlertSubmittedZHDto.getSequenceNbr(), AlertSubmittedZHDto.getBusinessType(), AlertSubmittedZHDto.getSubmissionTime(), content,null);
InstructionsZHDto instruct = new InstructionsZHDto(AlertSubmittedZHDto.getSequenceNbr(),
AlertSubmittedZHDto.getBusinessType(), AlertSubmittedZHDto.getSubmissionTime(), content, null);
listInstructionsZHDto.add(instruct); listInstructionsZHDto.add(instruct);
}); });
// 获取归并得警情信息 // 获取归并得警情信息
LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper(); LambdaQueryWrapper<AlertCalled> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(AlertCalled::getFatherAlert,id);
queryWrapper.eq(AlertCalled::getFatherAlert, id);
List<AlertCalled> alertCalleds = alertCalledService.getBaseMapper().selectList(queryWrapper); List<AlertCalled> alertCalleds = alertCalledService.getBaseMapper().selectList(queryWrapper);
alertCalleds.stream().forEach(e->{
alertCalleds.stream().forEach(e -> {
AlertSubmittedZHDto alertSubmittedZHDto = new AlertSubmittedZHDto(); AlertSubmittedZHDto alertSubmittedZHDto = new AlertSubmittedZHDto();
AlertCalledFormDto alertCalledFormDto = (AlertCalledFormDto) alertCalledService.selectAlertCalledByIdNoRedis(e.getSequenceNbr());
AlertCalledFormDto alertCalledFormDto = (AlertCalledFormDto) alertCalledService
.selectAlertCalledByIdNoRedis(e.getSequenceNbr());
alertSubmittedZHDto.setAlertCalledFormDto(alertCalledFormDto); alertSubmittedZHDto.setAlertCalledFormDto(alertCalledFormDto);
alertSubmittedZHDto.setSequenceNbr(e.getSequenceNbr()); alertSubmittedZHDto.setSequenceNbr(e.getSequenceNbr());
alertSubmittedZHDto.setBusinessType("警情归并"); alertSubmittedZHDto.setBusinessType("警情归并");
alertSubmittedZHDto.setSubmissionTime(alertCalledFormDto.getAlertCalled().getCallTime()); alertSubmittedZHDto.setSubmissionTime(alertCalledFormDto.getAlertCalled().getCallTime());
alertSubmittedZHDto.setCompanyName(alertCalledFormDto.getAlertCalled().getCompanyName()); alertSubmittedZHDto.setCompanyName(alertCalledFormDto.getAlertCalled().getCompanyName());
alertSubmittedZHDto.setUserName(alertCalledFormDto.getAlertCalled().getRecUserName()); alertSubmittedZHDto.setUserName(alertCalledFormDto.getAlertCalled().getRecUserName());
InstructionsZHDto instruct = new InstructionsZHDto(alertSubmittedZHDto.getSequenceNbr(), alertSubmittedZHDto.getBusinessType(), alertSubmittedZHDto.getSubmissionTime(), null, alertSubmittedZHDto.getAlertCalledFormDto());
InstructionsZHDto instruct = new InstructionsZHDto(alertSubmittedZHDto.getSequenceNbr(),
alertSubmittedZHDto.getBusinessType(), alertSubmittedZHDto.getSubmissionTime(), null,
alertSubmittedZHDto.getAlertCalledFormDto());
listInstructionsZHDto.add(instruct); listInstructionsZHDto.add(instruct);
}); });
// 排序时间倒序 //排序时间倒序
/* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 开始*/
/* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 开始 */
Collections.sort(listInstructionsZHDto, new Comparator<InstructionsZHDto>() { Collections.sort(listInstructionsZHDto, new Comparator<InstructionsZHDto>() {
@Override @Override
public int compare(InstructionsZHDto o1, InstructionsZHDto o2) { public int compare(InstructionsZHDto o1, InstructionsZHDto o2) {
long i = o2.getSubmissionTime().getTime() - o1.getSubmissionTime().getTime(); long i = o2.getSubmissionTime().getTime() - o1.getSubmissionTime().getTime();
if (i == 0) { if (i == 0) {
return (int) (o2.getSubmissionTime().getTime() - o1.getSubmissionTime().getTime()); return (int) (o2.getSubmissionTime().getTime() - o1.getSubmissionTime().getTime());
} }
return (int) i; return (int) i;
} }
}); });
/* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 结束*/
/* Bug 2613 修改排序 按照发送时间排序 2021-09-01 陈召 结束 */
return listInstructionsZHDto; return listInstructionsZHDto;
} }
/** /**
*
* 将Object对象里面的属性和值转化成Map对象 * 将Object对象里面的属性和值转化成Map对象
* *
*
*
* @param obj 源对象 * @param obj 源对象
*
* @return 转化结果 * @return 转化结果
*
* @throws IllegalAccessException IllegalAccessException * @throws IllegalAccessException IllegalAccessException
*
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException { public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
Class<?> clazz = obj.getClass(); Class<?> clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields(); Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
field.setAccessible(true); field.setAccessible(true);
String fieldName = field.getName(); String fieldName = field.getName();
if ("dynamicFormAlert".equalsIgnoreCase(fieldName)) { if ("dynamicFormAlert".equalsIgnoreCase(fieldName)) {
List<FormValue> dynamicFormAlert = (List<FormValue>) field.get(obj); List<FormValue> dynamicFormAlert = (List<FormValue>) field.get(obj);
for (FormValue formValue : dynamicFormAlert) { for (FormValue formValue : dynamicFormAlert) {
map.put(formValue.getLabel(), formValue.getValue()); map.put(formValue.getLabel(), formValue.getValue());
} }
} else { } else {
Object value = field.get(obj); Object value = field.get(obj);
map.put(fieldName, value); map.put(fieldName, value);
} }
} }
return map; return map;
} }
@SuppressWarnings("unchecked")
public void ruleCallbackActionForPowerTransferForCar(String smsCode, List sendIds, Object object)
@SuppressWarnings("unchecked")
public void ruleCallbackActionForPowerTransferForCar(String smsCode, List sendIds, Object object)
throws IllegalAccessException, MqttPersistenceException, MqttException { throws IllegalAccessException, MqttPersistenceException, MqttException {
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList(); List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
Set<String> mobiles = new HashSet<>(); Set<String> mobiles = new HashSet<>();
HashMap<String, String> smsParams = new HashMap<>(); HashMap<String, String> smsParams = new HashMap<>();
String alertCalledId = null; String alertCalledId = null;
Set<Map<String, Object>> userIdList = new HashSet<Map<String, Object>>(); Set<Map<String, Object>> userIdList = new HashSet<Map<String, Object>>();
// 判断当前的规则中是否指定了给当前的车辆驾驶员 // 判断当前的规则中是否指定了给当前的车辆驾驶员
boolean designatedDriver = false; boolean designatedDriver = false;
for (Object id : sendIds) { for (Object id : sendIds) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(id)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(id));
if (jsonObject.containsKey("type") && jsonObject.getString("type").equals(AlertStageEnums.BD.getCode())) { if (jsonObject.containsKey("type") && jsonObject.getString("type").equals(AlertStageEnums.BD.getCode())) {
designatedDriver = true; designatedDriver = true;
} }
} }
List<Map<String, Object>> orgUsers = new LinkedList<>(); List<Map<String, Object>> orgUsers = new LinkedList<>();
String sCode = ""; String sCode = "";
if (object instanceof AlertCallePowerTransferRo) { if (object instanceof AlertCallePowerTransferRo) {
AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object; AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object;
String alertSubmittedId = calledRo.getAlertSubmittedId(); String alertSubmittedId = calledRo.getAlertSubmittedId();
alertCalledId = calledRo.getSequenceNbr(); alertCalledId = calledRo.getSequenceNbr();
//先获取消救部领导、消救部值班人员信息
// 先获取消救部领导、消救部值班人员信息
sendIds.stream().forEach(e -> { sendIds.stream().forEach(e -> {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e));
// 消救部 // 消救部
if (jsonObject.containsKey("airportUnit")) {
String departmentName = jsonObject.getString("name");
if (jsonObject.containsKey("airportUnit")) { if (jsonObject.containsKey("airportUnit")) {
{ String departmentName= jsonObject.getString("name");
if (jsonObject.containsKey("airportUnit")) { {
List<Map<String, Object>> mapList = dynamicFormInstanceMapper List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getFireRescueDepartmentStaff(departmentName,null);
.getFireRescueDepartmentStaff(departmentName, null);
userIdList.addAll(mapList); userIdList.addAll(mapList);
} }
if (jsonObject.containsKey("onDuty")) { if(jsonObject.containsKey("onDuty")) {
List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(),departmentName);
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(), departmentName);
userIdList.addAll(mapList); userIdList.addAll(mapList);
} }
} }
} }
}); });
List<Object> companyDetail = JSONArray.parseArray(JSON.toJSON(calledRo.getCompany()).toString(),Object.class);
List<Object> companyDetail = JSONArray.parseArray(JSON.toJSON(calledRo.getCompany()).toString(),
Object.class);
for (Object powerTransferCompanyDto : companyDetail) { for (Object powerTransferCompanyDto : companyDetail) {
PowerTransferCompanyDto powerDto = JSONObject.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
PowerTransferCompanyDto powerDto = JSONObject
.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
Long companyId = powerDto.getCompanyId(); Long companyId = powerDto.getCompanyId();
String companyName = powerDto.getCompanyName(); String companyName = powerDto.getCompanyName();
StringBuffer resourcesNum = new StringBuffer(); StringBuffer resourcesNum = new StringBuffer();
Set<Map<String, Object>> sendUserIds = new HashSet<Map<String, Object>>(); Set<Map<String, Object>> sendUserIds = new HashSet<Map<String, Object>>();
//FireTeam fireTeam= fireTeamServiceImpl.getById(companyId);
// FireTeam fireTeam= fireTeamServiceImpl.getById(companyId);
String alertTypeCode = calledRo.getAlertTypeCode(); String alertTypeCode = calledRo.getAlertTypeCode();
FireTeam fireTeam= fireTeamServiceImpl.getById(companyId);
FireTeam fireTeam = fireTeamServiceImpl.getById(companyId);
sendIds.stream().forEach(e -> { sendIds.stream().forEach(e -> {
JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(e)); JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(e));
if (jsonObject1.containsKey("type") && (jsonObject1.getString("type").equals(AlertStageEnums.DD.getCode()))) {
String [] groupCode = jsonObject1.getString("fireBrigade").split(",");
List<String> positionType= Arrays.asList(groupCode);
if (jsonObject1.containsKey("fireBrigade")) { {
if (jsonObject1.containsKey("type") List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getFireRescueDepartmentStaff(fireTeam.getCompanyName(),positionType);
&& (jsonObject1.getString("type").equals(AlertStageEnums.DD.getCode()))) {
String[] groupCode = jsonObject1.getString("fireBrigade").split(",");
List<String> positionType = Arrays.asList(groupCode);
if (jsonObject1.containsKey("fireBrigade")) {
{
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getFireRescueDepartmentStaff(fireTeam.getCompanyName(), positionType);
sendUserIds.addAll(mapList); sendUserIds.addAll(mapList);
} }
if(jsonObject1.containsKey("onDuty")) {
if (jsonObject1.containsKey("onDuty")) { List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(),fireTeam.getCompanyName());
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(),
fireTeam.getCompanyName());
sendUserIds.addAll(mapList); sendUserIds.addAll(mapList);
} }
} }
}else if (jsonObject1.containsKey("type") && (jsonObject1.getString("type").equals(AlertStageEnums.ZD.getCode()))) {
} else if (jsonObject1.containsKey("type") String [] groupCode = jsonObject1.get("fireBrigade").toString().split(",");
&& (jsonObject1.getString("type").equals(AlertStageEnums.ZD.getCode()))) { List<String> positionType= Arrays.asList(groupCode);
String departmentName= jsonObject1.getString("name");
String[] groupCode = jsonObject1.get("fireBrigade").toString().split(","); if (jsonObject1.containsKey("fireBrigade")) { {
List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getFireRescueDepartmentStaff(departmentName,positionType);
List<String> positionType = Arrays.asList(groupCode);
String departmentName = jsonObject1.getString("name");
if (jsonObject1.containsKey("fireBrigade")) {
{
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getFireRescueDepartmentStaff(departmentName, positionType);
sendUserIds.addAll(mapList); sendUserIds.addAll(mapList);
} }
if(jsonObject1.containsKey("onDuty")) {
if (jsonObject1.containsKey("onDuty")) { List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(),departmentName);
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(), departmentName);
sendUserIds.addAll(mapList); sendUserIds.addAll(mapList);
} }
} }
} }
}); });
sendUserIds.addAll(userIdList); sendUserIds.addAll(userIdList);
smsCode = AlertBusinessTypeEnum.力量调派.getSms_code(); smsCode = AlertBusinessTypeEnum.力量调派.getSms_code();
// 组装人员信息 // 组装人员信息
for (Map<String, Object> orgUser : sendUserIds) { for (Map<String, Object> orgUser : sendUserIds) {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId)); alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId));
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setCompanyId(companyId); alertSubmittedObject.setCompanyId(companyId);
alertSubmittedObject.setCompanyName(companyName); alertSubmittedObject.setCompanyName(companyName);
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString())); alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString()));
alertSubmittedObject.setUserName(orgUser.get("userName").toString()); alertSubmittedObject.setUserName(orgUser.get("userName").toString());
if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) { if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone")); mobiles.add((String) orgUser.get("telephone"));
alertSubmittedObject.setUserPhone((String) orgUser.get("telephone")); alertSubmittedObject.setUserPhone((String) orgUser.get("telephone"));
} }
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
} }
smsParams.put("callTimeStr", calledRo.getCallTimeStr()); smsParams.put("callTimeStr", calledRo.getCallTimeStr());
smsParams.put("address", calledRo.getAddress()); smsParams.put("address", calledRo.getAddress());
smsParams.put("content", calledRo.getContent()); smsParams.put("content", calledRo.getContent());
smsParams.put("trappedNum", calledRo.getTrappedNum()); smsParams.put("trappedNum", calledRo.getTrappedNum());
smsParams.put("casualtiesNum", calledRo.getCasualtiesNum()); smsParams.put("casualtiesNum", calledRo.getCasualtiesNum());
smsParams.put("companyName", calledRo.getCompanyName()); smsParams.put("companyName", calledRo.getCompanyName());
smsParams.put("contactUser", calledRo.getContactUser()); smsParams.put("contactUser", calledRo.getContactUser());
smsParams.put("contactPhone", calledRo.getContactPhone()); smsParams.put("contactPhone", calledRo.getContactPhone());
smsParams.put("alertType", calledRo.getAlertType()); smsParams.put("alertType", calledRo.getAlertType());
List<PowerTransferCompanyResourcesDto> list = powerDto List<PowerTransferCompanyResourcesDto> list = powerDto
.getPowerTransferCompanyResourcesDtoList(); .getPowerTransferCompanyResourcesDtoList();
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
for (PowerTransferCompanyResourcesDto i : list) { for (PowerTransferCompanyResourcesDto i : list) {
String carName = i.getResourcesName(); String carName = i.getResourcesName();
String resourceName = i.getResourcesNum(); String resourceName = i.getResourcesNum();
String type = i.getType(); String type = i.getType();
resourcesNum.append("车辆" + type); resourcesNum.append("车辆" + type);
resourcesNum.append("车牌号" + carName + " " + resourceName); resourcesNum.append("车牌号" + carName + " " + resourceName);
resourcesNum.append("、"); resourcesNum.append("、");
if (designatedDriver) { if (designatedDriver) {
// 发送单个车辆的信息数据到客户 // 发送单个车辆的信息数据到客户
smsParams.put("resourcesNum", smsParams.put("resourcesNum",
resourcesNum.toString().substring(resourcesNum.toString().length() - 2)); resourcesNum.toString().substring(resourcesNum.toString().length() - 2));
List<AlertSubmittedObject> alertSubmittedObjectListSub = Lists.newArrayList(); List<AlertSubmittedObject> alertSubmittedObjectListSub = Lists.newArrayList();
Map<String, Object> map = dynamicFormInstanceMapper Map<String, Object> map = dynamicFormInstanceMapper
.getCurentCarIsUserPhone(Long.parseLong(i.getResourcesId())); .getCurentCarIsUserPhone(Long.parseLong(i.getResourcesId()));
AlertSubmittedObject alertSubmittedObjectSub = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObjectSub = new AlertSubmittedObject();
alertSubmittedObjectSub.setAlertSubmittedId(Long.parseLong(alertSubmittedId)); alertSubmittedObjectSub.setAlertSubmittedId(Long.parseLong(alertSubmittedId));
alertSubmittedObjectSub.setType(false); alertSubmittedObjectSub.setType(false);
alertSubmittedObjectSub.setCompanyId(companyId); alertSubmittedObjectSub.setCompanyId(companyId);
alertSubmittedObjectSub.setCompanyName(companyName); alertSubmittedObjectSub.setCompanyName(companyName);
alertSubmittedObjectSub.setType(false); alertSubmittedObjectSub.setType(false);
if(map==null || !map.containsKey("userId")) {
if (map == null || !map.containsKey("userId")) {
continue; continue;
} }
alertSubmittedObjectSub.setUserId(Long.parseLong(map.get("userId").toString())); alertSubmittedObjectSub.setUserId(Long.parseLong(map.get("userId").toString()));
alertSubmittedObjectSub.setUserName(map.get("userName").toString()); alertSubmittedObjectSub.setUserName(map.get("userName").toString());
Set<String> mobile =null;
Set<String> mobile = null;
if (!ValidationUtil.isEmpty(map.get("mobilePhone"))) { if (!ValidationUtil.isEmpty(map.get("mobilePhone"))) {
mobile = new HashSet<String>() { mobile = new HashSet<String>() {
{ {
add(map.get("mobilePhone").toString()); add(map.get("mobilePhone").toString());
} }
}; };
alertSubmittedObjectSub.setUserPhone(map.get("mobilePhone").toString()); alertSubmittedObjectSub.setUserPhone(map.get("mobilePhone").toString());
} }
alertSubmittedObjectListSub.add(alertSubmittedObjectSub); alertSubmittedObjectListSub.add(alertSubmittedObjectSub);
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectListSub); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectListSub);
// 调用短信发送接口 // 调用短信发送接口
alertCalledAction.sendAlertCalleCmd(sCode, mobile, smsParams); alertCalledAction.sendAlertCalleCmd(sCode, mobile, smsParams);
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS,
false); false);
} }
} }
} }
String resourcesNumStr = resourcesNum.toString(); String resourcesNumStr = resourcesNum.toString();
sendUserIds.stream().forEach(i -> { sendUserIds.stream().forEach(i -> {
if (i.containsKey("mobilePhone")) { if (i.containsKey("mobilePhone")) {
mobiles.add(i.get("mobilePhone").toString()); mobiles.add(i.get("mobilePhone").toString());
} }
}); });
smsParams.put("resourcesNum", resourcesNumStr.substring(resourcesNumStr.length() - 2)); smsParams.put("resourcesNum", resourcesNumStr.substring(resourcesNumStr.length() - 2));
// 短信报送对象 // 短信报送对象
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息 // 发送任务消息
// 组织短信内容 // 组织短信内容
// 调用短信发送接口 // 调用短信发送接口
try { try {
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
} catch (Exception e) { } catch (Exception e) {
} }
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void ruleCallbackActionForPowerTransferForSurvBrigade(String smsCode, List sendIds, Object object) throws MqttPersistenceException, MqttException {
public void ruleCallbackActionForPowerTransferForSurvBrigade(String smsCode, List sendIds, Object object)
throws MqttPersistenceException, MqttException {
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList(); List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
Set<String> mobiles = new HashSet<>(); Set<String> mobiles = new HashSet<>();
HashMap<String, String> smsParams = new HashMap<>(); HashMap<String, String> smsParams = new HashMap<>();
String alertCalledId = null; String alertCalledId = null;
if (object instanceof AlertCallePowerTransferRo) { if (object instanceof AlertCallePowerTransferRo) {
AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object; AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object;
String alertSubmittedId = calledRo.getAlertSubmittedId(); String alertSubmittedId = calledRo.getAlertSubmittedId();
alertCalledId = calledRo.getSequenceNbr(); alertCalledId = calledRo.getSequenceNbr();
Set<Map<String, Object>> userIds = new HashSet<Map<String, Object>>(); Set<Map<String, Object>> userIds = new HashSet<Map<String, Object>>();
List<Object> companyDetail =JSONArray.parseArray(JSON.toJSON(calledRo.getCompany()).toString(),Object.class);
List<Object> companyDetail = JSONArray.parseArray(JSON.toJSON(calledRo.getCompany()).toString(), for(Object e:sendIds) {
Object.class);
for (Object e : sendIds) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e));
if(jsonObject.containsKey("type") &&( (jsonObject.getString("type").equals(AlertStageEnums.ZH.getCode())) || jsonObject.getString("type").equals(AlertStageEnums.XJ.getCode()))) {
if (jsonObject.containsKey("type") String departmentName= jsonObject.getString("name");
&& ((jsonObject.getString("type").equals(AlertStageEnums.ZH.getCode())) if (jsonObject.containsKey("airportUnit")) { {
|| jsonObject.getString("type").equals(AlertStageEnums.XJ.getCode()))) { List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getFireRescueDepartmentStaff(departmentName,null);
String departmentName = jsonObject.getString("name");
if (jsonObject.containsKey("airportUnit")) {
{
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getFireRescueDepartmentStaff(departmentName, null);
userIds.addAll(mapList); userIds.addAll(mapList);
} }
if(jsonObject.containsKey("onDuty")) {
if (jsonObject.containsKey("onDuty")) { List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(),departmentName);
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(), departmentName);
userIds.addAll(mapList); userIds.addAll(mapList);
} }
} }
} }
} }
for (Object powerTransferCompanyDto : companyDetail) { for (Object powerTransferCompanyDto : companyDetail) {
Set<Map<String, Object>> sendUserIds = new HashSet<Map<String, Object>>(); Set<Map<String, Object>> sendUserIds = new HashSet<Map<String, Object>>();
PowerTransferCompanyDto powerDto = JSONObject.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
PowerTransferCompanyDto powerDto = JSONObject
.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
Long companyId = powerDto.getCompanyId(); Long companyId = powerDto.getCompanyId();
String companyName = powerDto.getCompanyName(); String companyName = powerDto.getCompanyName();
FireTeam fireTeam= fireTeamServiceImpl.getById(companyId);
FireTeam fireTeam = fireTeamServiceImpl.getById(companyId); for(Object sendObject:sendIds) {
for (Object sendObject : sendIds) {
JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(sendObject)); JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(sendObject));
if (jsonObject1.containsKey("type") && (jsonObject1.getString("type").equals(AlertStageEnums.监控大队.getCode()))) {
if (jsonObject1.containsKey("type") if(jsonObject1.containsKey("onDuty")) {
&& (jsonObject1.getString("type").equals(AlertStageEnums.监控大队.getCode()))) { List<Map<String, Object>> dutyList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndCarId(
if (jsonObject1.containsKey("onDuty")) {
List<Map<String, Object>> dutyList = dynamicFormInstanceMapper
.getDutyPersonByTeamIdAndCarId(
DateUtils.getDateNowShortStr(), fireTeam.getCompanyName()); DateUtils.getDateNowShortStr(), fireTeam.getCompanyName());
sendUserIds.addAll(dutyList); sendUserIds.addAll(dutyList);
} }
if (jsonObject1.containsKey("airportUnit")) { {
if (jsonObject1.containsKey("airportUnit")) { List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getFireRescueDepartmentStaff( fireTeam.getCompanyName(),null);
{
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getFireRescueDepartmentStaff(fireTeam.getCompanyName(), null);
sendUserIds.addAll(mapList); sendUserIds.addAll(mapList);
} }
} }
} }
} }
sendUserIds.addAll(userIds); sendUserIds.addAll(userIds);
smsCode = AlertBusinessTypeEnum.力量调派.getSms_code(); smsCode = AlertBusinessTypeEnum.力量调派.getSms_code();
// 组装人员信息 // 组装人员信息
for (Map<String, Object> orgUser : sendUserIds) { for (Map<String, Object> orgUser : sendUserIds) {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId)); alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId));
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setCompanyId(companyId); alertSubmittedObject.setCompanyId(companyId);
alertSubmittedObject.setCompanyName(companyName); alertSubmittedObject.setCompanyName(companyName);
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString())); alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString()));
alertSubmittedObject.setUserName(orgUser.get("userName").toString()); alertSubmittedObject.setUserName(orgUser.get("userName").toString());
if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) { if (!ValidationUtil.isEmpty(orgUser.get("telephone"))) {
mobiles.add((String) orgUser.get("telephone")); mobiles.add((String) orgUser.get("telephone"));
alertSubmittedObject.setUserPhone((String) orgUser.get("telephone")); alertSubmittedObject.setUserPhone((String) orgUser.get("telephone"));
} }
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
} }
smsParams.put("callTimeStr", calledRo.getCallTimeStr()); smsParams.put("callTimeStr", calledRo.getCallTimeStr());
smsParams.put("address", calledRo.getAddress()); smsParams.put("address", calledRo.getAddress());
smsParams.put("content", calledRo.getContent()); smsParams.put("content", calledRo.getContent());
smsParams.put("trappedNum", calledRo.getTrappedNum()); smsParams.put("trappedNum", calledRo.getTrappedNum());
smsParams.put("casualtiesNum", calledRo.getCasualtiesNum()); smsParams.put("casualtiesNum", calledRo.getCasualtiesNum());
smsParams.put("companyName", calledRo.getCompanyName()); smsParams.put("companyName", calledRo.getCompanyName());
smsParams.put("contactUser", calledRo.getContactUser()); smsParams.put("contactUser", calledRo.getContactUser());
smsParams.put("contactPhone", calledRo.getContactPhone()); smsParams.put("contactPhone", calledRo.getContactPhone());
smsParams.put("alertType", calledRo.getAlertType()); smsParams.put("alertType", calledRo.getAlertType());
sendUserIds.stream().forEach(i -> { sendUserIds.stream().forEach(i-> {
if (i.containsKey("mobilePhone")) { if (i.containsKey("mobilePhone")) {
mobiles.add(i.get("mobilePhone").toString()); mobiles.add(i.get("mobilePhone").toString());
} }
}); });
smsParams.put("resourcesNum", companyName); smsParams.put("resourcesNum", companyName);
// 短信报送对象 // 短信报送对象
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息 // 发送任务消息
// 组织短信内容 // 组织短信内容
// 调用短信发送接口 // 调用短信发送接口
try { try {
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
}catch(Exception e){
} catch (Exception e) {
} }
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
} }
} }
public void ruleCallbackActionForPowerTransferForAid(String smsCode, List sendIds, Object object)
throws MqttPersistenceException, MqttException {
public void ruleCallbackActionForPowerTransferForAid(String smsCode, List sendIds, Object object) throws MqttPersistenceException, MqttException {
List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList(); List<AlertSubmittedObject> alertSubmittedObjectList = Lists.newArrayList();
...@@ -1954,195 +1096,104 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -1954,195 +1096,104 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
Set<Map<String, Object>> userIds = new HashSet<Map<String, Object>>(); Set<Map<String, Object>> userIds = new HashSet<Map<String, Object>>();
HashMap<String, String> smsParams = new HashMap<>(); HashMap<String, String> smsParams = new HashMap<>();
String alertCalledId = null; String alertCalledId = null;
if (object instanceof AlertCallePowerTransferRo) { if (object instanceof AlertCallePowerTransferRo) {
AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object; AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object;
String alertSubmittedId = calledRo.getAlertSubmittedId(); String alertSubmittedId = calledRo.getAlertSubmittedId();
alertCalledId = calledRo.getSequenceNbr(); alertCalledId = calledRo.getSequenceNbr();
//List<FireTeam> fireTeamList= new ArrayList<FireTeam>();
// List<FireTeam> fireTeamList= new ArrayList<FireTeam>(); List<Object> companyDetail =JSONArray.parseArray(JSON.toJSON(calledRo.getCompany()).toString(),Object.class);
//获取急救科、消救部人员信息
List<Object> companyDetail = JSONArray.parseArray(JSON.toJSON(calledRo.getCompany()).toString(), for(Object e:sendIds) {
Object.class);
// 获取急救科、消救部人员信息
for (Object e : sendIds) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e));
if(jsonObject.containsKey("type") &&( (jsonObject.getString("type").equals(AlertStageEnums.ZH.getCode())) || jsonObject.getString("type").equals(AlertStageEnums.XJ.getCode()))) {
if (jsonObject.containsKey("type") String departmentName= jsonObject.getString("name");
&& ((jsonObject.getString("type").equals(AlertStageEnums.ZH.getCode())) if (jsonObject.containsKey("airportUnit")) { {
|| jsonObject.getString("type").equals(AlertStageEnums.XJ.getCode()))) { List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getFireRescueDepartmentStaff(departmentName,null);
String departmentName = jsonObject.getString("name");
if (jsonObject.containsKey("airportUnit")) {
{
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getFireRescueDepartmentStaff(departmentName, null);
userIds.addAll(mapList); userIds.addAll(mapList);
} }
if (jsonObject.containsKey("onDuty")) { if(jsonObject.containsKey("onDuty")) {
List<Map<String, Object>> mapList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(),departmentName);
List<Map<String, Object>> mapList = dynamicFormInstanceMapper
.getDutyPersonByTeamIdAndCarId(DateUtils.getDateNowShortStr(), departmentName);
userIds.addAll(mapList); userIds.addAll(mapList);
} }
} }
} }
} }
//获取对应急救站的当日值班员信息
// 获取对应急救站的当日值班员信息
for (Object powerTransferCompanyDto : companyDetail) { for (Object powerTransferCompanyDto : companyDetail) {
Set<Map<String, Object>> sendUserIds = new HashSet<Map<String, Object>>(); Set<Map<String, Object>> sendUserIds = new HashSet<Map<String, Object>>();
PowerTransferCompanyDto powerDto = JSONObject.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
PowerTransferCompanyDto powerDto = JSONObject
.parseObject(JSON.toJSON(powerTransferCompanyDto).toString(), PowerTransferCompanyDto.class);
Long companyId = powerDto.getCompanyId(); Long companyId = powerDto.getCompanyId();
String companyName = powerDto.getCompanyName(); String companyName = powerDto.getCompanyName();
FireTeam fireTeam= fireTeamServiceImpl.getById(companyId);//这个公司ID实际上是120急救站的id值
FireTeam fireTeam = fireTeamServiceImpl.getById(companyId);// 这个公司ID实际上是120急救站的id值 //fireTeamList.add(fireTeam);
for(Object e:sendIds) {
// fireTeamList.add(fireTeam);
for (Object e : sendIds) {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e));
//获取120急救站的规则
// 获取120急救站的规则 if (jsonObject.containsKey("type") && (jsonObject.getString("type").equals(AlertStageEnums.JJZ.getCode()))) {
if(!jsonObject.containsKey("onDuty")) {
if (jsonObject.containsKey("type")
&& (jsonObject.getString("type").equals(AlertStageEnums.JJZ.getCode()))) {
if (!jsonObject.containsKey("onDuty")) {
continue; continue;
} }
//fireTeamList.stream().forEach(i->{
// fireTeamList.stream().forEach(i->{ //获取120急救排版值班的人员信息
// 获取120急救排版值班的人员信息
List<Map<String, Object>> dutyList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndAirId( List<Map<String, Object>> dutyList = dynamicFormInstanceMapper.getDutyPersonByTeamIdAndAirId(
DateUtils.getDateNowShortStr(), fireTeam.getCompanyName()); DateUtils.getDateNowShortStr(), fireTeam.getCompanyName());
sendUserIds.addAll(dutyList); sendUserIds.addAll(dutyList);
//});
// });
} }
} }
sendUserIds.addAll(userIds); sendUserIds.addAll(userIds);
smsCode = AlertBusinessTypeEnum.力量调派.getSms_code(); smsCode = AlertBusinessTypeEnum.力量调派.getSms_code();
// 组装人员信息 // 组装人员信息
for (Map<String, Object> orgUser : sendUserIds) { for (Map<String, Object> orgUser : sendUserIds) {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject(); AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId)); alertSubmittedObject.setAlertSubmittedId(Long.parseLong(alertSubmittedId));
alertSubmittedObject.setCompanyId(companyId); alertSubmittedObject.setCompanyId(companyId);
alertSubmittedObject.setCompanyName(companyName); alertSubmittedObject.setCompanyName(companyName);
alertSubmittedObject.setType(false); alertSubmittedObject.setType(false);
alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString())); alertSubmittedObject.setUserId(Long.parseLong(orgUser.get("userId").toString()));
alertSubmittedObject.setUserName(orgUser.get("userName").toString()); alertSubmittedObject.setUserName(orgUser.get("userName").toString());
if (!ValidationUtil.isEmpty(orgUser.get("mobilePhone"))) { if (!ValidationUtil.isEmpty(orgUser.get("mobilePhone"))) {
mobiles.add((String) orgUser.get("mobilePhone")); mobiles.add((String) orgUser.get("mobilePhone"));
alertSubmittedObject.setUserPhone(orgUser.get("mobilePhone").toString()); alertSubmittedObject.setUserPhone(orgUser.get("mobilePhone").toString());
} }
alertSubmittedObjectList.add(alertSubmittedObject); alertSubmittedObjectList.add(alertSubmittedObject);
} }
smsParams.put("callTimeStr", calledRo.getCallTimeStr()); smsParams.put("callTimeStr", calledRo.getCallTimeStr());
smsParams.put("address", calledRo.getAddress()); smsParams.put("address", calledRo.getAddress());
smsParams.put("content", calledRo.getContent()); smsParams.put("content", calledRo.getContent());
smsParams.put("trappedNum", calledRo.getTrappedNum()); smsParams.put("trappedNum", calledRo.getTrappedNum());
smsParams.put("casualtiesNum", calledRo.getCasualtiesNum()); smsParams.put("casualtiesNum", calledRo.getCasualtiesNum());
smsParams.put("companyName", calledRo.getCompanyName()); smsParams.put("companyName", calledRo.getCompanyName());
smsParams.put("contactUser", calledRo.getContactUser()); smsParams.put("contactUser", calledRo.getContactUser());
smsParams.put("contactPhone", calledRo.getContactPhone()); smsParams.put("contactPhone", calledRo.getContactPhone());
smsParams.put("alertType", calledRo.getAlertType()); smsParams.put("alertType", calledRo.getAlertType());
sendUserIds.stream().forEach(i -> { sendUserIds.stream().forEach(i -> {
if (i.containsKey("mobilePhone")) { if (i.containsKey("mobilePhone")) {
mobiles.add(i.get("mobilePhone").toString()); mobiles.add(i.get("mobilePhone").toString());
} }
}); });
smsParams.put("resourcesNum", companyName); smsParams.put("resourcesNum", companyName);
// 短信报送对象 // 短信报送对象
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息 // 发送任务消息
// 组织短信内容 // 组织短信内容
// 调用短信发送接口 // 调用短信发送接口
try { try {
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
}catch (Exception e) {// TODO: handle exception
} catch (Exception e) {// TODO: handle exception
} }
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment