QlygSyncSupervise.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package com.jtgh.qlyg.sync;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.List;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.data.jpa.domain.Specification;
  8. import org.springframework.stereotype.Component;
  9. import com.jtgh.qlyg.service.MonitorSuperviseReplyService;
  10. import com.jtgh.qlyg.service.MonitorSuperviseResultService;
  11. import com.jtgh.qlyg.service.MonitorSuperviseService;
  12. import com.jtgh.yjpt.common.Constants;
  13. import com.jtgh.yjpt.common.GlobalData;
  14. import com.jtgh.yjpt.common.PredicateModel;
  15. import com.jtgh.yjpt.common.PredicateModel.Operator;
  16. import com.jtgh.yjpt.common.SpecificationCreater;
  17. import com.jtgh.yjpt.controller.BaseController;
  18. import com.jtgh.yjpt.entity.BaseEntity;
  19. import com.jtgh.yjpt.entity.qlyg.SuperviseEntity;
  20. import com.jtgh.yjpt.entity.qlyg.SuperviseReplyEntity;
  21. import com.jtgh.yjpt.entity.qlyg.SuperviseResultEntity;
  22. import com.jtgh.yjpt.service.common.AccessoryService;
  23. import com.jtgh.yjpt.service.qlyg.SuperviseReplyService;
  24. import com.jtgh.yjpt.service.qlyg.SuperviseResultService;
  25. import com.jtgh.yjpt.service.qlyg.SuperviseService;
  26. /**
  27. * 同步督察督办信息
  28. *
  29. * @author liangz
  30. *
  31. */
  32. @Component
  33. public class QlygSyncSupervise extends BaseController {
  34. @Autowired
  35. private SuperviseService superviseService;
  36. @Autowired
  37. private SuperviseReplyService replyService;
  38. @Autowired
  39. private SuperviseResultService resultService;
  40. @Autowired
  41. private MonitorSuperviseService monitorSuperviseService;
  42. @Autowired
  43. private MonitorSuperviseReplyService monitorReplyService;
  44. @Autowired
  45. private MonitorSuperviseResultService monitorResultService;
  46. @Autowired
  47. private AccessoryService accessoryService;
  48. /**
  49. * 执行前一天督查督办信息
  50. */
  51. public void execute() {
  52. if (Constants.NO.equals(GlobalData.QLYG_SYNC))
  53. return;
  54. logger.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
  55. .format(new Date()) + "执行QlygSyncSupervise");
  56. // Calendar c = Calendar.getInstance();
  57. // c.set(Calendar.HOUR_OF_DAY, 0);
  58. // c.set(Calendar.MINUTE, 0);
  59. // c.set(Calendar.SECOND, 0);
  60. // c.set(Calendar.MILLISECOND, 0);
  61. // Date stopTime = c.getTime();
  62. // c.add(Calendar.DAY_OF_MONTH, -1);
  63. // Date startTime = c.getTime();
  64. // 同步督察督办基本信息
  65. List<PredicateModel> filterListSupervise = new ArrayList<PredicateModel>();
  66. addNotEmptyModel(filterListSupervise, "recordStatus",
  67. BaseEntity.RECORD_STATE_COMPLETED, Operator.EQ);
  68. // addNotEmptyModel(filterListSupervise, "superviseDate", startTime,
  69. // Operator.GTE);
  70. // addNotEmptyModel(filterListSupervise, "superviseDate", stopTime,
  71. // Operator.LT);
  72. addNotEmptyModel(filterListSupervise, "byzd5", GlobalData.QLYG_RES,
  73. Operator.NEQ);
  74. Specification<SuperviseEntity> specSupervise = SpecificationCreater
  75. .searchByPredicateModels(filterListSupervise);
  76. List<SuperviseEntity> listSupervise = superviseService
  77. .findAll(specSupervise);
  78. if (listSupervise != null) {
  79. for (SuperviseEntity superviseEntity : listSupervise) {
  80. monitorSuperviseService.save(superviseEntity, accessoryService
  81. .findByEntityIdAndEntityTypeAndType(
  82. superviseEntity.getId(),
  83. Constants.GGDM_ID_SUPERVISE, null));
  84. }
  85. }
  86. // 同步督办反馈信息
  87. filterListSupervise.clear();
  88. addNotEmptyModel(filterListSupervise, "recordStatus",
  89. BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
  90. // addNotEmptyModel(filterListSupervise, "replyDate", startTime,
  91. // Operator.GTE);
  92. // addNotEmptyModel(filterListSupervise, "replyDate", stopTime,
  93. // Operator.LT);
  94. addNotEmptyModel(filterListSupervise, "byzd5", GlobalData.QLYG_RES,
  95. Operator.NEQ);
  96. Specification<SuperviseReplyEntity> specReply = SpecificationCreater
  97. .searchByPredicateModels(filterListSupervise);
  98. List<SuperviseReplyEntity> listReply = replyService.findAll(specReply);
  99. for (SuperviseReplyEntity superviseReplyEntity : listReply) {
  100. monitorReplyService.save(superviseReplyEntity, accessoryService
  101. .findByEntityIdAndEntityTypeAndType(
  102. superviseReplyEntity.getId(),
  103. Constants.GGDM_ID_SUPERVISE_REPLY, null));
  104. }
  105. // 同步督办结论信息
  106. filterListSupervise.clear();
  107. addNotEmptyModel(filterListSupervise, "recordStatus",
  108. BaseEntity.RECORD_STATE_COMPLETED, Operator.EQ);
  109. // addNotEmptyModel(filterListSupervise, "endDate", startTime,
  110. // Operator.GTE);
  111. // addNotEmptyModel(filterListSupervise, "endDate", stopTime,
  112. // Operator.LT);
  113. addNotEmptyModel(filterListSupervise, "byzd5", GlobalData.QLYG_RES,
  114. Operator.NEQ);
  115. Specification<SuperviseResultEntity> specResult = SpecificationCreater
  116. .searchByPredicateModels(filterListSupervise);
  117. List<SuperviseResultEntity> listResult = resultService
  118. .findAll(specResult);
  119. if (listResult != null) {
  120. for (SuperviseResultEntity superviseResultEntity : listResult) {
  121. monitorResultService.saveEntity(superviseResultEntity);
  122. }
  123. }
  124. }
  125. }