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 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 list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetype(achievementStatisticsParam); return new PageInfo(list); } @Override public PageInfo 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 list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetypeCate(achievementStatisticsParam); return new PageInfo(list); } @Override public PageInfo 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 list = achievementStatisticsDao.getQuestionInfoByObjtypeTimetypeAdcode(achievementStatisticsParam); return new PageInfo(list); } @Override public List getObjNum(String orgId) { List statisticsDtoList = achievementStatisticsDao.getObjNum(orgId); // statisticsDtoList.forEach(achievementStatisticsDto -> { // Map map = new HashMap<>(1); // map.put("id", orgId + achievementStatisticsDto.getPc()); // map.put("length", "9"); // map.put("year", DateUtils.getToday("yyyy")); // List 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; } }