|
|
@@ -12,6 +12,8 @@ import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
|
+import com.sckw.contract.api.feign.LogisticsScoreFeignService;
|
|
|
+import com.sckw.contract.api.model.dto.req.LogisticsScoreDetailFeignDto;
|
|
|
import com.sckw.contract.api.model.vo.TradeContractUnitDto;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
@@ -33,6 +35,7 @@ import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.core.web.response.result.PageDataResult;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
|
+import com.sckw.fleet.api.model.dto.RUpdateDriverScoreDto;
|
|
|
import com.sckw.fleet.api.model.vo.*;
|
|
|
import com.sckw.mongo.model.SckwWaybillOrder;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
@@ -159,6 +162,9 @@ public class KwtWaybillOrderV1Service {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private RemoteContractService remoteContractService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ LogisticsScoreFeignService logisticsScoreFeignService;
|
|
|
+
|
|
|
/**
|
|
|
* @param params 请求参数
|
|
|
* @desc 统计
|
|
|
@@ -3750,20 +3756,19 @@ public class KwtWaybillOrderV1Service {
|
|
|
return;
|
|
|
}
|
|
|
//单据错误驳回分数
|
|
|
- Integer documentErrorMissing = driverRulesVO.getDocumentErrorMissing();
|
|
|
- if (documentErrorMissing <= 0) {
|
|
|
- log.warn("司机扣分失败:企业{}的司机单据错误/缺失分数配置需大于0,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "司机扣分失败,单据错误/缺失分数配置需大于0!");
|
|
|
+ Integer documentErrorScore = driverRulesVO.getDocumentErrorMissingScore();
|
|
|
+ if (documentErrorScore <= 0) {
|
|
|
+ log.warn("【单据错误/缺失】司机扣分失败:企业{}的司机单据错误/缺失分数配置异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "【单据错误/缺失】司机扣分失败,单据错误/缺失分数配置需大于0!");
|
|
|
}
|
|
|
|
|
|
//1、更新司机分数(减分)
|
|
|
- documentErrorMissing = -Math.abs(documentErrorMissing);
|
|
|
-
|
|
|
+ documentErrorScore = -Math.abs(documentErrorScore);
|
|
|
+ Long supEntId = getSupplierId(waybillOrder);
|
|
|
+ updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), documentErrorScore, "单据错误/缺失");
|
|
|
|
|
|
//2、更新企业分数(减分)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ updateLogEntScore(waybillOrder, supEntId, documentErrorScore, "单据错误/缺失");
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -3773,14 +3778,13 @@ public class KwtWaybillOrderV1Service {
|
|
|
*/
|
|
|
private void checkCompletionTimeout(KwtWaybillOrder waybillOrder, Map<Integer, KwtWaybillOrderAddress> addressMap,
|
|
|
DriverConductRulesVO driverRulesVO) {
|
|
|
- //单趟严重超时分数
|
|
|
+ //单趟严重超时倍数
|
|
|
BigDecimal timeoutMultiple = driverRulesVO.getUnloadSeriousTimeoutMultiple();
|
|
|
-
|
|
|
//单趟严重超时分数
|
|
|
- Integer timeoutScore = driverRulesVO.getUnloadSeriousTimeout();
|
|
|
- if (timeoutScore <= 0) {
|
|
|
- log.warn("司机扣分失败:企业{}的司机单趟严重超时分数配置需大于0,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "司机扣分失败,司机单趟严重超时分数配置需大于0!");
|
|
|
+ Integer timeoutScore = driverRulesVO.getUnloadSeriousTimeoutScore();
|
|
|
+ if (timeoutMultiple == null || timeoutMultiple.compareTo(BigDecimal.ZERO) <= 0 || timeoutScore <= 0) {
|
|
|
+ log.warn("【卸货严重超时】司机扣分失败:企业{}的司机卸货严重超时倍数/分数配置异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "【卸货严重超时】司机扣分失败,司机卸货严重超时配置倍数/分数需大于0!");
|
|
|
}
|
|
|
|
|
|
//校验司机运单完成是否超时
|
|
|
@@ -3788,9 +3792,11 @@ public class KwtWaybillOrderV1Service {
|
|
|
if (isTimeOut) {
|
|
|
//1、更新司机分数(减分)
|
|
|
timeoutScore = -Math.abs(timeoutScore);
|
|
|
-
|
|
|
+ Long supEntId = getSupplierId(waybillOrder);
|
|
|
+ updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), timeoutScore, "卸货严重超时");
|
|
|
|
|
|
//2、更新企业分数(减分)
|
|
|
+ updateLogEntScore(waybillOrder, supEntId, timeoutScore, "卸货严重超时");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -3803,7 +3809,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
log.info("校验司机运单完成是否超时:运单ID:{}", waybillOrder.getId());
|
|
|
//运单总耗时
|
|
|
Long orderTotalTimes = calOrderTotalTimes(waybillOrder);
|
|
|
- //平台配置的运单单趟总耗时
|
|
|
+ //平台配置的单趟总耗时
|
|
|
Integer singleTripTotalTimes = calSingleTripTotalTimes(waybillOrder, addressMap);
|
|
|
//计算超时阈值
|
|
|
BigDecimal threshold = timeoutMultiple.compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
@@ -3835,7 +3841,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
}
|
|
|
Date overOrderTime = overOrderNodes.getCreateTime() != null ? overOrderNodes.getCreateTime() : null;
|
|
|
//运单总耗时(分钟)
|
|
|
- Long orderTotalTimes = calculateTimeDiffMinutes(takingOrderTime, overOrderTime);
|
|
|
+ Long orderTotalTimes = DateUtils.calculateTimeDiffMinutes(takingOrderTime, overOrderTime);
|
|
|
log.info("司机完成运单总耗时:{}", orderTotalTimes);
|
|
|
return orderTotalTimes;
|
|
|
}
|
|
|
@@ -3892,31 +3898,6 @@ public class KwtWaybillOrderV1Service {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- /**
|
|
|
- * 计算两个时间的分钟差值
|
|
|
- * @param startTime 开始时间
|
|
|
- * @param endTime 结束时间
|
|
|
- * @return
|
|
|
- */
|
|
|
- private Long calculateTimeDiffMinutes(Date startTime, Date endTime) {
|
|
|
- // 校验
|
|
|
- if (startTime == null || endTime == null) {
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR,
|
|
|
- "计算时间差失败:,startTime=[" + startTime + "], endTime=[" + endTime + "]");
|
|
|
- }
|
|
|
- // 计算时间戳差值(毫秒)
|
|
|
- long diffMillis = endTime.getTime() - startTime.getTime();
|
|
|
- long diffMinutes = TimeUnit.MILLISECONDS.toMinutes(diffMillis);
|
|
|
- // 时间顺序异常提醒(结束时间早于开始时间)
|
|
|
- if (diffMinutes < 0) {
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR,
|
|
|
- "时间顺序异常,结束时间早于开始时间,startTime=[" + startTime + "], endTime=[" + endTime + "], 差值:[" + diffMinutes + "]分钟");
|
|
|
- }
|
|
|
- return diffMinutes;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 校验司机连续准时卸货
|
|
|
* @param waybillOrder
|
|
|
@@ -3930,10 +3911,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
//连续卸货次数
|
|
|
Integer continuousOnTimes = driverRulesVO.getContinuousOnTimeUnloadTimes();
|
|
|
//连续卸货加分分数
|
|
|
- Integer continuousOnTimeUnload = driverRulesVO.getContinuousOnTimeUnload();
|
|
|
- if (continuousOnTimes <= 0 || continuousOnTimeUnload <= 0) {
|
|
|
- log.warn("该司机无需加分,获取连续准时卸货数据失败:企业{}的连续按时到场配置需大于0,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "连续准时卸货次数和分数需大于0!");
|
|
|
+ Integer continuousScore = driverRulesVO.getContinuousOnTimeUnloadScore();
|
|
|
+ if (continuousOnTimes <= 0 || continuousScore <= 0) {
|
|
|
+ log.warn("【连续准时卸货】获取连续准时卸货数据失败:企业{}的连续按时到场次数/分数配置异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "【连续准时卸货】配置的次数/分数需大于0!");
|
|
|
}
|
|
|
|
|
|
//查询该司机连续审核通过节点数据
|
|
|
@@ -3967,12 +3948,14 @@ public class KwtWaybillOrderV1Service {
|
|
|
return;
|
|
|
}
|
|
|
//1. 给连续的10次节点数据打标
|
|
|
- updateNode(waybillOrder, nodeIds, continuousOnTimeUnload);
|
|
|
+ updateNode(waybillOrder, nodeIds, continuousScore);
|
|
|
|
|
|
//2 .更新司机分数(加分)
|
|
|
-
|
|
|
+ Long supEntId = getSupplierId(waybillOrder);
|
|
|
+ updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), continuousScore, "连续准时卸货");
|
|
|
|
|
|
//3. 更新企业分数(加分)
|
|
|
+ updateLogEntScore(waybillOrder, supEntId, continuousScore, "连续准时卸货");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -3986,16 +3969,16 @@ public class KwtWaybillOrderV1Service {
|
|
|
throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "未找到司机行为规则数据!");
|
|
|
}
|
|
|
//连续卸货次数
|
|
|
- Integer continuousAccurateUnloadTimes = driverRulesVO.getContinuousAccurateUnloadTimes();
|
|
|
+ Integer continuousUnloadTimes = driverRulesVO.getContinuousAccurateUnloadTimes();
|
|
|
//连续卸货加分分数
|
|
|
- Integer continuousAccurateUnload = driverRulesVO.getContinuousAccurateUnload();
|
|
|
- if (continuousAccurateUnloadTimes <= 0 || continuousAccurateUnload <= 0) {
|
|
|
- log.warn("该司机无需加分,获取连续准确填写卸货信息数据失败:企业{}的连续按时到场配置异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
- throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "连续准确填写卸货信息次数和分数不能小于等于0!");
|
|
|
+ Integer continuousScore = driverRulesVO.getContinuousAccurateUnloadScore();
|
|
|
+ if (continuousUnloadTimes <= 0 || continuousScore <= 0) {
|
|
|
+ log.warn("【连续准确填写卸货信息】企业{}的连续准确填写卸货信息配置的次数/分数异常,运单ID:{}", waybillOrder.getEntId(), waybillOrder.getId());
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "【连续准确填写卸货信息】配置的次数/分数需大于0!");
|
|
|
}
|
|
|
|
|
|
//查询该司机连续审核通过节点数据
|
|
|
- List<KwtWaybillOrderNode> waybillOrderNodeList = getWaybillOrderNodesByStatus(waybillOrder, continuousAccurateUnloadTimes, CarWaybillV1Enum.WAIT_UNLOADING);
|
|
|
+ List<KwtWaybillOrderNode> waybillOrderNodeList = getWaybillOrderNodesByStatus(waybillOrder, continuousUnloadTimes, CarWaybillV1Enum.WAIT_UNLOADING);
|
|
|
if (waybillOrderNodeList == null) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -4007,24 +3990,26 @@ public class KwtWaybillOrderV1Service {
|
|
|
continuousCount++;
|
|
|
qualifiedNodeIds.add(orderNode.getId());
|
|
|
// 达到10次,返回最新的10条ID
|
|
|
- if (continuousCount >= continuousAccurateUnloadTimes) {
|
|
|
+ if (continuousCount >= continuousUnloadTimes) {
|
|
|
// 截断前10条
|
|
|
- nodeIds = qualifiedNodeIds.subList(0, continuousAccurateUnloadTimes);
|
|
|
+ nodeIds = qualifiedNodeIds.subList(0, continuousUnloadTimes);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
// 校验是否达到次数
|
|
|
- if (continuousCount < continuousAccurateUnloadTimes) {
|
|
|
- log.info("司机{}连续准确填写卸货信息次数{},未达到配置阈值{}", waybillOrder.getDriverId(), continuousCount, continuousAccurateUnloadTimes);
|
|
|
+ if (continuousCount < continuousUnloadTimes) {
|
|
|
+ log.info("司机{}连续准确填写卸货信息次数{},未达到配置阈值{}", waybillOrder.getDriverId(), continuousCount, continuousUnloadTimes);
|
|
|
return;
|
|
|
}
|
|
|
//1. 给连续的10次节点数据打标
|
|
|
- updateNode(waybillOrder, nodeIds, continuousAccurateUnloadTimes);
|
|
|
+ updateNode(waybillOrder, nodeIds, continuousScore);
|
|
|
|
|
|
//2 .更新司机分数(加分)
|
|
|
-
|
|
|
+ Long supEntId = getSupplierId(waybillOrder);
|
|
|
+ updateDriverScore(supEntId, waybillOrder.getEntId(), waybillOrder.getDriverId(), continuousScore, "连续准确填写卸货信息");
|
|
|
|
|
|
//3. 更新企业分数(加分)
|
|
|
+ updateLogEntScore(waybillOrder, supEntId, continuousScore, "连续准确填写卸货信息");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -4062,6 +4047,52 @@ public class KwtWaybillOrderV1Service {
|
|
|
log.info("司机{}连续执行运单节点,加分:{},节点ID:{}", waybillOrder.getDriverId(), continuousOnTimeScore, JSON.toJSONString(nodeIds));
|
|
|
}
|
|
|
|
|
|
+ // 查询供应商id
|
|
|
+ protected Long getSupplierId(KwtWaybillOrder waybillOrder) {
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ return 0L;
|
|
|
+ }
|
|
|
+ //查询订单托运单位(自动派单订单承运单位只为供应商)
|
|
|
+ KwtLogisticsOrderUnit logisticsOrderUnit = kwtLogisticsOrderUnitRepository.queryByLOrderIdAndUnitType(waybillOrder.getLOrderId(), 1);
|
|
|
+ if (logisticsOrderUnit == null || logisticsOrderUnit.getEntId() == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_ORDER_NOT_ENT, "未找到关联的物流订单托运企业(供应商)!");
|
|
|
+ }
|
|
|
+ return logisticsOrderUnit.getEntId();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改司机评分
|
|
|
+ * @param supeEntId
|
|
|
+ * @param entId
|
|
|
+ * @param driverId
|
|
|
+ * @param score
|
|
|
+ */
|
|
|
+ public void updateDriverScore(Long supeEntId, Long entId, Long driverId, Integer score, String action) {
|
|
|
+ RUpdateDriverScoreDto dto = new RUpdateDriverScoreDto();
|
|
|
+ dto.setSupEntId(supeEntId);
|
|
|
+ dto.setLogEntId(entId);
|
|
|
+ dto.setDriverId(driverId);
|
|
|
+ dto.setScore(BigDecimal.valueOf(score));
|
|
|
+ dto.setAction(action);
|
|
|
+ remoteFleetService.updateDriverScoreByEntId(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新企业评分
|
|
|
+ * @param waybillOrder
|
|
|
+ * @param supplierId
|
|
|
+ * @param score
|
|
|
+ */
|
|
|
+ public void updateLogEntScore(KwtWaybillOrder waybillOrder, Long supplierId, Integer score, String remark) {
|
|
|
+ LogisticsScoreDetailFeignDto detailDto = new LogisticsScoreDetailFeignDto();
|
|
|
+ detailDto.setProviderEntId(supplierId);
|
|
|
+ detailDto.setLogisticsEntId(waybillOrder.getEntId());
|
|
|
+ detailDto.setInfluenceBy(waybillOrder.getDriverId());
|
|
|
+ detailDto.setAction(remark);
|
|
|
+ detailDto.setScoreChange(BigDecimal.valueOf(score));
|
|
|
+ logisticsScoreFeignService.updateLogisticsScore(detailDto);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private void noticeTraderOrder(KwtLogisticsOrder kwtLogisticsOrder, KwtLogisticsOrder kwtLogistics) {
|
|
|
|