Commit f70f6c4c by huangjinxin

fix:工程师列表,甘特图筛选添加订单技能过滤

1 parent e24f9c0f
...@@ -78,9 +78,10 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ ...@@ -78,9 +78,10 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ
/** /**
* 查询在指定技能组中至少满足 skillGroupCodes.size 个技能的工程师 * 查询在指定技能组中至少满足 skillGroupCodes.size 个技能的工程师
* @param skillGroupCodes 技能组编码 *
* @param skillGroupCodes 技能组编码
* @param skillGroupNumber 至少拥有其中skillGroupCodes.size 个技能 * @param skillGroupNumber 至少拥有其中skillGroupCodes.size 个技能
* @param teamId 工作队ID * @param teamId 工作队ID
* @return 工程师信息 * @return 工程师信息
*/ */
@Query(value = "SELECT ei.* FROM org_team_engineer ote " + @Query(value = "SELECT ei.* FROM org_team_engineer ote " +
...@@ -91,7 +92,7 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ ...@@ -91,7 +92,7 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ
" LEFT JOIN engineer_info ei ON ei.engineer_code = tabA.engineer_code " + " LEFT JOIN engineer_info ei ON ei.engineer_code = tabA.engineer_code " +
" WHERE ote.team_id = :teamId AND ei.id is not null" + " WHERE ote.team_id = :teamId AND ei.id is not null" +
" order by ei.engineer_code desc", nativeQuery = true) " order by ei.engineer_code desc", nativeQuery = true)
Set<EngineerInfoEntity> listBySkillGroupCode( @Param("skillGroupCodes")Collection<String> skillGroupCodes, @Param("skillGroupNumber")int skillGroupNumber, @Param("teamId")String teamId); Set<EngineerInfoEntity> listBySkillGroupCode(@Param("skillGroupCodes") Collection<String> skillGroupCodes, @Param("skillGroupNumber") int skillGroupNumber, @Param("teamId") String teamId);
@Query(value = "SELECT ei.* from engineer_info ei left join engineer_skill_group esg on ei.engineer_code = esg.engineer_code " + @Query(value = "SELECT ei.* from engineer_info ei left join engineer_skill_group esg on ei.engineer_code = esg.engineer_code " +
...@@ -127,4 +128,7 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ ...@@ -127,4 +128,7 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ
@Query(value = "SELECT ei.* from org_team_engineer ote left join engineer_info ei ON ote.engineer_code = ei.engineer_code " + @Query(value = "SELECT ei.* from org_team_engineer ote left join engineer_info ei ON ote.engineer_code = ei.engineer_code " +
"WHERE ote.team_id = :teamId AND ote.engineer_code = :engineerCode AND ote.`status` = 1", nativeQuery = true) "WHERE 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)", nativeQuery = true)
List<String> findByEngineerCodesBySkillCodes(@Param("engineerCodes") List<String> engineerCodes, @Param("skillGroupCodes") Set<String> skillGroupCodes);
} }
...@@ -7,16 +7,17 @@ import java.util.List; ...@@ -7,16 +7,17 @@ import java.util.List;
@Data @Data
public class DispatchEngineerOrderListReq { public class DispatchEngineerOrderListReq {
@NotNull @NotNull
private String levelType; private String levelType;
@NotNull @NotNull
private String levelValue; private String levelValue;
@NotNull @NotNull
private String Date; private String Date;
private String groupId; private String groupId;
private List<String> branchIds; private List<String> branchIds;
private List<String> groupIds; private List<String> groupIds;
private List<String> teamIds; private List<String> teamIds;
private List<String> engineerCodes; private List<String> engineerCodes;
private String key; private List<String> orderIds;
private String key;
} }
...@@ -26,6 +26,7 @@ public class EngineersGanttDTO { ...@@ -26,6 +26,7 @@ public class EngineersGanttDTO {
private List<String> branchIds; private List<String> branchIds;
private List<String> groupIds; private List<String> groupIds;
private List<String> teamIds; private List<String> teamIds;
private List<String> orderIds;
private String key; private String key;
} }
......
...@@ -12,12 +12,14 @@ import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq; ...@@ -12,12 +12,14 @@ import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp; import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
import com.dituhui.pea.order.dto.DispatchOrderListReq; import com.dituhui.pea.order.dto.DispatchOrderListReq;
import com.dituhui.pea.order.dto.DispatchOrderListResp; import com.dituhui.pea.order.dto.DispatchOrderListResp;
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;
import com.dituhui.pea.order.service.DispatchService; import com.dituhui.pea.order.service.DispatchService;
import com.dituhui.pea.order.service.OrderInfoService; import com.dituhui.pea.order.service.OrderInfoService;
import com.dituhui.pea.order.utils.CommonUtil; import com.dituhui.pea.order.utils.CommonUtil;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -166,9 +168,21 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -166,9 +168,21 @@ public class DispatchServiceImpl implements DispatchService {
res.setEngineers(egs); res.setEngineers(egs);
return Result.success(res); return Result.success(res);
} }
// 获取engineerCodes // 获取engineerCodes
List<String> engineerCodes = engineers.stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList()); List<String> engineerCodes = engineers.stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(reqDTO.getOrderIds())) {
List<OrderInfoEntity> infoEntities = orderInfoDao.findAllByOrderIdIn(reqDTO.getOrderIds());
Set<String> skillGroupCodes = Sets.newConcurrentHashSet();
for (OrderInfoEntity orderInfo : infoEntities) {
//查询对应的技能信息
SkillInfoEntity skill = skillInfo.get(String.format("%s%s%s", orderInfo.getBrand(), orderInfo.getType(), orderInfo.getSkill()));
if (Objects.isNull(skill)) {
throw new BusinessException("查询不到对应的技能组信息:" + String.join(",", orderInfo.getType(), orderInfo.getSkill()));
}
skillGroupCodes.add(skill.getSkillGroupCode());
}
engineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCodes, skillGroupCodes);
}
// 获取技术员已指派单列表 // 获取技术员已指派单列表
Map<String, List<OrderInfoEntity>> engineerOrders = this.queryEngineerOrders(engineerCodes, date); Map<String, List<OrderInfoEntity>> engineerOrders = this.queryEngineerOrders(engineerCodes, date);
...@@ -179,6 +193,9 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -179,6 +193,9 @@ public class DispatchServiceImpl implements DispatchService {
// 获取技术员已指派单列表 // 获取技术员已指派单列表
List<DispatchEngineerOrderListResp.EngineerInfo> egs = new ArrayList<>(); List<DispatchEngineerOrderListResp.EngineerInfo> egs = new ArrayList<>();
for (EngineerInfoEntity e : engineers) { for (EngineerInfoEntity e : engineers) {
if (!engineerCodes.contains(e.getEngineerCode())) {
continue;
}
List<DispatchEngineerOrderListResp.OrderInfo> items = new ArrayList<>(); List<DispatchEngineerOrderListResp.OrderInfo> items = new ArrayList<>();
// 技术员已指派的订单列表 // 技术员已指派的订单列表
......
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.DateUtils; import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.common.EngineerUtils; import com.dituhui.pea.order.common.EngineerUtils;
...@@ -10,7 +11,9 @@ import com.dituhui.pea.order.dto.LabelValueDTO; ...@@ -10,7 +11,9 @@ import com.dituhui.pea.order.dto.LabelValueDTO;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.OrderFlowEnum; import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.service.EngineerGanttService; import com.dituhui.pea.order.service.EngineerGanttService;
import com.google.common.collect.Sets;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -35,6 +38,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -35,6 +38,8 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
private OrderInfoDao orderInfoDao; private OrderInfoDao orderInfoDao;
@Autowired @Autowired
private EngineerBusinessDao engineerBusinessDao; private EngineerBusinessDao engineerBusinessDao;
@Autowired
private SkillInfoDao skillInfoDao;
private String getHourMinute(LocalDateTime time) { private String getHourMinute(LocalDateTime time) {
return this.getHourMinute(time, 0); return this.getHourMinute(time, 0);
...@@ -51,7 +56,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -51,7 +56,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
List<String> engineerCodes = reqDTO.getEngineerCodes(); List<String> engineerCodes = reqDTO.getEngineerCodes();
if (engineerCodes == null || engineerCodes.isEmpty()) { if (engineerCodes == null || engineerCodes.isEmpty()) {
// 需要根据levelType/levelValue/brandIds/branchIds/groupIds/teamIds/key,后端查询匹配 // 需要根据levelType/levelValue/brandIds/branchIds/groupIds/teamIds/key,后端查询匹配
engineerCodes = findEngineers(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(), reqDTO.getGroupIds(), reqDTO.getTeamIds(), reqDTO.getKey()); engineerCodes = findEngineers(reqDTO.getLevelType(), reqDTO.getLevelValue(), reqDTO.getBranchIds(), reqDTO.getGroupIds(), reqDTO.getTeamIds(), reqDTO.getKey(), reqDTO.getOrderIds());
log.info("根据多条件,查询返回符合条件的技术员列表:{}", engineerCodes); log.info("根据多条件,查询返回符合条件的技术员列表:{}", engineerCodes);
} }
...@@ -149,7 +154,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -149,7 +154,7 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
return Result.success(res); return Result.success(res);
} }
private List<String> findEngineers(String levelType, String levelValue, List<String> branchIds, List<String> groupIds, List<String> teamIds, String key) { private List<String> findEngineers(String levelType, String levelValue, List<String> branchIds, List<String> groupIds, List<String> teamIds, String key, List<String> orderIds) {
// brandIds, groupIds, teamIds, 以team -> group -> branch 为顺序判断,前者优先; // brandIds, groupIds, teamIds, 以team -> group -> branch 为顺序判断,前者优先;
List<String> engineerCodes = new ArrayList<>(); List<String> engineerCodes = new ArrayList<>();
if (teamIds != null && teamIds.size() > 0) { if (teamIds != null && teamIds.size() > 0) {
...@@ -171,12 +176,25 @@ public class EngineerGanttServiceImpl implements EngineerGanttService { ...@@ -171,12 +176,25 @@ public class EngineerGanttServiceImpl implements EngineerGanttService {
engineerCodes.addAll(engineerUtils.getEngineersByLevel(levelType, levelValue).stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList())); engineerCodes.addAll(engineerUtils.getEngineersByLevel(levelType, levelValue).stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList()));
} }
engineerCodes = new ArrayList<>(new HashSet<>(engineerCodes)); engineerCodes = new ArrayList<>(new HashSet<>(engineerCodes));
if (StringUtils.isBlank(key)) { if (StringUtils.isNotBlank(key)) {
return engineerCodes;
} else {
// 最后,还需要根据key进行过滤(需要结合数据库表) // 最后,还需要根据key进行过滤(需要结合数据库表)
return engineerUtils.filterEngineersByKey(engineerCodes, key).stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList()); engineerCodes = engineerUtils.filterEngineersByKey(engineerCodes, key).stream().map(EngineerInfoEntity::getEngineerCode).collect(Collectors.toList());
}
if (CollectionUtils.isNotEmpty(orderIds)) {
List<OrderInfoEntity> infoEntities = orderInfoDao.findAllByOrderIdIn(orderIds);
Set<String> skillGroupCodes = Sets.newConcurrentHashSet();
for (OrderInfoEntity orderInfo : infoEntities) {
//查询对应的技能信息
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(orderInfo.getBrand(), orderInfo.getType(), orderInfo.getSkill());
if (Objects.isNull(skill)) {
throw new BusinessException("查询不到对应的技能组信息:" + String.join(",", orderInfo.getType(), orderInfo.getSkill()));
}
skillGroupCodes.add(skill.getSkillGroupCode());
}
engineerCodes = engineerInfoDao.findByEngineerCodesBySkillCodes(engineerCodes, skillGroupCodes);
} }
return engineerCodes;
} }
private List<LabelValueDTO> getOnwayTips(OrderInfoEntity order) { private List<LabelValueDTO> getOnwayTips(OrderInfoEntity order) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!