| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- package cn.com.goldenwater.dcproj.service.impl;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.dao.AchievementStatisticsDao;
- import cn.com.goldenwater.dcproj.dao.AttInspTypeDao;
- import cn.com.goldenwater.dcproj.dao.BisInspAllDao;
- import cn.com.goldenwater.dcproj.dto.AchievementStatisticsDto;
- import cn.com.goldenwater.dcproj.dto.BisInspAllDto;
- import cn.com.goldenwater.dcproj.model.AttInspType;
- import cn.com.goldenwater.dcproj.param.AchievementStatisticsParam;
- import cn.com.goldenwater.dcproj.service.AchievementStatisticsService;
- import cn.com.goldenwater.dcproj.task.DayTypeRegService;
- import cn.com.goldenwater.dcproj.utils.DateUtils;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * @author lhc
- * @date 2020-12-25
- */
- @Service
- @Transactional
- public class AchievementStatisticsServiceImpl extends AbstractCrudService<AchievementStatisticsDto, AchievementStatisticsParam> implements AchievementStatisticsService {
- @Autowired
- private AchievementStatisticsDao achievementStatisticsDao;
- @Autowired
- private AttInspTypeDao attInspTypeDao;
- @Autowired
- private BisInspAllDao bisInspAllDao;
- public AchievementStatisticsServiceImpl(AchievementStatisticsDao achievementStatisticsDao) {
- super(achievementStatisticsDao);
- this.achievementStatisticsDao = achievementStatisticsDao;
- }
- @Override
- public PageInfo getQuestionInfoByObjtypeTimetype(AchievementStatisticsParam achievementStatisticsParam) {
- AttInspType attInspType = attInspTypeDao.get(achievementStatisticsParam.getObjType());
- achievementStatisticsParam.setObjType(attInspType.getPtype());
- if (achievementStatisticsParam.getTimeType() != null && !achievementStatisticsParam.getTimeType().equals("")) {
- achievementStatisticsParam.setSttime(setTimetype(achievementStatisticsParam).getSttime());
- achievementStatisticsParam.setEttime(setTimetype(achievementStatisticsParam).getEttime());
- }
- PageHelper.startPage(achievementStatisticsParam.getPageNum(), achievementStatisticsParam.getPageSize());
- List<AchievementStatisticsDto> list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetype(achievementStatisticsParam);
- return new PageInfo(list);
- }
- @Override
- public PageInfo<AchievementStatisticsDto> getQuestionInfoByObjtypeTimetypeCate(AchievementStatisticsParam achievementStatisticsParam) {
- if (achievementStatisticsParam.getObjType() != null && !achievementStatisticsParam.getObjType().equals("")) {
- AttInspType attInspType = attInspTypeDao.get(achievementStatisticsParam.getObjType());
- achievementStatisticsParam.setObjType(attInspType.getPtype());
- }
- if (achievementStatisticsParam.getTimeType() != null && !achievementStatisticsParam.getTimeType().equals("")) {
- achievementStatisticsParam.setSttime(setTimetype(achievementStatisticsParam).getSttime());
- achievementStatisticsParam.setEttime(setTimetype(achievementStatisticsParam).getEttime());
- }
- PageHelper.startPage(achievementStatisticsParam.getPageNum(), achievementStatisticsParam.getPageSize());
- List<AchievementStatisticsDto> list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetypeCate(achievementStatisticsParam);
- return new PageInfo(list);
- }
- @Override
- public PageInfo<AchievementStatisticsDto> getQuestionInfoByObjtypeTimetypeAdcode(AchievementStatisticsParam achievementStatisticsParam) {
- if (achievementStatisticsParam.getObjType() != null && !achievementStatisticsParam.getObjType().equals("")) {
- AttInspType attInspType = attInspTypeDao.get(achievementStatisticsParam.getObjType());
- achievementStatisticsParam.setObjType(attInspType.getPtype());
- }
- if (achievementStatisticsParam.getTimeType() != null && !achievementStatisticsParam.getTimeType().equals("")) {
- achievementStatisticsParam.setSttime(setTimetype(achievementStatisticsParam).getSttime());
- achievementStatisticsParam.setEttime(setTimetype(achievementStatisticsParam).getEttime());
- }
- if (achievementStatisticsParam.getAdcode().substring(2, 4).equals("00")) {
- achievementStatisticsParam.setAdcode(achievementStatisticsParam.getOrgId().substring(1));
- } else {
- achievementStatisticsParam.setAdcode(achievementStatisticsParam.getAdcode().substring(0, 4));
- }
- PageHelper.startPage(achievementStatisticsParam.getPageNum(), achievementStatisticsParam.getPageSize());
- List<AchievementStatisticsDto> list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetypeAdcode(achievementStatisticsParam);
- return new PageInfo(list);
- }
- @Override
- public List<AchievementStatisticsDto> getObjNum(String orgId) {
- List<AchievementStatisticsDto> statisticsDtoList = achievementStatisticsDao.getObjNum(orgId);
- // statisticsDtoList.forEach(achievementStatisticsDto -> {
- // Map<String, String> map = new HashMap<>(1);
- // map.put("id", orgId + achievementStatisticsDto.getPc());
- // map.put("length", "9");
- // map.put("year", DateUtils.getToday("yyyy"));
- // List<BisInspAllDto> bisInspAllDtoList = bisInspAllDao.listByMap2(map);
- // achievementStatisticsDto.setPc(bisInspAllDtoList.stream()
- // .map(BisInspAllDto::getPnm)
- // .distinct()
- // .collect(Collectors.joining("、")));
- // });
- return statisticsDtoList;
- }
- public AchievementStatisticsParam setTimetype(AchievementStatisticsParam achievementStatisticsParam) {
- Date entm = DayTypeRegService.getToday();
- Calendar sttm = Calendar.getInstance();
- switch (achievementStatisticsParam.getTimeType()) {
- // 近一个月
- case "1":
- sttm.add(Calendar.MONTH, -1);
- break;
- // 近三个月
- case "2":
- sttm.add(Calendar.MONTH, -3);
- break;
- // 近半年
- case "3":
- sttm.add(Calendar.MONTH, -6);
- break;
- // 近一年
- case "4":
- sttm.add(Calendar.YEAR, -1);
- break;
- case "6":
- sttm.set(Integer.parseInt(DateUtils.getToday("yyyy")), Calendar.JANUARY, 1);
- break;
- default:
- }
- achievementStatisticsParam.setSttime(DateUtils.Calendar2Str(sttm, "yyyy-MM-dd"));
- achievementStatisticsParam.setSttime(DateUtils.Date2Str(entm, "yyyy-MM-dd"));
- return achievementStatisticsParam;
- }
- }
|