e38c64b40cb0bfa5e3e7c1baa7c0105314e68896.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package com.chinacreator.process.job;
  2. import java.net.URLEncoder;
  3. import java.sql.SQLException;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. import org.apache.log4j.Logger;
  8. import org.quartz.DisallowConcurrentExecution;
  9. import org.quartz.PersistJobDataAfterExecution;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import com.chinacreator.common.util.URLUtil;
  12. import com.chinacreator.process.dao.AsynDao;
  13. import com.chinacreator.process.util.JsonUtil;
  14. @PersistJobDataAfterExecution
  15. @DisallowConcurrentExecution
  16. public class Tencent12NotifyJob {
  17. private static final String notifyurl = "http://10.199.99.142:8090/video-activity/notify";
  18. private static final String orderyurl = "http://10.199.99.142:8090/video-activity/notifyOrder";
  19. private static final String vipurl = "http://10.199.99.142:8090/video-activity/notifyVip";
  20. private static Logger log = Logger.getLogger("tenc12log");
  21. @Autowired
  22. private AsynDao asynDao;
  23. public void doProcess() throws Exception {
  24. try{
  25. order();
  26. }catch(Exception e){
  27. e.printStackTrace();
  28. }
  29. try{
  30. vip();
  31. }catch(Exception e){
  32. e.printStackTrace();
  33. }
  34. try{
  35. sync();
  36. }catch(Exception e){
  37. e.printStackTrace();
  38. }
  39. }
  40. public void order() throws SQLException{
  41. List<String> orderlist = asynDao.getOrderOrderid();
  42. Map<String,String> orderMap = new HashMap<String, String>();
  43. if(orderlist != null){
  44. for (String orderid : orderlist) {
  45. orderMap.put("action", "order");
  46. orderMap.put("orderid", orderid);
  47. String result = "";
  48. try{
  49. result = URLUtil.get(orderyurl+"?orderid="+orderid, 5000);
  50. }catch(Exception e){
  51. e.printStackTrace();
  52. result = e.getMessage();
  53. }finally {
  54. orderMap.put("result", result);
  55. log.info(JsonUtil.objectToJson(orderMap));
  56. }
  57. }
  58. }
  59. }
  60. public void vip() throws SQLException{
  61. List<String> orderlist = asynDao.getvipOrderid();
  62. Map<String,String> orderMap = new HashMap<String, String>();
  63. if(orderlist != null){
  64. for (String orderid : orderlist) {
  65. orderMap.put("action", "vip");
  66. orderMap.put("orderid", orderid);
  67. String result = "";
  68. try{
  69. result = URLUtil.get(vipurl+"?orderid="+orderid, 5000);
  70. }catch(Exception e){
  71. e.printStackTrace();
  72. result = e.getMessage();
  73. }finally {
  74. orderMap.put("result", result);
  75. log.info(JsonUtil.objectToJson(orderMap));
  76. }
  77. }
  78. }
  79. }
  80. public void sync() throws SQLException{
  81. List<String> orderlist = asynDao.getsyncOrderid();
  82. Map<String,String> orderMap = new HashMap<String, String>();
  83. if(orderlist != null){
  84. for (String orderid : orderlist) {
  85. orderMap.put("action", "sync");
  86. orderMap.put("orderid", orderid);
  87. String result = "";
  88. try{
  89. result = URLUtil.get(notifyurl+"?orderid="+orderid, 5000);
  90. }catch(Exception e){
  91. e.printStackTrace();
  92. result = e.getMessage();
  93. }finally {
  94. orderMap.put("result", result);
  95. log.info(JsonUtil.objectToJson(orderMap));
  96. }
  97. }
  98. }
  99. }
  100. }