Commit 6abb93c3 by huangjinxin

fix:后续工程师工单添加辅助工程师校验

1 parent 046915fe
...@@ -19,6 +19,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS ...@@ -19,6 +19,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes); List<OrderInfoEntity> findByDtAndEngineerCodeIn(LocalDate date, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCodeSubIn(LocalDate date, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndServiceStatusNotAndEngineerCodeIn(LocalDate date, String serviceSatus, List<String> engineerCodes); List<OrderInfoEntity> findByDtAndServiceStatusNotAndEngineerCodeIn(LocalDate date, String serviceSatus, List<String> engineerCodes);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode); List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate date, String engineerCode);
......
...@@ -100,5 +100,15 @@ public class DispatchEngineerOrderListResp { ...@@ -100,5 +100,15 @@ public class DispatchEngineerOrderListResp {
private Integer isCutoff = 0; private Integer isCutoff = 0;
private String beanTags; private String beanTags;
/**
* 辅助工程师工号
*/
private String engineerCodeSub = "";
/**
* 是否是辅助单
*/
private Boolean isSub = false;
} }
} }
...@@ -10,7 +10,6 @@ import com.dituhui.pea.order.common.TimeUtils; ...@@ -10,7 +10,6 @@ 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.*; 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.entity.*;
import com.dituhui.pea.order.enums.*; import com.dituhui.pea.order.enums.*;
import com.dituhui.pea.order.service.CommonService; import com.dituhui.pea.order.service.CommonService;
...@@ -172,9 +171,9 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -172,9 +171,9 @@ public class DispatchServiceImpl implements DispatchService {
} }
// 获取engineerCodes // 获取engineerCodes
List<String> engineerCodes = engineers.stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList()); List<String> engineerCodes = engineers.stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList());
Set<String> skillGroupCodes = Sets.newConcurrentHashSet();
if (CollectionUtils.isNotEmpty(reqDTO.getOrderIds())) { if (CollectionUtils.isNotEmpty(reqDTO.getOrderIds())) {
List<OrderInfoEntity> infoEntities = orderInfoDao.findAllByOrderIdIn(reqDTO.getOrderIds()); List<OrderInfoEntity> infoEntities = orderInfoDao.findAllByOrderIdIn(reqDTO.getOrderIds());
Set<String> skillGroupCodes = Sets.newConcurrentHashSet();
for (OrderInfoEntity orderInfo : infoEntities) { for (OrderInfoEntity orderInfo : infoEntities) {
//查询对应的技能信息 //查询对应的技能信息
SkillInfoEntity skill = skillInfo.get(String.format("%s%s%s", orderInfo.getBrand(), orderInfo.getType(), orderInfo.getSkill())); SkillInfoEntity skill = skillInfo.get(String.format("%s%s%s", orderInfo.getBrand(), orderInfo.getType(), orderInfo.getSkill()));
...@@ -183,11 +182,12 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -183,11 +182,12 @@ public class DispatchServiceImpl implements DispatchService {
} }
skillGroupCodes.add(skill.getSkillGroupCode()); skillGroupCodes.add(skill.getSkillGroupCode());
} }
engineerCodes = handleEngineerLeave(engineerCodes, date, skillGroupCodes);
} }
engineerCodes = handleEngineerLeave(engineerCodes, date, skillGroupCodes);
// 获取技术员已指派单列表 // 获取技术员已指派单列表
Map<String, List<OrderInfoEntity>> engineerOrders = this.queryEngineerOrders(engineerCodes, date); Map<String, List<OrderInfoEntity>> engineerOrders = this.queryEngineerOrders(engineerCodes, date);
Map<String, List<OrderInfoEntity>> subEngineerOrders = this.querySubEngineerOrders(engineerCodes, date);
// 获取技术员的容量 // 获取技术员的容量
HashMap<String, CapacityEngineerStatEntity> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate()); HashMap<String, CapacityEngineerStatEntity> engineerCap = this.queryCapacityEngineerStat(engineerCodes, reqDTO.getDate());
...@@ -202,8 +202,10 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -202,8 +202,10 @@ public class DispatchServiceImpl implements DispatchService {
// 技术员已指派的订单列表 // 技术员已指派的订单列表
List<OrderInfoEntity> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>()); List<OrderInfoEntity> records = engineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
List<OrderInfoEntity> subRecords = subEngineerOrders.getOrDefault(e.getEngineerCode(), new ArrayList<>());
records.addAll(subRecords);
for (OrderInfoEntity o : records) { for (OrderInfoEntity o : records) {
addOrderToItems(o, items, skillInfo, true); addOrderToItems(o, items, skillInfo, true, e.getEngineerCode());
} }
// 获取容量 // 获取容量
...@@ -245,9 +247,11 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -245,9 +247,11 @@ public class DispatchServiceImpl implements DispatchService {
private List<String> handleEngineerLeave(List<String> engineerCodes, LocalDate targetDate, Set<String> skillGroupCodes) { 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 (CollectionUtils.isNotEmpty(skillGroupCodes)) {
if (skilllEngineerCodes.size() < skillGroupCodes.size()) { List skilllEngineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCode, skillGroupCodes);
continue; if (skilllEngineerCodes.size() < skillGroupCodes.size()) {
continue;
}
} }
//获取工作队休息时间, 判定目标时间是否在工作队休息日中 //获取工作队休息时间, 判定目标时间是否在工作队休息日中
if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) { if (!engineerCalendarService.engineerTargetLeave(engineerCode, targetDate)) {
...@@ -257,7 +261,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -257,7 +261,7 @@ public class DispatchServiceImpl implements DispatchService {
return engineerCodes2; return engineerCodes2;
} }
private void addOrderToItems(OrderInfoEntity o, List<DispatchEngineerOrderListResp.OrderInfo> items, HashMap<String, SkillInfoEntity> skillInfo, boolean isContinue) { private void addOrderToItems(OrderInfoEntity o, List<DispatchEngineerOrderListResp.OrderInfo> items, HashMap<String, SkillInfoEntity> skillInfo, boolean isContinue, String engineerCode) {
DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo(); DispatchEngineerOrderListResp.OrderInfo item = new DispatchEngineerOrderListResp.OrderInfo();
item.setOrderId(o.getOrderId()); item.setOrderId(o.getOrderId());
item.setDescription(String.format("%s:%s-%s-%s\n%s:%s-%s-%s", o.getOrderId(), o.getBrand(), o.getType(), item.setDescription(String.format("%s:%s-%s-%s\n%s:%s-%s-%s", o.getOrderId(), o.getBrand(), o.getType(),
...@@ -309,11 +313,15 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -309,11 +313,15 @@ public class DispatchServiceImpl implements DispatchService {
item.setIsSpecialTime(o.getIsSpecialTime()); item.setIsSpecialTime(o.getIsSpecialTime());
item.setIsCutoff(o.getIsCutoff()); item.setIsCutoff(o.getIsCutoff());
item.setBeanTags(o.getBeanTags()); item.setBeanTags(o.getBeanTags());
item.setEngineerCodeSub(o.getEngineerCodeSub());
if (StringUtils.isNotBlank(o.getEngineerCodeSub()) && o.getIsMultiple() == 1 && o.getEngineerCodeSub().equals(engineerCode)) {
item.setIsSub(true);
}
if (isContinue && StringUtils.isNotEmpty(o.getMultipleOrders())) { if (isContinue && StringUtils.isNotEmpty(o.getMultipleOrders())) {
List<OrderInfoEntity> byMultipleOrders = orderInfoDao.findByMultipleOrdersAndOrderIdNot(o.getMultipleOrders(), o.getOrderId()); List<OrderInfoEntity> byMultipleOrders = orderInfoDao.findByMultipleOrdersAndOrderIdNot(o.getMultipleOrders(), o.getOrderId());
List<DispatchEngineerOrderListResp.OrderInfo> multipleItems = new ArrayList<>(); List<DispatchEngineerOrderListResp.OrderInfo> multipleItems = new ArrayList<>();
for (OrderInfoEntity info : byMultipleOrders) { for (OrderInfoEntity info : byMultipleOrders) {
addOrderToItems(info, multipleItems, skillInfo, false); addOrderToItems(info, multipleItems, skillInfo, false, engineerCode);
} }
item.setMultipleOrderList(multipleItems); item.setMultipleOrderList(multipleItems);
} }
...@@ -651,7 +659,6 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -651,7 +659,6 @@ public class DispatchServiceImpl implements DispatchService {
private Map<String, List<OrderInfoEntity>> queryEngineerOrders(List<String> engineerCodes, LocalDate date) { private Map<String, List<OrderInfoEntity>> queryEngineerOrders(List<String> engineerCodes, LocalDate date) {
// 获取工程师服务单列表 // 获取工程师服务单列表
List<OrderInfoEntity> records = orderInfoDao.findByDtAndEngineerCodeIn(date, engineerCodes); List<OrderInfoEntity> records = orderInfoDao.findByDtAndEngineerCodeIn(date, engineerCodes);
// 排序 // 排序
records.sort(Comparator.comparing(OrderInfoEntity::getEngineerCode)); records.sort(Comparator.comparing(OrderInfoEntity::getEngineerCode));
records.sort(Comparator.comparing(OrderInfoEntity::getPlanStartTime)); records.sort(Comparator.comparing(OrderInfoEntity::getPlanStartTime));
...@@ -665,6 +672,23 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -665,6 +672,23 @@ public class DispatchServiceImpl implements DispatchService {
} }
private Map<String, List<OrderInfoEntity>> querySubEngineerOrders(List<String> engineerCodes, LocalDate date) {
// 获取工程师服务单列表
List<OrderInfoEntity> subRecords = orderInfoDao.findByDtAndEngineerCodeSubIn(date, engineerCodes);
// 排序
subRecords.sort(Comparator.comparing(OrderInfoEntity::getEngineerCode));
subRecords.sort(Comparator.comparing(OrderInfoEntity::getPlanStartTime));
//过滤
List<OrderInfoEntity> orders = subRecords.stream()
.filter(r -> !r.getOrderStatus().equals(OrderStatusEnum.CANCELED))
.collect(Collectors.toList());
return orders.stream().collect(Collectors.groupingBy(OrderInfoEntity::getEngineerCodeSub));
}
public List<EngineerInfoEntity> queryEngineers(List<String> teamIds, List<String> engineerCodes, String key) { public List<EngineerInfoEntity> queryEngineers(List<String> teamIds, List<String> engineerCodes, String key) {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<EngineerInfoEntity> criteriaQuery = criteriaBuilder.createQuery(EngineerInfoEntity.class); CriteriaQuery<EngineerInfoEntity> criteriaQuery = criteriaBuilder.createQuery(EngineerInfoEntity.class);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!