|
|
@@ -1,22 +1,46 @@
|
|
|
package com.xunmei.sms.service;
|
|
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dc.eai.data.CompositeData;
|
|
|
import com.dcfs.esb.client.ESBClient;
|
|
|
+import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
+import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.web.domain.AjaxResult;
|
|
|
import com.xunmei.sms.utils.SmsUtil;
|
|
|
+import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.RemoteRoleService;
|
|
|
+import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import com.xunmei.system.api.domain.SysUser;
|
|
|
+import com.xunmei.system.api.function.RemoteCallHandlerExecutor;
|
|
|
import com.xunmei.system.api.vo.SmsInfoVo;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
@Service
|
|
|
public class SmsService implements ISmsService {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(SmsService.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RemoteRoleService remoteRoleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RemoteOrgService remoteOrgService;
|
|
|
+
|
|
|
+ //告警代码
|
|
|
+ private static final String ALARM_CODE="854002";
|
|
|
+ //逾期提醒代码
|
|
|
+ private static final String TODO_CODE="854001";
|
|
|
+
|
|
|
/**
|
|
|
* 在ESB系统里的 系统编码
|
|
|
*/
|
|
|
@@ -70,6 +94,42 @@ public class SmsService implements ISmsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据机构获取机构下网点负责人角色,并发送告警短信
|
|
|
+ * @param orgId
|
|
|
+ * @param alarmContent
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void sendSmsIot(Long orgId, String alarmContent,String alarmTime) {
|
|
|
+ List<SysUser> userList = RemoteCallHandlerExecutor.executeRemoteCall(() ->
|
|
|
+ remoteRoleService.selectUserByRoleNameAndOrgId("网点负责人", orgId, 0, SecurityConstants.INNER), ErrorMsgConstants.QUERY_USER_DATA_ERROR);
|
|
|
+ SysOrg sysOrg = remoteOrgService.selectOrgById(orgId, SecurityConstants.INNER);
|
|
|
+ Date now = new Date();
|
|
|
+ String date = DateUtil.format(now, "yyyy-MM-dd");
|
|
|
+ String time = DateUtil.format(now, "hh:mm:ss");
|
|
|
+ if (ObjectUtil.isNotEmpty(userList)){
|
|
|
+ for (SysUser sysUser : userList) {
|
|
|
+ String phone = sysUser.getPhone();
|
|
|
+ SmsInfoVo smsInfoVo = new SmsInfoVo();
|
|
|
+ smsInfoVo.setBelongBranchId(sysOrg.getGuid());
|
|
|
+ smsInfoVo.setTranType(ALARM_CODE);
|
|
|
+ smsInfoVo.setMobile(phone);
|
|
|
+ smsInfoVo.setOccurDate(date);
|
|
|
+ smsInfoVo.setOccurTime(time);
|
|
|
+ smsInfoVo.setBak3(alarmContent);
|
|
|
+ CompositeData smsCompositeData = SmsUtil.createSmsBody(smsInfoVo,systemCode,systemName,serviceCode,serviceScene);
|
|
|
+ CompositeData rspData = null;
|
|
|
+ try {
|
|
|
+ rspData = ESBClient.request(smsCompositeData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ getResult(rspData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private AjaxResult getResult(CompositeData repData) {
|
|
|
boolean result = false;
|
|
|
try {
|