|
|
@@ -153,7 +153,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
private RemoteUserService remoteUserService;
|
|
|
- @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 10000)
|
|
|
private RemoteFleetService remoteFleetService;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private TradeOrderInfoService tradeOrderInfoService;
|
|
|
@@ -4553,6 +4553,9 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //计算司机分值
|
|
|
+ calculateAutoDispatchScore(billOrder, status);
|
|
|
+
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
|
// 驳回的订单可以通过完善单证变成已完成
|
|
|
@@ -4593,8 +4596,6 @@ public class KwtWaybillOrderV1Service {
|
|
|
return Boolean.TRUE;
|
|
|
}
|
|
|
noticeTraderOrder(status, subtask,kwtLogistics);
|
|
|
- //计算司机分值
|
|
|
- calculateAutoDispatchScore(billOrder, status);
|
|
|
|
|
|
return Boolean.FALSE;
|
|
|
}
|
|
|
@@ -4631,47 +4632,39 @@ public class KwtWaybillOrderV1Service {
|
|
|
* @param billOrder
|
|
|
*/
|
|
|
protected void calculateAutoDispatchScore(KwtWaybillOrder billOrder, Integer status) {
|
|
|
-// if (true) {
|
|
|
-// //先不执行自动派单逻辑
|
|
|
-// return;
|
|
|
-// }
|
|
|
- //查询物流订单
|
|
|
- KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderRepository.queryByLogisticsOrderId(billOrder.getLOrderId());
|
|
|
-
|
|
|
- //查询运单装卸货地址
|
|
|
- List<KwtWaybillOrderAddress> addressList = waybillOrderAddressRepository.queryByWOrderId(billOrder.getId());
|
|
|
- if (CollectionUtils.isEmpty(addressList)) {
|
|
|
- log.info("物流运单无装卸货地址信息,运单id:{}", billOrder.getId());
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_ADDRESS, "物流订单无装卸货地址信息");
|
|
|
- }
|
|
|
- Map<Integer, KwtWaybillOrderAddress> addressMap = addressList.stream()
|
|
|
- .filter(addr -> addr.getAddressType() != null)
|
|
|
- .collect(Collectors.toMap(KwtWaybillOrderAddress::getAddressType, Function.identity(),
|
|
|
- (x,y) ->x));
|
|
|
-
|
|
|
- // 获取司机行为规则配置(司机违规取消运单分钟数)
|
|
|
- DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(billOrder.getEntId());
|
|
|
- if (driverRulesVO == null) {
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "未找到司机行为规则数据!");
|
|
|
- }
|
|
|
+ try {
|
|
|
+ if (!DispatchWayEnums.AUTO_DISPATCH.getCode().equals(billOrder.getDispatchWay())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Long supEntId = getSupplierId(billOrder);
|
|
|
+ //查询物流订单
|
|
|
+ KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderRepository.queryByLogisticsOrderId(billOrder.getLOrderId());
|
|
|
+ // 获取司机行为规则配置(司机违规取消运单分钟数)
|
|
|
+ DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(supEntId);
|
|
|
+ if (driverRulesVO == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "未找到司机行为规则数据!");
|
|
|
+ }
|
|
|
|
|
|
+ //1. 运单单据错误被驳回
|
|
|
+ checkRefuseScore(billOrder, status, driverRulesVO);
|
|
|
|
|
|
- //1. 运单单据错误被驳回
|
|
|
- checkRefuseScore(billOrder, status, driverRulesVO);
|
|
|
+ //运单没通过,不执行以下逻辑
|
|
|
+ if (!Objects.equals(status, CarWaybillV1Enum.COMPLETED.getCode())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- //运单没通过,不执行以下逻辑
|
|
|
- if (!Objects.equals(status, CarWaybillV1Enum.COMPLETED.getCode())) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ //2. 校验司机运单完成是否超时
|
|
|
+ checkCompletionTimeout(billOrder, logisticsOrder, driverRulesVO);
|
|
|
|
|
|
- //2. 校验司机运单完成是否超时
|
|
|
- checkCompletionTimeout(billOrder, logisticsOrder, driverRulesVO);
|
|
|
+ //3. 校验司机连续准时卸货(审核通过)
|
|
|
+ checkContinuousUnload(billOrder, logisticsOrder, supEntId);
|
|
|
|
|
|
- //3. 校验司机连续准时卸货(审核通过)
|
|
|
- checkContinuousUnload(billOrder, logisticsOrder);
|
|
|
+ //4. 校验司机连续准确填写卸货信息(审核通过)
|
|
|
+ checkContinuousPass(billOrder, supEntId);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("司机分数计算失败!", e);
|
|
|
+ }
|
|
|
|
|
|
- //4. 校验司机连续准确填写卸货信息(审核通过)
|
|
|
- checkContinuousPass(billOrder, addressMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -4693,11 +4686,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
|
|
|
//1、更新司机分数(减分)
|
|
|
documentErrorScore = -Math.abs(documentErrorScore);
|
|
|
- Long supEntId = getSupplierId(waybillOrder);
|
|
|
- updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), documentErrorScore, "单据错误/缺失");
|
|
|
+ updateDriverScore(driverRulesVO.getEntId(), waybillOrder.getEntId(), waybillOrder.getDriverId(), documentErrorScore, "单据错误/缺失");
|
|
|
|
|
|
//2、更新企业分数(减分)
|
|
|
- updateLogEntScore(waybillOrder, supEntId, documentErrorScore, "单据错误/缺失");
|
|
|
+ updateLogEntScore(waybillOrder, driverRulesVO.getEntId(), documentErrorScore, "单据错误/缺失");
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -4721,11 +4713,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
if (isTimeOut) {
|
|
|
//1、更新司机分数(减分)
|
|
|
timeoutScore = -Math.abs(timeoutScore);
|
|
|
- Long supEntId = getSupplierId(waybillOrder);
|
|
|
- updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), timeoutScore, "卸货严重超时");
|
|
|
+ updateDriverScore(driverRulesVO.getEntId(), waybillOrder.getEntId(), waybillOrder.getDriverId(), timeoutScore, "卸货严重超时");
|
|
|
|
|
|
//2、更新企业分数(减分)
|
|
|
- updateLogEntScore(waybillOrder, supEntId, timeoutScore, "卸货严重超时");
|
|
|
+ updateLogEntScore(waybillOrder, driverRulesVO.getEntId(), timeoutScore, "卸货严重超时");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -4823,9 +4814,9 @@ public class KwtWaybillOrderV1Service {
|
|
|
* 校验司机连续准时卸货
|
|
|
* @param waybillOrder
|
|
|
*/
|
|
|
- private void checkContinuousUnload(KwtWaybillOrder waybillOrder, KwtLogisticsOrder logisticsOrder) {
|
|
|
+ private void checkContinuousUnload(KwtWaybillOrder waybillOrder, KwtLogisticsOrder logisticsOrder, Long supEntId) {
|
|
|
// 获取司机行为规则配置(连续准时卸货次数)
|
|
|
- DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(waybillOrder.getEntId());
|
|
|
+ DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(supEntId);
|
|
|
if (driverRulesVO == null) {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "未找到司机行为规则数据!");
|
|
|
}
|
|
|
@@ -4834,58 +4825,51 @@ public class KwtWaybillOrderV1Service {
|
|
|
//连续卸货加分分数
|
|
|
Integer continuousScore = driverRulesVO.getContinuousOnTimeUnloadScore();
|
|
|
if (continuousOnTimes <= 0 || continuousScore <= 0) {
|
|
|
- log.warn("【连续准时卸货】获取连续准时卸货数据失败:企业{}的连续按时到场次数/分数配置异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
+ log.warn("【连续准时卸货】获取连续准时卸货数据失败:企业{}的连续按时到场次数/分数配置异常,运单ID:{}", supEntId, waybillOrder.getId());
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "【连续准时卸货】配置的次数/分数需大于0!");
|
|
|
}
|
|
|
|
|
|
//查询该司机连续审核通过节点数据
|
|
|
- List<KwtWaybillOrderNode> waybillOrderNodeList = getWaybillOrderNodesByStatus(waybillOrder, continuousOnTimes, CarWaybillV1Enum.COMPLETED);
|
|
|
- if (waybillOrderNodeList == null) {
|
|
|
+ List<KwtWaybillOrderNode> waybillOrderNodeList = getWaybillOrderNodesByStatus(waybillOrder, continuousOnTimes);
|
|
|
+ if (waybillOrderNodeList.size() != continuousOnTimes) {
|
|
|
+ log.info("司机{}最近连续准时卸货记录不足{}条,当前:{}", waybillOrder.getDriverId(), continuousOnTimes, waybillOrderNodeList.size());
|
|
|
return;
|
|
|
}
|
|
|
//记录连续审核通过次数
|
|
|
- int continuousCount = 0;
|
|
|
- List<Long> qualifiedNodeIds = new ArrayList<>();
|
|
|
List<Long> nodeIds = new ArrayList<>();
|
|
|
+ boolean allOnTime = true;
|
|
|
for (KwtWaybillOrderNode orderNode : waybillOrderNodeList) {
|
|
|
+ if (orderNode.getContinuous() == 1) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //计算每次运单是否准时卸货
|
|
|
KwtWaybillOrder wOrder = kwtWaybillOrderRepository.queryByBillOrderId(orderNode.getWOrderId());
|
|
|
- Boolean timeOut = isTimeOut(wOrder, logisticsOrder, BigDecimal.ZERO);
|
|
|
- if (timeOut) {
|
|
|
+ if (isTimeOut(wOrder, logisticsOrder, BigDecimal.ZERO)) {
|
|
|
log.info("司机{}存在超时情况,运单id:{}", orderNode.getDriverId(), orderNode.getWOrderId());
|
|
|
- return;
|
|
|
- }
|
|
|
- continuousCount++;
|
|
|
- qualifiedNodeIds.add(orderNode.getId());
|
|
|
- // 达到10次,返回最新的10条ID
|
|
|
- if (continuousCount >= continuousOnTimes) {
|
|
|
- // 截断前10条
|
|
|
- nodeIds = qualifiedNodeIds.subList(0, continuousOnTimes);
|
|
|
+ allOnTime = false;
|
|
|
break;
|
|
|
}
|
|
|
+ nodeIds.add(orderNode.getId());
|
|
|
}
|
|
|
- // 校验是否达到次数
|
|
|
- if (continuousCount < continuousOnTimes) {
|
|
|
- log.info("司机{}连续卸货完成次数{},未达到配置阈值{}", waybillOrder.getDriverId(), continuousCount, continuousOnTimes);
|
|
|
- return;
|
|
|
- }
|
|
|
- //1. 给连续的10次节点数据打标
|
|
|
- updateNode(waybillOrder, nodeIds, continuousScore);
|
|
|
+ if (allOnTime && nodeIds.size() == continuousOnTimes) {
|
|
|
+ //1. 给连续的10次节点数据打标
|
|
|
+ updateNode(waybillOrder, nodeIds, continuousScore);
|
|
|
|
|
|
- //2 .更新司机分数(加分)
|
|
|
- Long supEntId = getSupplierId(waybillOrder);
|
|
|
- updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), continuousScore, "连续准时卸货");
|
|
|
+ //2 .更新司机分数(加分)
|
|
|
+ updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), continuousScore, "连续准时卸货");
|
|
|
|
|
|
- //3. 更新企业分数(加分)
|
|
|
- updateLogEntScore(waybillOrder, supEntId, continuousScore, "连续准时卸货");
|
|
|
+ //3. 更新企业分数(加分)
|
|
|
+ updateLogEntScore(waybillOrder, supEntId, continuousScore, "连续准时卸货");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 校验司机连续准确填写卸货信息
|
|
|
* @param waybillOrder
|
|
|
*/
|
|
|
- private void checkContinuousPass(KwtWaybillOrder waybillOrder, Map<Integer, KwtWaybillOrderAddress> addressMap) {
|
|
|
+ private void checkContinuousPass(KwtWaybillOrder waybillOrder, Long supEntId) {
|
|
|
// 获取司机行为规则配置(连续准确填写卸货信息次数)
|
|
|
- DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(waybillOrder.getEntId());
|
|
|
+ DriverConductRulesVO driverRulesVO = remoteFleetService.findDriverConductRulesByEntId(supEntId);
|
|
|
if (driverRulesVO == null) {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "未找到司机行为规则数据!");
|
|
|
}
|
|
|
@@ -4894,43 +4878,41 @@ public class KwtWaybillOrderV1Service {
|
|
|
//连续卸货加分分数
|
|
|
Integer continuousScore = driverRulesVO.getContinuousAccurateUnloadScore();
|
|
|
if (continuousUnloadTimes <= 0 || continuousScore <= 0) {
|
|
|
- log.warn("【连续准确填写卸货信息】企业{}的连续准确填写卸货信息配置的次数/分数异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
+ log.warn("【连续准确填写卸货信息】企业{}的连续准确填写卸货信息配置的次数/分数异常,运单ID:{}", supEntId, waybillOrder.getId());
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "【连续准确填写卸货信息】配置的次数/分数需大于0!");
|
|
|
}
|
|
|
|
|
|
//查询该司机连续审核通过节点数据
|
|
|
- List<KwtWaybillOrderNode> waybillOrderNodeList = getWaybillOrderNodesByStatus(waybillOrder, continuousUnloadTimes, CarWaybillV1Enum.COMPLETED);
|
|
|
+ List<KwtWaybillOrderNode> waybillOrderNodeList = getWaybillOrderNodesByStatus(waybillOrder, continuousUnloadTimes);
|
|
|
if (waybillOrderNodeList == null) {
|
|
|
return;
|
|
|
}
|
|
|
//记录连续审核通过次数
|
|
|
- int continuousCount = 0;
|
|
|
- List<Long> qualifiedNodeIds = new ArrayList<>();
|
|
|
List<Long> nodeIds = new ArrayList<>();
|
|
|
+ boolean allOnTime = true;
|
|
|
for (KwtWaybillOrderNode orderNode : waybillOrderNodeList) {
|
|
|
- continuousCount++;
|
|
|
- qualifiedNodeIds.add(orderNode.getId());
|
|
|
- // 达到10次,返回最新的10条ID
|
|
|
- if (continuousCount >= continuousUnloadTimes) {
|
|
|
- // 截断前10条
|
|
|
- nodeIds = qualifiedNodeIds.subList(0, continuousUnloadTimes);
|
|
|
+ if (orderNode.getIsBonus() == 2) {
|
|
|
break;
|
|
|
}
|
|
|
+ //计算每次运单是否连续审核通过
|
|
|
+ KwtWaybillOrderNode wOrderNode = kwtWaybillOrderNodeRepository.queryNodesByOrderId(orderNode.getWOrderId(), CarWaybillV1Enum.REVIEW_REJECTION.getCode());
|
|
|
+ if (wOrderNode != null) {
|
|
|
+ log.info("司机{}存在审核驳回的情况,运单id:{}", orderNode.getDriverId(), orderNode.getWOrderId());
|
|
|
+ allOnTime = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ nodeIds.add(orderNode.getId());
|
|
|
}
|
|
|
- // 校验是否达到次数
|
|
|
- if (continuousCount < continuousUnloadTimes) {
|
|
|
- log.info("司机{}连续准确填写卸货信息次数{},未达到配置阈值{}", waybillOrder.getDriverId(), continuousCount, continuousUnloadTimes);
|
|
|
- return;
|
|
|
- }
|
|
|
- //1. 给连续的10次节点数据打标
|
|
|
- updateNode(waybillOrder, nodeIds, continuousScore);
|
|
|
+ if (allOnTime && nodeIds.size() == continuousUnloadTimes) {
|
|
|
+ //1. 给连续的10次节点数据打标
|
|
|
+ updateReviewNode(waybillOrder, nodeIds, continuousScore);
|
|
|
|
|
|
- //2 .更新司机分数(加分)
|
|
|
- Long supEntId = getSupplierId(waybillOrder);
|
|
|
- updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), continuousScore, "连续准确填写卸货信息");
|
|
|
+ //2 .更新司机分数(加分)
|
|
|
+ updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), continuousScore, "连续准确填写卸货信息");
|
|
|
|
|
|
- //3. 更新企业分数(加分)
|
|
|
- updateLogEntScore(waybillOrder, supEntId, continuousScore, "连续准确填写卸货信息");
|
|
|
+ //3. 更新企业分数(加分)
|
|
|
+ updateLogEntScore(waybillOrder, supEntId, continuousScore, "连续准确填写卸货信息");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -4939,7 +4921,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
* @param continuousOnTimes
|
|
|
* @return
|
|
|
*/
|
|
|
- protected List<KwtWaybillOrderNode> getWaybillOrderNodesByStatus(KwtWaybillOrder waybillOrder, Integer continuousOnTimes, CarWaybillV1Enum waybillV1Enum) {
|
|
|
+ protected List<KwtWaybillOrderNode> getWaybillOrderNodesByStatus(KwtWaybillOrder waybillOrder, Integer continuousOnTimes) {
|
|
|
//司机运单数据
|
|
|
List<KwtWaybillOrder> waybillOrders = kwtWaybillOrderRepository.queryByEntId(waybillOrder.getEntId(), waybillOrder.getDriverId());
|
|
|
if (CollectionUtils.isEmpty(waybillOrders)) {
|
|
|
@@ -4948,12 +4930,16 @@ public class KwtWaybillOrderV1Service {
|
|
|
List<Long> wOrderIds = waybillOrders.stream().map(KwtWaybillOrder::getId).collect(Collectors.toList());
|
|
|
//查询司机的节点数据
|
|
|
List<KwtWaybillOrderNode> waybillOrderNodeList = kwtWaybillOrderNodeRepository
|
|
|
- .queryContinuousNodesByDriverId(wOrderIds, waybillOrder.getDriverId(), waybillV1Enum.getCode());
|
|
|
+ .queryContinuousNodesByDriverId(wOrderIds, waybillOrder.getDriverId(), CarWaybillV1Enum.COMPLETED.getCode());
|
|
|
if (CollectionUtils.isEmpty(waybillOrderNodeList) || waybillOrderNodeList.size() < continuousOnTimes) {
|
|
|
log.info("司机{}按时接节点不足{}次,当前记录数:{}", waybillOrder.getDriverId(), continuousOnTimes, waybillOrderNodeList.size());
|
|
|
return null;
|
|
|
}
|
|
|
- return waybillOrderNodeList;
|
|
|
+
|
|
|
+ //取continuousOnTimes条节点数据
|
|
|
+ return waybillOrderNodeList.stream().sorted(Comparator.comparing(KwtWaybillOrderNode::getCreateTime).reversed())
|
|
|
+ .limit(continuousOnTimes)
|
|
|
+ .collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -4968,6 +4954,18 @@ public class KwtWaybillOrderV1Service {
|
|
|
log.info("司机{}连续执行运单节点,加分:{},节点ID:{}", waybillOrder.getDriverId(), continuousOnTimeScore, JSON.toJSONString(nodeIds));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 给连续的10次的节点数据打标
|
|
|
+ */
|
|
|
+ protected void updateReviewNode(KwtWaybillOrder waybillOrder, List<Long> nodeIds, Integer continuousOnTimeScore) {
|
|
|
+ KwtWaybillOrderNode updateEntity = new KwtWaybillOrderNode();
|
|
|
+ updateEntity.setIsBonus(2);
|
|
|
+ LambdaQueryWrapper<KwtWaybillOrderNode> updateWrapper = new LambdaQueryWrapper<KwtWaybillOrderNode>()
|
|
|
+ .in(KwtWaybillOrderNode::getId, nodeIds);
|
|
|
+ kwtWaybillOrderNodeRepository.update(updateEntity, updateWrapper);
|
|
|
+ log.info("司机{}连续执行运单节点,加分:{},节点ID:{}", waybillOrder.getDriverId(), continuousOnTimeScore, JSON.toJSONString(nodeIds));
|
|
|
+ }
|
|
|
+
|
|
|
// 查询供应商id
|
|
|
protected Long getSupplierId(KwtWaybillOrder waybillOrder) {
|
|
|
if (waybillOrder == null) {
|
|
|
@@ -5008,7 +5006,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
LogisticsScoreDetailFeignDto detailDto = new LogisticsScoreDetailFeignDto();
|
|
|
detailDto.setProviderEntId(supplierId);
|
|
|
detailDto.setLogisticsEntId(waybillOrder.getEntId());
|
|
|
- detailDto.setInfluenceBy(waybillOrder.getDriverId());
|
|
|
+ detailDto.setPhone(waybillOrder.getDriverPhone());
|
|
|
detailDto.setAction(remark);
|
|
|
detailDto.setScoreChange(BigDecimal.valueOf(score));
|
|
|
logisticsScoreFeignService.updateLogisticsScore(detailDto);
|