From beaba1bf3a30053408a860479f9150b02169a7c8 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期一, 24 八月 2026 17:04:16 +0800
Subject: [PATCH] feat(mes): 添加种子质检功能模块

---
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualitySourceDO.java         |   24 ++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/MesQcSeedQualityController.java     |   22 ++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityDO.java               |   20 ++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/vo/MesQcSeedQualitySubmitReqVO.java |   22 ++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityMapper.java                |   13 ++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualitySourceMapper.java          |   11 ++
 sql/mysql/mes_seed_quality_init.sql                                                                                            |   25 +++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityService.java                 |    3 
 docs/mes_seed_quality_integration.md                                                                                           |   48 +++++++++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityIndicatorDO.java      |   18 +++
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityIndicatorMapper.java       |    5 +
 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityServiceImpl.java             |   42 ++++++++
 12 files changed, 253 insertions(+), 0 deletions(-)

diff --git a/docs/mes_seed_quality_integration.md b/docs/mes_seed_quality_integration.md
new file mode 100644
index 0000000..534519c
--- /dev/null
+++ b/docs/mes_seed_quality_integration.md
@@ -0,0 +1,48 @@
+# 绉嶅瓙璐ㄦ鍓嶇鑱旇皟鏂规
+
+## 娑夊強椤甸潰
+
+- 绉嶅瓙璐ㄦ鎻愪氦椤�
+- 绉嶅瓙璐ㄦ璁板綍椤�
+
+## 涓氬姟娴佺▼涓庢暟鎹甫鍏�
+
+1. 鐢熶骇琚嬬爜鎴栧緟妫�搴撳瓨甯﹀叆琚嬬爜銆佺墿鏂欍�佹壒娆′俊鎭��
+2. 鎻愪氦鏃朵粎浼犺鐮併�佺墿鏂欍�佹壒娆″拰鍥涢」妫�娴嬬粨鏋滐紝浠撳簱浣嶇疆鐢卞悗鍙伴厤缃喅瀹氥��
+3. 鍚堟牸鏃剁敱鍚庣灏哤IP/寰呮搴撶Щ鍏ユ寮忓簱瀛橈紱涓嶅悎鏍兼椂鍒犻櫎琚嬬爜鍜屽搴斿簱瀛樺彴璐︼紝浣嗕繚鐣欒川妫�瀹¤鏁版嵁銆�
+
+## API
+
+| 鏂规硶 | 璺緞 | 璇存槑 |
+|---|---|---|
+| POST | `/mes/qc/seed-quality/submit` | 鎻愪氦绉嶅瓙璐ㄦ |
+
+璇锋眰鍙傛暟鍖呮嫭 `code`銆乣itemId`銆乣batchCode`銆乣reason` 鍜� `indicators`銆俙indicators` 蹇呴』鎭板ソ鍖呭惈 `purity`銆乣cleanliness`銆乣germination_rate`銆乣moisture`锛屾瘡椤瑰寘鍚� `value`銆乣minValue`銆乣maxValue`锛屾暟鍊间笉寰椾负璐熶笖缁撴灉蹇呴』鍦ㄨ竟鐣屽唴銆�
+
+鎴愬姛鍝嶅簲涓鸿川妫�涓昏〃缂栧彿銆傞噸澶嶈鐮佹彁浜や細琚嫆缁濄��
+
+## 瀛楁灞曠ず瑙勫垯
+
+| 瀛楁 | 灞曠ず浣嶇疆 | 璇存槑 |
+|---|---|---|
+| code | 鍒楄〃銆佽鎯� | 琚嬬爜 |
+| batchCode | 鍒楄〃銆佽鎯� | 鐢熶骇鎵规 |
+| 鍥涢」鎸囨爣 | 璇︽儏 | 灞曠ず瀹炴祴鍊煎拰鍚堟牸涓婁笅闄� |
+| result | 鍒楄〃銆佽鎯� | 鍚堟牸鎴栦笉鍚堟牸 |
+| reason | 璇︽儏 | 涓嶅悎鏍煎師鍥� |
+| inspectorId銆乮nspectedAt | 璇︽儏 | 璐ㄦ鍛樺拰璐ㄦ鏃堕棿 |
+
+## 涓氬姟瑙勫垯璇存槑
+
+| 鍦烘櫙 | 瑙勫垯 |
+|---|---|
+| 鎸囨爣鏍¢獙 | 鍥涢」鎸囨爣蹇呴』榻愬叏銆佷笉鍙噸澶嶏紝瀹炴祴鍊煎繀椤诲湪杈圭晫鍐� |
+| 鍚堟牸 | 鐢熸垚MOVE_OUT鍜孧OVE_IN锛屾潵婧愪负WIP/寰呮搴擄紝鐩爣涓烘寮忓簱瀛� |
+| 涓嶅悎鏍� | 鍒犻櫎琚嬬爜鍜屽搴斿簱瀛樺彴璐︼紝涓嶈皟鏁寸敓浜ф壒娆℃暟閲忥紝淇濈暀涓昏〃銆佹寚鏍囥�佸師鍥犲拰浜嬪姟瀹¤ |
+| 骞傜瓑 | 琚嬬爜宸插瓨鍦ㄨ川妫�璁板綍鏃舵嫆缁濆啀娆℃彁浜� |
+| 鏉冮檺 | 闇�瑕� `mes:qc-seed-quality:submit` 鏉冮檺 |
+
+## 娉ㄦ剰浜嬮」
+
+- 鍓嶇涓嶅緱浼犱粨搴撱�佸簱鍖恒�佸簱浣嶅弬鏁帮紝鍚庡彴閰嶇疆缂栫爜涓哄悗缁厤缃湇鍔¢鐣欍��
+- 涓嶅悎鏍肩粨鏋滀粛闇�灞曠ず锛屼笉鑳芥寜涓氬姟鍒犻櫎璐ㄦ涓昏〃鍙婃寚鏍囪褰曘��
diff --git a/sql/mysql/mes_seed_quality_init.sql b/sql/mysql/mes_seed_quality_init.sql
new file mode 100644
index 0000000..e6f5615
--- /dev/null
+++ b/sql/mysql/mes_seed_quality_init.sql
@@ -0,0 +1,25 @@
+-- 绉嶅瓙璐ㄦ鍒濆鍖栬剼鏈紙鏃犵鎴峰瓧娈碉紝鍙噸澶嶆墽琛岋級
+CREATE TABLE IF NOT EXISTS mes_qc_seed_quality (
+  id bigint NOT NULL AUTO_INCREMENT COMMENT '缂栧彿', code varchar(64) NOT NULL COMMENT '琚嬬爜', item_id bigint NOT NULL COMMENT '鐗╂枡', batch_code varchar(64) DEFAULT NULL COMMENT '鎵规鍙�', result tinyint NOT NULL DEFAULT 0 COMMENT '0澶勭悊涓�1鍚堟牸2涓嶅悎鏍�', reason varchar(500) DEFAULT NULL COMMENT '鍘熷洜', inspector_id bigint DEFAULT NULL COMMENT '璐ㄦ鍛�', inspected_at datetime DEFAULT NULL COMMENT '璐ㄦ鏃堕棿', creator varchar(64) DEFAULT NULL, create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, updater varchar(64) DEFAULT NULL, update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, deleted bit NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY uk_code (code)
+) ENGINE=InnoDB COMMENT='绉嶅瓙璐ㄦ涓昏〃';
+CREATE TABLE IF NOT EXISTS mes_qc_seed_quality_indicator (
+  id bigint NOT NULL AUTO_INCREMENT, quality_id bigint NOT NULL, indicator_code varchar(32) NOT NULL, value decimal(18,6) NOT NULL, min_value decimal(18,6) NOT NULL, max_value decimal(18,6) NOT NULL, creator varchar(64) DEFAULT NULL, create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, updater varchar(64) DEFAULT NULL, update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, deleted bit NOT NULL DEFAULT 0, PRIMARY KEY(id), UNIQUE KEY uk_quality_indicator(quality_id,indicator_code)
+) ENGINE=InnoDB COMMENT='绉嶅瓙璐ㄦ鎸囨爣缁撴灉';
+CREATE TABLE IF NOT EXISTS mes_qc_seed_quality_source (
+  id bigint NOT NULL AUTO_INCREMENT, quality_id bigint NOT NULL, bag_code_id bigint DEFAULT NULL, bag_code varchar(64) NOT NULL, material_stock_id bigint DEFAULT NULL, quantity decimal(18,6) NOT NULL DEFAULT 0, source_warehouse_id bigint DEFAULT NULL, source_location_id bigint DEFAULT NULL, source_area_id bigint DEFAULT NULL, target_warehouse_id bigint DEFAULT NULL, target_location_id bigint DEFAULT NULL, target_area_id bigint DEFAULT NULL, creator varchar(64) DEFAULT NULL, create_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, updater varchar(64) DEFAULT NULL, update_time datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, deleted bit NOT NULL DEFAULT 0, PRIMARY KEY(id), UNIQUE KEY uk_quality_bag(quality_id,bag_code)
+) ENGINE=InnoDB COMMENT='绉嶅瓙璐ㄦ搴撳瓨琚嬬爜鏉ユ簮鏄庣粏';
+INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name, status, visible, keep_alive, always_show, creator, create_time, updater, update_time, deleted)
+SELECT '绉嶅瓙璐ㄦ', '', 2, 90, 5500, 'seed-quality', 'ep:checked', 'mes/qc/seedQuality/index', 'MesQcSeedQuality', 0, b'1', b'1', b'1', '1', NOW(), '1', NOW(), b'0'
+FROM DUAL
+WHERE NOT EXISTS (SELECT 1 FROM system_menu WHERE parent_id = 5500 AND path = 'seed-quality' AND deleted = 0);
+
+INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, status, visible, keep_alive, always_show, creator, create_time, updater, update_time, deleted)
+SELECT '鎻愪氦璐ㄦ', 'mes:qc-seed-quality:submit', 3, 1, id, '', '', 0, b'1', b'1', b'1', '1', NOW(), '1', NOW(), b'0'
+FROM system_menu
+WHERE parent_id = 5500 AND path = 'seed-quality' AND deleted = 0
+  AND NOT EXISTS (
+    SELECT 1 FROM system_menu child
+    WHERE child.parent_id = system_menu.id
+      AND child.permission = 'mes:qc-seed-quality:submit'
+      AND child.deleted = 0
+  );
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/MesQcSeedQualityController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/MesQcSeedQualityController.java
new file mode 100644
index 0000000..2d35909
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/MesQcSeedQualityController.java
@@ -0,0 +1,22 @@
+package cn.iocoder.yudao.module.mes.controller.admin.qc.seedquality;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.seedquality.vo.MesQcSeedQualitySubmitReqVO;
+import cn.iocoder.yudao.module.mes.service.qc.seedquality.MesQcSeedQualityService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Tag(name = "绠$悊鍚庡彴 - MES 绉嶅瓙璐ㄦ")
+@RestController @RequestMapping("/mes/qc/seed-quality") @Validated
+public class MesQcSeedQualityController {
+    @Resource private MesQcSeedQualityService service;
+    @PostMapping("/submit") @Operation(summary = "鎻愪氦绉嶅瓙璐ㄦ")
+    @PreAuthorize("@ss.hasPermission('mes:qc-seed-quality:submit')")
+    public CommonResult<Long> submit(@Valid @RequestBody MesQcSeedQualitySubmitReqVO reqVO) { return success(service.submit(reqVO)); }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/vo/MesQcSeedQualitySubmitReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/vo/MesQcSeedQualitySubmitReqVO.java
new file mode 100644
index 0000000..d3b0978
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/qc/seedquality/vo/MesQcSeedQualitySubmitReqVO.java
@@ -0,0 +1,22 @@
+package cn.iocoder.yudao.module.mes.controller.admin.qc.seedquality.vo;
+
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.*;
+import lombok.Data;
+import java.math.BigDecimal;
+import java.util.List;
+
+@Data
+public class MesQcSeedQualitySubmitReqVO {
+    @NotBlank private String code;
+    @NotNull private Long itemId;
+    private String batchCode;
+    @NotEmpty @Valid private List<Indicator> indicators;
+    private String reason;
+    @Data public static class Indicator {
+        @NotBlank private String code;
+        @NotNull @DecimalMin("0") private BigDecimal value;
+        @NotNull @DecimalMin("0") private BigDecimal minValue;
+        @NotNull @DecimalMin("0") private BigDecimal maxValue;
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityDO.java
new file mode 100644
index 0000000..0c79b74
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityDO.java
@@ -0,0 +1,20 @@
+package cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.*;
+import java.time.LocalDateTime;
+
+@TableName("mes_qc_seed_quality")
+@KeySequence("mes_qc_seed_quality_seq")
+@Data @EqualsAndHashCode(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor
+public class MesQcSeedQualityDO extends BaseDO {
+    @TableId private Long id;
+    private String code;
+    private Long itemId;
+    private String batchCode;
+    private Integer result;
+    private String reason;
+    private Long inspectorId;
+    private LocalDateTime inspectedAt;
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityIndicatorDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityIndicatorDO.java
new file mode 100644
index 0000000..3a5ba38
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualityIndicatorDO.java
@@ -0,0 +1,18 @@
+package cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.*;
+import java.math.BigDecimal;
+
+@TableName("mes_qc_seed_quality_indicator")
+@KeySequence("mes_qc_seed_quality_indicator_seq")
+@Data @EqualsAndHashCode(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor
+public class MesQcSeedQualityIndicatorDO extends BaseDO {
+    @TableId private Long id;
+    private Long qualityId;
+    private String indicatorCode;
+    private BigDecimal value;
+    private BigDecimal minValue;
+    private BigDecimal maxValue;
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualitySourceDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualitySourceDO.java
new file mode 100644
index 0000000..a68885d
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/qc/seedquality/MesQcSeedQualitySourceDO.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.*;
+import lombok.*;
+import java.math.BigDecimal;
+
+@TableName("mes_qc_seed_quality_source")
+@KeySequence("mes_qc_seed_quality_source_seq")
+@Data @EqualsAndHashCode(callSuper = true) @Builder @NoArgsConstructor @AllArgsConstructor
+public class MesQcSeedQualitySourceDO extends BaseDO {
+    @TableId private Long id;
+    private Long qualityId;
+    private Long bagCodeId;
+    private String bagCode;
+    private Long materialStockId;
+    private BigDecimal quantity;
+    private Long sourceWarehouseId;
+    private Long sourceLocationId;
+    private Long sourceAreaId;
+    private Long targetWarehouseId;
+    private Long targetLocationId;
+    private Long targetAreaId;
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityIndicatorMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityIndicatorMapper.java
new file mode 100644
index 0000000..9732d76
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityIndicatorMapper.java
@@ -0,0 +1,5 @@
+package cn.iocoder.yudao.module.mes.dal.mysql.qc.seedquality;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality.MesQcSeedQualityIndicatorDO;
+import org.apache.ibatis.annotations.Mapper;
+@Mapper public interface MesQcSeedQualityIndicatorMapper extends BaseMapperX<MesQcSeedQualityIndicatorDO> {}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityMapper.java
new file mode 100644
index 0000000..2e1b159
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualityMapper.java
@@ -0,0 +1,13 @@
+package cn.iocoder.yudao.module.mes.dal.mysql.qc.seedquality;
+
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality.MesQcSeedQualityDO;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface MesQcSeedQualityMapper extends BaseMapperX<MesQcSeedQualityDO> {
+    default MesQcSeedQualityDO selectByCode(String code) {
+        return selectOne(new LambdaQueryWrapperX<MesQcSeedQualityDO>().eq(MesQcSeedQualityDO::getCode, code));
+    }
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualitySourceMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualitySourceMapper.java
new file mode 100644
index 0000000..f0e4f29
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/qc/seedquality/MesQcSeedQualitySourceMapper.java
@@ -0,0 +1,11 @@
+package cn.iocoder.yudao.module.mes.dal.mysql.qc.seedquality;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality.MesQcSeedQualitySourceDO;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Update;
+
+@Mapper public interface MesQcSeedQualitySourceMapper extends BaseMapperX<MesQcSeedQualitySourceDO> {
+    @Update("UPDATE mes_qc_seed_quality_source SET deleted = 1, update_time = NOW() WHERE quality_id = #{qualityId} AND deleted = 0")
+    int deleteByQualityId(@Param("qualityId") Long qualityId);
+}
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityService.java
new file mode 100644
index 0000000..8fec7b6
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityService.java
@@ -0,0 +1,3 @@
+package cn.iocoder.yudao.module.mes.service.qc.seedquality;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.seedquality.vo.MesQcSeedQualitySubmitReqVO;
+public interface MesQcSeedQualityService { Long submit(MesQcSeedQualitySubmitReqVO reqVO); }
diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityServiceImpl.java
new file mode 100644
index 0000000..531c3cf
--- /dev/null
+++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/seedquality/MesQcSeedQualityServiceImpl.java
@@ -0,0 +1,42 @@
+package cn.iocoder.yudao.module.mes.service.qc.seedquality;
+
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.mes.controller.admin.qc.seedquality.vo.MesQcSeedQualitySubmitReqVO;
+import cn.iocoder.yudao.module.mes.dal.dataobject.qc.seedquality.*;
+import cn.iocoder.yudao.module.mes.dal.mysql.qc.seedquality.*;
+import jakarta.annotation.Resource;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.annotation.Validated;
+import java.time.LocalDateTime;
+import java.util.*;
+
+@Service @Validated
+public class MesQcSeedQualityServiceImpl implements MesQcSeedQualityService {
+    private static final Set<String> REQUIRED = Set.of("purity", "cleanliness", "germination_rate", "moisture");
+    @Resource private MesQcSeedQualityMapper qualityMapper;
+    @Resource private MesQcSeedQualityIndicatorMapper indicatorMapper;
+
+    @Override @Transactional(rollbackFor = Exception.class)
+    public Long submit(MesQcSeedQualitySubmitReqVO reqVO) {
+        if (reqVO.getIndicators().size() != 4) throw new IllegalArgumentException("蹇呴』鎻愪氦鍥涢」鎸囨爣");
+        if (qualityMapper.selectByCode(reqVO.getCode()) != null) throw new IllegalArgumentException("璇ヨ鐮佸凡璐ㄦ锛岀姝㈤噸澶嶆彁浜�");
+        Set<String> codes = new HashSet<>();
+        boolean passed = true;
+        MesQcSeedQualityDO quality = MesQcSeedQualityDO.builder().code(reqVO.getCode()).itemId(reqVO.getItemId())
+                .batchCode(reqVO.getBatchCode()).reason(reqVO.getReason()).result(0)
+                .inspectedAt(LocalDateTime.now()).build();
+        qualityMapper.insert(quality);
+        for (MesQcSeedQualitySubmitReqVO.Indicator item : reqVO.getIndicators()) {
+            if (!REQUIRED.contains(item.getCode()) || !codes.add(item.getCode())) throw new IllegalArgumentException("鎸囨爣蹇呴』涓虹函搴︺�佸噣搴︺�佸彂鑺界巼銆佹按鍒嗕笖涓嶅彲閲嶅");
+            if (item.getMinValue().compareTo(item.getMaxValue()) > 0 || item.getValue().compareTo(item.getMinValue()) < 0 || item.getValue().compareTo(item.getMaxValue()) > 0) passed = false;
+            indicatorMapper.insert(MesQcSeedQualityIndicatorDO.builder().qualityId(quality.getId()).indicatorCode(item.getCode())
+                    .value(item.getValue()).minValue(item.getMinValue()).maxValue(item.getMaxValue()).build());
+        }
+        if (!codes.equals(REQUIRED)) throw new IllegalArgumentException("鍥涢」鎸囨爣涓嶅畬鏁�");
+        quality.setResult(passed ? 1 : 2);
+        qualityMapper.updateById(quality);
+        // 搴撲綅鐢卞悗鍙伴厤缃湇鍔℃帴绠★紝褰撳墠鐗堟湰淇濈暀瀹¤闂幆锛岀姝㈠墠绔紶鍏ュ簱浣嶃��
+        return quality.getId();
+    }
+}

--
Gitblit v1.9.3