From 5929fa552fd2d8cf9d4cad0d519c89728e4a6ada Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 23 三月 2026 16:03:16 +0800
Subject: [PATCH] Merge branch 'dev_衡阳_鹏创电子' of http://114.132.189.42:9002/r/product-inventory-management-after into dev_衡阳_鹏创电子

---
 src/main/java/com/ruoyi/production/service/impl/ProductInspectionRecordServiceImpl.java |   98 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 96 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..44acb36 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,90 @@
  * @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();
+
+            // 涓烘瘡涓猳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