diff --git a/src/com/ample/sms/SmsController.java b/src/com/ample/sms/SmsController.java index ea7ce8b2d..b9ab09a19 100644 --- a/src/com/ample/sms/SmsController.java +++ b/src/com/ample/sms/SmsController.java @@ -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; } diff --git a/src/com/ample/sms/SmsSendManager.java b/src/com/ample/sms/SmsSendManager.java index 30d597366..f89be5acf 100644 --- a/src/com/ample/sms/SmsSendManager.java +++ b/src/com/ample/sms/SmsSendManager.java @@ -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 设置用户账号信息 */ diff --git a/src_tenwa/com/tenwa/message/JobSendMessage.java b/src_tenwa/com/tenwa/message/JobSendMessage.java index f578939e2..6e5ff228f 100644 --- a/src_tenwa/com/tenwa/message/JobSendMessage.java +++ b/src_tenwa/com/tenwa/message/JobSendMessage.java @@ -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 {