Commit 619d5fee authored by chenhao's avatar chenhao

提交信息发送的代码

parent 2bd57061
package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
import static org.hamcrest.CoreMatchers.nullValue;
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;
...@@ -40,6 +42,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -40,6 +42,7 @@ 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.constants.RuleConstant;
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;
...@@ -61,6 +64,7 @@ import com.yeejoin.amos.boot.module.jcs.api.dto.CarStatusInfoDto; ...@@ -61,6 +64,7 @@ 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.PushMessageWebAndAppRo;
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;
...@@ -79,6 +83,7 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferCompanyMapper; ...@@ -79,6 +83,7 @@ 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.RuleTrigger;
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;
...@@ -154,6 +159,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -154,6 +159,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
@Autowired @Autowired
DynamicFormInstanceMapper dynamicFormInstanceMapper; DynamicFormInstanceMapper dynamicFormInstanceMapper;
@Autowired
private RuleTrigger ruleTrigger;
private final String msgType = "jcs119";
@Override @Override
public SchedulingReportingDto listSchedulingByParam(AlertSubmittedDto queryParam) { public SchedulingReportingDto listSchedulingByParam(AlertSubmittedDto queryParam) {
...@@ -824,6 +835,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -824,6 +835,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object; AlertCallePowerTransferRo calledRo = (AlertCallePowerTransferRo) object;
String alertSubmittedId = calledRo.getAlertSubmittedId(); String alertSubmittedId = calledRo.getAlertSubmittedId();
alertCalledId = calledRo.getSequenceNbr(); alertCalledId = calledRo.getSequenceNbr();
AlertCalled alertCalled = alertCalledService.getAlertCalledById(Long.parseLong(alertSubmittedId));
//响应级别
String responseLevelString ="";
if(alertCalled!=null && alertCalled.getResponseLevel()!=null) {
responseLevelString = alertCalled.getResponseLevel();
}
//先获取消救部领导、消救部值班人员信息 //先获取消救部领导、消救部值班人员信息
sendIds.stream().forEach(e -> { sendIds.stream().forEach(e -> {
JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e)); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(e));
...@@ -940,28 +957,44 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -940,28 +957,44 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
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;
List<String> userList=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());
} }
}; };
userList=new ArrayList<String>();
if(!ValidationUtil.isEmpty(map.get("amosId"))) {
userList.add(map.get("amosId").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);
Map<String, String> besidesMap = new HashMap<String, String>();
besidesMap.put("responseLevelString", responseLevelString);
besidesMap.put("alterId", alertCalledId);
if(userList.size()>0) {
pushPowerTransferToAppAndWeb(AlertBusinessTypeEnum.力量调派.getCode(),besidesMap,smsParams,userList);
}
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();
List<String> userList= new ArrayList<String>();
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());
} }
if (i.containsKey("amosId")&& !ValidationUtil.isEmpty(i.get("amosId"))) {
userList.add(i.get("amosId").toString());
}
}); });
smsParams.put("resourcesNum", resourcesNumStr.substring(resourcesNumStr.length() - 2)); smsParams.put("resourcesNum", resourcesNumStr.substring(resourcesNumStr.length() - 2));
// 短信报送对象 // 短信报送对象
...@@ -973,7 +1006,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -973,7 +1006,12 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams); alertCalledAction.sendAlertCalleCmd(smsCode, mobiles, smsParams);
} catch (Exception e) { } catch (Exception e) {
} }
Map<String, String> besidesMap = new HashMap<String, String>();
besidesMap.put("responseLevelString", responseLevelString);//响应级别
besidesMap.put("alterId", alertCalledId);
if(userList.size()>0) {
pushPowerTransferToAppAndWeb(AlertBusinessTypeEnum.力量调派.getCode(),besidesMap,smsParams,userList);
}
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
} }
...@@ -1061,10 +1099,14 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -1061,10 +1099,14 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
smsParams.put("contactPhone", calledRo.getContactPhone()); smsParams.put("contactPhone", calledRo.getContactPhone());
smsParams.put("alertType", calledRo.getAlertType()); smsParams.put("alertType", calledRo.getAlertType());
sendUserIds.stream().forEach(i-> { List<String> userList= new ArrayList<String>();
sendUserIds.stream().forEach(i -> {
if (i.containsKey("mobilePhone")) { if (i.containsKey("mobilePhone")) {
mobiles.add(i.get("mobilePhone").toString()); mobiles.add(i.get("mobilePhone").toString());
} }
if (i.containsKey("amosId")&& !ValidationUtil.isEmpty(i.get("amosId"))) {
userList.add(i.get("amosId").toString());
}
}); });
smsParams.put("resourcesNum", companyName); smsParams.put("resourcesNum", companyName);
// 短信报送对象 // 短信报送对象
...@@ -1077,7 +1119,11 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -1077,7 +1119,11 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}catch(Exception e){ }catch(Exception e){
} }
Map<String, String> besidesMap = new HashMap<String, String>();
besidesMap.put("alterId", alertCalledId);
if(userList.size()>0) {
pushPowerTransferToAppAndWeb(AlertBusinessTypeEnum.力量调派.getCode(),besidesMap,smsParams,userList);
}
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
} }
...@@ -1172,11 +1218,14 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -1172,11 +1218,14 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
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<String> userList= new ArrayList<String>();
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());
} }
if (i.containsKey("amosId")&& !ValidationUtil.isEmpty(i.get("amosId"))) {
userList.add(i.get("amosId").toString());
}
}); });
smsParams.put("resourcesNum", companyName); smsParams.put("resourcesNum", companyName);
// 短信报送对象 // 短信报送对象
...@@ -1189,11 +1238,81 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -1189,11 +1238,81 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}catch (Exception e) {// TODO: handle exception }catch (Exception e) {// TODO: handle exception
} }
Map<String, String> besidesMap = new HashMap<String, String>();
besidesMap.put("alterId", alertCalledId);
if(userList.size()>0) {
pushPowerTransferToAppAndWeb(AlertBusinessTypeEnum.力量调派.getCode(),besidesMap,smsParams,userList);
}
emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(topic, alertCalledId.getBytes(), RuleConfig.DEFAULT_QOS, false);
} }
} }
} }
/**
* app消息web 消息推送
* @param smsCode
* @param sendIds
* @param object
* @throws MqttPersistenceException
* @throws MqttException
*/
public void pushPowerTransferToAppAndWeb(String type,Map<String, String> besidesMap, HashMap<String, String> smsParams, List<String> userList){
PushMessageWebAndAppRo pushMessageWebAndAppRo = new PushMessageWebAndAppRo();
pushMessageWebAndAppRo.setRelationId(besidesMap.get("alterId"));
pushMessageWebAndAppRo.setRecivers(userList);
pushMessageWebAndAppRo.setCategory(RuleConstant.NOTIFY);
pushMessageWebAndAppRo.setIsSendApp(true);
pushMessageWebAndAppRo.setIsSendWeb(true);
pushMessageWebAndAppRo.setRuleType(type);
pushMessageWebAndAppRo.setMsgType(this.msgType);
pushMessageWebAndAppRo.setTerminal(RuleConstant.APP_WEB);
if(AlertBusinessTypeEnum.警情结案.getCode().equals(type)) {
pushMessageWebAndAppRo.setName("消息");
pushMessageWebAndAppRo.setStartTime(besidesMap.get("startTime"));
pushMessageWebAndAppRo.setEndTime(besidesMap.get("endTime"));
pushMessageWebAndAppRo.setAddress(smsParams.get("address"));
}
if(AlertBusinessTypeEnum.非警情确认.getCode().equals(type)) {
pushMessageWebAndAppRo.setName("消息");
pushMessageWebAndAppRo.setSendTime(smsParams.get("callTimeStr"));
pushMessageWebAndAppRo.setAddress(smsParams.get("address"));
}
if(AlertBusinessTypeEnum.警情续报.getCode().equals(type)) {
pushMessageWebAndAppRo.setName("消息");
pushMessageWebAndAppRo.setCompanyName(smsParams.get("companyName"));
pushMessageWebAndAppRo.setAddress(smsParams.get("address"));
pushMessageWebAndAppRo.setSendTime(besidesMap.get("sendTime"));
pushMessageWebAndAppRo.setTransferLocation(besidesMap.get("transferLocation"));
}
if(AlertBusinessTypeEnum.力量调派.getCode().equals(type)) {
pushMessageWebAndAppRo.setName(AlertBusinessTypeEnum.力量调派.getName());
pushMessageWebAndAppRo.setCompanyName(smsParams.get("resourcesNum"));
pushMessageWebAndAppRo.setAddress(smsParams.get("address"));
pushMessageWebAndAppRo.setSendTime(smsParams.get("callTimeStr"));
if(StringUtils.isNotBlank(besidesMap.get("transferLocation"))) {
pushMessageWebAndAppRo.setTransferLocation(besidesMap.get("responseLevelString"));//响应级别
pushMessageWebAndAppRo.setRuleType("fullTime");
}else {
pushMessageWebAndAppRo.setRuleType("monitor");
}
}
if(AlertBusinessTypeEnum.警情初报.getCode().equals(type)) {
pushMessageWebAndAppRo.setRuleType("reportAlert");
pushMessageWebAndAppRo.setName(AlertBusinessTypeEnum.警情初报.getName());
pushMessageWebAndAppRo.setSendTime(besidesMap.get("sendTime"));
pushMessageWebAndAppRo.setCompanyName(smsParams.get("companyName"));//发送单位
pushMessageWebAndAppRo.setAddress(smsParams.get("address"));
pushMessageWebAndAppRo.setFireSituation(besidesMap.get("fireSituation"));//火势情况
pushMessageWebAndAppRo.setTrappedNum(smsParams.get("trappedNum"));//被困人数
pushMessageWebAndAppRo.setCasualtiesNum(smsParams.get("casualtiesNum"));//伤亡人数
}
try {
ruleTrigger.publish(pushMessageWebAndAppRo, "消息/addAlterMessageCheck", new String[0]);
} catch (Exception e) {
}
}
} }
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