| | |
| | | ) ENGINE = InnoDB |
| | | DEFAULT CHARSET = utf8mb4 COMMENT ='éå®ç产计å'; |
| | | |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_tyep` varchar(255) NULL COMMENT 'è½æºç±»å', |
| | | `energy_name` varchar(255) NULL COMMENT 'è½æºåç§°', |
| | | `unit` varchar(255) NULL COMMENT 'åä½', |
| | | `unit_price` decimal(10, 2) NULL COMMENT 'åä»·', |
| | | `remark` varchar(255) NULL COMMENT '夿³¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `create_user` bigint NULL DEFAULT NULL COMMENT 'å建è
', |
| | | `update_user` bigint NULL DEFAULT NULL COMMENT 'æ´æ°è
', |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy` |
| | | ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_tyep` varchar(255) NULL COMMENT 'è½æºç±»å', |
| | | `energy_name` varchar(255) NULL COMMENT 'è½æºåç§°', |
| | | `unit` varchar(255) NULL COMMENT 'åä½', |
| | | `unit_price` decimal(10, 2) NULL COMMENT 'åä»·', |
| | | `remark` varchar(255) NULL COMMENT '夿³¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `create_user` bigint NULL DEFAULT NULL COMMENT 'å建è
', |
| | | `update_user` bigint NULL DEFAULT NULL COMMENT 'æ´æ°è
', |
| | | PRIMARY KEY (`id`) |
| | | ) COMMENT = 'è½æºç±»å'; |
| | | ) COMMENT = 'è½æºç±»å'; |
| | | |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy_consumption_detail` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_id` int NULL COMMENT '夿£å
³èè½æºç±»åid', |
| | | `type` varchar(255) NULL COMMENT 'åå
¬/ç产', |
| | | `meter_reading_location` varchar(255) NULL COMMENT 'æè¡¨ä½ç½®', |
| | | `meter_reading_date` date NULL COMMENT 'æè¡¨æ¥æ', |
| | | `start_code` decimal(10, 2) NULL COMMENT 'èµ·ç ', |
| | | `stop_code` decimal(10, 2) NULL COMMENT 'æ¢ç ', |
| | | `dosage` decimal(10, 2) NULL COMMENT 'ç¨é', |
| | | `remark` varchar(255) NULL COMMENT '夿³¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `create_user` bigint NULL DEFAULT NULL COMMENT 'å建è
', |
| | | `update_user` bigint NULL DEFAULT NULL COMMENT 'æ´æ°è
', |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy_consumption_detail` |
| | | ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_id` int NULL COMMENT '夿£å
³èè½æºç±»åid', |
| | | `type` varchar(255) NULL COMMENT 'åå
¬/ç产', |
| | | `meter_reading_location` varchar(255) NULL COMMENT 'æè¡¨ä½ç½®', |
| | | `meter_reading_date` date NULL COMMENT 'æè¡¨æ¥æ', |
| | | `start_code` decimal(10, 2) NULL COMMENT 'èµ·ç ', |
| | | `stop_code` decimal(10, 2) NULL COMMENT 'æ¢ç ', |
| | | `dosage` decimal(10, 2) NULL COMMENT 'ç¨é', |
| | | `remark` varchar(255) NULL COMMENT '夿³¨', |
| | | `create_time` datetime(0) NULL DEFAULT NULL COMMENT 'å建æ¶é´', |
| | | `update_time` datetime(0) NULL DEFAULT NULL COMMENT 'æ´æ°æ¶é´', |
| | | `create_user` bigint NULL DEFAULT NULL COMMENT 'å建è
', |
| | | `update_user` bigint NULL DEFAULT NULL COMMENT 'æ´æ°è
', |
| | | PRIMARY KEY (`id`) |
| | | ) COMMENT = 'è½æºç±»å-è½èæè¡¨æç»'; |
| | | ) COMMENT = 'è½æºç±»å-è½èæè¡¨æç»'; |
| | | |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy_consumption_detail_file` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_consumption_detail_id` int NULL COMMENT 'å
³èå¤é®è½èæè¡¨id', |
| | | `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, |
| | | `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, |
| | | `file_size` double NULL DEFAULT NULL, |
| | | `create_time` timestamp(0) NULL DEFAULT NULL, |
| | | `create_user` int NULL DEFAULT NULL, |
| | | `update_time` timestamp(0) NULL DEFAULT NULL, |
| | | `update_user` int NULL DEFAULT NULL, |
| | | CREATE TABLE `product-inventory-management-zsjc`.`energy_consumption_detail_file` |
| | | ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `energy_consumption_detail_id` int NULL COMMENT 'å
³èå¤é®è½èæè¡¨id', |
| | | `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, |
| | | `url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL, |
| | | `file_size` double NULL DEFAULT NULL, |
| | | `create_time` timestamp(0) NULL DEFAULT NULL, |
| | | `create_user` int NULL DEFAULT NULL, |
| | | `update_time` timestamp(0) NULL DEFAULT NULL, |
| | | `update_user` int NULL DEFAULT NULL, |
| | | PRIMARY KEY (`id`) |
| | | ) COMMENT = 'è½æºç±»å-è½èæè¡¨æç»_éä»¶'; |
| | | ) COMMENT = 'è½æºç±»å-è½èæè¡¨æç»_éä»¶'; |
| | | |
| | | alter table product_order |
| | | drop column sales_ledger_id, |
| | | drop column sale_ledger_product_id, |
| | | drop column product_model_id; |
| | | drop column sales_ledger_id, |
| | | drop column sale_ledger_product_id, |
| | | drop column product_model_id; |
| | | |
| | | alter table production_plan |
| | | add assigned_quantity DECIMAL(10, 4) default 0 not null COMMENT 'ä¸åæ°é'; |
| | |
| | | drop table if exists product_order_plan; |
| | | create table product_order_plan |
| | | ( |
| | | id bigint auto_increment primary key, |
| | | product_order_id bigint not null default 0 comment 'ç产订åid', |
| | | production_plan_id bigint not null default 0 comment 'ç产计åid', |
| | | create_time datetime null comment 'å½å
¥æ¶é´', |
| | | update_time datetime null comment 'æ´æ°æ¶é´', |
| | | assigned_quantity DECIMAL(10, 4) default 0 not null comment 'ä¸åæ°é', |
| | | id bigint auto_increment primary key, |
| | | product_order_id bigint not null default 0 comment 'ç产订åid', |
| | | production_plan_id bigint not null default 0 comment 'ç产计åid', |
| | | create_time datetime null comment 'å½å
¥æ¶é´', |
| | | update_time datetime null comment 'æ´æ°æ¶é´', |
| | | assigned_quantity DECIMAL(10, 4) default 0 not null comment 'ä¸åæ°é', |
| | | index idx_product_order_id (product_order_id), |
| | | index idx_production_plan_id (production_plan_id), |
| | | unique idx_product_order_production_plan (product_order_id, production_plan_id) |
| | |
| | | |
| | | CREATE TABLE `product_material` |
| | | ( |
| | | `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT '主é®ID', |
| | | `tenant_id` BIGINT DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | `material_type_id` INT DEFAULT NULL COMMENT 'å
³èç©æç±»åID', |
| | | `inventory_category_id` INT DEFAULT NULL COMMENT 'å
³èåè´§ç±»å«ID', |
| | | `identifier_code` VARCHAR(100) DEFAULT NULL COMMENT 'æ è¯ç¼ç ', |
| | | `material_code` VARCHAR(100) DEFAULT NULL COMMENT 'ç©æä»£ç ', |
| | | `product_name` VARCHAR(255) DEFAULT NULL COMMENT '产ååç§°', |
| | | `material_name` VARCHAR(255) DEFAULT NULL COMMENT 'ç©æåå', |
| | | `specification` VARCHAR(255) DEFAULT NULL COMMENT 'è§æ ¼åå·', |
| | | `base_unit` VARCHAR(50) DEFAULT NULL COMMENT 'åºæ¬åä½', |
| | | `material_attribute` VARCHAR(100) DEFAULT NULL COMMENT 'ç©æå±æ§', |
| | | `finished_product_name` VARCHAR(100) DEFAULT NULL COMMENT 'æååå', |
| | | `originator_name` VARCHAR(100) DEFAULT NULL COMMENT 'æäº¤äººå§å', |
| | | `originator_org` VARCHAR(255) DEFAULT 'å®å¤ä¸å绿è½å®ä¸é墿éå
¬å¸', |
| | | `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主é®ID', |
| | | `tenant_id` BIGINT DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | `material_type_id` INT DEFAULT NULL COMMENT 'ç©æç±»åID', |
| | | `inventory_category_id` INT DEFAULT NULL COMMENT 'åè´§ç±»å«ID', |
| | | `material_name` VARCHAR(255) NOT NULL COMMENT 'ç©æåç§°', |
| | | `base_unit` VARCHAR(50) DEFAULT NULL COMMENT 'åºæ¬åä½', |
| | | `remark` TEXT COMMENT '夿³¨', |
| | | `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| | | INDEX `idx_type_id` (`material_type_id`), |
| | | INDEX `idx_cat_id` (`inventory_category_id`) |
| | | `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| | | PRIMARY KEY (`id`), |
| | | KEY `idx_type_id` (`material_type_id`), |
| | | KEY `idx_cat_id` (`inventory_category_id`), |
| | | UNIQUE KEY `uk_material_name` (`material_name`) |
| | | ) ENGINE = INNODB |
| | | DEFAULT CHARSET = utf8mb4 COMMENT = 'ç©æä¿¡æ¯è¡¨'; |
| | | DEFAULT CHARSET = utf8mb4 COMMENT = 'ç©æä¸»è¡¨'; |
| | | CREATE TABLE `product_material_sku` |
| | | ( |
| | | `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主é®ID', |
| | | `material_id` BIGINT NOT NULL COMMENT 'ç©æID', |
| | | `identifier_code` VARCHAR(100) DEFAULT NULL COMMENT 'æ è¯ç¼ç ', |
| | | `material_code` VARCHAR(100) DEFAULT NULL COMMENT 'ç©æç¼ç ', |
| | | `specification` VARCHAR(255) DEFAULT NULL COMMENT 'è§æ ¼åå·', |
| | | `supply_type` VARCHAR(20) DEFAULT NULL COMMENT 'ä¾åºæ¹å¼', |
| | | `originator_name` VARCHAR(100) DEFAULT NULL COMMENT 'æäº¤äººå§å', |
| | | `originator_org` VARCHAR(255) DEFAULT 'å®å¤ä¸å绿è½å®ä¸é墿éå
¬å¸', |
| | | `form_instance_id` VARCHAR(100) DEFAULT NULL COMMENT 'å®æè¡¨åå®ä¾ID', |
| | | `form_modified_time` DATETIME DEFAULT NULL COMMENT 'å®æä¿®æ¹æ¶é´', |
| | | `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP, |
| | | `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| | | PRIMARY KEY (`id`), |
| | | KEY `idx_material_id` (`material_id`), |
| | | UNIQUE KEY `uk_material_spec` (`material_id`, `specification`), |
| | | CONSTRAINT `fk_material` FOREIGN KEY (`material_id`) REFERENCES `product_material` (`id`) ON DELETE CASCADE |
| | | ) ENGINE = INNODB |
| | | DEFAULT CHARSET = utf8mb4 COMMENT = 'ç©æè§æ ¼è¡¨'; |
| | | |
| | | ALTER TABLE product_material |
| | | ADD COLUMN form_instance_id VARCHAR(100) DEFAULT NULL COMMENT 'å®æè¡¨åå®ä¾ID', |
| | | ADD COLUMN form_modified_time DATETIME DEFAULT NULL COMMENT 'å®æä¿®æ¹æ¶é´'; |
| | | ALTER TABLE product_material_sku |
| | | DROP FOREIGN KEY fk_material; |
| | | |
| | | DROP TABLE IF EXISTS `product_material_config`; |
| | | CREATE TABLE `product_material_config` |
| | | ( |
| | | `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 ='ç©æä¿¡æ¯è¡¨é
置表'; |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `config_type` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT 'åºåç±»å: MATERIAL_TYPE æ INVENTORY_CAT', |
| | | `config_name` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT 'æ¾ç¤ºçåç§°', |
| | | PRIMARY KEY (`id`) USING BTREE |
| | | ) ENGINE = InnoDB |
| | | AUTO_INCREMENT = 39 |
| | | CHARACTER SET = utf8mb3 |
| | | COLLATE = utf8mb3_general_ci COMMENT = 'ç©æä¿¡æ¯è¡¨é
置表' |
| | | ROW_FORMAT = Dynamic; |
| | | |
| | | ALTER TABLE `production_plan` |
| | | ADD COLUMN `product_material_id` int DEFAULT NULL COMMENT 'å
³èç©æä¿¡æ¯è¡¨ID' AFTER `material_code`; |
| | | |
| | | -- 建议顺便å ä¸ç´¢å¼ï¼æåå
³èæ¥è¯¢é度 |
| | | ALTER TABLE `production_plan` |
| | | ADD INDEX `idx_product_material_id` (`product_material_id`); |
| | | SET FOREIGN_KEY_CHECKS = 1; |
| | |
| | | package com.ruoyi.energy.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | |
| | | public class EnergyCostDto { |
| | | |
| | | @ApiModelProperty("æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate meterReadingDate; |
| | | |
| | | @ApiModelProperty("ç¨æ°´é") |
| | |
| | | package com.ruoyi.energy.vo; |
| | | |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import lombok.Data; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | import java.time.LocalDate; |
| | | |
| | |
| | | public class EnergyStatisticsVo { |
| | | |
| | | //å¼å§æ¥æ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate startDate; |
| | | |
| | | //ç»ææ¥æ |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate endDate; |
| | | |
| | | //æ¥è¯¢é´éå¤©æ° |
| | |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log; |
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.dto.ProductMaterialConfigDto; |
| | | import com.ruoyi.production.dto.ProductMaterialGroupDto; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialConfig; |
| | | import com.ruoyi.production.service.ProductMaterialConfigService; |
| | | import com.ruoyi.production.service.ProductMaterialService; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @Autowired |
| | | private ProductMaterialService productMaterialService; |
| | | |
| | | @Autowired |
| | | private ProductMaterialConfigService productMaterialConfigService; |
| | | |
| | | @GetMapping("/loadData") |
| | | @ApiOperation("æåç©æç¼ç æ°æ®") |
| | | @Log(title = "æåç©æç¼ç æ°æ®", businessType = BusinessType.INSERT) |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation("ç©ææ°æ®") |
| | | @Log(title = "ç©ææ°æ®", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialList(String materialName) { |
| | | List<ProductMaterialGroupDto> productMaterialMap = productMaterialService.ProductMaterialList(materialName); |
| | | return AjaxResult.success(productMaterialMap); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation("æ°å¢ç©æ") |
| | | @Log(title = "æ°å¢ç©æ", businessType = BusinessType.INSERT) |
| | | public AjaxResult addProductMaterial(@RequestBody ProductMaterial productMaterial) { |
| | | productMaterialService.addProductMaterial(productMaterial); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @ApiOperation("ä¿®æ¹ç©æ") |
| | | @Log(title = "ä¿®æ¹ç©æ", businessType = BusinessType.UPDATE) |
| | | public AjaxResult updateProductMaterial(@RequestBody ProductMaterial productMaterial) { |
| | | productMaterialService.updateProductMaterial(productMaterial); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("å é¤ç©æ") |
| | | @Log(title = "å é¤ç©æ", businessType = BusinessType.DELETE) |
| | | public AjaxResult deleteProductMaterial(@RequestBody List<Long> ids) { |
| | | productMaterialService.deleteProductMaterial(ids); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | @GetMapping("/materialTypeList") |
| | | @ApiOperation("ç©æç±»åæ°æ®éå") |
| | | @Log(title = "ç©æç±»åæ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult materialTypeList() { |
| | | List<ProductMaterialConfig> list = productMaterialConfigService.materialTypeList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @GetMapping("/inventoryCategoryList") |
| | | @ApiOperation("'åè´§ç±»å«æ°æ®éå") |
| | | @Log(title = "'åè´§ç±»å«æ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult inventoryCategoryList() { |
| | | List<ProductMaterialConfig> list = productMaterialConfigService.inventoryCategoryList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/config/add") |
| | | @ApiOperation("æ°å¢ç©æé
ç½®") |
| | | @Log(title = "æ°å¢ç©æé
ç½®", businessType = BusinessType.INSERT) |
| | | public AjaxResult addProductMaterialConfig(@RequestBody ProductMaterialConfigDto config) { |
| | | productMaterialConfigService.addProductMaterialConfig(config); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/config/update") |
| | | @ApiOperation("ä¿®æ¹ç©æé
ç½®") |
| | | @Log(title = "ä¿®æ¹ç©æé
ç½®", businessType = BusinessType.UPDATE) |
| | | public AjaxResult updateProductMaterialConfig(@RequestBody ProductMaterialConfigDto config) { |
| | | productMaterialConfigService.updateProductMaterialConfig(config); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/config/delete") |
| | | @ApiOperation("å é¤ç©æé
ç½®") |
| | | @Log(title = "å é¤ç©æé
ç½®", businessType = BusinessType.DELETE) |
| | | public AjaxResult deleteProductMaterialConfig(@RequestBody List<Integer> ids) { |
| | | productMaterialConfigService.deleteProductMaterialConfig(ids); |
| | | return AjaxResult.success(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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.AjaxResult; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuDto; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductMaterialSkuImportDto; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æè§æ ¼æ§å¶å± |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 10:43 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/productMaterialSku") |
| | | @Api(tags = "ç©æè§æ ¼ç®¡çæ¥å£") |
| | | public class ProductMaterialSkuController { |
| | | |
| | | @Autowired |
| | | private ProductMaterialSkuService productMaterialSkuService; |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation("ç©æè§æ ¼æ°æ®éå") |
| | | @Log(title = "ç©æè§æ ¼æ°æ®éå", businessType = BusinessType.OTHER) |
| | | public AjaxResult productMaterialSkuList(@RequestParam("materialId") Long materialId) { |
| | | List<ProductMaterialSkuDto> list = productMaterialSkuService.productMaterialSkuList(materialId); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation("æ°å¢ç©æè§æ ¼") |
| | | @Log(title = "æ°å¢ç©æè§æ ¼", businessType = BusinessType.INSERT) |
| | | public AjaxResult addProductMaterialSku(@RequestBody ProductMaterialSku productMaterialSku) { |
| | | productMaterialSkuService.addProductMaterialSku(productMaterialSku); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @ApiOperation("ä¿®æ¹ç©æè§æ ¼") |
| | | @Log(title = "ä¿®æ¹ç©æè§æ ¼", businessType = BusinessType.UPDATE) |
| | | public AjaxResult updateProductMaterialSku(@RequestBody ProductMaterialSku productMaterialSku) { |
| | | productMaterialSkuService.updateProductMaterialSku(productMaterialSku); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("å é¤ç©æè§æ ¼") |
| | | @Log(title = "å é¤ç©æè§æ ¼", businessType = BusinessType.DELETE) |
| | | public AjaxResult deleteProductMaterialSku(@RequestBody List<Long> ids) { |
| | | productMaterialSkuService.deleteProductMaterialSku(ids); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PostMapping("/downloadTemplate") |
| | | @Log(title = "ä¸è½½ç©æè§æ ¼å¯¼å
¥æ¨¡æ¿", businessType = BusinessType.EXPORT) |
| | | @ApiOperation("ä¸è½½ç©æè§æ ¼å¯¼å
¥æ¨¡æ¿") |
| | | public void importTemplate(HttpServletResponse response) { |
| | | ExcelUtil<ProductMaterialSkuImportDto> excelUtil = new ExcelUtil<>(ProductMaterialSkuImportDto.class); |
| | | excelUtil.importTemplateExcel(response, "ä¸è½½ç©æè§æ ¼å¯¼å
¥æ¨¡æ¿"); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @ApiOperation("ç©æè§æ ¼æ°æ®å¯¼å
¥") |
| | | @Log(title = "ç©æè§æ ¼æ°æ®å¯¼å
¥", businessType = BusinessType.IMPORT) |
| | | public AjaxResult importProdData(@RequestParam("file") MultipartFile file, @RequestParam("materialId") Long materialId) { |
| | | productMaterialSkuService.importProdData(file, materialId); |
| | | return AjaxResult.success("导å
¥æå"); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.ruoyi.production.pojo.ProductMaterialConfig; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æä¿¡æ¯è¡¨é
置表Dto |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 14:07 |
| | | */ |
| | | @Data |
| | | public class ProductMaterialConfigDto extends ProductMaterialConfig { |
| | | |
| | | @ApiModelProperty("é
置类å") |
| | | @TableField(exist = false) |
| | | private Integer type; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æé
ç½®åç» DTO |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @since 2026/03/12 13:43 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ProductMaterialGroupDto", description = "ç©æé
ç½®åç»æ°æ®") |
| | | public class ProductMaterialGroupDto { |
| | | |
| | | @ApiModelProperty("é
ç½®ID") |
| | | private Integer configId; |
| | | |
| | | @ApiModelProperty("é
ç½®åç§°") |
| | | private String configName; |
| | | |
| | | @ApiModelProperty("ç©æå表") |
| | | private List<ProductMaterial> materialList; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.dto; |
| | | |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æ + è§æ ¼ DTO |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 10:50 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ProductMaterialSkuDto", description = "ç©æSKUä¿¡æ¯") |
| | | public class ProductMaterialSkuDto { |
| | | |
| | | @ApiModelProperty("ç©æID") |
| | | private Long materialId; |
| | | |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String baseUnit; |
| | | |
| | | @ApiModelProperty("è§æ ¼ID") |
| | | private Long skuId; |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | |
| | | @ApiModelProperty("ä¾åºæ¹å¼") |
| | | private String supplyType; |
| | | |
| | | } |
| | |
| | | |
| | | /** |
| | | * ç©æç±»å |
| | | * å¯¹åºæ°æ®åº config_type = MATERIAL_TYPE |
| | | */ |
| | | MATERIAL_TYPE, |
| | | MATERIAL_TYPE(1, "ç©æç±»å"), |
| | | |
| | | /** |
| | | * åè´§ç±»å« |
| | | * å¯¹åºæ°æ®åº config_type = INVENTORY_CAT |
| | | */ |
| | | INVENTORY_CAT |
| | | INVENTORY_CAT(2, "åè´§ç±»å«"); |
| | | |
| | | private final Integer type; |
| | | private final String desc; |
| | | |
| | | MaterialConfigTypeEnum(Integer type, String desc) { |
| | | this.type = type; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public Integer getType() { |
| | | return type; |
| | | } |
| | | |
| | | public String getDesc() { |
| | | return desc; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® type è·åæä¸¾ |
| | | */ |
| | | public static MaterialConfigTypeEnum getByType(Integer type) { |
| | | for (MaterialConfigTypeEnum value : values()) { |
| | | if (value.type.equals(type)) { |
| | | return value; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ® type è·åæ°æ®åºåå¨å¼ |
| | | */ |
| | | public static String getConfigType(Integer type) { |
| | | MaterialConfigTypeEnum e = getByType(type); |
| | | if (e == null) { |
| | | throw new IllegalArgumentException("é
置类åé误"); |
| | | } |
| | | return e.name(); |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æè§æ ¼Mapper |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 10:04 |
| | | */ |
| | | public interface ProductMaterialSkuMapper extends BaseMapper<ProductMaterialSku> { |
| | | } |
| | |
| | | */ |
| | | @Data |
| | | @TableName("product_material") |
| | | @ApiModel(value = "ProductMaterial", description = "产åç©æä¿¡æ¯è¡¨") |
| | | @ApiModel(value = "ProductMaterial", description = "ç©æä¸»è¡¨") |
| | | public class ProductMaterial { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | @ApiModelProperty("主é®ID") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç§æ·ID") |
| | | private Long tenantId; |
| | |
| | | @ApiModelProperty("åè´§ç±»å«ID") |
| | | private Integer inventoryCategoryId; |
| | | |
| | | @ApiModelProperty("æ è¯ç¼ç ") |
| | | private String identifierCode; |
| | | |
| | | @ApiModelProperty("ç©æä»£ç ") |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty("ç©æåå") |
| | | @ApiModelProperty("ç©æåç§°") |
| | | private String materialName; |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | |
| | | @ApiModelProperty("åºæ¬åä½") |
| | | private String baseUnit; |
| | | |
| | | @ApiModelProperty("ç©æå±æ§") |
| | | private String materialAttribute; |
| | | |
| | | @ApiModelProperty("æååå") |
| | | private String finishedProductName; |
| | | |
| | | @ApiModelProperty("æäº¤äººå§å") |
| | | private String originatorName; |
| | | |
| | | @ApiModelProperty("æäº¤äººç»ç»") |
| | | private String originatorOrg; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | |
| | | @ApiModelProperty("å®æè¡¨åå®ä¾ID") |
| | | private String formInstanceId; |
| | | |
| | | @ApiModelProperty("å®æä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime formModifiedTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æè§æ ¼è¡¨ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 10:02 |
| | | */ |
| | | @Data |
| | | @TableName("product_material_sku") |
| | | @ApiModel(value = "ProductMaterialSku", description = "ç©æè§æ ¼è¡¨") |
| | | public class ProductMaterialSku { |
| | | |
| | | @TableId(type = IdType.AUTO) |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç©æID") |
| | | private Long materialId; |
| | | |
| | | @ApiModelProperty("æ è¯ç¼ç ") |
| | | private String identifierCode; |
| | | |
| | | @ApiModelProperty("ç©æç¼ç ") |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | |
| | | @ApiModelProperty("ä¾åºæ¹å¼ï¼èªå¶ï¼å¤è´ï¼") |
| | | private String supplyType; |
| | | |
| | | @ApiModelProperty("æäº¤äººå§å") |
| | | private String originatorName; |
| | | |
| | | @ApiModelProperty("æäº¤äººç»ç»") |
| | | private String originatorOrg; |
| | | |
| | | @ApiModelProperty("å®æè¡¨åå®ä¾ID") |
| | | private String formInstanceId; |
| | | |
| | | @ApiModelProperty("å®æä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime formModifiedTime; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty("ä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime updateTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æè§æ ¼å¯¼å
¥ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 13:08 |
| | | */ |
| | | @Data |
| | | @ApiModel(value = "ProductMaterialSkuImportDto", description = "ç©æè§æ ¼è¡¨å¯¼å
¥") |
| | | public class ProductMaterialSkuImportDto { |
| | | |
| | | @ApiModelProperty("è§æ ¼åå·") |
| | | @Excel(name = "è§æ ¼åå·") |
| | | private String specification; |
| | | |
| | | @ApiModelProperty("ä¾åºæ¹å¼ï¼èªå¶ï¼å¤è´ï¼") |
| | | @Excel(name = "ä¾åºæ¹å¼") |
| | | private String supplyType; |
| | | |
| | | |
| | | } |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProductMaterialConfigDto; |
| | | import com.ruoyi.production.pojo.ProductMaterialConfig; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | * @since 2026/03/11 16:58 |
| | | */ |
| | | public interface ProductMaterialConfigService extends IService<ProductMaterialConfig> { |
| | | List<ProductMaterialConfig> materialTypeList(); |
| | | |
| | | List<ProductMaterialConfig> inventoryCategoryList(); |
| | | |
| | | void addProductMaterialConfig(ProductMaterialConfigDto config); |
| | | |
| | | void updateProductMaterialConfig(ProductMaterialConfigDto config); |
| | | |
| | | void deleteProductMaterialConfig(List<Integer> ids); |
| | | } |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProductMaterialGroupDto; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | void loadProductMaterialData(); |
| | | |
| | | void syncProductMaterialJob(); |
| | | |
| | | List<ProductMaterialGroupDto> ProductMaterialList(String materialName); |
| | | |
| | | void addProductMaterial(ProductMaterial productMaterial); |
| | | |
| | | void updateProductMaterial(ProductMaterial productMaterial); |
| | | |
| | | void deleteProductMaterial(List<Long> ids); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuDto; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æè§æ ¼æ¥å£ |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 10:04 |
| | | */ |
| | | public interface ProductMaterialSkuService extends IService<ProductMaterialSku> { |
| | | List<ProductMaterialSkuDto> productMaterialSkuList(Long materialId); |
| | | |
| | | void addProductMaterialSku(ProductMaterialSku productMaterialSku); |
| | | |
| | | void updateProductMaterialSku(ProductMaterialSku productMaterialSku); |
| | | |
| | | void deleteProductMaterialSku(List<Long> ids); |
| | | |
| | | void importProdData(MultipartFile file, Long materialId); |
| | | } |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.production.dto.ProductMaterialConfigDto; |
| | | import com.ruoyi.production.enums.MaterialConfigTypeEnum; |
| | | import com.ruoyi.production.mapper.ProductMaterialConfigMapper; |
| | | import com.ruoyi.production.pojo.ProductMaterialConfig; |
| | | import com.ruoyi.production.service.ProductMaterialConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @Service |
| | | public class ProductMaterialConfigServiceImpl extends ServiceImpl<ProductMaterialConfigMapper, ProductMaterialConfig> implements ProductMaterialConfigService { |
| | | |
| | | @Override |
| | | public List<ProductMaterialConfig> materialTypeList() { |
| | | return getByType(MaterialConfigTypeEnum.MATERIAL_TYPE); |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductMaterialConfig> inventoryCategoryList() { |
| | | return getByType(MaterialConfigTypeEnum.INVENTORY_CAT); |
| | | } |
| | | |
| | | private List<ProductMaterialConfig> getByType(MaterialConfigTypeEnum type) { |
| | | return list(new LambdaQueryWrapper<ProductMaterialConfig>().eq(ProductMaterialConfig::getConfigType, type.name())); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addProductMaterialConfig(ProductMaterialConfigDto config) { |
| | | config.setConfigType(MaterialConfigTypeEnum.getConfigType(config.getType())); |
| | | validateConfig(config, false); |
| | | if (existsConfig(config.getConfigType(), config.getConfigName(), null)) { |
| | | throw new ServiceException("é
ç½®åç§°å·²åå¨"); |
| | | } |
| | | if (!this.save(config)) { |
| | | throw new ServiceException("æ°å¢é
置失败"); |
| | | } |
| | | log.info("æ°å¢ç©æé
ç½®æå type={}, name={}", config.getConfigType(), config.getConfigName()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateProductMaterialConfig(ProductMaterialConfigDto config) { |
| | | config.setConfigType(MaterialConfigTypeEnum.getConfigType(config.getType())); |
| | | validateConfig(config, true); |
| | | ProductMaterialConfig exist = this.getById(config.getId()); |
| | | if (exist == null) { |
| | | throw new ServiceException("é
ç½®ä¸åå¨"); |
| | | } |
| | | if (existsConfig(config.getConfigType(), config.getConfigName(), config.getId())) { |
| | | throw new ServiceException("é
ç½®åç§°å·²åå¨"); |
| | | } |
| | | if (!this.updateById(config)) { |
| | | throw new ServiceException("ä¿®æ¹é
置失败"); |
| | | } |
| | | log.info("ä¿®æ¹ç©æé
ç½®æå id={}", config.getId()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteProductMaterialConfig(List<Integer> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | throw new ServiceException("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | if (!this.removeByIds(ids)) { |
| | | throw new ServiceException("å é¤é
置失败"); |
| | | } |
| | | log.info("å é¤ç©æé
ç½®æå ids={}", ids); |
| | | } |
| | | |
| | | private void validateConfig(ProductMaterialConfig config, boolean requireId) { |
| | | if (config == null) { |
| | | throw new ServiceException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (requireId && config.getId() == null) { |
| | | throw new ServiceException("主é®IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isEmpty(config.getConfigType())) { |
| | | throw new ServiceException("é
置类åä¸è½ä¸ºç©º"); |
| | | } |
| | | try { |
| | | MaterialConfigTypeEnum.valueOf(config.getConfigType()); |
| | | } catch (IllegalArgumentException e) { |
| | | throw new ServiceException("é
置类åä¸åæ³"); |
| | | } |
| | | if (StringUtils.isEmpty(config.getConfigName())) { |
| | | throw new ServiceException("é
ç½®åç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | |
| | | private boolean existsConfig(String configType, String configName, Integer excludeId) { |
| | | if (StringUtils.isEmpty(configName) || StringUtils.isEmpty(configType)) { |
| | | return false; |
| | | } |
| | | LambdaQueryWrapper<ProductMaterialConfig> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterialConfig::getConfigType, configType).eq(ProductMaterialConfig::getConfigName, configName); |
| | | if (excludeId != null) { |
| | | wrapper.ne(ProductMaterialConfig::getId, excludeId); |
| | | } |
| | | return this.count(wrapper) > 0; |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.http.HttpUtils; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.production.dto.ProductMaterialGroupDto; |
| | | import com.ruoyi.production.enums.MaterialConfigTypeEnum; |
| | | import com.ruoyi.production.mapper.ProductMaterialMapper; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialConfig; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.service.ProductMaterialConfigService; |
| | | import com.ruoyi.production.service.ProductMaterialService; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.format.DateTimeParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ProductMaterialConfigService productMaterialConfigService; |
| | | |
| | | @Autowired |
| | | private ProductMaterialSkuService productMaterialSkuService; |
| | | |
| | | /** |
| | | * 忥éï¼é²æ¢æå¨å宿¶ä»»å¡åæ¶æ§è¡ |
| | | */ |
| | | private final ReentrantLock syncLock = new ReentrantLock(); |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void loadProductMaterialData() { |
| | | syncProductMaterialData(1); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void syncProductMaterialJob() { |
| | | syncProductMaterialData(2); |
| | | } |
| | |
| | | JSONObject searchParam = buildSearchParam(lastSyncTime, pageNumber, pageSize); |
| | | |
| | | // è°ç¨å®ææ¥å£æåæ°æ® |
| | | String dataRes = HttpUtils.sendPostJson( |
| | | aliDingConfig.getSearchFormDataUrl(), |
| | | searchParam.toJSONString(), |
| | | StandardCharsets.UTF_8.name(), |
| | | null, |
| | | accessToken |
| | | ); |
| | | String dataRes = HttpUtils.sendPostJson(aliDingConfig.getSearchFormDataUrl(), searchParam.toJSONString(), StandardCharsets.UTF_8.name(), null, accessToken); |
| | | |
| | | if (StringUtils.isEmpty(dataRes)) { |
| | | log.warn("第 {} 页æåæ°æ®ä¸ºç©º", pageNumber); |
| | |
| | | } |
| | | |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<ProductMaterial> list = parseProductMaterials(dataArr, totalCount); |
| | | List<ProductMaterialSku> list = parseProductMaterials(dataArr, totalCount); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | |
| | | } |
| | | |
| | | private String getAccessToken() { |
| | | String params = "appkey=" + aliDingConfig.getAppKey() |
| | | + "&appsecret=" + aliDingConfig.getAppSecret(); |
| | | String params = "appkey=" + aliDingConfig.getAppKey() + "&appsecret=" + aliDingConfig.getAppSecret(); |
| | | String tokenRes = HttpUtils.sendGet(aliDingConfig.getAccessTokenUrl(), params); |
| | | JSONObject tokenObj = JSON.parseObject(tokenRes); |
| | | String accessToken = tokenObj.getString("access_token"); |
| | |
| | | } |
| | | |
| | | private LocalDateTime getLastSyncTime() { |
| | | LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(ProductMaterial::getFormModifiedTime).last("LIMIT 1"); |
| | | ProductMaterial lastRecord = this.getOne(queryWrapper); |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(ProductMaterialSku::getFormModifiedTime).last("LIMIT 1"); |
| | | ProductMaterialSku lastRecord = productMaterialSkuService.getOne(queryWrapper); |
| | | return lastRecord != null ? lastRecord.getFormModifiedTime() : null; |
| | | } |
| | | |
| | |
| | | searchParam.put("orderConfigJson", "{\"gmt_modified\":\"+\"}"); |
| | | |
| | | if (lastSyncTime != null) { |
| | | String startTime = lastSyncTime.plusSeconds(1).atZone(ZoneId.systemDefault()) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String startTime = lastSyncTime.plusSeconds(1).atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedFromTimeGMT", startTime); |
| | | } |
| | | |
| | | String endTime = LocalDateTime.now().atZone(ZoneId.systemDefault()) |
| | | .format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | String endTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | searchParam.put("modifiedToTimeGMT", endTime); |
| | | |
| | | return searchParam; |
| | | } |
| | | |
| | | private List<ProductMaterial> parseProductMaterials(JSONArray dataArr, Integer totalCount) { |
| | | List<ProductMaterial> list = new ArrayList<>(); |
| | | private List<ProductMaterialSku> parseProductMaterials(JSONArray dataArr, Integer totalCount) { |
| | | List<ProductMaterialSku> list = new ArrayList<>(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | |
| | | for (int i = 0; i < dataArr.size(); i++) { |
| | |
| | | String formInstanceId = item.getString("formInstanceId"); |
| | | |
| | | JSONObject originator = item.getJSONObject("originator"); |
| | | String originatorName = originator != null && originator.containsKey("userName") |
| | | ? originator.getJSONObject("userName").getString("nameInChinese") : "æªç¥"; |
| | | |
| | | String originatorName = originator != null && originator.containsKey("userName") ? originator.getJSONObject("userName").getString("nameInChinese") : "æªç¥"; |
| | | JSONObject formData = item.getJSONObject("formData"); |
| | | // å¤çç©æä¸»è¡¨æ°æ® |
| | | ProductMaterial material = new ProductMaterial(); |
| | | |
| | | material.setFormInstanceId(formInstanceId); |
| | | material.setIdentifierCode(formData.getString("textField_l92h77ju")); |
| | | material.setMaterialCode(formData.getString("textField_l92f36f2")); |
| | | material.setMaterialName(formData.getString("textField_l92f36f5")); |
| | | material.setSpecification(formData.getString("textField_l92f36f6")); |
| | | material.setBaseUnit(formData.getString("textField_la147lnw")); |
| | | material.setMaterialAttribute(formData.getString("selectField_la14k51j")); |
| | | material.setFinishedProductName(formData.getString("radioField_lbkk2nn2")); |
| | | material.setRemark(formData.getString("textareaField_l92f36f9")); |
| | | |
| | | // å¤çç©æç±»åååè´§ç±»å« |
| | | String materialType = formData.getString("selectField_l92f36fb"); |
| | | String inventoryCat = formData.getString("selectField_la154noy"); |
| | | material.setMaterialTypeId(getOrCreateConfigId(materialType, MaterialConfigTypeEnum.MATERIAL_TYPE.name())); |
| | | material.setInventoryCategoryId(getOrCreateConfigId(inventoryCat, MaterialConfigTypeEnum.INVENTORY_CAT.name())); |
| | | |
| | | material.setOriginatorName(originatorName); |
| | | material.setOriginatorOrg("å®å¤ä¸å绿è½å®ä¸é墿éå
¬å¸"); |
| | | Long materialId = getOrCreateMaterial(material); |
| | | |
| | | material.setFormModifiedTime(parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | material.setCreateTime(now); |
| | | material.setUpdateTime(now); |
| | | // å¤çç©æè§æ ¼æ°æ® |
| | | ProductMaterialSku sku = new ProductMaterialSku(); |
| | | sku.setMaterialId(materialId); |
| | | sku.setFormInstanceId(formInstanceId); |
| | | sku.setIdentifierCode(formData.getString("textField_l92h77ju")); |
| | | sku.setMaterialCode(formData.getString("textField_l92f36f2")); |
| | | sku.setSpecification(formData.getString("textField_l92f36f6")); |
| | | sku.setSupplyType(formData.getString("selectField_la14k51j")); |
| | | sku.setOriginatorName(originatorName); |
| | | sku.setOriginatorOrg("å®å¤ä¸å绿è½å®ä¸é墿éå
¬å¸"); |
| | | sku.setFormModifiedTime(parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | sku.setCreateTime(now); |
| | | sku.setUpdateTime(now); |
| | | |
| | | list.add(material); |
| | | list.add(sku); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private Long getOrCreateMaterial(ProductMaterial material) { |
| | | LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterial::getMaterialName, material.getMaterialName()); |
| | | |
| | | ProductMaterial exist = this.getOne(queryWrapper); |
| | | if (exist == null) { |
| | | material.setCreateTime(LocalDateTime.now()); |
| | | material.setUpdateTime(LocalDateTime.now()); |
| | | this.save(material); |
| | | return material.getId(); |
| | | } else { |
| | | // 妿已åå¨ï¼ä½å
³é®å±æ§åçååï¼åè¿è¡æ´æ°ï¼ä»¥å®ææ°æ®ä¸ºåï¼ |
| | | boolean needUpdate = false; |
| | | if (material.getMaterialTypeId() != null && !material.getMaterialTypeId().equals(exist.getMaterialTypeId())) { |
| | | exist.setMaterialTypeId(material.getMaterialTypeId()); |
| | | needUpdate = true; |
| | | } |
| | | if (material.getInventoryCategoryId() != null && !material.getInventoryCategoryId().equals(exist.getInventoryCategoryId())) { |
| | | exist.setInventoryCategoryId(material.getInventoryCategoryId()); |
| | | needUpdate = true; |
| | | } |
| | | if (StringUtils.isNotEmpty(material.getBaseUnit()) && !material.getBaseUnit().equals(exist.getBaseUnit())) { |
| | | exist.setBaseUnit(material.getBaseUnit()); |
| | | needUpdate = true; |
| | | } |
| | | if (needUpdate) { |
| | | exist.setUpdateTime(LocalDateTime.now()); |
| | | this.updateById(exist); |
| | | } |
| | | return exist.getId(); |
| | | } |
| | | } |
| | | |
| | | private Integer getOrCreateConfigId(String name, String type) { |
| | | if (StringUtils.isEmpty(name)) { |
| | | return null; |
| | | } |
| | | ProductMaterialConfig config = productMaterialConfigService.getOne(new LambdaQueryWrapper<ProductMaterialConfig>() |
| | | .eq(ProductMaterialConfig::getConfigName, name) |
| | | .eq(ProductMaterialConfig::getConfigType, type)); |
| | | ProductMaterialConfig config = productMaterialConfigService.getOne(new LambdaQueryWrapper<ProductMaterialConfig>().eq(ProductMaterialConfig::getConfigName, name).eq(ProductMaterialConfig::getConfigType, type)); |
| | | if (config == null) { |
| | | config = new ProductMaterialConfig(); |
| | | config.setConfigName(name); |
| | |
| | | return config.getId(); |
| | | } |
| | | |
| | | private int processSaveOrUpdate(List<ProductMaterial> list) { |
| | | private int processSaveOrUpdate(List<ProductMaterialSku> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return 0; |
| | | } |
| | | int affected = 0; |
| | | |
| | | for (ProductMaterial material : list) { |
| | | ProductMaterial exist = this.getOne(new LambdaQueryWrapper<ProductMaterial>() |
| | | .eq(ProductMaterial::getFormInstanceId, material.getFormInstanceId())); |
| | | for (ProductMaterialSku sku : list) { |
| | | |
| | | if (exist == null) { |
| | | this.save(material); |
| | | affected++; |
| | | log.info("æ°å¢ç©ææ°æ® formInstanceId={}", material.getFormInstanceId()); |
| | | LambdaQueryWrapper<ProductMaterialSku> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterialSku::getMaterialId, sku.getMaterialId()) |
| | | .eq(ProductMaterialSku::getSpecification, sku.getSpecification()); |
| | | |
| | | if (StringUtils.isNotEmpty(sku.getMaterialCode())) { |
| | | wrapper.eq(ProductMaterialSku::getMaterialCode, sku.getMaterialCode()); |
| | | } else { |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(material.getFormModifiedTime())) { |
| | | material.setId(exist.getId()); |
| | | material.setCreateTime(exist.getCreateTime()); |
| | | this.updateById(material); |
| | | wrapper.isNull(ProductMaterialSku::getMaterialCode); |
| | | } |
| | | |
| | | ProductMaterialSku exist = productMaterialSkuService.getOne(wrapper); |
| | | if (exist == null) { |
| | | productMaterialSkuService.save(sku); |
| | | affected++; |
| | | log.info("æ°å¢ç©æè§æ ¼ {}", sku.getSpecification()); |
| | | } else { |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(sku.getFormModifiedTime())) { |
| | | sku.setId(exist.getId()); |
| | | sku.setCreateTime(exist.getCreateTime()); |
| | | productMaterialSkuService.updateById(sku); |
| | | |
| | | affected++; |
| | | log.info("æ´æ°ç©ææ°æ® formInstanceId={}", material.getFormInstanceId()); |
| | | log.info("æ´æ°ç©æè§æ ¼ {}", sku.getSpecification()); |
| | | } |
| | | } |
| | | } |
| | |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductMaterialGroupDto> ProductMaterialList(String materialName) { |
| | | |
| | | List<ProductMaterialConfig> materialConfigList = productMaterialConfigService.list(new LambdaQueryWrapper<ProductMaterialConfig>() |
| | | .eq(ProductMaterialConfig::getConfigType, MaterialConfigTypeEnum.MATERIAL_TYPE.name())); |
| | | |
| | | List<ProductMaterialGroupDto> productMaterialMap = new ArrayList<>(); |
| | | if (materialConfigList == null || materialConfigList.isEmpty()) { |
| | | return productMaterialMap; |
| | | } |
| | | for (ProductMaterialConfig materialConfig : materialConfigList) { |
| | | LambdaQueryWrapper<ProductMaterial> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(ProductMaterial::getMaterialTypeId, materialConfig.getId()) |
| | | .like(materialName != null && !materialName.isEmpty(), ProductMaterial::getMaterialName, materialName); |
| | | List<ProductMaterial> productMaterialList = list(wrapper); |
| | | ProductMaterialGroupDto dto = new ProductMaterialGroupDto(); |
| | | dto.setConfigId(materialConfig.getId()); |
| | | dto.setConfigName(materialConfig.getConfigName()); |
| | | dto.setMaterialList(productMaterialList); |
| | | productMaterialMap.add(dto); |
| | | } |
| | | return productMaterialMap; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addProductMaterial(ProductMaterial productMaterial) { |
| | | validateProductMaterial(productMaterial, false); |
| | | if (existsMaterialName(productMaterial.getMaterialName(), null)) { |
| | | throw new ServiceException("ç©æåç§°å·²åå¨"); |
| | | } |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | if (productMaterial.getCreateTime() == null) { |
| | | productMaterial.setCreateTime(now); |
| | | } |
| | | productMaterial.setUpdateTime(now); |
| | | if (!this.save(productMaterial)) { |
| | | throw new ServiceException("æ°å¢ç©æå¤±è´¥"); |
| | | } |
| | | log.info("æ°å¢ç©ææå materialName={}", productMaterial.getMaterialName()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateProductMaterial(ProductMaterial productMaterial) { |
| | | validateProductMaterial(productMaterial, true); |
| | | ProductMaterial exist = this.getById(productMaterial.getId()); |
| | | if (exist == null) { |
| | | throw new ServiceException("ç©æä¸åå¨"); |
| | | } |
| | | if (existsMaterialName(productMaterial.getMaterialName(), productMaterial.getId())) { |
| | | throw new ServiceException("ç©æåç§°å·²åå¨"); |
| | | } |
| | | productMaterial.setUpdateTime(LocalDateTime.now()); |
| | | if (!this.updateById(productMaterial)) { |
| | | throw new ServiceException("ä¿®æ¹ç©æå¤±è´¥"); |
| | | } |
| | | log.info("ä¿®æ¹ç©ææå id={}", productMaterial.getId()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteProductMaterial(List<Long> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | throw new ServiceException("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | if (!this.removeByIds(ids)) { |
| | | throw new ServiceException("å é¤ç©æå¤±è´¥"); |
| | | } |
| | | log.info("å é¤ç©ææå ids={}", ids); |
| | | } |
| | | |
| | | private void validateProductMaterial(ProductMaterial productMaterial, boolean requireId) { |
| | | if (productMaterial == null) { |
| | | throw new ServiceException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (requireId && productMaterial.getId() == null) { |
| | | throw new ServiceException("主é®IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isEmpty(productMaterial.getMaterialName())) { |
| | | throw new ServiceException("ç©æåç§°ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | |
| | | private boolean existsMaterialName(String materialName, Long excludeId) { |
| | | if (StringUtils.isEmpty(materialName)) { |
| | | return false; |
| | | } |
| | | LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterial::getMaterialName, materialName); |
| | | if (excludeId != null) { |
| | | queryWrapper.ne(ProductMaterial::getId, excludeId); |
| | | } |
| | | return this.count(queryWrapper) > 0; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.production.dto.ProductMaterialSkuDto; |
| | | import com.ruoyi.production.mapper.ProductMaterialMapper; |
| | | import com.ruoyi.production.mapper.ProductMaterialSkuMapper; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductMaterialSkuImportDto; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <br> |
| | | * ç©æè§æ ¼æ¥å£å®ç°ç±» |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/12 10:05 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ProductMaterialSkuServiceImpl |
| | | extends ServiceImpl<ProductMaterialSkuMapper, ProductMaterialSku> |
| | | implements ProductMaterialSkuService { |
| | | |
| | | @Autowired |
| | | private ProductMaterialMapper productMaterialMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ç©æè§æ ¼å表 |
| | | */ |
| | | @Override |
| | | public List<ProductMaterialSkuDto> productMaterialSkuList(Long materialId) { |
| | | |
| | | if (materialId == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId) |
| | | .orderByAsc(ProductMaterialSku::getId); |
| | | List<ProductMaterialSku> skuList = this.list(queryWrapper); |
| | | if (skuList == null || skuList.isEmpty()) { |
| | | return Collections.emptyList(); |
| | | } |
| | | // æ¥è¯¢ç©æä¿¡æ¯ |
| | | ProductMaterial material = productMaterialMapper.selectById(materialId); |
| | | |
| | | String materialName = material != null ? material.getMaterialName() : null; |
| | | String baseUnit = material != null ? material.getBaseUnit() : null; |
| | | List<ProductMaterialSkuDto> result = new ArrayList<>(skuList.size()); |
| | | for (ProductMaterialSku sku : skuList) { |
| | | ProductMaterialSkuDto dto = new ProductMaterialSkuDto(); |
| | | dto.setMaterialId(materialId); |
| | | dto.setMaterialName(materialName); |
| | | dto.setBaseUnit(baseUnit); |
| | | dto.setSkuId(sku.getId()); |
| | | dto.setSpecification(sku.getSpecification()); |
| | | dto.setSupplyType(sku.getSupplyType()); |
| | | result.add(dto); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ç©æè§æ ¼ |
| | | */ |
| | | @Override |
| | | public void addProductMaterialSku(ProductMaterialSku sku) { |
| | | validateProductMaterialSku(sku, false); |
| | | // æ ¡éªç©ææ¯å¦åå¨ |
| | | ProductMaterial material = productMaterialMapper.selectById(sku.getMaterialId()); |
| | | if (material == null) { |
| | | throw new ServiceException("ç©æä¸åå¨"); |
| | | } |
| | | // æ ¡éªè§æ ¼æ¯å¦éå¤ |
| | | if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), null)) { |
| | | throw new ServiceException("è¯¥ç©æå·²åå¨ç¸åè§æ ¼"); |
| | | } |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | if (sku.getCreateTime() == null) { |
| | | sku.setCreateTime(now); |
| | | } |
| | | sku.setUpdateTime(now); |
| | | |
| | | if (!this.save(sku)) { |
| | | throw new ServiceException("æ°å¢ç©æè§æ ¼å¤±è´¥"); |
| | | } |
| | | log.info("æ°å¢ç©æè§æ ¼æå materialId={}, specification={}", sku.getMaterialId(), sku.getSpecification()); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç©æè§æ ¼ |
| | | */ |
| | | @Override |
| | | public void updateProductMaterialSku(ProductMaterialSku sku) { |
| | | validateProductMaterialSku(sku, true); |
| | | // æ ¡éªè§æ ¼æ¯å¦éå¤ |
| | | if (existsSameSpecification(sku.getMaterialId(), sku.getSpecification(), sku.getId())) { |
| | | throw new ServiceException("è¯¥ç©æå·²åå¨ç¸åè§æ ¼"); |
| | | } |
| | | sku.setUpdateTime(LocalDateTime.now()); |
| | | if (!this.updateById(sku)) { |
| | | throw new ServiceException("ä¿®æ¹ç©æè§æ ¼å¤±è´¥"); |
| | | } |
| | | log.info("ä¿®æ¹ç©æè§æ ¼æå id={}", sku.getId()); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ç©æè§æ ¼ |
| | | */ |
| | | @Override |
| | | public void deleteProductMaterialSku(List<Long> ids) { |
| | | if (ids == null || ids.isEmpty()) { |
| | | throw new ServiceException("è¯·éæ©è³å°ä¸æ¡æ°æ®"); |
| | | } |
| | | if (!this.removeByIds(ids)) { |
| | | throw new ServiceException("å é¤ç©æè§æ ¼å¤±è´¥"); |
| | | } |
| | | log.info("å é¤ç©æè§æ ¼æå ids={}", ids); |
| | | } |
| | | |
| | | /** |
| | | * åæ°æ ¡éª |
| | | */ |
| | | private void validateProductMaterialSku(ProductMaterialSku sku, boolean requireId) { |
| | | if (sku == null) { |
| | | throw new ServiceException("åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (requireId && sku.getId() == null) { |
| | | throw new ServiceException("主é®IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (sku.getMaterialId() == null) { |
| | | throw new ServiceException("ç©æIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (StringUtils.isEmpty(sku.getSpecification())) { |
| | | throw new ServiceException("è§æ ¼ä¸è½ä¸ºç©º"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¡éªæ¯å¦åå¨ç¸åè§æ ¼ |
| | | */ |
| | | private boolean existsSameSpecification(Long materialId, String specification, Long excludeId) { |
| | | LambdaQueryWrapper<ProductMaterialSku> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterialSku::getMaterialId, materialId) |
| | | .eq(ProductMaterialSku::getSpecification, specification); |
| | | if (excludeId != null) { |
| | | queryWrapper.ne(ProductMaterialSku::getId, excludeId); |
| | | } |
| | | |
| | | return this.count(queryWrapper) > 0; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importProdData(MultipartFile file, Long materialId) { |
| | | if (materialId == null) { |
| | | throw new ServiceException("ç©æIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (file == null || file.isEmpty()) { |
| | | throw new ServiceException("导å
¥æä»¶ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | ProductMaterial material = productMaterialMapper.selectById(materialId); |
| | | if (material == null) { |
| | | throw new ServiceException("ç©æä¸åå¨"); |
| | | } |
| | | |
| | | ExcelUtil<ProductMaterialSkuImportDto> excelUtil = new ExcelUtil<>(ProductMaterialSkuImportDto.class); |
| | | List<ProductMaterialSkuImportDto> importList; |
| | | try { |
| | | importList = excelUtil.importExcel(file.getInputStream()); |
| | | } catch (Exception e) { |
| | | log.error("导å
¥ç©æè§æ ¼Excelè§£æå¤±è´¥", e); |
| | | throw new ServiceException("Excelè§£æå¤±è´¥"); |
| | | } |
| | | |
| | | if (importList == null || importList.isEmpty()) { |
| | | throw new ServiceException("Excelæ²¡ææ°æ®"); |
| | | } |
| | | |
| | | Map<String, ProductMaterialSkuImportDto> specMap = new LinkedHashMap<>(); |
| | | for (ProductMaterialSkuImportDto dto : importList) { |
| | | if (dto == null || StringUtils.isEmpty(dto.getSpecification())) { |
| | | continue; |
| | | } |
| | | String specification = dto.getSpecification().trim(); |
| | | if (specification.isEmpty()) { |
| | | continue; |
| | | } |
| | | specMap.putIfAbsent(specification, dto); |
| | | } |
| | | |
| | | if (specMap.isEmpty()) { |
| | | throw new ServiceException("Excelæ²¡æææçè§æ ¼æ°æ®"); |
| | | } |
| | | |
| | | Set<String> specifications = specMap.keySet(); |
| | | |
| | | List<ProductMaterialSku> existList = this.list(new LambdaQueryWrapper<ProductMaterialSku>() |
| | | .eq(ProductMaterialSku::getMaterialId, materialId) |
| | | .in(ProductMaterialSku::getSpecification, specifications)); |
| | | Map<String, ProductMaterialSku> existMap = existList.stream() |
| | | .collect(Collectors.toMap(ProductMaterialSku::getSpecification, sku -> sku, (a, b) -> a)); |
| | | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | List<ProductMaterialSku> saveList = new ArrayList<>(); |
| | | List<ProductMaterialSku> updateList = new ArrayList<>(); |
| | | |
| | | for (Map.Entry<String, ProductMaterialSkuImportDto> entry : specMap.entrySet()) { |
| | | String specification = entry.getKey(); |
| | | ProductMaterialSkuImportDto dto = entry.getValue(); |
| | | String supplyType = StringUtils.isNotEmpty(dto.getSupplyType()) ? dto.getSupplyType().trim() : null; |
| | | |
| | | ProductMaterialSku exist = existMap.get(specification); |
| | | if (exist == null) { |
| | | ProductMaterialSku sku = new ProductMaterialSku(); |
| | | sku.setMaterialId(materialId); |
| | | sku.setSpecification(specification); |
| | | sku.setSupplyType(supplyType); |
| | | sku.setCreateTime(now); |
| | | sku.setUpdateTime(now); |
| | | saveList.add(sku); |
| | | } else { |
| | | boolean needUpdate = false; |
| | | if (supplyType != null && !supplyType.equals(exist.getSupplyType())) { |
| | | exist.setSupplyType(supplyType); |
| | | needUpdate = true; |
| | | } |
| | | if (needUpdate) { |
| | | exist.setUpdateTime(now); |
| | | updateList.add(exist); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (saveList.isEmpty() && updateList.isEmpty()) { |
| | | throw new ServiceException("Excelä¸ç°ææ°æ®ä¸è´ï¼æ é导å
¥"); |
| | | } |
| | | |
| | | if (!saveList.isEmpty()) { |
| | | this.saveBatch(saveList); |
| | | } |
| | | if (!updateList.isEmpty()) { |
| | | this.updateBatchById(updateList); |
| | | } |
| | | |
| | | log.info("ç©æè§æ ¼å¯¼å
¥å®æ materialId={}, æ°å¢{}æ¡ï¼æ´æ°{}æ¡", materialId, saveList.size(), updateList.size()); |
| | | } |
| | | } |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Log(title = "åå¹¶ç产计å", businessType = BusinessType.INSERT) |
| | | @ApiOperation("åå¹¶ç产计å") |
| | | public AjaxResult combine(@RequestBody ProductionPlanDto productionPlanDto) { |
| | | if (productionPlanDto.getIds() == null || productionPlanDto.getIds().isEmpty()) { |
| | | return AjaxResult.error("è¯·éæ©è¦ä¸åçç产计å"); |
| | | } |
| | | |
| | | if (productionPlanDto.getTotalAssignedQuantity() == null || productionPlanDto.getTotalAssignedQuantity().compareTo(BigDecimal.ZERO) <= 0) { |
| | | return AjaxResult.error("请è¾å
¥ä¸åæ°é"); |
| | | } |
| | | return AjaxResult.success(productionPlanService.combine(productionPlanDto)); |
| | | } |
| | | |
| | |
| | | package com.ruoyi.productionPlan.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.framework.aspectj.lang.annotation.Excel; |
| | | import com.ruoyi.productionPlan.pojo.ProductionPlan; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | |
| | | @Data |
| | | public class ProductionPlanDto extends ProductionPlan { |
| | | /** |
| | | * ç©æç¼ç |
| | | */ |
| | | @ApiModelProperty("ç©æç¼ç ") |
| | | @Excel(name = "ç©æç¼ç ") |
| | | private String materialCode; |
| | | |
| | | /** |
| | | * 产ååç§° |
| | | */ |
| | | @ApiModelProperty("产ååç§°") |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | |
| | | /** |
| | | * 产åè§æ ¼ |
| | | */ |
| | | @ApiModelProperty("产åè§æ ¼") |
| | | @Excel(name = "产åè§æ ¼") |
| | | private String specification; |
| | | |
| | | @ApiModelProperty("产ååä½") |
| | | @Excel(name = "产ååä½") |
| | | private String baseUnit; |
| | | |
| | | @ApiModelProperty(value = "ç产计åidéå") |
| | | private List<Long> ids; |
| | | |
| | |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate planCompleteTime; |
| | | |
| | | /** |
| | | * å
³èç©æä¿¡æ¯è¡¨ |
| | | */ |
| | | @ApiModelProperty("å
³èç©æä¿¡æ¯è¡¨ID") |
| | | private Long productMaterialId; |
| | | } |
| | |
| | | |
| | | List<ProductionPlanSummaryDto> selectSummaryByProductType(ProductionPlanSummaryDto query); |
| | | |
| | | List<ProductionPlanDto> selectWithMaterialByIds(@Param("ids") List<Long> ids); |
| | | |
| | | } |
| | |
| | | private String customerName; |
| | | |
| | | /** |
| | | * ç©æç¼ç |
| | | */ |
| | | @ApiModelProperty("ç©æç¼ç ") |
| | | @Excel(name = "ç©æç¼ç ") |
| | | private String materialCode; |
| | | |
| | | |
| | | /** |
| | | * å
³èç©æä¿¡æ¯è¡¨ID |
| | | */ |
| | | @ApiModelProperty("å
³èç©æä¿¡æ¯è¡¨ID") |
| | | private Integer productMaterialId; |
| | | |
| | | /** |
| | | * 产ååç§° |
| | | */ |
| | | @ApiModelProperty("产ååç§°") |
| | | @Excel(name = "产ååç§°") |
| | | private String productName; |
| | | |
| | | /** |
| | | * 产åè§æ ¼ |
| | | */ |
| | | @ApiModelProperty("产åè§æ ¼") |
| | | @Excel(name = "产åè§æ ¼") |
| | | private String productSpec; |
| | | private Long productMaterialSkuId; |
| | | |
| | | /** |
| | | * é¿ |
| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.service.ProductMaterialService; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import com.ruoyi.production.service.ProductOrderService; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanDto; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanImportDto; |
| | |
| | | private ProductOrderPlanMapper productOrderPlanMapper; |
| | | |
| | | @Autowired |
| | | private ProductMaterialSkuService productMaterialSkuService; |
| | | |
| | | @Autowired |
| | | private ProductMaterialService productMaterialService; |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // æ¥è¯¢ä¸»ç产计å |
| | | List<ProductionPlan> plans = productionPlanMapper.selectBatchIds(productionPlanDto.getIds()); |
| | | plans.sort(Comparator.comparingLong(ProductionPlan::getId)); |
| | | List<ProductionPlanDto> plans = productionPlanMapper.selectWithMaterialByIds(productionPlanDto.getIds()); |
| | | |
| | | // æ ¡éªæ¯å¦åå¨ä¸åç产ååç§° |
| | | String firstProductName = plans.get(0).getProductName(); |
| | |
| | | } |
| | | |
| | | // æ ¡éªæ¯å¦åå¨ä¸åç产åè§æ ¼ |
| | | String firstProductSpec = plans.get(0).getProductSpec(); |
| | | if (plans.stream().anyMatch(p -> !p.getProductSpec().equals(firstProductSpec))) { |
| | | String firstProductSpec = plans.get(0).getSpecification(); |
| | | if (plans.stream().anyMatch(p -> !p.getSpecification().equals(firstProductSpec))) { |
| | | throw new BaseException("å并失败ï¼åå¨ä¸åç产åè§æ ¼"); |
| | | } |
| | | |
| | | |
| | | // å å å©ä½æ¹æ° |
| | | BigDecimal totalRemainingVolume = plans.stream() |
| | |
| | | plan.setCustomerName(formData.getString("textField_lbkozohg")); |
| | | |
| | | 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()); |
| | | LambdaQueryWrapper<ProductMaterialSku> skuQueryWrapper = new LambdaQueryWrapper<>(); |
| | | skuQueryWrapper.eq(ProductMaterialSku::getMaterialCode, materialCode); |
| | | ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper); |
| | | if (sku != null) { |
| | | plan.setProductMaterialSkuId(sku.getId()); |
| | | } |
| | | } |
| | | |
| | | plan.setProductName(row.getString("textField_l9xo62q7")); |
| | | plan.setProductSpec(row.getString("textField_l9xo62q8")); |
| | | plan.setLength(row.getInteger("numberField_lb7lgatg_value")); |
| | | plan.setWidth(row.getInteger("numberField_lb7lgath_value")); |
| | | plan.setHeight(row.getInteger("numberField_lb7lgati_value")); |
| | |
| | | // Map (formInstanceId + materialCode) |
| | | Map<String, ProductionPlan> existMap = new HashMap<>(); |
| | | for (ProductionPlan p : existList) { |
| | | String key = p.getFormInstanceId() + "_" + p.getMaterialCode(); |
| | | String key = p.getFormInstanceId() + "_" + p.getProductMaterialSkuId(); |
| | | existMap.put(key, p); |
| | | } |
| | | |
| | | // éååæ¥æ°æ® |
| | | for (ProductionPlan plan : list) { |
| | | String key = plan.getFormInstanceId() + "_" + plan.getMaterialCode(); |
| | | String key = plan.getFormInstanceId() + "_" + plan.getProductMaterialSkuId(); |
| | | ProductionPlan exist = existMap.get(key); |
| | | if (exist == null) { |
| | | // æ°å¢ |
| | | this.save(plan); |
| | | affected++; |
| | | log.info("æ°å¢æ°æ® formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getMaterialCode()); |
| | | log.info("æ°å¢æ°æ® formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getProductMaterialSkuId()); |
| | | } else { |
| | | // 夿æ¯å¦éè¦æ´æ° |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(plan.getFormModifiedTime())) { |
| | |
| | | plan.setCreateTime(exist.getCreateTime()); |
| | | this.updateById(plan); |
| | | affected++; |
| | | log.info("æ´æ°æ°æ® formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getMaterialCode()); |
| | | log.info("æ´æ°æ°æ® formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getProductMaterialSkuId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | entity.setDataSourceType(2); |
| | | entity.setDataSyncType(1); |
| | | |
| | | // æ ¹æ®ç©æç¼ç å¡«å
å
³èID |
| | | if (StringUtils.isNotEmpty(dto.getMaterialCode())) { |
| | | LambdaQueryWrapper<ProductMaterialSku> skuQueryWrapper = new LambdaQueryWrapper<>(); |
| | | skuQueryWrapper.eq(ProductMaterialSku::getMaterialCode, dto.getMaterialCode()); |
| | | ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper); |
| | | if (sku != null) { |
| | | entity.setProductMaterialSkuId(sku.getId()); |
| | | } |
| | | } |
| | | |
| | | entityList.add(entity); |
| | | } |
| | | this.saveBatch(entityList); |
| | |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.ruoyi.production.mapper.ProductMaterialMapper"> |
| | | |
| | | <resultMap id="ProductMaterialResultMap" type="com.ruoyi.production.pojo.ProductMaterial"> |
| | | <id property="id" column="id"/> |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <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="materialName" column="material_name"/> |
| | | <result property="specification" column="specification"/> |
| | | <result property="baseUnit" column="base_unit"/> |
| | | <result property="materialAttribute" column="material_attribute"/> |
| | | <result property="finishedProductName" column="finished_product_name"/> |
| | | <result property="originatorName" column="originator_name"/> |
| | | <result property="originatorOrg" column="originator_org"/> |
| | | <result property="remark" column="remark"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.ProductMaterialSkuMapper"> |
| | | |
| | | <resultMap id="ProductMaterialSkuResultMap" type="com.ruoyi.production.pojo.ProductMaterialSku"> |
| | | <id property="id" column="id"/> |
| | | <result property="materialId" column="material_id"/> |
| | | <result property="identifierCode" column="identifier_code"/> |
| | | <result property="materialCode" column="material_code"/> |
| | | <result property="specification" column="specification"/> |
| | | <result property="supplyType" column="supply_type"/> |
| | | <result property="originatorName" column="originator_name"/> |
| | | <result property="originatorOrg" column="originator_org"/> |
| | | <result property="formInstanceId" column="form_instance_id"/> |
| | | <result property="formModifiedTime" column="form_modified_time"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | <result property="serialNo" column="serial_no"/> |
| | | <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="productMaterialSkuId" column="product_material_sku_id"/> |
| | | <result property="length" column="length"/> |
| | | <result property="width" column="width"/> |
| | | <result property="height" column="height"/> |
| | |
| | | <result property="totalCount" column="total_count"/> |
| | | </resultMap> |
| | | |
| | | |
| | | <select id="listPage" resultType="com.ruoyi.productionPlan.dto.ProductionPlanDto"> |
| | | SELECT * |
| | | SELECT |
| | | pp.*, |
| | | pms.material_code AS materialCode, |
| | | pms.specification AS specification, |
| | | pms.material_id AS productMaterialId, |
| | | pm.material_name AS productName, |
| | | pm.base_unit |
| | | FROM production_plan pp |
| | | left join product_material_sku pms on pp.product_material_sku_id = pms.id |
| | | left join product_material pm on pms.material_id = pm.id |
| | | WHERE 1 = 1 |
| | | <if test="c.customerName != null and c.customerName != '' "> |
| | | AND pp.customer_name LIKE CONCAT('%',#{c.customerName},'%') |
| | | </if> |
| | | <if test="c.productName != null and c.productName != '' "> |
| | | AND pp.product_name LIKE CONCAT('%',#{c.productName},'%') |
| | | </if> |
| | | <if test="c.productSpec != null and c.productSpec != '' "> |
| | | AND pp.product_spec LIKE CONCAT('%',#{c.productSpec},'%') |
| | | AND pm.material_name LIKE CONCAT('%',#{c.productName},'%') |
| | | </if> |
| | | <if test="c.materialCode != null and c.materialCode != '' "> |
| | | AND pp.material_code LIKE CONCAT('%',#{c.materialCode},'%') |
| | | AND pms.material_code LIKE CONCAT('%',#{c.materialCode},'%') |
| | | </if> |
| | | <if test="c.specification != null and c.specification != '' "> |
| | | AND pms.specification LIKE CONCAT('%',#{c.specification},'%') |
| | | </if> |
| | | <if test="c.applyNo != null and c.applyNo != '' "> |
| | | AND pp.apply_no LIKE CONCAT('%',#{c.applyNo},'%') |
| | | </if> |
| | | <if test="c.startDate != null"> |
| | | AND pp.start_date >= DATE_FORMAT(#{c.startDate},'%Y-%m-%d') |
| | |
| | | |
| | | <select id="selectSummaryByProductType" resultType="com.ruoyi.productionPlan.dto.ProductionPlanSummaryDto"> |
| | | SELECT |
| | | material_code, |
| | | product_name, |
| | | product_spec, |
| | | length, |
| | | width, |
| | | height, |
| | | COALESCE(SUM(quantity),0) AS quantity, |
| | | COALESCE(SUM(volume),0) AS volume |
| | | FROM production_plan |
| | | sku.material_code, |
| | | pm.material_name AS product_name, |
| | | sku.specification AS product_spec, |
| | | pp.length, |
| | | pp.width, |
| | | pp.height, |
| | | COALESCE(SUM(pp.quantity),0) AS quantity, |
| | | COALESCE(SUM(pp.volume),0) AS volume |
| | | FROM production_plan pp |
| | | LEFT JOIN product_material_sku sku |
| | | ON pp.product_material_sku_id = sku.id |
| | | LEFT JOIN product_material pm |
| | | ON sku.material_id = pm.id |
| | | <where> |
| | | <if test="materialCode != null and materialCode != ''"> |
| | | AND material_code LIKE CONCAT('%', #{materialCode}, '%') |
| | | AND sku.material_code LIKE CONCAT('%', #{materialCode}, '%') |
| | | </if> |
| | | |
| | | <if test="productName != null and productName != ''"> |
| | | AND product_name LIKE CONCAT('%', #{productName}, '%') |
| | | AND pm.material_name LIKE CONCAT('%', #{productName}, '%') |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | material_code, |
| | | product_name, |
| | | product_spec, |
| | | length, |
| | | width, |
| | | height |
| | | sku.material_code, |
| | | pm.material_name, |
| | | sku.specification, |
| | | pp.length, |
| | | pp.width, |
| | | pp.height |
| | | </select> |
| | | |
| | | <select id="selectWithMaterialByIds" resultType="com.ruoyi.productionPlan.dto.ProductionPlanDto"> |
| | | SELECT |
| | | pp.*, |
| | | pms.material_code AS materialCode, |
| | | pms.specification AS specification, |
| | | pm.material_name AS productName, |
| | | pm.base_unit |
| | | FROM production_plan pp |
| | | LEFT JOIN product_material_sku pms ON pp.product_material_sku_id = pms.id |
| | | LEFT JOIN product_material pm ON pms.material_id = pm.id |
| | | WHERE pp.id IN |
| | | <foreach collection="ids" item="id" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | ORDER BY pp.id ASC |
| | | </select> |
| | | </mapper> |