|
|
@ -1,14 +1,18 @@ |
|
|
|
package com.epmet.datareport.service.user.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.EpmetRequestHolder; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.datareport.constant.PatrolConstant; |
|
|
|
import com.epmet.datareport.dao.user.StaffPatrolDetailDao; |
|
|
|
import com.epmet.datareport.dao.user.StaffPatrolRecordDao; |
|
|
|
import com.epmet.datareport.service.evaluationindex.screen.ScreenOrgService; |
|
|
|
import com.epmet.datareport.service.user.StaffPatrolDetailService; |
|
|
|
import com.epmet.dto.IcEventDTO; |
|
|
|
import com.epmet.dto.form.PatrolCountFormDTO; |
|
|
|
import com.epmet.dto.form.PatrolTrackFormDTO; |
|
|
|
import com.epmet.dto.form.RecordListFormDTO; |
|
|
@ -54,7 +58,7 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 001、网格员分布 |
|
|
|
* @Description 001、网格员分布 |
|
|
|
* 1.根据agencyId或者areaCode查询出网格 |
|
|
|
* 2.根据查出来的网格ID去查网格下边的人【人只要网格员】 |
|
|
|
* 3.根据userId查询巡查记录表 |
|
|
@ -66,31 +70,40 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
@Override |
|
|
|
public List<GridManagerListResultDTO> gridManagerList(GridManagerListFormDTO formDTO) { |
|
|
|
List<GridManagerListResultDTO> grids = new ArrayList<>(); |
|
|
|
if (StringUtils.isEmpty(formDTO.getAreaCode())){ |
|
|
|
if (StringUtils.isEmpty(formDTO.getAreaCode())) { |
|
|
|
// 根据agencyId查询网格
|
|
|
|
grids = screenOrgService.selectAllGrid(formDTO.getAgencyId(), null); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 根据areaCode查询网格
|
|
|
|
grids = screenOrgService.selectAllGrid(null, formDTO.getAreaCode()); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(grids)){ |
|
|
|
if (CollectionUtils.isEmpty(grids)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<String> gridIds = grids.stream().map(m -> m.getGridId()).collect(Collectors.toList()); |
|
|
|
List<String> gridIds = grids.stream().map(GridManagerListResultDTO::getGridId).collect(Collectors.toList()); |
|
|
|
// 查询网格下的网格员
|
|
|
|
Result<List<GridStaffResultDTO>> resultData = govOrgOpenFeignClient.selectGridStaffByGridIds(gridIds); |
|
|
|
if(!resultData.success()){ |
|
|
|
throw new RenException("查询网格下的网格员失败【"+resultData.getMsg()+"】"); |
|
|
|
if (!resultData.success()) { |
|
|
|
throw new RenException("查询网格下的网格员失败【" + resultData.getMsg() + "】"); |
|
|
|
} |
|
|
|
List<GridStaffResultDTO> data = resultData.getData(); |
|
|
|
if (CollectionUtils.isEmpty(data)){ |
|
|
|
if (CollectionUtils.isEmpty(data)) { |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<GridManagerListResultDTO> result = ConvertUtils.sourceToTarget(data, GridManagerListResultDTO.class); |
|
|
|
result.forEach(staff -> {//获取头像
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), staff.getStaffId()); |
|
|
|
if (null != staffInfo) { |
|
|
|
staff.setHeadPhoto(staffInfo.getHeadPhoto()); |
|
|
|
} |
|
|
|
}); |
|
|
|
//统计事件
|
|
|
|
List<IcEventDTO> events = null; |
|
|
|
|
|
|
|
// 查询经纬度
|
|
|
|
Result<UserNameAndLLResultDTO> selectll = epmetUserOpenFeignClient.selectll(result.stream().map(m -> m.getStaffId()).collect(Collectors.toList())); |
|
|
|
if (!selectll.success()){ |
|
|
|
throw new RenException("查询经纬度和姓名失败【"+selectll.getMsg()+"】"); |
|
|
|
Result<UserNameAndLLResultDTO> selectll = epmetUserOpenFeignClient.selectll(result.stream().map(GridManagerListResultDTO::getStaffId).collect(Collectors.toList())); |
|
|
|
if (!selectll.success()) { |
|
|
|
throw new RenException("查询经纬度和姓名失败【" + selectll.getMsg() + "】"); |
|
|
|
} |
|
|
|
UserNameAndLLResultDTO llAndNameData = selectll.getData(); |
|
|
|
List<GridManagerListResultDTO> finalGrids = grids; |
|
|
@ -107,27 +120,27 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
}); |
|
|
|
} |
|
|
|
// 姓名赋值
|
|
|
|
if (!CollectionUtils.isEmpty(llAndNameData.getUserNames())){ |
|
|
|
if (!CollectionUtils.isEmpty(llAndNameData.getUserNames())) { |
|
|
|
llAndNameData.getUserNames().forEach(n -> { |
|
|
|
if (r.getStaffId().equals(n.getUserId())){ |
|
|
|
if (r.getStaffId().equals(n.getUserId())) { |
|
|
|
r.setStaffName(n.getUserName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// 网格名赋值
|
|
|
|
finalGrids.forEach(g -> { |
|
|
|
if (r.getGridId().equals(g.getGridId())){ |
|
|
|
if (r.getGridId().equals(g.getGridId())) { |
|
|
|
r.setGridName(g.getGridName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
result.forEach(r -> { |
|
|
|
if (!r.getLlStatus()){ |
|
|
|
if (!r.getLlStatus()) { |
|
|
|
finalGrids.forEach(g -> { |
|
|
|
// 网格相同,并且中心点位不为空,并且中心点位不等于 '[]'
|
|
|
|
if (r.getGridId().equals(g.getGridId()) && (StringUtils.isNotBlank(g.getCenterMark())&& !"[]".equals(g.getCenterMark()))){ |
|
|
|
r.setLongitude(getLL(g.getCenterMark(),PatrolConstant.LONGITUDE)); |
|
|
|
r.setLatitude(getLL(g.getCenterMark(),PatrolConstant.LATITUDE)); |
|
|
|
if (r.getGridId().equals(g.getGridId()) && (StringUtils.isNotBlank(g.getCenterMark()) && !"[]".equals(g.getCenterMark()))) { |
|
|
|
r.setLongitude(getLL(g.getCenterMark(), PatrolConstant.LONGITUDE)); |
|
|
|
r.setLatitude(getLL(g.getCenterMark(), PatrolConstant.LATITUDE)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
@ -136,7 +149,7 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 网格员分布 |
|
|
|
* @Description 网格员分布 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/8/25 3:00 下午 |
|
|
@ -146,14 +159,14 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
List<GridManagerListResultDTO> resultTwo = this.gridManagerList(formDTO); |
|
|
|
List<GridManagerListGeneralResultDTO> result = ConvertUtils.sourceToTarget(resultTwo, GridManagerListGeneralResultDTO.class); |
|
|
|
Result<List<PatrolYuShanResultDTO>> listResult = epmetUserOpenFeignClient.patrolInfo(formDTO.getAgencyId()); |
|
|
|
if (!listResult.success()){ |
|
|
|
if (!listResult.success()) { |
|
|
|
throw new RenException("查询巡查次数和时长失败"); |
|
|
|
} |
|
|
|
List<PatrolYuShanResultDTO> data = listResult.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(data)){ |
|
|
|
if (!CollectionUtils.isEmpty(data)) { |
|
|
|
result.forEach(r -> { |
|
|
|
data.forEach(d -> { |
|
|
|
if (r.getGridId().equals(d.getGridId()) && r.getStaffId().equals(d.getStaffId())){ |
|
|
|
if (r.getGridId().equals(d.getGridId()) && r.getStaffId().equals(d.getStaffId())) { |
|
|
|
r.setPatrolCount(d.getPatrolCount()); |
|
|
|
r.setPatrolDuration(d.getPatrolDuration()); |
|
|
|
} |
|
|
@ -164,17 +177,17 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 根据中心点位截取经纬度 |
|
|
|
* @Description 根据中心点位截取经纬度 |
|
|
|
* @Param centMark |
|
|
|
* @Param ll |
|
|
|
* @author zxc |
|
|
|
* @date 2021/6/9 2:08 下午 |
|
|
|
*/ |
|
|
|
public String getLL(String centMark,String ll){ |
|
|
|
if (ll.equals(PatrolConstant.LONGITUDE)){ |
|
|
|
public String getLL(String centMark, String ll) { |
|
|
|
if (ll.equals(PatrolConstant.LONGITUDE)) { |
|
|
|
String longitude = centMark.substring(NumConstant.TWO, centMark.indexOf(",")); |
|
|
|
return longitude; |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
String s = centMark.substring(NumConstant.ZERO, centMark.indexOf(",")); |
|
|
|
String latitude = centMark.substring(s.length() + NumConstant.ONE, centMark.length() - NumConstant.TWO); |
|
|
|
return latitude; |
|
|
@ -182,7 +195,7 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 002、查看巡查记录 |
|
|
|
* @Description 002、查看巡查记录 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/6/7 3:25 下午 |
|
|
@ -190,18 +203,18 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
@Override |
|
|
|
public List<RecordListResultDTO> recordList(RecordListFormDTO formDTO) { |
|
|
|
Result<List<RecordListResultDTO>> listResult = epmetUserOpenFeignClient.recordList(formDTO); |
|
|
|
if (!listResult.success()){ |
|
|
|
throw new RenException("查询巡查记录失败【"+listResult.getMsg()+"】"); |
|
|
|
if (!listResult.success()) { |
|
|
|
throw new RenException("查询巡查记录失败【" + listResult.getMsg() + "】"); |
|
|
|
} |
|
|
|
List<RecordListResultDTO> result = listResult.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
|
if (!CollectionUtils.isEmpty(result)) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 003、巡查轨迹 |
|
|
|
* @Description 003、巡查轨迹 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/6/7 3:35 下午 |
|
|
@ -209,18 +222,18 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
@Override |
|
|
|
public List<PatrolTrackResultDTO> patrolTrack(PatrolTrackFormDTO formDTO) { |
|
|
|
Result<List<PatrolTrackResultDTO>> result = epmetUserOpenFeignClient.patrolTrack(formDTO); |
|
|
|
if (!result.success()){ |
|
|
|
throw new RenException("查询 巡查轨迹失败【"+result.getMsg()+"】"); |
|
|
|
if (!result.success()) { |
|
|
|
throw new RenException("查询 巡查轨迹失败【" + result.getMsg() + "】"); |
|
|
|
} |
|
|
|
List<PatrolTrackResultDTO> results = result.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(results)){ |
|
|
|
if (!CollectionUtils.isEmpty(results)) { |
|
|
|
return results; |
|
|
|
} |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 004、网格员巡查中和未巡查中的人数 |
|
|
|
* @Description 004、网格员巡查中和未巡查中的人数 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/6/22 2:01 下午 |
|
|
@ -228,7 +241,7 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
@Override |
|
|
|
public PatrolCountResultDTO patrolCount(PatrolCountFormDTO formDTO) { |
|
|
|
Result<PatrolCountResultDTO> resultDTOResult = epmetUserOpenFeignClient.patrolCount(formDTO); |
|
|
|
if (!resultDTOResult.success()){ |
|
|
|
if (!resultDTOResult.success()) { |
|
|
|
throw new RenException("查询巡查人数失败..."); |
|
|
|
} |
|
|
|
return resultDTOResult.getData(); |
|
|
|