|
|
@@ -14,6 +14,7 @@ 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.KwcContractLogisticsDto;
|
|
|
import com.sckw.contract.api.model.vo.TradeContractGoodsDto;
|
|
|
import com.sckw.contract.api.model.vo.TradeContractUnitDto;
|
|
|
import com.sckw.core.common.enums.enums.DictEnum;
|
|
|
@@ -152,6 +153,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
private final KwtWaybillOrderTicketRepository kwtWaybillOrderTicketRepository;
|
|
|
private final KwtWaybillOrderNodeRepository kwtWaybillOrderNodeRepository;
|
|
|
private final VehicleTraceClient vehicleTraceClient;
|
|
|
+ private final KwtLogisticsOrderContractRepository logisticsOrderContractRepository;
|
|
|
@Resource
|
|
|
private StreamBridge streamBridge;
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
@@ -4652,7 +4654,7 @@ public class KwtWaybillOrderV1Service {
|
|
|
* @param tradeContractUnitDtos 贸易合同单位列表
|
|
|
* @return 运单详情响应对象
|
|
|
*/
|
|
|
- private static WaybillOrderDetailResp getWaybillOrderDetailResp(KwtWaybillOrderSubtask subtask,
|
|
|
+ private WaybillOrderDetailResp getWaybillOrderDetailResp(KwtWaybillOrderSubtask subtask,
|
|
|
KwtWaybillOrder billOrder,
|
|
|
KwtLogisticsOrder logOrder,
|
|
|
RTruckVo truck, RFleetVo fleet,
|
|
|
@@ -4784,7 +4786,10 @@ public class KwtWaybillOrderV1Service {
|
|
|
BigDecimal unloadAmount = subtask.getUnloadAmount();
|
|
|
|
|
|
resp.setLoadCompleteRate(calculatePercentage(loadAmount, entrustAmount));
|
|
|
- resp.setLossRate(calculateLossRate(loadAmount, unloadAmount));
|
|
|
+ String lossRate = calculateLossRate(loadAmount, unloadAmount);
|
|
|
+ resp.setLossRate(lossRate);
|
|
|
+
|
|
|
+ resp.setIsPassReason(isLossRateExceeded(logOrder, lossRate));
|
|
|
|
|
|
// 轨迹记录
|
|
|
if (!CollectionUtils.isEmpty(nodeList)) {
|
|
|
@@ -4814,6 +4819,31 @@ public class KwtWaybillOrderV1Service {
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验货损率是否超过千分之三
|
|
|
+ */
|
|
|
+ private boolean isLossRateExceeded(KwtLogisticsOrder logOrder, String lossRate) {
|
|
|
+ log.info("[门卫]开始计算货损率是否超过配置值,物流订单:{},货损率:{}", JSON.toJSONString(logOrder), JSON.toJSONString(lossRate));
|
|
|
+ BigDecimal lossRateBig = StringUtils.isBlank(lossRate) ? BigDecimal.ZERO : new BigDecimal(lossRate);
|
|
|
+
|
|
|
+ KwtLogisticsOrderContract orderContract = logisticsOrderContractRepository.queryByLogOrderId(logOrder.getId());
|
|
|
+ if (orderContract == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.LOGISTICS_CONTRACT_NOT_FOUND, "物流订单无合同数据!");
|
|
|
+ }
|
|
|
+ KwcContractLogisticsDto contractLogisticsDto = remoteContractService.queryContractByContractId(orderContract.getContractId());
|
|
|
+ if (contractLogisticsDto == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.DATA_NOT_EXIST, "物流合同不存在!");
|
|
|
+ }
|
|
|
+ if (contractLogisticsDto.getAllowedError() == null || contractLogisticsDto.getAllowedError().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ // 查询出来的货损率为5,表示千分之5,需除以1000
|
|
|
+ BigDecimal allowedError = contractLogisticsDto.getAllowedError().divide(new BigDecimal("1000"), 6, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ log.info("[门卫]计算货损率是否超过配置值完成,配置的货损率:{}", com.alibaba.fastjson.JSON.toJSONString(allowedError));
|
|
|
+ return lossRateBig.compareTo(allowedError) > 0;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 格式化金额
|
|
|
*/
|