From d1791f762791428af91467b8855de83d54f015f9 Mon Sep 17 00:00:00 2001
From: zhuguifei <312353457@qq.com>
Date: 星期五, 17 四月 2026 15:23:21 +0800
Subject: [PATCH] feat: 1.新增物料、物料类型、材料检验统计等表维护功能  2.完善判定依据-判断依据明细  3.新增判断依据、物料管理等字典翻译类  4.成品物料批次-原始数据维护页面

---
 RuoYi-Vue-Plus/ruoyi-modules/ruoyi-qa/src/main/java/org/dromara/qa/qm/service/impl/QmJudgeServiceImpl.java |   61 ++++++++++++++++++++++++++++++
 1 files changed, 60 insertions(+), 1 deletions(-)

diff --git a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-qa/src/main/java/org/dromara/qa/qm/service/impl/QmJudgeServiceImpl.java b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-qa/src/main/java/org/dromara/qa/qm/service/impl/QmJudgeServiceImpl.java
index 55b949c..e6edd0e 100644
--- a/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-qa/src/main/java/org/dromara/qa/qm/service/impl/QmJudgeServiceImpl.java
+++ b/RuoYi-Vue-Plus/ruoyi-modules/ruoyi-qa/src/main/java/org/dromara/qa/qm/service/impl/QmJudgeServiceImpl.java
@@ -1,5 +1,6 @@
 package org.dromara.qa.qm.service.impl;
 
+import org.dromara.common.core.service.JudgeService;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
@@ -19,6 +20,13 @@
 import org.dromara.qa.qm.service.IQmStdService;
 import org.dromara.qa.qm.mapper.QmStdMapper;
 
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import org.dromara.qa.qm.domain.QmCheckitem;
+import org.dromara.qa.qm.domain.QmJudgeDetails;
+import org.dromara.qa.qm.mapper.QmCheckitemMapper;
+import org.dromara.qa.qm.mapper.QmJudgeDetailsMapper;
+import org.springframework.transaction.annotation.Transactional;
+
 import java.util.List;
 import java.util.Map;
 import java.util.Collection;
@@ -35,10 +43,12 @@
 @Slf4j
 @RequiredArgsConstructor
 @Service
-public class QmJudgeServiceImpl implements IQmJudgeService {
+public class QmJudgeServiceImpl implements IQmJudgeService, JudgeService {
 
     private final QmJudgeMapper baseMapper;
     private final QmStdMapper qmStdMapper;
+    private final QmCheckitemMapper qmCheckitemMapper;
+    private final QmJudgeDetailsMapper qmJudgeDetailsMapper;
 
     /**
      * 鏌ヨ鍒ゅ畾渚濇嵁
@@ -127,12 +137,52 @@
      * @return 鏄惁鏂板鎴愬姛
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Boolean insertByBo(QmJudgeBo bo) {
         QmJudge add = MapstructUtils.convert(bo, QmJudge.class);
+        if (add.getCdate() == null) {
+            add.setCdate(new java.util.Date());
+        }
         validEntityBeforeSave(add);
         boolean flag = baseMapper.insert(add) > 0;
         if (flag) {
             bo.setId(add.getId());
+
+            // 1. 鏍规嵁 stdCod 鏌ヨ鍚敤鐨勮绋嬫楠岄」鐩�
+            LambdaQueryWrapper<QmCheckitem> itemLqw = Wrappers.lambdaQuery();
+            itemLqw.eq(QmCheckitem::getStdCode, bo.getStdCod());
+            itemLqw.eq(QmCheckitem::getEnable, 1L);
+            itemLqw.ne(QmCheckitem::getDel, 1L);
+            List<QmCheckitem> checkitems = qmCheckitemMapper.selectList(itemLqw);
+
+            if (!checkitems.isEmpty()) {
+                List<QmJudgeDetails> detailsList = checkitems.stream().map(item -> {
+                    QmJudgeDetails detail = new QmJudgeDetails();
+                    detail.setJudgeId(add.getId());
+                    detail.setItemCod(item.getId());
+                    detail.setItemName(item.getItemName());
+                    detail.setValue3(0.0);
+                    detail.setValue1(0.0);
+                    detail.setValue2(0.0);
+                    detail.setLocation(item.getLocation());
+                    detail.setCls(item.getCheckLevel());
+                    detail.setStdscore(item.getScore() != null ? item.getScore() : 0.0);
+                    detail.setIsmix(item.getIsmix() != null ? item.getIsmix() : 0L);
+                    detail.setRid(item.getRid());
+                    detail.setCategory(item.getCategory());
+                    detail.setDecisionDes(item.getItemDes());
+                    return detail;
+                }).collect(Collectors.toList());
+                qmJudgeDetailsMapper.insertBatch(detailsList);
+            }
+
+            // 2. 灏嗗師鏉ュ瓨鍦ㄧ殑鐩稿悓鐗╂枡鐗屽彿鍜岀被鍨嬬殑渚濇嵁璁剧疆涓虹鐢�
+            LambdaUpdateWrapper<QmJudge> updateWrapper = Wrappers.lambdaUpdate();
+            updateWrapper.set(QmJudge::getStatus, 0L)
+                .eq(QmJudge::getMatCode, bo.getMatCode())
+                .eq(QmJudge::getCategory, bo.getCategory())
+                .ne(QmJudge::getId, add.getId());
+            baseMapper.update(null, updateWrapper);
         }
         return flag;
     }
@@ -171,4 +221,13 @@
         }
         return baseMapper.deleteByIds(ids) > 0;
     }
+
+    @Override
+    public String selectJudgeNameByCode(String judgeCode) {
+        QmJudgeVo qmJudgeVo = baseMapper.selectVoById(judgeCode);
+        if(qmJudgeVo!=null){
+            return qmJudgeVo.getJudgeName();
+        }
+        return null;
+    }
 }

--
Gitblit v1.9.3