|
|
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.sckw.contract.api.RemoteContractService;
|
|
|
+import com.sckw.contract.api.model.vo.KwcContractLogisticsDto;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.common.enums.enums.ErrorCodeEnum;
|
|
|
import com.sckw.core.exception.BusinessPlatfromException;
|
|
|
@@ -69,6 +70,7 @@ public class GatekeeperOrderService {
|
|
|
private final KwtWaybillOrderTicketRepository waybillOrderTicketRepository;
|
|
|
private final KwtLogisticsOrderRepository logisticsOrderRepository;
|
|
|
private final KwtLogisticsOrderGoodsRepository logisticsOrderGoodsRepository;
|
|
|
+ private final KwtLogisticsOrderContractRepository logisticsOrderContractRepository;
|
|
|
private final KwtWaybillOrderNodeRepository waybillOrderNodeRepository;
|
|
|
private final KwtWaybillOrderWeighbridgeRepository waybillOrderWeighbridgeRepository;
|
|
|
@Autowired
|
|
|
@@ -441,7 +443,7 @@ public class GatekeeperOrderService {
|
|
|
//计算货损率
|
|
|
BigDecimal lossRate = calculateLossRate(loadAmount, unloadAmount);
|
|
|
gatekeeper.setLossRate(lossRate);
|
|
|
- gatekeeper.setIsPassReason(isLossRateExceeded(lossRate));
|
|
|
+ gatekeeper.setIsPassReason(isLossRateExceeded(logOrder, lossRate));
|
|
|
}
|
|
|
|
|
|
gatekeeper.setOrderType(logOrder.getOrderType());
|
|
|
@@ -471,9 +473,24 @@ public class GatekeeperOrderService {
|
|
|
/**
|
|
|
* 校验货损率是否超过千分之三
|
|
|
*/
|
|
|
- private static boolean isLossRateExceeded(BigDecimal lossRate) {
|
|
|
- BigDecimal threshold = new BigDecimal("0.003");
|
|
|
- return lossRate.compareTo(threshold) > 0;
|
|
|
+ private boolean isLossRateExceeded(KwtLogisticsOrder logOrder, BigDecimal lossRate) {
|
|
|
+ log.info("[门卫]开始计算货损率是否超过配置值,物流订单:{},货损率:{}", JSON.toJSONString(logOrder), JSON.toJSONString(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("[门卫]计算货损率是否超过配置值完成,配置的货损率:{}", JSON.toJSONString(allowedError));
|
|
|
+ return lossRate.compareTo(allowedError) > 0;
|
|
|
}
|
|
|
|
|
|
/**
|