cc2eec5ab4a61febf55f3166fab131d95f01f0b9.svn-base 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.AchievementStatisticsDao;
  4. import cn.com.goldenwater.dcproj.dao.AttInspTypeDao;
  5. import cn.com.goldenwater.dcproj.dao.BisInspAllDao;
  6. import cn.com.goldenwater.dcproj.dto.AchievementStatisticsDto;
  7. import cn.com.goldenwater.dcproj.dto.BisInspAllDto;
  8. import cn.com.goldenwater.dcproj.model.AttInspType;
  9. import cn.com.goldenwater.dcproj.param.AchievementStatisticsParam;
  10. import cn.com.goldenwater.dcproj.service.AchievementStatisticsService;
  11. import cn.com.goldenwater.dcproj.task.DayTypeRegService;
  12. import cn.com.goldenwater.dcproj.utils.DateUtils;
  13. import com.github.pagehelper.PageHelper;
  14. import com.github.pagehelper.PageInfo;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Service;
  17. import org.springframework.transaction.annotation.Transactional;
  18. import java.util.*;
  19. import java.util.stream.Collectors;
  20. /**
  21. * @author lhc
  22. * @date 2020-12-25
  23. */
  24. @Service
  25. @Transactional
  26. public class AchievementStatisticsServiceImpl extends AbstractCrudService<AchievementStatisticsDto, AchievementStatisticsParam> implements AchievementStatisticsService {
  27. @Autowired
  28. private AchievementStatisticsDao achievementStatisticsDao;
  29. @Autowired
  30. private AttInspTypeDao attInspTypeDao;
  31. @Autowired
  32. private BisInspAllDao bisInspAllDao;
  33. public AchievementStatisticsServiceImpl(AchievementStatisticsDao achievementStatisticsDao) {
  34. super(achievementStatisticsDao);
  35. this.achievementStatisticsDao = achievementStatisticsDao;
  36. }
  37. @Override
  38. public PageInfo getQuestionInfoByObjtypeTimetype(AchievementStatisticsParam achievementStatisticsParam) {
  39. AttInspType attInspType = attInspTypeDao.get(achievementStatisticsParam.getObjType());
  40. achievementStatisticsParam.setObjType(attInspType.getPtype());
  41. if (achievementStatisticsParam.getTimeType() != null && !achievementStatisticsParam.getTimeType().equals("")) {
  42. achievementStatisticsParam.setSttime(setTimetype(achievementStatisticsParam).getSttime());
  43. achievementStatisticsParam.setEttime(setTimetype(achievementStatisticsParam).getEttime());
  44. }
  45. PageHelper.startPage(achievementStatisticsParam.getPageNum(), achievementStatisticsParam.getPageSize());
  46. List<AchievementStatisticsDto> list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetype(achievementStatisticsParam);
  47. return new PageInfo(list);
  48. }
  49. @Override
  50. public PageInfo<AchievementStatisticsDto> getQuestionInfoByObjtypeTimetypeCate(AchievementStatisticsParam achievementStatisticsParam) {
  51. if (achievementStatisticsParam.getObjType() != null && !achievementStatisticsParam.getObjType().equals("")) {
  52. AttInspType attInspType = attInspTypeDao.get(achievementStatisticsParam.getObjType());
  53. achievementStatisticsParam.setObjType(attInspType.getPtype());
  54. }
  55. if (achievementStatisticsParam.getTimeType() != null && !achievementStatisticsParam.getTimeType().equals("")) {
  56. achievementStatisticsParam.setSttime(setTimetype(achievementStatisticsParam).getSttime());
  57. achievementStatisticsParam.setEttime(setTimetype(achievementStatisticsParam).getEttime());
  58. }
  59. PageHelper.startPage(achievementStatisticsParam.getPageNum(), achievementStatisticsParam.getPageSize());
  60. List<AchievementStatisticsDto> list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetypeCate(achievementStatisticsParam);
  61. return new PageInfo(list);
  62. }
  63. @Override
  64. public PageInfo<AchievementStatisticsDto> getQuestionInfoByObjtypeTimetypeAdcode(AchievementStatisticsParam achievementStatisticsParam) {
  65. if (achievementStatisticsParam.getObjType() != null && !achievementStatisticsParam.getObjType().equals("")) {
  66. AttInspType attInspType = attInspTypeDao.get(achievementStatisticsParam.getObjType());
  67. achievementStatisticsParam.setObjType(attInspType.getPtype());
  68. }
  69. if (achievementStatisticsParam.getTimeType() != null && !achievementStatisticsParam.getTimeType().equals("")) {
  70. achievementStatisticsParam.setSttime(setTimetype(achievementStatisticsParam).getSttime());
  71. achievementStatisticsParam.setEttime(setTimetype(achievementStatisticsParam).getEttime());
  72. }
  73. if (achievementStatisticsParam.getAdcode().substring(2, 4).equals("00")) {
  74. achievementStatisticsParam.setAdcode(achievementStatisticsParam.getOrgId().substring(1));
  75. } else {
  76. achievementStatisticsParam.setAdcode(achievementStatisticsParam.getAdcode().substring(0, 4));
  77. }
  78. PageHelper.startPage(achievementStatisticsParam.getPageNum(), achievementStatisticsParam.getPageSize());
  79. List<AchievementStatisticsDto> list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetypeAdcode(achievementStatisticsParam);
  80. return new PageInfo(list);
  81. }
  82. @Override
  83. public List<AchievementStatisticsDto> getObjNum(String orgId) {
  84. List<AchievementStatisticsDto> statisticsDtoList = achievementStatisticsDao.getObjNum(orgId);
  85. // statisticsDtoList.forEach(achievementStatisticsDto -> {
  86. // Map<String, String> map = new HashMap<>(1);
  87. // map.put("id", orgId + achievementStatisticsDto.getPc());
  88. // map.put("length", "9");
  89. // map.put("year", DateUtils.getToday("yyyy"));
  90. // List<BisInspAllDto> bisInspAllDtoList = bisInspAllDao.listByMap2(map);
  91. // achievementStatisticsDto.setPc(bisInspAllDtoList.stream()
  92. // .map(BisInspAllDto::getPnm)
  93. // .distinct()
  94. // .collect(Collectors.joining("、")));
  95. // });
  96. return statisticsDtoList;
  97. }
  98. public AchievementStatisticsParam setTimetype(AchievementStatisticsParam achievementStatisticsParam) {
  99. Date entm = DayTypeRegService.getToday();
  100. Calendar sttm = Calendar.getInstance();
  101. switch (achievementStatisticsParam.getTimeType()) {
  102. // 近一个月
  103. case "1":
  104. sttm.add(Calendar.MONTH, -1);
  105. break;
  106. // 近三个月
  107. case "2":
  108. sttm.add(Calendar.MONTH, -3);
  109. break;
  110. // 近半年
  111. case "3":
  112. sttm.add(Calendar.MONTH, -6);
  113. break;
  114. // 近一年
  115. case "4":
  116. sttm.add(Calendar.YEAR, -1);
  117. break;
  118. case "6":
  119. sttm.set(Integer.parseInt(DateUtils.getToday("yyyy")), Calendar.JANUARY, 1);
  120. break;
  121. default:
  122. }
  123. achievementStatisticsParam.setSttime(DateUtils.Calendar2Str(sttm, "yyyy-MM-dd"));
  124. achievementStatisticsParam.setSttime(DateUtils.Date2Str(entm, "yyyy-MM-dd"));
  125. return achievementStatisticsParam;
  126. }
  127. }