From 6c1a7d22a8b26bcbf820c89057b25bad69a95866 Mon Sep 17 00:00:00 2001 From: jing's Date: Mon, 1 Apr 2024 22:56:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BABom=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewEbomParentService.java | 44 +++------------- .../bomnew/service/domain/EBom/EBomEdit.java | 51 ++++++++++++++++--- 2 files changed, 49 insertions(+), 46 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 62947ead..e8415f60 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 @@ -5,7 +5,6 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.lang.TypeReference; -import cn.hutool.core.thread.ThreadUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; @@ -38,7 +37,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.ttzero.excel.entity.ListSheet; -import org.ttzero.excel.entity.Workbook; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -51,6 +49,7 @@ import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinTask; +import java.util.concurrent.atomic.AtomicReference; import java.util.function.BinaryOperator; import java.util.function.Function; import java.util.stream.Collectors; @@ -1592,6 +1591,9 @@ public class BomNewEbomParentService extends ServiceImpl @@ -1621,24 +1623,7 @@ public class BomNewEbomParentService extends ServiceImpl oldParent= this.lambdaQuery() - .eq(BomNewEbomParentEntity::getMaterialNo, eBomEdit.getParentEntity().getMaterialNo()) - .eq(BomNewEbomParentEntity::getLastVersionIs,1) - //.ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) - .ne(BomNewEbomParentEntity::getRowId, eBomEdit.getParentEntity().getRowId()) - .list(); - - if(CollUtil.isNotEmpty(oldParent)){ - // oldParent.setLastVersionIs(0); - oldParent.forEach(u->{ - u.setLastVersionIs(0); - }); - this.updateBatchById(oldParent); - } - } + eBomEdit.nextVersion(); this.saveOrUpdate(eBomEdit.getParentEntity()); } @@ -1694,24 +1679,7 @@ public class BomNewEbomParentService extends ServiceImpl oldParent= this.lambdaQuery() - .eq(BomNewEbomParentEntity::getMaterialNo, eBomEdit.getParentEntity().getMaterialNo()) - .eq(BomNewEbomParentEntity::getLastVersionIs,1) - //.ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) - .ne(BomNewEbomParentEntity::getRowId, eBomEdit.getParentEntity().getRowId()) - .list(); - - if(CollUtil.isNotEmpty(oldParent)){ - // oldParent.setLastVersionIs(0); - oldParent.forEach(u->{ - u.setLastVersionIs(0); - }); - this.updateBatchById(oldParent); - } - } + eBomEdit.nextVersion(); this.saveOrUpdate(eBomEdit.getParentEntity()); 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 8a211c4f..09783030 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 @@ -25,6 +25,7 @@ import com.nflg.product.bomnew.service.MaterialMainService; import com.nflg.product.bomnew.service.UserRoleService; import com.nflg.product.bomnew.util.ListCommonUtil; import com.nflg.product.bomnew.util.VUtils; +import com.nflg.product.bomnew.util.VersionUtil; import lombok.Getter; import nflg.product.common.constant.STATE; @@ -85,18 +86,25 @@ public class EBomEdit { parent.setModifyTime(LocalDateTime.now()); parent.setExpireEndTime( LocalDateTime.parse("9999-12-31 23:59:59", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss") )); + parent.setRootIs(0); + parent.setUserRootIs(0); - - Integer rootIs =SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().checkIsRoot(parent.getMaterialNo()); - Integer userRootIs = SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().checkIsUserRoot(parent.getMaterialNo(), parent.getCreatedBy()); - parent.setRootIs(rootIs > 0 ? 0 : 1); - parent.setUserRootIs(userRootIs > 0 ? 0 : 1); +// Integer rootIs =SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().checkIsRoot(parent.getMaterialNo()); +// Integer userRootIs = SpringUtil.getBean(BomNewEbomParentService.class).getBaseMapper().checkIsUserRoot(parent.getMaterialNo(), parent.getCreatedBy()); +// parent.setRootIs(rootIs > 0 ? 0 : 1); +// parent.setUserRootIs(userRootIs > 0 ? 0 : 1); return parent; } + /** + * 如果有定版后才能新建bom + * @param materialNo + */ void checkHadBom(String materialNo){ QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(BomNewEbomParentEntity::getMaterialNo, materialNo); + queryWrapper.lambda().eq(BomNewEbomParentEntity::getMaterialNo, materialNo) + + .ne(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()); List existBomlist = SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper); VUtils.isTure(CollUtil.isNotEmpty(existBomlist)).throwMessage(materialNo+"该物料已存在BOM"); } @@ -107,7 +115,7 @@ public class EBomEdit { void createRootBom(BomNewEBomParentEditDTO createDTO) { - // checkHadBom(createDTO.getParent().getMaterialNo()); + checkHadBom(createDTO.getParent().getMaterialNo()); parentEntity = createParentBomInfo(createDTO.getParent()); parentEntity.setEditStatus(createDTO.getOpType()); @@ -291,7 +299,7 @@ public class EBomEdit { //缺bom if (dto.getParent().getBomRowId() == null || dto.getParent().getBomRowId().longValue() == 0) { - // checkHadBom(dto.getParent().getMaterialNo()); + checkHadBom(dto.getParent().getMaterialNo()); dto.getParent().setBomRowId(dto.getParent().getRowId()); parentEntity = createParentBomInfo(dto.getParent()); @@ -317,6 +325,33 @@ public class EBomEdit { } + public void nextVersion(){ + //同一物料且存在一个 lastVersionIs=1 + if(ObjectUtil.isNotNull(getParentEntity().getLastVersionIs()) + && ObjectUtil.equal(getParentEntity().getLastVersionIs(),1)) { + QueryWrapper queryWrapper=new QueryWrapper<>(); + + queryWrapper.lambda() + .eq(BomNewEbomParentEntity::getMaterialNo, getParentEntity().getMaterialNo()) + .eq(BomNewEbomParentEntity::getLastVersionIs,1) + // .eq(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()) + .orderByDesc(BomNewEbomParentEntity::getCurrentVersion); + List oldParent=SpringUtil.getBean(BomNewEbomParentService.class).list(queryWrapper); + + if(CollUtil.isNotEmpty(oldParent)){ + // oldParent.setLastVersionIs(0); + BomNewEbomParentEntity lastParent=oldParent.get(0); + for (BomNewEbomParentEntity u: + oldParent) { + u.setLastVersionIs(0); + lastParent=u; + } + getParentEntity().setCurrentVersion(VersionUtil.getNextVersion(lastParent.getCurrentVersion())); + SpringUtil.getBean(BomNewEbomParentService.class).updateBatchById(oldParent); + } + } + } + /** * 废弃 * @param dto