QlygSyncCheckLog.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.jtgh.qlyg.sync;
  2. import java.math.BigDecimal;
  3. import java.text.SimpleDateFormat;
  4. import java.util.Calendar;
  5. import java.util.Date;
  6. import java.util.List;
  7. import org.apache.log4j.Logger;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9. import org.springframework.stereotype.Component;
  10. import com.jtgh.qlyg.entity.InfCheckLogEntity;
  11. import com.jtgh.qlyg.service.InfCheckLogService;
  12. import com.jtgh.yjpt.common.Constants;
  13. import com.jtgh.yjpt.common.GlobalData;
  14. import com.jtgh.yjpt.common.Utils;
  15. import com.jtgh.yjpt.controller.BaseController;
  16. import com.jtgh.yjpt.service.common.LogService;
  17. /**
  18. * 同步登录信息
  19. *
  20. * @author masn
  21. *
  22. */
  23. @Component
  24. public class QlygSyncCheckLog extends BaseController {
  25. /** 日志记录 */
  26. private Logger logger = Logger.getLogger(getClass());
  27. @Autowired
  28. private LogService logService;
  29. @Autowired
  30. private InfCheckLogService infCheckLogService;
  31. /**
  32. * 执行前一天登录情况
  33. */
  34. public void execute() {
  35. if (Constants.NO.equals(GlobalData.QLYG_SYNC))
  36. return;
  37. logger.info(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
  38. .format(new Date()) + "执行QlygSyncCheckLog");
  39. Calendar c = Calendar.getInstance();
  40. c.set(Calendar.HOUR_OF_DAY, 0);
  41. c.set(Calendar.MINUTE, 0);
  42. c.set(Calendar.SECOND, 0);
  43. c.set(Calendar.MILLISECOND, 0);
  44. Date stopTime = c.getTime();
  45. c.add(Calendar.DAY_OF_MONTH, -1);
  46. Date startTime = c.getTime();
  47. List<Object[]> logs = logService.findInfCheckLog(startTime, stopTime);
  48. if (logs != null && logs.size() > 0) {
  49. for (Object[] log : logs) {
  50. InfCheckLogEntity checkLog = new InfCheckLogEntity();
  51. String dept_code = GlobalData.DEPT_CODE;
  52. if (Utils.getCurrentUser() != null) {
  53. dept_code = Utils.getCurrentUser().getSzd().getByzd4()
  54. + "JT";
  55. }
  56. checkLog.setCheckId(generateQlygNo(dept_code,
  57. generateEntityId(Constants.QLYG_SEQ_INF_CHECK_LOG)));
  58. checkLog.setNo(checkLog.getCheckId());
  59. checkLog.setCheckPerson((String) log[0]);
  60. checkLog.setOrgId((String) log[1]);
  61. checkLog.setCheckDate(c.getTime());
  62. checkLog.setCheckNumber(((BigDecimal) log[2]).intValue());
  63. checkLog.setCheckInteger(((BigDecimal) log[3]).intValue());
  64. checkLog.setCheckType(Constants.QLYG_CHECK_TYPE_APPLY);
  65. infCheckLogService.save(checkLog);
  66. }
  67. }
  68. }
  69. }