java代码手机发短信 java sms短信接收( 三 )


if (BaseConstant.task_status_cs.equals(taskInfo.getTask_status())) {
taskInfo.setTask_status(BaseConstant.task_status_zx);//设置任务执行状态为执行
taskInfo.setTask_last_start_time(new Date());//设置任务执行开始时间
baseService.update("sms_send.updateTaskStatus", taskInfo);//
//移动号码库
HashMapString,String hashMap = new HashMapString,String();
//134 、135、136、137、138、139、150、151、152、158、159、182、183、184 。157、187、188
hashMap.put("134", "134");
hashMap.put("135", "135");
hashMap.put("136", "136");
hashMap.put("137", "137");
hashMap.put("138", "138");
hashMap.put("139", "139");
hashMap.put("150", "150");
hashMap.put("151", "151");
hashMap.put("152", "152");
hashMap.put("157", "157");
hashMap.put("158", "158");
hashMap.put("159", "159");
hashMap.put("182", "182");
hashMap.put("183", "183");
hashMap.put("184", "184");
hashMap.put("187", "187");
hashMap.put("188", "188");
SmsVisit smsSend = new SmsVisit();
smsSend.setSms_status(BaseConstant.sms_status_csh);
List list = baseService.queryForList("sms_send.queryForSmsTask", smsSend);
List smsMasList = new ArrayList();
List smsList = new ArrayList();
if (list == null||list.size()==0) return;// 如果列表为空,没有待办任务,则任务结束
for (int i = 0; ilist.size(); i++) {
smsSend = (SmsVisit) list.get(i);
//String msg = messagecontent(smsSend);
String msg = smsSend.getSpare_2();
if(hashMap.get(smsSend.getVisit_phone().substring(0, 3))!=null){
SmsOutBox smsOutBox = new SmsOutBox();
smsOutBox.setSismsid(smsSend.getP_id());
smsOutBox.setReqdeliveryreport(BaseConstant.NoReport);
smsOutBox.setApplicationid(BaseConstant.APPLICATIONID);
smsOutBox.setDestaddr(smsSend.getVisit_phone());
smsOutBox.setMsgfmt(BaseConstant.MSGFMT);
smsOutBox.setRequesttime(new Date());
smsOutBox.setExtcode(smsSend.getExtccode());
smsOutBox.setSendmethod(BaseConstant.NoMsg);// 正常短信
smsOutBox.setMessagecontent(msg);
smsMasList.add(smsOutBox);
}else{
boolean con = true;
String lastMsg = msg;
int xh =0;
while(con){
lastMsg = msg.substring(0,msg.length()55 ? 55 : msg.length());
msg = msg.substring(msg.length()55 ? 55 : msg.length(),msg.length());
if (msg.equals("")) {
con = false;
}
SmsOutBox smsOutBox = new SmsOutBox();
smsOutBox.setSismsid(smsSend.getP_id()+(xh==0?"":xh));
xh++;
smsOutBox.setReqdeliveryreport(BaseConstant.NoReport);
smsOutBox.setApplicationid(BaseConstant.APPLICATIONID);
smsOutBox.setDestaddr(smsSend.getVisit_phone());
smsOutBox.setMsgfmt(BaseConstant.MSGFMT);
smsOutBox.setRequesttime(new Date());
smsOutBox.setExtcode(smsSend.getExtccode());
smsOutBox.setSendmethod(BaseConstant.NoMsg);// 正常短信
smsOutBox.setMessagecontent(lastMsg);
smsMasList.add(smsOutBox);
}
}
SmsVisit smsSendTemp = new SmsVisit();
smsSendTemp.setP_id(smsSend.getP_id());
//smsSendTemp.setSpare_2(msg);//短信内容
smsSendTemp.setSms_status_time(new Date());
smsSendTemp.setSms_status(BaseConstant.sms_status_yfswg);
smsList.add(smsSendTemp);
}
baseService.insertBatch("sms_send.insertSmsOutBox", smsMasList);//插入本地历史记录表
baseServiceMas.insertBatch("sms_mas.insertSmsOutBox", smsMasList);//插入mas机待发送表
baseService.updateBatch("sms_send.updateSmsVisit", smsList);//更新回访记录状态
}
} catch (Exception e) {
e.printStackTrace();
//baseService.saveLog("同步短信到mas机待发短信表", "100001", "同步短信到mas机待发短信表错误");
logger.error("同步短信到mas机待发短信表错误", getTrace(e));
}finally{

推荐阅读