| 
						
						
							
								
							
						
						
					 | 
					@ -5,7 +5,9 @@ import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.DateUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.DateUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.constant.DataSourceConstant; | 
					 | 
					 | 
					import com.epmet.dataaggre.constant.DataSourceConstant; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dao.epmetuser.StaffPatrolRecordDao; | 
					 | 
					 | 
					import com.epmet.dataaggre.dao.epmetuser.StaffPatrolRecordDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.dataaggre.dao.epmetuser.StaffRoleDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dao.epmetuser.UserBaseInfoDao; | 
					 | 
					 | 
					import com.epmet.dataaggre.dao.epmetuser.UserBaseInfoDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.datastats.result.SubAgencyUserResultDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO; | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO; | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO; | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.form.PatrolDateListFormDTO; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -13,11 +15,13 @@ import com.epmet.dataaggre.dto.epmetuser.form.PatrolRecordListFormDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO; | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.result.*; | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.epmetuser.result.*; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.service.epmetuser.EpmetUserService; | 
					 | 
					 | 
					import com.epmet.dataaggre.service.epmetuser.EpmetUserService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.service.epmetuser.StaffPatrolDetailService; | 
					 | 
					 | 
					import com.epmet.dataaggre.service.epmetuser.StaffPatrolDetailService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService; | 
					 | 
					 | 
					import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.dataaggre.service.govorg.GovOrgService; | 
					 | 
					 | 
					import com.epmet.dataaggre.service.govorg.GovOrgService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
					 | 
					 | 
					import lombok.extern.slf4j.Slf4j; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import oracle.sql.NUMBER; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.commons.collections4.CollectionUtils; | 
					 | 
					 | 
					import org.apache.commons.collections4.CollectionUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
					 | 
					 | 
					import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import org.springframework.beans.factory.annotation.Autowired; | 
					 | 
					 | 
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -46,6 +50,8 @@ public class EpmetUserServiceImpl implements EpmetUserService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private StaffPatrolDetailService staffPatrolDetailService; | 
					 | 
					 | 
					    private StaffPatrolDetailService staffPatrolDetailService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Resource | 
					 | 
					 | 
					    @Resource | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    private StaffPatrolRecordService staffPatrolRecordService; | 
					 | 
					 | 
					    private StaffPatrolRecordService staffPatrolRecordService; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    @Resource | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    private StaffRoleDao staffRoleDao; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					     * @Description  根据UserIds查询 | 
					 | 
					 | 
					     * @Description  根据UserIds查询 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -77,29 +83,68 @@ public class EpmetUserServiceImpl implements EpmetUserService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @Override | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    public List<StaffListResultDTO> staffList(StaffListFormDTO formDTO) { | 
					 | 
					 | 
					    public List<StaffListResultDTO> staffList(StaffListFormDTO formDTO) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        List<StaffListResultDTO> resultList = new ArrayList<>(); | 
					 | 
					 | 
					        List<StaffListResultDTO> resultList = new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        //1.设置分页参数
 | 
					 | 
					 | 
					        List<StaffListResultDTO> result = new ArrayList<>(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        int num = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); | 
					 | 
					 | 
					        //1.查询当前人员所属组织下网格列表数据,供后续封装数据使用
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setPageNo(num); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //2.查询当前人员所属组织下网格列表数据,供后续使用
 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        List<CustomerGridDTO> list = govOrgService.gridListByStaffId(formDTO.getUserId()); | 
					 | 
					 | 
					        List<CustomerGridDTO> list = govOrgService.gridListByStaffId(formDTO.getUserId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (list.size() < NumConstant.ONE) { | 
					 | 
					 | 
					        if (list.size() < NumConstant.ONE) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            return resultList; | 
					 | 
					 | 
					            return resultList; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        //网格集合为空则查询当前人员所属组织下网格列表
 | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        //2.网格集合为空则查询当前人员所属组织下网格列表
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (CollectionUtils.isEmpty(formDTO.getGridIds())) { | 
					 | 
					 | 
					        if (CollectionUtils.isEmpty(formDTO.getGridIds())) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            formDTO.setGridIds(list.stream().map(CustomerGridDTO::getId).collect(Collectors.toList())); | 
					 | 
					 | 
					            formDTO.setGridIds(list.stream().map(CustomerGridDTO::getId).collect(Collectors.toList())); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        //3.按条件查询巡查业务数据
 | 
					 | 
					 | 
					        //3.按条件查询网格下工作人员基本信息
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        List<GridStaffResultDTO> staffList = govOrgService.selectGridStaffByGridIds(formDTO.getGridIds(), formDTO.getStaffName()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (staffList.size() < NumConstant.ONE) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            return resultList; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        for (GridStaffResultDTO st : staffList) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            StaffListResultDTO sf = new StaffListResultDTO(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            sf.setGridId(st.getGridId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            sf.setStaffId(st.getStaffId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            sf.setStaffName(st.getStaffName()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            sf.setGender(st.getGender()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            result.add(sf); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        //4.按条件查询巡查业务数据
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        formDTO.setPatrolStartTime(DateUtils.getBeforeMonthDate(formDTO.getTime())); | 
					 | 
					 | 
					        formDTO.setPatrolStartTime(DateUtils.getBeforeMonthDate(formDTO.getTime())); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        resultList = staffPatrolRecordDao.selectPatrolList(formDTO); | 
					 | 
					 | 
					        List<StaffListResultDTO> staffPatrolList = staffPatrolRecordDao.selectPatrolList(formDTO); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        if (resultList.size() < NumConstant.ONE) { | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            return new ArrayList<>(); | 
					 | 
					 | 
					        //5.封装数据并做分页处理
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        result.forEach(re -> { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            staffPatrolList.forEach(st -> { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                if (re.getGridId().equals(st.getGridId()) && re.getStaffId().equals(st.getStaffId())) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    re.setPatrolStartTime(st.getPatrolStartTime()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    re.setPatrolTotal(st.getPatrolTotal()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    re.setStatus(st.getStatus()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                } | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        int num = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        int size = num + formDTO.getPageSize(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (num > result.size()) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            return resultList; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        resultList = result.subList(num, (size > result.size() ? result.size() : size)); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        //4.封装数据并返回
 | 
					 | 
					 | 
					        //6.赋值网格名称
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        resultList.forEach(re -> list.stream().filter(l -> re.getGridId().equals(l.getId())).forEach(s -> re.setGridName(s.getGridName()))); | 
					 | 
					 | 
					        resultList.forEach(re -> list.stream().filter(l -> re.getGridId().equals(l.getId())).forEach(s -> re.setGridName(s.getGridName()))); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        //7.按条件排序并返回
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        Collections.sort(resultList, new Comparator<StaffListResultDTO>() { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            public int compare(StaffListResultDTO o1, StaffListResultDTO o2) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                if ("latestPatrolledTime".equals(formDTO.getSortCode())) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    return o2.getPatrolStartTime().compareTo(o1.getPatrolStartTime()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    return o2.getPatrolTotal().compareTo(o1.getPatrolTotal()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        }); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        return resultList; | 
					 | 
					 | 
					        return resultList; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -177,5 +222,22 @@ public class EpmetUserServiceImpl implements EpmetUserService { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
							return dto; | 
					 | 
					 | 
							return dto; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
						} | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @Description  查询网格员角色 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @Param forms | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     * @author sun | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					     */ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    @Override | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    public List<GridStaffResultDTO> staffGridRole(List<GridStaffResultDTO> forms, String staffName) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (org.springframework.util.CollectionUtils.isEmpty(forms)){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            return new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        List<GridStaffResultDTO> result = staffRoleDao.staffGridRole(forms, staffName); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        if (org.springframework.util.CollectionUtils.isEmpty(result)){ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            return new ArrayList<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        return result; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					} | 
					 | 
					 | 
					} | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					
  |