From f32de021e7af1627b6d18e681b46dbc0a5b108f8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 21 四月 2026 13:33:04 +0800
Subject: [PATCH] feat: 设备台账与工序进行绑定

---
 src/main/java/com/ruoyi/device/service/impl/DeviceLedgerServiceImpl.java |   34 +++++++++++++++++++++++++++++++---
 1 files changed, 31 insertions(+), 3 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 0687aad..f9ed796 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,19 +38,25 @@
     private DeviceLedgerMapper deviceLedgerMapper;
     @Autowired
     private SysUserMapper sysUserMapper;
+    @Autowired
+    private ProductProcessMapper productProcessMapper;
 
     @Override
-    public IPage<DeviceLedgerDto> queryPage(Page page, DeviceLedgerDto deviceLedger) {
+    public IPage<DeviceLedgerDto> queryPage(Page<?> page, DeviceLedgerDto deviceLedger) {
 
         return deviceLedgerMapper.queryPage(page, deviceLedger);
     }
 
     @Override
     public AjaxResult saveDeviceLedger(DeviceLedger deviceLedger) {
+        AjaxResult processCheckResult = validateProductProcess(deviceLedger.getProductProcessId());
+        if (processCheckResult != null) {
+            return processCheckResult;
+        }
         LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceModel,deviceLedger.getDeviceModel());
+        deviceLedgerLambdaQueryWrapper.eq(DeviceLedger::getDeviceName,deviceLedger.getDeviceName());
         if (this.count(deviceLedgerLambdaQueryWrapper) > 0) {
-            return AjaxResult.error("璁惧鍨嬪彿宸插瓨鍦�");
+            return AjaxResult.error("璁惧鍚嶇О宸插瓨鍦�");
         }
         boolean save = this.save(deviceLedger);
         if (save){
@@ -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