From 55011a9cd84676913b62b3c130257939c1df2488 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期五, 18 九月 2026 09:19:24 +0800
Subject: [PATCH] feat(生产核算): 新增成品/白盒部门产量工时折算核算
---
src/main/java/com/ruoyi/production/pojo/ProductionCostingWorkday.java | 49 ++
src/main/java/com/ruoyi/production/bean/vo/ProductionCostingSummaryVo.java | 36 +
src/main/java/com/ruoyi/production/mapper/ProductionCostingWorkdayMapper.java | 20
src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java | 52 ++
src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java | 377 +++++++++++++++
src/main/resources/mapper/production/ProductionCostingMapper.xml | 47 +
src/main/java/com/ruoyi/production/mapper/ProductionCostingFactorMapper.java | 20
src/main/resources/mapper/production/ProductionCostingFactorMapper.xml | 27 +
src/main/java/com/ruoyi/production/mapper/ProductionCostingStandardMapper.java | 20
src/main/java/com/ruoyi/production/service/ProductionCostingService.java | 63 ++
src/main/java/com/ruoyi/production/bean/vo/ProductionCostingRawVo.java | 31 +
src/main/java/com/ruoyi/production/controller/ProductionCostingController.java | 185 +++++++
src/main/resources/mapper/production/ProductionCostingDeptMapper.xml | 13
src/main/java/com/ruoyi/production/bean/vo/ProductionCostingDetailVo.java | 62 ++
src/main/java/com/ruoyi/production/mapper/ProductionCostingMapper.java | 20
src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java | 19
src/main/java/com/ruoyi/production/pojo/ProductionCostingStandard.java | 68 ++
sql/production_costing_config.sql | 130 +++++
src/main/resources/mapper/production/ProductionCostingStandardMapper.xml | 29 +
src/main/resources/mapper/production/ProductionCostingWorkdayMapper.xml | 19
src/main/java/com/ruoyi/production/pojo/ProductionCostingFactor.java | 66 ++
src/main/java/com/ruoyi/production/bean/dto/ProductionCostingQueryDto.java | 28 +
22 files changed, 1,381 insertions(+), 0 deletions(-)
diff --git a/sql/production_costing_config.sql b/sql/production_costing_config.sql
new file mode 100644
index 0000000..b386772
--- /dev/null
+++ b/sql/production_costing_config.sql
@@ -0,0 +1,130 @@
+-- ============================================================
+-- 鐢熶骇鏍哥畻锛堟垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛夐厤缃笌缁撴瀯琛ュ厖鑴氭湰
+-- 鏁版嵁搴擄細product-inventory-management-new-pro
+-- 璇存槑锛氭湰鍦板簱缁撴瀯钀藉悗浜庝唬鐮侊紝production_product_main 缂哄皯
+-- 鎶ュ伐缁撴灉/瀹℃牳鐩稿叧鍒楋紝杩欓噷琛ラ綈锛涘苟鏂板鏍哥畻閰嶇疆琛ㄤ笌婕旂ず鏁版嵁銆�
+-- ============================================================
+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`;
+
+-- 宸插瓨鍦ㄦ姤宸ユ暟鎹粯璁よ涓猴細瀹℃牳閫氳繃銆佸悎鏍�
+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` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '涓婚敭',
+ `dept_id` bigint NULL COMMENT '閮ㄩ棬ID(sys_dept.dept_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 = '鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆';
+
+DROP TABLE IF EXISTS `production_costing_standard`;
+CREATE TABLE `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)锛岀櫧鐩掑繀濉�',
+ `standard_quantity` decimal(18,4) NULL COMMENT '鏍囧噯鏁伴噺',
+ `unit` varchar(50) 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`)
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆';
+
+DROP TABLE IF EXISTS `production_costing_factor`;
+CREATE TABLE `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)',
+ `staff_name` varchar(255) NULL COMMENT '鍛樺伐濮撳悕',
+ `violin_factor` decimal(18,4) NULL DEFAULT 1 COMMENT '灏忔彁鐞存姌绠楃巼(鍩哄噯)',
+ `viola_factor` decimal(18,4) NULL COMMENT '澶ф彁鐞存姌绠楃巼',
+ `bass_factor` decimal(18,4) 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`)
+) 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());
+
+-- 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);
+
+-- 3.3 閮ㄩ棬绫诲瀷閰嶇疆
+INSERT INTO `production_costing_dept` (`dept_id`, `dept_type`, `remark`, `create_time`)
+VALUES (220, 1, '鎴愬搧閮ㄩ棬', NOW()),
+ (221, 2, '鐧界洅閮ㄩ棬', NOW());
+
+-- 3.4 鏍囧噯鏁伴噺閰嶇疆
+-- 鎴愬搧锛氭寜宸ュ簭
+-- 鐧界洅锛氭寜宸ュ簭 + 鍨嬪彿
+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());
+
+-- 3.5 鎶樼畻鐜囬厤缃紙宸ュ簭 + 鍛樺伐锛�
+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());
+
+-- 3.6 涔愬櫒婕旂ず鏁版嵁锛堝皬鎻愮惔/澶ф彁鐞�/璐濇柉锛夛紝鐢ㄤ簬灞曠ず鎴愬搧閮ㄩ棬鎶樼畻鏁堟灉
+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);
+
+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);
+
+-- 鎶ュ伐閾撅細璁㈠崟 -> 宸ヨ壓璺嚎宸ュ簭 -> 宸ュ崟 -> 鎶ュ伐 -> 浜у嚭
+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);
+
+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);
+
+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);
+
+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);
+
+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);
diff --git a/src/main/java/com/ruoyi/production/bean/dto/ProductionCostingQueryDto.java b/src/main/java/com/ruoyi/production/bean/dto/ProductionCostingQueryDto.java
new file mode 100644
index 0000000..fe0d49c
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/bean/dto/ProductionCostingQueryDto.java
@@ -0,0 +1,28 @@
+package com.ruoyi.production.bean.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 鐢熶骇鏍哥畻鏌ヨ鍙傛暟
+ */
+@Data
+@Schema(name = "ProductionCostingQueryDto", description = "鐢熶骇鏍哥畻鏌ヨ鍙傛暟")
+public class ProductionCostingQueryDto implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @Schema(description = "閮ㄩ棬绫诲瀷锛�1鎴愬搧閮ㄩ棬锛�2鐧界洅閮ㄩ棬")
+ private Integer deptType;
+
+ @Schema(description = "鏈堜唤 yyyy-MM")
+ private String yearMonth;
+
+ @Schema(description = "鍛樺伐濮撳悕锛堟ā绯婏級")
+ private String staffName;
+
+ @Schema(description = "宸ュ簭ID")
+ private Long processId;
+}
diff --git a/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingDetailVo.java b/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingDetailVo.java
new file mode 100644
index 0000000..e2f3e38
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingDetailVo.java
@@ -0,0 +1,62 @@
+package com.ruoyi.production.bean.vo;
+
+import com.ruoyi.framework.aspectj.lang.annotation.Excel;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 鐢熶骇鏍哥畻鏄庣粏鍒嗛〉琛�
+ * 鐧界洅锛氬憳宸� + 宸ュ簭 + 鍨嬪彿/闆朵欢
+ * 鎴愬搧锛氬憳宸� + 宸ュ簭锛堝惈涓夌涔愬櫒鏁伴噺銆佹姌绠楃巼銆佹姌鍚堝皬鎻愮惔锛�
+ */
+@Data
+@Schema(name = "ProductionCostingDetailVo", description = "鐢熶骇鏍哥畻鏄庣粏琛�")
+public class ProductionCostingDetailVo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Long staffId;
+ @Excel(name = "鐢熶骇浜�")
+ private String staffName;
+ private String yearMonth;
+
+ private Long processId;
+ @Excel(name = "宸ュ簭")
+ private String processName;
+ private Integer deptType;
+
+ private Long productModelId;
+ @Excel(name = "浜у搧澶х被")
+ private String productName;
+ @Excel(name = "鍨嬪彿/闆朵欢")
+ private String modelName;
+
+ @Excel(name = "鏈堜骇閲�")
+ private BigDecimal quantity;
+
+ @Excel(name = "灏忔彁鐞存暟閲�")
+ private BigDecimal violinQty;
+ @Excel(name = "澶ф彁鐞存暟閲�")
+ private BigDecimal celloQty;
+ @Excel(name = "璐濇柉鏁伴噺")
+ private BigDecimal bassQty;
+
+ @Excel(name = "灏忔彁鐞存姌绠楃巼")
+ private BigDecimal violinFactor;
+ @Excel(name = "澶ф彁鐞存姌绠楃巼")
+ private BigDecimal celloFactor;
+ @Excel(name = "璐濇柉鎶樼畻鐜�")
+ private BigDecimal bassFactor;
+
+ @Excel(name = "鏈堜骇鎶樺悎灏忔彁鐞�")
+ private BigDecimal foldedQuantity;
+
+ @Excel(name = "鏍囧噯鏁伴噺")
+ private BigDecimal standardQuantity;
+
+ @Excel(name = "鎶樼畻鏃堕暱")
+ private BigDecimal convertedHours;
+}
diff --git a/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingRawVo.java b/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingRawVo.java
new file mode 100644
index 0000000..5071e7c
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingRawVo.java
@@ -0,0 +1,31 @@
+package com.ruoyi.production.bean.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 鐢熶骇鏍哥畻-鎶ュ伐鑱氬悎鍘熷琛岋紙鍛樺伐 + 鏈堜唤 + 宸ュ簭 + 鍨嬪彿/浜у搧澶х被锛�
+ */
+@Data
+@Schema(name = "ProductionCostingRawVo", description = "鐢熶骇鏍哥畻鍘熷鑱氬悎琛�")
+public class ProductionCostingRawVo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Long staffId;
+ private String staffName;
+ private String yearMonth;
+ private Long processId;
+ private String processName;
+ private Integer deptType;
+ private Long productModelId;
+ /** 浜у搧澶х被锛坧roduct.product_name锛夛紝涔愬櫒鍒ゆ柇渚濇嵁 */
+ private String productName;
+ /** 鍨嬪彿/瑙勬牸锛坧roduct_model.model锛� */
+ private String modelName;
+ /** 鏈堜骇閲� */
+ private BigDecimal quantity;
+}
diff --git a/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingSummaryVo.java b/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingSummaryVo.java
new file mode 100644
index 0000000..3a0ce71
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/bean/vo/ProductionCostingSummaryVo.java
@@ -0,0 +1,36 @@
+package com.ruoyi.production.bean.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 鐢熶骇鏍哥畻-姹囨�诲彴璐﹁锛堟寜鍛樺伐锛�
+ */
+@Data
+@Schema(name = "ProductionCostingSummaryVo", description = "鐢熶骇鏍哥畻姹囨�昏")
+public class ProductionCostingSummaryVo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private Long staffId;
+ private String staffName;
+ private String yearMonth;
+
+ /** 浜ч噺 */
+ private BigDecimal output;
+
+ /** 鏈堟椂闂村悎璁★紙鎶樼畻鏃堕暱姹傚拰锛� */
+ private BigDecimal monthTimeTotal;
+
+ /** 鎶樺悎鍊嶆暟 = 鏈堟椂闂村悎璁� / (褰撴湀宸ヤ綔鏃� * 8) */
+ private BigDecimal conversionRatio;
+
+ /** 褰撴湀宸ヤ綔鏃� */
+ private Integer workDays;
+
+ /** 褰撴湀婊″嫟宸ユ椂 = 宸ヤ綔鏃� * 8 */
+ private BigDecimal monthHours;
+}
diff --git a/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java b/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java
new file mode 100644
index 0000000..7394c0c
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/controller/ProductionCostingController.java
@@ -0,0 +1,185 @@
+package com.ruoyi.production.controller;
+
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.framework.aspectj.lang.annotation.Log;
+import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
+import com.ruoyi.framework.web.domain.R;
+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.ProductionCostingFactor;
+import com.ruoyi.production.pojo.ProductionCostingStandard;
+import com.ruoyi.production.pojo.ProductionCostingWorkday;
+import com.ruoyi.production.service.ProductionCostingService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.servlet.http.HttpServletResponse;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鐢熶骇鏍哥畻锛堟垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛夊墠绔帶鍒跺櫒
+ */
+@RestController
+@RequestMapping("/productionCosting")
+@RequiredArgsConstructor
+@Tag(name = "鐢熶骇鏍哥畻")
+public class ProductionCostingController {
+
+ private final ProductionCostingService productionCostingService;
+
+ @GetMapping("/summary")
+ @Log(title = "鐢熶骇鏍哥畻-姹囨�绘煡璇�", businessType = BusinessType.OTHER)
+ @Operation(summary = "鐢熶骇鏍哥畻鎸夊憳宸ユ眹鎬�")
+ public R<List<ProductionCostingSummaryVo>> summary(ProductionCostingQueryDto dto) {
+ return R.ok(productionCostingService.summary(dto));
+ }
+
+ @GetMapping("/detail")
+ @Log(title = "鐢熶骇鏍哥畻-鏄庣粏鏌ヨ", businessType = BusinessType.OTHER)
+ @Operation(summary = "鐢熶骇鏍哥畻鏄庣粏鏌ヨ")
+ public R<List<ProductionCostingDetailVo>> detail(ProductionCostingQueryDto dto) {
+ return R.ok(productionCostingService.detailList(dto));
+ }
+
+ @GetMapping("/workday")
+ @Operation(summary = "鏌ヨ鏈堜唤宸ヤ綔鏃ヤ俊鎭�")
+ public R<Map<String, Object>> workday(String yearMonth) {
+ return R.ok(productionCostingService.workdayInfo(yearMonth));
+ }
+
+ @PostMapping("/export")
+ @Log(title = "鐢熶骇鏍哥畻-瀵煎嚭", businessType = BusinessType.EXPORT)
+ @Operation(summary = "瀵煎嚭鐢熶骇鏍哥畻鏄庣粏")
+ public void export(HttpServletResponse response, ProductionCostingQueryDto dto) {
+ ExcelUtil<ProductionCostingDetailVo> util = new ExcelUtil<>(ProductionCostingDetailVo.class);
+ util.exportExcel(response, productionCostingService.detailList(dto), "鐢熶骇鏍哥畻鏄庣粏");
+ }
+
+ /* ---------------- 閮ㄩ棬绫诲瀷閰嶇疆 ---------------- */
+
+ @GetMapping("/dept/list")
+ @Operation(summary = "閮ㄩ棬绫诲瀷閰嶇疆鍒楄〃")
+ public R<List<ProductionCostingDept>> deptList() {
+ return R.ok(productionCostingService.listDept());
+ }
+
+ @PostMapping("/dept")
+ @Log(title = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆鏂板", businessType = BusinessType.INSERT)
+ @Operation(summary = "鏂板閮ㄩ棬绫诲瀷閰嶇疆")
+ public R<Boolean> deptAdd(@RequestBody ProductionCostingDept dept) {
+ return R.ok(productionCostingService.saveDept(dept));
+ }
+
+ @PutMapping("/dept")
+ @Log(title = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆淇敼", businessType = BusinessType.UPDATE)
+ @Operation(summary = "淇敼閮ㄩ棬绫诲瀷閰嶇疆")
+ public R<Boolean> deptEdit(@RequestBody ProductionCostingDept dept) {
+ return R.ok(productionCostingService.updateDept(dept));
+ }
+
+ @DeleteMapping("/dept/{id}")
+ @Log(title = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆鍒犻櫎", businessType = BusinessType.DELETE)
+ @Operation(summary = "鍒犻櫎閮ㄩ棬绫诲瀷閰嶇疆")
+ public R<Boolean> deptRemove(@PathVariable Long id) {
+ return R.ok(productionCostingService.removeDept(id));
+ }
+
+ /* ---------------- 鏍囧噯鏁伴噺閰嶇疆 ---------------- */
+
+ @GetMapping("/standard/list")
+ @Operation(summary = "鏍囧噯鏁伴噺閰嶇疆鍒楄〃")
+ public R<List<ProductionCostingStandard>> standardList(ProductionCostingStandard query) {
+ return R.ok(productionCostingService.listStandard(query));
+ }
+
+ @PostMapping("/standard")
+ @Log(title = "鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆鏂板", businessType = BusinessType.INSERT)
+ @Operation(summary = "鏂板鏍囧噯鏁伴噺閰嶇疆")
+ public R<Boolean> standardAdd(@RequestBody ProductionCostingStandard standard) {
+ return R.ok(productionCostingService.saveStandard(standard));
+ }
+
+ @PutMapping("/standard")
+ @Log(title = "鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆淇敼", businessType = BusinessType.UPDATE)
+ @Operation(summary = "淇敼鏍囧噯鏁伴噺閰嶇疆")
+ public R<Boolean> standardEdit(@RequestBody ProductionCostingStandard standard) {
+ return R.ok(productionCostingService.updateStandard(standard));
+ }
+
+ @DeleteMapping("/standard/{id}")
+ @Log(title = "鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆鍒犻櫎", businessType = BusinessType.DELETE)
+ @Operation(summary = "鍒犻櫎鏍囧噯鏁伴噺閰嶇疆")
+ public R<Boolean> standardRemove(@PathVariable Long id) {
+ return R.ok(productionCostingService.removeStandard(id));
+ }
+
+ /* ---------------- 鎶樼畻鐜囬厤缃� ---------------- */
+
+ @GetMapping("/factor/list")
+ @Operation(summary = "鎶樼畻鐜囬厤缃垪琛�")
+ public R<List<ProductionCostingFactor>> factorList(ProductionCostingFactor query) {
+ return R.ok(productionCostingService.listFactor(query));
+ }
+
+ @PostMapping("/factor")
+ @Log(title = "鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃柊澧�", businessType = BusinessType.INSERT)
+ @Operation(summary = "鏂板鎶樼畻鐜囬厤缃�")
+ public R<Boolean> factorAdd(@RequestBody ProductionCostingFactor factor) {
+ return R.ok(productionCostingService.saveFactor(factor));
+ }
+
+ @PutMapping("/factor")
+ @Log(title = "鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃慨鏀�", businessType = BusinessType.UPDATE)
+ @Operation(summary = "淇敼鎶樼畻鐜囬厤缃�")
+ public R<Boolean> factorEdit(@RequestBody ProductionCostingFactor factor) {
+ return R.ok(productionCostingService.updateFactor(factor));
+ }
+
+ @DeleteMapping("/factor/{id}")
+ @Log(title = "鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃垹闄�", businessType = BusinessType.DELETE)
+ @Operation(summary = "鍒犻櫎鎶樼畻鐜囬厤缃�")
+ public R<Boolean> factorRemove(@PathVariable Long id) {
+ return R.ok(productionCostingService.removeFactor(id));
+ }
+
+ /* ---------------- 鏈堝害宸ヤ綔鏃ラ厤缃� ---------------- */
+
+ @GetMapping("/workdayConfig/list")
+ @Operation(summary = "鏈堝害宸ヤ綔鏃ラ厤缃垪琛�")
+ public R<List<ProductionCostingWorkday>> workdayList(ProductionCostingWorkday query) {
+ return R.ok(productionCostingService.listWorkday(query));
+ }
+
+ @PostMapping("/workdayConfig")
+ @Log(title = "鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃柊澧�", businessType = BusinessType.INSERT)
+ @Operation(summary = "鏂板鏈堝害宸ヤ綔鏃ラ厤缃�")
+ public R<Boolean> workdayAdd(@RequestBody ProductionCostingWorkday workday) {
+ return R.ok(productionCostingService.saveWorkday(workday));
+ }
+
+ @PutMapping("/workdayConfig")
+ @Log(title = "鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃慨鏀�", businessType = BusinessType.UPDATE)
+ @Operation(summary = "淇敼鏈堝害宸ヤ綔鏃ラ厤缃�")
+ public R<Boolean> workdayEdit(@RequestBody ProductionCostingWorkday workday) {
+ return R.ok(productionCostingService.updateWorkday(workday));
+ }
+
+ @DeleteMapping("/workdayConfig/{id}")
+ @Log(title = "鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃垹闄�", businessType = BusinessType.DELETE)
+ @Operation(summary = "鍒犻櫎鏈堝害宸ヤ綔鏃ラ厤缃�")
+ public R<Boolean> workdayRemove(@PathVariable Long id) {
+ return R.ok(productionCostingService.removeWorkday(id));
+ }
+}
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java
new file mode 100644
index 0000000..7310d85
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/mapper/ProductionCostingDeptMapper.java
@@ -0,0 +1,19 @@
+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/ProductionCostingFactorMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingFactorMapper.java
new file mode 100644
index 0000000..14cb7cc
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/mapper/ProductionCostingFactorMapper.java
@@ -0,0 +1,20 @@
+package com.ruoyi.production.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.production.pojo.ProductionCostingFactor;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃� Mapper
+ */
+@Mapper
+public interface ProductionCostingFactorMapper extends BaseMapper<ProductionCostingFactor> {
+
+ /**
+ * 鏌ヨ鎶樼畻鐜囬厤缃垪琛紙鍚伐搴忓悕绉帮級
+ */
+ List<ProductionCostingFactor> selectFactorList(@Param("c") ProductionCostingFactor query);
+}
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductionCostingMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingMapper.java
new file mode 100644
index 0000000..064c37b
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/mapper/ProductionCostingMapper.java
@@ -0,0 +1,20 @@
+package com.ruoyi.production.mapper;
+
+import com.ruoyi.production.bean.dto.ProductionCostingQueryDto;
+import com.ruoyi.production.bean.vo.ProductionCostingRawVo;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 鐢熶骇鏍哥畻-鏍哥畻缁熻 Mapper
+ */
+@Mapper
+public interface ProductionCostingMapper {
+
+ /**
+ * 鏌ヨ鏌愭潯浠朵笅鐨勬姤宸ヨ仛鍚堝師濮嬭锛堝憳宸�+鏈堜唤+宸ュ簭+鍨嬪彿/浜у搧澶х被锛�
+ */
+ List<ProductionCostingRawVo> selectCostingRows(@Param("c") ProductionCostingQueryDto dto);
+}
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductionCostingStandardMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingStandardMapper.java
new file mode 100644
index 0000000..39d03cf
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/mapper/ProductionCostingStandardMapper.java
@@ -0,0 +1,20 @@
+package com.ruoyi.production.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.production.pojo.ProductionCostingStandard;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆 Mapper
+ */
+@Mapper
+public interface ProductionCostingStandardMapper extends BaseMapper<ProductionCostingStandard> {
+
+ /**
+ * 鏌ヨ鏍囧噯鏁伴噺閰嶇疆鍒楄〃锛堝惈宸ュ簭鍚嶇О銆佸瀷鍙峰悕绉帮級
+ */
+ List<ProductionCostingStandard> selectStandardList(@Param("c") ProductionCostingStandard query);
+}
diff --git a/src/main/java/com/ruoyi/production/mapper/ProductionCostingWorkdayMapper.java b/src/main/java/com/ruoyi/production/mapper/ProductionCostingWorkdayMapper.java
new file mode 100644
index 0000000..acfe201
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/mapper/ProductionCostingWorkdayMapper.java
@@ -0,0 +1,20 @@
+package com.ruoyi.production.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ruoyi.production.pojo.ProductionCostingWorkday;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃� Mapper
+ */
+@Mapper
+public interface ProductionCostingWorkdayMapper extends BaseMapper<ProductionCostingWorkday> {
+
+ /**
+ * 鏌ヨ鏈堝害宸ヤ綔鏃ラ厤缃垪琛�
+ */
+ List<ProductionCostingWorkday> selectWorkdayList(@Param("c") ProductionCostingWorkday query);
+}
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java b/src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java
new file mode 100644
index 0000000..3834304
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/pojo/ProductionCostingDept.java
@@ -0,0 +1,52 @@
+package com.ruoyi.production.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆锛堝尯鍒嗘垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛�
+ */
+@Data
+@TableName("production_costing_dept")
+@Schema(name = "ProductionCostingDept瀵硅薄", description = "鐢熶骇鏍哥畻-閮ㄩ棬绫诲瀷閰嶇疆")
+public class ProductionCostingDept implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableId(value = "id", type = IdType.AUTO)
+ @Schema(description = "涓婚敭")
+ private Long id;
+
+ @Schema(description = "閮ㄩ棬ID")
+ private Long deptId;
+
+ @Schema(description = "閮ㄩ棬绫诲瀷锛�1鎴愬搧閮ㄩ棬锛�2鐧界洅閮ㄩ棬")
+ private Integer deptType;
+
+ @Schema(description = "澶囨敞")
+ private String remark;
+
+ @Schema(description = "閮ㄩ棬鍚嶇О锛堥潪鏁版嵁搴撳瓧娈碉級")
+ @TableField(exist = false)
+ private String deptName;
+
+ @TableField(fill = FieldFill.INSERT)
+ private Long createUser;
+
+ @TableField(fill = FieldFill.INSERT)
+ private LocalDateTime createTime;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Long updateUser;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private LocalDateTime updateTime;
+}
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductionCostingFactor.java b/src/main/java/com/ruoyi/production/pojo/ProductionCostingFactor.java
new file mode 100644
index 0000000..d0bdf8e
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/pojo/ProductionCostingFactor.java
@@ -0,0 +1,66 @@
+package com.ruoyi.production.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃紙宸ュ簭 + 鍛樺伐锛�
+ * 鎴愬搧閮ㄩ棬锛氭瘡涓伐搴忕殑姣忎釜鍛樺伐鎶樼畻鐜囧彲涓嶅悓锛堝皬鎻愮惔涓哄熀鍑� 1锛�
+ */
+@Data
+@TableName("production_costing_factor")
+@Schema(name = "ProductionCostingFactor瀵硅薄", description = "鐢熶骇鏍哥畻-鎶樼畻鐜囬厤缃�")
+public class ProductionCostingFactor implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableId(value = "id", type = IdType.AUTO)
+ @Schema(description = "涓婚敭")
+ private Long id;
+
+ @Schema(description = "宸ュ簭ID")
+ private Long processId;
+
+ @Schema(description = "鍛樺伐ID")
+ private Long staffId;
+
+ @Schema(description = "鍛樺伐濮撳悕")
+ private String staffName;
+
+ @Schema(description = "灏忔彁鐞存姌绠楃巼锛堝熀鍑嗭級")
+ private BigDecimal violinFactor;
+
+ @Schema(description = "澶ф彁鐞存姌绠楃巼")
+ private BigDecimal violaFactor;
+
+ @Schema(description = "璐濇柉鎶樼畻鐜�")
+ private BigDecimal bassFactor;
+
+ @Schema(description = "澶囨敞")
+ private String remark;
+
+ @Schema(description = "宸ュ簭鍚嶇О锛堥潪鏁版嵁搴撳瓧娈碉級")
+ @TableField(exist = false)
+ private String processName;
+
+ @TableField(fill = FieldFill.INSERT)
+ private Long createUser;
+
+ @TableField(fill = FieldFill.INSERT)
+ private LocalDateTime createTime;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Long updateUser;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private LocalDateTime updateTime;
+}
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductionCostingStandard.java b/src/main/java/com/ruoyi/production/pojo/ProductionCostingStandard.java
new file mode 100644
index 0000000..b29bf01
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/pojo/ProductionCostingStandard.java
@@ -0,0 +1,68 @@
+package com.ruoyi.production.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+
+/**
+ * 鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆
+ * 鎴愬搧閮ㄩ棬锛氭寜宸ュ簭閰嶇疆锛坧roduct_model_id 鍙┖锛�
+ * 鐧界洅閮ㄩ棬锛氭寜 宸ュ簭 + 鍨嬪彿 閰嶇疆
+ */
+@Data
+@TableName("production_costing_standard")
+@Schema(name = "ProductionCostingStandard瀵硅薄", description = "鐢熶骇鏍哥畻-鏍囧噯鏁伴噺閰嶇疆")
+public class ProductionCostingStandard implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableId(value = "id", type = IdType.AUTO)
+ @Schema(description = "涓婚敭")
+ private Long id;
+
+ @Schema(description = "閮ㄩ棬绫诲瀷锛�1鎴愬搧锛�2鐧界洅")
+ private Integer deptType;
+
+ @Schema(description = "宸ュ簭ID")
+ private Long processId;
+
+ @Schema(description = "鍨嬪彿ID锛堢櫧鐩掑繀濉級")
+ private Long productModelId;
+
+ @Schema(description = "鏍囧噯鏁伴噺")
+ private BigDecimal standardQuantity;
+
+ @Schema(description = "鍗曚綅")
+ private String unit;
+
+ @Schema(description = "澶囨敞")
+ private String remark;
+
+ @Schema(description = "宸ュ簭鍚嶇О锛堥潪鏁版嵁搴撳瓧娈碉級")
+ @TableField(exist = false)
+ private String processName;
+
+ @Schema(description = "鍨嬪彿鍚嶇О锛堥潪鏁版嵁搴撳瓧娈碉級")
+ @TableField(exist = false)
+ private String modelName;
+
+ @TableField(fill = FieldFill.INSERT)
+ private Long createUser;
+
+ @TableField(fill = FieldFill.INSERT)
+ private LocalDateTime createTime;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Long updateUser;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private LocalDateTime updateTime;
+}
diff --git a/src/main/java/com/ruoyi/production/pojo/ProductionCostingWorkday.java b/src/main/java/com/ruoyi/production/pojo/ProductionCostingWorkday.java
new file mode 100644
index 0000000..03b5681
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/pojo/ProductionCostingWorkday.java
@@ -0,0 +1,49 @@
+package com.ruoyi.production.pojo;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃�
+ */
+@Data
+@TableName("production_costing_workday")
+@Schema(name = "ProductionCostingWorkday瀵硅薄", description = "鐢熶骇鏍哥畻-鏈堝害宸ヤ綔鏃ラ厤缃�")
+public class ProductionCostingWorkday implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableId(value = "id", type = IdType.AUTO)
+ @Schema(description = "涓婚敭")
+ private Long id;
+
+ @Schema(description = "骞存湀 yyyy-MM")
+ @TableField("work_month")
+ private String yearMonth;
+
+ @Schema(description = "褰撴湀宸ヤ綔鏃ュぉ鏁�")
+ private Integer workDays;
+
+ @Schema(description = "澶囨敞")
+ private String remark;
+
+ @TableField(fill = FieldFill.INSERT)
+ private Long createUser;
+
+ @TableField(fill = FieldFill.INSERT)
+ private LocalDateTime createTime;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private Long updateUser;
+
+ @TableField(fill = FieldFill.INSERT_UPDATE)
+ private LocalDateTime updateTime;
+}
diff --git a/src/main/java/com/ruoyi/production/service/ProductionCostingService.java b/src/main/java/com/ruoyi/production/service/ProductionCostingService.java
new file mode 100644
index 0000000..843f2d8
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/service/ProductionCostingService.java
@@ -0,0 +1,63 @@
+package com.ruoyi.production.service;
+
+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.ProductionCostingFactor;
+import com.ruoyi.production.pojo.ProductionCostingStandard;
+import com.ruoyi.production.pojo.ProductionCostingWorkday;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鐢熶骇鏍哥畻锛堟垚鍝侀儴闂� / 鐧界洅閮ㄩ棬锛夋湇鍔�
+ */
+public interface ProductionCostingService {
+
+ /** 鎸夊憳宸ユ眹鎬伙細浜ч噺銆佹湀鏃堕棿鍚堣銆佹姌鍚堝�嶆暟 */
+ List<ProductionCostingSummaryVo> summary(ProductionCostingQueryDto dto);
+
+ /** 鏄庣粏琛岋紙鐧界洅锛氬伐搴�+鍨嬪彿锛涙垚鍝侊細宸ュ簭锛� */
+ List<ProductionCostingDetailVo> detailList(ProductionCostingQueryDto dto);
+
+ /** 鏈堜唤宸ヤ綔鏃ヤ俊鎭� */
+ Map<String, Object> workdayInfo(String yearMonth);
+
+ /* ---------------- 閮ㄩ棬绫诲瀷閰嶇疆 ---------------- */
+ List<ProductionCostingDept> listDept();
+
+ boolean saveDept(ProductionCostingDept dept);
+
+ boolean updateDept(ProductionCostingDept dept);
+
+ boolean removeDept(Long id);
+
+ /* ---------------- 鏍囧噯鏁伴噺閰嶇疆 ---------------- */
+ List<ProductionCostingStandard> listStandard(ProductionCostingStandard query);
+
+ boolean saveStandard(ProductionCostingStandard standard);
+
+ boolean updateStandard(ProductionCostingStandard standard);
+
+ boolean removeStandard(Long id);
+
+ /* ---------------- 鎶樼畻鐜囬厤缃� ---------------- */
+ List<ProductionCostingFactor> listFactor(ProductionCostingFactor query);
+
+ boolean saveFactor(ProductionCostingFactor factor);
+
+ boolean updateFactor(ProductionCostingFactor factor);
+
+ boolean removeFactor(Long id);
+
+ /* ---------------- 鏈堝害宸ヤ綔鏃ラ厤缃� ---------------- */
+ List<ProductionCostingWorkday> listWorkday(ProductionCostingWorkday query);
+
+ boolean saveWorkday(ProductionCostingWorkday workday);
+
+ boolean updateWorkday(ProductionCostingWorkday workday);
+
+ boolean removeWorkday(Long id);
+}
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java
new file mode 100644
index 0000000..bd9d2d7
--- /dev/null
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionCostingServiceImpl.java
@@ -0,0 +1,377 @@
+package com.ruoyi.production.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.ruoyi.production.bean.dto.ProductionCostingQueryDto;
+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.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.ProductionCostingFactor;
+import com.ruoyi.production.pojo.ProductionCostingStandard;
+import com.ruoyi.production.pojo.ProductionCostingWorkday;
+import com.ruoyi.production.service.ProductionCostingService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.time.DayOfWeek;
+import java.time.YearMonth;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 鐢熶骇鏍哥畻鏈嶅姟瀹炵幇
+ * <p>
+ * 璁$畻瑙勫垯锛堜弗鏍兼寜闇�姹傦級锛�
+ * 鐧界洅閮ㄩ棬锛氭姌绠楁椂闀� = 鏈堜骇閲� 脳 鏍囧噯鏁伴噺 脳 8
+ * 鎴愬搧閮ㄩ棬锛氭湀浜ф姌鍚堝皬鎻� = 灏忔彁鐞� + 澶ф彁鐞疵楀ぇ鎻愭姌绠楃巼 + 璐濇柉脳璐濇柉鎶樼畻鐜�
+ * 鎶樼畻鏃堕暱 = 鏈堜骇鎶樺悎灏忔彁 梅 鏍囧噯鏁伴噺 脳 8
+ * 鏈堟椂闂村悎璁� = 鎶樼畻鏃堕暱姹傚拰
+ * 鎶樺悎鍊嶆暟 = 鏈堟椂闂村悎璁� 梅锛堝綋鏈堝伐浣滄棩 脳 8锛�
+ */
+@Service
+@RequiredArgsConstructor
+public class ProductionCostingServiceImpl implements ProductionCostingService {
+
+ private static final BigDecimal EIGHT = new BigDecimal("8");
+ private static final BigDecimal ONE = new BigDecimal("1");
+ private static final String VIOLIN = "灏忔彁鐞�";
+ private static final String CELLO = "澶ф彁鐞�";
+ private static final String BASS = "璐濇柉";
+
+ private final ProductionCostingMapper productionCostingMapper;
+ private final ProductionCostingStandardMapper standardMapper;
+ private final ProductionCostingFactorMapper factorMapper;
+ private final ProductionCostingDeptMapper deptMapper;
+ private final ProductionCostingWorkdayMapper workdayMapper;
+
+ @Override
+ public List<ProductionCostingDetailVo> detailList(ProductionCostingQueryDto dto) {
+ ProductionCostingQueryDto query = dto == null ? new ProductionCostingQueryDto() : dto;
+ List<ProductionCostingRawVo> rows = productionCostingMapper.selectCostingRows(query);
+
+ // 鏍囧噯鏁伴噺锛氭垚鍝�(1) 鎸夊伐搴忥紱鐧界洅(2) 鎸� 宸ュ簭+鍨嬪彿
+ Map<Long, BigDecimal> standardByProcess = new HashMap<>();
+ Map<String, BigDecimal> standardByProcessModel = new HashMap<>();
+ List<ProductionCostingStandard> standardList = standardMapper.selectList(null);
+ for (ProductionCostingStandard s : standardList) {
+ if (s.getProcessId() == null || s.getStandardQuantity() == null) {
+ continue;
+ }
+ if (Integer.valueOf(2).equals(s.getDeptType())) {
+ standardByProcessModel.put(key(s.getProcessId(), s.getProductModelId()), s.getStandardQuantity());
+ } else {
+ standardByProcess.put(s.getProcessId(), s.getStandardQuantity());
+ }
+ }
+
+ // 鎶樼畻鐜囷細宸ュ簭 + 鍛樺伐
+ Map<String, ProductionCostingFactor> factorMap = new HashMap<>();
+ for (ProductionCostingFactor f : factorMapper.selectList(null)) {
+ factorMap.put(key(f.getProcessId(), f.getStaffId()), f);
+ }
+
+ List<ProductionCostingDetailVo> result = new ArrayList<>();
+
+ // ---------- 鎴愬搧閮ㄩ棬锛氭寜 鍛樺伐 + 鏈堜唤 + 宸ュ簭 鑱氬悎 ----------
+ Map<String, ProductionCostingDetailVo> finishedGroup = new LinkedHashMap<>();
+ // ---------- 鐧界洅閮ㄩ棬锛氭寜 鍛樺伐 + 鏈堜唤 + 宸ュ簭 + 鍨嬪彿 鑱氬悎 ----------
+ Map<String, ProductionCostingDetailVo> whiteGroup = new LinkedHashMap<>();
+
+ for (ProductionCostingRawVo row : rows) {
+ BigDecimal qty = nz(row.getQuantity());
+ boolean white = Integer.valueOf(2).equals(row.getDeptType());
+ if (white) {
+ String k = key(row.getStaffId(), row.getYearMonth(), row.getProcessId(), row.getProductModelId());
+ ProductionCostingDetailVo vo = whiteGroup.get(k);
+ if (vo == null) {
+ vo = new ProductionCostingDetailVo();
+ vo.setStaffId(row.getStaffId());
+ vo.setStaffName(row.getStaffName());
+ vo.setYearMonth(row.getYearMonth());
+ vo.setProcessId(row.getProcessId());
+ vo.setProcessName(row.getProcessName());
+ vo.setDeptType(row.getDeptType());
+ vo.setProductModelId(row.getProductModelId());
+ vo.setProductName(row.getProductName());
+ vo.setModelName(row.getModelName());
+ vo.setQuantity(BigDecimal.ZERO);
+ whiteGroup.put(k, vo);
+ }
+ vo.setQuantity(vo.getQuantity().add(qty));
+ } else {
+ String k = key(row.getStaffId(), row.getYearMonth(), row.getProcessId());
+ ProductionCostingDetailVo vo = finishedGroup.get(k);
+ if (vo == null) {
+ vo = new ProductionCostingDetailVo();
+ vo.setStaffId(row.getStaffId());
+ vo.setStaffName(row.getStaffName());
+ vo.setYearMonth(row.getYearMonth());
+ vo.setProcessId(row.getProcessId());
+ vo.setProcessName(row.getProcessName());
+ vo.setDeptType(row.getDeptType());
+ vo.setQuantity(BigDecimal.ZERO);
+ vo.setViolinQty(BigDecimal.ZERO);
+ vo.setCelloQty(BigDecimal.ZERO);
+ vo.setBassQty(BigDecimal.ZERO);
+ finishedGroup.put(k, vo);
+ }
+ vo.setQuantity(vo.getQuantity().add(qty));
+ if (VIOLIN.equals(row.getProductName())) {
+ vo.setViolinQty(vo.getViolinQty().add(qty));
+ } else if (CELLO.equals(row.getProductName())) {
+ vo.setCelloQty(vo.getCelloQty().add(qty));
+ } else if (BASS.equals(row.getProductName())) {
+ vo.setBassQty(vo.getBassQty().add(qty));
+ } else {
+ // 闈炰箰鍣ㄤ骇鍝侀粯璁ゆ寜灏忔彁鐞村綋閲� 1:1 璁″叆
+ vo.setViolinQty(vo.getViolinQty().add(qty));
+ }
+ }
+ }
+
+ // 鎴愬搧锛氭姌绠�
+ for (ProductionCostingDetailVo vo : finishedGroup.values()) {
+ ProductionCostingFactor factor = factorMap.get(key(vo.getProcessId(), vo.getStaffId()));
+ BigDecimal violinFactor = factor == null ? ONE : nzDefault(factor.getViolinFactor(), ONE);
+ BigDecimal celloFactor = factor == null ? ONE : nzDefault(factor.getViolaFactor(), ONE);
+ BigDecimal bassFactor = factor == null ? ONE : nzDefault(factor.getBassFactor(), ONE);
+ vo.setViolinFactor(violinFactor);
+ vo.setCelloFactor(celloFactor);
+ vo.setBassFactor(bassFactor);
+
+ BigDecimal folded = nz(vo.getViolinQty()).multiply(violinFactor)
+ .add(nz(vo.getCelloQty()).multiply(celloFactor))
+ .add(nz(vo.getBassQty()).multiply(bassFactor))
+ .setScale(2, RoundingMode.HALF_UP);
+ vo.setFoldedQuantity(folded);
+
+ BigDecimal standard = standardByProcess.get(vo.getProcessId());
+ vo.setStandardQuantity(standard);
+ vo.setConvertedHours(calcFinishedHours(folded, standard));
+ }
+
+ // 鐧界洅锛氭姌绠楁椂闀� = 鏈堜骇閲� 脳 鏍囧噯鏁伴噺 脳 8
+ for (ProductionCostingDetailVo vo : whiteGroup.values()) {
+ BigDecimal standard = standardByProcessModel.get(key(vo.getProcessId(), vo.getProductModelId()));
+ vo.setStandardQuantity(standard);
+ BigDecimal hours = nz(standard).compareTo(BigDecimal.ZERO) <= 0
+ ? BigDecimal.ZERO
+ : nz(vo.getQuantity()).multiply(standard).multiply(EIGHT);
+ vo.setConvertedHours(hours.setScale(2, RoundingMode.HALF_UP));
+ }
+
+ result.addAll(finishedGroup.values());
+ result.addAll(whiteGroup.values());
+ return result;
+ }
+
+ @Override
+ public List<ProductionCostingSummaryVo> summary(ProductionCostingQueryDto dto) {
+ ProductionCostingQueryDto query = dto == null ? new ProductionCostingQueryDto() : dto;
+ String yearMonth = (query.getYearMonth() == null || query.getYearMonth().isEmpty())
+ ? YearMonth.now().toString() : query.getYearMonth();
+ query.setYearMonth(yearMonth);
+ int workDays = resolveWorkDays(yearMonth);
+ BigDecimal fullHours = new BigDecimal(workDays).multiply(EIGHT);
+
+ List<ProductionCostingDetailVo> details = detailList(query);
+ Map<Long, ProductionCostingSummaryVo> map = new LinkedHashMap<>();
+ for (ProductionCostingDetailVo d : details) {
+ ProductionCostingSummaryVo vo = map.get(d.getStaffId());
+ if (vo == null) {
+ vo = new ProductionCostingSummaryVo();
+ vo.setStaffId(d.getStaffId());
+ vo.setStaffName(d.getStaffName());
+ vo.setYearMonth(yearMonth);
+ vo.setOutput(BigDecimal.ZERO);
+ vo.setMonthTimeTotal(BigDecimal.ZERO);
+ vo.setWorkDays(workDays);
+ vo.setMonthHours(fullHours);
+ map.put(d.getStaffId(), vo);
+ }
+ vo.setOutput(vo.getOutput().add(nz(d.getQuantity())).setScale(2, RoundingMode.HALF_UP));
+ vo.setMonthTimeTotal(vo.getMonthTimeTotal().add(nz(d.getConvertedHours())).setScale(2, RoundingMode.HALF_UP));
+ }
+ List<ProductionCostingSummaryVo> result = new ArrayList<>(map.values());
+ for (ProductionCostingSummaryVo vo : result) {
+ BigDecimal divisor = fullHours;
+ BigDecimal ratio = divisor.compareTo(BigDecimal.ZERO) == 0
+ ? BigDecimal.ZERO
+ : vo.getMonthTimeTotal().divide(divisor, 2, RoundingMode.HALF_UP);
+ vo.setConversionRatio(ratio);
+ }
+ return result;
+ }
+
+ @Override
+ public Map<String, Object> workdayInfo(String yearMonth) {
+ String ym = (yearMonth == null || yearMonth.isEmpty()) ? YearMonth.now().toString() : yearMonth;
+ ProductionCostingWorkday cfg = findWorkday(ym);
+ int workDays = (cfg != null && cfg.getWorkDays() != null) ? cfg.getWorkDays() : workDays(ym);
+ Map<String, Object> map = new HashMap<>();
+ map.put("yearMonth", ym);
+ map.put("workDays", workDays);
+ map.put("dayHours", 8);
+ map.put("monthHours", new BigDecimal(workDays).multiply(EIGHT).setScale(2, RoundingMode.HALF_UP));
+ map.put("source", (cfg != null && cfg.getWorkDays() != null) ? "CONFIG" : "DEFAULT");
+ return map;
+ }
+
+ /* ================= 閰嶇疆 CRUD ================= */
+
+ @Override
+ public List<ProductionCostingDept> listDept() {
+ return deptMapper.selectDeptConfigs();
+ }
+
+ @Override
+ public boolean saveDept(ProductionCostingDept dept) {
+ return deptMapper.insert(dept) > 0;
+ }
+
+ @Override
+ public boolean updateDept(ProductionCostingDept dept) {
+ return deptMapper.updateById(dept) > 0;
+ }
+
+ @Override
+ public boolean removeDept(Long id) {
+ return deptMapper.deleteById(id) > 0;
+ }
+
+ @Override
+ public List<ProductionCostingStandard> listStandard(ProductionCostingStandard query) {
+ return standardMapper.selectStandardList(query == null ? new ProductionCostingStandard() : query);
+ }
+
+ @Override
+ public boolean saveStandard(ProductionCostingStandard standard) {
+ return standardMapper.insert(standard) > 0;
+ }
+
+ @Override
+ public boolean updateStandard(ProductionCostingStandard standard) {
+ return standardMapper.updateById(standard) > 0;
+ }
+
+ @Override
+ public boolean removeStandard(Long id) {
+ return standardMapper.deleteById(id) > 0;
+ }
+
+ @Override
+ public List<ProductionCostingFactor> listFactor(ProductionCostingFactor query) {
+ return factorMapper.selectFactorList(query == null ? new ProductionCostingFactor() : query);
+ }
+
+ @Override
+ public boolean saveFactor(ProductionCostingFactor factor) {
+ return factorMapper.insert(factor) > 0;
+ }
+
+ @Override
+ public boolean updateFactor(ProductionCostingFactor factor) {
+ return factorMapper.updateById(factor) > 0;
+ }
+
+ @Override
+ public boolean removeFactor(Long id) {
+ return factorMapper.deleteById(id) > 0;
+ }
+
+ @Override
+ public List<ProductionCostingWorkday> listWorkday(ProductionCostingWorkday query) {
+ return workdayMapper.selectWorkdayList(query == null ? new ProductionCostingWorkday() : query);
+ }
+
+ @Override
+ public boolean saveWorkday(ProductionCostingWorkday workday) {
+ return workdayMapper.insert(workday) > 0;
+ }
+
+ @Override
+ public boolean updateWorkday(ProductionCostingWorkday workday) {
+ return workdayMapper.updateById(workday) > 0;
+ }
+
+ @Override
+ public boolean removeWorkday(Long id) {
+ return workdayMapper.deleteById(id) > 0;
+ }
+
+ /* ================= 宸ュ叿鏂规硶 ================= */
+
+ /** 鏌ユ湀搴﹀伐浣滄棩閰嶇疆 */
+ private ProductionCostingWorkday findWorkday(String yearMonth) {
+ if (yearMonth == null || yearMonth.isEmpty()) {
+ return null;
+ }
+ return workdayMapper.selectOne(new LambdaQueryWrapper<ProductionCostingWorkday>()
+ .eq(ProductionCostingWorkday::getYearMonth, yearMonth)
+ .last("limit 1"));
+ }
+
+ /** 宸ヤ綔鏃ワ細浼樺厛鍙栨湀搴﹂厤缃紝鏈厤缃垯鎸夊懆涓�~鍛ㄤ簲 */
+ private int resolveWorkDays(String yearMonth) {
+ ProductionCostingWorkday cfg = findWorkday(yearMonth);
+ if (cfg != null && cfg.getWorkDays() != null) {
+ return cfg.getWorkDays();
+ }
+ return workDays(yearMonth);
+ }
+
+ /** 鎴愬搧鎶樼畻锛氭姌鍚堝皬鎻愮惔 / 鏍囧噯鏁伴噺 * 8锛涙爣鍑嗘暟閲�<=0 杩斿洖 0 */
+ private BigDecimal calcFinishedHours(BigDecimal folded, BigDecimal standard) {
+ if (standard == null || standard.compareTo(BigDecimal.ZERO) <= 0) {
+ return BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP);
+ }
+ return folded.divide(standard, 8, RoundingMode.HALF_UP)
+ .multiply(EIGHT)
+ .setScale(2, RoundingMode.HALF_UP);
+ }
+
+ private int workDays(String yearMonth) {
+ try {
+ YearMonth ym = YearMonth.parse(yearMonth);
+ int count = 0;
+ for (int d = 1; d <= ym.lengthOfMonth(); d++) {
+ DayOfWeek dow = ym.atDay(d).getDayOfWeek();
+ if (dow != DayOfWeek.SATURDAY && dow != DayOfWeek.SUNDAY) {
+ count++;
+ }
+ }
+ return count;
+ } catch (Exception e) {
+ return 0;
+ }
+ }
+
+ private BigDecimal nz(BigDecimal v) {
+ return v == null ? BigDecimal.ZERO : v;
+ }
+
+ private BigDecimal nzDefault(BigDecimal v, BigDecimal def) {
+ return v == null ? def : v;
+ }
+
+ private String key(Object... parts) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < parts.length; i++) {
+ if (i > 0) {
+ sb.append(':');
+ }
+ sb.append(parts[i] == null ? "null" : parts[i]);
+ }
+ return sb.toString();
+ }
+}
diff --git a/src/main/resources/mapper/production/ProductionCostingDeptMapper.xml b/src/main/resources/mapper/production/ProductionCostingDeptMapper.xml
new file mode 100644
index 0000000..cebf740
--- /dev/null
+++ b/src/main/resources/mapper/production/ProductionCostingDeptMapper.xml
@@ -0,0 +1,13 @@
+<?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/ProductionCostingFactorMapper.xml b/src/main/resources/mapper/production/ProductionCostingFactorMapper.xml
new file mode 100644
index 0000000..8f80fae
--- /dev/null
+++ b/src/main/resources/mapper/production/ProductionCostingFactorMapper.xml
@@ -0,0 +1,27 @@
+<?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.ProductionCostingFactorMapper">
+
+ <select id="selectFactorList" resultType="com.ruoyi.production.pojo.ProductionCostingFactor">
+ select f.id, f.process_id, f.staff_id, f.staff_name, f.violin_factor, f.viola_factor, f.bass_factor, f.remark,
+ f.create_user, f.create_time, f.update_user, f.update_time,
+ too.name as processName
+ from production_costing_factor f
+ left join technology_operation too on too.id = f.process_id
+ <where>
+ <if test="c != null">
+ <if test="c.processId != null">
+ and f.process_id = #{c.processId}
+ </if>
+ <if test="c.staffId != null">
+ and f.staff_id = #{c.staffId}
+ </if>
+ <if test="c.staffName != null and c.staffName != ''">
+ and f.staff_name like concat('%', #{c.staffName}, '%')
+ </if>
+ </if>
+ </where>
+ order by f.process_id asc, f.staff_id asc
+ </select>
+
+</mapper>
diff --git a/src/main/resources/mapper/production/ProductionCostingMapper.xml b/src/main/resources/mapper/production/ProductionCostingMapper.xml
new file mode 100644
index 0000000..569a067
--- /dev/null
+++ b/src/main/resources/mapper/production/ProductionCostingMapper.xml
@@ -0,0 +1,47 @@
+<?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.ProductionCostingMapper">
+
+ <select id="selectCostingRows" resultType="com.ruoyi.production.bean.vo.ProductionCostingRawVo">
+ select
+ ppm.user_id as staffId,
+ ppm.user_name as staffName,
+ date_format(ppm.create_time, '%Y-%m') as yearMonth,
+ too.id as processId,
+ too.name as processName,
+ cd.dept_type as deptType,
+ ppo.product_model_id as productModelId,
+ p.product_name as productName,
+ pm.model as modelName,
+ sum(ifnull(ppo.quantity, 0)) as quantity
+ from production_product_main ppm
+ 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_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
+ <where>
+ ppm.audit_status = 1
+ and ppm.report_type in (0, 1)
+ <if test="c != null">
+ <if test="c.deptType != null">
+ and cd.dept_type = #{c.deptType}
+ </if>
+ <if test="c.yearMonth != null and c.yearMonth != ''">
+ and date_format(ppm.create_time, '%Y-%m') = #{c.yearMonth}
+ </if>
+ <if test="c.staffName != null and c.staffName != ''">
+ and ppm.user_name like concat('%', #{c.staffName}, '%')
+ </if>
+ <if test="c.processId != null">
+ and too.id = #{c.processId}
+ </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
+ order by yearMonth desc, ppm.user_id, too.id
+ </select>
+
+</mapper>
diff --git a/src/main/resources/mapper/production/ProductionCostingStandardMapper.xml b/src/main/resources/mapper/production/ProductionCostingStandardMapper.xml
new file mode 100644
index 0000000..ca821d0
--- /dev/null
+++ b/src/main/resources/mapper/production/ProductionCostingStandardMapper.xml
@@ -0,0 +1,29 @@
+<?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.ProductionCostingStandardMapper">
+
+ <select id="selectStandardList" resultType="com.ruoyi.production.pojo.ProductionCostingStandard">
+ select s.id, s.dept_type, s.process_id, s.product_model_id, s.standard_quantity, s.unit, s.remark,
+ s.create_user, s.create_time, s.update_user, s.update_time,
+ too.name as processName,
+ pm.model as modelName
+ from production_costing_standard s
+ left join technology_operation too on too.id = s.process_id
+ left join product_model pm on pm.id = s.product_model_id
+ <where>
+ <if test="c != null">
+ <if test="c.deptType != null">
+ and s.dept_type = #{c.deptType}
+ </if>
+ <if test="c.processId != null">
+ and s.process_id = #{c.processId}
+ </if>
+ <if test="c.productModelId != null">
+ and s.product_model_id = #{c.productModelId}
+ </if>
+ </if>
+ </where>
+ order by s.dept_type asc, s.process_id asc, s.product_model_id asc
+ </select>
+
+</mapper>
diff --git a/src/main/resources/mapper/production/ProductionCostingWorkdayMapper.xml b/src/main/resources/mapper/production/ProductionCostingWorkdayMapper.xml
new file mode 100644
index 0000000..8f1c5a8
--- /dev/null
+++ b/src/main/resources/mapper/production/ProductionCostingWorkdayMapper.xml
@@ -0,0 +1,19 @@
+<?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.ProductionCostingWorkdayMapper">
+
+ <select id="selectWorkdayList" resultType="com.ruoyi.production.pojo.ProductionCostingWorkday">
+ select w.id, w.work_month as yearMonth, w.work_days, w.remark,
+ w.create_user, w.create_time, w.update_user, w.update_time
+ from production_costing_workday w
+ <where>
+ <if test="c != null">
+ <if test="c.yearMonth != null and c.yearMonth != ''">
+ and w.work_month = #{c.yearMonth}
+ </if>
+ </if>
+ </where>
+ order by w.work_month desc
+ </select>
+
+</mapper>
--
Gitblit v1.9.3