diff --git a/src/main/java/com/bonus/gzcar/business/backstage/service/SupDispatchCarServiceImpl.java b/src/main/java/com/bonus/gzcar/business/backstage/service/SupDispatchCarServiceImpl.java index 6d0a8de..cb074ef 100644 --- a/src/main/java/com/bonus/gzcar/business/backstage/service/SupDispatchCarServiceImpl.java +++ b/src/main/java/com/bonus/gzcar/business/backstage/service/SupDispatchCarServiceImpl.java @@ -465,6 +465,10 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { } else { // tonValue ≥ 5(明确包含等于5的情况) tonType = "3"; } + + log.info("车辆派车计算 - 公里数:{}, 吨位:{}, 吨位类型:{}, 合同ID:{}, 供应商ID:{}", + gls, vo.getTon(), tonType, vo.getContractId(), vo.getSupId()); + PriceVo priceVo = getMoney(vo.getContractId(), null, vo.getSupId(), gls, tonType); sb.append("依据:").append(priceVo.getGlsStart()).append("-").append(priceVo.getGlsEnd()); sb.append("公里:").append(priceVo.getPrice()).append("元"); @@ -480,6 +484,8 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { vo.setCost(glsMoney.toString()); vo.setGlsMoney(glsMoney); } catch (Exception e) { + log.error("车辆派车计算失败 - 公里数:{}, 吨位:{}, 合同ID:{}, 供应商ID:{}, 异常信息:{}", + gls, vo.getTon(), vo.getContractId(), vo.getSupId(), e.getMessage(), e); return "公里数不在厂商合同范围内"; } } else { @@ -487,6 +493,9 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { int day = vo.getPlanDay(); int isOutSet = vo.getIsOutSet(); try { + log.info("吊车派车计算 - 计划天数:{}, 是否收取进出场费:{}, 合同ID:{}, 车型ID:{}, 供应商ID:{}", + day, isOutSet, vo.getContractId(), vo.getModelId(), vo.getSupId()); + BigDecimal days = new BigDecimal(day); BigDecimal dcMoney = new BigDecimal("0"); BigDecimal month = new BigDecimal("30"); @@ -533,12 +542,17 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { vo.setDayPrice(priceVo.getDayPrice()); vo.setMonthPrice(priceVo.getMonthPrice()); } catch (Exception e) { + log.error("吊车派车计算失败 - 计划天数:{}, 合同ID:{}, 车型ID:{}, 供应商ID:{}, 异常信息:{}", + day, vo.getContractId(), vo.getModelId(), vo.getSupId(), e.getMessage(), e); return "公里数不在厂商合同范围内"; } if (isOutSet == 1) { //进出场公里数 String jcGls = vo.getJcGls(); try { + log.info("计算进出场费用 - 进出场公里数:{}, 合同ID:{}, 车型ID:{}, 供应商ID:{}", + jcGls, vo.getContractId(), vo.getModelId(), vo.getSupId()); + PriceVo priceVo = getJccMoney(vo.getContractId(), vo.getModelId(), vo.getSupId(), jcGls); sb.append("依据:").append(priceVo.getGlsStart()).append("-").append(priceVo.getGlsEnd()); sb.append("公里:").append(priceVo.getPrice()).append("元"); @@ -549,6 +563,8 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { cost = cost.add(jcMoney); vo.setCost(cost.toString()); } catch (Exception e) { + log.error("进出场费用计算失败 - 进出场公里数:{}, 合同ID:{}, 车型ID:{}, 供应商ID:{}, 异常信息:{}", + jcGls, vo.getContractId(), vo.getModelId(), vo.getSupId(), e.getMessage(), e); return "公里数不在进出场费用范围内"; } } @@ -567,18 +583,38 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { */ private PriceVo getMoney(String contractId, String modelId, String supId, String gls, String ton) throws Exception { List list = mapper.getContractPriceList(contractId, modelId, supId, ton); + + log.info("查询合同价格 - contractId:{}, modelId:{}, supId:{}, gls:{}, ton:{}", contractId, modelId, supId, gls, ton); + log.info("查询到的价格区间数量: {}", list != null ? list.size() : 0); + //车辆 if (StringHelper.isEmpty(modelId)) { + if (list == null || list.isEmpty()) { + log.error("未查询到合同价格配置 - contractId:{}, supId:{}, ton:{}", contractId, supId, ton); + throw new Exception("未查询到合同价格配置"); + } + BigDecimal nowGls = new BigDecimal(gls); + log.info("当前公里数: {}", nowGls); + for (PriceVo priceVo : list) { BigDecimal glsEnd = new BigDecimal(priceVo.getGlsEnd()); BigDecimal glsStart = new BigDecimal(priceVo.getGlsStart()); + log.info("价格区间: {} - {}, 价格: {}", glsStart, glsEnd, priceVo.getPrice()); + if (nowGls.compareTo(glsEnd) <= 0 && nowGls.compareTo(glsStart) >= 0) { + log.info("匹配到价格区间: {} - {}", glsStart, glsEnd); return priceVo; } } - throw new Exception(); + + log.error("公里数{}不在任何价格区间内 - contractId:{}, supId:{}, ton:{}", nowGls, contractId, supId, ton); + throw new Exception("公里数不在合同配置范围内"); } else { + if (list == null || list.isEmpty()) { + log.error("未查询到吊车价格配置 - contractId:{}, modelId:{}, supId:{}", contractId, modelId, supId); + throw new Exception("未查询到吊车价格配置"); + } return list.get(0); } } @@ -595,15 +631,31 @@ public class SupDispatchCarServiceImpl implements SupDispatchCarService { */ private PriceVo getJccMoney(String contractId, String modelId, String supId, String gls) throws Exception { List list = mapper.getCarOutList(contractId, modelId, supId); + + log.info("查询进出场费用 - contractId:{}, modelId:{}, supId:{}, gls:{}", contractId, modelId, supId, gls); + log.info("查询到的进出场费用区间数量: {}", list != null ? list.size() : 0); + + if (list == null || list.isEmpty()) { + log.error("未查询到进出场费用配置 - contractId:{}, modelId:{}, supId:{}", contractId, modelId, supId); + throw new Exception("未查询到进出场费用配置"); + } + BigDecimal nowGls = new BigDecimal(gls); + log.info("当前进出场公里数: {}", nowGls); + for (PriceVo priceVo : list) { BigDecimal glsEnd = new BigDecimal(priceVo.getGlsEnd()); BigDecimal glsStart = new BigDecimal(priceVo.getGlsStart()); + log.info("进出场费用区间: {} - {}, 价格: {}", glsStart, glsEnd, priceVo.getPrice()); + if (nowGls.compareTo(glsEnd) <= 0 && nowGls.compareTo(glsStart) > 0) { + log.info("匹配到进出场费用区间: {} - {}", glsStart, glsEnd); return priceVo; } } - throw new Exception(); + + log.error("进出场公里数{}不在任何费用区间内 - contractId:{}, modelId:{}, supId:{}", nowGls, contractId, modelId, supId); + throw new Exception("进出场公里数不在配置范围内"); }