From 4690d8b2b30a05931beeb4966a3248981cf0c1e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 26 May 2026 08:41:02 +0800 Subject: [PATCH] =?UTF-8?q?refactor(quotation):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E5=8F=8A=E6=96=B9=E6=A1=88=E9=A1=B9=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 合并方案项保存操作,避免重复查询和判断 - 统一设置方案项的创建和更新时间 - 精简对旧方案版本号处理逻辑 - 避免空指针,确保方案存在才更新状态 feat(price-config): 增加价格配置可用标志 - 在价格配置数据中添加“enable”字段,默认设置为true fix(ratio-agent-config): 修复空字符串过滤问题 - 过滤条件中排除空字符串,避免无效数据处理 --- .../admin/PriceConfigController.java | 2 + .../admin/RatioAgentConfigController.java | 2 +- .../controller/app/PlanController.java | 56 ++++++------------- 3 files changed, 21 insertions(+), 39 deletions(-) diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java index f15adc9c..9a2be51a 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/PriceConfigController.java @@ -110,6 +110,8 @@ public class PriceConfigController extends ControllerBase { map.put(area.getCode(), NumberUtil.format(area.getAmount())); }); } + //是否可以配置价格 + map.put("enable", true); map.put("children", new ArrayList<>()); data.getChildren().forEach(item -> convert(map, item)); return map; diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/RatioAgentConfigController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/RatioAgentConfigController.java index d0ae5108..ba515b04 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/RatioAgentConfigController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/admin/RatioAgentConfigController.java @@ -235,7 +235,7 @@ public class RatioAgentConfigController extends ControllerBase { data.remove("modelId"); data.remove("modelNo"); data.forEach((key, value) -> { - if (Objects.nonNull(value)) { + if (Objects.nonNull(value) && StrUtil.isNotBlank(value.toString())) { Integer userId = Integer.parseInt(key.split("-")[0]); String type = key.split("-")[1]; if ("standardRatio".equals(type) || "optionalRatio".equals(type)) { diff --git a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java index d298da88..c1e1c80f 100644 --- a/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java +++ b/nflg-mobilebroken-quotation/src/main/java/com/nflg/mobilebroken/quotation/controller/app/PlanController.java @@ -338,13 +338,12 @@ public class PlanController extends ControllerBase { .eq(QuotationUserPlanModel::getCreateByType, AppUserUtil.isAgent() ? 1 : 0) .eq(QuotationUserPlanModel::getCreateById, AppUserUtil.getUserId()) .one(); - List items = Objects.isNull(plan) - ? new ArrayList<>() - : planModelItemService.lambdaQuery() - .eq(QuotationUserPlanModelItem::getPlanId, plan.getId()) - .list(); + List items = new ArrayList<>(); if (Objects.nonNull(plan)) { - QuotationUserPlanModel oldPlan = planModelService.getById(plan.getId()); + String version = plan.getVersion().substring(2); + String day = version.split("-")[0]; + int index = Integer.parseInt(version.split("-")[1]); + String today = DateTimeUtil.format(LocalDate.now(), "yyMMdd"); planModelService.lambdaUpdate() .set(QuotationUserPlanModel::getStatus, 2) .eq(QuotationUserPlanModel::getId, plan.getId()) @@ -356,10 +355,6 @@ public class PlanController extends ControllerBase { .setCreateById(AppUserUtil.getUserId()) .setCreateBy(AppUserUtil.getUserName()) .setCreateTime(LocalDateTime.now()); - String version = oldPlan.getVersion().substring(2); - String day = version.split("-")[0]; - int index = Integer.parseInt(version.split("-")[1]); - String today = DateTimeUtil.format(LocalDate.now(), "yyMMdd"); if (today.equals(day)) { plan.setVersion("BP" + day + "-" + StrUtil.padPre(String.valueOf(index + 1), 2, '0')); } else { @@ -377,34 +372,19 @@ public class PlanController extends ControllerBase { .setCreateTime(LocalDateTime.now()); planModelService.save(plan); } - QuotationUserPlanModel finalPlan = plan; - datas.forEach(data -> { - if (Objects.isNull(data.getId())) { - items.add(new QuotationUserPlanModelItem() - .setPlanId(finalPlan.getId()) - .setModelId(data.getModelId()) - .setName(data.getName()) - .setRatio(data.getRatio()) - .setAreaId(data.getAreaId()) - .setIsDefault(data.getIsDefault()) - .setCreateTime(LocalDateTime.now()) - ); - } else { - QuotationUserPlanModelItem item = items.stream() - .filter(item1 -> item1.getId().equals(data.getId())) - .findFirst() - .orElse(null); - VUtils.trueThrowBusinessError(Objects.isNull(item)).throwMessage("数据不存在:" + data.getId()); - item.setPlanId(finalPlan.getId()); - item.setName(data.getName()); - item.setRatio(data.getRatio()); - item.setAreaId(data.getAreaId()); - item.setIsDefault(data.getIsDefault()); - item.setCreateTime(LocalDateTime.now()); - } - }); - items.forEach(item -> item.setId(IdUtil.getId())); - planModelItemService.saveBatch(items); + Long planId = plan.getId(); + planModelItemService.saveBatch( + datas.stream() + .map(data -> new QuotationUserPlanModelItem() + .setPlanId(planId) + .setName(data.getName()) + .setRatio(data.getRatio()) + .setModelId(data.getModelId()) + .setIsDefault(data.getIsDefault()) + .setCreateTime(LocalDateTime.now()) + .setUpdateTime(LocalDateTime.now())) + .collect(Collectors.toList()) + ); return ApiResult.success(); }