|
|
@ -5,7 +5,9 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
|
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.dto.datastats.result.SubAgencyUserResultDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmetuser.StaffPatrolDetailDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmetuser.StaffPatrolRecordDTO; |
|
|
|
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.result.*; |
|
|
|
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.StaffPatrolDetailService; |
|
|
|
import com.epmet.dataaggre.service.epmetuser.StaffPatrolRecordService; |
|
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import oracle.sql.NUMBER; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -46,6 +50,8 @@ public class EpmetUserServiceImpl implements EpmetUserService { |
|
|
|
private StaffPatrolDetailService staffPatrolDetailService; |
|
|
|
@Resource |
|
|
|
private StaffPatrolRecordService staffPatrolRecordService; |
|
|
|
@Resource |
|
|
|
private StaffRoleDao staffRoleDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 根据UserIds查询 |
|
|
@ -77,29 +83,78 @@ public class EpmetUserServiceImpl implements EpmetUserService { |
|
|
|
@Override |
|
|
|
public List<StaffListResultDTO> staffList(StaffListFormDTO formDTO) { |
|
|
|
List<StaffListResultDTO> resultList = new ArrayList<>(); |
|
|
|
//1.设置分页参数
|
|
|
|
int num = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); |
|
|
|
formDTO.setPageNo(num); |
|
|
|
|
|
|
|
//2.查询当前人员所属组织下网格列表数据,供后续使用
|
|
|
|
List<StaffListResultDTO> result = new ArrayList<>(); |
|
|
|
//1.查询当前人员所属组织下网格列表数据,供后续封装数据使用
|
|
|
|
List<CustomerGridDTO> list = govOrgService.gridListByStaffId(formDTO.getUserId()); |
|
|
|
if (list.size() < NumConstant.ONE) { |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
//网格集合为空则查询当前人员所属组织下网格列表
|
|
|
|
|
|
|
|
//2.网格集合为空则查询当前人员所属组织下网格列表
|
|
|
|
if (CollectionUtils.isEmpty(formDTO.getGridIds())) { |
|
|
|
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())); |
|
|
|
resultList = staffPatrolRecordDao.selectPatrolList(formDTO); |
|
|
|
if (resultList.size() < NumConstant.ONE) { |
|
|
|
return new ArrayList<>(); |
|
|
|
List<StaffListResultDTO> staffPatrolList = staffPatrolRecordDao.selectPatrolList(formDTO); |
|
|
|
|
|
|
|
//5.封装数据
|
|
|
|
Map<String, String> map = new HashMap<>(); |
|
|
|
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()); |
|
|
|
map.put(re.getGridId()+re.getStaffId(),re.getStaffId()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
//可能存在的在a网格有记录后在a网格将该人员移除
|
|
|
|
staffPatrolList.forEach(st->{ |
|
|
|
if(!map.containsKey(st.getGridId()+st.getStaffId())){ |
|
|
|
result.add(st); |
|
|
|
} |
|
|
|
}); |
|
|
|
//6.按条件排序
|
|
|
|
Collections.sort(result, 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()); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
//7.按分页抽取数据
|
|
|
|
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.封装数据并返回
|
|
|
|
//8.赋值网格名称
|
|
|
|
resultList.forEach(re -> list.stream().filter(l -> re.getGridId().equals(l.getId())).forEach(s -> re.setGridName(s.getGridName()))); |
|
|
|
|
|
|
|
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
@ -137,8 +192,10 @@ public class EpmetUserServiceImpl implements EpmetUserService { |
|
|
|
String totalTimeDesc = minutes / 60 + "小时"+ minutes % 60 + "分"; |
|
|
|
dto.setTotalTimeDesc(totalTimeDesc); |
|
|
|
List<StaffPatrolDetailDTO> detailList = details.get(record.getId()); |
|
|
|
List<PatrolRecordDetailDTO> recordDetails = |
|
|
|
detailList.stream().sorted(Comparator.comparing(StaffPatrolDetailDTO::getSerialNum).reversed()).collect(Collectors.toList()).stream().map( detail -> { |
|
|
|
detailList = |
|
|
|
detailList.stream().sorted(Comparator.comparing(StaffPatrolDetailDTO::getSerialNum).reversed()).collect(Collectors.toList()).stream() |
|
|
|
.filter(item -> null == record.getPatrolEndTime() || record.getPatrolEndTime().compareTo(item.getUploadTime()) > -1).collect(Collectors.toList()); |
|
|
|
List<PatrolRecordDetailDTO> recordDetails = detailList.stream().map( detail -> { |
|
|
|
PatrolRecordDetailDTO detailDTO = new PatrolRecordDetailDTO(); |
|
|
|
detailDTO.setLatitude(detail.getLatitude()); |
|
|
|
detailDTO.setLongitude(detail.getLongitude()); |
|
|
@ -175,5 +232,22 @@ public class EpmetUserServiceImpl implements EpmetUserService { |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|