From 3ee0745bd5168d91c9464b3c948745cb1bcdde8d Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 22 四月 2026 09:23:45 +0800
Subject: [PATCH] fix: 去除生产相关入库

---
 src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java b/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
index b614149..e781672 100644
--- a/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java
@@ -12,6 +12,8 @@
 import com.ruoyi.device.mapper.DeviceLedgerMapper;
 import com.ruoyi.device.pojo.DeviceLedger;
 import com.ruoyi.device.service.IDeviceLedgerService;
+import com.ruoyi.production.mapper.ProductProcessMapper;
+import com.ruoyi.production.pojo.ProductProcess;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
@@ -36,6 +38,8 @@
     private DeviceLedgerMapper deviceLedgerMapper;
     @Autowired
     private SysUserMapper sysUserMapper;
+    @Autowired
+    private ProductProcessMapper productProcessMapper;
 
     @Override
     public IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger) {
@@ -45,6 +49,10 @@
 
     @Override
     public AjaxResult saveDeviceLedger(DeviceLedger deviceLedger) {
+        AjaxResult processCheckResult = validateProductProcess(deviceLedger.getProductProcessId());
+        if (processCheckResult != null) {
+            return processCheckResult;
+        }
         LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
         deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedger.getDeviceName());
         if (this.count(deviceLedgerLambdaQueryWrapper) > 0) {
@@ -59,6 +67,10 @@
 
     @Override
     public AjaxResult updateDeviceLedger(DeviceLedger deviceLedger) {
+        AjaxResult processCheckResult = validateProductProcess(deviceLedger.getProductProcessId());
+        if (processCheckResult != null) {
+            return processCheckResult;
+        }
         if (this.updateById(deviceLedger)) {
             return AjaxResult.success();
         }
@@ -66,6 +78,22 @@
     }
 
     @Override
+    public DeviceLedger getDetailById(Long id) {
+        return deviceLedgerMapper.selectById1(id);
+    }
+
+    private AjaxResult validateProductProcess(Long productProcessId) {
+        if (productProcessId == null) {
+            return null;
+        }
+        ProductProcess productProcess = productProcessMapper.selectById(productProcessId);
+        if (productProcess == null) {
+            return AjaxResult.error("宸ュ簭涓嶅瓨鍦紝璇烽噸鏂伴�夋嫨");
+        }
+        return null;
+    }
+
+    @Override
     public void export(HttpServletResponse response, Long[] ids) {
 
         if (ids == null || ids.length == 0) {

--
Gitblit v1.9.3