Commit c4adf19c by 刘鑫

Merge remote-tracking branch 'origin/develop' into develop-16542

2 parents 9e4da8a7 1de26b2e
package com.dituhui.pea.order.dao; package com.dituhui.pea.order.dao;
import com.dituhui.pea.order.entity.MapBlockInfoEntity; 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.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
...@@ -10,15 +12,20 @@ import java.util.List; ...@@ -10,15 +12,20 @@ import java.util.List;
@Repository @Repository
public interface MapBlockInfoDao extends JpaRepository<MapBlockInfoEntity, Integer>, JpaSpecificationExecutor<MapBlockInfoEntity> { 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);
} }
...@@ -25,6 +25,12 @@ public class ScheduleOverviewResp { ...@@ -25,6 +25,12 @@ public class ScheduleOverviewResp {
private String distanceDesc; private String distanceDesc;
private OrderSum order; private OrderSum order;
private List<Item> children; private List<Item> children;
private String clusterId;
private String branchId;
private String groupId;
} }
@Data @Data
......
...@@ -49,8 +49,8 @@ public class EngineerBusinessEntity implements Serializable { ...@@ -49,8 +49,8 @@ public class EngineerBusinessEntity implements Serializable {
@Column(name = "y", nullable = false, length = 20) @Column(name = "y", nullable = false, length = 20)
private String Y; private String Y;
@Column(name = "vehicle", nullable = false, length = 10, columnDefinition = "varchar(10) default 'electric'") @Column(name = "vehicle", nullable = false, length = 10, columnDefinition = "varchar(10) default '1'")
private String vehicle; private String vehicle = "1";
@Column(name = "vehicle_no", nullable = false, length = 10, columnDefinition = "varchar(10) default ''") @Column(name = "vehicle_no", nullable = false, length = 10, columnDefinition = "varchar(10) default ''")
private String vehicleNo; private String vehicleNo;
......
...@@ -58,8 +58,8 @@ public class OrgTeamEntity { ...@@ -58,8 +58,8 @@ public class OrgTeamEntity {
@Column(name = "work_duration", nullable = false, columnDefinition = "int default 600") @Column(name = "work_duration", nullable = false, columnDefinition = "int default 600")
private Integer workDuration = 600; private Integer workDuration = 600;
@Column(name = "transport_mode", columnDefinition = "varchar(10) default '电动车'") @Column(name = "transport_mode", columnDefinition = "varchar(10) default '1'")
private String transportMode = "电动车"; private String transportMode = "1";
@Column(name = "strategy_schedule", columnDefinition = "varchar(10) default '营销优先'") @Column(name = "strategy_schedule", columnDefinition = "varchar(10) default '营销优先'")
private String strategySchedule = "营销优先"; private String strategySchedule = "营销优先";
......
...@@ -36,6 +36,8 @@ public class FendanServiceImpl implements FendanService { ...@@ -36,6 +36,8 @@ public class FendanServiceImpl implements FendanService {
@Autowired @Autowired
private OrgTeamEngineerDao orgTeamEngineerDao; private OrgTeamEngineerDao orgTeamEngineerDao;
private static String allLayerId = "ALL";
@Override @Override
public Result<List<OrgTeamInfo>> fendan(OrderDTO.OrderCreateRequest request) { public Result<List<OrgTeamInfo>> fendan(OrderDTO.OrderCreateRequest request) {
List<OrgTeamInfo> orgTeamInfos = new ArrayList<>(); List<OrgTeamInfo> orgTeamInfos = new ArrayList<>();
...@@ -129,6 +131,12 @@ public class FendanServiceImpl implements FendanService { ...@@ -129,6 +131,12 @@ public class FendanServiceImpl implements FendanService {
return Result.success(orgTeamInfos); return Result.success(orgTeamInfos);
} }
/**
* 派工到工作队
*
* @param request
* @return
*/
@Override @Override
public Result<List<OrgGroupInfo>> fendanToGroup(OrderDTO.OrderCreateRequest request) { public Result<List<OrgGroupInfo>> fendanToGroup(OrderDTO.OrderCreateRequest request) {
List<OrgGroupInfo> orgGroupTeamInfos = new ArrayList<>(); List<OrgGroupInfo> orgGroupTeamInfos = new ArrayList<>();
...@@ -140,21 +148,53 @@ public class FendanServiceImpl implements FendanService { ...@@ -140,21 +148,53 @@ public class FendanServiceImpl implements FendanService {
return Result.failed(StatusCodeEnum.FENDAN_AREA_UNMATCHED); 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<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); return Result.failed(StatusCodeEnum.FENDAN_TEAM_UNMATCHED);
} }
List<Integer> mapBlockIdList = mapBlockInfoList.stream().map(MapBlockInfoEntity::getId).distinct().collect(Collectors.toList());
//3:匹配分部 //筛选漏选工作队(处理全技能图层)
List<String> teamIdList = mapBlockInfoEntities.stream().map(MapBlockInfoEntity::getTeamId).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); 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); List<OrgGroupEntity> orgGroupList = orgGroupDao.findByTeamIdIn(teamIdList);
for (OrgGroupEntity orgGroupEntity : orgGroupList) { for (OrgGroupEntity orgGroupEntity : orgGroupList) {
OrgGroupInfo orgGroup = BeanUtil.copyProperties(orgGroupEntity, OrgGroupInfo.class); 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()); MapBlockInfoEntity allLayer = null;
orgGroup.setTeamInfos(orgTeamInfoList); 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); orgGroupTeamInfos.add(orgGroup);
} }
return Result.success(orgGroupTeamInfos); 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!