From 34981c30a78e8bbd7791131059a9210f9928b62c Mon Sep 17 00:00:00 2001
From: 刘光辉 <347230014@qq.com>
Date: 星期四, 17 九月 2026 09:24:09 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master' into master

---
 jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiQijuBaofeiServiceImpl.java |   76 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiQijuBaofeiServiceImpl.java b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiQijuBaofeiServiceImpl.java
new file mode 100644
index 0000000..92d79fd
--- /dev/null
+++ b/jnpf-lims/jnpf-lims-biz/src/main/java/jnpf/limsService/impl/LimsShebeiYiqiQijuBaofeiServiceImpl.java
@@ -0,0 +1,76 @@
+package jnpf.limsService.impl;
+
+import jnpf.audit.sdk.annotation.AuditLog;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import jnpf.exception.DataException;
+import jnpf.limsEntity.LimsShebeiJiliangQijuEntity;
+import jnpf.limsEntity.LimsShebeiYiqiQijuBaofeiEntity;
+import jnpf.limsMapper.LimsShebeiJiliangQijuMapper;
+import jnpf.limsMapper.LimsShebeiYiqiQijuBaofeiMapper;
+import jnpf.limsService.LimsShebeiYiqiQijuBaofeiService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+@Service
+public class LimsShebeiYiqiQijuBaofeiServiceImpl implements LimsShebeiYiqiQijuBaofeiService {
+
+    private static final String BIZ_STATUS_YIBAOFEI = "yibaofei";
+
+    @Autowired
+    private LimsShebeiYiqiQijuBaofeiMapper qijuBaofeiMapper;
+
+    @Autowired
+    private LimsShebeiJiliangQijuMapper jiliangQijuMapper;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    @AuditLog(action = "SCRAP", label = "鍣ㄥ叿鎶ュ簾", bizType = "SHEBEI_YIQI",
+            bizCodeExpr = "#flowId", bizCodeRequired = false, targetTable = "lims_shebei_yiqi_qiju",
+            targetIdExpr = "T(jnpf.limsService.support.LimsAuditTargetIds).qijuByScrapFlow(#flowId, #taskId)",
+            diff = true, entityClass = LimsShebeiJiliangQijuEntity.class)
+    public void baofeiQiju(String flowId, String taskId) throws DataException {
+        String resolvedFlowId = trimToEmpty(flowId);
+        String resolvedTaskId = trimToEmpty(taskId);
+        if (resolvedFlowId.isEmpty()) {
+            throw new DataException("娴佺▼ID(flow_id)涓嶈兘涓虹┖");
+        }
+        if (resolvedTaskId.isEmpty()) {
+            throw new DataException("娴佺▼浠诲姟ID(task_id)涓嶈兘涓虹┖");
+        }
+
+        LambdaQueryWrapper<LimsShebeiYiqiQijuBaofeiEntity> query = new LambdaQueryWrapper<>();
+        query.eq(LimsShebeiYiqiQijuBaofeiEntity::getFlowId, resolvedFlowId)
+                .eq(LimsShebeiYiqiQijuBaofeiEntity::getFlowTaskId, resolvedTaskId);
+        List<LimsShebeiYiqiQijuBaofeiEntity> baofeiList = qijuBaofeiMapper.selectList(query);
+        if (baofeiList.isEmpty()) {
+            throw new DataException("鏈壘鍒板叧鑱旂殑鍣ㄥ叿鎶ュ簾鐢宠锛歠low_id=" + resolvedFlowId + ", task_id=" + resolvedTaskId);
+        }
+        if (baofeiList.size() > 1) {
+            throw new DataException("澶氫釜鍣ㄥ叿鎶ュ簾鐢宠鍏宠仈鍚屼竴娴佺▼浠诲姟锛歵ask_id=" + resolvedTaskId);
+        }
+
+        String qijuId = trimToEmpty(baofeiList.get(0).getQijuId());
+        if (qijuId.isEmpty()) {
+            throw new DataException("鍣ㄥ叿鎶ュ簾鐢宠鏈叧鑱旇閲忓櫒鍏�");
+        }
+        if (jiliangQijuMapper.selectById(qijuId) == null) {
+            throw new DataException("璁¢噺鍣ㄥ叿涓嶅瓨鍦細" + qijuId);
+        }
+
+        LambdaUpdateWrapper<LimsShebeiJiliangQijuEntity> update = new LambdaUpdateWrapper<>();
+        update.eq(LimsShebeiJiliangQijuEntity::getId, qijuId)
+                .set(LimsShebeiJiliangQijuEntity::getBizStatus, BIZ_STATUS_YIBAOFEI);
+        if (jiliangQijuMapper.update(null, update) != 1) {
+            throw new DataException("璁¢噺鍣ㄥ叿鎶ュ簾鐘舵�佹洿鏂板け璐ワ紝璇峰埛鏂板悗閲嶈瘯");
+        }
+    }
+
+    private String trimToEmpty(String value) {
+        return value == null ? "" : value.trim();
+    }
+}

--
Gitblit v1.8.0