|  |  |  | @ -1,10 +1,8 @@ | 
			
		
	
		
			
				
					|  |  |  |  | package cn.iocoder.yudao.module.system.service.home; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.controller.admin.home.vo.*; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoPageReqVO; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; | 
			
		
	
		
			
				
					|  |  |  |  | import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; | 
			
		
	
	
		
			
				
					|  |  |  | @ -50,59 +48,35 @@ public class HomeServiceImpl implements HomeService{ | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		//按时间查询
 | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeSelectVO.getSelectWeek() != null) { | 
			
		
	
		
			
				
					|  |  |  |  | 			LocalDateTime now = LocalDateTime.now(); | 
			
		
	
		
			
				
					|  |  |  |  | 			LocalDateTime[] dateList = new LocalDateTime[2]; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			switch (homeSelectVO.getSelectWeek()) { | 
			
		
	
		
			
				
					|  |  |  |  | 				case 1: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusDays(3); // 三天前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 				case 2: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusWeeks(1); // 一周前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 				case 3: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusMonths(1); // 一月前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 				case 4: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusYears(1); // 一年前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 			dateList[1] = now; | 
			
		
	
		
			
				
					|  |  |  |  | 			final LocalDateTime[] weekDate = this.getWeekDate(homeSelectVO.getSelectWeek()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, dateList[0], dateList[1]); | 
			
		
	
		
			
				
					|  |  |  |  | 			enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, weekDate[0], weekDate[1]); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		final Long enterpriseCount = enterpriseMapper.selectCount(enterpriseDOLambdaQueryWrapper); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setEnterpriseCount(enterpriseCount); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		TaskInfoPageReqVO taskInfoPageReqVO = new TaskInfoPageReqVO(); | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeSelectVO.getDeptId() != null) { | 
			
		
	
		
			
				
					|  |  |  |  | 			taskInfoPageReqVO.setDeptId(homeSelectVO.getDeptId()); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		//查询任务和执法
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeSelectVO.getSelectWeek() != null) { | 
			
		
	
		
			
				
					|  |  |  |  | 			taskInfoPageReqVO.setSelectWeek(homeSelectVO.getSelectWeek()); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		final PageResult<TaskInfoDO> taskInfoAppPage = taskInfoService.getTaskInfoAppPage(taskInfoPageReqVO); | 
			
		
	
		
			
				
					|  |  |  |  | 		final List<HomeExecFinishVO> homeExecFinishVOS = taskInfoMapper.selectHomeExecFinish(homeSelectVO); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		List<Integer> taskExecList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  | 		List<Integer> taskFinishList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  | 		if (taskInfoAppPage != null && taskInfoAppPage.getList() != null && taskInfoAppPage.getList().size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  | 			taskInfoAppPage.getList().forEach(item->{ | 
			
		
	
		
			
				
					|  |  |  |  | 				taskExecList.add(item.getTaskExecNum()); | 
			
		
	
		
			
				
					|  |  |  |  | 				taskFinishList.add(item.getTaskFinishNum()); | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeExecFinishVOS != null && homeExecFinishVOS.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  | 			homeExecFinishVOS.forEach(item->{ | 
			
		
	
		
			
				
					|  |  |  |  | 				taskExecList.add(item.getExecCount()); | 
			
		
	
		
			
				
					|  |  |  |  | 				taskFinishList.add(item.getFinishCount()); | 
			
		
	
		
			
				
					|  |  |  |  | 			}); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		//任务总数
 | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setTaskCount(homeExecFinishVOS.size()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		//总数
 | 
			
		
	
		
			
				
					|  |  |  |  | 		final Integer taskExec = taskExecList.stream().reduce(Integer::sum).orElse(0); | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setInspectionsCount(taskExec); | 
			
		
	
		
			
				
					|  |  |  |  | 		//完成数
 | 
			
		
	
		
			
				
					|  |  |  |  | 		final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		if (taskFinish != null && taskFinish != 0) { | 
			
		
	
		
			
				
					|  |  |  |  | 			double taskCompletionRate = (double) taskFinish/taskExec*100; | 
			
		
	
		
			
				
					|  |  |  |  | 			homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); | 
			
		
	
	
		
			
				
					|  |  |  | @ -110,32 +84,62 @@ public class HomeServiceImpl implements HomeService{ | 
			
		
	
		
			
				
					|  |  |  |  | 			homeCountResVO.setTaskCompletionRate("0.0"); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setTaskCount(taskInfoAppPage.getTotal()); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		//根据不同的身份查询
 | 
			
		
	
		
			
				
					|  |  |  |  | 		final List<HomeGroupCountVO> homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		List<HomeGroupCountVO> homeGroupCountVOS1 = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  | 		List<HomeListVO> homeGroupCountVOS1 = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { | 
			
		
	
		
			
				
					|  |  |  |  | 			homeGroupCountVOS.forEach(item->{ | 
			
		
	
		
			
				
					|  |  |  |  | 					HomeGroupCountVO groupCountVO = new HomeGroupCountVO(); | 
			
		
	
		
			
				
					|  |  |  |  | 					groupCountVO.setName(item.getName()); | 
			
		
	
		
			
				
					|  |  |  |  | 					HomeListVO homeListVO = new HomeListVO(); | 
			
		
	
		
			
				
					|  |  |  |  | 					homeListVO.setName(item.getName()); | 
			
		
	
		
			
				
					|  |  |  |  | 					homeListVO.setValue(item.getCompletionRate()); | 
			
		
	
		
			
				
					|  |  |  |  | 					double rate = (double) item.getFinishCount() /taskExec * 100; | 
			
		
	
		
			
				
					|  |  |  |  | 					groupCountVO.setCompletionRate(String.format("%.1f", rate)); | 
			
		
	
		
			
				
					|  |  |  |  | 					homeGroupCountVOS1.add(groupCountVO); | 
			
		
	
		
			
				
					|  |  |  |  | 					homeListVO.setPieValue(String.format("%.1f", rate)); | 
			
		
	
		
			
				
					|  |  |  |  | 					homeGroupCountVOS1.add(homeListVO); | 
			
		
	
		
			
				
					|  |  |  |  | 			}); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setCompletionRate(homeGroupCountVOS); | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setTotalCompletionRate(homeGroupCountVOS1); | 
			
		
	
		
			
				
					|  |  |  |  | 		homeCountResVO.setCompletionRate(homeGroupCountVOS1); | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		return homeCountResVO; | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	public LocalDateTime[] getWeekDate(Integer selectWeek) { | 
			
		
	
		
			
				
					|  |  |  |  | 		//按时间查询
 | 
			
		
	
		
			
				
					|  |  |  |  | 			LocalDateTime now = LocalDateTime.now(); | 
			
		
	
		
			
				
					|  |  |  |  | 			LocalDateTime[] dateList = new LocalDateTime[2]; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			switch (selectWeek) { | 
			
		
	
		
			
				
					|  |  |  |  | 				case 1: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusDays(3); // 三天前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 				case 2: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusWeeks(1); // 一周前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 				case 3: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusMonths(1); // 一月前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 				case 4: | 
			
		
	
		
			
				
					|  |  |  |  | 					dateList[0]  = now.minusYears(1); // 一年前
 | 
			
		
	
		
			
				
					|  |  |  |  | 					break; | 
			
		
	
		
			
				
					|  |  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  |  | 			dateList[1] = now; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 			return dateList; | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  |  | 	public HomeCountResVO appCount2(HomeSelectVO homeSelectVO) { | 
			
		
	
		
			
				
					|  |  |  |  | 	public List<EnterpriseNumVO> appCount2(HomeSelectVO homeSelectVO) { | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  | 		return null; | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeSelectVO.getSelectWeek() != null) { | 
			
		
	
		
			
				
					|  |  |  |  | 			homeSelectVO.setTime(this.getWeekDate(homeSelectVO.getSelectWeek())); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 		if (homeSelectVO.getType() != null && homeSelectVO.getType() == 2) { | 
			
		
	
		
			
				
					|  |  |  |  | 			return taskInfoMapper.selectEnterpriseStatus(homeSelectVO); | 
			
		
	
		
			
				
					|  |  |  |  | 		} else { | 
			
		
	
		
			
				
					|  |  |  |  | 			return  taskInfoMapper.selectEnterpriseNum(homeSelectVO); | 
			
		
	
		
			
				
					|  |  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  |  | } | 
			
		
	
	
		
			
				
					|  |  |  | 
 |