Commit 046915fe by Ren Ping

Merge remote-tracking branch 'origin/develop' into develop

2 parents 756f43d2 f337e39c
......@@ -63,7 +63,7 @@ public class DispatchController {
// 派工台确认派单
Result<?> res = null;
try {
res = dispatchService.dispatchOrderConfirm(req.getEngineerCode(), req.getDate(), req.getOrderIds());
res = dispatchService.dispatchOrderConfirm(req);
}catch (BusinessException e){
return Result.failed(e.getMessage());
}
......
......@@ -146,6 +146,6 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ
"WHERE ei.bean_status = 1 AND ote.team_id = :teamId AND ote.engineer_code = :engineerCode AND ote.`status` = 1", nativeQuery = true)
EngineerInfoEntity selectEngineerByEngineerCodeAndTeamId(@Param("engineerCode") String engineerCode, @Param("teamId") String teamId);
@Query(value = "SELECT DISTINCT esg.engineer_code FROM engineer_skill_group esg WHERE engineer_code in (:engineerCodes) and skill_group_code in (:skillGroupCodes) and status = 1", nativeQuery = true)
List<String> findByEngineerCodesBySkillCodes(@Param("engineerCodes") List<String> engineerCodes, @Param("skillGroupCodes") Set<String> skillGroupCodes);
@Query(value = "SELECT esg.engineer_code FROM engineer_skill_group esg WHERE engineer_code = :engineerCode and skill_group_code in (:skillGroupCodes) and status = 1", nativeQuery = true)
List<String> findByEngineerCodesBySkillCodes(@Param("engineerCode") String engineerCode, @Param("skillGroupCodes") Set<String> skillGroupCodes);
}
......@@ -23,6 +23,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
List<OrderInfoEntity> findByDtAndEngineerCodeSub(LocalDate date, String engineerCode);
@Query("SELECT o.orderId, s.skillCategory as skillCaption FROM OrderInfoEntity o JOIN SkillInfoEntity s on o.brand=s.brand and o.type=s.type and o.skill=s.skill WHERE o.orderId = :orderId and o.dt = :dt")
OrderSkillProjection getOrderSkillCaptionByOrderIdAndDt(String orderId, LocalDate dt);
......
......@@ -9,4 +9,9 @@ public class DispatchOrderConfirmReqDTO {
private String engineerCode;
private String date;
private List<String> orderIds;
/**
* 是否是辅助工程师指定
*/
private Boolean isSub = false;
}
......@@ -11,4 +11,9 @@ public class OrderAssignReq {
* 操作员
*/
private String operator;
/**
* 是否是辅助工程师指定
*/
private Boolean isSub = false;
}
......@@ -15,6 +15,11 @@ public class OrderSegment {
private int elapsed;
private int distance;
/**
* 是否是辅助单
*/
private Boolean isSub = false;
public OrderSegment() {
}
......
......@@ -158,12 +158,6 @@ public class OrderInfoEntity {
@Column(name = "arrive_distance", nullable = true, columnDefinition = "int(11) default '0'")
private Integer arriveDistance = 0;
/**
* 辅助工程师在途时长
*/
@Column(name = "sub_distance", nullable = true, columnDefinition = "int(11) default '0'")
private Integer subDistance = 0;
@Column(name = "actual_start_time")
private LocalDateTime actualStartTime;
......@@ -258,4 +252,28 @@ public class OrderInfoEntity {
*/
@Column(name = "vehicle")
private Integer vehicle;
/**
* 辅助工程师计划开始时间
*/
@Column(name = "sub_plan_start_time")
private LocalDateTime subPlanStartTime;
/**
* 辅助工程师计划结束时间
*/
@Column(name = "sub_plan_end_time")
private LocalDateTime subPlanEndTime;
/**
* 辅助工程师在途时长
*/
@Column(name = "sub_distance", nullable = true, columnDefinition = "int(11) default '0'")
private Integer subDistance = 0;
/**
* 辅助工程师到达耗时(分钟)
*/
@Column(name = "sub_elapsed", nullable = true, columnDefinition = "int(11) default '0'")
private Integer subElapsed = 0;
}
......@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderConfirmReqDTO;
import com.dituhui.pea.order.dto.DispatchOrderListReq;
import java.util.List;
......@@ -12,7 +13,7 @@ public interface DispatchService {
Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO);
Result<?> dispatchOrderConfirm(String engineerCode, String date, List<String> orderIds);
Result<?> dispatchOrderConfirm(DispatchOrderConfirmReqDTO req);
/**
* 待派工工单池分组
......@@ -21,4 +22,5 @@ public interface DispatchService {
* @return
*/
Result<?> getDispatchOrderGroup(DispatchOrderListReq reqDTO);
}
......@@ -58,15 +58,16 @@ public interface OrderInfoService {
Result<?> orderReschedulingReason();
/**
* 根据工程师当日订单插入订单
* 根据工程师当日订单插入订单(根据工单预计开始时间插入,其他顺延)
*
* @param skillInfo 待指派订单技能
* @param engineerOrders 待指派工程师当日工单
* @param insertOrder 待指派订单
* @param orgTeam 待指派工程师团队
* @param engineer 指派工程师
* @param isSub 是否指派辅助指派工程师
* @return
*/
public Result<OrderInfoEntity> insterEngineerOrders(List<OrderInfoEntity> engineerOrders, OrderInfoEntity insertOrder, SkillInfoEntity skillInfo, OrgTeamEntity orgTeam, EngineerInfoEntity engineer);
public Result<OrderInfoEntity> insterEngineerOrders(List<OrderInfoEntity> engineerOrders, OrderInfoEntity insertOrder, SkillInfoEntity skillInfo, OrgTeamEntity orgTeam, EngineerInfoEntity engineer, Boolean isSub);
}
......@@ -9,10 +9,7 @@ import com.dituhui.pea.order.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
import com.dituhui.pea.order.dto.DispatchOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderListResp;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.dto.param.CapacityQueryDTO;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.*;
......@@ -186,8 +183,7 @@ public class DispatchServiceImpl implements DispatchService {
}
skillGroupCodes.add(skill.getSkillGroupCode());
}
engineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCodes, skillGroupCodes);
engineerCodes = handleEngineerLeave(engineerCodes, date);
engineerCodes = handleEngineerLeave(engineerCodes, date, skillGroupCodes);
}
// 获取技术员已指派单列表
......@@ -243,11 +239,16 @@ public class DispatchServiceImpl implements DispatchService {
*
* @param engineerCodes
* @param targetDate
* @param skillGroupCodes
* @return
*/
private List<String> handleEngineerLeave(List<String> engineerCodes, LocalDate targetDate) {
private List<String> handleEngineerLeave(List<String> engineerCodes, LocalDate targetDate, Set<String> skillGroupCodes) {
List engineerCodes2 = new ArrayList();
for (String engineerCode : engineerCodes) {
List skilllEngineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCode, skillGroupCodes);
if (skilllEngineerCodes.size() < skillGroupCodes.size()) {
continue;
}
//获取工作队休息时间, 判定目标时间是否在工作队休息日中
if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) {
engineerCodes2.add(engineerCode);
......@@ -321,7 +322,10 @@ public class DispatchServiceImpl implements DispatchService {
@Transactional
@Override
public Result<?> dispatchOrderConfirm(String engineerCode, String date, List<String> orderIds) throws BusinessException {
public Result<?> dispatchOrderConfirm(DispatchOrderConfirmReqDTO reqDTO) throws BusinessException {
String engineerCode = reqDTO.getEngineerCode();
String date = reqDTO.getDate();
List<String> orderIds = reqDTO.getOrderIds();
// 派工台确认派单
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
List<String> successList = new ArrayList<>();
......@@ -344,11 +348,19 @@ public class DispatchServiceImpl implements DispatchService {
for (OrderInfoEntity entity : orders) {
if (StringUtils.isNotBlank(entity.getEngineerCode()) && entity.getEngineerCode().equals(engineer.getEngineerCode())) {
return Result.failed(String.format("订单已指派个技术员[%s], 不必重复指派给同一个技术员", engineer.getName()));
return Result.failed(String.format("订单已指派给技术员[%s], 不必重复指派给同一个技术员", engineer.getName()));
}
if (reqDTO.getIsSub() && entity.getEngineerCodeSub().equals(engineer.getEngineerCode())) {
return Result.failed(String.format("订单已指派给技术员[%s], 不必重复指派给同一个技术员", engineer.getName()));
}
if (reqDTO.getIsSub() && entity.getIsMultiple() != 1) {
return Result.failed("订单无需指派辅助工程师");
}
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill());
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(localDate, engineer.getEngineerCode());
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
List<OrderInfoEntity> engineerSubOrders = orderInfoDao.findByDtAndEngineerCodeSub(localDate, engineer.getEngineerCode());
engineerOrders.addAll(engineerSubOrders);
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer, reqDTO.getIsSub());
log.info("插入订单信息------------->{}", JsonUtil.toJson(entityResult));
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
// return Result.failed("当前工程师无法预约合适时间");
......@@ -356,6 +368,9 @@ public class DispatchServiceImpl implements DispatchService {
continue;
}
entity = entityResult.getResult();
if (reqDTO.getIsSub()) {
entity.setEngineerCodeSub(engineer.getEngineerCode());
} else {
entity.setTakeTime(skill.getTakeTime());
entity.setEngineerCode(engineer.getEngineerCode());
entity.setEngineerName(engineer.getName());
......@@ -366,6 +381,7 @@ public class DispatchServiceImpl implements DispatchService {
entity.setOrgGroupId(byTeamId.getGroupId());
entity.setOrgBranchId(byTeamId.getBranchId());
entity.setOrgClusterId(byTeamId.getClusterId());
}
orderInfoDao.save(entity);
//记录流程
commonService.addOrderEvent(entity.getOrderId(), "", "PEA", "PEA", OrderEventEnum.reassignment.getEvent(),
......@@ -382,6 +398,7 @@ public class DispatchServiceImpl implements DispatchService {
return Result.success();
}
@Override
public Result<?> getDispatchOrderGroup(DispatchOrderListReq reqDTO) {
// 获取技能信息
......
......@@ -232,7 +232,9 @@ public class OrderAssignImpl implements OrderAssign {
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill());
//判断工程师订单当日工单时间安排
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(entity.getDt(), engineer.getEngineerCode());
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
List<OrderInfoEntity> engineerSubOrders = orderInfoDao.findByDtAndEngineerCodeSub(entity.getDt(), engineer.getEngineerCode());
engineerOrders.addAll(engineerSubOrders);
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer, req.getIsSub());
log.info("插入订单信息------------->{}", JsonUtil.toJson(entityResult));
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
String desc = StatusCodeEnum.ENGINEER_IS_LEAVE_TIME.getDesc();
......@@ -241,6 +243,9 @@ public class OrderAssignImpl implements OrderAssign {
}
entity = entityResult.getResult();
if (req.getIsSub()){
entity.setEngineerCodeSub(engineer.getEngineerCode());
}else {
entity.setEngineerCode(engineer.getEngineerCode());
entity.setEngineerName(engineer.getName());
entity.setEngineerPhone(engineer.getPhone());
......@@ -250,6 +255,7 @@ public class OrderAssignImpl implements OrderAssign {
entity.setOrgGroupId(byTeamId.getGroupId());
entity.setOrgBranchId(byTeamId.getBranchId());
entity.setOrgClusterId(byTeamId.getClusterId());
}
orderInfoDao.save(entity);
// 工单变更登记
commonService.addOrderEvent(entity.getOrderId(), "", "BEAN", "BEAN", OrderEventEnum.reassignment.getEvent(),
......
......@@ -11,6 +11,7 @@ import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.OccupyInfoDetail;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.constant.OrderConstant;
import com.dituhui.pea.order.constant.OrderReschedulingReason;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.MsgDTO;
......@@ -485,30 +486,39 @@ public class OrderInfoServiceImpl implements OrderInfoService {
* @param insertOrder 待指派订单
* @param orgTeam 待指派工程师团队
* @param engineer 指派工程师
* @param isSub 是否指派辅助指派工程师
* @return
*/
@Transactional
@Override
public Result<OrderInfoEntity> insterEngineerOrders(List<OrderInfoEntity> engineerOrders, OrderInfoEntity insertOrder, SkillInfoEntity skillInfo, OrgTeamEntity orgTeam, EngineerInfoEntity engineer) {
public Result<OrderInfoEntity> insterEngineerOrders(List<OrderInfoEntity> engineerOrders, OrderInfoEntity insertOrder, SkillInfoEntity skillInfo, OrgTeamEntity orgTeam, EngineerInfoEntity engineer, Boolean isSub) {
//查询工程师当天请假时间
int takeTime = isSub ? OrderConstant.sub_engineer_take_time : skillInfo.getTakeTime();
LocalDateTime beginStart = isSub ? insertOrder.getPlanStartTime() : insertOrder.getExpectTimeBegin();
LocalDateTime beginEnd = isSub ? insertOrder.getPlanStartTime().plusMinutes(OrderConstant.sub_engineer_take_time) : insertOrder.getExpectTimeEnd();
log.info("待插入工程师是否是辅助工程师------------->{}", isSub);
log.info("待插入订单耗时------------->{}", takeTime);
log.info("待插入订单信息------------->{}", JsonUtil.toJson(insertOrder));
List<OccupyInfoDetail> engineerLeaveTimeSlice = engineerCalendarService.getEngineerWorkDayCalendar(engineer.getEngineerCode(), insertOrder.getDt());
log.info("【engineerWorkTimeSlice】结果------------->{}", JsonUtil.toJson(engineerLeaveTimeSlice));
// 没有单直接返回
if (CollectionUtils.isEmpty(engineerOrders)) {
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime(), true, insertOrder);
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, beginStart, beginEnd, takeTime, true, insertOrder);
if (!handleLeaveTimeResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
if (isSub) {
insertOrder = handleSubOrder(insertOrder, planStartTime, 0, 0);
return Result.success(insertOrder);
}
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setTakeTime(takeTime);
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
insertOrder.setPlanEndTime(planStartTime.plusMinutes(takeTime));
return Result.success(insertOrder);
}
int takeTime = skillInfo.getTakeTime();
// 计算最早派工和最晚派工时间
// 订单工作时间顺序排序
List<OrderSegment> orderSegments = new ArrayList<>();
......@@ -524,30 +534,49 @@ public class OrderInfoServiceImpl implements OrderInfoService {
seg.setDistance(orderInfo.getArriveDistance());
seg.setStart(orderInfo.getPlanStartTime());
seg.setEnd(orderInfo.getPlanEndTime());
if (StringUtils.isNotBlank(orderInfo.getEngineerCodeSub()) && orderInfo.getIsMultiple() == 1 && orderInfo.getEngineerCodeSub().equals(engineer.getEngineerCode())) {
seg.setIsSub(true);
seg.setElapsed(orderInfo.getSubElapsed());
seg.setDistance(orderInfo.getSubDistance());
seg.setStart(orderInfo.getSubPlanStartTime());
seg.setEnd(orderInfo.getSubPlanEndTime());
}
orderSegments.add(seg);
}
// 没有单直接返回
if (CollectionUtils.isEmpty(orderSegments)) {
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime(), true, insertOrder);
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, beginStart, beginEnd, takeTime, true, insertOrder);
if (!handleLeaveTimeResult.getCode().equals(ResultEnum.SUCCESS)) {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
if (isSub) {
insertOrder = handleSubOrder(insertOrder, planStartTime, 0, 0);
return Result.success(insertOrder);
}
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setTakeTime(takeTime);
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
insertOrder.setPlanEndTime(planStartTime.plusMinutes(takeTime));
return Result.success(insertOrder);
}
OrderSegment seg = new OrderSegment();
seg.setX(Double.parseDouble(insertOrder.getX()));
seg.setY(Double.parseDouble(insertOrder.getY()));
seg.setOrderId(insertOrder.getOrderId());
if (isSub) {
seg.setIsSub(true);
seg.setElapsed(0);
seg.setDistance(0);
seg.setStart(insertOrder.getPlanStartTime());
seg.setEnd(insertOrder.getPlanStartTime().plusMinutes(OrderConstant.sub_engineer_take_time));
} else {
seg.setElapsed(insertOrder.getArriveElapsed());
seg.setDistance(insertOrder.getArriveDistance());
seg.setStart(insertOrder.getExpectTimeBegin());
seg.setEnd(insertOrder.getExpectTimeEnd());
}
orderSegments.add(seg);
orderSegments = orderSegments.stream().sorted(Comparator.comparing(OrderSegment::getStart)).collect(Collectors.toList());
// 工单排序
......@@ -560,8 +589,13 @@ public class OrderInfoServiceImpl implements OrderInfoService {
continue;
}
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(orderSegment.getOrderId());
if (orderSegment.getIsSub()) {
nestOrder.setSubPlanStartTime(nestOrder.getSubPlanStartTime().plusMinutes(moveTime));
nestOrder.setSubPlanEndTime(nestOrder.getSubPlanEndTime().plusMinutes(moveTime));
} else {
nestOrder.setPlanStartTime(nestOrder.getPlanStartTime().plusMinutes(moveTime));
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(moveTime));
}
orderInfoDao.save(nestOrder);
continue;
}
......@@ -576,25 +610,34 @@ public class OrderInfoServiceImpl implements OrderInfoService {
DistanceDTO distanceDTO = roadResult.getResult();
int roadTime = BigDecimal.valueOf(distanceDTO.getTime()).divide(BigDecimal.valueOf(60), 0, RoundingMode.HALF_UP).intValue();
if (orderSegment.getOrderId().equals(insertOrder.getOrderId())) {
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime(), true, insertOrder);
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, beginStart, beginEnd, takeTime, true, insertOrder);
if (!handleLeaveTimeResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
//第一个没有在途时长
if (isSub) {
if (i == 0) {
insertOrder.setSubDistance(0);
insertOrder.setSubElapsed(0);
}
insertOrder.setSubPlanStartTime(planStartTime);
insertOrder.setSubPlanEndTime(planStartTime.plusMinutes(takeTime));
} else {
if (i == 0) {
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
}
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setTakeTime(takeTime);
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
insertOrder.setPlanEndTime(planStartTime.plusMinutes(takeTime));
}
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(nestOrderSegment.getOrderId());
nestOrder.setArriveElapsed(roadTime);
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
if (orderSegment.getStart().plusMinutes(takeTime + roadTime).compareTo(nestOrder.getPlanStartTime()) > 0) {
long minutes = Duration.between(nestOrder.getPlanStartTime(), planStartTime.plusMinutes(skillInfo.getTakeTime() + roadTime)).toMinutes();
long minutes = Duration.between(nestOrder.getPlanStartTime(), planStartTime.plusMinutes(takeTime + roadTime)).toMinutes();
nestOrder.setPlanStartTime(nestOrder.getPlanStartTime().plusMinutes(minutes));
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(minutes));
orderInfoDao.save(nestOrder);
......@@ -606,46 +649,75 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.success(insertOrder);
}
if (nestOrderSegment.getOrderId().equals(insertOrder.getOrderId())) {
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, insertOrder.getExpectTimeBegin(), insertOrder.getExpectTimeEnd(), skillInfo.getTakeTime(), true, insertOrder);
Result handleLeaveTimeResult = handleLeaveTime(engineerLeaveTimeSlice, beginStart, beginEnd, takeTime, true, insertOrder);
if (!handleLeaveTimeResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return handleLeaveTimeResult;
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
if (orderSegment.getEnd().plusMinutes(roadTime).compareTo(planStartTime) <= 0) {
//下一单为待插入订单且为最后一单直接返回
if (isSub) {
insertOrder.setSubElapsed(roadTime);
insertOrder.setSubDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
} else {
insertOrder.setArriveElapsed(roadTime);
insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
}
if (i == orderSegments.size() - 2) {
insertOrder.setTakeTime(skillInfo.getTakeTime());
if (isSub) {
insertOrder = handleSubOrder(insertOrder, planStartTime, roadTime, BigDecimal.valueOf(distanceDTO.getDis()).intValue());
return Result.success(insertOrder);
}
insertOrder.setTakeTime(takeTime);
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
insertOrder.setPlanEndTime(planStartTime.plusMinutes(takeTime));
return Result.success(insertOrder);
}
continue;
}
insertOrder.setTakeTime(skillInfo.getTakeTime());
if (isSub) {
insertOrder.setSubPlanStartTime(planStartTime);
insertOrder.setSubPlanEndTime(planStartTime.plusMinutes(takeTime));
} else {
insertOrder.setTakeTime(takeTime);
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
insertOrder.setPlanEndTime(planStartTime.plusMinutes(takeTime));
}
if (i > 0) {
OrderSegment orderSegmentPrev = orderSegments.get(i - 1);
Result<DistanceDTO> roadResultPrev = pathService.getRoadDistance(orderSegmentPrev.getOrderId(), insertOrder.getOrderId(), engineer.getVehicle());
log.info("【getRoadDistancePrev】参数------------->{},{},{}", orderSegmentPrev.getOrderId(), insertOrder.getOrderId(), engineer.getVehicle());
log.info("【getRoadDistancePrev】结果------------->{}", JsonUtil.toJson(roadResultPrev));
int roadTimePrev = BigDecimal.valueOf(roadResultPrev.getResult().getTime()).divide(BigDecimal.valueOf(60), 0, RoundingMode.HALF_UP).intValue();
if (isSub) {
insertOrder.setSubElapsed(roadTimePrev);
insertOrder.setSubDistance(BigDecimal.valueOf(roadResultPrev.getResult().getDis()).intValue());
} else {
insertOrder.setArriveElapsed(roadTimePrev);
insertOrder.setArriveDistance(BigDecimal.valueOf(roadResultPrev.getResult().getDis()).intValue());
}
} else {
// 第一单没有在途时长
if (isSub) {
insertOrder.setSubElapsed(0);
insertOrder.setSubDistance(0);
} else {
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
}
}
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(orderSegment.getOrderId());
long minutes = Duration.between(nestOrder.getPlanStartTime(), planStartTime.plusMinutes(takeTime + roadTime)).toMinutes();
if (orderSegment.getIsSub()) {
nestOrder = handleSubOrder(nestOrder, nestOrder.getPlanStartTime().plusMinutes(minutes), roadTime, BigDecimal.valueOf(distanceDTO.getDis()).intValue());
} else {
nestOrder.setArriveElapsed(roadTime);
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
long minutes = Duration.between(nestOrder.getPlanStartTime(), planStartTime.plusMinutes(skillInfo.getTakeTime() + roadTime)).toMinutes();
nestOrder.setPlanStartTime(nestOrder.getPlanStartTime().plusMinutes(minutes));
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(minutes));
}
orderInfoDao.save(nestOrder);
//下一单为待插入订单且为最后一单直接返回
if (i == orderSegments.size() - 2) {
......@@ -658,6 +730,20 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.success(insertOrder);
}
/**
* 处理辅助工单返回信息
*
* @param insertOrder
* @return
*/
private OrderInfoEntity handleSubOrder(OrderInfoEntity insertOrder, LocalDateTime planStartTime, Integer elapsed, Integer distance) {
insertOrder.setSubDistance(distance);
insertOrder.setSubElapsed(elapsed);
insertOrder.setSubPlanStartTime(planStartTime);
insertOrder.setSubPlanEndTime(planStartTime.plusMinutes(OrderConstant.sub_engineer_take_time));
return insertOrder;
}
/**
* 处理工程师请假时间和工单计划开始时间
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!