From 08fc06ee98a00e3eda4ceda8eff4e974fec41825 Mon Sep 17 00:00:00 2001 From: jing's Date: Wed, 13 Mar 2024 17:47:01 +0800 Subject: [PATCH 1/9] 11 --- .../bomnew/service/domain/EBom/EBomEdit.java | 70 ++++++++++++++++--- 1 file changed, 59 insertions(+), 11 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java index 6101852d..f36a7619 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java @@ -8,9 +8,11 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.google.common.collect.Sets; import com.nflg.product.base.core.conmon.util.SessionUtil; +import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO; import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; @@ -20,6 +22,8 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.service.UserRoleService; import com.nflg.product.bomnew.util.VUtils; +import nflg.product.common.constant.STATE; +import org.ttzero.excel.reader.Col; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -36,6 +40,9 @@ public class EBomEdit { public EBomEdit(Integer source) { this.source = source; + + parentEntities = new ArrayList<>(); + childEntities = new ArrayList<>(); } BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) { @@ -47,12 +54,7 @@ public class EBomEdit { String batchNo = IdUtil.simpleUUID(); parent.setRowId(IdWorker.getId()); parent.setBatchNo(batchNo); -// parent.setDrawingNo(material.getDrawingNo()); -// parent.setMaterialNo(material.getMaterialNo()); -// parent.setMaterialName(material.getMaterialName()); -// parent.setMaterialDesc(material.getMaterialDesc()); -// parent.setMaterialTexture(material.getMaterial()); - // parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum()); + parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum())); parent.setDeviseUserCode(SessionUtil.getUserCode()); @@ -67,9 +69,7 @@ public class EBomEdit { parent.setLastVersionIs(1); parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); -// if(StrUtil.isEmpty(parent.getProjectType())){ -// parent.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); -// } + parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician() ? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue()); parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); @@ -79,6 +79,34 @@ public class EBomEdit { } + void createBom(BomNewEBomParentEditDTO createDTO){ + + List materialNos = createDTO.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + materialNos.add(createDTO.getParent().getMaterialNo()); + //检查物料编码是否在主数据中存在 + List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); + List effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + Set difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos)); + VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在"); + + + List existBomlist =SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, createDTO.getParent().getMaterialNo()).list(); + + QueryWrapper + + VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage("该物料已存在BOM"); + + + + + } + + + + + + + private void checkExcept(BomNewEbomParentVO parent, BomNewEbomChildEntity child) { if (StrUtil.isBlank(child.getMaterialNo()) || Objects.isNull(child.getNum()) @@ -99,14 +127,34 @@ public class EBomEdit { } + void checkDataRule(BomNewEBomParentEditDTO dto){ + if(dto.getParent()==null){ + throw new NflgBusinessException(STATE.Error,"parent 数据不能为空"); + } + + if(CollUtil.isEmpty(dto.getDatas())){ + throw new NflgBusinessException(STATE.Error,"datas 数据不能为空"); + } + + } + + public void temporary(BomNewEBomParentEditDTO dto) { - parentEntities = new ArrayList<>(); - childEntities = new ArrayList<>(); + checkDataRule(dto); List roleList = SpringUtil.getBean(UserRoleService.class).getUserPost(); //添加数据 + if(dto.getParent().getRowId()==null){ + + + + } + + + + if (dto.getParent() == null) { for (BomNewEbomParentVO vo : dto.getDatas()) { From fa7435e95b6ada76179f9b495f1eeaa163f53a61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 14 Mar 2024 09:36:00 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E5=8C=85=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/nflg/product/material/pojo/vo/AdSyncSetInfoVO.java | 1 - .../nflg/product/material/pojo/vo/ExcelDictionariesApiVO.java | 1 - 2 files changed, 2 deletions(-) diff --git a/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/AdSyncSetInfoVO.java b/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/AdSyncSetInfoVO.java index fe12ca6f..7edc5b1d 100644 --- a/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/AdSyncSetInfoVO.java +++ b/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/AdSyncSetInfoVO.java @@ -1,6 +1,5 @@ package com.nflg.product.material.pojo.vo; -import jdk.nashorn.internal.objects.annotations.Constructor; import lombok.Data; /** diff --git a/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/ExcelDictionariesApiVO.java b/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/ExcelDictionariesApiVO.java index 3588c8d5..44715a6f 100644 --- a/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/ExcelDictionariesApiVO.java +++ b/nflg_project_dev/material/src/main/java/com/nflg/product/material/pojo/vo/ExcelDictionariesApiVO.java @@ -1,6 +1,5 @@ package com.nflg.product.material.pojo.vo; -import jdk.nashorn.internal.objects.annotations.Constructor; import lombok.AllArgsConstructor; import lombok.Data; import org.ttzero.excel.annotation.ExcelColumn; From f92ac3be80586e25faa7832bfabcf39f9d75aee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 14 Mar 2024 09:37:45 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=B6=E8=BF=94=E5=9B=9E=E7=9A=84=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=98=AF404=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/BaseGlobalExceptionHandle.java | 82 ++++++++++++------- 1 file changed, 52 insertions(+), 30 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 d773176d..80b0fa39 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,17 +1,18 @@ package com.nflg.product.base.core.exception; -import cn.hutool.core.util.StrUtil; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DuplicateKeyException; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.multipart.MaxUploadSizeExceededException; import org.springframework.web.servlet.NoHandlerFoundException; @@ -33,31 +34,35 @@ public class BaseGlobalExceptionHandle { */ @ExceptionHandler(value = NflgBusinessException.class) @ResponseBody - public ResultVO handleJeecgBootException(NflgBusinessException e) { - return ResultVO.error(e.getState(), e.getMessage()); - + public ResponseEntity> handleJeecgBootException(NflgBusinessException e) { + log.error(e.getMessage(), e); + //return ResultVO.error(e.getState(), e.getMessage()); + return errorResult(e.getState(),e.getMessage()); } @ExceptionHandler(value = NoHandlerFoundException.class) @ResponseBody - public ResultVO handlerNoFoundException(NoHandlerFoundException e) { + public ResponseEntity> handlerNoFoundException(NoHandlerFoundException e) { log.error(e.getMessage(), e); - return ResultVO.error(404, "路径不存在,请检查路径是否正确"); + //return ResultVO.error(404, "路径不存在,请检查路径是否正确"); + return errorResult(STATE.AddressNotFound,"路径不存在,请检查路径是否正确"); } @ExceptionHandler(value = DuplicateKeyException.class) @ResponseBody - public ResultVO handleDuplicateKeyException(DuplicateKeyException e) { + public ResponseEntity> handleDuplicateKeyException(DuplicateKeyException e) { log.error(e.getMessage(), e); - return ResultVO.error("已存在该记录,请勿重复操作"); + //return ResultVO.error("已存在该记录,请勿重复操作"); + return errorResult("已存在该记录,请勿重复操作"); } @ExceptionHandler(value = Exception.class) @ResponseBody - public ResultVO handleException(Exception e) { + public ResponseEntity> handleException(Exception e) { log.error(e.getMessage(), e); - return ResultVO.error("操作失败,请联系系统管理员"); + //return ResultVO.error("操作失败,请联系系统管理员"); + return errorResult("操作失败,请联系系统管理员"); } /** @@ -67,8 +72,9 @@ public class BaseGlobalExceptionHandle { */ @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) @ResponseBody - public ResultVO HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { - StringBuffer sb = new StringBuffer(); + public ResponseEntity> HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { + log.error(e.getMessage(), e); + StringBuilder sb = new StringBuilder(); sb.append("不支持"); sb.append(e.getMethod()); sb.append("请求方法,"); @@ -81,8 +87,8 @@ public class BaseGlobalExceptionHandle { } } log.error(sb.toString(), e); - return ResultVO.error(STATE.PermissionDenied, "登录已过期,请重新登录"); -// return ResultVO.error(STATE.PermissionDenied, sb.toString()); + //return ResultVO.error(STATE.PermissionDenied, "登录已过期,请重新登录"); + return errorResult(STATE.PermissionDenied,"不支持的请求方法:"+e.getMethod()); } /** @@ -90,53 +96,69 @@ public class BaseGlobalExceptionHandle { */ @ExceptionHandler(value = MaxUploadSizeExceededException.class) @ResponseBody - public ResultVO handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) { + public ResponseEntity> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) { log.error(e.getMessage(), e); - return ResultVO.error("文件大小超出10MB限制, 请压缩或降低文件质量! "); + //return ResultVO.error("文件大小超出10MB限制, 请压缩或降低文件质量! "); + return errorResult("文件大小超出10MB限制, 请压缩或降低文件质量! "); } @ExceptionHandler(value = DataIntegrityViolationException.class) @ResponseBody - public ResultVO handleDataIntegrityViolationException(DataIntegrityViolationException e) { + public ResponseEntity> handleDataIntegrityViolationException(DataIntegrityViolationException e) { log.error(e.getMessage(), e); - return ResultVO.error("字段太长,超出数据库字段的长度"); +// return ResultVO.error("字段太长,超出数据库字段的长度"); + return errorResult("字段太长,超出数据库字段的长度"); } @ExceptionHandler(value = SQLException.class) @ResponseBody - public ResultVO handleSQLException(SQLException e) { + public ResponseEntity> handleSQLException(SQLException e) { log.error(e.getMessage(),e); - return ResultVO.error("sql执行过程出现错误"); + //return ResultVO.error("sql执行过程出现错误"); + return errorResult("sql执行过程出现错误"); } @ExceptionHandler(value = RuntimeException.class) @ResponseBody - public ResultVO handleRuntimeExceptionException(RuntimeException e) { + public ResponseEntity> handleRuntimeExceptionException(RuntimeException e) { log.error(e.getMessage(),e); - throw new NflgBusinessException(STATE.Error, "系统错误,请联系管理员"); + //throw new NflgBusinessException(STATE.Error, "系统错误,请联系管理员"); + return errorResult("系统错误,请联系管理员"); } @ExceptionHandler(value = BadSqlGrammarException.class) @ResponseBody - public ResultVO handleDataAccessException(BadSqlGrammarException e) { + public ResponseEntity> handleDataAccessException(BadSqlGrammarException e) { log.error(e.getMessage(),e); - throw new NflgBusinessException(STATE.Error, "sql 语法错误,系统错误,请联系管理员"); + //throw new NflgBusinessException(STATE.Error, "sql 语法错误,系统错误,请联系管理员"); + return errorResult("sql 语法错误,系统错误,请联系管理员"); } @ExceptionHandler(value = MethodArgumentNotValidException.class) @ResponseBody - public ResultVO handleMethodArgumentException(MethodArgumentNotValidException e){ + public ResponseEntity> handleMethodArgumentException(MethodArgumentNotValidException e){ log.error(e.getMessage(),e); - return ResultVO.error(e.getBindingResult().getFieldError().getDefaultMessage()) ; + return errorResult(e.getBindingResult().getFieldError().getDefaultMessage()) ; } @ExceptionHandler(NullPointerException.class) - public ResultVO handleNullPointerException(NullPointerException ex) { - - return ResultVO.error(STATE.Error, "系统错误,请联系管理员:"+ex.getMessage()) ; + public ResponseEntity> handleNullPointerException(NullPointerException ex) { + log.error(ex.getMessage(),ex); + return errorResult(STATE.Error, "系统错误,请联系管理员:"+ex.getMessage()) ; } + @ExceptionHandler(MissingServletRequestParameterException.class) + public ResponseEntity> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex) { + log.error(ex.getMessage(),ex); + return errorResult(STATE.ParamErr, ex.getParameterName()+"参数不能为空"); + } + private static ResponseEntity> errorResult(String msg) { + return ResponseEntity.status(HttpStatus.OK).body(ResultVO.error(STATE.Error,msg)); + } + private static ResponseEntity> errorResult(STATE code,String msg) { + return ResponseEntity.status(HttpStatus.OK).body(ResultVO.error(code,msg)); + } } From f859141de89611daeedac091ea51986c3d34b9e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 14 Mar 2024 11:23:57 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E6=97=B6=E8=BF=94=E5=9B=9E=E7=9A=84=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E6=98=AF404=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exception/BaseGlobalExceptionHandle.java | 65 ++++++++----------- 1 file changed, 28 insertions(+), 37 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 80b0fa39..8348eea3 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 @@ -5,8 +5,6 @@ import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DuplicateKeyException; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.web.HttpRequestMethodNotSupportedException; import org.springframework.web.bind.MethodArgumentNotValidException; @@ -34,35 +32,35 @@ public class BaseGlobalExceptionHandle { */ @ExceptionHandler(value = NflgBusinessException.class) @ResponseBody - public ResponseEntity> handleJeecgBootException(NflgBusinessException e) { + public ResultVO handleJeecgBootException(NflgBusinessException e) { log.error(e.getMessage(), e); //return ResultVO.error(e.getState(), e.getMessage()); - return errorResult(e.getState(),e.getMessage()); + return ResultVO.error(e.getState(),e.getMessage()); } @ExceptionHandler(value = NoHandlerFoundException.class) @ResponseBody - public ResponseEntity> handlerNoFoundException(NoHandlerFoundException e) { + public ResultVO handlerNoFoundException(NoHandlerFoundException e) { log.error(e.getMessage(), e); //return ResultVO.error(404, "路径不存在,请检查路径是否正确"); - return errorResult(STATE.AddressNotFound,"路径不存在,请检查路径是否正确"); + return ResultVO.error(STATE.AddressNotFound,"路径不存在,请检查路径是否正确"); } @ExceptionHandler(value = DuplicateKeyException.class) @ResponseBody - public ResponseEntity> handleDuplicateKeyException(DuplicateKeyException e) { + public ResultVO handleDuplicateKeyException(DuplicateKeyException e) { log.error(e.getMessage(), e); //return ResultVO.error("已存在该记录,请勿重复操作"); - return errorResult("已存在该记录,请勿重复操作"); + return ResultVO.error("已存在该记录,请勿重复操作"); } @ExceptionHandler(value = Exception.class) @ResponseBody - public ResponseEntity> handleException(Exception e) { + public ResultVO handleException(Exception e) { log.error(e.getMessage(), e); //return ResultVO.error("操作失败,请联系系统管理员"); - return errorResult("操作失败,请联系系统管理员"); + return ResultVO.error("操作失败,请联系系统管理员"); } /** @@ -72,7 +70,7 @@ public class BaseGlobalExceptionHandle { */ @ExceptionHandler(value = HttpRequestMethodNotSupportedException.class) @ResponseBody - public ResponseEntity> HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { + public ResultVO HttpRequestMethodNotSupportedException(HttpRequestMethodNotSupportedException e) { log.error(e.getMessage(), e); StringBuilder sb = new StringBuilder(); sb.append("不支持"); @@ -88,7 +86,7 @@ public class BaseGlobalExceptionHandle { } log.error(sb.toString(), e); //return ResultVO.error(STATE.PermissionDenied, "登录已过期,请重新登录"); - return errorResult(STATE.PermissionDenied,"不支持的请求方法:"+e.getMethod()); + return ResultVO.error(STATE.PermissionDenied,"不支持的请求方法:"+e.getMethod()); } /** @@ -96,69 +94,62 @@ public class BaseGlobalExceptionHandle { */ @ExceptionHandler(value = MaxUploadSizeExceededException.class) @ResponseBody - public ResponseEntity> handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) { + public ResultVO handleMaxUploadSizeExceededException(MaxUploadSizeExceededException e) { log.error(e.getMessage(), e); //return ResultVO.error("文件大小超出10MB限制, 请压缩或降低文件质量! "); - return errorResult("文件大小超出10MB限制, 请压缩或降低文件质量! "); + return ResultVO.error("文件大小超出10MB限制, 请压缩或降低文件质量! "); } @ExceptionHandler(value = DataIntegrityViolationException.class) @ResponseBody - public ResponseEntity> handleDataIntegrityViolationException(DataIntegrityViolationException e) { + public ResultVO handleDataIntegrityViolationException(DataIntegrityViolationException e) { log.error(e.getMessage(), e); // return ResultVO.error("字段太长,超出数据库字段的长度"); - return errorResult("字段太长,超出数据库字段的长度"); + return ResultVO.error("字段太长,超出数据库字段的长度"); } @ExceptionHandler(value = SQLException.class) @ResponseBody - public ResponseEntity> handleSQLException(SQLException e) { + public ResultVO handleSQLException(SQLException e) { log.error(e.getMessage(),e); //return ResultVO.error("sql执行过程出现错误"); - return errorResult("sql执行过程出现错误"); + return ResultVO.error("sql执行过程出现错误"); } @ExceptionHandler(value = RuntimeException.class) @ResponseBody - public ResponseEntity> handleRuntimeExceptionException(RuntimeException e) { + public ResultVO handleRuntimeExceptionException(RuntimeException e) { log.error(e.getMessage(),e); //throw new NflgBusinessException(STATE.Error, "系统错误,请联系管理员"); - return errorResult("系统错误,请联系管理员"); + return ResultVO.error("系统错误,请联系管理员"); } - - @ExceptionHandler(value = BadSqlGrammarException.class) @ResponseBody - public ResponseEntity> handleDataAccessException(BadSqlGrammarException e) { + public ResultVO handleDataAccessException(BadSqlGrammarException e) { log.error(e.getMessage(),e); //throw new NflgBusinessException(STATE.Error, "sql 语法错误,系统错误,请联系管理员"); - return errorResult("sql 语法错误,系统错误,请联系管理员"); + return ResultVO.error("sql 语法错误,系统错误,请联系管理员"); } @ExceptionHandler(value = MethodArgumentNotValidException.class) @ResponseBody - public ResponseEntity> handleMethodArgumentException(MethodArgumentNotValidException e){ + public ResultVO handleMethodArgumentException(MethodArgumentNotValidException e){ log.error(e.getMessage(),e); - return errorResult(e.getBindingResult().getFieldError().getDefaultMessage()) ; + return ResultVO.error(e.getBindingResult().getFieldError().getDefaultMessage()) ; } @ExceptionHandler(NullPointerException.class) - public ResponseEntity> handleNullPointerException(NullPointerException ex) { + @ResponseBody + public ResultVO handleNullPointerException(NullPointerException ex) { log.error(ex.getMessage(),ex); - return errorResult(STATE.Error, "系统错误,请联系管理员:"+ex.getMessage()) ; + return ResultVO.error(STATE.Error, "系统错误,请联系管理员") ; } @ExceptionHandler(MissingServletRequestParameterException.class) - public ResponseEntity> handleMissingServletRequestParameterException(MissingServletRequestParameterException ex) { + @ResponseBody + public ResultVO handleMissingServletRequestParameterException(MissingServletRequestParameterException ex) { log.error(ex.getMessage(),ex); - return errorResult(STATE.ParamErr, ex.getParameterName()+"参数不能为空"); - } - - private static ResponseEntity> errorResult(String msg) { - return ResponseEntity.status(HttpStatus.OK).body(ResultVO.error(STATE.Error,msg)); - } - private static ResponseEntity> errorResult(STATE code,String msg) { - return ResponseEntity.status(HttpStatus.OK).body(ResultVO.error(code,msg)); + return ResultVO.error(STATE.ParamErr, ex.getParameterName()+"参数不能为空"); } } From a4c4facf3152084ae4bbb23e64752a3ff023c3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 14 Mar 2024 14:28:17 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BB=8Eexcel=E5=AF=BC=E5=85=A5=E5=8E=9F?= =?UTF-8?q?=E5=A7=8Bbom=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=BC=96=E5=8F=B7=E6=98=AF=E2=80=9D=E6=97=A0=E2=80=9C?= =?UTF-8?q?=E5=88=99=E6=94=B9=E4=B8=BA=E2=80=9D=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewOriginalParentService.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java index 8a726401..4ce3ab3e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewOriginalParentService.java @@ -10,27 +10,24 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.google.common.collect.Sets; import com.mzt.logapi.context.LogRecordContext; -import com.nflg.product.base.core.config.SpringContextUtils; import com.nflg.product.base.core.conmon.util.SessionUtil; -import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.bomnew.constant.*; import com.nflg.product.bomnew.mapper.master.BomNewOriginalParentMapper; import com.nflg.product.bomnew.pojo.dto.BomNewOriginalExcelDTO; import com.nflg.product.bomnew.pojo.dto.OriginalSaveBomDTO; -import com.nflg.product.bomnew.pojo.entity.*; +import com.nflg.product.bomnew.pojo.entity.BomNewOriginalChildEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewOriginalMaterialUseEntity; +import com.nflg.product.bomnew.pojo.entity.BomNewOriginalParentEntity; +import com.nflg.product.bomnew.pojo.entity.BomOriginalCadParentEntity; import com.nflg.product.bomnew.pojo.query.OriginalBomQuery; -import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; import com.nflg.product.bomnew.pojo.vo.BomOriginalListVO; import com.nflg.product.bomnew.pojo.vo.BomOriginalPlmBomVO; import com.nflg.product.bomnew.pojo.vo.ImportOriginalBomVO; -import com.nflg.product.bomnew.service.domain.EBom.CheckEBomException; import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomDetailTask; import com.nflg.product.bomnew.service.domain.OriginalBom.OriginalBomToEBomConvert; import com.nflg.product.bomnew.service.domain.OriginalBom.PlmBomToOriginalConvert; import com.nflg.product.bomnew.util.*; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections.map.LinkedMap; -import org.bouncycastle.cert.dane.DANEEntry; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.stereotype.Service; @@ -46,7 +43,6 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; import java.util.stream.Collectors; -import java.util.stream.Stream; /** @@ -618,6 +614,9 @@ public class BomNewOriginalParentService extends ServiceImpl Date: Thu, 14 Mar 2024 14:29:33 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=BB=8Ecad=E5=AF=BC=E5=85=A5=E5=8E=9F?= =?UTF-8?q?=E5=A7=8Bbom=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9C=E7=88=B6?= =?UTF-8?q?=E7=BA=A7=E7=89=A9=E6=96=99=E7=BC=96=E5=8F=B7=E6=98=AF=E2=80=9D?= =?UTF-8?q?=E6=97=A0=E2=80=9C=E5=88=99=E4=BB=8E=E4=B8=BB=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/domain/OriginalBom/PlmBomToOriginalConvert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/PlmBomToOriginalConvert.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/PlmBomToOriginalConvert.java index 030a824e..fa783287 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/PlmBomToOriginalConvert.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/OriginalBom/PlmBomToOriginalConvert.java @@ -49,7 +49,7 @@ public class PlmBomToOriginalConvert extends BaseConvert { childs = Convert.toList(BomOriginalPlmBomVO.class, SpringUtil.getBean(BomOriginalCadChildService.class).lambdaQuery().eq(BomOriginalCadChildEntity::getParentRowId, inParent.getRowId()).list()); parent = Convert.convert(BomOriginalPlmBomVO.class, inParent); //图号-初始化缺编码的物料 - if(StrUtil.isBlank(parent.getMaterialNo())){ + if(StrUtil.isBlank(parent.getMaterialNo()) || parent.getMaterialNo().trim().equalsIgnoreCase("无")){ SpringUtil.getBean(MaterialMainService.class).initMaterialForDrawdingNo(ImmutableList.of(parent) ,BomOriginalPlmBomVO::getDrawingNo,BomOriginalPlmBomVO::setMaterialNo,BomOriginalPlmBomVO::setMaterialName); } List noMaterialNoList = childs.stream().filter(u -> StrUtil.isBlank(u.getMaterialNo())).collect(Collectors.toList()); From 5175f8a60661fd6551391419068ade1a088f2b44 Mon Sep 17 00:00:00 2001 From: jing's Date: Thu, 14 Mar 2024 16:11:17 +0800 Subject: [PATCH 7/9] =?UTF-8?q?ebom=E7=BC=96=E8=BE=91=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nflg/product/bomnew/api/user/EbomApi.java | 15 +- .../bomnew/constant/EbomEditStatusEnum.java | 4 +- .../bomnew/pojo/dto/BomNewEbomImportDTO.java | 4 + .../service/BomNewEbomParentService.java | 118 +++++----- .../bomnew/service/domain/EBom/EBomEdit.java | 207 ++++++++++++++---- 5 files changed, 247 insertions(+), 101 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 15ac993b..87f7e9b3 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -281,14 +281,16 @@ public class EbomApi extends BaseApi { @GetMapping("editDetail") @ApiOperation("编辑物料列表") - public ResultVO editDetail(@RequestParam("bomRowId") Long bomRowId,@RequestParam("projectType") String projectType) { - + public ResultVO editDetail(@RequestParam("rowId") Long rowId,@RequestParam("bomRowId") Long bomRowId,@RequestParam("projectType") String projectType) { + if(Objects.isNull(bomRowId)){ + VUtils.isTure(true ).throwMessage("rowId 不能为空"); + } if(Objects.isNull(bomRowId)){ VUtils.isTure(true ).throwMessage("bomRowId不能为空"); } ResultVO resultVO = new ResultVO(); - resultVO.setData(bomNewEbomParentService.editDetail(bomRowId,projectType)); + resultVO.setData(bomNewEbomParentService.editDetail(rowId,bomRowId,projectType)); return resultVO; } @@ -350,7 +352,8 @@ public class EbomApi extends BaseApi { @PostMapping("temporary") @ApiOperation("暂存") - public ResultVO temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { + @LogRecord(success = "Ebom-暂存,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-暂存") + public ResultVO temporary(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { return ResultVO.success(bomNewEbomParentService.temporary(dto)); } @@ -364,9 +367,11 @@ public class EbomApi extends BaseApi { } + + @PostMapping("intiException") @ApiOperation("初始化错误类型") - @LogRecord(success = "Ebom-初始化错误类型,操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}",type = "Ebom-提交") + @LogRecord(success = "Ebom-初始化错误类型,操作结果:{{#_ret}}", bizNo = "{{#bomRowIds.toString()}}",type = "Ebom-初始化错误类型") public ResultVO intiException(@RequestBody List bomRowIds) throws ExecutionException, InterruptedException { bomNewEbomParentService.batchCheckAndSaveEBomException(bomRowIds ); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EbomEditStatusEnum.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EbomEditStatusEnum.java index 8d162090..4f029242 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EbomEditStatusEnum.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EbomEditStatusEnum.java @@ -8,8 +8,8 @@ import lombok.Getter; @Getter public enum EbomEditStatusEnum implements ValueEnum { - HANDLER_CREATED(1, "待处理"), - HANDLER_FINISHED(2, "处理完成"); + HANDLER_CREATED(1, "待处理"),//待处理=暂存 + HANDLER_FINISHED(2, "已处理"); //已处理=提交 private final Integer value; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java index c65fea2a..53f30874 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/dto/BomNewEbomImportDTO.java @@ -17,6 +17,10 @@ public class BomNewEbomImportDTO { // private BomNewEbomParentVO parent; @ApiModelProperty("父物料id") private Long rowId; + + @ApiModelProperty("bom id") + private Long bomRowId; + @ApiModelProperty("操作类型(1:删除 2:追加)") private Integer opType; 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 e0ae536e..ec5263c4 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 @@ -914,6 +914,10 @@ public class BomNewEbomParentService extends ServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(BomNewEbomChildEntity::getParentRowId, dto.getRowId()).last("limit 1"); queryWrapper.lambda().orderByDesc(BomNewEbomChildEntity::getOrderNumber); @@ -948,26 +953,26 @@ public class BomNewEbomParentService extends ServiceImpl()); + }else{ + BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId); + parentVO = Convert.convert(BomNewEbomParentVO.class, parent); + + parentVO.setBomRowId(parentVO.getRowId()); + parentVO.setProjectType(projectType); + parentVO.setParentRowId(0l); + materialMainService.intiMaterialInfo(ImmutableList.of(parentVO), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2); + vo.setDatas(getChild(bomRowId)); + } // materialMainService.intiMaterialInfo(ImmutableList.of(parentVO)); @@ -1303,7 +1327,7 @@ public class BomNewEbomParentService extends ServiceImpl childList = dto.getDatas(); - - if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) { - childList.add(dto.getParent()); - } // checkAndSaveEBomException(childList); //不要异步 ebomChildService.getBaseMapper().updateEBomMaterialUse(); // ThreadUtil.execAsync(() -> computeLevelNumAndRootState()); - return true; + BomNewEbomParentVO retParentVO= Convert.convert(BomNewEbomParentVO.class,eBomEdit.getParentEntity()); + retParentVO.setBomRowId(retParentVO.getRowId()); + + return retParentVO; } /** @@ -1538,7 +1556,7 @@ public class BomNewEbomParentService extends ServiceImpl checkStatus = CollectionUtil.toList(new Integer[]{ EBomExceptionStatusEnum.EXCEPT_NO_2.getValue(), @@ -1557,27 +1575,22 @@ public class BomNewEbomParentService extends ServiceImpl allBom = Convert.convert(new TypeReference>() { }, eBomEdit.childEntities); - BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class - , eBomEdit.parentEntities.get(0)); - -// if (dto.getParent().getRootIs() == null || dto.getParent().getRootIs() == 0) { -// allBom.add(parent); -// } - CheckEBomException checkEBomException = new CheckEBomException(allBom); checkEBomException.checkContainExcept(checkStatus); } - if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) { - this.saveOrUpdateBatch(eBomEdit.parentEntities); - } if (CollectionUtil.isNotEmpty(eBomEdit.childEntities)) { ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); @@ -1611,6 +1624,7 @@ public class BomNewEbomParentService extends ServiceImpl delTagList = new ArrayList<>(); List okList = delList.stream().filter(u -> Objects.equals(EBomSourceEnum.FROM_BOM.getValue(), u.getSource()) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java index f244aad0..dac923d9 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/EBomEdit.java @@ -19,43 +19,50 @@ import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO; +import com.nflg.product.bomnew.service.BomNewEbomParentService; import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.service.UserRoleService; +import com.nflg.product.bomnew.util.MaterialshouldBomExistUtil; import com.nflg.product.bomnew.util.VUtils; +import lombok.Getter; import nflg.product.common.constant.STATE; import org.ttzero.excel.reader.Col; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; public class EBomEdit { public List parentEntities; + @Getter + private BomNewEbomParentEntity parentEntity; public List childEntities; Integer source; + List roleList; public EBomEdit(Integer source) { this.source = source; parentEntities = new ArrayList<>(); childEntities = new ArrayList<>(); + roleList = SpringUtil.getBean(UserRoleService.class).getUserPost(); } BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) { - BomNewEbomParentEntity parent = new BomNewEbomParentEntity(); - BeanUtil.copyProperties(vo,parent); + BomNewEbomParentEntity parent = Convert.convert(BomNewEbomParentEntity.class, vo); + //BeanUtil.copyProperties(vo,parent); // BaseMaterialVO material = materialVOMap.get(vo.getMaterialNo()); String batchNo = IdUtil.simpleUUID(); parent.setRowId(IdWorker.getId()); parent.setBatchNo(batchNo); - parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum())); parent.setDeviseUserCode(SessionUtil.getUserCode()); parent.setCurrentVersion("A00"); @@ -64,7 +71,7 @@ public class EBomEdit { parent.setSourceRowId(0l); parent.setSource(source); parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue()); - + parent.setNum(new BigDecimal(1)); parent.setBomExist(1); parent.setLastVersionIs(1); parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); @@ -74,37 +81,102 @@ public class EBomEdit { parent.setStatus(SpringUtil.getBean(UserRoleService.class).technician() ? EBomStatusEnum.CHECKED.getValue() : EBomStatusEnum.WAIT_CHECK.getValue()); parent.setCreatedJob(SpringUtil.getBean(UserRoleService.class).technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); + parent.setModifyTime(LocalDateTime.now()); + + parent.setExpireEndTime( LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") )); + return parent; } - - void createBom(BomNewEBomParentEditDTO createDTO){ - - List materialNos = createDTO.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); - materialNos.add(createDTO.getParent().getMaterialNo()); - //检查物料编码是否在主数据中存在 - List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); - List effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); - Set difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos)); - VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在"); - - - List existBomlist =SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, createDTO.getParent().getMaterialNo()).list(); - - QueryWrapper - - VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage("该物料已存在BOM"); - - - - + void checkHadBom(String materialNo){ + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(BomNewEbomParentEntity::getMaterialNo, materialNo); + List existBomlist = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper); + VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo+"该物料已存在BOM"); } + void createRootBom(BomNewEBomParentEditDTO createDTO) { + + checkHadBom(createDTO.getParent().getMaterialNo()); + + parentEntity = createParentBomInfo(createDTO.getParent()); + parentEntity.setEditStatus(createDTO.getOpType()); + + parentEntity.setRootIs(1); + parentEntity.setUserRootIs(1); + createDTO.getDatas().forEach(k -> { + k.setParentRowId(parentEntity.getRowId()); + }); + + + if (Objects.equals(createDTO.getOpType(), EbomEditStatusEnum.HANDLER_FINISHED.getValue())) { + //工艺人员 + if (roleList.contains(EBomConstant.TECHNICIAN)) { + parentEntity.setStatus(EBomStatusEnum.CHECKED.getValue()); + } + } + + childEntities.addAll(updateOrCreateChild(createDTO)); + + } + + List updateOrCreateChild(BomNewEBomParentEditDTO dto) { + List childEntity = Convert.convert(new TypeReference>() { + }, dto.getDatas()); + + + for (BomNewEbomChildEntity child : + childEntity) { + + child.setEditStatus(dto.getOpType()); + child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); + child.setModifyTime(LocalDateTime.now()); + + if (child.getMaterialName().contains(VirtualPackageTypeEnum.MAKING_PACKAGE.getConMaterialName())) { + child.setVirtualPartType(VirtualPackageTypeEnum.MAKING_PACKAGE.getValue()); + child.setVirtualPartIs(1); + + } else if (child.getMaterialName().contains(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getConMaterialName())) { + child.setVirtualPartType(VirtualPackageTypeEnum.DELIVERY_PACKAGE.getValue()); + child.setVirtualPartIs(1); + } else if (child.getMaterialName().contains(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getConMaterialName())) { + child.setVirtualPartType(VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue()); + child.setVirtualPartIs(1); + } else if (child.getMaterialName().contains(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getConMaterialName())) { + child.setVirtualPartType(VirtualPackageTypeEnum.PRE_ASSEMBLY_PACKAGE.getValue()); + child.setVirtualPartIs(1); + } + + + //新增数据 + if (child.getRowId() == null || child.getRowId().longValue() == 0) { + child.setRowId(IdWorker.getId()); + child.setIdentityNo(StrUtil.join("_", parentEntity.getRowId(), child.getRowId())); + child.setSource(source); + child.setCreatedTime(LocalDateTime.now()); + child.setCreatedBy(SessionUtil.getUserCode()); + child.setSourceRowId(0l); + child.setParentRowId(parentEntity.getRowId()); + if(StrUtil.isEmpty(child.getOrderNumber())){ + child.setOrderNumber("00"); + } + child.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); + // parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); + checkExcept(dto.getParent(), child); + if (StrUtil.isNotBlank(child.getProjectType())) { + child.setProjectType(child.getProjectType().toUpperCase()); + } + } + + + } + return childEntity; + } private void checkExcept(BomNewEbomParentVO parent, BomNewEbomChildEntity child) { @@ -127,32 +199,79 @@ public class EBomEdit { } - void checkDataRule(BomNewEBomParentEditDTO dto){ - if(dto.getParent()==null){ - throw new NflgBusinessException(STATE.Error,"parent 数据不能为空"); + void checkDataRule(BomNewEBomParentEditDTO dto) { + if (dto.getParent() == null) { + throw new NflgBusinessException(STATE.Error, "parent 数据不能为空"); } - if(CollUtil.isEmpty(dto.getDatas())){ - throw new NflgBusinessException(STATE.Error,"datas 数据不能为空"); + if (CollUtil.isEmpty(dto.getDatas())) { + throw new NflgBusinessException(STATE.Error, "datas 数据不能为空"); } + List materialNos = dto.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + if(materialNos.contains(dto.getParent().getMaterialNo())){ + VUtils.isTure(true).throwMessage(StrUtil.format("上下级存在相同物料{}",dto.getParent().getMaterialNo())); + } + materialNos.add(dto.getParent().getMaterialNo()); + //检查物料编码是否在主数据中存在 + List materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos); + List effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList()); + Set difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos)); + VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料主数据中不存在"); + } + + public void handleBom(BomNewEBomParentEditDTO dto) { + checkDataRule(dto); + //添加根节点数据 + //rowId is null 必定是未入库作为根 + if (dto.getParent().getRowId() == null || dto.getParent().getRowId().longValue() == 0) { + createRootBom(dto); + return; + } + + //缺bom + if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) { + + checkHadBom(dto.getParent().getMaterialNo()); + dto.getParent().setBomRowId(dto.getParent().getRowId()); + parentEntity = createParentBomInfo(dto.getParent()); + + dto.getDatas().forEach(k -> { + k.setParentRowId(parentEntity.getRowId()); + }); + parentEntity.setEditStatus(dto.getOpType()); + + }else{ + parentEntity = Convert.convert(BomNewEbomParentEntity.class, dto.getParent()); + parentEntity.setModifyTime(LocalDateTime.now()); + } + parentEntity.setEditStatus(dto.getOpType()); + //提交 + if (Objects.equals(dto.getOpType(), EbomEditStatusEnum.HANDLER_FINISHED.getValue())) { + //工艺人员 + if (roleList.contains(EBomConstant.TECHNICIAN)) { + parentEntity.setStatus(EBomStatusEnum.CHECKED.getValue()); + } + } + childEntities.addAll(updateOrCreateChild(dto)); + + } + + + /** + * 废弃 + * @param dto + */ + @Deprecated public void temporary(BomNewEBomParentEditDTO dto) { - checkDataRule(dto); + List roleList = SpringUtil.getBean(UserRoleService.class).getUserPost(); - //添加数据 - if(dto.getParent().getRowId()==null){ - - - - } - - if (dto.getParent() == null) { @@ -226,7 +345,11 @@ public class EBomEdit { } - + /** + * 废弃 + * @param dto + */ + @Deprecated public void submit(BomNewEBomParentEditDTO dto) { @@ -256,7 +379,7 @@ public class EBomEdit { if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) { dto.getParent().setBomRowId(dto.getParent().getRowId()); parent = createParentBomInfo(dto.getParent()); - dto.getDatas().forEach(k->{ + dto.getDatas().forEach(k -> { k.setParentRowId(parent.getRowId()); }); parent.setEditStatus(dto.getOpType()); @@ -305,7 +428,7 @@ public class EBomEdit { // parent.setExceptionStatus(EBomExceptionStatusEnum.OK.getValue()); checkExcept(dto.getParent(), child); - }else { + } else { child.setModifyTime(LocalDateTime.now()); } From 9b7f3b2a1d691173c39ea2bf0db6e0e48b6950f9 Mon Sep 17 00:00:00 2001 From: jing's Date: Thu, 14 Mar 2024 16:15:40 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 87f7e9b3..92df9876 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -282,7 +282,7 @@ public class EbomApi extends BaseApi { @GetMapping("editDetail") @ApiOperation("编辑物料列表") public ResultVO editDetail(@RequestParam("rowId") Long rowId,@RequestParam("bomRowId") Long bomRowId,@RequestParam("projectType") String projectType) { - if(Objects.isNull(bomRowId)){ + if(Objects.isNull(rowId)){ VUtils.isTure(true ).throwMessage("rowId 不能为空"); } if(Objects.isNull(bomRowId)){ From e4791b20bf662ef6e8e249f0536f993c654d6f67 Mon Sep 17 00:00:00 2001 From: jing's Date: Thu, 14 Mar 2024 17:21:58 +0800 Subject: [PATCH 9/9] =?UTF-8?q?ebom=E6=B7=BB=E5=8A=A0bom=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nflg/product/bomnew/api/user/EbomApi.java | 13 +++++++++++++ .../bomnew/service/BomNewMbomParentService.java | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java index 92df9876..45c3a5ca 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/EbomApi.java @@ -357,6 +357,19 @@ public class EbomApi extends BaseApi { return ResultVO.success(bomNewEbomParentService.temporary(dto)); } + @PostMapping("temporaryAdd") + @ApiOperation("暂存添加") + @LogRecord(success = "Ebom-暂存添加,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-暂存添加") + public ResultVO temporaryAdd(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { + return ResultVO.success(bomNewEbomParentService.temporary(dto)); + } + + @PostMapping("submitAdd") + @ApiOperation("提交添加") + @LogRecord(success = "Ebom-提交添加,物料编码:{{#dto.parent.materialNo}}-版本:{{#dto.parent.currentVersion}},操作结果:{{#_ret}}", bizNo = "{{#dto.parent.rowId}}",type = "Ebom-提交添加") + public ResultVO submitAdd(@RequestBody BomNewEBomParentEditDTO dto) throws ExecutionException, InterruptedException { + return ResultVO.success(bomNewEbomParentService.submit(dto)); + } @PostMapping("submit") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java index 92e6a623..dfcdb40c 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java @@ -255,8 +255,6 @@ public class BomNewMbomParentService extends ServiceImpl()); result.setZID(RandomUtil.randomNumbers(5));