Commit 63415388 by huangjinxin

fix:订单插单优化

1 parent fc6b7a75
......@@ -298,6 +298,8 @@ public class DispatchServiceImpl implements DispatchService {
public Result<?> dispatchOrderConfirm(String engineerCode, String date, List<String> orderIds) throws BusinessException {
// 派工台确认派单
LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
List<String> successList = new ArrayList<>();
List<String> errorList = new ArrayList<>();
EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode);
if (engineer == null) {
......@@ -320,13 +322,12 @@ public class DispatchServiceImpl implements DispatchService {
}
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill());
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(localDate, engineer.getEngineerCode());
if (CollectionUtils.isNotEmpty(engineerOrders)) {
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return Result.failed("当前工程师无法预约合适时间");
// return Result.failed("当前工程师无法预约合适时间");
errorList.add(entity.getOrderId());
}
entity = entityResult.getResult();
}
entity.setTakeTime(skill.getTakeTime());
entity.setEngineerCode(engineer.getEngineerCode());
entity.setEngineerName(engineer.getName());
......@@ -341,8 +342,16 @@ public class DispatchServiceImpl implements DispatchService {
commonService.addOrderEvent(entity.getOrderId(), "", "PEA", "PEA", OrderEventEnum.reassignment.getEvent(),
String.format(OrderEventEnum.reassignment.getMsg(), engineer.getName() + "-" + (ObjectUtil.isNotNull(byTeamId) ? byTeamId.getTeamName() : "")),
"", LocalDateTime.now());
successList.add(entity.getOrderId());
}
List<String> resultList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(successList)) {
resultList.add(String.format("%s订单指派(改派)成功", String.join(",", successList)));
}
if (CollectionUtils.isNotEmpty(errorList)) {
resultList.add(String.format("%s订单指派(改派)失败,当前工程师无法预约合适时间", String.join(",", errorList)));
}
return Result.success(null);
return Result.success(CollectionUtils.isNotEmpty(resultList) ? String.join(",", resultList) : null);
}
@Override
......
......@@ -164,13 +164,11 @@ 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());
if (CollectionUtils.isNotEmpty(engineerOrders)) {
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
return Result.failed("当前工程师工单已满");
}
entity = entityResult.getResult();
}
entity.setEngineerCode(engineer.getEngineerCode());
entity.setEngineerName(engineer.getName());
......
......@@ -442,15 +442,26 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Transactional
@Override
public Result<OrderInfoEntity> insterEngineerOrders(List<OrderInfoEntity> engineerOrders, OrderInfoEntity insertOrder, SkillInfoEntity skillInfo, OrgTeamEntity orgTeam, EngineerInfoEntity engineer) {
int takeTime = skillInfo.getTakeTime();
// 获取客户期望时间段
LocalDateTime start = insertOrder.getExpectTimeBegin();
LocalDateTime end = insertOrder.getExpectTimeEnd();
// 没有单直接返回
// 获取团队工作起止时间
String[] teamWorkStartTime = orgTeam.getWorkOn().split(":");
String[] teamWorkEndTime = orgTeam.getWorkOff().split(":");
LocalDateTime startTeam = insertOrder.getDt().atTime(Integer.parseInt(teamWorkStartTime[0]), Integer.parseInt(teamWorkStartTime[1]), 0);
LocalDateTime endTeam = insertOrder.getDt().atTime(Integer.parseInt(teamWorkEndTime[0]), Integer.parseInt(teamWorkEndTime[1]), 0);
// 获取客户期望时间段
LocalDateTime start = insertOrder.getExpectTimeBegin();
LocalDateTime end = insertOrder.getExpectTimeEnd();
if (CollectionUtils.isEmpty(engineerOrders)) {
// 特殊时间不插单
if (LocalDateTime.now().isBefore(startTeam) || LocalDateTime.now().isAfter(endTeam) || end.isAfter(endTeam) || end.isBefore(startTeam)) {
return Result.failed(insertOrder);
}
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(insertOrder.getExpectTimeBegin());
insertOrder.setPlanEndTime(insertOrder.getExpectTimeBegin().plusMinutes(skillInfo.getTakeTime()));
return Result.success(insertOrder);
}
int takeTime = skillInfo.getTakeTime();
// 计算最早派工和最晚派工时间
LocalDateTime workStartTime = start.isAfter(startTeam) ? start : startTeam;
LocalDateTime workEndTime = end.isBefore(endTeam) ? end : endTeam;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!