From 4a9d799535d8c5e66481ccc1e512db1fddb608ae Mon Sep 17 00:00:00 2001 From: jing's Date: Sun, 7 Jan 2024 17:00:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/bomnew/constant/EBomConstant.java | 3 + .../service/BomNewMbomDetailService.java | 96 +++++++++++-------- 2 files changed, 58 insertions(+), 41 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java index 3dc8b171..1c1f28fc 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/constant/EBomConstant.java @@ -13,6 +13,9 @@ public class EBomConstant { //EBOM 获取时,初始化物料主数据信息是,忽略的字段 public static final String[] EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT = {"material", "materialTexture", "projectType", "materialUnit"}; + public static final String[] EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2 = {"material", "materialTexture", "projectType", "materialUnit","materialNo", + "materialName","materialDesc","drawingNo" + }; //集团总部代码 public static final String MAIN_FACTORY_CODE_1010="1010"; diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomDetailService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomDetailService.java index 070933d2..5ac02c88 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomDetailService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomDetailService.java @@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.nflg.product.base.core.exception.NflgBusinessException; +import com.nflg.product.bomnew.constant.EBomConstant; import com.nflg.product.bomnew.constant.MBomConstantEnum; import com.nflg.product.bomnew.mapper.master.BomNewMbomDetailMapper; import com.nflg.product.bomnew.pojo.entity.BomNewMbomDetailEntity; @@ -19,6 +20,7 @@ import com.nflg.product.bomnew.pojo.vo.BomNewMbomMiddleVO; import nflg.product.common.constant.STATE; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.time.LocalDateTime; import java.util.List; @@ -61,6 +63,8 @@ public class BomNewMbomDetailService extends ServiceImpl voList = Convert.convert(new TypeReference>() { }, list); + SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(voList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2); + return voList; } @@ -74,6 +78,7 @@ public class BomNewMbomDetailService extends ServiceImpl queryWrapper = new QueryWrapper<>(); +// queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, 0l) +// .eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue()); +// List list = this.list(queryWrapper); +// if (CollectionUtil.isNotEmpty(list)) { +// throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料"); +// } +// } else { +// //check 父级为超级物料 子级才能为超级物料 +// QueryWrapper queryParentWrapper = new QueryWrapper<>(); +// queryParentWrapper.lambda().eq(BomNewMbomDetailEntity::getRowId, entity.getParentRowId()); +// BomNewMbomDetailEntity parentDetail = this.getOne(queryParentWrapper); +// if (parentDetail == null) { +// throw new NflgBusinessException(STATE.Error, "数据异常联系管理员"); +// } +// if (!Objects.equals(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue(), parentDetail.getSuperMaterialStatus())) { +// throw new NflgBusinessException(STATE.Error, "父级不为超级物料,子级不能设置为超级物料"); +// } +// //check 同级不能多个超级物料 +// QueryWrapper queryWrapper = new QueryWrapper<>(); +// queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, entity.getParentRowId()) +// .eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue()); +// List list = this.list(queryWrapper); +// if (CollectionUtil.isNotEmpty(list)) { +// throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料"); +// } +// +// } - //parentRowId 空情况 - if (Objects.isNull(entity.getParentRowId()) || entity.getParentRowId().longValue() == 0) { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, 0l) - .eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue()); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { - throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料"); - } - } else { - //check 父级为超级物料 子级才能为超级物料 - QueryWrapper queryParentWrapper = new QueryWrapper<>(); - queryParentWrapper.lambda().eq(BomNewMbomDetailEntity::getRowId, entity.getParentRowId()); - BomNewMbomDetailEntity parentDetail = this.getOne(queryParentWrapper); - if (parentDetail == null) { - throw new NflgBusinessException(STATE.Error, "数据异常联系管理员"); - } - if (!Objects.equals(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue(), parentDetail.getSuperMaterialStatus())) { - throw new NflgBusinessException(STATE.Error, "父级不为超级物料,子级不能设置为超级物料"); - } - //check 同级不能多个超级物料 - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId, entity.getParentRowId()) - .eq(BomNewMbomDetailEntity::getSuperMaterialStatus, MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue()); - List list = this.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)) { - throw new NflgBusinessException(STATE.Error, "同级已有物料设置为超级物料"); - } + //取消 - } + UpdateWrapper updateWrapper=new UpdateWrapper<>(); + updateWrapper.lambda().set(BomNewMbomDetailEntity::getModifyTime,LocalDateTime.now()); + updateWrapper.lambda().set(BomNewMbomDetailEntity::getSuperMaterialStatus,MBomConstantEnum.MBomSuperMaterialStatusEnum.UN_SUPER.getValue()); + updateWrapper.lambda().eq(BomNewMbomDetailEntity::getParentRowId ,entity.getParentRowId()); + update(updateWrapper); + BomNewMbomDetailEntity uppdateBomNewMbomDetailEntity = new BomNewMbomDetailEntity(); uppdateBomNewMbomDetailEntity.setSuperMaterialStatus(MBomConstantEnum.MBomSuperMaterialStatusEnum.SUPER.getValue()); uppdateBomNewMbomDetailEntity.setModifyTime(LocalDateTime.now());