QlygSyncApply.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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.apache.log4j.Logger;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.data.jpa.domain.Specification;
  9. import org.springframework.stereotype.Component;
  10. import com.jtgh.qlyg.service.InfApplyProcessService;
  11. import com.jtgh.qlyg.service.InfApplyResultService;
  12. import com.jtgh.qlyg.service.InfApplyService;
  13. import com.jtgh.yjpt.common.Constants;
  14. import com.jtgh.yjpt.common.GlobalData;
  15. import com.jtgh.yjpt.common.PredicateModel;
  16. import com.jtgh.yjpt.common.PredicateModel.Operator;
  17. import com.jtgh.yjpt.common.SpecificationCreater;
  18. import com.jtgh.yjpt.controller.BaseController;
  19. import com.jtgh.yjpt.entity.BaseEntity;
  20. import com.jtgh.yjpt.entity.qlyg.ApplyEntity;
  21. import com.jtgh.yjpt.entity.qlyg.ApplyProcessEntity;
  22. import com.jtgh.yjpt.entity.qlyg.ApplyResultEntity;
  23. import com.jtgh.yjpt.service.qlyg.ApplyProcessService;
  24. import com.jtgh.yjpt.service.qlyg.ApplyResultService;
  25. import com.jtgh.yjpt.service.qlyg.ApplyService;
  26. /**
  27. * 同步办件信息
  28. *
  29. * @author masn
  30. *
  31. */
  32. @Component
  33. public class QlygSyncApply extends BaseController {
  34. /** 日志记录 */
  35. private Logger logger = Logger.getLogger(getClass());
  36. @Autowired
  37. private ApplyService applyService;
  38. @Autowired
  39. private ApplyProcessService applyProcessService;
  40. @Autowired
  41. private ApplyResultService applyResultService;
  42. @Autowired
  43. private InfApplyService infApplyService;
  44. @Autowired
  45. private InfApplyProcessService infApplyProcessService;
  46. @Autowired
  47. private InfApplyResultService infApplyResultService;
  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()) + "执行QlygSyncApply");
  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> filterListApply = new ArrayList<PredicateModel>();
  66. addNotEmptyModel(filterListApply, "recordStatus",
  67. BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
  68. // addNotEmptyModel(filterListApply, "createDate", startTime,
  69. // Operator.GTE);
  70. // addNotEmptyModel(filterListApply, "createDate", stopTime,
  71. // Operator.LT);
  72. addNotEmptyModel(filterListApply, "byzd5", GlobalData.QLYG_RES,
  73. Operator.NEQ);
  74. Specification<ApplyEntity> specApply = SpecificationCreater
  75. .searchByPredicateModels(filterListApply);
  76. List<ApplyEntity> listApply = applyService.findAll(specApply);
  77. if (listApply != null && listApply.size() > 0) {
  78. for (ApplyEntity apply : listApply) {
  79. // 保存办件基本信息
  80. infApplyService.save(apply);
  81. }
  82. }
  83. // 同步办件过程信息
  84. List<PredicateModel> filterListApplyProcess = new ArrayList<PredicateModel>();
  85. addNotEmptyModel(filterListApplyProcess, "recordStatus",
  86. BaseEntity.RECORD_STATE_COMPLETED, Operator.EQ);
  87. // addNotEmptyModel(filterListApplyProcess, "createDate", startTime,
  88. // Operator.GTE);
  89. // addNotEmptyModel(filterListApplyProcess, "createDate", stopTime,
  90. // Operator.LT);
  91. addNotEmptyModel(filterListApply, "byzd5", GlobalData.QLYG_RES,
  92. Operator.NEQ);
  93. Specification<ApplyProcessEntity> specApplyProcess = SpecificationCreater
  94. .searchByPredicateModels(filterListApplyProcess);
  95. List<ApplyProcessEntity> listApplyProcess = applyProcessService
  96. .findAll(specApplyProcess);
  97. if (listApplyProcess != null && listApplyProcess.size() > 0) {
  98. for (ApplyProcessEntity applyProcess : listApplyProcess) {
  99. // 保存办件过程 保存到权力阳光库
  100. infApplyProcessService.save(applyProcess);
  101. }
  102. }
  103. // 同步办件过程信息
  104. List<PredicateModel> filterListApplyResult = new ArrayList<PredicateModel>();
  105. addNotEmptyModel(filterListApplyResult, "recordStatus",
  106. BaseEntity.RECORD_STATE_DELETE, Operator.NEQ);
  107. // addNotEmptyModel(filterListApplyResult, "createDate", startTime,
  108. // Operator.GTE);
  109. // addNotEmptyModel(filterListApplyResult, "createDate", stopTime,
  110. // Operator.LT);
  111. addNotEmptyModel(filterListApply, "byzd5", GlobalData.QLYG_RES,
  112. Operator.NEQ);
  113. Specification<ApplyResultEntity> specApplyResult = SpecificationCreater
  114. .searchByPredicateModels(filterListApplyResult);
  115. List<ApplyResultEntity> listApplyResult = applyResultService
  116. .findAll(specApplyResult);
  117. if (listApplyResult != null && listApplyResult.size() > 0) {
  118. for (ApplyResultEntity applyResult : listApplyResult) {
  119. // 保存办件过程
  120. infApplyResultService.save(applyResult);
  121. }
  122. }
  123. }
  124. }