From f5437437d161d8d3fc3b4027049c907226afe7ba Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Tue, 11 Mar 2025 21:19:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(coal-washing-daily-analysis):=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=BC=96=E8=BE=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加了更新煤洗日常分析的接口和实现 - 新增 updateKfItems 和 updateMain 方法分别处理不同类型的更新请求 - 优化了数据验证和保存逻辑 --- .../CoalWashingDailyAnalysisController.java | 15 +++++ .../CoalWashingDailyAnalysisService.java | 66 +++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java index e90510dd..7b606b71 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/controller/CoalWashingDailyAnalysisController.java @@ -51,6 +51,21 @@ public class CoalWashingDailyAnalysisController extends BaseController { return this.service.update(dto); } + + @PostMapping("/updateKfItems") + @SysLog(action = "编辑") + public CoalWashingDailyAnalysisDto updateKfItems(@RequestBody UpdateCoalWashingDailyAnalysisDto dto) { + return this.service.updateKfItems(dto); + } + + + + @PostMapping("/updateMain") + @SysLog(action = "编辑") + public CoalWashingDailyAnalysisDto updateMain(@RequestBody UpdateCoalWashingDailyAnalysisDto dto) { + return this.service.updateKfItems(dto); + } + @PostMapping("/delete") @SysLog(action = "删除") public Object delete(@RequestBody IdRequest dto) { diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java index 8f744557..81f734dd 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java @@ -8,6 +8,7 @@ import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDt import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto; import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto; import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisKFItemVo; import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.CoalWashingDailyAnalysisMapper; import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.RoundMapper; import cn.lihongjie.coal.coalWashingDailyAnalysis.repository.CoalWashingDailyAnalysisRepository; @@ -124,6 +125,71 @@ public class CoalWashingDailyAnalysisService return getById(entity.getId()); } + + + public CoalWashingDailyAnalysisDto updateKfItems(UpdateCoalWashingDailyAnalysisDto request) { + + CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId()); + + if (this.repository.containArchived(request.getId())) { + throw new BizException("部分数据已归档,无法编辑或删除"); + } + + + + entity.setKfItems(request.getKfItems()); + + entity.setOrganizationId(Ctx.currentUser().getOrganizationId()); + + validate(entity); + if (entity.getProduct() != null) { + + entity.setName(productService.get(entity.getProduct().getId()).getName()); + } + this.repository.save(entity); + + return getById(entity.getId()); + } + + + + public CoalWashingDailyAnalysisDto updateMain(UpdateCoalWashingDailyAnalysisDto request) { + + CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId()); + List kfItems = entity.getKfItems(); + + if (this.repository.containArchived(request.getId())) { + throw new BizException("部分数据已归档,无法编辑或删除"); + } + this.mapper.updateEntity(entity, request); + + + entity.setKfItems(kfItems); + + entity.setOrganizationId(Ctx.currentUser().getOrganizationId()); + + validate(entity); + if (entity.getProduct() != null) { + + entity.setName(productService.get(entity.getProduct().getId()).getName()); + } + this.repository.save(entity); + + return getById(entity.getId()); + } + + + + + + + + + + + + + public void delete(IdRequest request) { if (this.repository.containArchived(request)) {