Commit 39797ca5 by huangjinxin

fix:插单处理请假时间

1 parent 822072a4
...@@ -460,11 +460,13 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -460,11 +460,13 @@ public class OrderInfoServiceImpl implements OrderInfoService {
LocalDateTime workStartTime = insertOrder.getExpectTimeBegin(); LocalDateTime workStartTime = insertOrder.getExpectTimeBegin();
LocalDateTime workEndTime = insertOrder.getExpectTimeEnd(); LocalDateTime workEndTime = insertOrder.getExpectTimeEnd();
//查询工程师当天出勤时间 //查询工程师当天出勤时间
List<OccupyInfoDetail> engineerWorkTimeSlice = engineerCalendarService.timeWindowsSlice(engineer.getEngineerCode(), orgTeam.getTeamId(), insertOrder.getDt()); // List<OccupyInfoDetail> engineerWorkTimeSlice = engineerCalendarService.timeWindowsSlice(engineer.getEngineerCode(), orgTeam.getTeamId(), insertOrder.getDt());
log.info("【engineerWorkTimeSlice】结果------------->{}", JsonUtil.toJson(engineerWorkTimeSlice)); //查询工程师当天请假时间
List<OccupyInfoDetail> engineerLeaveTimeSlice = engineerCalendarService.getEngineerWorkDayCalendar(engineer.getEngineerCode(), insertOrder.getDt());
log.info("【engineerWorkTimeSlice】结果------------->{}", JsonUtil.toJson(engineerLeaveTimeSlice));
// 没有单直接返回 // 没有单直接返回
if (CollectionUtils.isEmpty(engineerOrders)) { if (CollectionUtils.isEmpty(engineerOrders)) {
LocalDateTime planStartTime = handleWorkTime(engineerWorkTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeBegin().plusMinutes(skillInfo.getTakeTime())); LocalDateTime planStartTime = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime());
if (ObjectUtil.isNull(planStartTime)) { if (ObjectUtil.isNull(planStartTime)) {
return Result.failed(insertOrder); return Result.failed(insertOrder);
} }
...@@ -493,7 +495,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -493,7 +495,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
} }
// 没有单直接返回 // 没有单直接返回
if (CollectionUtils.isEmpty(orderSegments)) { if (CollectionUtils.isEmpty(orderSegments)) {
LocalDateTime planStartTime = handleWorkTime(engineerWorkTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeBegin().plusMinutes(skillInfo.getTakeTime())); LocalDateTime planStartTime = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime());
if (ObjectUtil.isNull(planStartTime)) { if (ObjectUtil.isNull(planStartTime)) {
return Result.failed(insertOrder); return Result.failed(insertOrder);
} }
...@@ -515,7 +517,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -515,7 +517,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
int roadTime = distanceDTO.getTime() / 1000; int roadTime = distanceDTO.getTime() / 1000;
// 先判断第一单开始时间 // 先判断第一单开始时间
if (i == 0 && orderSegment.getStart().compareTo(workStartTime.plusMinutes(takeTime + roadTime)) >= 0) { if (i == 0 && orderSegment.getStart().compareTo(workStartTime.plusMinutes(takeTime + roadTime)) >= 0) {
LocalDateTime planStartTime = handleWorkTime(engineerWorkTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeBegin().plusMinutes(skillInfo.getTakeTime())); LocalDateTime planStartTime = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime());
if (ObjectUtil.isNull(planStartTime)) { if (ObjectUtil.isNull(planStartTime)) {
return Result.failed(insertOrder); return Result.failed(insertOrder);
} }
...@@ -538,11 +540,11 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -538,11 +540,11 @@ public class OrderInfoServiceImpl implements OrderInfoService {
// 判断工单开始时间 // 判断工单开始时间
LocalDateTime planStartTime = insertOrder.getExpectTimeBegin().compareTo(orderSegment.getEnd().plusMinutes(roadTime)) >= 0 ? LocalDateTime planStartTime = insertOrder.getExpectTimeBegin().compareTo(orderSegment.getEnd().plusMinutes(roadTime)) >= 0 ?
insertOrder.getExpectTimeBegin() : orderSegment.getEnd().plusMinutes(roadTime); insertOrder.getExpectTimeBegin() : orderSegment.getEnd().plusMinutes(roadTime);
planStartTime = handleWorkTime(engineerWorkTimeSlice, planStartTime, planStartTime.plusMinutes(skillInfo.getTakeTime())); planStartTime = handleLeaveTime(engineerLeaveTimeSlice, planStartTime, insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime());
if (ObjectUtil.isNull(planStartTime)) { if (ObjectUtil.isNull(planStartTime)) {
return Result.failed(insertOrder); return Result.failed(insertOrder);
} }
insertOrder.setArriveDistance(roadTime); insertOrder.setArriveElapsed(roadTime);
insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue()); insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
insertOrder.setTakeTime(skillInfo.getTakeTime()); insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(planStartTime); insertOrder.setPlanStartTime(planStartTime);
...@@ -561,19 +563,19 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -561,19 +563,19 @@ public class OrderInfoServiceImpl implements OrderInfoService {
// 判断工单开始时间 // 判断工单开始时间
LocalDateTime planStartTime = insertOrder.getExpectTimeBegin().compareTo(orderSegment.getEnd().plusMinutes(roadTime)) >= 0 ? LocalDateTime planStartTime = insertOrder.getExpectTimeBegin().compareTo(orderSegment.getEnd().plusMinutes(roadTime)) >= 0 ?
insertOrder.getExpectTimeBegin() : orderSegment.getEnd().plusMinutes(roadTime); insertOrder.getExpectTimeBegin() : orderSegment.getEnd().plusMinutes(roadTime);
planStartTime = handleWorkTime(engineerWorkTimeSlice, planStartTime, planStartTime.plusMinutes(skillInfo.getTakeTime())); planStartTime = handleLeaveTime(engineerLeaveTimeSlice, planStartTime, insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime());
if (ObjectUtil.isNull(planStartTime)) { if (ObjectUtil.isNull(planStartTime)) {
return Result.failed(insertOrder); return Result.failed(insertOrder);
} }
insertOrder.setArriveDistance(roadTime); insertOrder.setArriveElapsed(roadTime);
insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue()); insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
insertOrder.setTakeTime(skillInfo.getTakeTime()); insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(planStartTime); insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime())); insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(nestOrderSegment.getOrderId()); OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(nestOrderSegment.getOrderId());
nestOrder.setArriveDistance(roadResult2.getResult().getTime() / 1000); nestOrder.setArriveElapsed(roadResult2.getResult().getTime() / 1000);
nestOrder.setArriveElapsed(BigDecimal.valueOf(roadResult2.getResult().getDis() * 1000).intValue()); nestOrder.setArriveDistance(BigDecimal.valueOf(roadResult2.getResult().getDis() * 1000).intValue());
orderInfoDao.save(nestOrder); orderInfoDao.save(nestOrder);
return Result.success(insertOrder); return Result.success(insertOrder);
} }
...@@ -582,6 +584,32 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -582,6 +584,32 @@ public class OrderInfoServiceImpl implements OrderInfoService {
} }
/** /**
* 处理工程师请假时间和工单计划开始时间
*
* @param engineerLeaveTimeSlice
* @param expectTimeBegin
* @param expectTimeEnd
* @return 工单计划开始时间
*/
private LocalDateTime handleLeaveTime(List<OccupyInfoDetail> engineerLeaveTimeSlice, LocalDateTime expectTimeBegin, LocalDateTime expectTimeEnd, Integer takeTime) {
if (CollectionUtils.isEmpty(engineerLeaveTimeSlice)) {
return expectTimeBegin;
}
for (int i = 0; i < engineerLeaveTimeSlice.size(); i++) {
OccupyInfoDetail occupyInfoDetail = engineerLeaveTimeSlice.get(i);
// 处理请假开始时间
if (expectTimeBegin.plusMinutes(takeTime).compareTo(occupyInfoDetail.getBeginTime()) <= 0) {
return expectTimeBegin;
}
if (expectTimeEnd.compareTo(occupyInfoDetail.getEndTime().plusMinutes(takeTime)) >= 0) {
return expectTimeBegin.compareTo(occupyInfoDetail.getEndTime()) >= 0 ? expectTimeBegin : occupyInfoDetail.getEndTime();
}
return null;
}
return null;
}
/**
* 处理工程师出勤时间和工单计划开始时间 * 处理工程师出勤时间和工单计划开始时间
* *
* @param engineerWorkTimeSlice * @param engineerWorkTimeSlice
...@@ -589,16 +617,18 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -589,16 +617,18 @@ public class OrderInfoServiceImpl implements OrderInfoService {
* @param expectTimeEnd * @param expectTimeEnd
* @return 工单计划开始时间 * @return 工单计划开始时间
*/ */
private LocalDateTime handleWorkTime(List<OccupyInfoDetail> engineerWorkTimeSlice, LocalDateTime expectTimeBegin, LocalDateTime expectTimeEnd) { private LocalDateTime handleWorkTime(List<OccupyInfoDetail> engineerWorkTimeSlice, LocalDateTime expectTimeBegin, LocalDateTime expectTimeEnd, Integer takeTime) {
if (CollectionUtils.isEmpty(engineerWorkTimeSlice)) { if (CollectionUtils.isEmpty(engineerWorkTimeSlice)) {
return null; return null;
} }
for (int i = 0; i < engineerWorkTimeSlice.size(); i++) { for (int i = 0; i < engineerWorkTimeSlice.size(); i++) {
OccupyInfoDetail occupyInfoDetail = engineerWorkTimeSlice.get(i); OccupyInfoDetail occupyInfoDetail = engineerWorkTimeSlice.get(i);
if (expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) < 0 || expectTimeEnd.compareTo(occupyInfoDetail.getEndTime()) > 0) { LocalDateTime planStartTime = expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) >= 0 ? expectTimeBegin : occupyInfoDetail.getBeginTime();
LocalDateTime planEndTime = expectTimeEnd.compareTo(occupyInfoDetail.getEndTime()) <= 0 ? expectTimeEnd : occupyInfoDetail.getEndTime();
if (planStartTime.plusMinutes(takeTime).compareTo(planEndTime) > 0) {
continue; continue;
} }
return expectTimeBegin.compareTo(occupyInfoDetail.getBeginTime()) >= 0 ? expectTimeBegin : occupyInfoDetail.getBeginTime(); return planStartTime;
} }
return null; return null;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!