已添加10个文件
已修改38个文件
已删除6个文件
| | |
| | | -- Table structure for process_route_item_param_instance |
| | | -- ---------------------------- |
| | | DROP TABLE IF EXISTS `process_route_item_param_instance`; |
| | | |
| | | CREATE TABLE `process_route_item_param_instance` |
| | | ( |
| | | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主é®ID', |
| | | `order_id` bigint DEFAULT NULL COMMENT 'ç产订åID', |
| | | `route_item_id` bigint NOT NULL COMMENT 'å
³èå·¥èºè·¯çº¿æç»ID (process_route_item.id)', |
| | | `param_id` bigint NOT NULL COMMENT 'å
³èåºç¡åæ°å®ä¹ID (base_param.id)', |
| | | `process_param_id` bigint NULL DEFAULT NULL COMMENT 'æ¥æºå·¥åºåæ°ID', |
| | | `standard_value` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'æ¤è·¯çº¿èç¹è®¾å®çæ åå¼', |
| | | `min_value` decimal(10, 2) NULL DEFAULT NULL COMMENT 'æ¤è·¯çº¿èç¹è®¾å®çæ åæå°å¼', |
| | | `max_value` decimal(10, 2) NULL DEFAULT NULL COMMENT 'æ¤è·¯çº¿èç¹è®¾å®çæ åæå¤§å¼', |
| | | `is_required` tinyint NOT NULL DEFAULT 0 COMMENT 'æ¯å¦å¿
å¡«', |
| | | `sort` int NOT NULL DEFAULT 0 COMMENT 'æåº', |
| | | `tenant_id` bigint NULL DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP, |
| | | `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
| | | `process_param_id` bigint DEFAULT NULL COMMENT 'æ¥æºå·¥åºåæ°ID', |
| | | `param_key` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'åæ°å¯ä¸æ è¯', |
| | | `param_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'åæ°åç§°', |
| | | `param_type` tinyint NOT NULL COMMENT 'åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)', |
| | | `param_format` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'åæ°æ ¼å¼', |
| | | `value_mode` tinyint DEFAULT '1' COMMENT '弿¨¡å¼(1åå¼ 2åºé´)', |
| | | `unit` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'åä½', |
| | | `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '夿³¨', |
| | | `standard_value` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT 'æ åå¼', |
| | | `min_value` decimal(10, 2) DEFAULT NULL COMMENT 'æ¤è·¯çº¿èç¹è®¾å®çæ åæå°å¼', |
| | | `max_value` decimal(10, 2) DEFAULT NULL COMMENT 'æ¤è·¯çº¿èç¹è®¾å®çæ åæå¤§å¼', |
| | | `is_required` tinyint NOT NULL DEFAULT '0' COMMENT 'æ¯å¦å¿
å¡«', |
| | | `sort` int NOT NULL DEFAULT '0' COMMENT 'æåº', |
| | | `tenant_id` bigint DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT 'å建æ¶é´', |
| | | `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'æ´æ°æ¶é´', |
| | | PRIMARY KEY (`id`) USING BTREE, |
| | | INDEX `idx_route_item_id` (`route_item_id` ASC) USING BTREE, |
| | | INDEX `idx_param_id` (`param_id` ASC) USING BTREE |
| | | KEY `idx_route_item_id` (`route_item_id`) USING BTREE, |
| | | KEY `idx_param_key` (`param_key`) |
| | | ) ENGINE = InnoDB |
| | | AUTO_INCREMENT = 178 |
| | | CHARACTER SET = utf8mb4 |
| | | COLLATE = utf8mb4_0900_ai_ci COMMENT = 'å·¥èºè·¯çº¿å·¥åºåæ°-é表' |
| | | ROW_FORMAT = Dynamic; |
| | | |
| | | -- ---------------------------- |
| | | -- Table structure for product_process_param_instance |
| | | -- ---------------------------- |
| | | DROP TABLE IF EXISTS `product_process_param_instance`; |
| | | CREATE TABLE `product_process_param_instance` |
| | | ( |
| | | `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主é®ID', |
| | | `process_id` bigint NOT NULL COMMENT 'æå±å·¥åºID (product_process.id)', |
| | | `param_id` bigint NOT NULL COMMENT 'å
³èåºç¡åæ°ID (base_param.id)', |
| | | `standard_value` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '卿¤å·¥åºè®¾å®çæ åå¼(å弿¨¡å¼)', |
| | | `min_value` decimal(10, 2) NULL DEFAULT NULL COMMENT '卿¤å·¥åºè®¾å®çæ åæå°å¼(åºé´æ¨¡å¼)', |
| | | `max_value` decimal(10, 2) NULL DEFAULT NULL COMMENT '卿¤å·¥åºè®¾å®çæ åæå¤§å¼(åºé´æ¨¡å¼)', |
| | | `is_required` tinyint NOT NULL DEFAULT 0 COMMENT '卿¤å·¥åºä¸æ¯å¦å¿
å¡«(0-å¦, 1-æ¯)', |
| | | `sort` int NOT NULL DEFAULT 0 COMMENT 'æåºå·', |
| | | `tenant_id` bigint NULL DEFAULT NULL COMMENT 'ç§æ·ID', |
| | | `create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'å建æ¶é´', |
| | | `update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'æ´æ°æ¶é´', |
| | | PRIMARY KEY (`id`) USING BTREE, |
| | | INDEX `idx_process_id` (`process_id` ASC) USING BTREE, |
| | | INDEX `idx_param_id` (`param_id` ASC) USING BTREE |
| | | ) ENGINE = InnoDB |
| | | AUTO_INCREMENT = 61 |
| | | CHARACTER SET = utf8mb4 |
| | | COLLATE = utf8mb4_0900_ai_ci COMMENT = 'å·¥åºç»å®åæ°-é表' |
| | | ROW_FORMAT = Dynamic; |
| | | AUTO_INCREMENT = 1 |
| | | DEFAULT CHARSET = utf8mb4 |
| | | COLLATE = utf8mb4_0900_ai_ci |
| | | ROW_FORMAT = DYNAMIC COMMENT ='å·¥èºè·¯çº¿å·¥åºåæ°å®ä¾è¡¨'; |
| | | |
| | | -- ---------------------------- |
| | | -- Table structure for product_structure_instance |
| | |
| | | ROW_FORMAT = Dynamic; |
| | | |
| | | SET FOREIGN_KEY_CHECKS = 1; |
| | | |
| | | |
| | | ALTER TABLE `process_route_item_instance` |
| | | ADD COLUMN `order_id` bigint NOT NULL COMMENT 'ç产订åid' AFTER `id`, |
| | | ADD INDEX `idx_order_id` (`order_id`); |
| | | |
| | | ALTER TABLE `process_route_item_param_instance` |
| | | ADD COLUMN `order_id` bigint NOT NULL COMMENT 'ç产订åid' AFTER `id`, |
| | | ADD INDEX `idx_order_id` (`order_id`); |
| | | |
| | | ALTER TABLE `product_structure_instance` |
| | | ADD COLUMN `order_id` bigint NOT NULL COMMENT 'ç产订åid' AFTER `id`, |
| | | ADD INDEX `idx_order_id` (`order_id`); |
| | | |
| | | ALTER TABLE `product-inventory-management-zsjc`.`product_order` |
| | | ADD COLUMN `strength` varchar(255) NULL COMMENT '产åç±»å' AFTER `plan_complete_time`; |
| | | |
| | | CREATE TABLE `product-inventory-management-zsjc`.`sales_delivery` ( |
| | | `id` int NOT NULL AUTO_INCREMENT, |
| | | `delivery_date` date NULL COMMENT 'ä¾è´§æ¥æ', |
| | | `delivery_code` varchar(255) NULL COMMENT 'åè´§åç¼å·', |
| | | `project_name` varchar(255) NULL COMMENT '项ç®åç§°', |
| | | `delivery_place` varchar(255) NULL COMMENT 'éè´§å°ç¹', |
| | | `link_man` varchar(255) NULL COMMENT 'è系人', |
| | | `link_phone` varchar(255) NULL COMMENT 'èç³»çµè¯', |
| | | `delivery_remark` varchar(255) NULL COMMENT 'åè´§å¤æ³¨', |
| | | `material_code` varchar(255) NULL COMMENT 'ç©æä»£ç ', |
| | | `product_name` varchar(255) NULL COMMENT '产ååç§°', |
| | | `model` varchar(255) NULL COMMENT '产åè§æ ¼', |
| | | `volume` decimal(10, 4) NULL COMMENT 'æ¹é', |
| | | `unit_price` decimal(10, 2) NULL COMMENT 'åä»·', |
| | | `price` decimal(10, 2) NULL COMMENT 'ä»·æ ¼', |
| | | `product_remark` varchar(255) NULL COMMENT '产å夿³¨', |
| | | `customer` varchar(255) NULL COMMENT '客æ·åç§°', |
| | | `salesman` varchar(255) NULL COMMENT 'ä¸å¡å', |
| | | `delivery_method` varchar(255) NULL COMMENT 'åè´§æ¹å¼', |
| | | `form_instance_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'å®æè¡¨åå®ä¾ID', |
| | | `form_modified_time` datetime(0) NULL DEFAULT NULL COMMENT 'å®æä¿®æ¹æ¶é´', |
| | | `create_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0), |
| | | `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0), |
| | | PRIMARY KEY (`id`) |
| | | ) COMMENT = 'éå®åè´§æç»(宿)'; |
| | | |
| | | |
| | | ALTER TABLE product_process_param |
| | | DROP COLUMN param_id; |
| | | |
| | | ALTER TABLE product_process_param |
| | | ADD COLUMN `param_key` varchar(100) DEFAULT NULL COMMENT 'åæ°å¯ä¸æ è¯', |
| | | ADD COLUMN `param_name` varchar(100) NOT NULL COMMENT 'åæ°åç§°', |
| | | ADD COLUMN `param_type` tinyint NOT NULL COMMENT 'åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)', |
| | | ADD COLUMN `param_format` varchar(255) DEFAULT NULL COMMENT 'åæ°æ ¼å¼', |
| | | ADD COLUMN `value_mode` tinyint DEFAULT '1' COMMENT '弿¨¡å¼(1åå¼ 2åºé´)', |
| | | ADD COLUMN `unit` varchar(50) DEFAULT NULL COMMENT 'åä½', |
| | | ADD COLUMN `remark` varchar(255) DEFAULT NULL COMMENT '夿³¨'; |
| | | |
| | | ALTER TABLE process_route_item_param |
| | | DROP COLUMN param_id; |
| | | |
| | | ALTER TABLE process_route_item_param |
| | | ADD COLUMN `param_key` varchar(100) DEFAULT NULL COMMENT 'åæ°å¯ä¸æ è¯', |
| | | ADD COLUMN `param_name` varchar(100) NOT NULL COMMENT 'åæ°åç§°', |
| | | ADD COLUMN `param_type` tinyint NOT NULL COMMENT 'åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)', |
| | | ADD COLUMN `param_format` varchar(255) DEFAULT NULL COMMENT 'åæ°æ ¼å¼', |
| | | ADD COLUMN `value_mode` tinyint DEFAULT '1' COMMENT '弿¨¡å¼(1åå¼ 2åºé´)', |
| | | ADD COLUMN `unit` varchar(50) DEFAULT NULL COMMENT 'åä½', |
| | | ADD COLUMN `remark` varchar(255) DEFAULT NULL COMMENT '夿³¨'; |
| | |
| | | public static String database_username = "root"; |
| | | public static String database_password= "xd@123456.."; |
| | | public static String author = "è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸"; |
| | | public static String model = "energy"; // 模å |
| | | public static String model = "productionPlan"; // 模å |
| | | public static String setParent = "com.ruoyi."+ model; // å
è·¯å¾ |
| | | public static String tablePrefix = ""; // è®¾ç½®è¿æ»¤è¡¨åç¼ |
| | | public static void main(String[] args) { |
| | |
| | | package com.ruoyi.appendix.controller; |
| | | |
| | | import com.ruoyi.appendix.service.AppendixService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @RequestMapping("/appendix") |
| | | @Api("BOM-å·¥èºè·¯çº¿é表æ§å¶å±") |
| | | public class AppendixController { |
| | | |
| | | @Resource |
| | | private AppendixService appendixService; |
| | | |
| | | @PostMapping("/bindingRoute") |
| | | @ApiOperation("ç产订åç»å®å·¥èºè·¯çº¿") |
| | | public AjaxResult bindingRoute(@RequestBody ProductOrder productOrder) { |
| | | appendixService.populateData(productOrder); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.appendix.controller; |
| | | |
| | | import com.ruoyi.appendix.dto.ProcessRouteItemInstanceDto; |
| | | import com.ruoyi.appendix.service.ProcessRouteItemInstanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @RequestMapping("/processRouteItemInstance") |
| | | @Api("èºè·¯çº¿åé-é表æ§å¶å±") |
| | | public class ProcessRouteItemInstanceController { |
| | | |
| | | @Resource |
| | | private ProcessRouteItemInstanceService processRouteItemInstanceService; |
| | | |
| | | @GetMapping("/list/{orderId}") |
| | | @ApiOperation("è·åå·¥åºå表") |
| | | public AjaxResult getProcessItem(@PathVariable Long orderId) { |
| | | List<ProcessRouteItemInstanceDto> list = processRouteItemInstanceService.getProcessItem(orderId); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("add") |
| | | @ApiOperation("æ°å¢å·¥åº") |
| | | public AjaxResult addProcessItem(@RequestBody ProcessRouteItemInstanceDto dto) { |
| | | processRouteItemInstanceService.addProcessItem(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @ApiOperation("ä¿®æ¹å·¥åº") |
| | | public AjaxResult updateProcessItem(@RequestBody ProcessRouteItemInstanceDto dto) { |
| | | processRouteItemInstanceService.updateProcessItem(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation("å é¤å·¥åº") |
| | | public AjaxResult deleteProcessItem(@PathVariable Long id) { |
| | | processRouteItemInstanceService.deleteProcessItem(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PostMapping("/sort") |
| | | @ApiOperation("å·¥åºæåº") |
| | | public AjaxResult sortProcessItem(@RequestBody ProcessRouteItemInstanceDto dto) { |
| | | processRouteItemInstanceService.sortProcessItem(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.appendix.controller; |
| | | |
| | | import com.ruoyi.appendix.dto.ProcessRouteItemParamInstanceDto; |
| | | import com.ruoyi.appendix.service.ProcessRouteItemParamInstanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @RestController |
| | | @RequestMapping("/processRouteItemParamInstance") |
| | | public class ProcessRouteItemParamInstanceController { |
| | | |
| | | @Resource |
| | | private ProcessRouteItemParamInstanceService processRouteItemParamInstanceService; |
| | | |
| | | @GetMapping("/list") |
| | | @ApiOperation("ç产订å-è·åå·¥åºç»å®çåæ°å表") |
| | | public AjaxResult routeItemParamList(@RequestParam("orderId") Long orderId, @RequestParam("routeItemId") Long routeItemId) { |
| | | List<ProcessRouteItemParamInstanceDto> list = processRouteItemParamInstanceService.routeItemParamList(orderId, routeItemId); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PostMapping("/add") |
| | | @ApiOperation("ç产订å-å·¥åºæ°å¢åæ°") |
| | | public AjaxResult addRouteItemParam(@RequestBody ProcessRouteItemParamInstanceDto dto) { |
| | | processRouteItemParamInstanceService.addRouteItemParam(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @PutMapping("/update") |
| | | @ApiOperation("ç产订å-å·¥åºæ´æ°åæ°") |
| | | public AjaxResult updateRouteItemParam(@RequestBody ProcessRouteItemParamInstanceDto dto){ |
| | | processRouteItemParamInstanceService.updateRouteItemParam(dto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @DeleteMapping("/delete/{id}") |
| | | @ApiOperation("ç产订å-å·¥åºå é¤åæ°") |
| | | public AjaxResult deleteRouteItemParam(@PathVariable Long id) { |
| | | processRouteItemParamInstanceService.deleteRouteItemParam(id); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ruoyi.appendix.controller; |
| | | |
| | | import com.ruoyi.appendix.dto.ProductStructureInstanceDto; |
| | | import com.ruoyi.appendix.service.ProductStructureInstanceService; |
| | | import com.ruoyi.framework.web.domain.AjaxResult; |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @RestController |
| | | @RequestMapping("/productStructureInstance") |
| | | public class ProductStructureInstanceController { |
| | | |
| | | @Resource |
| | | private ProductStructureInstanceService productStructureInstanceService; |
| | | |
| | | @GetMapping("/getBomStructs/{orderId}") |
| | | @ApiOperation("æ ¹æ®ç产订åIDè·åç»å®çBOMåéç»ææ ") |
| | | public AjaxResult getBomStructs(@PathVariable Long orderId) { |
| | | List<ProductStructureInstanceDto> list = productStructureInstanceService.listByOrderId(orderId); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @PutMapping("/addOrUpdateBomStructs") |
| | | @ApiOperation("æ°å¢/æ´æ°BOMåéç»æ") |
| | | public AjaxResult addOrUpdateBomStructs(@RequestBody ProductStructureInstanceDto instanceDto) { |
| | | productStructureInstanceService.addOrUpdateBomStructs(instanceDto); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.appendix.dto; |
| | | |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemInstance; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <br> |
| | | * å·¥èºè·¯çº¿åé-é表Dto |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/19 10:46 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class ProcessRouteItemInstanceDto extends ProcessRouteItemInstance { |
| | | |
| | | @ApiModelProperty("å·¥åºåç§°") |
| | | private String processName; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.appendix.dto; |
| | | |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemParamInstance; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | /** |
| | | * <br> |
| | | * |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/19 11:49 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class ProcessRouteItemParamInstanceDto extends ProcessRouteItemParamInstance { |
| | | |
| | | @ApiModelProperty("å·¥åºID") |
| | | private Long processId; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.appendix.dto; |
| | | |
| | | import com.ruoyi.appendix.pojo.ProductStructureInstance; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | * BOMåé-é表Dto |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | | * @version 1.0 |
| | | * @since 2026/03/19 10:08 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | public class ProductStructureInstanceDto extends ProductStructureInstance { |
| | | |
| | | @ApiModelProperty("åç±»") |
| | | private List<ProductStructureInstanceDto> children = new ArrayList<>(); |
| | | |
| | | @ApiModelProperty("临æ¶ID") |
| | | private String tempId; |
| | | |
| | | @ApiModelProperty("ç¶èç¹ä¸´æ¶ID") |
| | | private String parentTempId; |
| | | } |
| | |
| | | @TableId(type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç产订åid") |
| | | private Long orderId; |
| | | |
| | | @ApiModelProperty("å·¥èºè·¯çº¿id") |
| | | private Long routeId; |
| | | |
| | |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç产订åid") |
| | | private Long orderId; |
| | | |
| | | @ApiModelProperty("å
³èå·¥èºè·¯çº¿æç»ID") |
| | | private Long routeItemId; |
| | | |
| | | @ApiModelProperty("å
³èåºç¡åæ°å®ä¹ID") |
| | | private Long paramId; |
| | | @ApiModelProperty("åæ°å¯ä¸æ è¯") |
| | | private String paramKey; |
| | | |
| | | @ApiModelProperty("æ¥æºå·¥åºåæ°ID") |
| | | private Long processParamId; |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("æ åå¼") |
| | | private String standardValue; |
| | |
| | | private BigDecimal maxValue; |
| | | |
| | | @ApiModelProperty("æ¯å¦å¿
å¡«") |
| | | private Integer isRequired; |
| | | private Boolean isRequired; |
| | | |
| | | @ApiModelProperty("æåº") |
| | | private Integer sort; |
| | |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("ç产订åid") |
| | | private Long orderId; |
| | | |
| | | @ApiModelProperty("ç¶èç¹ID") |
| | | private Long parentId; |
| | | |
| | |
| | | |
| | | @ApiModelProperty("BOM ID") |
| | | private Long bomId; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.appendix.service; |
| | | |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanDto; |
| | | |
| | | /** |
| | |
| | | */ |
| | | public interface AppendixService { |
| | | |
| | | |
| | | /** |
| | | * å°å¯¹åºçå·¥èºè·¯çº¿åéä¸ç»å®çBOMåéå¡«å
å°éè¡¨ä¸ |
| | | * |
| | | * @param productOrderId ç产订åID |
| | | * @param processRouteId å·¥èºè·¯çº¿ID |
| | | */ |
| | | void populateData(Long productOrderId, Long processRouteId); |
| | | void populateData(ProductOrder productOrder); |
| | | |
| | | /** |
| | | * ç»ä¸åçç åæå对åºçå·¥èºè·¯çº¿åéä¸ç»å®çBOMåéå¡«å
å°éè¡¨ä¸ |
| | | * |
| | | * @param orderId ç产订åID |
| | | * @param productionPlanDto 产å详æ
|
| | | */ |
| | | Long populateBlocks(ProductionPlanDto productionPlanDto); |
| | | Long populateBlocks(Long orderId, ProductionPlanDto productionPlanDto); |
| | | |
| | | /** |
| | | * ç»ä¸åçæ¿ææå对åºçå·¥èºè·¯çº¿åéä¸ç»å®çBOMåéå¡«å
å°éè¡¨ä¸ |
| | | * <p> |
| | | * |
| | | * @param orderId ç产订åID |
| | | * @param productionPlanDto 产å详æ
|
| | | */ |
| | | Long populatePlates(ProductionPlanDto productionPlanDto); |
| | | Long populatePlates(Long orderId, ProductionPlanDto productionPlanDto); |
| | | |
| | | /** |
| | | * å é¤è¯¥è®¢åæºå¸¦çéè¡¨æ°æ® |
| | | * |
| | | * @param orderId ç产订åID |
| | | * @param processRouteId å·¥èºè·¯çº¿ID |
| | | */ |
| | | void deleteData(Long processRouteId); |
| | | void deleteData(Long orderId, Long processRouteId); |
| | | } |
| | |
| | | package com.ruoyi.appendix.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.appendix.dto.ProcessRouteItemInstanceDto; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemInstance; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | | *å·¥èºè·¯çº¿åé-é表Service |
| | | * å·¥èºè·¯çº¿åé-é表Service |
| | | * </br> |
| | | * |
| | | * @author deslrey |
| | |
| | | * @since 2026/03/18 13:07 |
| | | */ |
| | | public interface ProcessRouteItemInstanceService extends IService<ProcessRouteItemInstance> { |
| | | List<ProcessRouteItemInstanceDto> getProcessItem(Long orderId); |
| | | |
| | | void addProcessItem(ProcessRouteItemInstanceDto dto); |
| | | |
| | | void updateProcessItem(ProcessRouteItemInstanceDto dto); |
| | | |
| | | void deleteProcessItem(Long id); |
| | | |
| | | void sortProcessItem(ProcessRouteItemInstanceDto dto); |
| | | } |
| | |
| | | package com.ruoyi.appendix.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.appendix.dto.ProcessRouteItemParamInstanceDto; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemParamInstance; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | * @since 2026/03/18 13:11 |
| | | */ |
| | | public interface ProcessRouteItemParamInstanceService extends IService<ProcessRouteItemParamInstance> { |
| | | |
| | | List<ProcessRouteItemParamInstanceDto> routeItemParamList(Long orderId, Long routeItemId); |
| | | |
| | | void addRouteItemParam(ProcessRouteItemParamInstanceDto dto); |
| | | |
| | | void updateRouteItemParam(ProcessRouteItemParamInstanceDto dto); |
| | | |
| | | void deleteRouteItemParam(Long id); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.appendix.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.appendix.dto.ProductStructureInstanceDto; |
| | | import com.ruoyi.appendix.pojo.ProductStructureInstance; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | * @since 2026/03/18 13:21 |
| | | */ |
| | | public interface ProductStructureInstanceService extends IService<ProductStructureInstance> { |
| | | |
| | | List<ProductStructureInstanceDto> listByOrderId(Long orderId); |
| | | |
| | | void addOrUpdateBomStructs(ProductStructureInstanceDto instanceDto); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemInstance; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemParamInstance; |
| | | import com.ruoyi.appendix.pojo.ProductProcessParamInstance; |
| | | import com.ruoyi.appendix.pojo.ProductStructureInstance; |
| | | import com.ruoyi.appendix.service.*; |
| | | import com.ruoyi.basic.service.BaseParamService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.production.pojo.*; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | private ProcessRouteItemParamInstanceService processRouteItemParamInstanceService; |
| | | |
| | | @Resource |
| | | private ProductProcessParamInstanceService productProcessParamInstanceService; |
| | | private ProductStructureInstanceService productStructureInstanceService; |
| | | |
| | | @Resource |
| | | private ProductStructureInstanceService productStructureInstanceService; |
| | | private BaseParamService baseParamService; |
| | | |
| | | @Resource |
| | | private ProcessRouteService processRouteService; |
| | |
| | | private ProcessRouteItemParamService processRouteItemParamService; |
| | | |
| | | @Resource |
| | | private ProductProcessParamService productProcessParamService; |
| | | |
| | | @Resource |
| | | private ProductStructureService productStructureService; |
| | | |
| | | @Resource |
| | | private ProductOrderService productOrderService; |
| | | |
| | | @Override |
| | | public Long populateBlocks(ProductionPlanDto productionPlanDto) { |
| | | public Long populateBlocks(Long orderId, ProductionPlanDto productionPlanDto) { |
| | | if (productionPlanDto == null) { |
| | | throw new ServiceException("ä¸åæ°æ®ä¸è½ä¸ºç©º"); |
| | | } |
| | |
| | | log.info("ä¸å产åã{}ãæªæ¥è¯¢åºå·¥èºè·¯çº¿", productionPlanDto.getProductName()); |
| | | return null; |
| | | } |
| | | migration(processRoute); |
| | | migration(orderId, processRoute); |
| | | return processRoute.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public Long populatePlates(ProductionPlanDto productionPlanDto) { |
| | | public Long populatePlates(Long orderId, ProductionPlanDto productionPlanDto) { |
| | | if (productionPlanDto == null) { |
| | | throw new ServiceException("ä¸åæ°æ®ä¸è½ä¸ºç©º"); |
| | | } |
| | |
| | | log.info("ä¸å产åã{}ãæªæ¥è¯¢åºå·¥èºè·¯çº¿", productionPlanDto.getProductName()); |
| | | return null; |
| | | } |
| | | migration(processRoute); |
| | | migration(orderId, processRoute); |
| | | return processRoute.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public void populateData(Long productOrderId, Long processRouteId) { |
| | | ProcessRoute processRoute = processRouteService.getById(processRouteId); |
| | | if (processRoute == null) { |
| | | log.info("ç产订åã{}ãæªæ¥è¯¢åºå·¥èºè·¯çº¿ã{}ã", productOrderId, processRouteId); |
| | | return; |
| | | public void populateData(ProductOrder productOrder) { |
| | | if (productOrder == null) { |
| | | throw new ServiceException("ç»å®å¤±è´¥.æ°æ®ä¸è½ä¸ºç©º"); |
| | | } |
| | | migration(processRoute); |
| | | if (productOrder.getId() == null || productOrder.getRouteId() == null) { |
| | | throw new ServiceException("ç»å®å¤±è´¥,ç产订åæå·¥èºè·¯çº¿ä¸è½ä¸ºç©º"); |
| | | } |
| | | ProcessRoute processRoute = processRouteService.getById(productOrder.getRouteId()); |
| | | if (processRoute == null) { |
| | | throw new ServiceException("该工èºè·¯çº¿ä¸åå¨,ç»å®å¤±è´¥"); |
| | | } |
| | | migration(productOrder.getId(), processRoute); |
| | | |
| | | // ååå·¥èºè·¯çº¿idå°ç产订å |
| | | ProductOrder productOrder = new ProductOrder(); |
| | | productOrder.setId(productOrderId); |
| | | productOrder.setRouteId(processRouteId); |
| | | productOrderService.updateById(productOrder); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteData(Long processRouteId) { |
| | | // æ¥åºå·¥èºè·¯çº¿åéï¼ç¨äºå
³èå é¤åæ°é表 |
| | | List<ProcessRouteItem> itemList = processRouteItemService.list(new LambdaQueryWrapper<ProcessRouteItem>().eq(ProcessRouteItem::getRouteId, processRouteId)); |
| | | |
| | | if (itemList != null && !itemList.isEmpty()) { |
| | | List<Long> itemIds = itemList.stream().map(ProcessRouteItem::getId).collect(Collectors.toList()); |
| | | List<Long> processIds = itemList.stream().map(ProcessRouteItem::getProcessId).collect(Collectors.toList()); |
| | | |
| | | // å é¤å·¥èºè·¯çº¿å·¥åºåæ°é表 |
| | | processRouteItemParamInstanceService.remove(new LambdaQueryWrapper<ProcessRouteItemParamInstance>().in(ProcessRouteItemParamInstance::getRouteItemId, itemIds)); |
| | | |
| | | // å é¤å·¥åºç»å®åæ°é表 |
| | | productProcessParamInstanceService.remove(new LambdaQueryWrapper<ProductProcessParamInstance>().in(ProductProcessParamInstance::getProcessId, processIds)); |
| | | } |
| | | public void deleteData(Long orderId, Long processRouteId) { |
| | | // å é¤å·¥èºè·¯çº¿å·¥åºåæ°é表 |
| | | processRouteItemParamInstanceService.remove(new LambdaQueryWrapper<ProcessRouteItemParamInstance>() |
| | | .eq(ProcessRouteItemParamInstance::getOrderId, orderId)); |
| | | |
| | | // å é¤å·¥èºè·¯çº¿åéé表 |
| | | processRouteItemInstanceService.remove( |
| | | new LambdaQueryWrapper<ProcessRouteItemInstance>().eq(ProcessRouteItemInstance::getRouteId, processRouteId)); |
| | | processRouteItemInstanceService.remove(new LambdaQueryWrapper<ProcessRouteItemInstance>() |
| | | .eq(ProcessRouteItemInstance::getOrderId, orderId) |
| | | .eq(ProcessRouteItemInstance::getRouteId, processRouteId)); |
| | | |
| | | // å é¤BOMåéé表 |
| | | ProcessRoute processRoute = processRouteService.getById(processRouteId); |
| | | if (processRoute != null && processRoute.getBomId() != null) { |
| | | productStructureInstanceService.remove(new LambdaQueryWrapper<ProductStructureInstance>().eq(ProductStructureInstance::getBomId, processRoute.getBomId())); |
| | | productStructureInstanceService.remove(new LambdaQueryWrapper<ProductStructureInstance>() |
| | | .eq(ProductStructureInstance::getOrderId, orderId) |
| | | .eq(ProductStructureInstance::getBomId, processRoute.getBomId())); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®å·¥èºè·¯çº¿è¿ç§»åå¼ éè¡¨æ°æ® |
| | | * æ ¹æ®å·¥èºè·¯çº¿è¿ç§»éè¡¨æ°æ® |
| | | */ |
| | | private void migration(ProcessRoute processRoute) { |
| | | // è¿ç§»å·¥èºè·¯çº¿åéè¡¨æ°æ® |
| | | List<ProcessRouteItem> processRouteItemList = processRouteItemService.list(new LambdaQueryWrapper<ProcessRouteItem>().eq(ProcessRouteItem::getRouteId, processRoute.getId())); |
| | | migrationProcessRouteItem(processRouteItemList); |
| | | private void migration(Long orderId, ProcessRoute processRoute) { |
| | | // è¿ç§»å·¥èºè·¯çº¿åéè¡¨æ°æ®ï¼è¿åæ§id->æ°instanceæ å° |
| | | List<ProcessRouteItem> processRouteItemList = processRouteItemService.list( |
| | | new LambdaQueryWrapper<ProcessRouteItem>().eq(ProcessRouteItem::getRouteId, processRoute.getId())); |
| | | Map<Long, ProcessRouteItemInstance> routeItemOldIdMap = migrationProcessRouteItem(orderId, processRouteItemList); |
| | | |
| | | // è¿ç§»å·¥èºè·¯çº¿å
ç»å®çå·¥åºåå·¥åºåæ° |
| | | // è¿ç§»å·¥èºè·¯çº¿å
ç»å®çå·¥åºåæ° |
| | | if (processRouteItemList != null && !processRouteItemList.isEmpty()) { |
| | | for (ProcessRouteItem item : processRouteItemList) { |
| | | List<ProcessRouteItemParam> paramList = processRouteItemParamService.list(new LambdaQueryWrapper<ProcessRouteItemParam>().eq(ProcessRouteItemParam::getRouteItemId, item.getId())); |
| | | migrationProcessRouteItemParam(paramList); |
| | | ProcessRouteItemInstance newInstance = routeItemOldIdMap.get(item.getId()); |
| | | Long newRouteItemInstanceId = newInstance != null ? newInstance.getId() : item.getId(); |
| | | |
| | | List<ProductProcessParam> processParamList = productProcessParamService.list(new LambdaQueryWrapper<ProductProcessParam>().eq(ProductProcessParam::getProcessId, item.getProcessId())); |
| | | migrationProductProcessParam(processParamList); |
| | | List<ProcessRouteItemParam> paramList = processRouteItemParamService.list( |
| | | new LambdaQueryWrapper<ProcessRouteItemParam>().eq(ProcessRouteItemParam::getRouteItemId, item.getId())); |
| | | migrationProcessRouteItemParam(orderId, paramList, newRouteItemInstanceId); |
| | | } |
| | | } |
| | | |
| | | // è¿ç§»BOMåéè¡¨æ°æ® |
| | | if (processRoute.getBomId() != null) { |
| | | List<ProductStructure> structureList = productStructureService.list(new LambdaQueryWrapper<ProductStructure>().eq(ProductStructure::getBomId, processRoute.getBomId())); |
| | | migrationProductStructure(structureList); |
| | | List<ProductStructure> structureList = productStructureService.list( |
| | | new LambdaQueryWrapper<ProductStructure>().eq(ProductStructure::getBomId, processRoute.getBomId())); |
| | | migrationProductStructure(orderId, structureList); |
| | | } |
| | | } |
| | | |
| | | private void migrationProcessRouteItem(List<ProcessRouteItem> list) { |
| | | private Map<Long, ProcessRouteItemInstance> migrationProcessRouteItem(Long orderId, List<ProcessRouteItem> list) { |
| | | Map<Long, ProcessRouteItemInstance> oldIdMap = new HashMap<>(); |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | return oldIdMap; |
| | | } |
| | | List<ProcessRouteItemInstance> instances = list.stream().map(item -> { |
| | | ProcessRouteItemInstance instance = new ProcessRouteItemInstance(); |
| | | BeanUtils.copyProperties(item, instance, "id"); |
| | | instance.setIsQuality(item.getIsQuality() != null && item.getIsQuality() ? 1 : 0); |
| | | instance.setOrderId(orderId); |
| | | if (item.getId() != null) { |
| | | oldIdMap.put(item.getId(), instance); |
| | | } |
| | | return instance; |
| | | }).collect(Collectors.toList()); |
| | | processRouteItemInstanceService.saveBatch(instances); |
| | | return oldIdMap; |
| | | } |
| | | |
| | | private void migrationProcessRouteItemParam(List<ProcessRouteItemParam> list) { |
| | | private void migrationProcessRouteItemParam(Long orderId, List<ProcessRouteItemParam> list, Long newRouteItemInstanceId) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | List<ProcessRouteItemParamInstance> instances = list.stream().map(item -> { |
| | | ProcessRouteItemParamInstance instance = new ProcessRouteItemParamInstance(); |
| | | BeanUtils.copyProperties(item, instance, "id"); |
| | | instance.setOrderId(orderId); |
| | | instance.setRouteItemId(newRouteItemInstanceId); |
| | | return instance; |
| | | }).collect(Collectors.toList()); |
| | | processRouteItemParamInstanceService.saveBatch(instances); |
| | | } |
| | | |
| | | private void migrationProductProcessParam(List<ProductProcessParam> list) { |
| | | private void migrationProductStructure(Long orderId, List<ProductStructure> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | List<ProductProcessParamInstance> instances = list.stream().map(item -> { |
| | | ProductProcessParamInstance instance = new ProductProcessParamInstance(); |
| | | BeanUtils.copyProperties(item, instance, "id"); |
| | | instance.setIsRequired(item.getIsRequired() != null && item.getIsRequired() == 1); |
| | | return instance; |
| | | }).collect(Collectors.toList()); |
| | | productProcessParamInstanceService.saveBatch(instances); |
| | | } |
| | | |
| | | private void migrationProductStructure(List<ProductStructure> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return; |
| | | } |
| | | Map<Long, ProductStructureInstance> oldIdMap = new HashMap<>(); |
| | | List<ProductStructureInstance> instances = list.stream().map(item -> { |
| | | ProductStructureInstance instance = new ProductStructureInstance(); |
| | | BeanUtils.copyProperties(item, instance, "id"); |
| | | instance.setBomId(item.getBomId() != null ? item.getBomId().longValue() : null); |
| | | instance.setOrderId(orderId); |
| | | if (item.getId() != null) { |
| | | oldIdMap.put(item.getId(), instance); |
| | | } |
| | | return instance; |
| | | }).collect(Collectors.toList()); |
| | | productStructureInstanceService.saveBatch(instances); |
| | | |
| | | // æ°å¢åæidï¼æ§id->æ°idï¼ä¿®æ£parentId |
| | | Map<Long, Long> oldToNewId = new HashMap<>(); |
| | | list.forEach(item -> { |
| | | if (item.getId() != null && oldIdMap.containsKey(item.getId())) { |
| | | oldToNewId.put(item.getId(), oldIdMap.get(item.getId()).getId()); |
| | | } |
| | | }); |
| | | |
| | | List<ProductStructureInstance> toUpdate = instances.stream() |
| | | .filter(i -> i.getParentId() != null && oldToNewId.containsKey(i.getParentId())) |
| | | .peek(i -> i.setParentId(oldToNewId.get(i.getParentId()))) |
| | | .collect(Collectors.toList()); |
| | | if (!toUpdate.isEmpty()) { |
| | | productStructureInstanceService.updateBatchById(toUpdate); |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.appendix.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.appendix.dto.ProcessRouteItemInstanceDto; |
| | | import com.ruoyi.appendix.mapper.ProcessRouteItemInstanceMapper; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemInstance; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemParamInstance; |
| | | import com.ruoyi.appendix.service.ProcessRouteItemInstanceService; |
| | | import com.ruoyi.appendix.service.ProcessRouteItemParamInstanceService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.production.pojo.ProcessRouteItemParam; |
| | | import com.ruoyi.production.pojo.ProductProcess; |
| | | import com.ruoyi.production.service.ProcessRouteItemParamService; |
| | | import com.ruoyi.production.service.ProductProcessService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @Service |
| | | public class ProcessRouteItemInstanceServiceImpl extends ServiceImpl<ProcessRouteItemInstanceMapper, ProcessRouteItemInstance> implements ProcessRouteItemInstanceService { |
| | | |
| | | @Resource |
| | | private ProductProcessService productProcessService; |
| | | |
| | | } |
| | | @Resource |
| | | private ProcessRouteItemParamInstanceService processRouteItemParamInstanceService; |
| | | |
| | | @Resource |
| | | private ProcessRouteItemParamService processRouteItemParamService; |
| | | |
| | | @Override |
| | | public List<ProcessRouteItemInstanceDto> getProcessItem(Long orderId) { |
| | | List<ProcessRouteItemInstance> list = list(new LambdaQueryWrapper<ProcessRouteItemInstance>() |
| | | .eq(ProcessRouteItemInstance::getOrderId, orderId) |
| | | .orderByAsc(ProcessRouteItemInstance::getDragSort)); |
| | | return list.stream().map(item -> { |
| | | ProcessRouteItemInstanceDto dto = new ProcessRouteItemInstanceDto(); |
| | | BeanUtils.copyProperties(item, dto); |
| | | if (item.getProcessId() != null) { |
| | | ProductProcess process = productProcessService.getById(item.getProcessId()); |
| | | if (process != null) { |
| | | dto.setProcessName(process.getName()); |
| | | } |
| | | } |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | public void addProcessItem(ProcessRouteItemInstanceDto dto) { |
| | | if (dto == null) { |
| | | throw new ServiceException("æ°å¢æ°æ®ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (dto.getOrderId() == null) { |
| | | throw new ServiceException("ç产订åIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (dto.getProcessId() == null) { |
| | | throw new ServiceException("å·¥åºIDä¸è½ä¸ºç©º"); |
| | | } |
| | | ProcessRouteItemInstance entity = new ProcessRouteItemInstance(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setId(null); |
| | | entity.setTenantId(SecurityUtils.getLoginUser().getTenantId()); |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | |
| | | // åå½å订å䏿大 dragSort + 1 |
| | | ProcessRouteItemInstance maxSortItem = getOne(new LambdaQueryWrapper<ProcessRouteItemInstance>() |
| | | .eq(ProcessRouteItemInstance::getOrderId, dto.getOrderId()) |
| | | .orderByDesc(ProcessRouteItemInstance::getDragSort) |
| | | .last("limit 1")); |
| | | entity.setDragSort(maxSortItem != null && maxSortItem.getDragSort() != null ? maxSortItem.getDragSort() + 1 : 1); |
| | | save(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void updateProcessItem(ProcessRouteItemInstanceDto dto) { |
| | | if (dto == null || dto.getId() == null) { |
| | | throw new ServiceException("æ´æ°æ°æ®æIDä¸è½ä¸ºç©º"); |
| | | } |
| | | ProcessRouteItemInstance old = getById(dto.getId()); |
| | | if (old == null) { |
| | | throw new ServiceException("æ°æ®ä¸åå¨"); |
| | | } |
| | | // å·¥åºåæ´ï¼å 餿§åæ°é表ï¼è¿ç§»æ°å·¥åºåæ° |
| | | if (dto.getProcessId() != null && !dto.getProcessId().equals(old.getProcessId())) { |
| | | // å é¤å·¥èºè·¯çº¿å·¥åºåæ°é表 |
| | | processRouteItemParamInstanceService.remove(new LambdaQueryWrapper<ProcessRouteItemParamInstance>() |
| | | .eq(ProcessRouteItemParamInstance::getOrderId, old.getOrderId()) |
| | | .eq(ProcessRouteItemParamInstance::getRouteItemId, old.getId())); |
| | | |
| | | // è¿ç§»æ°å·¥åºç process_route_item_param |
| | | List<ProcessRouteItemParam> routeItemParams = processRouteItemParamService.list( |
| | | new LambdaQueryWrapper<ProcessRouteItemParam>().eq(ProcessRouteItemParam::getRouteItemId, old.getId())); |
| | | if (!routeItemParams.isEmpty()) { |
| | | List<ProcessRouteItemParamInstance> newInstances = routeItemParams.stream().map(p -> { |
| | | ProcessRouteItemParamInstance instance = new ProcessRouteItemParamInstance(); |
| | | BeanUtils.copyProperties(p, instance, "id"); |
| | | instance.setOrderId(old.getOrderId()); |
| | | return instance; |
| | | }).collect(Collectors.toList()); |
| | | processRouteItemParamInstanceService.saveBatch(newInstances); |
| | | } |
| | | } |
| | | ProcessRouteItemInstance entity = new ProcessRouteItemInstance(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteProcessItem(Long id) { |
| | | if (id == null) { |
| | | throw new ServiceException("IDä¸è½ä¸ºç©º"); |
| | | } |
| | | ProcessRouteItemInstance old = getById(id); |
| | | if (old == null) { |
| | | throw new ServiceException("æ°æ®ä¸åå¨"); |
| | | } |
| | | // å é¤å·¥èºè·¯çº¿å·¥åºåæ°é表 |
| | | processRouteItemParamInstanceService.remove(new LambdaQueryWrapper<ProcessRouteItemParamInstance>() |
| | | .eq(ProcessRouteItemParamInstance::getOrderId, old.getOrderId()) |
| | | .eq(ProcessRouteItemParamInstance::getRouteItemId, id)); |
| | | removeById(id); |
| | | } |
| | | |
| | | @Override |
| | | public void sortProcessItem(ProcessRouteItemInstanceDto dto) { |
| | | if (dto == null || dto.getId() == null) { |
| | | throw new ServiceException("æ°æ®æIDä¸è½ä¸ºç©º"); |
| | | } |
| | | ProcessRouteItemInstance old = getById(dto.getId()); |
| | | if (old == null) { |
| | | throw new ServiceException("æ°æ®ä¸åå¨"); |
| | | } |
| | | List<ProcessRouteItemInstance> items = list(new LambdaQueryWrapper<ProcessRouteItemInstance>() |
| | | .eq(ProcessRouteItemInstance::getOrderId, old.getOrderId()) |
| | | .orderByAsc(ProcessRouteItemInstance::getDragSort)); |
| | | Integer targetPosition = dto.getDragSort(); |
| | | if (targetPosition != null && targetPosition >= 1) { |
| | | items.removeIf(item -> item.getId().equals(old.getId())); |
| | | items.add(targetPosition - 1, old); |
| | | for (int i = 0; i < items.size(); i++) { |
| | | ProcessRouteItemInstance item = items.get(i); |
| | | int newSort = i + 1; |
| | | if (!item.getId().equals(old.getId())) { |
| | | if (!Integer.valueOf(newSort).equals(item.getDragSort())) { |
| | | item.setDragSort(newSort); |
| | | updateById(item); |
| | | } |
| | | } else { |
| | | old.setDragSort(newSort); |
| | | updateById(old); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.appendix.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.appendix.dto.ProcessRouteItemParamInstanceDto; |
| | | import com.ruoyi.appendix.mapper.ProcessRouteItemParamInstanceMapper; |
| | | import com.ruoyi.appendix.pojo.ProcessRouteItemParamInstance; |
| | | import com.ruoyi.appendix.service.ProcessRouteItemParamInstanceService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class ProcessRouteItemParamInstanceServiceImpl extends ServiceImpl<ProcessRouteItemParamInstanceMapper, ProcessRouteItemParamInstance> implements ProcessRouteItemParamInstanceService { |
| | | } |
| | | |
| | | @Override |
| | | public List<ProcessRouteItemParamInstanceDto> routeItemParamList(Long orderId, Long routeItemId) { |
| | | List<ProcessRouteItemParamInstance> list = list(new LambdaQueryWrapper<ProcessRouteItemParamInstance>() |
| | | .eq(ProcessRouteItemParamInstance::getOrderId, orderId) |
| | | .eq(ProcessRouteItemParamInstance::getRouteItemId, routeItemId) |
| | | .orderByAsc(ProcessRouteItemParamInstance::getSort)); |
| | | |
| | | return list.stream().map(item -> { |
| | | ProcessRouteItemParamInstanceDto dto = new ProcessRouteItemParamInstanceDto(); |
| | | BeanUtils.copyProperties(item, dto); |
| | | return dto; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void addRouteItemParam(ProcessRouteItemParamInstanceDto dto) { |
| | | if (dto == null) { |
| | | throw new ServiceException("æ°å¢æ°æ®ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (dto.getOrderId() == null) { |
| | | throw new ServiceException("ç产订åIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (dto.getRouteItemId() == null) { |
| | | throw new ServiceException("å·¥èºè·¯çº¿æç»IDä¸è½ä¸ºç©º"); |
| | | } |
| | | Long tenantId = SecurityUtils.getLoginUser().getTenantId(); |
| | | |
| | | ProcessRouteItemParamInstance entity = new ProcessRouteItemParamInstance(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setId(null); |
| | | entity.setOrderId(dto.getOrderId()); |
| | | entity.setRouteItemId(dto.getRouteItemId()); |
| | | entity.setIsRequired(dto.getIsRequired()); |
| | | // åå½å订å+路线æç»ä¸æå¤§ sort + 1 |
| | | ProcessRouteItemParamInstance maxSortItem = getOne(new LambdaQueryWrapper<ProcessRouteItemParamInstance>() |
| | | .select(ProcessRouteItemParamInstance::getSort) |
| | | .eq(ProcessRouteItemParamInstance::getOrderId, dto.getOrderId()) |
| | | .eq(ProcessRouteItemParamInstance::getRouteItemId, dto.getRouteItemId()) |
| | | .orderByDesc(ProcessRouteItemParamInstance::getSort) |
| | | .last("limit 1")); |
| | | entity.setSort(maxSortItem != null && maxSortItem.getSort() != null ? maxSortItem.getSort() + 1 : 1); |
| | | entity.setTenantId(tenantId); |
| | | entity.setCreateTime(LocalDateTime.now()); |
| | | save(entity); |
| | | } |
| | | |
| | | @Override |
| | | public void updateRouteItemParam(ProcessRouteItemParamInstanceDto dto) { |
| | | if (dto == null || dto.getId() == null) { |
| | | throw new ServiceException("æ´æ°æ°æ®æIDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (getById(dto.getId()) == null) { |
| | | throw new ServiceException("æ°æ®ä¸åå¨"); |
| | | } |
| | | ProcessRouteItemParamInstance entity = new ProcessRouteItemParamInstance(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | updateById(entity); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteRouteItemParam(Long id) { |
| | | if (id == null) { |
| | | throw new ServiceException("IDä¸è½ä¸ºç©º"); |
| | | } |
| | | if (getById(id) == null) { |
| | | throw new ServiceException("æ°æ®ä¸åå¨"); |
| | | } |
| | | removeById(id); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.appendix.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.appendix.dto.ProductStructureInstanceDto; |
| | | import com.ruoyi.appendix.mapper.ProductStructureInstanceMapper; |
| | | import com.ruoyi.appendix.pojo.ProductStructureInstance; |
| | | import com.ruoyi.appendix.service.ProductStructureInstanceService; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <br> |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class ProductStructureInstanceServiceImpl extends ServiceImpl<ProductStructureInstanceMapper, ProductStructureInstance> implements ProductStructureInstanceService { |
| | | |
| | | @Override |
| | | public List<ProductStructureInstanceDto> listByOrderId(Long orderId) { |
| | | List<ProductStructureInstance> list = list(new LambdaQueryWrapper<ProductStructureInstance>().eq(ProductStructureInstance::getOrderId, orderId)); |
| | | |
| | | List<ProductStructureInstanceDto> dtoList = list.stream().map(item -> { |
| | | ProductStructureInstanceDto dto = new ProductStructureInstanceDto(); |
| | | BeanUtils.copyProperties(item, dto); |
| | | return dto; |
| | | }).collect(java.util.stream.Collectors.toList()); |
| | | |
| | | Map<Long, ProductStructureInstanceDto> map = new HashMap<>(); |
| | | for (ProductStructureInstanceDto node : dtoList) { |
| | | map.put(node.getId(), node); |
| | | } |
| | | |
| | | List<ProductStructureInstanceDto> tree = new ArrayList<>(); |
| | | for (ProductStructureInstanceDto node : dtoList) { |
| | | Long parentId = node.getParentId(); |
| | | if (parentId == null || !map.containsKey(parentId)) { |
| | | tree.add(node); |
| | | } else { |
| | | map.get(parentId).getChildren().add(node); |
| | | } |
| | | } |
| | | return tree; |
| | | } |
| | | |
| | | @Override |
| | | public void addOrUpdateBomStructs(ProductStructureInstanceDto instanceDto) { |
| | | Long orderId = instanceDto.getOrderId(); |
| | | |
| | | // æå¹³ååç«¯ä¼ å
¥çæ |
| | | List<ProductStructureInstanceDto> flatList = new ArrayList<>(); |
| | | flattenTree(instanceDto.getChildren(), flatList); |
| | | |
| | | // æ¥è¯¢æ°æ®åºå·²ææ°æ® |
| | | List<ProductStructureInstance> dbList = list(new LambdaQueryWrapper<ProductStructureInstance>() |
| | | .eq(ProductStructureInstance::getOrderId, orderId)); |
| | | |
| | | // å端已æidéå |
| | | Set<Long> frontendIds = flatList.stream() |
| | | .map(ProductStructureInstanceDto::getId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | |
| | | // éè¦å é¤çèç¹ |
| | | Set<Long> deleteIds = dbList.stream() |
| | | .map(ProductStructureInstance::getId) |
| | | .filter(id -> !frontendIds.contains(id)) |
| | | .collect(Collectors.toSet()); |
| | | if (!deleteIds.isEmpty()) { |
| | | removeByIds(deleteIds); |
| | | } |
| | | |
| | | List<ProductStructureInstance> insertList = new ArrayList<>(); |
| | | List<ProductStructureInstance> updateList = new ArrayList<>(); |
| | | Map<String, ProductStructureInstance> tempEntityMap = new HashMap<>(); |
| | | |
| | | for (ProductStructureInstanceDto dto : flatList) { |
| | | ProductStructureInstance entity = new ProductStructureInstance(); |
| | | BeanUtils.copyProperties(dto, entity); |
| | | entity.setOrderId(orderId); |
| | | if (dto.getId() == null) { |
| | | entity.setId(null); |
| | | entity.setParentId(null); |
| | | insertList.add(entity); |
| | | if (dto.getTempId() != null) { |
| | | tempEntityMap.put(dto.getTempId(), entity); |
| | | } |
| | | } else { |
| | | updateList.add(entity); |
| | | } |
| | | } |
| | | |
| | | if (!insertList.isEmpty()) { |
| | | saveBatch(insertList); |
| | | } |
| | | |
| | | // ååæ°å¢èç¹ç parentId |
| | | List<ProductStructureInstance> parentFixList = new ArrayList<>(); |
| | | for (ProductStructureInstanceDto dto : flatList) { |
| | | if (dto.getId() != null) continue; |
| | | ProductStructureInstance child = tempEntityMap.get(dto.getTempId()); |
| | | if (child == null) continue; |
| | | String parentTempId = dto.getParentTempId(); |
| | | if (parentTempId != null && !parentTempId.isEmpty()) { |
| | | Long realParentId; |
| | | if (tempEntityMap.containsKey(parentTempId)) { |
| | | realParentId = tempEntityMap.get(parentTempId).getId(); |
| | | } else { |
| | | try { |
| | | realParentId = Long.valueOf(parentTempId); |
| | | } catch (NumberFormatException e) { |
| | | realParentId = 0L; |
| | | } |
| | | } |
| | | child.setParentId(realParentId); |
| | | } else { |
| | | child.setParentId(0L); |
| | | } |
| | | parentFixList.add(child); |
| | | } |
| | | |
| | | if (!parentFixList.isEmpty()) { |
| | | updateBatchById(parentFixList); |
| | | } |
| | | if (!updateList.isEmpty()) { |
| | | updateBatchById(updateList); |
| | | } |
| | | } |
| | | |
| | | private void flattenTree(List<ProductStructureInstanceDto> source, List<ProductStructureInstanceDto> result) { |
| | | if (source == null) return; |
| | | for (ProductStructureInstanceDto node : source) { |
| | | result.add(node); |
| | | flattenTree(node.getChildren(), result); |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public void syncCustomerJob() { |
| | | syncCustomerData(2); |
| | | syncCustomerData(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * åæ¥æ°æ® |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void syncCustomerData(Integer dataSyncType) { |
| | | if (!syncLock.tryLock()) { |
| | | log.warn("忥æ£å¨è¿è¡ä¸ï¼æ¬æ¬¡ {} åæ¥è¯·æ±è¢«è·³è¿", dataSyncType == 1 ? "æå¨" : "宿¶ä»»å¡"); |
| | | return; |
| | | } |
| | | public void syncCustomerData() { |
| | | try { |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject statusCondition = new JSONObject(); |
| | |
| | | |
| | | } catch (Exception e) { |
| | | log.error("忥客æ·ä¿¡æ¯å¼å¸¸", e); |
| | | } finally { |
| | | // éæ¾é |
| | | syncLock.unlock(); |
| | | } |
| | | } |
| | | |
| | |
| | | @Autowired |
| | | private ICustomerService customerService; |
| | | |
| | | @Scheduled(cron = "0 0 * * * ?") |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void syncCustomerDataJob() { |
| | | customerService.syncCustomerJob(); |
| | | } |
| | |
| | | private String customerCodeFormUuid; |
| | | |
| | | /** |
| | | * éå®åè´§æç»-å®æè¡¨åID |
| | | */ |
| | | private String salesDeliveryFormUuid; |
| | | |
| | | /** |
| | | * 宿åºç¨å¯é¥ |
| | | * ç¨äºè®¿é®å®æè¡¨å API |
| | | */ |
| | |
| | | @ExcelIgnoreUnannotated |
| | | public class ProductOrderDto extends ProductOrder { |
| | | |
| | | @ApiModelProperty(value = "éå®ååå·") |
| | | @Excel(name = "éå®ååå·") |
| | | private String salesContractNo; |
| | | |
| | | @ApiModelProperty(value = "项ç®å") |
| | | @Excel(name = "项ç®å") |
| | | private String projectName; |
| | | |
| | | @ApiModelProperty(value = "客æ·åç§°") |
| | | @Excel(name = "客æ·åç§°") |
| | | private String customerName; |
| | | |
| | | @ApiModelProperty(value = "产ååç§°") |
| | | @Excel(name = "产ååç§°") |
| | | private String productCategory; |
| | | private String productName; |
| | | |
| | | @ApiModelProperty(value = "è§æ ¼") |
| | | @Excel(name = "è§æ ¼") |
| | | private String specificationModel; |
| | | private String model; |
| | | |
| | | @ApiModelProperty(value = "产åç±»å") |
| | | @Excel(name = "产åç±»å") |
| | | private String strength; |
| | | |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿æè¿°") |
| | | @Excel(name = "å·¥èºè·¯çº¿æè¿°") |
| | | private String description; |
| | | |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿äº§åç±»å") |
| | | @Excel(name = "å·¥èºè·¯çº¿äº§åç±»å") |
| | | private String dictLabel; |
| | | |
| | | @ApiModelProperty(value = "ç©æç¼ç ") |
| | | @Excel(name = "ç©æç¼ç ") |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty(value = "å·¥èºè·¯çº¿ç¼å·") |
| | | @Excel(name = "å·¥èºè·¯çº¿ç¼å·") |
| | |
| | | @Excel(name = "宿è¿åº¦", suffix = "%") |
| | | private BigDecimal completionStatus; |
| | | |
| | | @ApiModelProperty(value = "BOM ID") |
| | | @Excel(name = "BOM ID") |
| | | private String bomId; |
| | | |
| | | @ApiModelProperty(value = "BOMç¼å·") |
| | | @Excel(name = "BOMç¼å·") |
| | | private String bomNo; |
| | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.production.pojo.ProductProcessParam; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | |
| | | * @since 2026/03/14 15:33 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value = "ProductProcessParamDto对象", description = "å·¥åºç»å®åæ°Dto") |
| | | public class ProductProcessParamDto { |
| | | public class ProductProcessParamDto extends ProductProcessParam { |
| | | |
| | | @ApiModelProperty("主é®ID") |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("æå±å·¥åºID (product_process.id)") |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty("å
³èåºç¡åæ°ID (base_param.id)") |
| | | private Long paramId; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åå¼(å弿¨¡å¼ä½¿ç¨)") |
| | | private String standardValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åæå°å¼(åºé´æ¨¡å¼ä½¿ç¨)") |
| | | private BigDecimal minValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åæå¤§å¼(åºé´æ¨¡å¼ä½¿ç¨)") |
| | | private BigDecimal maxValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºä¸æ¯å¦å¿
å¡«(0-å¦, 1-æ¯)") |
| | | private Integer isRequired; |
| | | |
| | | @ApiModelProperty("æåºå·") |
| | | private Integer sort; |
| | | |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("å建æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | } |
| | |
| | | @ApiModelProperty("å
³èå·¥èºè·¯çº¿æç»ID (process_route_item.id)") |
| | | private Long routeItemId; |
| | | |
| | | @ApiModelProperty("å
³èåºç¡åæ°å®ä¹ID (base_param.id)") |
| | | private Long paramId; |
| | | @ApiModelProperty("åæ°å¯ä¸æ è¯") |
| | | private String paramKey; |
| | | |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("æ¥æºå·¥åºåæ°ID") |
| | | private Long processParamId; |
| | |
| | | private BigDecimal maxValue; |
| | | |
| | | @ApiModelProperty("æ¯å¦å¿
å¡«") |
| | | private Integer isRequired; |
| | | private Boolean isRequired; |
| | | |
| | | @ApiModelProperty("æåº") |
| | | private Integer sort; |
| | |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime endTime; |
| | | |
| | | @Excel(name = "产åç±»å") |
| | | @ApiModelProperty("产åç±»å") |
| | | private String strength; |
| | | |
| | | @ApiModelProperty(value = "ç¶æï¼1.å¾
å¼å§ã2.è¿è¡ä¸ã3.已宿ã4.已忶ï¼") |
| | | private Integer status; |
| | | } |
| | |
| | | package com.ruoyi.production.pojo; |
| | | |
| | | 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 com.fasterxml.jackson.annotation.JsonFormat; |
| | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | @ApiModelProperty("åæ°å¯ä¸æ è¯") |
| | | private String paramKey; |
| | | |
| | | @ApiModelProperty("åæ°åç§°") |
| | | private String paramName; |
| | | |
| | | @ApiModelProperty("åæ°ç±»å(1æ°å 2ææ¬ 3䏿鿩 4æ¶é´)") |
| | | private Integer paramType; |
| | | |
| | | @ApiModelProperty("åæ°æ ¼å¼") |
| | | private String paramFormat; |
| | | |
| | | @ApiModelProperty("弿¨¡å¼(1åå¼ 2åºé´)") |
| | | private Integer valueMode; |
| | | |
| | | @ApiModelProperty("åä½") |
| | | private String unit; |
| | | |
| | | @ApiModelProperty("夿³¨") |
| | | private String remark; |
| | | |
| | | @ApiModelProperty("æå±å·¥åºID (product_process.id)") |
| | | private Long processId; |
| | | |
| | | @ApiModelProperty("å
³èåºç¡åæ°ID (base_param.id)") |
| | | @TableField(exist = false) |
| | | private Long paramId; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºè®¾å®çæ åå¼(å弿¨¡å¼ä½¿ç¨)") |
| | |
| | | private BigDecimal maxValue; |
| | | |
| | | @ApiModelProperty("卿¤å·¥åºä¸æ¯å¦å¿
å¡«(0-å¦, 1-æ¯)") |
| | | private Integer isRequired; |
| | | private Boolean isRequired; |
| | | |
| | | @ApiModelProperty("æåºå·") |
| | | private Integer sort; |
| | |
| | | @ApiModelProperty("æ´æ°æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private Date updateTime; |
| | | } |
| | | } |
| | |
| | | |
| | | Boolean addProductOrder(ProductOrder productOrder); |
| | | |
| | | Long insertProductOrder(ProductOrder productOrder); |
| | | |
| | | Boolean delete(Long[] id); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.pojo.BaseParam; |
| | | import com.ruoyi.basic.service.BaseParamService; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.production.dto.ProcessRouteItemParamDto; |
| | |
| | | import com.ruoyi.production.pojo.ProcessRouteItemParam; |
| | | import com.ruoyi.production.service.ProcessRouteItemParamService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class ProcessRouteItemParamServiceImpl extends ServiceImpl<ProcessRouteItemParamMapper, ProcessRouteItemParam> implements ProcessRouteItemParamService { |
| | | |
| | | @Autowired |
| | | private BaseParamService baseParamService; |
| | | |
| | | @Override |
| | | public IPage<ProcessRouteItemParamDto> pageList(Page<ProcessRouteItemParam> page, ProcessRouteItemParam param) { |
| | |
| | | if (param == null) { |
| | | throw new ServiceException("æ°å¢å¤±è´¥,åæ°ä¸è½ä¸ºç©º"); |
| | | } |
| | | if (param.getRouteItemId() == null || param.getParamId() == null) { |
| | | throw new ServiceException("å
³èå·¥åºIDå忰项IDä¸è½ä¸ºç©º"); |
| | | if (param.getRouteItemId() == null || param.getParamKey() == null) { |
| | | throw new ServiceException("å
³èå·¥åºIDååæ°æ è¯ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | Long tenantId = SecurityUtils.getLoginUser().getTenantId(); |
| | | Long count = baseMapper.selectCount(Wrappers.<ProcessRouteItemParam>lambdaQuery() |
| | | .eq(ProcessRouteItemParam::getRouteItemId, param.getRouteItemId()) |
| | | .eq(ProcessRouteItemParam::getParamId, param.getParamId()) |
| | | .eq(ProcessRouteItemParam::getParamKey, param.getParamKey()) |
| | | .eq(ProcessRouteItemParam::getTenantId, tenantId)); |
| | | if (count > 0) { |
| | | throw new ServiceException("该工åºå·²å卿¤åæ°é¡¹ï¼è¯·å¿é夿·»å "); |
| | | } |
| | | |
| | | BaseParam baseParam = baseParamService.getById(param.getParamId()); |
| | | if (baseParam == null) { |
| | | throw new ServiceException("æ°å¢å¤±è´¥,æ¹åºç¡åæ°ä¸åå¨"); |
| | | throw new ServiceException("该工åºå·²åå¨åæ°é¡¹ï¼è¯·å¿é夿·»å "); |
| | | } |
| | | |
| | | Integer maxSort = baseMapper.selectMaxSortByRouteItemId(param.getRouteItemId()); |
| | |
| | | |
| | | @Override |
| | | public Boolean addProductOrder(ProductOrder productOrder) { |
| | | String string = generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(string); |
| | | fillAndSaveProductOrder(productOrder); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Long insertProductOrder(ProductOrder productOrder) { |
| | | fillAndSaveProductOrder(productOrder); |
| | | return productOrder.getId(); |
| | | } |
| | | |
| | | private void fillAndSaveProductOrder(ProductOrder productOrder) { |
| | | String orderNo = generateNextOrderNo(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"))); |
| | | productOrder.setNpsNo(orderNo); |
| | | productOrder.setCompleteQuantity(BigDecimal.ZERO); |
| | | this.save(productOrder); |
| | | if (ObjectUtils.isNotEmpty(productOrder.getRouteId())) { |
| | | this.bindingRoute(productOrder); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | |
| | | // å é¤é表çå·¥èºè·¯çº¿ä¸BOM |
| | | for (Long id : ids) { |
| | | ProductOrder productOrder = baseMapper.selectById(id); |
| | | appendixService.deleteData(productOrder.getRouteId()); |
| | | appendixService.deleteData(productOrder.getId(), productOrder.getRouteId()); |
| | | } |
| | | |
| | | // productProcessRouteItemMapper.delete(new LambdaQueryWrapper<ProductProcessRouteItem>().in(ProductProcessRouteItem::getProductOrderId, ids)); |
| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.basic.mapper.BaseParamMapper; |
| | | import com.ruoyi.basic.pojo.BaseParam; |
| | | import com.ruoyi.basic.service.BaseParamService; |
| | | import com.ruoyi.production.dto.ProductProcessParamDto; |
| | | import com.ruoyi.production.dto.ProductProcessParamSortDTO; |
| | |
| | | public class ProductProcessParamServiceImpl extends ServiceImpl<ProductProcessParamMapper, ProductProcessParam> implements ProductProcessParamService { |
| | | |
| | | @Autowired |
| | | private BaseParamService baseParamService; |
| | | BaseParamMapper baseParamMapper; |
| | | |
| | | @Override |
| | | public List<ProductProcessParamDto> listByProcessId(Long processId) { |
| | |
| | | if (productProcessParam.getParamId() == null) { |
| | | throw new IllegalArgumentException("å
³èåºç¡åæ°IDä¸è½ä¸ºç©º"); |
| | | } |
| | | BaseParam baseParam = baseParamMapper.selectById(productProcessParam.getParamId()); |
| | | productProcessParam.setParamKey(baseParam.getParamKey()); |
| | | productProcessParam.setParamName(baseParam.getParamName()); |
| | | productProcessParam.setParamType(baseParam.getParamType()); |
| | | productProcessParam.setParamFormat(baseParam.getParamFormat()); |
| | | productProcessParam.setUnit(baseParam.getUnit()); |
| | | productProcessParam.setCreateTime(new Date()); |
| | | if (!this.save(productProcessParam)) { |
| | | throw new RuntimeException("æ°å¢å¤±è´¥"); |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.productionPlan.controller; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | | * éå®åè´§æç»(宿) å端æ§å¶å¨ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-19 11:49:57 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/salesDelivery") |
| | | @Api(tags = "éå®åè´§æç»") |
| | | public class SalesDeliveryController { |
| | | |
| | | } |
| | |
| | | */ |
| | | @ApiModelProperty("å
³èç©æä¿¡æ¯è¡¨ID") |
| | | private Long productMaterialId; |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.productionPlan.mapper; |
| | | |
| | | import com.ruoyi.productionPlan.pojo.SalesDelivery; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | /** |
| | | * <p> |
| | | * éå®åè´§æç»(宿) Mapper æ¥å£ |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-19 11:49:57 |
| | | */ |
| | | @Mapper |
| | | public interface SalesDeliveryMapper extends BaseMapper<SalesDelivery> { |
| | | |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.productionPlan.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 java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Getter; |
| | | import lombok.Setter; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | |
| | | /** |
| | | * <p> |
| | | * éå®åè´§æç»(宿) |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-19 11:49:57 |
| | | */ |
| | | @Getter |
| | | @Setter |
| | | @TableName("sales_delivery") |
| | | @ApiModel(value = "SalesDelivery对象", description = "éå®åè´§æç»(宿)") |
| | | public class SalesDelivery implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | |
| | | @ApiModelProperty("ä¾è´§æ¥æ") |
| | | @JsonFormat(pattern = "yyyy-MM-dd") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd") |
| | | private LocalDate deliveryDate; |
| | | |
| | | @ApiModelProperty("åè´§åç¼å·") |
| | | private String deliveryCode; |
| | | |
| | | @ApiModelProperty("项ç®åç§°") |
| | | private String projectName; |
| | | |
| | | @ApiModelProperty("éè´§å°ç¹") |
| | | private String deliveryPlace; |
| | | |
| | | @ApiModelProperty("è系人") |
| | | private String linkMan; |
| | | |
| | | @ApiModelProperty("èç³»çµè¯") |
| | | private String linkPhone; |
| | | |
| | | @ApiModelProperty("åè´§å¤æ³¨") |
| | | private String deliveryRemark; |
| | | |
| | | @ApiModelProperty("ç©æä»£ç ") |
| | | private String materialCode; |
| | | |
| | | @ApiModelProperty("产ååç§°") |
| | | private String productName; |
| | | |
| | | @ApiModelProperty("产åè§æ ¼") |
| | | private String model; |
| | | |
| | | @ApiModelProperty("æ¹é") |
| | | private BigDecimal volume; |
| | | |
| | | @ApiModelProperty("åä»·") |
| | | private BigDecimal unitPrice; |
| | | |
| | | @ApiModelProperty("ä»·æ ¼") |
| | | private BigDecimal price; |
| | | |
| | | @ApiModelProperty("产å夿³¨") |
| | | private String productRemark; |
| | | |
| | | @ApiModelProperty("客æ·åç§°") |
| | | private String customer; |
| | | |
| | | @ApiModelProperty("ä¸å¡å") |
| | | private String salesman; |
| | | |
| | | @ApiModelProperty("åè´§æ¹å¼") |
| | | private String deliveryMethod; |
| | | |
| | | @ApiModelProperty("å®æè¡¨åå®ä¾ID") |
| | | private String formInstanceId; |
| | | |
| | | @ApiModelProperty("å®æä¿®æ¹æ¶é´") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime formModifiedTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | |
| | | @TableField(fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.productionPlan.service; |
| | | |
| | | import com.ruoyi.productionPlan.pojo.SalesDelivery; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | |
| | | /** |
| | | * <p> |
| | | * éå®åè´§æç»(宿) æå¡ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-19 11:49:57 |
| | | */ |
| | | public interface SalesDeliveryService extends IService<SalesDelivery> { |
| | | |
| | | void syncSalesDeliveryJob(); |
| | | |
| | | } |
| | |
| | | productOrder.setQuantity(productionPlanDto.getTotalAssignedQuantity()); |
| | | productOrder.setPlanCompleteTime(productionPlanDto.getPlanCompleteTime()); |
| | | productOrder.setStatus(ProductOrderStatusEnum.WAIT.getCode()); |
| | | productOrder.setStrength(productionPlanDto.getStrength()); |
| | | |
| | | Long orderId = productOrderService.insertProductOrder(productOrder); |
| | | |
| | | // å½ä¸åç产å为ç åææ¿æï¼å°±æåBOMåéä¸å·¥èºè·¯çº¿åéæ°æ®åå
¥å°éè¡¨ä¸ |
| | | if ("ç å".equals(productionPlanDto.getProductName())) { |
| | | productOrder.setRouteId(appendixService.populateBlocks(productionPlanDto)); |
| | | productOrder.setRouteId(appendixService.populateBlocks(orderId, productionPlanDto)); |
| | | } |
| | | if ("æ¿æ".equals(productionPlanDto.getProductName())) { |
| | | productOrder.setRouteId(appendixService.populatePlates(productionPlanDto)); |
| | | productOrder.setRouteId(appendixService.populatePlates(orderId, productionPlanDto)); |
| | | } |
| | | productOrderService.addProductOrder(productOrder); |
| | | // æ´æ°ç»å®çå·¥èºè·¯çº¿ |
| | | productOrderService.updateById(productOrder); |
| | | |
| | | // æ ¹æ®ä¸åæ°éï¼ä»ç¬¬ä¸ä¸ªç产计åå¼å§åé
æ¹æ° |
| | | BigDecimal assignedVolume = BigDecimal.ZERO; |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.productionPlan.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.basic.pojo.Customer; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.framework.util.AliDingUtils; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.productionPlan.enums.DataSourceTypeEnum; |
| | | import com.ruoyi.productionPlan.pojo.ProductionPlan; |
| | | import com.ruoyi.productionPlan.pojo.SalesDelivery; |
| | | import com.ruoyi.productionPlan.mapper.SalesDeliveryMapper; |
| | | import com.ruoyi.productionPlan.service.SalesDeliveryService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | | * éå®åè´§æç»(宿) æå¡å®ç°ç±» |
| | | * </p> |
| | | * |
| | | * @author è¯å¯¼è½¯ä»¶ï¼æ±èï¼æéå
¬å¸ |
| | | * @since 2026-03-19 11:49:57 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class SalesDeliveryServiceImpl extends ServiceImpl<SalesDeliveryMapper, SalesDelivery> implements SalesDeliveryService { |
| | | |
| | | @Autowired |
| | | private SalesDeliveryMapper salesDeliveryMapper; |
| | | |
| | | @Autowired |
| | | private AliDingConfig aliDingConfig; |
| | | |
| | | @Override |
| | | public void syncSalesDeliveryJob() { |
| | | syncSalesDelivery(); |
| | | } |
| | | |
| | | /** |
| | | * åæ¥æ°æ® |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void syncSalesDelivery() { |
| | | try { |
| | | JSONArray searchConditions = new JSONArray(); |
| | | JSONObject condition = new JSONObject(); |
| | | condition.put("key", "processApprovedResult"); |
| | | JSONArray valueArray = new JSONArray(); |
| | | valueArray.add("agree"); |
| | | condition.put("value", valueArray); |
| | | condition.put("type", "ARRAY"); |
| | | condition.put("operator", "in"); |
| | | condition.put("componentName", "SelectField"); |
| | | searchConditions.add(condition); |
| | | |
| | | JSONObject statusCondition = new JSONObject(); |
| | | statusCondition.put("key", "processInstanceStatus"); |
| | | JSONArray statusValueArray = new JSONArray(); |
| | | statusValueArray.add("COMPLETED"); |
| | | statusCondition.put("value", statusValueArray); |
| | | statusCondition.put("type", "ARRAY"); |
| | | statusCondition.put("operator", "in"); |
| | | statusCondition.put("componentName", "SelectField"); |
| | | searchConditions.add(statusCondition); |
| | | |
| | | String searchFieldJson = searchConditions.toJSONString(); |
| | | |
| | | JSONArray dataArr = AliDingUtils.getFormDataList(aliDingConfig, aliDingConfig.getSalesDeliveryFormUuid(), searchFieldJson, this, SalesDelivery::getFormModifiedTime); |
| | | |
| | | if (dataArr.isEmpty()) { |
| | | return; |
| | | } |
| | | |
| | | // è§£æå¹¶ä¿åæ°æ® |
| | | List<SalesDelivery> list = parseSalesDeliverys(dataArr); |
| | | if (!list.isEmpty()) { |
| | | // å¤çæ´æ°ææ°å¢ |
| | | int affected = processSaveOrUpdate(list); |
| | | log.info("æ°æ®åæ¥å®æï¼å
±åæ¥ {} æ¡æ°æ®", affected); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | log.error("忥ç产计åå¼å¸¸", e); |
| | | } |
| | | } |
| | | |
| | | private List<SalesDelivery> parseSalesDeliverys(JSONArray dataArr) { |
| | | List<SalesDelivery> list = new ArrayList<>(); |
| | | for (int i = 0; i < dataArr.size(); i++) { |
| | | JSONObject item = dataArr.getJSONObject(i); |
| | | String formInstanceId = item.getString("formInstanceId"); |
| | | JSONObject formData = item.getJSONObject("formData"); |
| | | JSONArray tableArr = formData.getJSONArray("tableField_kt8b0qse"); |
| | | if (tableArr == null || tableArr.isEmpty()) { |
| | | continue; |
| | | } |
| | | for (int j = 0; j < tableArr.size(); j++) { |
| | | JSONObject row = tableArr.getJSONObject(j); |
| | | SalesDelivery salesDelivery = new SalesDelivery(); |
| | | salesDelivery.setFormInstanceId(formInstanceId); |
| | | Long time = formData.getLong("dateField_kt8b0qsm"); |
| | | LocalDate date = Instant.ofEpochMilli(time).atZone(ZoneId.of("Asia/Shanghai")).toLocalDate(); |
| | | salesDelivery.setDeliveryDate(date);//ä¾è´§æ¥æ |
| | | salesDelivery.setDeliveryCode(formData.getString("textField_kt8b0qrp"));//åè´§åç¼å· |
| | | salesDelivery.setProjectName(formData.getString("textField_l92dg1tg"));//项ç®åç§° |
| | | salesDelivery.setDeliveryPlace(formData.getString("textField_kt8b0qsd"));//éè´§å°ç¹ |
| | | salesDelivery.setLinkMan(formData.getString("textField_kt8b0qsb"));//è系人 |
| | | salesDelivery.setLinkPhone(formData.getString("textField_kt8b0qsc"));//èç³»çµè¯ |
| | | salesDelivery.setDeliveryRemark(formData.getString("textareaField_kt8b0qsl"));//åè´§å¤æ³¨ |
| | | salesDelivery.setCustomer(formData.getString("textField_la98q3sg"));//客æ·åç§° |
| | | salesDelivery.setSalesman(formData.getString("textField_ladnkyu1"));//ä¸å¡å |
| | | salesDelivery.setDeliveryMethod(formData.getString("radioField_ldoc0027"));//åè´§æ¹å¼ |
| | | String materialCode = row.getString("textField_l92dg1tc"); |
| | | // æ ¹æ®ç©æç¼ç æ¥è¯¢ç©æä¿¡æ¯è¡¨ï¼å
³èç©æID |
| | | // if (StringUtils.isNotEmpty(materialCode)) { |
| | | // LambdaQueryWrapper<ProductMaterialSku> skuQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // skuQueryWrapper.eq(ProductMaterialSku::getMaterialCode, materialCode); |
| | | // ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper); |
| | | // if (sku != null) { |
| | | // salesDelivery.setProductMaterialSkuId(sku.getId()); |
| | | // } |
| | | // } |
| | | salesDelivery.setMaterialCode(materialCode);//ç©æç¼ç |
| | | salesDelivery.setProductName(row.getString("textField_l96srw8x"));//产ååç§° |
| | | salesDelivery.setModel(row.getString("textField_l9tljfl8"));//产åè§æ ¼ |
| | | salesDelivery.setVolume(row.getBigDecimal("numberField_kt8b0qsg_value"));//æ¹é |
| | | salesDelivery.setUnitPrice(row.getBigDecimal("numberField_la0tb2x9_value"));//åä»· |
| | | salesDelivery.setPrice(row.getBigDecimal("numberField_l9w2piwf"));//ä»·æ ¼ |
| | | salesDelivery.setProductRemark(row.getString("textField_kt8b0qsi"));//产å夿³¨ |
| | | salesDelivery.setFormModifiedTime(AliDingUtils.parseUtcTime(item.getString("modifiedTimeGMT"))); |
| | | list.add(salesDelivery); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | private int processSaveOrUpdate(List<SalesDelivery> list) { |
| | | if (list == null || list.isEmpty()) { |
| | | return 0; |
| | | } |
| | | int affected = 0; |
| | | |
| | | for (SalesDelivery salesDelivery : list) { |
| | | |
| | | LambdaQueryWrapper<SalesDelivery> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(SalesDelivery::getFormInstanceId, salesDelivery.getFormInstanceId()); |
| | | |
| | | SalesDelivery exist = this.getOne(wrapper); |
| | | if (exist == null) { |
| | | this.save(salesDelivery); |
| | | affected++; |
| | | } else { |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(salesDelivery.getFormModifiedTime())) { |
| | | salesDelivery.setId(exist.getId()); |
| | | this.updateById(salesDelivery); |
| | | affected++; |
| | | } |
| | | } |
| | | } |
| | | return affected; |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.productionPlan.task; |
| | | |
| | | |
| | | import com.ruoyi.productionPlan.service.ProductionPlanService; |
| | | import com.ruoyi.productionPlan.service.SalesDeliveryService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | |
| | | //éå®åè´§æç»å¯¹æ¥å®æå®æ¶ä»»å¡ |
| | | @Component |
| | | public class SalesDeliveryTask { |
| | | |
| | | |
| | | @Autowired |
| | | private SalesDeliveryService salesDeliveryService; |
| | | |
| | | @Scheduled(cron = "0 0 0 * * ?") |
| | | public void syncSalesDeliveryJob() { |
| | | salesDeliveryService.syncSalesDeliveryJob(); |
| | | } |
| | | } |
| | |
| | | produce-plan-form-uuid: "FORM-4IA66891C5H3QWMDBSGO05C0OX9628GRPYF7L8" |
| | | material-code-form-uuid: "FORM-8I666N718RW4ALO4ETYDDB0U6U8T3EIWTQ0ALL1" |
| | | customer-code-form-uuid: "FORM-4V966QC1M8B5W4Q89M1VL4ZURJ6C3FVA021ALE" |
| | | sales-delivery-form-uuid: "FORM-78766VC18V25CTDL82XSZBXKHBPX3BVEHI6ALE2" |
| | | system-token: "4J766L91OFH3V612E7LG5B4DI8M13MQF9VF7LG4" |
| | | # æ¥å£å°å |
| | | access-token-url: "https://oapi.dingtalk.com/gettoken" |
| | |
| | | |
| | | <resultMap id="ProcessRouteItemInstanceMap" type="com.ruoyi.appendix.pojo.ProcessRouteItemInstance"> |
| | | <id property="id" column="id"/> |
| | | <result property="orderId" column="order_id"/> |
| | | <result property="routeId" column="route_id"/> |
| | | <result property="productModelId" column="product_model_id"/> |
| | | <result property="processId" column="process_id"/> |
| | |
| | | |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.appendix.pojo.ProcessRouteItemParamInstance"> |
| | | <id property="id" column="id"/> |
| | | <result property="orderId" column="order_id"/> |
| | | <result property="routeItemId" column="route_item_id"/> |
| | | <result property="paramId" column="param_id"/> |
| | | <result property="processParamId" column="process_param_id"/> |
| | | <result property="paramKey" column="param_key"/> |
| | | <result property="paramName" column="param_name"/> |
| | | <result property="paramType" column="param_type"/> |
| | | <result property="paramFormat" column="param_format"/> |
| | | <result property="valueMode" column="value_mode"/> |
| | | <result property="unit" column="unit"/> |
| | | <result property="remark" column="remark"/> |
| | | <result property="standardValue" column="standard_value"/> |
| | | <result property="minValue" column="min_value"/> |
| | | <result property="maxValue" column="max_value"/> |
| | |
| | | |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.appendix.pojo.ProductStructureInstance"> |
| | | <id property="id" column="id"/> |
| | | <result property="orderId" column="order_id"/> |
| | | <result property="parentId" column="parent_id"/> |
| | | <result property="productModelId" column="product_model_id"/> |
| | | <result property="processId" column="process_id"/> |
| | |
| | | <resultMap id="ProcessRouteItemParamResultMap" type="com.ruoyi.production.pojo.ProcessRouteItemParam"> |
| | | <id property="id" column="id"/> |
| | | <result property="routeItemId" column="route_item_id"/> |
| | | <result property="paramId" column="param_id"/> |
| | | <result property="processParamId" column="process_param_id"/> |
| | | <result property="standardValue" column="standard_value"/> |
| | | <result property="minValue" column="min_value"/> |
| | |
| | | <result property="tenantId" column="tenant_id"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | <result property="paramKey" column="param_key"/> |
| | | <result property="paramName" column="param_name"/> |
| | | <result property="paramType" column="param_type"/> |
| | | <result property="paramFormat" column="param_format"/> |
| | | <result property="valueMode" column="value_mode"/> |
| | | <result property="unit" column="unit"/> |
| | | <result property="remark" column="remark"/> |
| | | </resultMap> |
| | | |
| | | <insert id="insertFromProcessTemplate"> |
| | | INSERT INTO process_route_item_param (route_item_id, param_id, process_param_id, |
| | | standard_value, min_value, max_value, |
| | | is_required, sort, tenant_id, create_time) |
| | | INSERT INTO process_route_item_param (route_item_id, |
| | | process_param_id, |
| | | standard_value, |
| | | min_value, |
| | | max_value, |
| | | is_required, |
| | | sort, |
| | | tenant_id, |
| | | create_time, |
| | | param_key, |
| | | param_name, |
| | | param_type, |
| | | param_format, |
| | | value_mode, |
| | | unit, |
| | | remark) |
| | | SELECT #{routeItemId}, |
| | | param_id, |
| | | id, |
| | | standard_value, |
| | | min_value, |
| | | max_value, |
| | | is_required, |
| | | sort, |
| | | ppp.id, |
| | | ppp.standard_value, |
| | | ppp.min_value, |
| | | ppp.max_value, |
| | | ppp.is_required, |
| | | ppp.sort, |
| | | #{tenantId}, |
| | | NOW() |
| | | FROM product_process_param |
| | | WHERE process_id = #{processId} |
| | | NOW(), |
| | | ppp.param_key, |
| | | ppp.param_name, |
| | | ppp.param_type, |
| | | ppp.param_format, |
| | | ppp.value_mode, |
| | | ppp.unit, |
| | | ppp.remark |
| | | FROM product_process_param ppp |
| | | WHERE ppp.process_id = #{processId} |
| | | </insert> |
| | | |
| | | <select id="selectParamPage" resultType="com.ruoyi.production.dto.ProcessRouteItemParamDto"> |
| | | select |
| | | prip.*, |
| | | bp.param_name, |
| | | bp.param_key, |
| | | bp.unit, |
| | | bp.param_type, |
| | | bp.param_format, |
| | | bp.value_mode |
| | | prip.* |
| | | from process_route_item_param prip |
| | | left join base_param bp on prip.param_id = bp.id |
| | | <where> |
| | | <if test="p.routeItemId != null"> |
| | | and prip.route_item_id = #{p.routeItemId} |
| | |
| | | </resultMap> |
| | | |
| | | <select id="pageProductOrder" resultType="com.ruoyi.production.dto.ProductOrderDto"> |
| | | select po.*, |
| | | ppr.process_route_code, |
| | | ROUND(po.complete_quantity / po.quantity * 100, 2) AS completionStatus |
| | | from product_order po |
| | | left join product_process_route ppr on po.id = ppr.product_order_id |
| | | SELECT |
| | | po.id, |
| | | po.nps_no, |
| | | po.tenant_id, |
| | | po.create_time, |
| | | po.update_time, |
| | | po.route_id, |
| | | po.quantity, |
| | | po.complete_quantity, |
| | | po.start_time, |
| | | po.end_time, |
| | | po.plan_complete_time, |
| | | po.status, |
| | | pm.product_name, |
| | | po.strength AS strength, |
| | | pr.process_route_code AS processRouteCode, |
| | | pr.description, |
| | | pb.id AS bomId, |
| | | pb.bom_no AS bomNo, |
| | | ROUND(po.complete_quantity / po.quantity * 100, 2) AS completionStatus, |
| | | pms.model, |
| | | pms.material_code AS materialCode |
| | | FROM product_order po |
| | | LEFT JOIN process_route pr ON po.route_id = pr.id |
| | | LEFT JOIN product_bom pb ON pr.bom_id = pb.id |
| | | LEFT JOIN product_order_plan pop ON po.id = pop.product_order_id |
| | | LEFT JOIN production_plan pp ON pop.production_plan_id = pp.id |
| | | LEFT JOIN product_material_sku pms ON pms.id = pp.product_material_sku_id |
| | | LEFT JOIN product_material pm ON pm.id = pms.product_id |
| | | <where> |
| | | <if test="c.npsNo != null and c.npsNo != ''"> |
| | | and po.nps_no like concat('%',#{c.npsNo},'%') |
| | | </if> |
| | | <if test="c.customerName != null and c.customerName != ''"> |
| | | and sl.customer_name like concat('%',#{c.customerName},'%') |
| | | AND po.nps_no LIKE CONCAT('%', #{c.npsNo}, '%') |
| | | </if> |
| | | <if test="c.startTime != null and c.endTime != null"> |
| | | and po.create_time between #{c.startTime} and #{c.endTime} |
| | | AND po.create_time BETWEEN #{c.startTime} AND #{c.endTime} |
| | | </if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="listProcessRoute" resultType="com.ruoyi.production.pojo.ProcessRoute"> |
| | | select pr.* |
| | | from process_route pr |
| | |
| | | ps.unit_quantity * po.quantity as demandedQuantity, |
| | | ps.unit, |
| | | p.product_name, |
| | | pp.name as process_name, |
| | | pp.name as process_name, |
| | | pm.product_id, |
| | | pm.model |
| | | from |
| | | product_structure ps |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | left join product_process_route ppr on ps.bom_id = ppr.bom_id |
| | | left join product_order po on po.id = ppr.product_order_id |
| | | from product_structure ps |
| | | left join product_model pm on ps.product_model_id = pm.id |
| | | left join product p on pm.product_id = p.id |
| | | left join product_process pp on ps.process_id = pp.id |
| | | left join product_process_route ppr on ps.bom_id = ppr.bom_id |
| | | left join product_order po on po.id = ppr.product_order_id |
| | | where ppr.product_order_id = #{orderId} |
| | | order by ps.id |
| | | </select> |
| | | |
| | | |
| | | <select id="countCreated" resultType="java.lang.Integer"> |
| | | SELECT count(1) FROM product_order |
| | | WHERE create_time >= #{startDate} AND create_time <= #{endDate} |
| | | SELECT count(1) |
| | | FROM product_order |
| | | WHERE create_time >= #{startDate} |
| | | AND create_time <= #{endDate} |
| | | </select> |
| | | |
| | | <select id="countCompleted" resultType="java.lang.Integer"> |
| | | SELECT count(1) FROM product_order |
| | | WHERE end_time >= #{startDate} AND end_time <= #{endDate} |
| | | SELECT count(1) |
| | | FROM product_order |
| | | WHERE end_time >= #{startDate} |
| | | AND end_time <= #{endDate} |
| | | AND complete_quantity >= quantity |
| | | </select> |
| | | |
| | | <select id="countPending" resultType="java.lang.Integer"> |
| | | SELECT count(1) FROM product_order |
| | | WHERE create_time >= #{startDate} AND create_time <= #{endDate} |
| | | SELECT count(1) |
| | | FROM product_order |
| | | WHERE create_time >= #{startDate} |
| | | AND create_time <= #{endDate} |
| | | AND complete_quantity < quantity |
| | | </select> |
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | <?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.ProductProcessParamMapper"> |
| | | |
| | | <resultMap id="ProductProcessParamResult" type="com.ruoyi.production.pojo.ProductProcessParam"> |
| | | <id property="id" column="id"/> |
| | | <result property="processId" column="process_id"/> |
| | | <result property="paramId" column="param_id"/> |
| | | <result property="paramKey" column="param_key"/> |
| | | <result property="paramName" column="param_name"/> |
| | | <result property="paramType" column="param_type"/> |
| | | <result property="paramFormat" column="param_format"/> |
| | | <result property="valueMode" column="value_mode"/> |
| | | <result property="unit" column="unit"/> |
| | | <result property="remark" column="remark"/> |
| | | <result property="standardValue" column="standard_value"/> |
| | | <result property="minValue" column="min_value"/> |
| | | <result property="maxValue" column="max_value"/> |
| | |
| | | |
| | | <select id="selectDtoListByProcessId" resultType="com.ruoyi.production.dto.ProductProcessParamDto" |
| | | parameterType="java.lang.Long"> |
| | | SELECT ppp.id, |
| | | ppp.process_id, |
| | | ppp.param_id, |
| | | ppp.standard_value, |
| | | ppp.min_value, |
| | | ppp.max_value, |
| | | ppp.is_required, |
| | | ppp.sort, |
| | | ppp.create_time, |
| | | ppp.update_time, |
| | | bp.param_name, |
| | | bp.param_type, |
| | | bp.param_format, |
| | | bp.value_mode, |
| | | bp.unit |
| | | FROM product_process_param ppp |
| | | LEFT JOIN base_param bp ON ppp.param_id = bp.id |
| | | WHERE ppp.process_id = #{processId} |
| | | ORDER BY ppp.sort ASC |
| | | SELECT id, |
| | | process_id, |
| | | param_key, |
| | | param_name, |
| | | param_type, |
| | | param_format, |
| | | value_mode, |
| | | unit, |
| | | remark, |
| | | standard_value, |
| | | min_value, |
| | | max_value, |
| | | is_required, |
| | | sort, |
| | | create_time, |
| | | update_time |
| | | FROM product_process_param |
| | | WHERE process_id = #{processId} |
| | | ORDER BY sort ASC |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | <?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.productionPlan.mapper.SalesDeliveryMapper"> |
| | | |
| | | <!-- éç¨æ¥è¯¢æ å°ç»æ --> |
| | | <resultMap id="BaseResultMap" type="com.ruoyi.productionPlan.pojo.SalesDelivery"> |
| | | <id column="id" property="id" /> |
| | | <result column="delivery_date" property="deliveryDate" /> |
| | | <result column="delivery_code" property="deliveryCode" /> |
| | | <result column="project_name" property="projectName" /> |
| | | <result column="delivery_place" property="deliveryPlace" /> |
| | | <result column="link_man" property="linkMan" /> |
| | | <result column="link_phone" property="linkPhone" /> |
| | | <result column="delivery_remark" property="deliveryRemark" /> |
| | | <result column="material_code" property="materialCode" /> |
| | | <result column="product_name" property="productName" /> |
| | | <result column="model" property="model" /> |
| | | <result column="volume" property="volume" /> |
| | | <result column="unit_price" property="unitPrice" /> |
| | | <result column="price" property="price" /> |
| | | <result column="product_remark" property="productRemark" /> |
| | | <result column="customer" property="customer" /> |
| | | <result column="salesman" property="salesman" /> |
| | | <result column="delivery_method" property="deliveryMethod" /> |
| | | <result column="form_instance_id" property="formInstanceId" /> |
| | | <result column="form_modified_time" property="formModifiedTime" /> |
| | | <result column="create_time" property="createTime" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |