From fc738cd40fb73e6d54faec1d1398fe31858fbd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Wed, 24 Apr 2024 18:09:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=B5=E6=B0=94=E4=B8=93=E7=94=A8bom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/pojo/vo/BomExceptionVO.java | 6 +++ .../product/bomnew/pojo/vo/BomNewDQbomVO.java | 5 +- .../product/bomnew/service/DQBomService.java | 54 ++++++++++--------- .../mapper/master/BomNewDQbomParentMapper.xml | 9 ++-- 4 files changed, 41 insertions(+), 33 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomExceptionVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomExceptionVO.java index 688404fc..f57001f2 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomExceptionVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomExceptionVO.java @@ -22,6 +22,12 @@ public class BomExceptionVO implements Serializable { @ApiModelProperty(value = "bom行编号") public Long bomRowId; + /** + * rowId + */ + @ApiModelProperty(value = "rowId") + public Long rowId; + /** * 物料编码 */ diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewDQbomVO.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewDQbomVO.java index d5d83c73..202f7210 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewDQbomVO.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/pojo/vo/BomNewDQbomVO.java @@ -1,7 +1,6 @@ package com.nflg.product.bomnew.pojo.vo; import cn.hutool.core.util.StrUtil; -import com.nflg.product.bomnew.constant.BomConstant; import com.nflg.product.bomnew.pojo.entity.BomNewDQbomChildEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -116,7 +115,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl private String drawingNoDesc; public String getDrawingNoDesc() { - if (StrUtil.isNotBlank(getDrawingNo()) && getDrawingNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) { + if (StrUtil.equals(getProjectType(), "T")) { return ""; } return getDrawingNo(); @@ -129,7 +128,7 @@ public class BomNewDQbomVO extends BomNewDQbomChildEntity implements Serializabl private String materialNoDesc; public String getMaterialNoDesc() { - if (StrUtil.isNotBlank(getMaterialNo()) && getMaterialNo().startsWith(BomConstant.NO_TEMPORARY_PREFIX)) { + if (StrUtil.equals(getProjectType(), "T")) { return ""; } return getMaterialNo(); diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/DQBomService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/DQBomService.java index 5257ebc3..9237d0a1 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/DQBomService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/DQBomService.java @@ -1,6 +1,5 @@ package com.nflg.product.bomnew.service; -import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateUtil; @@ -221,18 +220,18 @@ public class DQBomService { */ @Transactional(rollbackFor = Exception.class) public BomNewDQbomSaveQuery save(BomNewDQbomSaveQuery query) { - BomNewDQbomParentEntity parent = new BomNewDQbomParentEntity(); - BeanUtil.copyProperties(query.getParent(), parent); + BomNewDQbomParentEntity parent; - if (Objects.isNull(parent.getRowId()) || parent.getRowId() == 0) { + if (Objects.isNull(query.getParent()) || query.getParent().getBomRowId() == 0) { //新增父级节点 - BomNewDQbomParentEntity oldParent = dQBomParentService.lambdaQuery().eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo()) + BomNewDQbomParentEntity oldParent = dQBomParentService.lambdaQuery().eq(BomNewDQbomParentEntity::getMaterialNo, query.getParent().getMaterialNo()) .eq(BomNewDQbomParentEntity::getLastVersionIs, 1) .one(); VUtils.isTure(oldParent != null && !oldParent.getCreatedBy().equals(SessionUtil.getUserCode())) .throwMessage("父级已被其他人创建"); VUtils.isTure(CollUtil.isEmpty(query.getChildren())).throwMessage("新添加的bom必须有子级"); + parent = Convert.convert(BomNewDQbomParentEntity.class, query.getParent()); parent.setRowId(IdWorker.getId()); parent.setLevel(1); parent.setBomExist(1); @@ -245,16 +244,13 @@ public class DQBomService { parent.setCreatedJob(userRoleService.technician() ? UserJobEnum.ENGINEER.getValue() : UserJobEnum.DESIGNER.getValue()); parent.setSource(2); dQBomParentService.save(parent); - query.getParent().setRowId(parent.getRowId()); + query.getParent().setBomRowId(parent.getRowId()); } else { - //修改数据 - // VUtils.isTure(!SessionUtil.getUserCode().equals(parent.getCreatedBy())).throwMessage("不能修改他人的数据"); - - //删除 - dQBomChildService.deleteAllChildren(parent.getRowId()); + //删除所有子级关系 + dQBomChildService.deleteAllChildren(query.getParent().getBomRowId()); + parent = dQBomParentService.getById(query.getParent().getBomRowId()); parent.setModifyTime(LocalDateTime.now()); if (CollUtil.isEmpty(query.getChildren())) { - //dQBomChildService.deleteAllChildren(parent.getRowId()); parent.setBomExist(0); dQBomParentService.saveOrUpdate(parent); return query; @@ -270,18 +266,20 @@ public class DQBomService { c.setRowId(IdWorker.getId()); c.setCreatedBy(SessionUtil.getUserCode()); c.setCreatedName(SessionUtil.getRealName()); - String id = RandomUtil.randomNumbers(9); - c.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id); - c.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id); + if (StrUtil.equals(c.getProjectType(), "T")) { + String id = RandomUtil.randomNumbers(9); + c.setMaterialNo(BomConstant.NO_TEMPORARY_PREFIX + id); + c.setDrawingNo(BomConstant.NO_TEMPORARY_PREFIX + id); + if (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO)) { + c.setNum(BigDecimal.ONE); + } + if (StrUtil.isBlank(c.getMaterialUnit())) { + c.setMaterialUnit("PC"); + } + } } else { c.setModifyTime(LocalDateTime.now()); } - if (StrUtil.isBlank(c.getMaterialUnit())) { - c.setMaterialUnit("PC"); - } - if (Objects.isNull(c.getNum()) || NumberUtil.equals(c.getNum(), BigDecimal.ZERO)) { - c.setNum(BigDecimal.ONE); - } c.setLevel(parent.getLevel() + 1); c.setParentRowId(parent.getRowId()); c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId()); @@ -488,6 +486,7 @@ public class DQBomService { pchildren.forEach(c -> { c.setCreatedTime(LocalDateTime.now()); c.setModifyTime(null); + c.setFacCode(FactoryCodeEnum.FACTORY_1010.getValue()); c.setIdentityNo(c.getParentRowId() + "_" + c.getRowId()); if (CollUtil.isNotEmpty(materialBaseInfos)) { BaseMaterialVO materialVO = materialBaseInfos.stream() @@ -529,6 +528,7 @@ public class DQBomService { parent.setStatus(2); parent.setConvertToPbomTime(LocalDateTime.now()); parent.setModifyTime(LocalDateTime.now()); + parent.setEditStatus(2); parents.add(parent); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(BomNewDQbomParentEntity::getMaterialNo, parent.getMaterialNo()); @@ -537,6 +537,7 @@ public class DQBomService { List cc = dQBomChildService.getByParentRowId(parent.getRowId()); cc.forEach(c -> { c.setStatus(2); + c.setEditStatus(2); c.setModifyTime(LocalDateTime.now()); }); children.addAll(cc); @@ -572,6 +573,8 @@ public class DQBomService { .eq(BomNewPbomChildEntity::getParentRowId, pp.getRowId())); } } + } else { + parent.setCurrentVersion(VersionUtil.getNextVersion("")); } //处理子级 dQBomParentService.lambdaQuery() @@ -591,18 +594,14 @@ public class DQBomService { List datas = new ArrayList<>(); for (int index = 0, count = query.size(); index < count; index++) { BomExceptionQuery bom = query.get(index); + BomExceptionVO vo = new BomExceptionVO(); if (index == 0) { checkException(bom.getBomRowId()); BomNewDQbomParentEntity parent = dQBomParentService.getById(bom.getBomRowId()); - BomExceptionVO vo = new BomExceptionVO(); - vo.setBomRowId(bom.getBomRowId()); vo.setMaterialNo(parent.getMaterialNo()); vo.setExceptionStatus(parent.getExceptionStatus()); - datas.add(vo); } else { - BomExceptionVO vo = new BomExceptionVO(); - vo.setBomRowId(bom.getBomRowId()); BomNewDQbomChildEntity child = dQBomChildService.getById(bom.getRowId()); vo.setMaterialNo(child.getMaterialNo()); if (Objects.equals(child.getExceptionStatus(), EBomExceptionStatusEnum.OK.getValue())) { @@ -612,6 +611,9 @@ public class DQBomService { vo.setExceptionStatus(child.getExceptionStatus()); } } + vo.setBomRowId(bom.getBomRowId()); + vo.setRowId(bom.getRowId()); + datas.add(vo); } return datas; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewDQbomParentMapper.xml b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewDQbomParentMapper.xml index 6f5b2fe6..deec9537 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewDQbomParentMapper.xml +++ b/nflg_project_dev/nflg-bom-new/src/main/resources/mapper/master/BomNewDQbomParentMapper.xml @@ -30,7 +30,7 @@