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(),
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!