Commit cc7ca06b authored by fupeiyang's avatar fupeiyang

规则和发送短信接口

parent b9d57abb
...@@ -7,6 +7,7 @@ import java.util.List; ...@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertSubmittedServiceImpl;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -23,7 +24,6 @@ import com.yeejoin.amos.component.rule.RuleMethod; ...@@ -23,7 +24,6 @@ import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
/** /**
*
* <pre> * <pre>
* 警情报送规则动作 * 警情报送规则动作
* </pre> * </pre>
...@@ -32,14 +32,17 @@ import com.yeejoin.amos.feign.systemctl.Systemctl; ...@@ -32,14 +32,17 @@ import com.yeejoin.amos.feign.systemctl.Systemctl;
* @version $Id: AlertCalledAction.java, v 0.1 2021年6月24日 下午4:41:22 gwb Exp $ * @version $Id: AlertCalledAction.java, v 0.1 2021年6月24日 下午4:41:22 gwb Exp $
*/ */
@Component @Component
@RuleActionBean(beanLabel = "警情报送" ) @RuleActionBean(beanLabel = "警情报送")
public class AlertCalledAction { public class AlertCalledAction {
public static final Logger log = LoggerFactory.getLogger(AlertCalledAction.class); public static final Logger log = LoggerFactory.getLogger(AlertCalledAction.class);
@Autowired
private OrgUsrServiceImpl orgUsrService;
@Autowired @Autowired
private OrgUsrServiceImpl orgUsrService; private AlertSubmittedServiceImpl alertSubmittedService;
public void sendSysMessage(String msgType, AlertCalledRo contingency) { public void sendSysMessage(String msgType, AlertCalledRo contingency) {
// ContingencyRo ro = (ContingencyRo)contingency; // ContingencyRo ro = (ContingencyRo)contingency;
// ro.setTelemetryMap(null); // ro.setTelemetryMap(null);
...@@ -67,60 +70,32 @@ public class AlertCalledAction { ...@@ -67,60 +70,32 @@ public class AlertCalledAction {
} }
/** /**
*
* <pre>
* 短信报送 * 短信报送
* </pre>
* *
* @param smsTemp * @param smsCode 短信模板code
* @param sendType * @param sendType 发送类型
* @param sendIds * @param sendIds 人员id
* @param alertCalledRo * @param object 模板内容对象
* @throws Exception 异常
*/ */
@SuppressWarnings("unchecked") @RuleMethod(methodLabel = "短信报送", project = "西咸机场119接处警规则")
@RuleMethod(methodLabel = "短信报送", project = "西咸机场119接处警规则") public void sendcmd(String smsCode, String sendType, String sendIds, Object object) throws Exception {
public void sendcmd(String smsCode, String sendType, String sendIds, Object object) throws Exception
{ alertSubmittedService.ruleCallbackAction(smsCode, sendIds, object);
List<Long> seqs = StringUtil.String2LongList(sendIds);
if (!ValidationUtil.isEmpty(seqs))
{
//构建短信参数
HashMap<String, String> smsParams = new HashMap<String, String>();
Map<String, String> objectMap = JSON.parseObject(JSON.toJSONString(object), HashMap.class);
smsParams.putAll(objectMap);
//查询人员手机号
Set<String> mobiles = new HashSet<>();
for (Long seq : seqs)
{
OrgUsr orgUsr = orgUsrService.getById(seq);
Map<String, Object> result = orgUsrService.selectForShowById(orgUsr, seq);
Object telephone = result.get("telephone");
if (!ValidationUtil.isEmpty(telephone))
{
mobiles.add(String.valueOf(telephone));
}
}
//发送短信
sendAlertCalleCmd(smsCode, mobiles, smsParams);
}
} }
public void sendAlertCalleCmd(String smsCode, Set<String> mobiles, HashMap<String, String> smsParams) public void sendAlertCalleCmd(String smsCode, Set<String> mobiles, HashMap<String, String> smsParams) {
{
if (!ValidationUtil.isEmpty(mobiles)) {
if (!ValidationUtil.isEmpty(mobiles)) //构建短信参数
{ smsParams.put("smsCode", smsCode);
//构建短信参数 for (String mobile : mobiles) {
smsParams.put("smsCode", smsCode); smsParams.put("mobile", mobile);
for (String mobile : mobiles) }
{ //发送短信
smsParams.put("mobile", mobile); Systemctl.smsClient.sendCommonSms(smsParams);
//发送短信 }
Systemctl.smsClient.sendCommonSms(smsParams);
}
}
} }
} }
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
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.utils.EnumsUtils; import com.yeejoin.amos.boot.biz.common.utils.EnumsUtils;
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.TemplateExtendDto; import com.yeejoin.amos.boot.module.jcs.api.dto.TemplateExtendDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.*; import com.yeejoin.amos.boot.module.jcs.api.entity.*;
...@@ -27,6 +28,7 @@ import org.apache.commons.lang3.ObjectUtils; ...@@ -27,6 +28,7 @@ import org.apache.commons.lang3.ObjectUtils;
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.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.lang.reflect.Field; import java.lang.reflect.Field;
...@@ -124,14 +126,30 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -124,14 +126,30 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
/** /**
* 规则回调 * 规则回调
*/ */
public void ruleCallbackAction(String smsCode,String sendIds, Object object) { public void ruleCallbackAction(String smsCode, String sendIds, Object object) throws Exception {
// 获取报送对象列表 // 获取报送对象列表
List<AlertSubmittedObject> alertSubmittedObjectList = new ArrayList<>(); List<AlertSubmittedObject> alertSubmittedObjectList = new ArrayList<>();
Set<String> mobiles = new HashSet<>(); Set<String> mobiles = new HashSet<>();
// 根据id列表查询所有人员信息 // 根据id列表查询所有人员信息
ArrayList<String> list = new ArrayList<>(Arrays.asList(sendIds.split(","))); List<Long> ids = StringUtil.String2LongList(sendIds);
Collection<OrgUsr> orgUsrs = orgUsrService.listByIds(list); if (object instanceof AlertCalledRo) {
AlertCalledRo calledRo = (AlertCalledRo) object;
String sequenceNbr = calledRo.getSequenceNbr();
List<Map<String, Object>> orgUsers = orgUsrService.selectForShowByListId(ids);
for (Map<String, Object> orgUser : orgUsers) {
AlertSubmittedObject alertSubmittedObject = new AlertSubmittedObject();
alertSubmittedObject.setAlertSubmittedId(Long.parseLong(sequenceNbr));
alertSubmittedObject.setType(false);
alertSubmittedObject.setCompanyId((Long) orgUser.get("parentId"));
alertSubmittedObject.setCompanyName((String) orgUser.get("parentName"));
alertSubmittedObject.setUserId((Long) orgUser.get("bizOrgCode"));
alertSubmittedObject.setUserName((String) orgUser.get("bizOrgName"));
alertSubmittedObject.setUserPhone((String) orgUser.get("telephone"));
mobiles.add((String) orgUser.get("telephone"));
alertSubmittedObjectList.add(alertSubmittedObject);
}
}
// 执行短信报送对象 // 执行短信报送对象
saveAlertSubmittedObject(alertSubmittedObjectList, smsCode, mobiles, object); saveAlertSubmittedObject(alertSubmittedObjectList, smsCode, mobiles, object);
} }
...@@ -238,7 +256,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -238,7 +256,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList); alertSubmittedObjectServiceImpl.saveBatch(alertSubmittedObjectList);
// 发送任务消息 // 发送任务消息
// 组织短信内容 // 组织短信内容
HashMap<String, String> smsParams = new HashMap<String, String>(); HashMap<String, String> smsParams = new HashMap<>();
Map<String, String> objectMap = JSON.parseObject(JSON.toJSONString(object), HashMap.class); Map<String, String> objectMap = JSON.parseObject(JSON.toJSONString(object), HashMap.class);
smsParams.putAll(objectMap); smsParams.putAll(objectMap);
// 调用短信发送接口 // 调用短信发送接口
...@@ -270,7 +288,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -270,7 +288,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
} }
map.put("companyNames", companyNames.deleteCharAt(companyNames.length() - 1).toString()); map.put("companyNames", companyNames.deleteCharAt(companyNames.length() - 1).toString());
map.put("resourcesInfo", resourcesInfo.deleteCharAt(resourcesInfo.length() - 1).toString()); map.put("resourcesInfo", resourcesInfo.deleteCharAt(resourcesInfo.length() - 1).toString());
map.put("transferTime",lastPowerTransferCompany.get(0).getRecDate()); map.put("transferTime", lastPowerTransferCompany.get(0).getRecDate());
} }
TemplateVo templateVo = new TemplateVo(); TemplateVo templateVo = new TemplateVo();
BeanUtils.copyProperties(template, templateVo); BeanUtils.copyProperties(template, templateVo);
......
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