Commit 88ff1569 by huangjinxin

fix:工单查单优化

1 parent 53cbc50b
...@@ -306,13 +306,11 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -306,13 +306,11 @@ public class DispatchServiceImpl implements DispatchService {
if (CollectionUtils.isNotEmpty(engineerOrders)) { if (CollectionUtils.isNotEmpty(engineerOrders)) {
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer); Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return Result.failed("当前工程师工单已满"); return Result.failed("当前工程师无法预约合适时间");
} }
entity = entityResult.getResult(); entity = entityResult.getResult();
} }
entity.setTakeTime(skill.getTakeTime()); entity.setTakeTime(skill.getTakeTime());
entity.setPlanStartTime(entity.getExpectTimeBegin());
entity.setPlanEndTime(entity.getExpectTimeBegin().plusMinutes(skill.getTakeTime()));
entity.setEngineerCode(engineer.getEngineerCode()); entity.setEngineerCode(engineer.getEngineerCode());
entity.setEngineerName(engineer.getName()); entity.setEngineerName(engineer.getName());
entity.setEngineerPhone(engineer.getPhone()); entity.setEngineerPhone(engineer.getPhone());
......
...@@ -8,6 +8,7 @@ import com.dituhui.pea.common.ResultEnum; ...@@ -8,6 +8,7 @@ import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.dispatch.IPath; import com.dituhui.pea.dispatch.IPath;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.constant.OrderReschedulingReason; import com.dituhui.pea.order.constant.OrderReschedulingReason;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.MsgDTO; import com.dituhui.pea.order.dto.MsgDTO;
...@@ -448,8 +449,8 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -448,8 +449,8 @@ public class OrderInfoServiceImpl implements OrderInfoService {
// 获取团队工作起止时间 // 获取团队工作起止时间
String[] teamWorkStartTime = orgTeam.getWorkOn().split(":"); String[] teamWorkStartTime = orgTeam.getWorkOn().split(":");
String[] teamWorkEndTime = orgTeam.getWorkOff().split(":"); String[] teamWorkEndTime = orgTeam.getWorkOff().split(":");
LocalDateTime startTeam = LocalDate.now().atTime(Integer.parseInt(teamWorkStartTime[0]), Integer.parseInt(teamWorkStartTime[1]), 0); LocalDateTime startTeam = insertOrder.getDt().atTime(Integer.parseInt(teamWorkStartTime[0]), Integer.parseInt(teamWorkStartTime[1]), 0);
LocalDateTime endTeam = LocalDate.now().atTime(Integer.parseInt(teamWorkEndTime[0]), Integer.parseInt(teamWorkEndTime[1]), 0); LocalDateTime endTeam = insertOrder.getDt().atTime(Integer.parseInt(teamWorkEndTime[0]), Integer.parseInt(teamWorkEndTime[1]), 0);
// 计算最早派工和最晚派工时间 // 计算最早派工和最晚派工时间
LocalDateTime workStartTime = start.isAfter(startTeam) ? start : startTeam; LocalDateTime workStartTime = start.isAfter(startTeam) ? start : startTeam;
LocalDateTime workEndTime = end.isBefore(endTeam) ? end : endTeam; LocalDateTime workEndTime = end.isBefore(endTeam) ? end : endTeam;
...@@ -480,13 +481,15 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -480,13 +481,15 @@ public class OrderInfoServiceImpl implements OrderInfoService {
for (int i = 0; i < orderSegments.size(); i++) { for (int i = 0; i < orderSegments.size(); i++) {
OrderSegment orderSegment = orderSegments.get(i); OrderSegment orderSegment = orderSegments.get(i);
Result<DistanceDTO> roadResult = pathService.getRoadDistance(insertOrder.getOrderId(), orderSegment.getOrderId(), engineer.getVehicle()); Result<DistanceDTO> roadResult = pathService.getRoadDistance(insertOrder.getOrderId(), orderSegment.getOrderId(), engineer.getVehicle());
log.info("【getRoadDistance】参数------------->{},{},{}", insertOrder.getOrderId(), orderSegment.getOrderId(), engineer.getVehicle());
log.info("【getRoadDistance】结果------------->{}", JsonUtil.toJson(roadResult));
if (!roadResult.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!roadResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
continue; continue;
} }
DistanceDTO distanceDTO = roadResult.getResult(); DistanceDTO distanceDTO = roadResult.getResult();
int roadTime = distanceDTO.getTime() / 1000; int roadTime = distanceDTO.getTime() / 1000;
// 先判断第一单开始时间 // 先判断第一单开始时间
if (i == 0 && orderSegment.getStart().minusHours(orderSegment.getElapsed()).compareTo(workStartTime.plusMinutes(takeTime + roadTime)) >= 0) { if (i == 0 && orderSegment.getStart().compareTo(workStartTime.plusMinutes(takeTime + roadTime)) >= 0) {
insertOrder.setTakeTime(skillInfo.getTakeTime()); insertOrder.setTakeTime(skillInfo.getTakeTime());
// insertOrder.setArriveDistance(roadTime); // insertOrder.setArriveDistance(roadTime);
// insertOrder.setArriveDistance(Integer.valueOf(String.valueOf(distanceDTO.getDis() * 1000))); // insertOrder.setArriveDistance(Integer.valueOf(String.valueOf(distanceDTO.getDis() * 1000)));
...@@ -500,7 +503,11 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -500,7 +503,11 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.success(insertOrder); return Result.success(insertOrder);
} }
// 判断当前是不是最后一单 // 判断当前是不是最后一单
if (i == orderSegments.size() - 1 && workEndTime.compareTo(orderSegment.getEnd().plusMinutes(takeTime + roadTime)) >= 0) { if (i == orderSegments.size() - 1) {
// 最后一单如果没有符合条件的则代表没有合适时间
if (workEndTime.compareTo(orderSegment.getEnd().plusMinutes(takeTime + roadTime)) < 0) {
return Result.failed(insertOrder);
}
insertOrder.setTakeTime(skillInfo.getTakeTime()); insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setArriveDistance(roadTime); insertOrder.setArriveDistance(roadTime);
insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue()); insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
...@@ -511,10 +518,12 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -511,10 +518,12 @@ public class OrderInfoServiceImpl implements OrderInfoService {
// 当前单在中间 // 当前单在中间
OrderSegment nestOrderSegment = orderSegments.get(i + 1); OrderSegment nestOrderSegment = orderSegments.get(i + 1);
Result<DistanceDTO> roadResult2 = pathService.getRoadDistance(nestOrderSegment.getOrderId(), insertOrder.getOrderId(), engineer.getVehicle()); Result<DistanceDTO> roadResult2 = pathService.getRoadDistance(nestOrderSegment.getOrderId(), insertOrder.getOrderId(), engineer.getVehicle());
log.info("【getRoadDistance2】参数------------->{},{},{}", nestOrderSegment.getOrderId(), insertOrder.getOrderId(), engineer.getVehicle());
log.info("【getRoadDistance2】结果------------->{}", JsonUtil.toJson(roadResult2));
if (!roadResult.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!roadResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
continue; continue;
} }
if (nestOrderSegment.getStart().minusHours(roadResult2.getResult().getTime() / 1000).compareTo(orderSegment.getEnd().plusMinutes(takeTime + roadTime)) >= 0) { if (nestOrderSegment.getStart().minusMinutes(roadResult2.getResult().getTime() / 1000).compareTo(orderSegment.getEnd().plusMinutes(takeTime + roadTime)) >= 0) {
insertOrder.setTakeTime(skillInfo.getTakeTime()); insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setArriveDistance(roadTime); insertOrder.setArriveDistance(roadTime);
insertOrder.setArriveElapsed(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue()); insertOrder.setArriveElapsed(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!