|
|
|
|
@ -2,6 +2,8 @@ package com.hisense.hiatmp.server_api.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.nacos.client.utils.StringUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
|
import com.hisense.hiatmp.model.common.*; |
|
|
|
|
import com.hisense.hiatmp.model.common.DTO.SectionDTO; |
|
|
|
|
import com.hisense.hiatmp.model.common.DTO.ThtTimeLineDTO; |
|
|
|
|
@ -10,11 +12,8 @@ import com.hisense.hiatmp.model.common.VO.SectionVO; |
|
|
|
|
import com.hisense.hiatmp.server_api.exception.MyCustomException; |
|
|
|
|
import com.hisense.hiatmp.server_api.mapper.HighDangerMapper; |
|
|
|
|
import com.hisense.hiatmp.server_api.mapper.OperatorMapper; |
|
|
|
|
import com.hisense.hiatmp.server_api.service.GovernmentService; |
|
|
|
|
import com.hisense.hiatmp.server_api.service.HighDangerService; |
|
|
|
|
import com.hisense.hiatmp.server_api.service.*; |
|
|
|
|
import com.hisense.hiatmp.model.dmr.Point; |
|
|
|
|
import com.hisense.hiatmp.server_api.service.ThtApproveService; |
|
|
|
|
import com.hisense.hiatmp.server_api.service.ThtAttachsService; |
|
|
|
|
import com.hisense.hiatmp.server_api.utils.CoordinateConverter; |
|
|
|
|
import com.hisense.hiatmp.server_api.utils.HiddenDangerUtils; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
@ -72,6 +71,9 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
@Autowired |
|
|
|
|
private ThtApproveService thtApproveService; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IConfigService configService; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 椭球参数 |
|
|
|
|
*/ |
|
|
|
|
@ -433,16 +435,13 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<ThtApprove> getProcessRecord(String businessId) { |
|
|
|
|
List<ThtApprove> processRecord = highDangerMapper.getProcessRecord(businessId); |
|
|
|
|
return processRecord; |
|
|
|
|
return highDangerMapper.getProcessRecord(businessId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HighDangerBase getCurOperator(String businessId) { |
|
|
|
|
|
|
|
|
|
HighDangerBase curOperator = highDangerMapper.getCurOperator(businessId); |
|
|
|
|
|
|
|
|
|
return curOperator; |
|
|
|
|
return highDangerMapper.getCurOperator(businessId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public ThtSectionInfoDTO getNewRoadInfo(String businessId) { |
|
|
|
|
@ -471,6 +470,28 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
@Override |
|
|
|
|
public ServerResponse<?> saveHiddenDanger(ManualInvestigation manualInvestigation) throws MyCustomException { |
|
|
|
|
|
|
|
|
|
// 入参格式判断
|
|
|
|
|
if(manualInvestigation.getTemporary() == null || manualInvestigation.getOperator() == null || manualInvestigation.getIfCross() == null){ |
|
|
|
|
return ServerResponse.error("关键入参不合规(Temporary、Operator或if_cross)"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
加锁的意义? |
|
|
|
|
互斥访问 |
|
|
|
|
锁能够防止多个线程同时访问共享资源,确保任何时刻只有一个线程能够进入临界区,从而避免数据竞争和不一致状态。 |
|
|
|
|
原子操作保证 |
|
|
|
|
通过锁,可以确保某些关键操作(如修改共享变量)在执行时不会被其他线程中断,保证了这些操作的原子性。 |
|
|
|
|
线程同步 |
|
|
|
|
锁可以用于实现线程间的同步,例如一个线程等待另一个线程完成某个任务后继续执行,这有助于协调多线程程序中的复杂流程。 |
|
|
|
|
避免死锁和活锁 |
|
|
|
|
虽然锁本身可能导致死锁和活锁问题,但合理使用锁机制可以避免这些问题的发生,确保程序的稳定运行。 |
|
|
|
|
提高并发性能 |
|
|
|
|
虽然锁会带来一定的性能开销,但在适当的地方使用锁可以提高并发性能,尤其是在多处理器系统中,合理的锁策略能够有效利用硬件资源。 |
|
|
|
|
读写锁优化 |
|
|
|
|
Java提供了读写锁(ReentrantReadWriteLock),允许多个读取线程同时访问共享资源,但写入操作是排他的。这种机制在读操作远多于写操作的场景下,可以显著提升并发性能。 |
|
|
|
|
公平性和非公平性 |
|
|
|
|
Java中的锁还可以设置为公平锁或非公平锁,公平锁按照线程请求锁的顺序分配锁,而非公平锁则可能让后来的线程先获得锁,提高了锁的获取速度,但牺牲了一定的公平性。 |
|
|
|
|
*/ |
|
|
|
|
// 加锁
|
|
|
|
|
Lock lock = new ReentrantLock(); |
|
|
|
|
lock.lock(); |
|
|
|
|
@ -548,7 +569,7 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
-------------------------------------------------------------- |
|
|
|
|
*/ |
|
|
|
|
// 路段信息查询临时对象
|
|
|
|
|
SectionDTO sectionByCode = new SectionDTO(); |
|
|
|
|
SectionDTO sectionByCode; |
|
|
|
|
// 判断是否是路口(ifCross:1路口,2路段)
|
|
|
|
|
if (Objects.equals(manualInvestigation.getIfCross(), "1")) { |
|
|
|
|
// 路口数据将保存的SectionCode赋值给CrossCode
|
|
|
|
|
@ -645,6 +666,8 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
// 操作人
|
|
|
|
|
thtTimeLineDTO.setOperator(manualInvestigation.getOperator()); |
|
|
|
|
|
|
|
|
|
// 将生成的business_id存入manualInvestigation对象中
|
|
|
|
|
manualInvestigation.setBusinessId(hidden_businessId); |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
分别插入三张表 |
|
|
|
|
@ -657,9 +680,10 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
insertTimeLine(thtTimeLineDTO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// manualInvestigation.setBusinessId(hidden_businessId);
|
|
|
|
|
|
|
|
|
|
// 更新隐患名称(暂存/保存)
|
|
|
|
|
highDangerMapper.updateHiddenDangerBaseName(hidden_businessId,manualInvestigation.getName()); |
|
|
|
|
manualInvestigation.setBusinessId(hidden_businessId); |
|
|
|
|
|
|
|
|
|
// 保存辖区和街道
|
|
|
|
|
highDangerMapper.updateSectionCommunity(hidden_businessId, manualInvestigation.getXqcode(), manualInvestigation.getJdcode()); |
|
|
|
|
@ -681,16 +705,16 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
highDangerMapper.updateSectionInfo(basicInfoVO); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 判断数据库是否存在统计数据
|
|
|
|
|
ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(hidden_businessId); |
|
|
|
|
|
|
|
|
|
if (sectionTraffic != null) { |
|
|
|
|
// 更新统计数据(步骤2)
|
|
|
|
|
highDangerMapper.updateSectionTraffic(manualInvestigation); |
|
|
|
|
} else { |
|
|
|
|
// 保存统计数据(步骤2)
|
|
|
|
|
highDangerMapper.insertSectionTraffic(manualInvestigation); |
|
|
|
|
} |
|
|
|
|
// // 判断数据库是否存在统计数据
|
|
|
|
|
// ThtSectionTrafficDTO sectionTraffic = highDangerMapper.getSectionTraffic(hidden_businessId);
|
|
|
|
|
//
|
|
|
|
|
// if (sectionTraffic != null) {
|
|
|
|
|
// // 更新统计数据(步骤2)
|
|
|
|
|
// highDangerMapper.updateSectionTraffic(manualInvestigation);
|
|
|
|
|
// } else {
|
|
|
|
|
// // 保存统计数据(步骤2)
|
|
|
|
|
// highDangerMapper.insertSectionTraffic(manualInvestigation);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 查询base表的pcCount值
|
|
|
|
|
HighDangerBase higDangerDetail = highDangerMapper.getHigDangerDetail(hidden_businessId); |
|
|
|
|
@ -896,14 +920,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
|
|
|
|
|
// 超期
|
|
|
|
|
if (Objects.equals(dangerBase.getTimeStatus(), "1")) { |
|
|
|
|
// // 获取相差的时间戳
|
|
|
|
|
// double timeDiffSeconds = Double.parseDouble(base.getTimeDiffEnd());
|
|
|
|
|
// // 计算天数
|
|
|
|
|
// int days = (int)Math.floor(timeDiffSeconds / (24 * 3600));
|
|
|
|
|
// // 计算秒数
|
|
|
|
|
// double remainingSeconds = timeDiffSeconds % (24 * 3600);
|
|
|
|
|
// // 计算小时数
|
|
|
|
|
// int hours = (int)Math.ceil(remainingSeconds / 3600);
|
|
|
|
|
|
|
|
|
|
if (delayDay == 0) { |
|
|
|
|
dangerBase.setDeadlineStatus("超期" + delayHour + "小时"); |
|
|
|
|
@ -918,14 +934,6 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
dangerBase.setDeadlineType("1"); |
|
|
|
|
} |
|
|
|
|
if (Objects.equals(dangerBase.getTimeStatus(), "2")) { |
|
|
|
|
// // 获取相差的时间戳
|
|
|
|
|
// double timeDiffSeconds = Double.parseDouble(base.getTimeDiffStart());
|
|
|
|
|
// // 计算天数
|
|
|
|
|
// int days= (int)Math.floor(timeDiffSeconds / (24 * 3600));
|
|
|
|
|
// // 计算秒数
|
|
|
|
|
// double remainingSeconds = timeDiffSeconds % (24 * 3600);
|
|
|
|
|
// // 计算小时数
|
|
|
|
|
// int hours = (int)Math.ceil(remainingSeconds / 3600);
|
|
|
|
|
|
|
|
|
|
if (nearDay == 0) { |
|
|
|
|
dangerBase.setDeadlineStatus("临期" + nearHour + "小时"); |
|
|
|
|
@ -948,4 +956,282 @@ public class HighDangerBaseServiceImpl implements HighDangerService { |
|
|
|
|
|
|
|
|
|
return highDangerBase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public PageInfo<HighDangerBase> getHighDealt(HighDangerBaseVO highDangerBaseVO, Integer pageNum, Integer pageSize, String search, String approve, String classification, Float longitude, Float latitude, String startTime, String endTime) { |
|
|
|
|
|
|
|
|
|
if (endTime == null) { |
|
|
|
|
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
endTime = formatter.format(new Date()); |
|
|
|
|
} |
|
|
|
|
String cdepartmentid = null; |
|
|
|
|
String departmentid = null; |
|
|
|
|
// 去掉两侧的空格
|
|
|
|
|
search = search.trim(); |
|
|
|
|
departmentid = configService.getDepartmentJurisdiction(highDangerBaseVO.getNuserid()); |
|
|
|
|
// search = search.replaceAll(" ","");
|
|
|
|
|
|
|
|
|
|
// 获取当前操作的对象,用于查找对应的部
|
|
|
|
|
// Operator operatorById = operatorMapper.getOperatorById(highDangerBaseVO.getNuserid());
|
|
|
|
|
// if (operatorById != null) {
|
|
|
|
|
// cdepartmentid = operatorById.getCdepartmentid();
|
|
|
|
|
// } else {
|
|
|
|
|
// return ServerResponse.error("未找到当前用户");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (!Objects.equals(operatorById.getNlevel(), "2")) {
|
|
|
|
|
// // 取部门的前六位
|
|
|
|
|
// departmentid = cdepartmentid.substring(0, Math.min(cdepartmentid.length(), 6));
|
|
|
|
|
// }
|
|
|
|
|
// int termTime = Integer.parseInt(configureMapper.getTermTime());
|
|
|
|
|
|
|
|
|
|
//Page<HighDangerBase> page = new Page<>(pageNum, pageSize);
|
|
|
|
|
if(!("1".equals(approve) && "3".equals(classification))){ |
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
} |
|
|
|
|
// 将要查询的状态和部门id查询数据库,获得隐患排查表
|
|
|
|
|
List<HighDangerBase> statusCounts = highDangerMapper.getHigDangerDealt(highDangerBaseVO.getStatus(), departmentid, search, highDangerBaseVO.getNuserid(), classification, approve, startTime, endTime); |
|
|
|
|
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
// 遍历排查数据
|
|
|
|
|
for (HighDangerBase base : statusCounts) { |
|
|
|
|
// status是否是0或10,统一修改状态为“排查中”
|
|
|
|
|
if("10".equals(base.getStatus()) || "0".equals(base.getStatus())){ |
|
|
|
|
base.setEnumname("排查中"); |
|
|
|
|
} |
|
|
|
|
// 格式化排查开始时间
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
if(base.getPcStartTime() != null){ |
|
|
|
|
base.setPcStartTimeStr(sdf.format(base.getPcStartTime())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询列表的超期时间、临期时间
|
|
|
|
|
int delayHour = base.getDelayHour() - 1; |
|
|
|
|
int delayDay = base.getDelayDay(); |
|
|
|
|
int nearDay = base.getNearDay(); |
|
|
|
|
int nearHour = base.getNearHour() - 1; |
|
|
|
|
|
|
|
|
|
// 获取审批流程列表
|
|
|
|
|
List<ThtApprove> processRecord = getProcessRecord(base.getBusinessId()); |
|
|
|
|
|
|
|
|
|
// 待办状态数据
|
|
|
|
|
if (Objects.equals(approve, "1")) { |
|
|
|
|
if (!processRecord.isEmpty()) { |
|
|
|
|
// 取审批流程最后一条流程
|
|
|
|
|
ThtApprove thtApprove = processRecord.get(processRecord.size() - 1); |
|
|
|
|
// 状态不是驳回
|
|
|
|
|
if (!Objects.equals(thtApprove.getApproveResult(), "-1")) { |
|
|
|
|
String format = ""; |
|
|
|
|
String approveTime = ""; |
|
|
|
|
String approveStatus = ""; |
|
|
|
|
if(thtApprove.getOperateTime() != null){ |
|
|
|
|
format = dateFormat.format(thtApprove.getOperateTime()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Objects.equals(base.getApproveStatus(), "1")) { |
|
|
|
|
approveTime = "一次审批"; |
|
|
|
|
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + approveStatus + " " + format); |
|
|
|
|
} |
|
|
|
|
if (Objects.equals(base.getApproveStatus(), "2")) { |
|
|
|
|
approveTime = "二次审批"; |
|
|
|
|
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + approveStatus + " " + format); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if(Objects.equals(approve, "2")){ // 已完成
|
|
|
|
|
// 获取审批状态流程表
|
|
|
|
|
ThtApprove thtApprove = highDangerMapper.getProcessRecordByNid(base.getBusinessId(),highDangerBaseVO.getNuserid(),highDangerBaseVO.getStatus()); |
|
|
|
|
if (thtApprove != null) { |
|
|
|
|
String approveTime = ""; |
|
|
|
|
String approveStatus = ""; |
|
|
|
|
String format = ""; |
|
|
|
|
if (thtApprove.getOperateTime() != null) { |
|
|
|
|
format = dateFormat.format(thtApprove.getOperateTime()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 当前状态
|
|
|
|
|
if (Objects.equals(base.getStatus(), "0") || Objects.equals(thtApprove.getStatus(), "10")) { |
|
|
|
|
base.setEnumname("排查中"); |
|
|
|
|
} else if (Objects.equals(base.getStatus(), "20")) { |
|
|
|
|
base.setEnumname("治理中"); |
|
|
|
|
} else if (Objects.equals(base.getStatus(), "60")) { |
|
|
|
|
base.setEnumname("治理方案中"); |
|
|
|
|
} else if (Objects.equals(base.getStatus(), "50")) { |
|
|
|
|
base.setEnumname("跟踪中"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Objects.equals(base.getApproveStatus(), "1")) { |
|
|
|
|
approveTime = "一次审批"; |
|
|
|
|
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + format); |
|
|
|
|
} |
|
|
|
|
else if (Objects.equals(base.getApproveStatus(), "2")) { |
|
|
|
|
approveTime = "二次审批"; |
|
|
|
|
base.setEnumname(base.getEnumname() + "(" + approveTime + ") " + format); |
|
|
|
|
} else { |
|
|
|
|
base.setEnumname(base.getEnumname() + " " + format); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 正常
|
|
|
|
|
String deadlineStatus = "剩余" + Math.abs(nearDay) + "天" + (Math.abs(nearHour) == 24 ? 23 : Math.abs(nearHour) == 0 ? 1 : Math.abs(nearHour)) + "小时"; |
|
|
|
|
if (base.getTimeStatus() == null || base.getTimeStatus().equals("9")) { |
|
|
|
|
if(Math.abs(nearDay) == 0){ |
|
|
|
|
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时"); |
|
|
|
|
}else{ |
|
|
|
|
// 等于24变成23,等于0变为1
|
|
|
|
|
base.setDeadlineStatus(deadlineStatus); |
|
|
|
|
base.setDeadlineType("3"); |
|
|
|
|
} |
|
|
|
|
// base.setDeadlineStatus("正常");
|
|
|
|
|
// base.setDeadlineType("3");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 临期
|
|
|
|
|
if(Objects.equals(base.getTimeStatus(), "2")){ |
|
|
|
|
if(Math.abs(nearDay) == 0){ |
|
|
|
|
base.setDeadlineStatus("剩余" + Math.abs(nearHour)+"小时"); |
|
|
|
|
} else { |
|
|
|
|
// 等于24变成23,等于0变为1
|
|
|
|
|
base.setDeadlineStatus(deadlineStatus); |
|
|
|
|
} |
|
|
|
|
base.setDeadlineType("2"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 超期
|
|
|
|
|
if (Objects.equals(base.getTimeStatus(), "1")) { |
|
|
|
|
// // 获取相差的时间戳
|
|
|
|
|
// double timeDiffSeconds = Double.parseDouble(base.getTimeDiffEnd());
|
|
|
|
|
// // 计算天数
|
|
|
|
|
// int days = (int)Math.floor(timeDiffSeconds / (24 * 3600));
|
|
|
|
|
// // 计算秒数
|
|
|
|
|
// double remainingSeconds = timeDiffSeconds % (24 * 3600);
|
|
|
|
|
// // 计算小时数
|
|
|
|
|
// int hours = (int)Math.ceil(remainingSeconds / 3600);
|
|
|
|
|
|
|
|
|
|
if (delayDay == 0) { |
|
|
|
|
base.setDeadlineStatus("超期" + Math.abs(delayHour) + "小时"); |
|
|
|
|
if(delayHour == 0){ |
|
|
|
|
base.setDeadlineStatus("超期不足一小时"); |
|
|
|
|
} |
|
|
|
|
} else if (delayHour == 0) { |
|
|
|
|
base.setDeadlineStatus("超期" + Math.abs(delayDay) + "天"); |
|
|
|
|
} else { |
|
|
|
|
base.setDeadlineStatus("超期" + Math.abs(delayDay) + "天" + Math.abs(delayHour) + "小时"); |
|
|
|
|
} |
|
|
|
|
base.setDeadlineType("1"); |
|
|
|
|
} |
|
|
|
|
// if (Objects.equals(base.getTimeStatus(), "2")) {
|
|
|
|
|
//
|
|
|
|
|
// if (nearDay == 0) {
|
|
|
|
|
// base.setDeadlineStatus("临期" + Math.abs(nearHour) + "小时");
|
|
|
|
|
// if(delayHour == 0){
|
|
|
|
|
// base.setDeadlineStatus("临期不足一小时");
|
|
|
|
|
// }
|
|
|
|
|
// } else if (nearHour == 0) {
|
|
|
|
|
// base.setDeadlineStatus("临期" + Math.abs(nearDay) + "天");
|
|
|
|
|
// } else {
|
|
|
|
|
// base.setDeadlineStatus("临期" + Math.abs(nearDay) + "天" + Math.abs(nearHour) + "小时");
|
|
|
|
|
// }
|
|
|
|
|
// base.setDeadlineType("2");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if("1".equals(approve) && "3".equals(classification)){ |
|
|
|
|
LinkedList<Map<String, Double>> pointList = new LinkedList<>(); |
|
|
|
|
|
|
|
|
|
SectionDTO sectionDTO = new SectionDTO(); |
|
|
|
|
// 路口
|
|
|
|
|
if("1".equals(base.getIfCross())){ |
|
|
|
|
sectionDTO = highDangerMapper.getCrossingByCode(base.getCrossCode()); |
|
|
|
|
} |
|
|
|
|
// 路段
|
|
|
|
|
if("2".equals(base.getIfCross())){ |
|
|
|
|
sectionDTO = highDangerMapper.getSectionByCode(base.getSectionCode()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (sectionDTO == null) { |
|
|
|
|
sectionDTO = new SectionDTO(); |
|
|
|
|
HighDangerRoad highDangerRoadByBusinessId = highDangerMapper.getHighDangerRoadByBusinessId(base.getBusinessId()); |
|
|
|
|
if(highDangerRoadByBusinessId != null){ |
|
|
|
|
String coordinate = highDangerRoadByBusinessId.getCoordinate(); |
|
|
|
|
String result = ""; |
|
|
|
|
String[] split = coordinate.split(","); |
|
|
|
|
// 保存的坐标是奇数
|
|
|
|
|
if(split.length % 2 == 1){ |
|
|
|
|
int lastCommaIndex = coordinate.lastIndexOf(","); |
|
|
|
|
result = coordinate.substring(0, lastCommaIndex); |
|
|
|
|
}else{ |
|
|
|
|
result = coordinate; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sectionDTO.setPosition(result); |
|
|
|
|
}else{ |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(sectionDTO.getPosition() == null){ |
|
|
|
|
log.info("--------------最近距离问题businessId:{}",base.getBusinessId()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// 将单条路段的坐标点依次取出进行对比
|
|
|
|
|
String[] split = sectionDTO.getPosition().split(","); |
|
|
|
|
Point Dpoint = new Point(); |
|
|
|
|
Double minDistance = 0.0; |
|
|
|
|
|
|
|
|
|
Point point = new Point(); |
|
|
|
|
point.setX(longitude); |
|
|
|
|
point.setY(latitude); |
|
|
|
|
|
|
|
|
|
if(split.length % 2 == 1){ |
|
|
|
|
log.info("---------------------【列表查询】排查的路段坐标有误:{}",base); |
|
|
|
|
} |
|
|
|
|
/* |
|
|
|
|
遍历坐标字符串 |
|
|
|
|
字符串格式: 【119.996321,36.800453,119.996309,36.800294,119.996205,36.798752】 |
|
|
|
|
*/ |
|
|
|
|
for (int i = 0; i < split.length; i += 2) { |
|
|
|
|
|
|
|
|
|
double xPoint = Double.parseDouble(split[i]); |
|
|
|
|
double yPoint = Double.parseDouble(split[i + 1]); |
|
|
|
|
|
|
|
|
|
Map<String, Double> pointMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
CoordinateConverter.AMap aMap = CoordinateConverter.transform(xPoint, yPoint); |
|
|
|
|
// pointMap.put("longitude", aMap.getLongitude());
|
|
|
|
|
// pointMap.put("latitude", aMap.getLatitude());
|
|
|
|
|
//
|
|
|
|
|
// pointList.add(pointMap);
|
|
|
|
|
|
|
|
|
|
Dpoint.setX(aMap.getLongitude()); |
|
|
|
|
Dpoint.setY(aMap.getLatitude()); |
|
|
|
|
// 计算两点间的距离
|
|
|
|
|
Double pointDistance = getPointDistance(Dpoint, point); |
|
|
|
|
if (minDistance == null || minDistance == 0) { |
|
|
|
|
minDistance = pointDistance; |
|
|
|
|
continue; |
|
|
|
|
} else { |
|
|
|
|
if (pointDistance < minDistance) { |
|
|
|
|
minDistance = pointDistance; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 设置距离
|
|
|
|
|
base.setDistance((int) Math.ceil(minDistance)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if("1".equals(approve) && "3".equals(classification)) { |
|
|
|
|
// 根据距离排序
|
|
|
|
|
statusCounts.sort(new Comparator<HighDangerBase>() { |
|
|
|
|
@Override |
|
|
|
|
public int compare(HighDangerBase o1, HighDangerBase o2) { |
|
|
|
|
return o1.getDistance() - o2.getDistance(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 分页
|
|
|
|
|
PageInfo<HighDangerBase> pageInfo = new PageInfo<>(statusCounts); |
|
|
|
|
|
|
|
|
|
return pageInfo; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|