8e477801b875d420a94780ebfe35e2c74b67147f.svn-base 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package cn.com.goldenwater.dcproj.task;
  2. import cn.com.goldenwater.dcproj.dao.TacInspYearBatchGroupPersDao;
  3. import cn.com.goldenwater.dcproj.dao.TacNoticeReceiptDao;
  4. import cn.com.goldenwater.dcproj.model.TacInspYearBatchGroupPers;
  5. import cn.com.goldenwater.dcproj.model.TacNoticeReceipt;
  6. import cn.com.goldenwater.dcproj.param.TacInspYearBatchGroupPersParam;
  7. import cn.com.goldenwater.dcproj.param.TacNoticeReceiptParam;
  8. import cn.com.goldenwater.dcproj.utils.DateUtils;
  9. import org.apache.commons.lang3.StringUtils;
  10. import org.quartz.DisallowConcurrentExecution;
  11. import org.quartz.Job;
  12. import org.quartz.JobExecutionContext;
  13. import org.slf4j.Logger;
  14. import org.slf4j.LoggerFactory;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.beans.factory.annotation.Value;
  17. import java.util.Date;
  18. import java.util.List;
  19. @DisallowConcurrentExecution
  20. public class TaskChangeTacJoinService implements Job {
  21. @Value("${api.url}")
  22. private String apiUrl;
  23. private Logger log = LoggerFactory.getLogger(getClass());
  24. @Autowired
  25. private TacNoticeReceiptDao tacNoticeReceiptDao;
  26. @Autowired
  27. private TacInspYearBatchGroupPersDao tacInspYearBatchGroupPersDao;
  28. /**
  29. * 要处理的 PROCESS_STATUS
  30. */
  31. private final static String PROCESS_STATUS = "1";
  32. @Override
  33. public void execute(JobExecutionContext arg0) {
  34. log.info("通过实时同步的稽察通知短信回执信息改变稽察人员参与情况:TaskChangeTacJoinService.execute()...");
  35. // 查询24小时内通知并发送短信成功的稽察人员无回复,则删除该稽察分组人员的信息
  36. TacInspYearBatchGroupPersParam sqlGroupPers = new TacInspYearBatchGroupPersParam();
  37. sqlGroupPers.setIsSms("1");
  38. sqlGroupPers.setIsNotice("1");
  39. sqlGroupPers.setIsJoin("0");
  40. sqlGroupPers.setEntm("24");//结束时间范围为24小时
  41. //24小时无回复的将人员信息删除。
  42. List<TacInspYearBatchGroupPers> getNoReplytacInspYearBatchGroupPers = tacInspYearBatchGroupPersDao.getNoReply(sqlGroupPers);
  43. for (TacInspYearBatchGroupPers getNoReplytacInspYearBatchGroupPer : getNoReplytacInspYearBatchGroupPers) {
  44. getNoReplytacInspYearBatchGroupPer.setIsJoin("3");//24小时未该表isjoin的值则默认未回复
  45. getNoReplytacInspYearBatchGroupPer.setUpTm(new Date());
  46. tacInspYearBatchGroupPersDao.update(getNoReplytacInspYearBatchGroupPer);
  47. }
  48. List<TacInspYearBatchGroupPers> tacInspYearBatchGroupPers = tacInspYearBatchGroupPersDao.confirmerGroupPers(sqlGroupPers);
  49. for (TacInspYearBatchGroupPers tacInspYearBatchGroupPer : tacInspYearBatchGroupPers) {
  50. String phone = tacInspYearBatchGroupPer.getPhone();
  51. TacNoticeReceiptParam tacNoticeReceiptParam = new TacNoticeReceiptParam();
  52. tacNoticeReceiptParam.setPhoneNumber(phone);
  53. tacNoticeReceiptParam.setSttm(DateUtils.Date2Str(tacInspYearBatchGroupPer.getSendsmsTm(), "yyyy-MM-dd HH:mm:ss"));
  54. tacNoticeReceiptParam.setProcessStatus("0");
  55. List<TacNoticeReceipt> list = tacNoticeReceiptDao.findList(tacNoticeReceiptParam);
  56. if (list != null && list.size() > 0) {//同一个号码回复短信多条记录则按照最后一条修改人员状态
  57. TacNoticeReceipt tacNoticeReceipt = list.get(0);
  58. String content = tacNoticeReceipt.getContent();
  59. if (StringUtils.isNotBlank(content)) {//回复内容
  60. if ("1".equals(content)) {
  61. tacInspYearBatchGroupPer.setIsJoin("1");
  62. tacInspYearBatchGroupPer.setUpTm(new Date());
  63. tacInspYearBatchGroupPersDao.update(tacInspYearBatchGroupPer);
  64. } else {
  65. tacInspYearBatchGroupPer.setIsJoin("2");//回复非1则为回复不参加
  66. tacInspYearBatchGroupPer.setUpTm(new Date());
  67. tacInspYearBatchGroupPersDao.update(tacInspYearBatchGroupPer);
  68. }
  69. } else {//回复内容为空,则默认不参加删除分组人员数据
  70. tacInspYearBatchGroupPer.setIsJoin("2");//回复非1则为回复不参加
  71. tacInspYearBatchGroupPer.setUpTm(new Date());
  72. tacInspYearBatchGroupPersDao.update(tacInspYearBatchGroupPer);
  73. }
  74. //处理过的短信回复将处理标识改变
  75. for (TacNoticeReceipt noticeReceipt : list) {
  76. noticeReceipt.setProcessStatus(PROCESS_STATUS);
  77. tacNoticeReceiptDao.update(noticeReceipt);
  78. }
  79. }
  80. }
  81. }
  82. }