From 7dec2c11988cd97effdc7ebf63c75420ec2d48da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 18 Jun 2024 15:32:56 +0800 Subject: [PATCH 1/7] =?UTF-8?q?optimize(ebom):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/core/exception/BaseGlobalExceptionHandle.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java b/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java index 838f590e..114ccd6d 100644 --- a/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java +++ b/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java @@ -124,8 +124,11 @@ public class BaseGlobalExceptionHandle { @ResponseBody public ResultVO handleRuntimeExceptionException(RuntimeException e) { log.error(e.getMessage(),e); - //throw new NflgBusinessException(STATE.Error, "系统错误,请联系管理员"); - return ResultVO.error("系统错误,请联系管理员"); + if (StrUtil.isNotBlank(e.getMessage()) && e.getMessage().contains("Deadlock")) { + return ResultVO.error("操作失败,请重试"); + } else { + return ResultVO.error("系统错误,请联系管理员"); + } } @ExceptionHandler(value = BadSqlGrammarException.class) From 4a2e64a657fb8e51af1a450cd226d59c38f2f7cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 18 Jun 2024 15:33:28 +0800 Subject: [PATCH 2/7] =?UTF-8?q?fix(ebom):=20=E6=B7=BB=E5=8A=A0dept=5Frow?= =?UTF-8?q?=5Fid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/master/BomNewEbomParentMapper.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml index 6bab6f5a..745f6b03 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml @@ -526,7 +526,7 @@ a.`virtrual_package_enum`, a.`exception_status`, a.`virtual_package_is`, a.`source_row_id`, a.`devise_user_code`, a.`devise_name`, a.`created_by`, a.`created_time`, a.`created_job`, a.`audit_time`, a.`audit_user_name`, a.`release_time`, a.`release_user_name`, a.`revert_time`, a.`revert_user_name`, - a.`expire_end_time`, a.`convert_to_ebom_time`, a.`remark`, a.`dept_name`,`dept_row_id`, a.`level_num`, + a.`expire_end_time`, a.`convert_to_ebom_time`, a.`remark`, a.`dept_name`,a.`dept_row_id`, a.`level_num`, a.`change_desc`, a.`notice_nums`, a.`modify_time`, a.`sap_state`, a.`sap_time` from t_bom_new_ebom_parent a left join t_bom_new_ebom_parent_formal b on a.row_id = b.row_id From 0dc234ff71def86be8824a70a5be3c4a284f4ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 18 Jun 2024 15:35:06 +0800 Subject: [PATCH 3/7] =?UTF-8?q?feat(ebom):=20=E4=BF=AE=E5=A4=8D=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E6=A3=80=E6=9F=A5=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=B8=8D?= =?UTF-8?q?=E6=98=AF=E6=A3=80=E6=9F=A5=E6=A0=B9=E8=8A=82=E7=82=B9=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=87=BA=E7=8E=B0=E9=A1=B9=E7=9B=AE=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E4=B8=BA=E7=A9=BA=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewEbomParentService.java | 18 +++++++++++++----- .../domain/EBom/CheckEBomException.java | 11 ++++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 0785aff4..0b38ee77 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -678,7 +678,7 @@ public class BomNewEbomParentService extends ServiceImpl ignoreCheckException) throws ExecutionException, InterruptedException { - CheckEBomException checkEBomException = new CheckEBomException(bomRowId); + CheckEBomException checkEBomException = new CheckEBomException(bomRowId, null); checkEBomException.initException(ignoreCheckException); //保存异常 @@ -731,7 +731,7 @@ public class BomNewEbomParentService extends ServiceImpl bomRowIds) { for (Long bomRowId : bomRowIds) { - CheckEBomException checkEBomException = new CheckEBomException(bomRowId); + CheckEBomException checkEBomException = new CheckEBomException(bomRowId, null); checkEBomException.initException(); //保存异常 @@ -765,6 +765,14 @@ public class BomNewEbomParentService extends ServiceImpl 0) { + BomNewEbomChildEntity c = SpringUtil.getBean(BomNewEbomChildService.class).getById(childRowId); + if (Objects.nonNull(c)) { + convert.setProjectType(c.getProjectType()); + convert.setNum(c.getNum()); + } + } allBomDetail.add(convert); checkWaring=true; From 13d88007ec86c578bfb1ed1c49e325ac0e5f8fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Tue, 18 Jun 2024 16:14:42 +0800 Subject: [PATCH 4/7] =?UTF-8?q?1=E3=80=81=E8=BD=ACpbom=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/service/domain/EBom/EBomToPbomBase.java | 2 +- .../main/resources/mapper/master/BomNewEbomParentMapper.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java index 488667f4..a74a031b 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java @@ -174,7 +174,7 @@ public abstract class EBomToPbomBase { return null; } else { //pbom-处于正式表 - String bomVersion= VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>=0?parentVo.getCurrentVersion():VersionUtil.getNextVersion(oldParent.getCurrentVersion()); + String bomVersion= VersionUtil.compare(parentVo.getCurrentVersion(),oldParent.getCurrentVersion())>0?parentVo.getCurrentVersion():VersionUtil.getNextVersion(oldParent.getCurrentVersion()); return buildParentEntity(parentVo, facCode, oldParent,bomVersion); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml index e33fb42e..296d7707 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomParentMapper.xml @@ -511,8 +511,8 @@ - INSERT INTO `t_bom_new_ebom_parent_formal` (`row_id`, `batch_no`, `drawing_no`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_original_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `source`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtrual_package_enum`, `exception_status`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `created_job`, `audit_time`, `audit_user_name`, `release_time`, `release_user_name`, `revert_time`, `revert_user_name`, `expire_end_time`, `convert_to_ebom_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `sap_state`, `sap_time`) - select a.`row_id`, a.`batch_no`, a.`drawing_no`, a.`material_no`, a.`order_number`, a.`material_name`, a.`material_desc`, a.`material_texture`, a.`material_unit`, a.`material_original_unit`, a.`unit_weight`, a.`total_weight`, a.`current_version`, a.`num`, a.`source`, a.`root_is`, a.`should_bom_exist`, a.`super_material_status`, a.`bom_exist`, a.`last_version_is`, a.`edit_status`, a.`status`, a.`user_root_is`, a.`virtrual_package_enum`, a.`exception_status`, a.`virtual_package_is`, a.`source_row_id`, a.`devise_user_code`, a.`devise_name`, a.`created_by`, a.`created_time`, a.`created_job`, a.`audit_time`, a.`audit_user_name`, a.`release_time`, a.`release_user_name`, a.`revert_time`, a.`revert_user_name`, a.`expire_end_time`, a.`convert_to_ebom_time`, a.`remark`, a.`dept_name`, a.`level_num`, a.`change_desc`, a.`notice_nums`, a.`modify_time`, a.`sap_state`, a.`sap_time` + INSERT INTO `t_bom_new_ebom_parent_formal` (`row_id`, `batch_no`, `drawing_no`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `material_original_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `source`, `root_is`, `should_bom_exist`, `super_material_status`, `bom_exist`, `last_version_is`, `edit_status`, `status`, `user_root_is`, `virtrual_package_enum`, `exception_status`, `virtual_package_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `created_job`, `audit_time`, `audit_user_name`, `release_time`, `release_user_name`, `revert_time`, `revert_user_name`, `expire_end_time`, `convert_to_ebom_time`, `remark`, `dept_name`,`dept_row_id`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `sap_state`, `sap_time`) + select a.`row_id`, a.`batch_no`, a.`drawing_no`, a.`material_no`, a.`order_number`, a.`material_name`, a.`material_desc`, a.`material_texture`, a.`material_unit`, a.`material_original_unit`, a.`unit_weight`, a.`total_weight`, a.`current_version`, a.`num`, a.`source`, a.`root_is`, a.`should_bom_exist`, a.`super_material_status`, a.`bom_exist`, a.`last_version_is`, a.`edit_status`, a.`status`, a.`user_root_is`, a.`virtrual_package_enum`, a.`exception_status`, a.`virtual_package_is`, a.`source_row_id`, a.`devise_user_code`, a.`devise_name`, a.`created_by`, a.`created_time`, a.`created_job`, a.`audit_time`, a.`audit_user_name`, a.`release_time`, a.`release_user_name`, a.`revert_time`, a.`revert_user_name`, a.`expire_end_time`, a.`convert_to_ebom_time`, a.`remark`, a.`dept_row_id`, a.`dept_name`, a.`level_num`, a.`change_desc`, a.`notice_nums`, a.`modify_time`, a.`sap_state`, a.`sap_time` from t_bom_new_ebom_parent a left join t_bom_new_ebom_parent_formal b on a.row_id = b.row_id where a.row_id in From f4846bdc0767c9d2e715f21bbcfcc20fabef323f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Wed, 19 Jun 2024 13:35:36 +0800 Subject: [PATCH 5/7] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=94=99=E8=AF=AF=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E5=8F=8B=E5=A5=BD=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/core/exception/BaseGlobalExceptionHandle.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java b/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java index 114ccd6d..4c9faccc 100644 --- a/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java +++ b/nflg_project_dev/nflg-boot-base/nflg-boot-core/src/main/java/com/nflg/product/base/core/exception/BaseGlobalExceptionHandle.java @@ -1,6 +1,7 @@ package com.nflg.product.base.core.exception; import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.databind.exc.InvalidFormatException; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; @@ -167,4 +168,12 @@ public class BaseGlobalExceptionHandle { //return ResultVO.error(e.getState(), e.getMessage()); return ResultVO.error(e.getState(), e.getMessage(), e.getData()); } + + @ExceptionHandler(value = InvalidFormatException.class) + @ResponseBody + public ResultVO handleInvalidFormatException(ErrorMsgException e) { + log.error(e.getMessage(), e); + //return ResultVO.error(e.getState(), e.getMessage()); + return ResultVO.error(STATE.ParamErr, "数据格式错误,请修改后再提交: " + e.getMessage()); + } } From d5f948916b6d6378be7d4600da022aa5b168f818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Wed, 19 Jun 2024 13:35:58 +0800 Subject: [PATCH 6/7] =?UTF-8?q?optimize:=20=E4=BC=98=E5=8C=96http=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E5=92=8C=E5=93=8D=E5=BA=94=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../advice/LoggingRequestBodyAdvice.java | 41 +++++++++++++++---- .../advice/LoggingResponseBodyAdvice.java | 6 ++- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingRequestBodyAdvice.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingRequestBodyAdvice.java index a414ef07..62254e4a 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingRequestBodyAdvice.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingRequestBodyAdvice.java @@ -9,12 +9,16 @@ import nflg.product.common.vo.ResultVO; import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.core.MethodParameter; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpInputMessage; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice; +import java.io.*; import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.stream.Collectors; /** * @author 曹鹏飞 @@ -35,13 +39,16 @@ public class LoggingRequestBodyAdvice implements RequestBodyAdvice { @Override public HttpInputMessage beforeBodyRead(HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class> aClass) { - return httpInputMessage; - } - - @Override - public Object afterBodyRead(Object o, HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class> aClass) { try { - log.info("请求参数: {}", JsonUtil.toJson(o)); + String contentType = httpInputMessage.getHeaders().getFirst("Content-Type"); + if (StrUtil.containsIgnoreCase(contentType, "multipart")) { + return httpInputMessage; + } + String bodyContent; + try (BufferedReader reader = new BufferedReader(new InputStreamReader(httpInputMessage.getBody(), StandardCharsets.UTF_8))) { + bodyContent = reader.lines().collect(Collectors.joining()); + log.info("请求参数: {}", bodyContent); + } log.info("请求头: {}", JsonUtil.toJson(httpInputMessage.getHeaders())); String token = httpInputMessage.getHeaders().getFirst("Authorization"); if (StrUtil.isNotBlank(token)) { @@ -50,9 +57,29 @@ public class LoggingRequestBodyAdvice implements RequestBodyAdvice { log.info("请求用户: {}", JsonUtil.toJson(result.getData())); } } + if (StrUtil.isBlank(bodyContent)) { + return httpInputMessage; + } else { + return new HttpInputMessage() { + @Override + public InputStream getBody() throws IOException { + return new ByteArrayInputStream(bodyContent.getBytes()); + } + + @Override + public HttpHeaders getHeaders() { + return httpInputMessage.getHeaders(); + } + }; + } } catch (Exception ex) { - log.error("读取请求体出错", ex); + log.error("读取请求数据出错", ex); + return httpInputMessage; } + } + + @Override + public Object afterBodyRead(Object o, HttpInputMessage httpInputMessage, MethodParameter methodParameter, Type type, Class> aClass) { return o; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingResponseBodyAdvice.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingResponseBodyAdvice.java index 1fc4e76f..6c4de379 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingResponseBodyAdvice.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/advice/LoggingResponseBodyAdvice.java @@ -1,5 +1,6 @@ package com.nflg.product.bomnew.advice; +import cn.hutool.core.util.StrUtil; import com.nflg.product.bomnew.util.JsonUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -32,7 +33,10 @@ public class LoggingResponseBodyAdvice implements ResponseBodyAdvice { @Override public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class> aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) { try { - log.info("响应数据: {}", JsonUtil.toJson(o)); + String contentType = serverHttpResponse.getHeaders().getFirst("Content-Type"); + if (!StrUtil.containsIgnoreCase(contentType, "octet-stream")) { + log.info("响应数据: {}", JsonUtil.toJson(o)); + } } catch (Exception ex) { log.error("读取响应数据出错", ex); } From 47d2f01e50a2becfe9e06de9fa8524d84b95b23e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=B1=B3?= <470431449@qq.com> Date: Wed, 19 Jun 2024 16:15:47 +0800 Subject: [PATCH 7/7] =?UTF-8?q?1=E3=80=81=E6=98=A8=E5=A4=A9=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ewEbomVirtualPackageCompositionMapper.java | 5 ++ .../service/BomNewEbomParentService.java | 10 ++- .../service/domain/EBom/EBomToPbomBase.java | 86 +++++++++++++++---- ...NewEbomVirtualPackageCompositionMapper.xml | 8 ++ 4 files changed, 91 insertions(+), 18 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomVirtualPackageCompositionMapper.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomVirtualPackageCompositionMapper.java index f3d8ae1b..06de2764 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomVirtualPackageCompositionMapper.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/mapper/master/BomNewEbomVirtualPackageCompositionMapper.java @@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.nflg.product.bomnew.pojo.entity.BomNewEbomVirtualPackageCompositionEntity; import org.apache.ibatis.annotations.Param; +import java.util.Collection; +import java.util.List; + /** * t_bom_new_ebom_virtual_package_composition 表数据库访问层 * @@ -14,4 +17,6 @@ import org.apache.ibatis.annotations.Param; public interface BomNewEbomVirtualPackageCompositionMapper extends BaseMapper { void delByVnoAndParentNo(@Param("virtualPackageMaterialNo")String virtualPackageMaterialNo, @Param("parentMaterialNo")String parentMaterialNo); + + void batchDelByVMaterialNos(@Param("virtualMaterialNos") Collection virtualMaterialNos); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 0b38ee77..31c798ed 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -16,6 +16,7 @@ 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.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import com.mzt.logapi.context.LogRecordContext; import com.nflg.product.base.core.conmon.util.SessionUtil; @@ -912,6 +913,13 @@ public class BomNewEbomParentService extends ServiceImpl vMaterialNos = eBomToPBom.getVirtualPackageCompositionResult().stream().map(u -> u.getVirtualPackageMaterialNo()).collect(Collectors.toSet()); + virtualPackageCompositionService.getBaseMapper().batchDelByVMaterialNos(vMaterialNos); + virtualPackageCompositionService.saveBatch(eBomToPBom.getVirtualPackageCompositionResult()); + } + //删除EBOM中和正式表BOM一致的数据 List delEBomParents = bomTree.stream().filter(u -> u.getHasChangeState().equals(1)).collect(Collectors.toList()); if(CollUtil.isNotEmpty(delEBomParents)){ @@ -945,7 +953,7 @@ public class BomNewEbomParentService extends ServiceImpl!EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).collect(Collectors.toList()) ); + eBomToFormal(bomRowIds, bomTree.stream().filter(u ->!u.getHasChangeState().equals(1) && !EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).collect(Collectors.toList()) ); } //子级记录-bom版本 List bomChildren = new ArrayList<>(); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java index a74a031b..34286a64 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomToPbomBase.java @@ -2,12 +2,14 @@ package com.nflg.product.bomnew.service.domain.EBom; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateTime; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; import com.alibaba.excel.enums.BooleanEnum; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.*; @@ -26,6 +28,7 @@ import java.math.BigDecimal; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; public abstract class EBomToPbomBase { @@ -42,6 +45,8 @@ public abstract class EBomToPbomBase { protected List result = new ArrayList<>(); + protected BomNewEbomVirtualPackageCompositionService virtualPackageCompositionService=SpringUtil.getBean(BomNewEbomVirtualPackageCompositionService.class); + @Getter protected List pBomParentResult = new ArrayList<>(); @@ -163,6 +168,7 @@ public abstract class EBomToPbomBase { SpringUtil.getBean(BomNewPbomChildService.class).getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id", oldParent.getRowId())); oldParent.setCurrentVersion(parentVo.getCurrentVersion()); oldParent.setSourceRowId(parentVo.getRowId()); + oldParent.setCreatedTime(LocalDateTime.now()); this.pBomParentResult.add(oldParent); return oldParent; } @@ -192,6 +198,7 @@ public abstract class EBomToPbomBase { pBomParent.setTechnologyUserCode(SessionUtil.getUserCode()); pBomParent.setTechnologyUserName(SessionUtil.getRealName()); pBomParent.setDeptRowId(SessionUtil.getDepartRowId()); + pBomParent.setCreatedTime(LocalDateTime.now()); //版本=EBom版本 pBomParent.setCurrentVersion(bomVersion); pBomParent.setEditStatus(PBomEditStatusEnum.HANDLER_CREATED.getValue()); @@ -227,10 +234,6 @@ public abstract class EBomToPbomBase { vo.setParentRowId(lastVirtualPackage.getBomRowId()); result.add(vo); } - //当没找到直发包时,丢弃 -// else { -// // buildUpgradeChange(vo); -// } continue; } if (StrUtil.isNotBlank(vo.getProjectType()) && vo.getProjectType().equals(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey())) { @@ -242,9 +245,6 @@ public abstract class EBomToPbomBase { vo.setParentRowId(lastVirtualPackage.getBomRowId()); result.add(vo); } -// else { //当没找到直发包时,丢弃 -// // buildUpgradeChange(vo); -// } continue; } result.add(vo); @@ -332,36 +332,38 @@ public abstract class EBomToPbomBase { private void liftingLayerSummary(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) { BigDecimal sum = vo.getNum(); String parentLevelNo = BomLevelUtil.getParentLevelNo(vo.getLevelNo()); - List parentFullPathNum = new ArrayList<>(); + while (parentLevelNo.length() >= lastVirtualPackage.getLevelNo().length()) { String pNo = parentLevelNo; List parentList = allBomDetail.stream().filter(u -> u.getLevelNo().equals(pNo)).collect(Collectors.toList()); if (CollUtil.isNotEmpty(parentList)) { sum = NumberUtil.mul(sum, parentList.get(0).getNum()); - parentFullPathNum.add(parentList.get(0).getNum()); + + //构建虚拟包组成 + buildVirtualPackageComposition(lastVirtualPackage, vo); } -// else { -// parentFullPathNum.add(parentList.get(0).getNum()); -// } parentLevelNo = BomLevelUtil.getParentLevelNo(parentLevelNo); } vo.setNum(sum); - //构建虚拟包组成 - buildVirtualPackageComposition(lastVirtualPackage, vo, parentFullPathNum); + } - private void buildVirtualPackageComposition(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo, List parentFullPathNum) { + /** + * 构建虚拟包组成 + * @param lastVirtualPackage + * @param vo + */ + private void buildVirtualPackageComposition(BomNewEbomParentVO lastVirtualPackage, BomNewEbomParentVO vo) { BomNewEbomVirtualPackageCompositionEntity packageCompositionEntity = new BomNewEbomVirtualPackageCompositionEntity(); packageCompositionEntity.setRowId(IdWorker.getId()); packageCompositionEntity.setVirtualPackageMaterialNo(lastVirtualPackage.getMaterialNo()); List voParent = allBomDetail.stream().filter(u -> u.getBomRowId().equals(vo.getParentRowId())).collect(Collectors.toList()); - VUtils.isTure(CollUtil.isEmpty(voParent)).throwMessage(vo.getMaterialNo() + " 未找到父级"); packageCompositionEntity.setParentMaterialNo(voParent.get(0).getMaterialNo()); packageCompositionEntity.setChildMaterialNo(vo.getMaterialNo()); - packageCompositionEntity.setParentFullPathNum(StrUtil.join(",", parentFullPathNum)); + packageCompositionEntity.setNum(vo.getNum()); packageCompositionEntity.setProjectType(vo.getProjectType()); packageCompositionEntity.setUnitWeight(vo.getUnitWeight()); packageCompositionEntity.setTotalWeight(vo.getTotalWeight()); @@ -369,6 +371,46 @@ public abstract class EBomToPbomBase { this.virtualPackageCompositionResult.add(packageCompositionEntity); } + /** + * 变更影响 + */ + protected void changeImpact(){ + Set vmaterialNo = allBomDetail.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.equalsValue(u.getVirtualPartType()) || VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.equalsValue(u.getVirtualPartType())).map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + List firstParent = allBomDetail.stream().filter(u -> u.getParentRowId().equals(parent.getRowId())).collect(Collectors.toList()); + for (BomNewEbomParentVO vo : firstParent) { + changeImpactDo(vo); + } + + + } + + private void changeImpactDo(BomNewEbomParentVO parentVO){ + List subVos = allBomDetail.stream().filter(u -> u.getLevelNumber().compareTo(parentVO.getLevelNumber()) >= 0 && u.getLevelNumber().compareTo(NumberUtil.add(parentVO.getLevelNumber(), BigDecimal.valueOf(0.01))) < 0) + .sorted(Comparator.comparing(BomNewEbomParentVO::getLevelNumber)).collect(Collectors.toList()); + for (BomNewEbomParentVO vo : subVos) { + + } + } + + private Boolean compareVirtualPackage(BomNewEbomParentVO vo) { + List impactVm = virtualPackageCompositionService.lambdaQuery().eq(BomNewEbomVirtualPackageCompositionEntity::getParentMaterialNo, vo.getMaterialNo()).list(); + if(CollUtil.isNotEmpty(impactVm)){ + List childList = allBomDetail.stream().filter(u -> u.getParentRowId().equals(vo.getBomRowId())).collect(Collectors.toList()); + Map impactVmMp = impactVm.stream().collect(Collectors.toMap(v -> v.getChildMaterialNo(), v -> v, (v1, v2) -> v1)); + //对比F项 + List impactVmF = impactVm.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).collect(Collectors.toList()); + + List childListF = childList.stream().filter(u -> VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(u.getProjectType())).collect(Collectors.toList()); + if(impactVmF.size()!=impactVmF.size()){ + return true; + } + for (BomNewEbomParentVO child : childList) { +// if(impactVmMp.containsKey()); + } + } + return false; + } + private String getParentMaterialNo(Long parentRowId) { List collect = allBomDetail.stream().filter(u -> u.getBomRowId().equals(parentRowId)).collect(Collectors.toList()); if (CollUtil.isNotEmpty(collect)) { @@ -527,6 +569,16 @@ public abstract class EBomToPbomBase { parentBom.setCurrentVersion(VersionUtil.getNextVersion(oldEBom.getCurrentVersion())); parentBom.setHasChangeState(2); } + + //如子级都为F 项父级也不转 + Set projectSet = newParentChild.stream().map(u -> u.getProjectType().toUpperCase()).collect(Collectors.toSet()); + if(CollUtil.isNotEmpty(projectSet)){ + if(!VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && !VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getProductTypeKey().equals(parentBom.getVirtualPartType()) && + (ImmutableSet.of("F").equals(projectSet) || ImmutableSet.of("F","Z").equals(projectSet)|| ImmutableSet.of("Z").equals(projectSet))){ + parentBom.setNoConvertToPBomIs(1); + } + } + } } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomVirtualPackageCompositionMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomVirtualPackageCompositionMapper.xml index 8e3950ad..9bdb7b93 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomVirtualPackageCompositionMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewEbomVirtualPackageCompositionMapper.xml @@ -27,4 +27,12 @@ where virtual_package_material_no=#{virtualPackageMaterialNo} and parent_material_no=#{parentMaterialNo} + + + delete from t_bom_new_ebom_virtual_package_composition + where virtual_package_material_no in + + #{item} + +