From a76e1d17d67641993dea6335cb8e1465a94df58d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:05 +0800
Subject: [PATCH] feat(stock): 优化库存管理和成品树结构功能 1- 为ApproveProcessMapper.xml和ProductBomMapper.xml添加排序功能 2- 在ProductionProductMainDto中新增bomInputQty字段用于产品结构投入数量 3- 修改ProductionProductMainServiceImpl中投入数量计算逻辑,使用前端传入的bomInputQty值 4- 在ProductWorkOrderDto中添加bomInputQty字段并在服务实现中计算标准投入数量 5- 更新SalesLedgerMapper.xml查询逻辑,从product_summary获取电压信息 6- 为SalesLedgerProduct添加stockId字段并修改库存扣减逻辑使用具体库存ID 7- 重构StockInventoryController中的成品库存树查询接口和导入导出功能 8- 新增成品和非成品库存导入导出的数据模型和Excel工具类 9- 优化StockInventoryServiceImpl中的库存扣减逻辑,支持按特定库存ID操作 10- 更新库存导入导出功能,区分成品和非成品类型并提供相应模板

---
 src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java |  100 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 98 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java
index 5320a0e..4276f98 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java
@@ -1,10 +1,21 @@
 package com.ruoyi.production.service.impl;
 
-import com.ruoyi.production.pojo.ProductInspectionRecord;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.production.mapper.ProductInspectionRecordMapper;
+import com.ruoyi.production.pojo.ProductInspectionRecord;
 import com.ruoyi.production.service.ProductInspectionRecordService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.project.system.domain.SysNotice;
+import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.project.system.mapper.SysUserMapper;
+import com.ruoyi.project.system.service.ISysNoticeService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>
@@ -14,7 +25,92 @@
  * @author 鑺杞欢锛堟睙鑻忥級鏈夐檺鍏徃
  * @since 2026-03-16 04:16:32
  */
+@Slf4j
 @Service
-public class ProductInspectionRecordServiceImpl extends ServiceImpl<ProductInspectionRecordMapper, ProductInspectionRecord> implements ProductInspectionRecordService {
+public class ProductInspectionRecordServiceImpl extends ServiceImpl<ProductInspectionRecordMapper, ProductInspectionRecord>
+        implements ProductInspectionRecordService {
 
+    private static final String OP_POST_CODE = "op";
+
+    @Autowired
+    private SysUserMapper userMapper;
+
+    @Autowired
+    private ISysNoticeService noticeService;
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void notify(List<Long> ids) {
+        if (ids == null || ids.isEmpty()) {
+            return;
+        }
+
+        // 1. 鏌ヨ宸℃璁板綍
+        List<ProductInspectionRecord> records = listByIds(ids);
+        if (records == null || records.isEmpty()) {
+            log.warn("鏈壘鍒板搴旂殑宸℃璁板綍, ids={}", ids);
+            return;
+        }
+
+        // 2. 鏌ヨ宀椾綅涓簅p鐨勭敤鎴�
+        List<SysUser> opUsers = userMapper.selectUserListByPostCode(OP_POST_CODE);
+        if (opUsers == null || opUsers.isEmpty()) {
+            log.warn("鏈壘鍒板矖浣嶇紪鐮佷负[{}]鐨勭敤鎴�", OP_POST_CODE);
+            return;
+        }
+
+        // 3. 鑾峰彇褰撳墠鐢ㄦ埛淇℃伅
+        Long currentUserId = SecurityUtils.getLoginUser().getUserId();
+        Long tenantId = SecurityUtils.getLoginUser().getTenantId();
+
+        // 4. 涓烘瘡鏉″贰妫�璁板綍鍙戦�侀�氱煡
+        List<SysNotice> notices = new ArrayList<>();
+        for (ProductInspectionRecord record : records) {
+            // 杩囨护鍑轰笉鍚堟牸鐨勮褰�
+            if (!"no".equalsIgnoreCase(record.getJudgement())) {
+                continue;
+            }
+
+            // 鏋勫缓娑堟伅鍐呭锛歺xx鐢熶骇璁㈠崟锛寈x宸ュ簭锛寈x妫�楠岄」涓嶅悎鏍硷紝璇峰強鏃跺宸ヨ壓鍙婂弬鏁板仛璋冩暣锛�
+            String productionOrder = record.getUnqualifiedOrder();
+            String process = record.getProcess();
+            String inspectionItem = record.getInspectionItem();
+
+            StringBuilder messageBuilder = new StringBuilder();
+            if (productionOrder != null && !productionOrder.isEmpty()) {
+                messageBuilder.append(productionOrder).append("鐢熶骇璁㈠崟锛�");
+            }
+            if (process != null && !process.isEmpty()) {
+                messageBuilder.append(process).append("宸ュ簭锛�");
+            }
+            if (inspectionItem != null && !inspectionItem.isEmpty()) {
+                messageBuilder.append(inspectionItem).append("妫�楠岄」涓嶅悎鏍硷紝");
+            }
+            messageBuilder.append("璇峰強鏃跺宸ヨ壓鍙婂弬鏁板仛璋冩暣锛�");
+
+            String title = "宸℃涓嶅悎鏍奸�氱煡";
+            String message = messageBuilder.toString();
+
+            SysUser admin = userMapper.selectUserById(1L);
+            opUsers.add(admin);
+            // 涓烘瘡涓猳p宀椾綅鐢ㄦ埛鍒涘缓閫氱煡
+            for (SysUser opUser : opUsers) {
+                SysNotice notice = new SysNotice();
+                notice.setNoticeType("1");
+                notice.setNoticeTitle(title);
+                notice.setNoticeContent(message);
+                notice.setStatus("0");
+                notice.setConsigneeId(opUser.getUserId());
+                notice.setSenderId(currentUserId);
+                notice.setTenantId(tenantId);
+                notices.add(notice);
+            }
+        }
+
+        // 5. 鎵归噺淇濆瓨閫氱煡
+        if (!notices.isEmpty()) {
+            noticeService.saveBatch(notices);
+            log.info("宸插彂閫亄}鏉″贰妫�涓嶅悎鏍奸�氱煡缁檣}涓猳p宀椾綅鐢ㄦ埛", notices.size(), opUsers.size());
+        }
+    }
 }

--
Gitblit v1.9.3