QlygSyncSuperviseStat.java 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. package com.jtgh.qlyg.sync;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Calendar;
  5. import java.util.Date;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import org.apache.log4j.Logger;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.data.jpa.domain.Specification;
  11. import org.springframework.stereotype.Component;
  12. import com.jtgh.qlyg.entity.SuperviseStatEntity;
  13. import com.jtgh.qlyg.service.SuperviseStatService;
  14. import com.jtgh.yjpt.common.Constants;
  15. import com.jtgh.yjpt.common.GlobalData;
  16. import com.jtgh.yjpt.common.PredicateModel;
  17. import com.jtgh.yjpt.common.SpecificationCreater;
  18. import com.jtgh.yjpt.common.Utils;
  19. import com.jtgh.yjpt.controller.BaseController;
  20. import com.jtgh.yjpt.entity.common.CodeEntity;
  21. import com.jtgh.yjpt.service.common.CodeService;
  22. import com.jtgh.yjpt.service.qlyg.ApplyService;
  23. /**
  24. * 同步监察统计信息
  25. *
  26. * @author masn
  27. *
  28. */
  29. @Component
  30. public class QlygSyncSuperviseStat extends BaseController {
  31. /** 日志记录 */
  32. private Logger logger = Logger.getLogger(getClass());
  33. @Autowired
  34. private CodeService codeService;
  35. @Autowired
  36. private ApplyService applyService;
  37. @Autowired
  38. private SuperviseStatService superviseStatService;
  39. /**
  40. * 执行上月监察统计信息情况
  41. */
  42. public void execute() {
  43. if (Constants.NO.equals(GlobalData.QLYG_SYNC))
  44. return;
  45. logger.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
  46. .format(new Date()) + "执行QlygSyncLoginLog");
  47. Calendar c = Calendar.getInstance();
  48. c.set(Calendar.DAY_OF_MONTH, 1);
  49. c.set(Calendar.HOUR_OF_DAY, 0);
  50. c.set(Calendar.MINUTE, 0);
  51. c.set(Calendar.SECOND, 0);
  52. c.set(Calendar.MILLISECOND, 0);
  53. Date stopTime = c.getTime();
  54. c.add(Calendar.MONTH, -1);
  55. Date startTime = c.getTime();
  56. List<PredicateModel> filterList = new ArrayList<PredicateModel>();
  57. addNotEmptyModel(filterList, "id", GlobalData.CITY_CODE,
  58. PredicateModel.Operator.LIKE_R);
  59. addNotEmptyModel(filterList, "groupcode", "SZD",
  60. PredicateModel.Operator.EQ);
  61. Specification<CodeEntity> spec = SpecificationCreater
  62. .searchByPredicateModels(filterList);
  63. List<CodeEntity> szdList = codeService.findAll(spec);
  64. if (szdList != null && szdList.size() > 0) {
  65. for (CodeEntity szd : szdList) {
  66. HashMap<String, Object> stat = applyService.findSuperviseStat(
  67. startTime, stopTime, szd.getByzd4());
  68. if (stat != null) {
  69. SuperviseStatEntity entity = new SuperviseStatEntity();
  70. String dept_code = GlobalData.DEPT_CODE;
  71. if (Utils.getCurrentUser() != null) {
  72. dept_code = Utils.getCurrentUser().getSzd().getByzd4()
  73. + "JT";
  74. }
  75. entity.setNo(generateQlygNo(dept_code,
  76. generateEntityId(Constants.QLYG_SEQ_SUPERVISE_STAT)));
  77. entity.setOrgId(szd.getByzd4());
  78. entity.setStatDate(new SimpleDateFormat("yyyyMM")
  79. .format(startTime));
  80. entity.setAccept(stat.get("accept") == null ? 0
  81. : ((Long) stat.get("accept")).intValue());
  82. entity.setBanjielvAhead(stat.get("banjielvAhead") == null ? 0
  83. : (Double) stat.get("banjielvAhead"));
  84. entity.setMonitorSum(stat.get("monitorSum") == null ? 0
  85. : (Double) stat.get("monitorSum"));
  86. entity.setAlarmSum(stat.get("alarmSum") == null ? 0
  87. : (Double) stat.get("alarmSum"));
  88. entity.setSuperviseSum(stat.get("superviseSum") == null ? 0
  89. : ((Long) stat.get("superviseSum")).intValue());
  90. entity.setSuperviseProblermSum(stat
  91. .get("superviseProblermSum") == null ? 0
  92. : ((Long) stat.get("superviseProblermSum"))
  93. .intValue());
  94. entity.setComplaintsSum(stat.get("complaintsSum") == null ? 0
  95. : ((Long) stat.get("complaintsSum")).intValue());
  96. entity.setComplaintsProblermSum(stat
  97. .get("complaintsProblermSum") == null ? 0
  98. : ((Long) stat.get("complaintsProblermSum"))
  99. .intValue());
  100. superviseStatService.save(entity);
  101. }
  102. }
  103. }
  104. }
  105. }