Commit 8b6c9fbb by 刘鑫

fix(容量): 查询不到对应技能组时对外接口直接抛异常, 内部返回不可约状态

1 parent 65ffbb1c
...@@ -36,20 +36,20 @@ public class CapacityQueryDTO { ...@@ -36,20 +36,20 @@ public class CapacityQueryDTO {
* 地址坐标信息 * 地址坐标信息
*/ */
@Valid @Valid
@NotNull @NotNull(message = "地址坐标信息不能为空")
private Location location; private Location location;
/** /**
* 查询起始日期 * 查询起始日期
*/ */
@NotNull @NotNull(message = " 查询起始日期不能为空, 格式:yyyy-MM-dd ")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date beginDate; private Date beginDate;
/** /**
* 查询结束日期 * 查询结束日期
*/ */
@NotNull @NotNull(message = " 查询结束日期不能为空, 格式:yyyy-MM-dd ")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date endDate; private Date endDate;
...@@ -138,7 +138,7 @@ public class CapacityQueryDTO { ...@@ -138,7 +138,7 @@ public class CapacityQueryDTO {
private long maxDuration; private long maxDuration;
/** /**
* 容量名称 全天/上午/下午/时间段 * 容量名称 全天/上午/下午/晚上/时间段
*/ */
private String name; private String name;
...@@ -177,18 +177,18 @@ public class CapacityQueryDTO { ...@@ -177,18 +177,18 @@ public class CapacityQueryDTO {
/** /**
* 品牌 (CODE) * 品牌 (CODE)
*/ */
@NotBlank @NotBlank(message = "品牌(code)不能为空")
private String brand; private String brand;
/** /**
* 产品类型 (CODE) * 产品类型 (CODE)
*/ */
@NotBlank @NotBlank(message = "产品类型(code)不能为空")
private String productType; private String productType;
/** /**
* 需要的技能 (CODE) * 需要的技能 (CODE)
*/ */
@NotBlank @NotBlank(message = "技能(code)不能为空")
private String serviceType; private String serviceType;
} }
} }
package com.dituhui.pea.order.service.impl; package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.CapacityUtils; import com.dituhui.pea.order.common.CapacityUtils;
...@@ -135,6 +136,10 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -135,6 +136,10 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
allFulfillEngineer.addAll(engineerInfoEntities); allFulfillEngineer.addAll(engineerInfoEntities);
} }
log.info("[matchCapacityData]【符合技能要求的工程师总数为:{} 个】", allFulfillEngineer.size()); log.info("[matchCapacityData]【符合技能要求的工程师总数为:{} 个】", allFulfillEngineer.size());
if (CollectionUtils.isEmpty(querySkillGroup)) {
throw new BusinessException("查询不到对应的技能组信息");
}
//计算所有查询技能的所需耗时 (querySkillGroup) //计算所有查询技能的所需耗时 (querySkillGroup)
final int totalTakeTime = querySkillGroup.stream() final int totalTakeTime = querySkillGroup.stream()
.mapToInt(SkillInfoEntity::getTakeTime) .mapToInt(SkillInfoEntity::getTakeTime)
...@@ -194,6 +199,14 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -194,6 +199,14 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
//查询对应的技能信息 //查询对应的技能信息
SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(service.getBrand(), SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(service.getBrand(),
service.getProductType(), service.getServiceType()); service.getProductType(), service.getServiceType());
// 查询不到技能组 直接返不可用
if (Objects.isNull(skillInfo)) {
CapacityQueryDTO.Segment segment = new CapacityQueryDTO.Segment();
segment.setMaxDuration(0);
segment.setRemain(0);
segment.setStatus(0);
return segment;
}
List<CapacityEngineerSliceUsedEntity> allEngineerTimeSlice = new CopyOnWriteArrayList<>(); List<CapacityEngineerSliceUsedEntity> allEngineerTimeSlice = new CopyOnWriteArrayList<>();
for (EngineerInfoEntity engineerInfo : engineerInfoEntities) { for (EngineerInfoEntity engineerInfo : engineerInfoEntities) {
...@@ -236,7 +249,14 @@ public class CapacityQueryServiceImpl implements CapacityQueryService { ...@@ -236,7 +249,14 @@ public class CapacityQueryServiceImpl implements CapacityQueryService {
//查询对应的技能信息 //查询对应的技能信息
SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(service.getBrand(), SkillInfoEntity skillInfo = skillInfoDao.getByBrandAndTypeAndSkill(service.getBrand(),
service.getProductType(), service.getServiceType()); service.getProductType(), service.getServiceType());
// 查询不到技能组 直接返不可用
if (Objects.isNull(skillInfo)) {
CapacityQueryDTO.Segment segment = new CapacityQueryDTO.Segment();
segment.setMaxDuration(0);
segment.setRemain(0);
segment.setStatus(0);
return segment;
}
return CapacityUtils.caculateTargetTimeSlice(skillInfo.getTakeTime(), "时间段", return CapacityUtils.caculateTargetTimeSlice(skillInfo.getTakeTime(), "时间段",
new CopyOnWriteArrayList<>(engineerTimeSlice), startTime, endTime, date); new CopyOnWriteArrayList<>(engineerTimeSlice), startTime, endTime, date);
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!