Commit cc7ca06b authored by fupeiyang's avatar fupeiyang

规则和发送短信接口

parent b9d57abb
......@@ -7,6 +7,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertSubmittedServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -23,7 +24,6 @@ import com.yeejoin.amos.component.rule.RuleMethod;
import com.yeejoin.amos.feign.systemctl.Systemctl;
/**
*
* <pre>
* 警情报送规则动作
* </pre>
......@@ -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 $
*/
@Component
@RuleActionBean(beanLabel = "警情报送" )
@RuleActionBean(beanLabel = "警情报送")
public class AlertCalledAction {
public static final Logger log = LoggerFactory.getLogger(AlertCalledAction.class);
@Autowired
private OrgUsrServiceImpl orgUsrService;
@Autowired
private OrgUsrServiceImpl orgUsrService;
private AlertSubmittedServiceImpl alertSubmittedService;
public void sendSysMessage(String msgType, AlertCalledRo contingency) {
// ContingencyRo ro = (ContingencyRo)contingency;
// ro.setTelemetryMap(null);
......@@ -67,60 +70,32 @@ public class AlertCalledAction {
}
/**
*
* <pre>
* 短信报送
* </pre>
*
* @param smsTemp
* @param sendType
* @param sendIds
* @param alertCalledRo
* @param smsCode 短信模板code
* @param sendType 发送类型
* @param sendIds 人员id
* @param object 模板内容对象
* @throws Exception 异常
*/
@SuppressWarnings("unchecked")
@RuleMethod(methodLabel = "短信报送", project = "西咸机场119接处警规则")
public void sendcmd(String smsCode, String sendType, String sendIds, Object object) throws Exception
{
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);
}
@RuleMethod(methodLabel = "短信报送", project = "西咸机场119接处警规则")
public void sendcmd(String smsCode, String sendType, String sendIds, Object object) throws Exception {
alertSubmittedService.ruleCallbackAction(smsCode, sendIds, object);
}
public void sendAlertCalleCmd(String smsCode, Set<String> mobiles, HashMap<String, String> smsParams)
{
if (!ValidationUtil.isEmpty(mobiles))
{
//构建短信参数
smsParams.put("smsCode", smsCode);
for (String mobile : mobiles)
{
smsParams.put("mobile", mobile);
//发送短信
Systemctl.smsClient.sendCommonSms(smsParams);
}
}
public void sendAlertCalleCmd(String smsCode, Set<String> mobiles, HashMap<String, String> smsParams) {
if (!ValidationUtil.isEmpty(mobiles)) {
//构建短信参数
smsParams.put("smsCode", smsCode);
for (String mobile : mobiles) {
smsParams.put("mobile", mobile);
}
//发送短信
Systemctl.smsClient.sendCommonSms(smsParams);
}
}
}
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Lists;
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.TemplateExtendDto;
import com.yeejoin.amos.boot.module.jcs.api.entity.*;
......@@ -27,6 +28,7 @@ import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.lang.reflect.Field;
......@@ -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<>();
Set<String> mobiles = new HashSet<>();
// 根据id列表查询所有人员信息
ArrayList<String> list = new ArrayList<>(Arrays.asList(sendIds.split(",")));
Collection<OrgUsr> orgUsrs = orgUsrService.listByIds(list);
List<Long> ids = StringUtil.String2LongList(sendIds);
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);
}
......@@ -238,7 +256,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
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);
smsParams.putAll(objectMap);
// 调用短信发送接口
......@@ -270,7 +288,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
}
map.put("companyNames", companyNames.deleteCharAt(companyNames.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();
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