移动梦网短信平台修复切换用户优化

This commit is contained in:
zhanglei@ap-leasing.com.cn 2023-07-28 19:47:57 +08:00
parent fd1d7d5bdb
commit e1b2a8da53
3 changed files with 34 additions and 19 deletions

View File

@ -23,12 +23,16 @@ public class SmsController {
public String sendMessage(JBOTransaction tx){
try{
// 实例化短信处理对象
SmsSendConn smsSendConn = new SmsSendConn(true);
//将发送过来的参数按照@切分出来
String[] smsID = ids.split("@");
if(smsID.length==0){
return "ERROR";
}
BizObjectManager bomLSNT = JBOFactory.getBizObjectManager(LB_SMS_NOTICE_TASKS.CLASS_NAME,tx);
BizObjectManager bomSS = JBOFactory.getBizObjectManager(SMS_SEND.CLASS_NAME,tx);
SmsSendManager.accountCheck();
// 实例化短信处理对象
SmsSendConn smsSendConn = new SmsSendConn(true);
for(String id:smsID){
sendMessage(smsSendConn,id,bomLSNT,bomSS);
}
@ -44,12 +48,6 @@ public class SmsController {
int resultCode = -310099;
try {
Message message = createMessageByBizObject(boLSNT);
String smsObType = boLSNT.getAttribute("SEND_OBJ_TYPE").toString();
if(SmsObjType.URGE_COLLECTION.getType().equals(smsObType)){
SmsSendManager.setAccountInfo(SmsObjType.URGE_COLLECTION);
}else {
SmsSendManager.setAccountInfo(SmsObjType.NORMAL);
}
StringBuffer returnValue = new StringBuffer();
/*
发送短信
@ -97,13 +95,12 @@ public class SmsController {
// 实例化短信处理对象
SmsSendConn smsSendConn = new SmsSendConn(true);
String userId = SmsPropertiesUtil.get("userid");
SmsObjType smsEnum = SmsObjType.NORMAL;
if("02".equals(smsObjType)){
userId = SmsPropertiesUtil.get("urge_userid");
smsEnum = SmsObjType.URGE_COLLECTION;
}
// 查询余额接口
SmsSendManager.setAccountInfo(smsEnum);
if(!SmsSendManager.accountExist(userId)){
SmsSendManager.setAccountInfo();
}
Remains remains = smsSendConn.getRemains(userId);
//remains不为空
@ -149,14 +146,18 @@ public class SmsController {
return "获取状态报告的线程启动成功!";
}
public Message createMessageByBizObject(BizObject bo) throws JBOException {
//调用短信接口
String phoneNo = bo.getAttribute("PHONE_NUMBER").getString();
String smsContent = bo.getAttribute("SMS_CONTENT").getString();
String smsId = bo.getAttribute("ID").getString();
String smsObjType = bo.getAttribute("SEND_OBJ_TYPE").getString();
String userId = SmsPropertiesUtil.get("userid");
if("02".equals(smsObjType)){
userId = SmsPropertiesUtil.get("urge_userid");
}
// 参数类
Message message = new Message();
// 设置用户账号 指定用户账号发送需要填写用户账号不指定用户账号发送无需填写用户账号
// message.setUserid(userid);
message.setUserid(userId);
// 设置手机号码 此处只能设置一个手机号码
message.setMobile(phoneNo);
// 设置内容
@ -172,7 +173,6 @@ public class SmsController {
return message;
}
public String getSmsObjType() {
return smsObjType;
}

View File

@ -46,11 +46,27 @@ public class SmsSendManager {
//globalParams.setMoFixedKey("0123456789abcdeffedcba9876543210");
// 设置用户账号信息
setAccountInfo(SmsObjType.NORMAL);
setAccountInfo();
}
public static void accountCheck(){
if(!(accountExist(SmsPropertiesUtil.get("userid"))&&accountExist(SmsPropertiesUtil.get("urge_userid")))) {
SmsSendManager.setAccountInfo();
}
}
public static boolean accountExist(String userId){
Account account = (Account) ConfigManager.accountMap.get(userId);
if (account == null) {
return false;
}else{
return true;
}
}
public static void setAccountInfo(){
setAccountInfo(SmsObjType.NORMAL);
setAccountInfo(SmsObjType.URGE_COLLECTION);
}
/**
* @description 设置用户账号信息
*/

View File

@ -8,7 +8,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.text.SimpleDateFormat;
@ -18,7 +17,7 @@ public class JobSendMessage implements Job{
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
public void execute(JobExecutionContext context){
JBOTransaction tx = null;
String smsnoticeid = null;
try {