|
|
@ -1,21 +1,33 @@ |
|
|
|
package com.epmet.datareport.service.user.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
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.result.GridStaffResultDTO; |
|
|
|
import com.epmet.dto.result.UserNameAndLLResultDTO; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.user.form.GridManagerListFormDTO; |
|
|
|
import com.epmet.user.form.PatrolTrackFormDTO; |
|
|
|
import com.epmet.user.form.RecordListFormDTO; |
|
|
|
import com.epmet.dto.form.PatrolTrackFormDTO; |
|
|
|
import com.epmet.dto.form.RecordListFormDTO; |
|
|
|
import com.epmet.user.result.GridManagerListResultDTO; |
|
|
|
import com.epmet.user.result.PatrolTrackResultDTO; |
|
|
|
import com.epmet.user.result.RecordListResultDTO; |
|
|
|
import com.epmet.dto.result.PatrolTrackResultDTO; |
|
|
|
import com.epmet.dto.result.RecordListResultDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 工作人员巡查记录明细 |
|
|
@ -33,16 +45,111 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
@Autowired |
|
|
|
private StaffPatrolRecordDao staffPatrolRecordDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ScreenOrgService screenOrgService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 001、网格员分布 |
|
|
|
* 1.根据agencyId或者areaCode查询出网格 |
|
|
|
* 2.根据查出来的网格ID去查网格下边的人【人只要网格员】 |
|
|
|
* 3.根据userId查询巡查记录表 |
|
|
|
* 4.数据补全 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/6/7 3:06 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<GridManagerListResultDTO> gridManagerList(GridManagerListFormDTO formDTO) { |
|
|
|
List<GridManagerListResultDTO> grids = new ArrayList<>(); |
|
|
|
if (StringUtils.isEmpty(formDTO.getAreaCode())){ |
|
|
|
// 根据agencyId查询网格
|
|
|
|
grids = screenOrgService.selectAllGrid(formDTO.getAgencyId(), null); |
|
|
|
}else { |
|
|
|
// 根据areaCode查询网格
|
|
|
|
grids = screenOrgService.selectAllGrid(null, formDTO.getAreaCode()); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(grids)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<String> gridIds = grids.stream().map(m -> m.getGridId()).collect(Collectors.toList()); |
|
|
|
// 查询网格下的网格员
|
|
|
|
Result<List<GridStaffResultDTO>> resultData = govOrgOpenFeignClient.selectGridStaffByGridIds(gridIds); |
|
|
|
if(!resultData.success()){ |
|
|
|
throw new RenException("查询网格下的网格员失败【"+resultData.getMsg()+"】"); |
|
|
|
} |
|
|
|
List<GridStaffResultDTO> data = resultData.getData(); |
|
|
|
if (CollectionUtils.isEmpty(data)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<GridManagerListResultDTO> result = ConvertUtils.sourceToTarget(data, GridManagerListResultDTO.class); |
|
|
|
// 查询经纬度
|
|
|
|
Result<UserNameAndLLResultDTO> selectll = epmetUserOpenFeignClient.selectll(result.stream().map(m -> m.getStaffId()).collect(Collectors.toList())); |
|
|
|
if (!selectll.success()){ |
|
|
|
throw new RenException("查询经纬度和姓名失败【"+selectll.getMsg()+"】"); |
|
|
|
} |
|
|
|
UserNameAndLLResultDTO llAndNameData = selectll.getData(); |
|
|
|
List<GridManagerListResultDTO> finalGrids = grids; |
|
|
|
result.forEach(r -> { |
|
|
|
// 经纬度赋值 巡查状态赋值
|
|
|
|
if (!CollectionUtils.isEmpty(llAndNameData.getLl())) { |
|
|
|
llAndNameData.getLl().forEach(l -> { |
|
|
|
if (r.getStaffId().equals(l.getStaffId()) && r.getGridId().equals(l.getGridId())) { |
|
|
|
r.setLatitude(l.getLatitude()); |
|
|
|
r.setLongitude(l.getLongitude()); |
|
|
|
r.setStatus(l.getStatus()); |
|
|
|
r.setLlStatus(true); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
// 姓名赋值
|
|
|
|
if (!CollectionUtils.isEmpty(llAndNameData.getUserNames())){ |
|
|
|
llAndNameData.getUserNames().forEach(n -> { |
|
|
|
if (r.getStaffId().equals(n.getUserId())){ |
|
|
|
r.setStaffName(n.getUserName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
finalGrids.forEach(g -> { |
|
|
|
if (r.getGridId().equals(g.getGridId())){ |
|
|
|
r.setGridName(g.getGridName()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
result.forEach(r -> { |
|
|
|
if (!r.getLlStatus()){ |
|
|
|
finalGrids.forEach(g -> { |
|
|
|
if (StringUtils.isNotBlank(g.getCenterMark())){ |
|
|
|
r.setLongitude(getLL(g.getCenterMark(),PatrolConstant.LONGITUDE)); |
|
|
|
r.setLatitude(getLL(g.getCenterMark(),PatrolConstant.LATITUDE)); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
/** |
|
|
|
* @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)){ |
|
|
|
String longitude = centMark.substring(NumConstant.TWO, centMark.indexOf(",")); |
|
|
|
return longitude; |
|
|
|
}else { |
|
|
|
String s = centMark.substring(NumConstant.ZERO, centMark.indexOf(",")); |
|
|
|
String latitude = centMark.substring(s.length() + NumConstant.ONE, centMark.length() - NumConstant.TWO); |
|
|
|
return latitude; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -53,7 +160,11 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<RecordListResultDTO> recordList(RecordListFormDTO formDTO) { |
|
|
|
List<RecordListResultDTO> result = staffPatrolRecordDao.recordList(formDTO); |
|
|
|
Result<List<RecordListResultDTO>> listResult = epmetUserOpenFeignClient.recordList(formDTO); |
|
|
|
if (!listResult.success()){ |
|
|
|
throw new RenException("查询巡查记录失败【"+listResult.getMsg()+"】"); |
|
|
|
} |
|
|
|
List<RecordListResultDTO> result = listResult.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(result)){ |
|
|
|
return result; |
|
|
|
} |
|
|
@ -68,10 +179,16 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<PatrolTrackResultDTO> patrolTrack(PatrolTrackFormDTO formDTO) { |
|
|
|
List<PatrolTrackResultDTO> results = staffPatrolDetailDao.selectPatrolTrack(formDTO.getStaffPatrolRecId()); |
|
|
|
Result<List<PatrolTrackResultDTO>> result = epmetUserOpenFeignClient.patrolTrack(formDTO); |
|
|
|
if (!result.success()){ |
|
|
|
throw new RenException("查询 巡查轨迹失败【"+result.getMsg()+"】"); |
|
|
|
} |
|
|
|
List<PatrolTrackResultDTO> results = result.getData(); |
|
|
|
if (!CollectionUtils.isEmpty(results)){ |
|
|
|
return results; |
|
|
|
} |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |