From 423ac2a5e7e451248d8cdfc2cda3f32dba0ec8f8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 11 三月 2026 17:59:52 +0800
Subject: [PATCH] feat: 生产计划关联物料信息表
---
src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java | 8 ++++++++
src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java | 19 ++++++++++++++++++-
doc/宁夏-中盛建材.sql | 9 ++++++++-
src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml | 1 +
src/main/java/com/ruoyi/production/pojo/ProductMaterial.java | 3 ---
src/main/resources/mapper/production/ProductMaterialMapper.xml | 5 ++---
6 files changed, 37 insertions(+), 8 deletions(-)
diff --git "a/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql" "b/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql"
index 6823bce..9c16abe 100644
--- "a/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql"
+++ "b/doc/\345\256\201\345\244\217-\344\270\255\347\233\233\345\273\272\346\235\220.sql"
@@ -142,4 +142,11 @@
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,
`config_type` varchar(50) NOT NULL COMMENT '鍖哄垎绫诲瀷: MATERIAL_TYPE 鎴� INVENTORY_CAT',
`config_name` varchar(100) NOT NULL COMMENT '鏄剧ず鐨勫悕绉�'
-) ENGINE = InnoDB COMMENT ='鐗╂枡淇℃伅琛ㄩ厤缃〃';
\ No newline at end of file
+) ENGINE = InnoDB COMMENT ='鐗╂枡淇℃伅琛ㄩ厤缃〃';
+
+ALTER TABLE `production_plan`
+ ADD COLUMN `product_material_id` int DEFAULT NULL COMMENT '鍏宠仈鐗╂枡淇℃伅琛↖D' AFTER `material_code`;
+
+-- 寤鸿椤轰究鍔犱笂绱㈠紩锛屾彁鍗囧叧鑱旀煡璇㈤�熷害
+ALTER TABLE `production_plan`
+ ADD INDEX `idx_product_material_id` (`product_material_id`);
\ No newline at end of file
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java b/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
index 65f8a85..ee51416 100644
--- a/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
+++ b/src/main/java/com/ruoyi/production/pojo/ProductMaterial.java
@@ -43,9 +43,6 @@
@ApiModelProperty("鐗╂枡浠g爜")
private String materialCode;
- @ApiModelProperty("浜у搧鍚嶇О")
- private String productName;
-
@ApiModelProperty("鐗╂枡鍝佸悕")
private String materialName;
diff --git a/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java b/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java
index 2273b1f..8ecf1e8 100644
--- a/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java
+++ b/src/main/java/com/ruoyi/productionPlan/pojo/ProductionPlan.java
@@ -65,6 +65,13 @@
@Excel(name = "鐗╂枡缂栫爜")
private String materialCode;
+
+ /**
+ * 鍏宠仈鐗╂枡淇℃伅琛↖D
+ */
+ @ApiModelProperty("鍏宠仈鐗╂枡淇℃伅琛↖D")
+ private Integer productMaterialId;
+
/**
* 浜у搧鍚嶇О
*/
@@ -233,6 +240,7 @@
/**
* 璁$畻鍓╀綑鏂规暟
+ *
* @return 鍓╀綑鏂规暟
*/
@ApiModelProperty(value = "鍓╀綑鏂规暟")
diff --git a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
index 1b21552..6025b24 100644
--- a/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/ruoyi/productionPlan/service/impl/ProductionPlanServiceImpl.java
@@ -15,7 +15,9 @@
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.config.AliDingConfig;
+import com.ruoyi.production.pojo.ProductMaterial;
import com.ruoyi.production.pojo.ProductOrder;
+import com.ruoyi.production.service.ProductMaterialService;
import com.ruoyi.production.service.ProductOrderService;
import com.ruoyi.productionPlan.dto.ProductionPlanDto;
import com.ruoyi.productionPlan.dto.ProductionPlanImportDto;
@@ -68,6 +70,9 @@
@Autowired
private ProductOrderPlanMapper productOrderPlanMapper;
+
+ @Autowired
+ private ProductMaterialService productMaterialService;
/**
* 鍚屾閿侊紝纭繚鎵嬪姩鍜屽畾鏃朵换鍔′笉鍚屾椂鎵ц
@@ -380,7 +385,19 @@
plan.setApplyNo(formData.getString("textField_l7fytfco"));
plan.setCustomerName(formData.getString("textField_lbkozohg"));
- plan.setMaterialCode(row.getString("textField_l9xo62q5"));
+ String materialCode = row.getString("textField_l9xo62q5");
+ plan.setMaterialCode(materialCode);
+
+ // 鏍规嵁鐗╂枡缂栫爜鏌ヨ鐗╂枡淇℃伅琛紝鍏宠仈鐗╂枡ID
+ if (StringUtils.isNotEmpty(materialCode)) {
+ LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(ProductMaterial::getMaterialCode, materialCode);
+ ProductMaterial productMaterial = productMaterialService.getOne(queryWrapper);
+ if (productMaterial != null) {
+ plan.setProductMaterialId(productMaterial.getId());
+ }
+ }
+
plan.setProductName(row.getString("textField_l9xo62q7"));
plan.setProductSpec(row.getString("textField_l9xo62q8"));
plan.setLength(row.getInteger("numberField_lb7lgatg_value"));
diff --git a/src/main/resources/mapper/production/ProductMaterialMapper.xml b/src/main/resources/mapper/production/ProductMaterialMapper.xml
index 32c1ba1..84d8ca4 100644
--- a/src/main/resources/mapper/production/ProductMaterialMapper.xml
+++ b/src/main/resources/mapper/production/ProductMaterialMapper.xml
@@ -6,11 +6,10 @@
<resultMap id="ProductMaterialResultMap" type="com.ruoyi.production.pojo.ProductMaterial">
<id property="id" column="id"/>
<result property="tenantId" column="tenant_id"/>
- <result property="materialType" column="material_type"/>
- <result property="inventoryCategory" column="inventory_category"/>
+ <result property="materialTypeId" column="material_type_id"/>
+ <result property="inventoryCategoryId" column="inventory_category_id"/>
<result property="identifierCode" column="identifier_code"/>
<result property="materialCode" column="material_code"/>
- <result property="productName" column="product_name"/>
<result property="materialName" column="material_name"/>
<result property="specification" column="specification"/>
<result property="baseUnit" column="base_unit"/>
diff --git a/src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml b/src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml
index b4bea0a..43df1a5 100644
--- a/src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml
+++ b/src/main/resources/mapper/productionPlan/ProductionPlanMapper.xml
@@ -12,6 +12,7 @@
<result property="applyNo" column="apply_no"/>
<result property="customerName" column="customer_name"/>
<result property="materialCode" column="material_code"/>
+ <result property="productMaterialId" column="product_material_id"/>
<result property="productName" column="product_name"/>
<result property="productSpec" column="product_spec"/>
<result property="length" column="length"/>
--
Gitblit v1.9.3