f633b45b7ac783165b7a5950583d2abef646a10e.svn-base 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package com.chinacreator.videoalliance.smc.action;
  2. import com.chinacreator.common.exception.BusinessException;
  3. import com.chinacreator.common.util.DESUtil;
  4. import com.chinacreator.videoalliance.smc.bean.SmsSendBean;
  5. import com.chinacreator.videoalliance.smc.dao.SmsSendDao;
  6. import com.chinacreator.videoalliance.smc.util.SendSmsUtil;
  7. import org.apache.commons.lang.StringUtils;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Controller;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import org.springframework.web.bind.annotation.ResponseBody;
  12. import javax.servlet.http.HttpServletRequest;
  13. import javax.servlet.http.HttpServletResponse;
  14. import java.util.HashMap;
  15. import java.util.Map;
  16. @Controller
  17. public class ChannelSendSmsAction {
  18. @Autowired
  19. private SmsSendDao smsSendDao;
  20. @RequestMapping("/channelSmsSend.do")
  21. @ResponseBody
  22. public Object send(HttpServletRequest request, HttpServletResponse response) throws Exception {
  23. Map<String,String> map = new HashMap<String, String>();
  24. String resultCode = "0";
  25. String errorInfo = "";
  26. try{
  27. String channel = request.getParameter("channel");
  28. String content = request.getParameter("content");
  29. String userid = request.getParameter("userid");
  30. if(StringUtils.isEmpty(channel) || StringUtils.isEmpty(userid)){
  31. throw new BusinessException("9002", "参数错误");
  32. }
  33. SmsSendBean bean = smsSendDao.querySmsConfig(channel);
  34. if(bean == null){
  35. throw new BusinessException("9003", "渠道不存在");
  36. }
  37. userid = DESUtil.decode(userid, bean.getPwd());
  38. if(content == null){
  39. content = bean.getContent();
  40. }
  41. // SmsUtil.sendSms(userid,content);
  42. SendSmsUtil.send(userid,content);
  43. }catch(Exception e){
  44. e.printStackTrace();
  45. if(e instanceof BusinessException){
  46. resultCode = ((BusinessException) e).getCode();
  47. errorInfo = e.getMessage();
  48. }else{
  49. resultCode = "8000";
  50. errorInfo = "系统忙,请稍后再试";
  51. }
  52. }finally {
  53. map.put("resultCode", resultCode);
  54. map.put("errorInfo", errorInfo);
  55. }
  56. return map;
  57. }
  58. public static void main(String[] args) throws Exception, Exception {
  59. //20474
  60. // List<String> list = ReadUtil.read("f:1.txt");
  61. // int n = list.size();
  62. // for (String string : list) {
  63. // System.out.println(n--);
  64. // String result =URLUtil.get("http://114.255.201.238:8092/videoif/channelSmsSend.do?channel=letvsms&userid="+URLEncoder.encode(DESUtil.encode(string, "idfdse33"),"utf-8"));
  65. // System.out.println(result);
  66. // }
  67. // ChannelSendSmsAction cs = new ChannelSendSmsAction();
  68. // cs.sendSms("18673687435","这是一条测试短信20200310");
  69. // HashMap params = new HashMap();
  70. // String pwd = "net3gvideo";
  71. // params.put("SP_NUMBER", "10655117");
  72. // params.put("CHANNEK_ID", "video");
  73. // params.put("USERMOB", "18673197465");
  74. // params.put("SMS_CONTENT", "this is a message");
  75. // Gson gson = (new GsonBuilder()).disableHtmlEscaping().serializeNulls().create();
  76. System.out.println("--123---");
  77. }
  78. }