package cn.com.goldenwater.dcproj.service.impl.homepage; import cn.com.goldenwater.dcproj.constValue.AdCodeLabel; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.BisInspTypeEnum; import cn.com.goldenwater.dcproj.dao.BisInspAllObjDao; import cn.com.goldenwater.dcproj.dao.BisInspAllRlationPersDao; import cn.com.goldenwater.dcproj.dao.BisInspPblmDao; import cn.com.goldenwater.dcproj.dao.PersPositionDao; import cn.com.goldenwater.dcproj.dto.*; import cn.com.goldenwater.dcproj.model.BisInspPblm; import cn.com.goldenwater.dcproj.model.DuchaObj; import cn.com.goldenwater.dcproj.model.ObjPerson; import cn.com.goldenwater.dcproj.param.IndexParam; import cn.com.goldenwater.dcproj.param.IndexParamPage; import cn.com.goldenwater.dcproj.param.IndexPblmParam; import cn.com.goldenwater.dcproj.service.OlBisInspOrgService; import cn.com.goldenwater.dcproj.service.PcIndexService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; import cn.com.goldenwater.dcproj.utils.EnumUtil; import cn.com.goldenwater.dcproj.utils.InspUtils; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; import java.util.*; @Service @Transactional public class PcIndexServiceImpl implements PcIndexService { @Autowired private BisInspPblmDao inspPblmDao; @Autowired private BisInspAllObjDao inspAllObjDao; @Autowired private BisInspAllRlationPersDao bisInspAllRlationPersDao; @Autowired private PersPositionDao persPositionDao; @Autowired private OlBisInspOrgService inspOrgService; @Override public Map timeCount(String orgId) { LocalDateTime time = LocalDateTime.now(); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd"); //获取天 String dayDesc = dtf2.format(time); BisInspPblm bisInspPblm = new BisInspPblm(); bisInspPblm.setProvince(inspOrgService.getProvince(orgId)); bisInspPblm.setFindTime(dayDesc); int total = inspPblmDao.selectCount(bisInspPblm); bisInspPblm.setFindTime(null); Map params = new HashMap<>(); params.put("day", total + ""); dtf2 = DateTimeFormatter.ofPattern("yyyy-MM"); String monthDesc = dtf2.format(time); bisInspPblm.setMonthTime(monthDesc); total = inspPblmDao.selectCount(bisInspPblm); bisInspPblm.setMonthTime(null); params.put("month", total + ""); //获取一周内数据 //改为周一到当前时间 String weekTme = LocalDate.now().minusDays(LocalDate.now().getDayOfWeek().getValue() - 1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); bisInspPblm.setStartTime(weekTme); total = inspPblmDao.selectCount(bisInspPblm); params.put("week", total + ""); return params; } @Override public List countGroup(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); List list = inspAllObjDao.countGroup(getIndexParam(indexParam)); Map map = this.convertToTree(list); return new ArrayList(map.values()); } private Map convertToTree(List list){ Map map = new TreeMap<>(String::compareTo); for (DcTypeDto dcTypeDto : list) { BisInspTypeEnum typeEnum = EnumUtil.getBisInspTypeEnum(dcTypeDto.getObjType()); if (typeEnum == null) { DcTypeDto otherDto = null; if (map.keySet().contains("其他类")) { otherDto = map.get("其他类"); } else { otherDto = new DcTypeDto(); otherDto.setTotal("0"); otherDto.setName("其他类"); otherDto.setLevel("1"); otherDto.setChildren(new ArrayList<>()); map.put("其他类",otherDto); } otherDto.setTotal(Long.valueOf(otherDto.getTotal())+ Long.valueOf(dcTypeDto.getTotal()) + ""); otherDto.getChildren().add(dcTypeDto); } else { if (!map.containsKey(typeEnum.getParentCode())) { DcTypeDto dto = new DcTypeDto(); dto.setLevel("1"); List child = new ArrayList<>(); child.add(dcTypeDto); dto.setChildren(child); dto.setName(typeEnum.getParentName()); dto.setTotal(dcTypeDto.getTotal()); map.put(typeEnum.getParentCode(),dto); } else { DcTypeDto dto = map.get(typeEnum.getParentCode()); dto.setTotal(Long.valueOf(dto.getTotal())+Long.valueOf(dcTypeDto.getTotal()) + ""); dto.getChildren().add(dcTypeDto); } } } return map; } @Override public List countPerson(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); Map map = this.convertToTree(inspAllObjDao.countPerson(getIndexParam(indexParam))); return new ArrayList(map.values()); } @Override public List countDucha(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); List list = inspAllObjDao.countDcByType(getIndexParam(indexParam)); Map map = this.convertToTree(list); return new ArrayList(map.values()); } @Override public List countPblmByType(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); List typeDtoList = inspAllObjDao.countPblmByType(getIndexParam(indexParam)); Map map = this.convertToTree(typeDtoList); return new ArrayList(map.values()); } private List getTypeDto(List typeDtoList) { for (DcTypeDto typeDto : typeDtoList) { String name = typeDto.getName(); if (BisInspEnum.REVER.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.REVER.getValue()); } if (BisInspEnum.VILL.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.VILL.getValue()); } if (BisInspEnum.TRACK.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.TRACK.getValue()); } if (BisInspEnum.EMPWT.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.EMPWT.getValue()); } if (BisInspEnum.EMPWTRUN.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.EMPWTRUN.getValue()); } if (BisInspEnum.GRW.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.GRW.getValue()); } if (BisInspEnum.WAGA.getDesc().equals(name)) { typeDto.setObjType(BisInspEnum.WAGA.getValue()); } } //省级只保留 小水库和人饮 for (int i = typeDtoList.size() - 1; i >= 0; i--) { String objType = typeDtoList.get(i).getObjType(); if (!objType.equalsIgnoreCase(BisInspEnum.VILL.getValue()) && !objType.equalsIgnoreCase(BisInspEnum.REVER.getValue()) ) { typeDtoList.remove(i); } } return typeDtoList; } @Override public List countPlanByOrgOrType(String type, String orgId) { IndexParam indexParam = new IndexParam(); if ("pType".equals(type)) { return inspAllObjDao.countObjByType(getIndexParam(indexParam)); } return inspAllObjDao.countObjByOrg(getIndexParam(indexParam)); } @Override public List countPlan(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); return inspAllObjDao.countObjbyParam(getIndexParam(indexParam)); } @Override public List countPlanByPro(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); return inspAllObjDao.countPlanByPro(getIndexParam(indexParam)); } @Override public List countPblm(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); List typeDtoList = inspAllObjDao.countPblmbyParam(getIndexParam(indexParam)); for (DcTypeDto typeDto : typeDtoList) { indexParam.setpTypes(typeDto.getObjType()); List pblmDtoList = inspAllObjDao.countPblmByObjType(getIndexParam(indexParam)); typeDto.setPblmDtoList(pblmDtoList); } Map map = this.convertToTree(typeDtoList); return new ArrayList(map.values()); } @Override public List countGroupByPro(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); return inspAllObjDao.countGroupByPro(getIndexParam(indexParam)); } @Override public List countPersonByPro(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); return inspAllObjDao.countPersonByPro(getIndexParam(indexParam)); } @Override public List countPblmByPro(IndexParam indexParam) { indexParam.setOrgIds(InspUtils.setOrgIds(indexParam.getOrgIds())); List typeDtoList = inspAllObjDao.countPblmbyPro(getIndexParam(indexParam)); List pblmDtoList = new ArrayList<>(); List typeDtoes = new ArrayList<>(); for (DcPblmDto pblmDto : typeDtoList) { if (!pblmDtoList.contains(pblmDto.getName())) { pblmDtoList.add(pblmDto.getName()); } } for (String str : pblmDtoList) { DcPblmDto dto = new DcPblmDto(); dto.setName(str); int total = 0; List dtoList = new ArrayList<>(); for (DcPblmDto pblmDto : typeDtoList) { if (pblmDto.getName().equals(str)) { dto.setAdCode(pblmDto.getAdCode()); total += pblmDto.getTotal(); dtoList.add(pblmDto); } } dto.setPblmDtoList(dtoList); dto.setTotal(total); typeDtoes.add(dto); } return typeDtoes; } @Override public PersOnlineDto countPersOnline(IndexParam indexParam) { if (StringUtils.isBlank(indexParam.getEndTime())) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); indexParam.setEndTime(sdf.format(calendar.getTime())); calendar.set(Calendar.HOUR, calendar.get(Calendar.HOUR) - 2); indexParam.setStartTime(sdf.format(calendar.getTime())); } int ret = bisInspAllRlationPersDao.selectCountOnlinePers(indexParam.getStartTime(), indexParam.getEndTime(), indexParam.getOrgId()); int retgroup = persPositionDao.countGroupOnline(indexParam.getStartTime(), indexParam.getEndTime(), indexParam.getOrgId()); PersOnlineDto pers = new PersOnlineDto(); pers.setCountGroup(retgroup); pers.setCountPers(ret); return pers; } @Override public List countPblmByTime(IndexPblmParam indexPblmParam) { if (!StringUtils.isEmpty(indexPblmParam.getOrgIds())) { indexPblmParam.setOrgIds(InspUtils.setOrgIds(indexPblmParam.getOrgIds())); } if (!StringUtils.isEmpty(indexPblmParam.getAdCode())) { Map map = AdLevelUtil.SubAd(indexPblmParam.getAdCode()); indexPblmParam.setAdCode(String.valueOf(map.get("subAd"))); } if (!StringUtils.isEmpty(indexPblmParam.getType())) { indexPblmParam.setType(InspUtils.setOrgIds(indexPblmParam.getType())); } List list = new ArrayList<>(); indexPblmParam = getIndexPblmParam(indexPblmParam); if (!"".equals(indexPblmParam.getPblmState()) && "inc".equals(indexPblmParam.getPblmState())) { switch (indexPblmParam.getDtype()) { case "day": DateTimeFormatter dtfDay = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate dttm = LocalDate.parse(indexPblmParam.getEttm(), dtfDay); if (StringUtils.isEmpty(indexPblmParam.getSttm())) { indexPblmParam.setSttm(dttm.minusDays(6).format(dtfDay)); } indexPblmParam.setSeltime(dttm.minusDays(6).format(dtfDay)); list.addAll(inspPblmDao.countPblmIncByDay(indexPblmParam)); break; case "week": int currWeekCount = 0; int oneWeekCount = 0; int twoWeekCount = 0; int tWeekCount = 0; int fWeekCount = 0; DateTimeFormatter dtfWeek = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate dtWeek = LocalDate.parse(indexPblmParam.getEttm(), dtfWeek); if (StringUtils.isEmpty(indexPblmParam.getSttm())) { indexPblmParam.setSttm(dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(4).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(4).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); fWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else { String sttm = indexPblmParam.getSttm(); if (dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek).compareTo(sttm) <= 0) { currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek).compareTo(sttm) <= 0) { indexPblmParam.setSttm(dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(sttm); indexPblmParam.setEttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek).compareTo(sttm) <= 0) { indexPblmParam.setSttm(dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(sttm); indexPblmParam.setEttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek).compareTo(sttm) <= 0) { indexPblmParam.setSttm(dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(sttm); indexPblmParam.setEttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (dtWeek.minusWeeks(4).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek).compareTo(sttm) <= 0) { indexPblmParam.setSttm(dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(sttm); indexPblmParam.setEttm(dtWeek.minusWeeks(4).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); fWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else { indexPblmParam.setSttm(dtWeek.minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(1).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(2).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(3).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setSttm(dtWeek.minusWeeks(4).minusDays(dtWeek.getDayOfWeek().getValue() - 1).format(dtfWeek)); indexPblmParam.setEttm(dtWeek.minusWeeks(4).minusDays(dtWeek.getDayOfWeek().getValue() - 1).plusDays(6).format(dtfWeek)); fWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } } CountTime currCount = new CountTime(); currCount.setName("本周"); currCount.setValue(currWeekCount); CountTime oneCount = new CountTime(); oneCount.setName("前1周"); oneCount.setValue(oneWeekCount); CountTime twoCount = new CountTime(); twoCount.setName("前2周"); twoCount.setValue(twoWeekCount); CountTime threeCount = new CountTime(); threeCount.setName("前3周"); threeCount.setValue(tWeekCount); CountTime fourCount = new CountTime(); fourCount.setName("前4周"); fourCount.setValue(fWeekCount); list.add(fourCount); list.add(threeCount); list.add(twoCount); list.add(oneCount); list.add(currCount); break; case "month": DateTimeFormatter dtfMon = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate dtMon = LocalDate.parse(indexPblmParam.getEttm(), dtfMon); if (StringUtils.isEmpty(indexPblmParam.getSttm())) { indexPblmParam.setSttm(dtMon.minusMonths(4).format(dtfMon)); } indexPblmParam.setSeltime(dtMon.minusMonths(4).format(dtfMon)); list.addAll(inspPblmDao.countPblmIncByMonth(indexPblmParam)); break; } } else if (!"".equals(indexPblmParam.getPblmState()) && "total".equals(indexPblmParam.getPblmState())) { switch (indexPblmParam.getDtype()) { case "day": int day1 = 0; int day2 = 0; int day3 = 0; int day4 = 0; int day5 = 0; int day6 = 0; int day7 = 0; CountTime time1 = new CountTime(); CountTime time2 = new CountTime(); CountTime time3 = new CountTime(); CountTime time4 = new CountTime(); CountTime time5 = new CountTime(); CountTime time6 = new CountTime(); CountTime time7 = new CountTime(); DateTimeFormatter dtfDay = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate dttm = LocalDate.parse(indexPblmParam.getEttm(), dtfDay); time7.setName(String.valueOf(dttm.getDayOfMonth())); time6.setName(String.valueOf(dttm.minusDays(1).getDayOfMonth())); time5.setName(String.valueOf(dttm.minusDays(2).getDayOfMonth())); time4.setName(String.valueOf(dttm.minusDays(3).getDayOfMonth())); time3.setName(String.valueOf(dttm.minusDays(4).getDayOfMonth())); time2.setName(String.valueOf(dttm.minusDays(5).getDayOfMonth())); time1.setName(String.valueOf(dttm.minusDays(6).getDayOfMonth())); if (StringUtils.isEmpty(indexPblmParam.getSttm())) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(3).format(dtfDay)); day4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(4).format(dtfDay)); day3 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(5).format(dtfDay)); day2 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(6).format(dtfDay)); day1 = inspPblmDao.countPblmByTime(indexPblmParam); } else { String sttm = indexPblmParam.getSttm(); if (sttm.compareTo(dttm.minusDays(1).format(dtfDay)) >= 0) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(dttm.minusDays(2).format(dtfDay)) >= 0) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(dttm.minusDays(3).format(dtfDay)) >= 0) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(3).format(dtfDay)); day4 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(dttm.minusDays(4).format(dtfDay)) >= 0) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(3).format(dtfDay)); day4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(4).format(dtfDay)); day3 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(dttm.minusDays(5).format(dtfDay)) >= 0) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(3).format(dtfDay)); day4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(4).format(dtfDay)); day3 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(5).format(dtfDay)); day2 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(dttm.minusDays(6).format(dtfDay)) >= 0) { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(3).format(dtfDay)); day4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(4).format(dtfDay)); day3 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(5).format(dtfDay)); day2 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(6).format(dtfDay)); day1 = inspPblmDao.countPblmByTime(indexPblmParam); } else { day7 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(1).format(dtfDay)); day6 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(2).format(dtfDay)); day5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(3).format(dtfDay)); day4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(4).format(dtfDay)); day3 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(5).format(dtfDay)); day2 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(dttm.minusDays(6).format(dtfDay)); day1 = inspPblmDao.countPblmByTime(indexPblmParam); } } time7.setValue(day7); time6.setValue(day6); time5.setValue(day5); time4.setValue(day4); time3.setValue(day3); time2.setValue(day2); time1.setValue(day1); list.add(time1); list.add(time2); list.add(time3); list.add(time4); list.add(time5); list.add(time6); list.add(time7); break; case "week": int currWeekCount = 0; int oneWeekCount = 0; int twoWeekCount = 0; int tWeekCount = 0; int fWeekCount = 0; DateTimeFormatter dtfWeek = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate wktm = LocalDate.parse(indexPblmParam.getEttm(), dtfWeek); if (StringUtils.isEmpty(indexPblmParam.getSttm())) { //本周 currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); //上周日 indexPblmParam.setEttm(wktm.minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); //前两周 indexPblmParam.setEttm(wktm.minusWeeks(1).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); //前三周 indexPblmParam.setEttm(wktm.minusWeeks(2).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); //前四周 indexPblmParam.setEttm(wktm.minusWeeks(3).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); fWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else { String sttm = indexPblmParam.getSttm(); if (sttm.compareTo(wktm.minusDays(wktm.getDayOfWeek().getValue() - 1).format(dtfWeek)) >= 0) { //与本周一比较 currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(wktm.minusWeeks(1).minusDays(wktm.getDayOfWeek().getValue() - 1).format(dtfWeek)) >= 0) { //与上周一比较 currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(wktm.minusWeeks(2).minusDays(wktm.getDayOfWeek().getValue() - 1).format(dtfWeek)) >= 0) { //与前两周 currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusWeeks(1).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(wktm.minusWeeks(3).minusDays(wktm.getDayOfWeek().getValue() - 1).format(dtfWeek)) >= 0) { //前三周 currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusWeeks(1).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusWeeks(2).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } else { //前四周 currWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); oneWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusWeeks(1).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); twoWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusWeeks(2).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); tWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(wktm.minusWeeks(3).minusDays(wktm.getDayOfWeek().getValue()).format(dtfWeek)); fWeekCount = inspPblmDao.countPblmByTime(indexPblmParam); } } CountTime currCount = new CountTime(); currCount.setName("本周"); currCount.setValue(currWeekCount); CountTime oneCount = new CountTime(); oneCount.setName("前1周"); oneCount.setValue(oneWeekCount); CountTime twoCount = new CountTime(); twoCount.setName("前2周"); twoCount.setValue(twoWeekCount); CountTime threeCount = new CountTime(); threeCount.setName("前3周"); threeCount.setValue(tWeekCount); CountTime fourCount = new CountTime(); fourCount.setName("前4周"); fourCount.setValue(fWeekCount); list.add(fourCount); list.add(threeCount); list.add(twoCount); list.add(oneCount); list.add(currCount); break; case "month": int mon1 = 0; int mon2 = 0; int mon3 = 0; int mon4 = 0; int mon5 = 0; CountTime monTime1 = new CountTime(); CountTime monTime2 = new CountTime(); CountTime monTime3 = new CountTime(); CountTime monTime4 = new CountTime(); CountTime monTime5 = new CountTime(); DateTimeFormatter dtfMonth = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate montm = LocalDate.parse(indexPblmParam.getEttm(), dtfMonth); if (StringUtils.isEmpty(indexPblmParam.getSttm())) { mon5 = inspPblmDao.countPblmByTime(indexPblmParam); //获取上月最后一天 indexPblmParam.setEttm(montm.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon3 = inspPblmDao.countPblmByTime(indexPblmParam); monTime3.setName(String.valueOf(montm.minusMonths(2).getMonthValue())); monTime3.setValue(mon3); indexPblmParam.setEttm(montm.minusMonths(3).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon2 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(4).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon1 = inspPblmDao.countPblmByTime(indexPblmParam); } else { String sttm = indexPblmParam.getSttm(); if (sttm.compareTo(montm.with(TemporalAdjusters.firstDayOfMonth()).format(dtfMonth)) >= 0) { //大于本月第一天 mon5 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(montm.minusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).format(dtfMonth)) >= 0) { //大于上月第一天 mon5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon4 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(montm.minusMonths(2).with(TemporalAdjusters.firstDayOfMonth()).format(dtfMonth)) >= 0) { //大于上上月第一天 mon5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon3 = inspPblmDao.countPblmByTime(indexPblmParam); } else if (sttm.compareTo(montm.minusMonths(3).with(TemporalAdjusters.firstDayOfMonth()).format(dtfMonth)) >= 0) { //大于上上上月第一天 mon5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon3 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(3).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon2 = inspPblmDao.countPblmByTime(indexPblmParam); } else { mon5 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon4 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(2).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon3 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(3).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon2 = inspPblmDao.countPblmByTime(indexPblmParam); indexPblmParam.setEttm(montm.minusMonths(4).with(TemporalAdjusters.lastDayOfMonth()).format(dtfMonth)); mon1 = inspPblmDao.countPblmByTime(indexPblmParam); } } monTime5.setName(String.valueOf(montm.getMonthValue())); monTime5.setValue(mon5); monTime4.setName(String.valueOf(montm.minusMonths(1).getMonthValue())); monTime4.setValue(mon4); monTime3.setName(String.valueOf(montm.minusMonths(2).getMonthValue())); monTime3.setValue(mon3); monTime2.setName(String.valueOf(montm.minusMonths(3).getMonthValue())); monTime2.setValue(mon2); monTime1.setName(String.valueOf(montm.minusMonths(4).getMonthValue())); monTime1.setValue(mon1); list.add(monTime1); list.add(monTime2); list.add(monTime3); list.add(monTime4); list.add(monTime5); break; } } return list; } @Override public PageInfo countGroupByAdCode(IndexParamPage indexParam) { PageHelper.startPage(indexParam.getPageNum(), indexParam.getPageSize()); List objGroupList = inspAllObjDao.countGroupByAdCode(getIndexParamPage(indexParam)); return new PageInfo(objGroupList); } @Override public PageInfo findPerByAdCode(IndexParamPage indexParamPage) { PageHelper.startPage(indexParamPage.getPageNum(), indexParamPage.getPageSize()); List objGroupList = inspAllObjDao.findPerByAdCode(getIndexParamPage(indexParamPage)); return new PageInfo(objGroupList); } @Override public PageInfo findObjByAdCode(IndexParamPage indexParamPage) { PageHelper.startPage(indexParamPage.getPageNum(), indexParamPage.getPageSize()); List objGroupList = inspAllObjDao.findObjByAdCode(getIndexParamPage(indexParamPage)); return new PageInfo(objGroupList); } @Override public PageInfo findPblmByAdCode(IndexParamPage indexParamPage) { PageHelper.startPage(indexParamPage.getPageNum(), indexParamPage.getPageSize()); List objGroupList = inspAllObjDao.findPblmByAdCode(getIndexParamPage(indexParamPage)); return new PageInfo(objGroupList); } @Override public List findGroupCountByAdCode(IndexParamPage indexParam) { List objGroupCountList = inspAllObjDao.findGroupCountByAdCode(getIndexParamPage(indexParam)); return objGroupCountList; } @Override public List findPerCountByAdCode(IndexParamPage indexParamPage) { List objGroupCountList = inspAllObjDao.findPerCountByAdCode(getIndexParamPage(indexParamPage)); return objGroupCountList; } @Override public List findObjCountByAdCode(IndexParamPage indexParamPage) { List objGroupCountList = inspAllObjDao.findObjCountByAdCode(getIndexParamPage(indexParamPage)); return objGroupCountList; } private IndexParam getIndexParam(IndexParam indexParam) { String province = indexParam.getProvince(); if ("".equals(province)) { indexParam.setLength("2"); indexParam.setOtherLength("0000000000"); } else { int total = province.length(); int length = province.replace(AdCodeLabel.START_PARENT_ADCODE, "").length() + 2; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < total - length; i++) { buffer.append("0"); } indexParam.setOtherLength(buffer.toString()); indexParam.setLength(length + ""); } indexParam.setProvince(province); return indexParam; } private IndexPblmParam getIndexPblmParam(IndexPblmParam pblmParam) { String province = pblmParam.getProvince(); if ("".equals(province)) { pblmParam.setLength("2"); pblmParam.setOtherLength("0000000000"); } else { int total = province.length(); int length = province.replace(AdCodeLabel.START_PARENT_ADCODE, "").length() + 2; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < total - length; i++) { buffer.append("0"); } pblmParam.setOtherLength(buffer.toString()); pblmParam.setLength(length + ""); } pblmParam.setProvince(province); return pblmParam; } private IndexParamPage getIndexParamPage(IndexParamPage indexParamPage) { String province = indexParamPage.getProvince(); if ("".equals(province)) { indexParamPage.setLength("2"); indexParamPage.setOtherLength("0000000000"); } else { int total = province.length(); int length = province.replace(AdCodeLabel.START_PARENT_ADCODE, "").length() + 2; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < total - length; i++) { buffer.append("0"); } indexParamPage.setOtherLength(buffer.toString()); indexParamPage.setLength(length + ""); } indexParamPage.setProvince(province); return indexParamPage; } @Override public List findPblmCountByAdCode(IndexParamPage indexParamPage) { List objGroupCountList = inspAllObjDao.findPblmCountByAdCode(getIndexParamPage(indexParamPage)); return objGroupCountList; } }