Commit f337e39c by huangjinxin

fix:1:工程师推荐技能过滤 2:辅助工程师插单

1 parent c7e4b8bc
...@@ -63,7 +63,7 @@ public class DispatchController { ...@@ -63,7 +63,7 @@ public class DispatchController {
// 派工台确认派单 // 派工台确认派单
Result<?> res = null; Result<?> res = null;
try { try {
res = dispatchService.dispatchOrderConfirm(req.getEngineerCode(), req.getDate(), req.getOrderIds()); res = dispatchService.dispatchOrderConfirm(req);
}catch (BusinessException e){ }catch (BusinessException e){
return Result.failed(e.getMessage()); return Result.failed(e.getMessage());
} }
......
...@@ -146,6 +146,6 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ ...@@ -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) "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); 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) @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("engineerCodes") List<String> engineerCodes, @Param("skillGroupCodes") Set<String> skillGroupCodes); List<String> findByEngineerCodesBySkillCodes(@Param("engineerCode") String engineerCode, @Param("skillGroupCodes") Set<String> skillGroupCodes);
} }
...@@ -23,6 +23,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS ...@@ -23,6 +23,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode); 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") @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); OrderSkillProjection getOrderSkillCaptionByOrderIdAndDt(String orderId, LocalDate dt);
......
...@@ -6,7 +6,12 @@ import java.util.List; ...@@ -6,7 +6,12 @@ import java.util.List;
@Data @Data
public class DispatchOrderConfirmReqDTO { public class DispatchOrderConfirmReqDTO {
private String engineerCode; private String engineerCode;
private String date; private String date;
private List<String> orderIds; private List<String> orderIds;
/**
* 是否是辅助工程师指定
*/
private Boolean isSub = false;
} }
...@@ -11,4 +11,9 @@ public class OrderAssignReq { ...@@ -11,4 +11,9 @@ public class OrderAssignReq {
* 操作员 * 操作员
*/ */
private String operator; private String operator;
/**
* 是否是辅助工程师指定
*/
private Boolean isSub = false;
} }
...@@ -15,6 +15,11 @@ public class OrderSegment { ...@@ -15,6 +15,11 @@ public class OrderSegment {
private int elapsed; private int elapsed;
private int distance; private int distance;
/**
* 是否是辅助单
*/
private Boolean isSub = false;
public OrderSegment() { public OrderSegment() {
} }
......
...@@ -158,12 +158,6 @@ public class OrderInfoEntity { ...@@ -158,12 +158,6 @@ public class OrderInfoEntity {
@Column(name = "arrive_distance", nullable = true, columnDefinition = "int(11) default '0'") @Column(name = "arrive_distance", nullable = true, columnDefinition = "int(11) default '0'")
private Integer arriveDistance = 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") @Column(name = "actual_start_time")
private LocalDateTime actualStartTime; private LocalDateTime actualStartTime;
...@@ -258,4 +252,28 @@ public class OrderInfoEntity { ...@@ -258,4 +252,28 @@ public class OrderInfoEntity {
*/ */
@Column(name = "vehicle") @Column(name = "vehicle")
private Integer 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; ...@@ -2,6 +2,7 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq; import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderConfirmReqDTO;
import com.dituhui.pea.order.dto.DispatchOrderListReq; import com.dituhui.pea.order.dto.DispatchOrderListReq;
import java.util.List; import java.util.List;
...@@ -12,7 +13,7 @@ public interface DispatchService { ...@@ -12,7 +13,7 @@ public interface DispatchService {
Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO); Result<?> getDispatchEngineerOrderList(DispatchEngineerOrderListReq reqDTO);
Result<?> dispatchOrderConfirm(String engineerCode, String date, List<String> orderIds); Result<?> dispatchOrderConfirm(DispatchOrderConfirmReqDTO req);
/** /**
* 待派工工单池分组 * 待派工工单池分组
...@@ -21,4 +22,5 @@ public interface DispatchService { ...@@ -21,4 +22,5 @@ public interface DispatchService {
* @return * @return
*/ */
Result<?> getDispatchOrderGroup(DispatchOrderListReq reqDTO); Result<?> getDispatchOrderGroup(DispatchOrderListReq reqDTO);
} }
...@@ -58,15 +58,16 @@ public interface OrderInfoService { ...@@ -58,15 +58,16 @@ public interface OrderInfoService {
Result<?> orderReschedulingReason(); Result<?> orderReschedulingReason();
/** /**
* 根据工程师当日订单插入订单 * 根据工程师当日订单插入订单(根据工单预计开始时间插入,其他顺延)
* *
* @param skillInfo 待指派订单技能 * @param skillInfo 待指派订单技能
* @param engineerOrders 待指派工程师当日工单 * @param engineerOrders 待指派工程师当日工单
* @param insertOrder 待指派订单 * @param insertOrder 待指派订单
* @param orgTeam 待指派工程师团队 * @param orgTeam 待指派工程师团队
* @param engineer 指派工程师 * @param engineer 指派工程师
* @param isSub 是否指派辅助指派工程师
* @return * @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; ...@@ -9,10 +9,7 @@ import com.dituhui.pea.order.common.ListUtils;
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.common.jackson.JsonUtil;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq; import com.dituhui.pea.order.dto.*;
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.param.CapacityQueryDTO; import com.dituhui.pea.order.dto.param.CapacityQueryDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.*; import com.dituhui.pea.order.enums.*;
...@@ -186,8 +183,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -186,8 +183,7 @@ public class DispatchServiceImpl implements DispatchService {
} }
skillGroupCodes.add(skill.getSkillGroupCode()); skillGroupCodes.add(skill.getSkillGroupCode());
} }
engineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCodes, skillGroupCodes); engineerCodes = handleEngineerLeave(engineerCodes, date, skillGroupCodes);
engineerCodes = handleEngineerLeave(engineerCodes, date);
} }
// 获取技术员已指派单列表 // 获取技术员已指派单列表
...@@ -243,11 +239,16 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -243,11 +239,16 @@ public class DispatchServiceImpl implements DispatchService {
* *
* @param engineerCodes * @param engineerCodes
* @param targetDate * @param targetDate
* @param skillGroupCodes
* @return * @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(); List engineerCodes2 = new ArrayList();
for (String engineerCode : engineerCodes) { for (String engineerCode : engineerCodes) {
List skilllEngineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCode, skillGroupCodes);
if (skilllEngineerCodes.size() < skillGroupCodes.size()) {
continue;
}
//获取工作队休息时间, 判定目标时间是否在工作队休息日中 //获取工作队休息时间, 判定目标时间是否在工作队休息日中
if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) { if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) {
engineerCodes2.add(engineerCode); engineerCodes2.add(engineerCode);
...@@ -321,7 +322,10 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -321,7 +322,10 @@ public class DispatchServiceImpl implements DispatchService {
@Transactional @Transactional
@Override @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); LocalDate localDate = TimeUtils.IsoDate2LocalDate(date);
List<String> successList = new ArrayList<>(); List<String> successList = new ArrayList<>();
...@@ -344,11 +348,19 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -344,11 +348,19 @@ public class DispatchServiceImpl implements DispatchService {
for (OrderInfoEntity entity : orders) { for (OrderInfoEntity entity : orders) {
if (StringUtils.isNotBlank(entity.getEngineerCode()) && entity.getEngineerCode().equals(engineer.getEngineerCode())) { 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()); SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill());
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(localDate, engineer.getEngineerCode()); 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)); log.info("插入订单信息------------->{}", JsonUtil.toJson(entityResult));
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
// return Result.failed("当前工程师无法预约合适时间"); // return Result.failed("当前工程师无法预约合适时间");
...@@ -356,16 +368,20 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -356,16 +368,20 @@ public class DispatchServiceImpl implements DispatchService {
continue; continue;
} }
entity = entityResult.getResult(); entity = entityResult.getResult();
entity.setTakeTime(skill.getTakeTime()); if (reqDTO.getIsSub()) {
entity.setEngineerCode(engineer.getEngineerCode()); entity.setEngineerCodeSub(engineer.getEngineerCode());
entity.setEngineerName(engineer.getName()); } else {
entity.setEngineerPhone(engineer.getPhone()); entity.setTakeTime(skill.getTakeTime());
entity.setAppointmentStatus(OrderFlowEnum.CONFIRM.name()); entity.setEngineerCode(engineer.getEngineerCode());
entity.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); entity.setEngineerName(engineer.getName());
entity.setOrgTeamId(byTeamId.getTeamId()); entity.setEngineerPhone(engineer.getPhone());
entity.setOrgGroupId(byTeamId.getGroupId()); entity.setAppointmentStatus(OrderFlowEnum.CONFIRM.name());
entity.setOrgBranchId(byTeamId.getBranchId()); entity.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
entity.setOrgClusterId(byTeamId.getClusterId()); entity.setOrgTeamId(byTeamId.getTeamId());
entity.setOrgGroupId(byTeamId.getGroupId());
entity.setOrgBranchId(byTeamId.getBranchId());
entity.setOrgClusterId(byTeamId.getClusterId());
}
orderInfoDao.save(entity); orderInfoDao.save(entity);
//记录流程 //记录流程
commonService.addOrderEvent(entity.getOrderId(), "", "PEA", "PEA", OrderEventEnum.reassignment.getEvent(), commonService.addOrderEvent(entity.getOrderId(), "", "PEA", "PEA", OrderEventEnum.reassignment.getEvent(),
...@@ -382,6 +398,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -382,6 +398,7 @@ public class DispatchServiceImpl implements DispatchService {
return Result.success(); return Result.success();
} }
@Override @Override
public Result<?> getDispatchOrderGroup(DispatchOrderListReq reqDTO) { public Result<?> getDispatchOrderGroup(DispatchOrderListReq reqDTO) {
// 获取技能信息 // 获取技能信息
......
...@@ -232,7 +232,9 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -232,7 +232,9 @@ public class OrderAssignImpl implements OrderAssign {
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill()); SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill());
//判断工程师订单当日工单时间安排 //判断工程师订单当日工单时间安排
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(entity.getDt(), engineer.getEngineerCode()); 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)); log.info("插入订单信息------------->{}", JsonUtil.toJson(entityResult));
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
String desc = StatusCodeEnum.ENGINEER_IS_LEAVE_TIME.getDesc(); String desc = StatusCodeEnum.ENGINEER_IS_LEAVE_TIME.getDesc();
...@@ -241,15 +243,19 @@ public class OrderAssignImpl implements OrderAssign { ...@@ -241,15 +243,19 @@ public class OrderAssignImpl implements OrderAssign {
} }
entity = entityResult.getResult(); entity = entityResult.getResult();
entity.setEngineerCode(engineer.getEngineerCode()); if (req.getIsSub()){
entity.setEngineerName(engineer.getName()); entity.setEngineerCodeSub(engineer.getEngineerCode());
entity.setEngineerPhone(engineer.getPhone()); }else {
entity.setAppointmentStatus(OrderFlowEnum.CONFIRM.name()); entity.setEngineerCode(engineer.getEngineerCode());
entity.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name()); entity.setEngineerName(engineer.getName());
entity.setOrgTeamId(byTeamId.getTeamId()); entity.setEngineerPhone(engineer.getPhone());
entity.setOrgGroupId(byTeamId.getGroupId()); entity.setAppointmentStatus(OrderFlowEnum.CONFIRM.name());
entity.setOrgBranchId(byTeamId.getBranchId()); entity.setAppointmentMethod(AppointmentMethodEnum.MANUAL.name());
entity.setOrgClusterId(byTeamId.getClusterId()); entity.setOrgTeamId(byTeamId.getTeamId());
entity.setOrgGroupId(byTeamId.getGroupId());
entity.setOrgBranchId(byTeamId.getBranchId());
entity.setOrgClusterId(byTeamId.getClusterId());
}
orderInfoDao.save(entity); orderInfoDao.save(entity);
// 工单变更登记 // 工单变更登记
commonService.addOrderEvent(entity.getOrderId(), "", "BEAN", "BEAN", OrderEventEnum.reassignment.getEvent(), commonService.addOrderEvent(entity.getOrderId(), "", "BEAN", "BEAN", OrderEventEnum.reassignment.getEvent(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!