From 2c4bc1808f272b7d7282d1b8ba416d606ebc7df5 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期五, 18 九月 2026 15:25:31 +0800
Subject: [PATCH] refactor(生产核算): 成品/白盒归属改为按工序指定
---
/dev/null | 13 --
src/main/java/com/ruoyi/production/mapper/ProductionCostingProcessMapper.java | 20 +++
src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java | 22 +-
src/main/resources/mapper/production/ProductionCostingMapper.xml | 8
src/main/java/com/ruoyi/production/service/ProductionCostingService.java | 12 +-
sql/production_costing_config.sql | 188 ++++++++++++++++++------------
src/main/java/com/ruoyi/production/pojo/ProductionCostingProcess.java | 18 +-
src/main/resources/mapper/production/ProductionCostingProcessMapper.xml | 24 ++++
src/main/java/com/ruoyi/production/controller/ProductionCostingController.java | 42 +++---
9 files changed, 206 insertions(+), 141 deletions(-)
diff --git a/sql/production_costing_config.sql b/sql/production_costing_config.sql
index b386772..a1a029b 100644
--- a/sql/production_costing_config.sql
+++ b/sql/production_costing_config.sql
@@ -1,46 +1,63 @@
-- ============================================================
--- 鐢熶骇鏍哥畻锛堟垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛夐厤缃笌缁撴瀯琛ュ厖鑴氭湰
--- 鏁版嵁搴擄細product-inventory-management-new-pro
--- 璇存槑锛氭湰鍦板簱缁撴瀯钀藉悗浜庝唬鐮侊紝production_product_main 缂哄皯
--- 鎶ュ伐缁撴灉/瀹℃牳鐩稿叧鍒楋紝杩欓噷琛ラ綈锛涘苟鏂板鏍哥畻閰嶇疆琛ㄤ笌婕旂ず鏁版嵁銆�
+-- 鐢熶骇鏍哥畻锛堟垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛夋暟鎹簱鑴氭湰
+-- 鐩爣搴擄細product-inventory-management-new-pro锛堟寜瀹為檯鐜鏇挎崲锛�
+-- 璇存槑锛�
+-- 绗� 1 閮ㄥ垎锛氱粨鏋勫彉鏇达紙琛ュ垪 + 鏂板缓閰嶇疆琛級鈥斺�� 蹇呴』鎵ц锛屽箓绛夊彲閲嶅鎵ц
+-- 绗� 2 閮ㄥ垎锛氭紨绀烘暟鎹� 鈥斺�� 鍙�夛紝浠呯敤浜庢湰鍦�/婕旂ず鐜锛屾寮忕幆澧冭鍕挎墽琛屾垨鎸夐渶璋冩暣
+-- 鎴愬搧/鐧界洅 鐨勫綊灞烇細鍦ㄣ�愬伐搴忕被鍨嬮厤缃�戦噷鐩存帴鎶婃煇涓伐搴忔寚瀹氫负 鎴愬搧 鎴� 鐧界洅
+-- 锛�1=鎴愬搧閮ㄩ棬锛�2=鐧界洅閮ㄩ棬锛�
-- ============================================================
SET NAMES utf8mb4;
--- ------------------------------------------------------------
--- 1. 琛ュ厖 production_product_main 缂哄け鍒楋紙鎶ュ伐缁撴灉 / 瀹℃牳 / 琛ヤ慨鐞嗗伐鏃讹級
--- ------------------------------------------------------------
-ALTER TABLE `production_product_main`
- ADD COLUMN `report_type` int NULL COMMENT '鎶ュ伐缁撴灉绫诲瀷锛�0鍚堟牸锛�1杞诲井杩斿伐锛�2涓ラ噸杩斿伐锛�3鎶ュ簾' AFTER `status`,
- ADD COLUMN `audit_status` int NULL DEFAULT 1 COMMENT '瀹℃牳鐘舵�侊細0寰呭鏍革紝1瀹℃牳閫氳繃锛�2瀹℃牳涓嶉�氳繃' AFTER `report_type`,
- ADD COLUMN `audit_remark` varchar(255) NULL COMMENT '瀹℃牳鎰忚' AFTER `audit_status`,
- ADD COLUMN `repair_work_hour` decimal(10,2) NULL DEFAULT 0 COMMENT '琛ヤ慨鐞嗗伐鏃�' AFTER `work_hour`;
+/* ============================================================
+ * 绗� 1 閮ㄥ垎锛氱粨鏋勫彉鏇达紙蹇呴』鎵ц锛�
+ * ============================================================ */
--- 宸插瓨鍦ㄦ姤宸ユ暟鎹粯璁よ涓猴細瀹℃牳閫氳繃銆佸悎鏍�
+-- 1.1 琛ラ綈 production_product_main 缂哄け鍒�
+SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='production_product_main' AND COLUMN_NAME='report_type');
+SET @s := IF(@c=0, 'ALTER TABLE `production_product_main` ADD COLUMN `report_type` int NULL COMMENT ''鎶ュ伐缁撴灉绫诲瀷锛�0鍚堟牸锛�1杞诲井杩斿伐锛�2涓ラ噸杩斿伐锛�3鎶ュ簾'' AFTER `status`', 'DO 0');
+PREPARE st FROM @s; EXECUTE st; DEALLOCATE PREPARE st;
+
+SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='production_product_main' AND COLUMN_NAME='audit_status');
+SET @s := IF(@c=0, 'ALTER TABLE `production_product_main` ADD COLUMN `audit_status` int NULL DEFAULT 1 COMMENT ''瀹℃牳鐘舵�侊細0寰呭鏍革紝1瀹℃牳閫氳繃锛�2瀹℃牳涓嶉�氳繃'' AFTER `report_type`', 'DO 0');
+PREPARE st FROM @s; EXECUTE st; DEALLOCATE PREPARE st;
+
+SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='production_product_main' AND COLUMN_NAME='audit_remark');
+SET @s := IF(@c=0, 'ALTER TABLE `production_product_main` ADD COLUMN `audit_remark` varchar(255) NULL COMMENT ''瀹℃牳鎰忚'' AFTER `audit_status`', 'DO 0');
+PREPARE st FROM @s; EXECUTE st; DEALLOCATE PREPARE st;
+
+SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='production_product_main' AND COLUMN_NAME='repair_work_hour');
+SET @s := IF(@c=0, 'ALTER TABLE `production_product_main` ADD COLUMN `repair_work_hour` decimal(10,2) NULL DEFAULT 0 COMMENT ''琛ヤ慨鐞嗗伐鏃�'' AFTER `work_hour`', 'DO 0');
+PREPARE st FROM @s; EXECUTE st; DEALLOCATE PREPARE st;
+
+-- 1.2 琛ラ綈 product 缂哄け鍒� standard_quantity
+SET @c := (SELECT COUNT(*) FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME='product' AND COLUMN_NAME='standard_quantity');
+SET @s := IF(@c=0, 'ALTER TABLE `product` ADD COLUMN `standard_quantity` decimal(18,4) NULL COMMENT ''鏍囧噯鏁伴噺'' AFTER `product_name`', 'DO 0');
+PREPARE st FROM @s; EXECUTE st; DEALLOCATE PREPARE st;
+
+-- 1.3 宸插瓨鍦ㄦ姤宸ユ暟鎹粯璁わ細瀹℃牳閫氳繃銆佸悎鏍�
UPDATE `production_product_main` SET `report_type` = 0 WHERE `report_type` IS NULL;
UPDATE `production_product_main` SET `audit_status` = 1 WHERE `audit_status` IS NULL;
--- ------------------------------------------------------------
--- 2. 鏂板鏍哥畻閰嶇疆琛�
--- ------------------------------------------------------------
-DROP TABLE IF EXISTS `production_costing_dept`;
-CREATE TABLE `production_costing_dept` (
+-- 1.4 鏂板缓鏍哥畻閰嶇疆琛�
+CREATE TABLE IF NOT EXISTS `production_costing_process` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
- `dept_id` bigint NULL COMMENT '閮ㄩ棬ID(sys_dept.dept_id)',
- `dept_type` int NULL COMMENT '閮ㄩ棬绫诲瀷锛�1鎴愬搧閮ㄩ棬锛�2鐧界洅閮ㄩ棬',
+ `process_id` bigint NULL COMMENT '宸ュ簭ID(technology_operation.id)',
+ `dept_type` int NULL COMMENT '绫诲瀷锛�1鎴愬搧閮ㄩ棬锛�2鐧界洅閮ㄩ棬',
`remark` varchar(255) NULL COMMENT '澶囨敞',
`create_user` bigint NULL COMMENT '鍒涘缓浜�',
`create_time` datetime NULL COMMENT '鍒涘缓鏃堕棿',
`update_user` bigint NULL COMMENT '淇敼浜�',
`update_time` datetime NULL COMMENT '淇敼鏃堕棿',
- PRIMARY KEY (`id`)
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆';
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_process` (`process_id`)
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆';
-DROP TABLE IF EXISTS `production_costing_standard`;
-CREATE TABLE `production_costing_standard` (
+CREATE TABLE IF NOT EXISTS `production_costing_standard` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
- `dept_type` int NULL COMMENT '閮ㄩ棬绫诲瀷锛�1鎴愬搧锛�2鐧界洅',
- `process_id` bigint NULL COMMENT '宸ュ簭ID(technology_operation.id)',
- `product_model_id` bigint NULL COMMENT '鍨嬪彿ID(product_model.id)锛岀櫧鐩掑繀濉�',
+ `dept_type` int NULL COMMENT '绫诲瀷锛�1鎴愬搧锛�2鐧界洅',
+ `process_id` bigint NULL COMMENT '宸ュ簭ID',
+ `product_model_id` bigint NULL COMMENT '鍨嬪彿ID锛岀櫧鐩掑繀濉�',
`standard_quantity` decimal(18,4) NULL COMMENT '鏍囧噯鏁伴噺',
`unit` varchar(50) NULL COMMENT '鍗曚綅',
`remark` varchar(255) NULL COMMENT '澶囨敞',
@@ -48,14 +65,14 @@
`create_time` datetime NULL COMMENT '鍒涘缓鏃堕棿',
`update_user` bigint NULL COMMENT '淇敼浜�',
`update_time` datetime NULL COMMENT '淇敼鏃堕棿',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_std` (`dept_type`, `process_id`, `product_model_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆';
-DROP TABLE IF EXISTS `production_costing_factor`;
-CREATE TABLE `production_costing_factor` (
+CREATE TABLE IF NOT EXISTS `production_costing_factor` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
- `process_id` bigint NULL COMMENT '宸ュ簭ID(technology_operation.id)',
- `staff_id` bigint NULL COMMENT '鍛樺伐ID(sys_user.user_id)',
+ `process_id` bigint NULL COMMENT '宸ュ簭ID',
+ `staff_id` bigint NULL COMMENT '鍛樺伐ID',
`staff_name` varchar(255) NULL COMMENT '鍛樺伐濮撳悕',
`violin_factor` decimal(18,4) NULL DEFAULT 1 COMMENT '灏忔彁鐞存姌绠楃巼(鍩哄噯)',
`viola_factor` decimal(18,4) NULL COMMENT '澶ф彁鐞存姌绠楃巼',
@@ -65,66 +82,83 @@
`create_time` datetime NULL COMMENT '鍒涘缓鏃堕棿',
`update_user` bigint NULL COMMENT '淇敼浜�',
`update_time` datetime NULL COMMENT '淇敼鏃堕棿',
- PRIMARY KEY (`id`)
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_factor` (`process_id`, `staff_id`)
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃�(宸ュ簭+鍛樺伐)';
--- ------------------------------------------------------------
--- 3. 婕旂ず鏁版嵁锛堜究浜庢湰鍦版煡鐪嬫晥鏋滐級
--- ------------------------------------------------------------
--- 3.1 鏂板閮ㄩ棬锛氭垚鍝侀儴闂� / 鐧界洅閮ㄩ棬
-INSERT INTO `sys_dept` (`dept_id`, `parent_id`, `ancestors`, `dept_name`, `order_num`, `status`, `del_flag`, `create_by`, `create_time`)
-VALUES (220, 100, '0,100', '鎴愬搧閮ㄩ棬', 1, '0', '0', 'admin', NOW()),
- (221, 100, '0,100', '鐧界洅閮ㄩ棬', 2, '0', '0', 'admin', NOW());
+CREATE TABLE IF NOT EXISTS `production_costing_workday` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
+ `work_month` varchar(7) NULL COMMENT '骞存湀 yyyy-MM',
+ `work_days` int NULL COMMENT '褰撴湀宸ヤ綔鏃ュぉ鏁�',
+ `remark` varchar(255) NULL COMMENT '澶囨敞',
+ `create_user` bigint NULL COMMENT '鍒涘缓浜�',
+ `create_time` datetime NULL COMMENT '鍒涘缓鏃堕棿',
+ `update_user` bigint NULL COMMENT '淇敼浜�',
+ `update_time` datetime NULL COMMENT '淇敼鏃堕棿',
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `uk_work_month` (`work_month`)
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃�';
--- 3.2 鎶婃紨绀哄伐搴忓綊鍏ュ搴旈儴闂紙鎴愬搧锛氬喎宸ヨ壓27/纭寲28锛涚櫧鐩掞細鏀剁嚎25/鍒囧壊2锛�
-UPDATE `technology_operation` SET `dept_id` = 220 WHERE `id` IN (27, 28);
-UPDATE `technology_operation` SET `dept_id` = 221 WHERE `id` IN (2, 25);
+/* ============================================================
+ * 绗� 2 閮ㄥ垎锛氭紨绀烘暟鎹紙鍙�夛紝浠呮湰鍦�/婕旂ず鐜锛�
+ * ============================================================ */
--- 3.3 閮ㄩ棬绫诲瀷閰嶇疆
-INSERT INTO `production_costing_dept` (`dept_id`, `dept_type`, `remark`, `create_time`)
-VALUES (220, 1, '鎴愬搧閮ㄩ棬', NOW()),
- (221, 2, '鐧界洅閮ㄩ棬', NOW());
+-- 2.1 宸ュ簭绫诲瀷閰嶇疆锛堟垚鍝侊細鍐峰伐鑹�27/纭寲28锛涚櫧鐩掞細鍒囧壊2/鏀剁嚎25锛�
+INSERT INTO `production_costing_process` (`process_id`, `dept_type`, `remark`, `create_time`)
+SELECT 27, 1, '鍐峰伐鑹�-鎴愬搧', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_process` WHERE `process_id`=27);
+INSERT INTO `production_costing_process` (`process_id`, `dept_type`, `remark`, `create_time`)
+SELECT 28, 1, '纭寲-鎴愬搧', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_process` WHERE `process_id`=28);
+INSERT INTO `production_costing_process` (`process_id`, `dept_type`, `remark`, `create_time`)
+SELECT 2, 2, '鍒囧壊-鐧界洅', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_process` WHERE `process_id`=2);
+INSERT INTO `production_costing_process` (`process_id`, `dept_type`, `remark`, `create_time`)
+SELECT 25, 2, '鏀剁嚎-鐧界洅', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_process` WHERE `process_id`=25);
--- 3.4 鏍囧噯鏁伴噺閰嶇疆
--- 鎴愬搧锛氭寜宸ュ簭
--- 鐧界洅锛氭寜宸ュ簭 + 鍨嬪彿
+-- 2.2 鏍囧噯鏁伴噺閰嶇疆锛堟垚鍝侊細鎸夊伐搴忥紱鐧界洅锛氭寜宸ュ簭+鍨嬪彿锛�
INSERT INTO `production_costing_standard` (`dept_type`, `process_id`, `product_model_id`, `standard_quantity`, `unit`, `remark`, `create_time`)
-VALUES (1, 27, NULL, 10, 'm', '鍐峰伐鑹烘爣鍑嗘暟閲�', NOW()),
- (1, 28, NULL, 20, 'm', '纭寲鏍囧噯鏁伴噺', NOW()),
- (2, 25, 251, 5, 'kg/km', '鏀剁嚎-閾濆悎閲戠嚎', NOW()),
- (2, 25, 256, 2, 'm', '鏀剁嚎-閾濆悎閲戠粸绾�', NOW()),
- (2, 2, 246, 4, 'kg/km', '鍒囧壊-閾濆悎閲戠嚎', NOW());
+SELECT 1, 27, NULL, 10, 'm', '鍐峰伐鑹烘爣鍑嗘暟閲�', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_standard` WHERE `dept_type`=1 AND `process_id`=27 AND `product_model_id` IS NULL);
+INSERT INTO `production_costing_standard` (`dept_type`, `process_id`, `product_model_id`, `standard_quantity`, `unit`, `remark`, `create_time`)
+SELECT 1, 28, NULL, 20, 'm', '纭寲鏍囧噯鏁伴噺', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_standard` WHERE `dept_type`=1 AND `process_id`=28 AND `product_model_id` IS NULL);
+INSERT INTO `production_costing_standard` (`dept_type`, `process_id`, `product_model_id`, `standard_quantity`, `unit`, `remark`, `create_time`)
+SELECT 2, 25, 251, 5, 'kg/km', '鏀剁嚎-閾濆悎閲戠嚎', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_standard` WHERE `dept_type`=2 AND `process_id`=25 AND `product_model_id`=251);
+INSERT INTO `production_costing_standard` (`dept_type`, `process_id`, `product_model_id`, `standard_quantity`, `unit`, `remark`, `create_time`)
+SELECT 2, 25, 256, 2, 'm', '鏀剁嚎-閾濆悎閲戠粸绾�', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_standard` WHERE `dept_type`=2 AND `process_id`=25 AND `product_model_id`=256);
+INSERT INTO `production_costing_standard` (`dept_type`, `process_id`, `product_model_id`, `standard_quantity`, `unit`, `remark`, `create_time`)
+SELECT 2, 2, 246, 4, 'kg/km', '鍒囧壊-閾濆悎閲戠嚎', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_standard` WHERE `dept_type`=2 AND `process_id`=2 AND `product_model_id`=246);
--- 3.5 鎶樼畻鐜囬厤缃紙宸ュ簭 + 鍛樺伐锛�
+-- 2.3 鎶樼畻鐜囬厤缃紙宸ュ簭+鍛樺伐锛�
INSERT INTO `production_costing_factor` (`process_id`, `staff_id`, `staff_name`, `violin_factor`, `viola_factor`, `bass_factor`, `remark`, `create_time`)
-VALUES (27, 1, '绠$悊鍛樿处鍙�', 1, 3, 6, '鍐峰伐鑹�-鎶樼畻鐜�', NOW()),
- (28, 1, '绠$悊鍛樿处鍙�', 1, 2, 4, '纭寲-鎶樼畻鐜�', NOW());
+SELECT 27, 1, '绠$悊鍛樿处鍙�', 1, 3, 6, '鍐峰伐鑹�-鎶樼畻鐜�', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_factor` WHERE `process_id`=27 AND `staff_id`=1);
+INSERT INTO `production_costing_factor` (`process_id`, `staff_id`, `staff_name`, `violin_factor`, `viola_factor`, `bass_factor`, `remark`, `create_time`)
+SELECT 28, 1, '绠$悊鍛樿处鍙�', 1, 2, 4, '纭寲-鎶樼畻鐜�', NOW() WHERE NOT EXISTS (SELECT 1 FROM `production_costing_factor` WHERE `process_id`=28 AND `staff_id`=1);
--- 3.6 涔愬櫒婕旂ず鏁版嵁锛堝皬鎻愮惔/澶ф彁鐞�/璐濇柉锛夛紝鐢ㄤ簬灞曠ず鎴愬搧閮ㄩ棬鎶樼畻鏁堟灉
+-- 2.4 涔愬櫒婕旂ず鏁版嵁锛堝皬鎻愮惔/澶ф彁鐞�/璐濇柉锛�+ 鎶ュ伐閾�
INSERT INTO `product` (`id`, `parent_id`, `product_name`, `create_user`, `dept_id`)
-VALUES (510, 276, '灏忔彁鐞�', 1, 220),
- (511, 276, '澶ф彁鐞�', 1, 220),
- (512, 276, '璐濇柉', 1, 220);
+SELECT 510, 276, '灏忔彁鐞�', 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `product` WHERE `id` = 510);
+INSERT INTO `product` (`id`, `parent_id`, `product_name`, `create_user`, `dept_id`)
+SELECT 511, 276, '澶ф彁鐞�', 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `product` WHERE `id` = 511);
+INSERT INTO `product` (`id`, `parent_id`, `product_name`, `create_user`, `dept_id`)
+SELECT 512, 276, '璐濇柉', 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `product` WHERE `id` = 512);
INSERT INTO `product_model` (`id`, `product_id`, `model`, `unit`, `create_user`, `dept_id`)
-VALUES (5001, 510, 'VIOLIN-STD', '鎶�', 1, 220),
- (5002, 511, 'CELLO-STD', '鎶�', 1, 220),
- (5003, 512, 'BASS-STD', '鎶�', 1, 220);
+SELECT 5001, 510, 'VIOLIN-STD', '鎶�', 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `product_model` WHERE `id` = 5001);
+INSERT INTO `product_model` (`id`, `product_id`, `model`, `unit`, `create_user`, `dept_id`)
+SELECT 5002, 511, 'CELLO-STD', '鎶�', 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `product_model` WHERE `id` = 5002);
+INSERT INTO `product_model` (`id`, `product_id`, `model`, `unit`, `create_user`, `dept_id`)
+SELECT 5003, 512, 'BASS-STD', '鎶�', 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `product_model` WHERE `id` = 5003);
--- 鎶ュ伐閾撅細璁㈠崟 -> 宸ヨ壓璺嚎宸ュ簭 -> 宸ュ崟 -> 鎶ュ伐 -> 浜у嚭
INSERT INTO `production_order` (`id`, `product_model_id`, `technology_routing_id`, `nps_no`, `quantity`, `create_user`, `dept_id`)
-VALUES (5000, 5001, 0, 'DEMO-ORDER-1', 100, 1, 220);
-
+SELECT 5000, 5001, 0, 'DEMO-ORDER-1', 100, 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `production_order` WHERE `id` = 5000);
INSERT INTO `production_order_routing_operation` (`id`, `production_order_id`, `technology_routing_operation_id`, `technology_operation_id`, `operation_name`, `product_model_id`, `type`, `create_user`, `dept_id`)
-VALUES (5000, 5000, 0, 27, '鍐峰伐鑹�', 5001, 1, 1, 220);
-
+SELECT 5000, 5000, 0, 27, '鍐峰伐鑹�', 5001, 1, 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `production_order_routing_operation` WHERE `id` = 5000);
INSERT INTO `production_operation_task` (`id`, `production_order_routing_operation_id`, `technology_routing_operation_id`, `work_order_no`, `status`, `production_order_id`, `create_user`, `dept_id`)
-VALUES (5000, 5000, 0, 'DEMO-WO-1', 4, 5000, 1, 220);
-
+SELECT 5000, 5000, 0, 'DEMO-WO-1', 4, 5000, 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `production_operation_task` WHERE `id` = 5000);
INSERT INTO `production_product_main` (`id`, `product_no`, `user_id`, `user_name`, `production_operation_task_id`, `status`, `dept_id`, `create_time`, `create_user`, `report_type`, `audit_status`)
-VALUES (5000, 'BG-DEMO-001', 1, '绠$悊鍛樿处鍙�', 5000, 4, 220, '2026-09-15 10:00:00', 1, 0, 1);
-
+SELECT 5000, 'BG-DEMO-001', 1, '绠$悊鍛樿处鍙�', 5000, 4, 100, '2026-09-15 10:00:00', 1, 0, 1 WHERE NOT EXISTS (SELECT 1 FROM `production_product_main` WHERE `id` = 5000);
INSERT INTO `production_product_output` (`production_product_main_id`, `product_model_id`, `quantity`, `scrap_qty`, `create_user`, `dept_id`)
-VALUES (5000, 5001, 20, 0, 1, 220),
- (5000, 5002, 10, 0, 1, 220),
- (5000, 5003, 5, 0, 1, 220);
+SELECT 5000, 5001, 20, 0, 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `production_product_output` WHERE `production_product_main_id` = 5000 AND `product_model_id` = 5001);
+INSERT INTO `production_product_output` (`production_product_main_id`, `product_model_id`, `quantity`, `scrap_qty`, `create_user`, `dept_id`)
+SELECT 5000, 5002, 10, 0, 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `production_product_output` WHERE `production_product_main_id` = 5000 AND `product_model_id` = 5002);
+INSERT INTO `production_product_output` (`production_product_main_id`, `product_model_id`, `quantity`, `scrap_qty`, `create_user`, `dept_id`)
+SELECT 5000, 5003, 5, 0, 1, 100 WHERE NOT EXISTS (SELECT 1 FROM `production_product_output` WHERE `production_product_main_id` = 5000 AND `product_model_id` = 5003);
+
+SELECT '鐢熶骇鏍哥畻鏁版嵁搴撹剼鏈墽琛屽畬鎴�' AS result_message;
diff --git a/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java b/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java
index 7394c0c..af48b34 100644
--- a/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java
+++ b/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java
@@ -7,7 +7,7 @@
import com.ruoyi.production.bean.dto.ProductionCostingQueryDto;
import com.ruoyi.production.bean.vo.ProductionCostingDetailVo;
import com.ruoyi.production.bean.vo.ProductionCostingSummaryVo;
-import com.ruoyi.production.pojo.ProductionCostingDept;
+import com.ruoyi.production.pojo.ProductionCostingProcess;
import com.ruoyi.production.pojo.ProductionCostingFactor;
import com.ruoyi.production.pojo.ProductionCostingStandard;
import com.ruoyi.production.pojo.ProductionCostingWorkday;
@@ -67,33 +67,33 @@
util.exportExcel(response, productionCostingService.detailList(dto), "鐢熶骇鏍哥畻鏄庣粏");
}
- /* ---------------- 閮ㄩ棬绫诲瀷閰嶇疆 ---------------- */
+ /* ---------------- 宸ュ簭绫诲瀷閰嶇疆 ---------------- */
- @GetMapping("/dept/list")
- @Operation(summary = "閮ㄩ棬绫诲瀷閰嶇疆鍒楄〃")
- public R<List<ProductionCostingDept>> deptList() {
- return R.ok(productionCostingService.listDept());
+ @GetMapping("/process/list")
+ @Operation(summary = "宸ュ簭绫诲瀷閰嶇疆鍒楄〃")
+ public R<List<ProductionCostingProcess>> processList(ProductionCostingProcess query) {
+ return R.ok(productionCostingService.listProcess(query));
}
- @PostMapping("/dept")
- @Log(title = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆鏂板", businessType = BusinessType.INSERT)
- @Operation(summary = "鏂板閮ㄩ棬绫诲瀷閰嶇疆")
- public R<Boolean> deptAdd(@RequestBody ProductionCostingDept dept) {
- return R.ok(productionCostingService.saveDept(dept));
+ @PostMapping("/process")
+ @Log(title = "鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆鏂板", businessType = BusinessType.INSERT)
+ @Operation(summary = "鏂板宸ュ簭绫诲瀷閰嶇疆")
+ public R<Boolean> processAdd(@RequestBody ProductionCostingProcess process) {
+ return R.ok(productionCostingService.saveProcess(process));
}
- @PutMapping("/dept")
- @Log(title = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆淇敼", businessType = BusinessType.UPDATE)
- @Operation(summary = "淇敼閮ㄩ棬绫诲瀷閰嶇疆")
- public R<Boolean> deptEdit(@RequestBody ProductionCostingDept dept) {
- return R.ok(productionCostingService.updateDept(dept));
+ @PutMapping("/process")
+ @Log(title = "鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆淇敼", businessType = BusinessType.UPDATE)
+ @Operation(summary = "淇敼宸ュ簭绫诲瀷閰嶇疆")
+ public R<Boolean> processEdit(@RequestBody ProductionCostingProcess process) {
+ return R.ok(productionCostingService.updateProcess(process));
}
- @DeleteMapping("/dept/{id}")
- @Log(title = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆鍒犻櫎", businessType = BusinessType.DELETE)
- @Operation(summary = "鍒犻櫎閮ㄩ棬绫诲瀷閰嶇疆")
- public R<Boolean> deptRemove(@PathVariable Long id) {
- return R.ok(productionCostingService.removeDept(id));
+ @DeleteMapping("/process/{id}")
+ @Log(title = "鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆鍒犻櫎", businessType = BusinessType.DELETE)
+ @Operation(summary = "鍒犻櫎宸ュ簭绫诲瀷閰嶇疆")
+ public R<Boolean> processRemove(@PathVariable Long id) {
+ return R.ok(productionCostingService.removeProcess(id));
}
/* ---------------- 鏍囧噯鏁伴噺閰嶇疆 ---------------- */
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java
deleted file mode 100644
index 7310d85..0000000
--- a/src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.ruoyi.production.mapper;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.ruoyi.production.pojo.ProductionCostingDept;
-import org.apache.ibatis.annotations.Mapper;
-
-import java.util.List;
-
-/**
- * 鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆 Mapper
- */
-@Mapper
-public interface ProductionCostingDeptMapper extends BaseMapper<ProductionCostingDept> {
-
- /**
- * 鏌ヨ閮ㄩ棬绫诲瀷閰嶇疆锛堝惈閮ㄩ棬鍚嶇О锛�
- */
- List<ProductionCostingDept> selectDeptConfigs();
-}
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductionCostingProcessMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingProcessMapper.java
new file mode 100644
index 0000000..83edf1f
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/mapper/ProductionCostingProcessMapper.java
@@ -0,0 +1,20 @@
+package com.ruoyi.production.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.production.pojo.ProductionCostingProcess;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆 Mapper
+ */
+@Mapper
+public interface ProductionCostingProcessMapper extends BaseMapper<ProductionCostingProcess> {
+
+ /**
+ * 鏌ヨ宸ュ簭绫诲瀷閰嶇疆鍒楄〃锛堝惈宸ュ簭鍚嶇О锛�
+ */
+ List<ProductionCostingProcess> selectProcessList(@Param("c") ProductionCostingProcess query);
+}
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java b/src/main/java/com/ruoyi/production/pojo/ProductionCostingProcess.java
similarity index 65%
rename from src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java
rename to src/main/java/com/ruoyi/production/pojo/ProductionCostingProcess.java
index 3834304..a1f31a2 100644
--- a/src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java
+++ b/src/main/java/com/ruoyi/production/pojo/ProductionCostingProcess.java
@@ -12,12 +12,12 @@
import java.time.LocalDateTime;
/**
- * 鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆锛堝尯鍒嗘垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛�
+ * 鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆锛堢洿鎺ユ寚瀹氭煇涓伐搴忓睘浜庢垚鍝� / 鐧界洅锛�
*/
@Data
-@TableName("production_costing_dept")
-@Schema(name = "ProductionCostingDept瀵硅薄", description = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆")
-public class ProductionCostingDept implements Serializable {
+@TableName("production_costing_process")
+@Schema(name = "ProductionCostingProcess瀵硅薄", description = "鐢熶骇鏍哥畻-宸ュ簭绫诲瀷閰嶇疆")
+public class ProductionCostingProcess implements Serializable {
private static final long serialVersionUID = 1L;
@@ -25,18 +25,18 @@
@Schema(description = "涓婚敭")
private Long id;
- @Schema(description = "閮ㄩ棬ID")
- private Long deptId;
+ @Schema(description = "宸ュ簭ID(technology_operation.id)")
+ private Long processId;
- @Schema(description = "閮ㄩ棬绫诲瀷锛�1鎴愬搧閮ㄩ棬锛�2鐧界洅閮ㄩ棬")
+ @Schema(description = "绫诲瀷锛�1鎴愬搧閮ㄩ棬锛�2鐧界洅閮ㄩ棬")
private Integer deptType;
@Schema(description = "澶囨敞")
private String remark;
- @Schema(description = "閮ㄩ棬鍚嶇О锛堥潪鏁版嵁搴撳瓧娈碉級")
+ @Schema(description = "宸ュ簭鍚嶇О锛堥潪鏁版嵁搴撳瓧娈碉級")
@TableField(exist = false)
- private String deptName;
+ private String processName;
@TableField(fill = FieldFill.INSERT)
private Long createUser;
diff --git a/src/main/java/com/ruoyi/production/service/ProductionCostingService.java b/src/main/java/com/ruoyi/production/service/ProductionCostingService.java
index 843f2d8..6016596 100644
--- a/src/main/java/com/ruoyi/production/service/ProductionCostingService.java
+++ b/src/main/java/com/ruoyi/production/service/ProductionCostingService.java
@@ -3,7 +3,7 @@
import com.ruoyi.production.bean.dto.ProductionCostingQueryDto;
import com.ruoyi.production.bean.vo.ProductionCostingDetailVo;
import com.ruoyi.production.bean.vo.ProductionCostingSummaryVo;
-import com.ruoyi.production.pojo.ProductionCostingDept;
+import com.ruoyi.production.pojo.ProductionCostingProcess;
import com.ruoyi.production.pojo.ProductionCostingFactor;
import com.ruoyi.production.pojo.ProductionCostingStandard;
import com.ruoyi.production.pojo.ProductionCostingWorkday;
@@ -25,14 +25,14 @@
/** 鏈堜唤宸ヤ綔鏃ヤ俊鎭� */
Map<String, Object> workdayInfo(String yearMonth);
- /* ---------------- 閮ㄩ棬绫诲瀷閰嶇疆 ---------------- */
- List<ProductionCostingDept> listDept();
+ /* ---------------- 宸ュ簭绫诲瀷閰嶇疆 ---------------- */
+ List<ProductionCostingProcess> listProcess(ProductionCostingProcess query);
- boolean saveDept(ProductionCostingDept dept);
+ boolean saveProcess(ProductionCostingProcess process);
- boolean updateDept(ProductionCostingDept dept);
+ boolean updateProcess(ProductionCostingProcess process);
- boolean removeDept(Long id);
+ boolean removeProcess(Long id);
/* ---------------- 鏍囧噯鏁伴噺閰嶇疆 ---------------- */
List<ProductionCostingStandard> listStandard(ProductionCostingStandard query);
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java
index bd9d2d7..c674548 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java
@@ -5,12 +5,12 @@
import com.ruoyi.production.bean.vo.ProductionCostingDetailVo;
import com.ruoyi.production.bean.vo.ProductionCostingRawVo;
import com.ruoyi.production.bean.vo.ProductionCostingSummaryVo;
-import com.ruoyi.production.mapper.ProductionCostingDeptMapper;
+import com.ruoyi.production.mapper.ProductionCostingProcessMapper;
import com.ruoyi.production.mapper.ProductionCostingFactorMapper;
import com.ruoyi.production.mapper.ProductionCostingMapper;
import com.ruoyi.production.mapper.ProductionCostingStandardMapper;
import com.ruoyi.production.mapper.ProductionCostingWorkdayMapper;
-import com.ruoyi.production.pojo.ProductionCostingDept;
+import com.ruoyi.production.pojo.ProductionCostingProcess;
import com.ruoyi.production.pojo.ProductionCostingFactor;
import com.ruoyi.production.pojo.ProductionCostingStandard;
import com.ruoyi.production.pojo.ProductionCostingWorkday;
@@ -51,7 +51,7 @@
private final ProductionCostingMapper productionCostingMapper;
private final ProductionCostingStandardMapper standardMapper;
private final ProductionCostingFactorMapper factorMapper;
- private final ProductionCostingDeptMapper deptMapper;
+ private final ProductionCostingProcessMapper processMapper;
private final ProductionCostingWorkdayMapper workdayMapper;
@Override
@@ -230,23 +230,23 @@
/* ================= 閰嶇疆 CRUD ================= */
@Override
- public List<ProductionCostingDept> listDept() {
- return deptMapper.selectDeptConfigs();
+ public List<ProductionCostingProcess> listProcess(ProductionCostingProcess query) {
+ return processMapper.selectProcessList(query == null ? new ProductionCostingProcess() : query);
}
@Override
- public boolean saveDept(ProductionCostingDept dept) {
- return deptMapper.insert(dept) > 0;
+ public boolean saveProcess(ProductionCostingProcess process) {
+ return processMapper.insert(process) > 0;
}
@Override
- public boolean updateDept(ProductionCostingDept dept) {
- return deptMapper.updateById(dept) > 0;
+ public boolean updateProcess(ProductionCostingProcess process) {
+ return processMapper.updateById(process) > 0;
}
@Override
- public boolean removeDept(Long id) {
- return deptMapper.deleteById(id) > 0;
+ public boolean removeProcess(Long id) {
+ return processMapper.deleteById(id) > 0;
}
@Override
diff --git a/src/main/resources/mapper/production/ProductionCostingDeptMapper.xml b/src/main/resources/mapper/production/ProductionCostingDeptMapper.xml
deleted file mode 100644
index cebf740..0000000
--- a/src/main/resources/mapper/production/ProductionCostingDeptMapper.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.ruoyi.production.mapper.ProductionCostingDeptMapper">
-
- <select id="selectDeptConfigs" resultType="com.ruoyi.production.pojo.ProductionCostingDept">
- select d.id, d.dept_id, d.dept_type, d.remark, d.create_user, d.create_time, d.update_user, d.update_time,
- sd.dept_name as deptName
- from production_costing_dept d
- left join sys_dept sd on sd.dept_id = d.dept_id
- order by d.dept_type asc, d.id asc
- </select>
-
-</mapper>
diff --git a/src/main/resources/mapper/production/ProductionCostingMapper.xml b/src/main/resources/mapper/production/ProductionCostingMapper.xml
index 569a067..05e3d7a 100644
--- a/src/main/resources/mapper/production/ProductionCostingMapper.xml
+++ b/src/main/resources/mapper/production/ProductionCostingMapper.xml
@@ -9,7 +9,7 @@
date_format(ppm.create_time, '%Y-%m') as yearMonth,
too.id as processId,
too.name as processName,
- cd.dept_type as deptType,
+ cp.dept_type as deptType,
ppo.product_model_id as productModelId,
p.product_name as productName,
pm.model as modelName,
@@ -18,7 +18,7 @@
inner join production_operation_task pot on pot.id = ppm.production_operation_task_id
inner join production_order_routing_operation poro on poro.id = pot.production_order_routing_operation_id
inner join technology_operation too on too.id = poro.technology_operation_id
- inner join production_costing_dept cd on cd.dept_id = too.dept_id
+ inner join production_costing_process cp on cp.process_id = too.id
inner join production_product_output ppo on ppo.production_product_main_id = ppm.id
left join product_model pm on pm.id = ppo.product_model_id
left join product p on p.id = pm.product_id
@@ -27,7 +27,7 @@
and ppm.report_type in (0, 1)
<if test="c != null">
<if test="c.deptType != null">
- and cd.dept_type = #{c.deptType}
+ and cp.dept_type = #{c.deptType}
</if>
<if test="c.yearMonth != null and c.yearMonth != ''">
and date_format(ppm.create_time, '%Y-%m') = #{c.yearMonth}
@@ -40,7 +40,7 @@
</if>
</if>
</where>
- group by ppm.user_id, ppm.user_name, yearMonth, too.id, too.name, cd.dept_type, ppo.product_model_id, p.product_name, pm.model
+ group by ppm.user_id, ppm.user_name, yearMonth, too.id, too.name, cp.dept_type, ppo.product_model_id, p.product_name, pm.model
order by yearMonth desc, ppm.user_id, too.id
</select>
diff --git a/src/main/resources/mapper/production/ProductionCostingProcessMapper.xml b/src/main/resources/mapper/production/ProductionCostingProcessMapper.xml
new file mode 100644
index 0000000..310be54
--- /dev/null
+++ b/src/main/resources/mapper/production/ProductionCostingProcessMapper.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.production.mapper.ProductionCostingProcessMapper">
+
+ <select id="selectProcessList" resultType="com.ruoyi.production.pojo.ProductionCostingProcess">
+ select p.id, p.process_id, p.dept_type, p.remark,
+ p.create_user, p.create_time, p.update_user, p.update_time,
+ too.name as processName
+ from production_costing_process p
+ left join technology_operation too on too.id = p.process_id
+ <where>
+ <if test="c != null">
+ <if test="c.deptType != null">
+ and p.dept_type = #{c.deptType}
+ </if>
+ <if test="c.processId != null">
+ and p.process_id = #{c.processId}
+ </if>
+ </if>
+ </where>
+ order by p.dept_type asc, p.process_id asc
+ </select>
+
+</mapper>
--
Gitblit v1.9.3