Commit bfade5c7 by huangjinxin

fix:分单接口添加派单到工程师接口

fix:团队/工程师交通方式重构
1 parent 7410c7b5
package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.MapBlockInfoEntity;
import org.apache.ibatis.annotations.Param;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -10,15 +12,20 @@ import java.util.List;
@Repository
public interface MapBlockInfoDao extends JpaRepository<MapBlockInfoEntity, Integer>, JpaSpecificationExecutor<MapBlockInfoEntity> {
List<MapBlockInfoEntity> findByBlockIdInAndLayerIdIn(List<String> blockIds, List<String> layerIds);
List<MapBlockInfoEntity> findByBlockIdInAndLayerIdIn(List<String> blockIds, List<String> layerIds);
MapBlockInfoEntity findByBlockId(String blockId);
MapBlockInfoEntity findByBlockId(String blockId);
List<MapBlockInfoEntity> findByGroupId(String groupId);
List<MapBlockInfoEntity> findByGroupId(String groupId);
List<MapBlockInfoEntity> findByLayerId(String layerId);
List<MapBlockInfoEntity> findByLayerId(String layerId);
MapBlockInfoEntity findByTeamIdAndLayerId(String teamId, String layerId);
MapBlockInfoEntity findByTeamIdAndLayerId(String teamId, String layerId);
List<MapBlockInfoEntity> findByBlockIdIn(List<String> blockIds);
List<MapBlockInfoEntity> findByBlockIdIn(List<String> blockIds);
@Query(value = "select mbi.* from map_block_info mbi left join skill_info si on mbi.layer_id = si.layer_id left join map_layer_customize mlc on mlc.layer_id = mbi.layer_id " +
"where si.brand = :brand and si.`type` = :productType and si.skill = :skill and mbi.block_id in ( :blockIds ) order by mlc.priority ", nativeQuery = true)
List<MapBlockInfoEntity> listTeamIdByBrandAndSkillAndBlockIds(@Param("brand") String brand, @Param("productType") String productType,
@Param("skill") String skill, @Param("blockIds") List<String> blockIds);
}
......@@ -49,8 +49,8 @@ public class EngineerBusinessEntity implements Serializable {
@Column(name = "y", nullable = false, length = 20)
private String Y;
@Column(name = "vehicle", nullable = false, length = 10, columnDefinition = "varchar(10) default 'electric'")
private String vehicle;
@Column(name = "vehicle", nullable = false, length = 10, columnDefinition = "varchar(10) default '1'")
private String vehicle = "1";
@Column(name = "vehicle_no", nullable = false, length = 10, columnDefinition = "varchar(10) default ''")
private String vehicleNo;
......
......@@ -58,8 +58,8 @@ public class OrgTeamEntity {
@Column(name = "work_duration", nullable = false, columnDefinition = "int default 600")
private Integer workDuration = 600;
@Column(name = "transport_mode", columnDefinition = "varchar(10) default '电动车'")
private String transportMode = "电动车";
@Column(name = "transport_mode", columnDefinition = "varchar(10) default '1'")
private String transportMode = "1";
@Column(name = "strategy_schedule", columnDefinition = "varchar(10) default '营销优先'")
private String strategySchedule = "营销优先";
......
......@@ -36,6 +36,8 @@ public class FendanServiceImpl implements FendanService {
@Autowired
private OrgTeamEngineerDao orgTeamEngineerDao;
private static String allLayerId = "ALL";
@Override
public Result<List<OrgTeamInfo>> fendan(OrderDTO.OrderCreateRequest request) {
List<OrgTeamInfo> orgTeamInfos = new ArrayList<>();
......@@ -129,6 +131,12 @@ public class FendanServiceImpl implements FendanService {
return Result.success(orgTeamInfos);
}
/**
* 派工到工作队
*
* @param request
* @return
*/
@Override
public Result<List<OrgGroupInfo>> fendanToGroup(OrderDTO.OrderCreateRequest request) {
List<OrgGroupInfo> orgGroupTeamInfos = new ArrayList<>();
......@@ -140,21 +148,53 @@ public class FendanServiceImpl implements FendanService {
return Result.failed(StatusCodeEnum.FENDAN_AREA_UNMATCHED);
}
//2:匹配工作队
//2:根据服务范围匹配工作队
String peaBrand = fixBrand(request.getBrand());
List<String> blockIds = blockInfos.stream().map(SaasUtils.BlockInfo::getBlockId).distinct().collect(Collectors.toList());
List<MapBlockInfoEntity> mapBlockInfoEntities = mapBlockInfoDao.findByBlockIdIn(blockIds);
if (CollectionUtils.isEmpty(mapBlockInfoEntities)) {
//区划所在范围并分配到具体技能的工作队
List<MapBlockInfoEntity> mapBlockInfoList = mapBlockInfoDao.listTeamIdByBrandAndSkillAndBlockIds(peaBrand, request.getProductType(), request.getServiceType(), blockIds);
//区划所在范围所有工作队
List<MapBlockInfoEntity> mapBlockInBlockIdsList = mapBlockInfoDao.findByBlockIdIn(blockIds);
if (CollectionUtils.isEmpty(mapBlockInfoList) && CollectionUtils.isEmpty(mapBlockInBlockIdsList)) {
return Result.failed(StatusCodeEnum.FENDAN_TEAM_UNMATCHED);
}
//3:匹配分部
List<String> teamIdList = mapBlockInfoEntities.stream().map(MapBlockInfoEntity::getTeamId).distinct().collect(Collectors.toList());
List<Integer> mapBlockIdList = mapBlockInfoList.stream().map(MapBlockInfoEntity::getId).distinct().collect(Collectors.toList());
//筛选漏选工作队(处理全技能图层)
for (MapBlockInfoEntity mapBlockInfoEntity : mapBlockInBlockIdsList) {
if (mapBlockIdList.contains(mapBlockInfoEntity.getId())) {
continue;
}
if (mapBlockInfoEntity.getLayerId().equals(allLayerId)) {
mapBlockInfoList.add(mapBlockInfoEntity);
}
}
//3:按照派工顺序组装工作队数据
List<String> teamIdList = mapBlockInfoList.stream().map(MapBlockInfoEntity::getTeamId).distinct().collect(Collectors.toList());
List<OrgTeamEntity> teamList = orgTeamDao.findByTeamIdIn(teamIdList);
Map<String, OrgTeamEntity> teamMap = teamList.stream().collect(Collectors.toMap(OrgTeamEntity::getTeamId, e -> e));
List<OrgGroupEntity> orgGroupList = orgGroupDao.findByTeamIdIn(teamIdList);
for (OrgGroupEntity orgGroupEntity : orgGroupList) {
OrgGroupInfo orgGroup = BeanUtil.copyProperties(orgGroupEntity, OrgGroupInfo.class);
List<OrgTeamInfo> orgTeamInfoList = teamList.stream().filter(e -> e.getGroupId().equals(orgGroup.getGroupId())).map(e -> BeanUtil.copyProperties(e, OrgTeamInfo.class)).collect(Collectors.toList());
orgGroup.setTeamInfos(orgTeamInfoList);
MapBlockInfoEntity allLayer = null;
for (int i = 0; i < mapBlockInfoList.size(); i++) {
if (!mapBlockInfoList.get(i).getGroupId().equals(orgGroupEntity.getGroupId())) {
continue;
}
OrgTeamEntity orgTeamEntity = teamMap.get(mapBlockInfoList.get(i).getTeamId());
//全技能数据放在最后
if (mapBlockInfoList.get(i).getLayerId().equals(allLayerId)) {
allLayer = mapBlockInfoList.get(i);
} else {
OrgTeamInfo orgTeamInfo = BeanUtil.copyProperties(orgTeamEntity, OrgTeamInfo.class);
orgGroup.setTeamInfos(Arrays.asList(orgTeamInfo));
}
//最后处理全技能数据
if (i == mapBlockInfoList.size() - 1 && null != allLayer) {
OrgTeamInfo orgTeamInfoAll = BeanUtil.copyProperties(orgTeamEntity, OrgTeamInfo.class);
orgGroup.setTeamInfos(Arrays.asList(orgTeamInfoAll));
allLayer = null;
}
}
orgGroupTeamInfos.add(orgGroup);
}
return Result.success(orgGroupTeamInfos);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!