This commit is contained in:
jing's 2024-03-13 17:47:01 +08:00
parent f814d447d7
commit 08fc06ee98
1 changed files with 59 additions and 11 deletions

View File

@ -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<String> materialNos = createDTO.getDatas().stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
materialNos.add(createDTO.getParent().getMaterialNo());
//检查物料编码是否在主数据中存在
List<BaseMaterialVO> materialBaseInfo = SpringUtil.getBean(MaterialMainService.class).getMaterialBaseInfo(materialNos);
List<String> effectiveMaterialNos = materialBaseInfo.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
Set<String> difference = Sets.difference(new HashSet<>(materialNos), new HashSet<>(effectiveMaterialNos));
VUtils.isTure(CollUtil.isNotEmpty(difference)).throwMessage(StrUtil.join(",", difference) + "在物料档案中不存在");
List<BomNewEbomParentEntity> existBomlist =SpringUtil.getBean(MaterialMainService.class).lambdaQuery().eq(BomNewEbomParentEntity::getMaterialNo, createDTO.getParent().getMaterialNo()).list();
QueryWrapper<BomNewEbomParentEntity>
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<String> roleList = SpringUtil.getBean(UserRoleService.class).getUserPost();
//添加数据
if(dto.getParent().getRowId()==null){
}
if (dto.getParent() == null) {
for (BomNewEbomParentVO vo : dto.getDatas()) {