Merge remote-tracking branch 'origin/feature/DM/nflg-bom' into feature/DM/nflg-bom

This commit is contained in:
大米 2023-12-23 19:01:43 +08:00
commit d94a6653d8
6 changed files with 272 additions and 115 deletions

View File

@ -171,19 +171,28 @@ public class EbomApi extends BaseApi {
new Workbook("eBom-create-template", "").addSheet(new ListSheet<>("sheet1", ImmutableList.of(new BomNewEBomImportExcelDTO()))).writeTo(response.getOutputStream()); new Workbook("eBom-create-template", "").addSheet(new ListSheet<>("sheet1", ImmutableList.of(new BomNewEBomImportExcelDTO()))).writeTo(response.getOutputStream());
} }
@GetMapping("createBomImport") // @PostMapping("createBomImport")
// @ApiOperation("创建EBOM-导入")
// public ResultVO<List<BomNewEBomImportExcelDTO>> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException {
// if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
// return ResultVO.error("请上传Excel文件");
// }
// List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(dto.getFile().getInputStream(), BomNewEBomImportExcelDTO.class);
//
//
// materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo);
// return ResultVO.success(result);
// }
@PostMapping("createBomImport")
@ApiOperation("创建EBOM-导入") @ApiOperation("创建EBOM-导入")
public ResultVO<List<BomNewEBomImportExcelDTO>> createBomImport(@RequestParam(value = "file") MultipartFile file) throws IOException { public ResultVO<Boolean> createBomImport(@ModelAttribute BomNewEbomImportDTO dto) throws IOException {
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) { if (dto.getFile() != null && !dto.getFile().getOriginalFilename().endsWith("xls") && !dto.getFile().getOriginalFilename().endsWith("xlsx")) {
return ResultVO.error("请上传Excel文件"); return ResultVO.error("请上传Excel文件");
} }
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(file.getInputStream(), BomNewEBomImportExcelDTO.class); bomNewEbomParentService.createBomImport(dto,dto.getFile().getInputStream());
return ResultVO.success(true);
materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo);
return ResultVO.success(result);
} }
@PostMapping("createBom") @PostMapping("createBom")
@ApiOperation("创建BOM") @ApiOperation("创建BOM")
public ResultVO<Boolean> createBom(@RequestBody BomNewEBomCreateDTO createDTO) { public ResultVO<Boolean> createBom(@RequestBody BomNewEBomCreateDTO createDTO) {
@ -232,6 +241,19 @@ public class EbomApi extends BaseApi {
return resultVO; return resultVO;
} }
@PostMapping("updateProjectType")
@ApiOperation("更新项目类型")
public ResultVO<Boolean> updateProjectType(@RequestBody BomNewEbomProjectTypeDTO dto) {
VUtils.isTure(StrUtil.isEmpty(dto.getProjectType())).throwMessage("项目类型不能为空");
VUtils.isTure(CollUtil.isEmpty(dto.getRowIdList())).throwMessage("选择要修改的数据");
bomNewEbomParentService.updateProjectType(dto);
return ResultVO.success(true);
}
@PostMapping("queryMaterial") @PostMapping("queryMaterial")
@ApiOperation("查询物料信息") @ApiOperation("查询物料信息")

View File

@ -25,4 +25,18 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum<Integer> {
private final Integer value; private final Integer value;
private final String description; private final String description;
@Getter
@AllArgsConstructor
public enum ProjectTypeEnum implements ValueEnum<String> {
TYPE_Q("Q", "Q"),
TYPE_F("F", "F");
private final String value;
private final String description;
}
} }

View File

@ -0,0 +1,24 @@
package com.nflg.product.bomnew.pojo.dto;
import com.nflg.product.bomnew.constant.EBomSourceEnum;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
@Data
public class BomNewEbomImportDTO {
@ApiModelProperty("excel文件")
private MultipartFile file;
@ApiModelProperty("物料数据")
private BomNewEbomParentVO parent;
@ApiModelProperty("操作类型(1:删除 2:追加)")
private Integer opType;
@ApiModelProperty("忽略")
private Integer source= EBomSourceEnum.FROM_EXCE.getValue();
}

View File

@ -0,0 +1,22 @@
package com.nflg.product.bomnew.pojo.dto;
import com.nflg.product.bomnew.constant.EBomSourceEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
@ApiModel(value = "com-nflg-product-bomnew-pojo-new-dto-BomNewEbomProjectTypeDTO")
public class BomNewEbomProjectTypeDTO {
@ApiModelProperty("行rowId")
private List<Long> rowIdList;
@ApiModelProperty("项目类型")
private String projectType;
}

View File

@ -7,9 +7,11 @@ import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -40,6 +42,7 @@ import org.ttzero.excel.entity.ListSheet;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
@ -145,8 +148,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/** /**
* 获取物料所有父节点 * 获取物料所有父节点
* *
@ -352,20 +353,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 初始化bom 异常信息 * 初始化bom 异常信息
*
* @param list * @param list
*/ */
public void initBomException (List<BomNewEbomParentVO> list){ public void initBomException(List<BomNewEbomParentVO> list) {
CheckEBomException checkEBomException=new CheckEBomException(list); CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.initException(); checkEBomException.initException();
} }
/** /**
* 初始化bom 异常信息 * 初始化bom 异常信息
*
* @param bomRowId bom行ID * @param bomRowId bom行ID
*/ */
public void initBomException (Long bomRowId) throws ExecutionException, InterruptedException { public void initBomException(Long bomRowId) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId); CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
checkEBomException.initException(); checkEBomException.initException();
} }
@ -373,40 +376,39 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
* 检查 并保存异常信息 * 检查 并保存异常信息
*/ */
public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException { public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId); CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
checkEBomException.initException(); checkEBomException.initException();
List<BomNewEbomParentVO> allBomDetail = checkEBomException.getAllBomDetail(); List<BomNewEbomParentVO> allBomDetail = checkEBomException.getAllBomDetail();
//父级 //父级
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList()); List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) { if (CollUtil.isNotEmpty(parents)) {
List<BomNewEbomParentEntity> pentList=new ArrayList<>(); List<BomNewEbomParentEntity> pentList = new ArrayList<>();
parents.forEach(k->{ parents.forEach(k -> {
BomNewEbomParentEntity pEnt=new BomNewEbomParentEntity(); BomNewEbomParentEntity pEnt = new BomNewEbomParentEntity();
pEnt.setRowId(k.getBomRowId()); pEnt.setRowId(k.getBomRowId());
pEnt.setExceptionStatus(k.getExceptionStatus()); pEnt.setExceptionStatus(k.getExceptionStatus());
pentList.add(pEnt); pentList.add(pEnt);
}); });
if(CollUtil.isNotEmpty(pentList)){ if (CollUtil.isNotEmpty(pentList)) {
this.updateBatchById(pentList); this.updateBatchById(pentList);
} }
} }
//子级 //子级
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getRowId() > 0).collect(Collectors.toList()); List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getRowId() > 0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) { if (CollUtil.isNotEmpty(parents)) {
List<BomNewEbomChildEntity> childList=new ArrayList<>(); List<BomNewEbomChildEntity> childList = new ArrayList<>();
parents.forEach(k->{ parents.forEach(k -> {
BomNewEbomChildEntity pEnt=new BomNewEbomChildEntity(); BomNewEbomChildEntity pEnt = new BomNewEbomChildEntity();
pEnt.setRowId(k.getRowId()); pEnt.setRowId(k.getRowId());
pEnt.setExceptionStatus(k.getExceptionStatus()); pEnt.setExceptionStatus(k.getExceptionStatus());
childList.add(pEnt); childList.add(pEnt);
}); });
if(CollUtil.isNotEmpty(childList)){ if (CollUtil.isNotEmpty(childList)) {
ebomChildService.updateBatchById(childList); ebomChildService.updateBatchById(childList);
} }
} }
} }
@ -478,21 +480,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 发起变更 * 发起变更
*
* @param bomRowIds * @param bomRowIds
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void upgradeChanges(List<Long> bomRowIds){ public void upgradeChanges(List<Long> bomRowIds) {
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, bomRowIds).list(); List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getRowId, bomRowIds).list();
List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList()); List<String> notConvertToPbom = list.stream().filter(u -> u.getStatus() < EBomStatusEnum.PUBLISHED.getValue()).map(u -> u.getMaterialNo()).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom)+"未转PBom,不能发起变更"); VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更");
List<BomNewEbomParentEntity> parentResult=new ArrayList<>(); List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
List<BomNewEbomChildEntity> childResult=new ArrayList<>(); List<BomNewEbomChildEntity> childResult = new ArrayList<>();
for (Long bomRowId : bomRowIds) { for (Long bomRowId : bomRowIds) {
BomNewEbomParentEntity parent = this.getById(bomRowId); BomNewEbomParentEntity parent = this.getById(bomRowId);
List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list(); List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list();
BomNewEbomParentEntity newParent=new BomNewEbomParentEntity(); BomNewEbomParentEntity newParent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent,newParent); BeanUtil.copyProperties(parent, newParent);
newParent.setRowId(IdWorker.getId()); newParent.setRowId(IdWorker.getId());
newParent.setLastVersionIs(1); newParent.setLastVersionIs(1);
newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion())); newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion()));
@ -501,19 +504,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parentResult.add(newParent); parentResult.add(newParent);
parentResult.add(parent); parentResult.add(parent);
for (BomNewEbomChildEntity childEnt :child) { for (BomNewEbomChildEntity childEnt : child) {
BomNewEbomChildEntity newChild=new BomNewEbomChildEntity(); BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
BeanUtil.copyProperties(childEnt,newChild); BeanUtil.copyProperties(childEnt, newChild);
newChild.setRowId(IdWorker.getId()); newChild.setRowId(IdWorker.getId());
newChild.setParentRowId(newParent.getRowId()); newChild.setParentRowId(newParent.getRowId());
childResult.add(newChild); childResult.add(newChild);
} }
} }
if(CollUtil.isNotEmpty(parentResult)){ if (CollUtil.isNotEmpty(parentResult)) {
this.saveOrUpdateBatch(parentResult); this.saveOrUpdateBatch(parentResult);
} }
if(CollUtil.isNotEmpty(childResult)){ if (CollUtil.isNotEmpty(childResult)) {
ebomChildService.saveOrUpdateBatch(childResult); ebomChildService.saveOrUpdateBatch(childResult);
} }
@ -532,13 +535,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}; };
EecExcelUtil.eecExcel("bom列表", listSheet, response); EecExcelUtil.eecExcel("bom列表", listSheet, response);
} }
/** /**
* 计算BOM树高度 * 计算BOM树高度
* *
* @param * @param
*/ */
public boolean compucteLevelNum() throws ExecutionException, InterruptedException { public boolean compucteLevelNum() throws ExecutionException, InterruptedException {
List<BomNewEbomParentEntity> list = this.lambdaQuery().le(BomNewEbomParentEntity ::getLevelNum, 0).list(); List<BomNewEbomParentEntity> list = this.lambdaQuery().le(BomNewEbomParentEntity::getLevelNum, 0).list();
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
for (BomNewEbomParentEntity bom : list) { for (BomNewEbomParentEntity bom : list) {
@ -568,12 +572,30 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
this.compucteLevelNum(); this.compucteLevelNum();
} catch (Exception e) { } catch (Exception e) {
log.info("计算层级出错:"+e.getMessage()); log.info("计算层级出错:" + e.getMessage());
} }
// }); // });
} }
@Transactional(rollbackFor = Exception.class)
public void createBomImport(BomNewEbomImportDTO dto, InputStream inputStream) throws IOException {
List<BomNewEBomImportExcelDTO> result = EecExcelUtil.getExcelContext(inputStream, BomNewEBomImportExcelDTO.class);
List<BomNewEbomParentVO> datas = Convert.convert(new TypeReference<List<BomNewEbomParentVO>>() {
}, result);
materialMainService.intiMaterialInfo(datas, BomNewEbomParentVO::getMaterialNo);
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_EXCE.getValue());
BomNewEBomParentEditDTO bomNewEBomParentEditDTO=new BomNewEBomParentEditDTO();
bomNewEBomParentEditDTO.setParent(dto.getParent());
bomNewEBomParentEditDTO.setDatas(datas);
eBomEdit.temporary(bomNewEBomParentEditDTO);
}
/** /**
@ -846,44 +868,71 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
/**
* 更新项目类型
* @return
*/
public Boolean updateProjectType(BomNewEbomProjectTypeDTO dto ){
List<BomNewEbomChildEntity> childEntity=new ArrayList<>();
dto.getRowIdList().forEach(rowid->{
BomNewEbomChildEntity entity=new BomNewEbomChildEntity();
entity.setRowId(rowid);
entity.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
entity.setProjectType(dto.getProjectType());
entity.setModifyTime(LocalDateTime.now());
});
SpringUtil.getBean(BomNewEbomChildService.class).updateBatchById(childEntity);
return true;
}
public BomNewEbomEditDetailVO editDetail(Long bomRowId) { public BomNewEbomEditDetailVO editDetail(Long bomRowId) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO(); BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
List<BomNewEbomParentVO> parentList = new ArrayList<>(); BomNewEbomParentEntity parent= this.getById(bomRowId);
parentList.add(parentVO);
materialMainService.intiMaterialInfo(parentList); BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class,parent);
parentVO.setBomRowId(parentVO.getRowId());
// List<BomNewEbomParentVO> parentList = new ArrayList<>();
// parentList.add(parentVO);
// materialMainService.intiMaterialInfo(parentList);
//
vo.setDatas(getChild(bomRowId)); vo.setDatas(getChild(bomRowId));
vo.setParent(parentList.get(0)); vo.setParent(parentVO);
return vo; return vo;
} }
public BomNewEbomParentVO queryMaterial(BomNewEbomMaterialQuery query) { public BomNewEbomParentVO queryMaterial(BomNewEbomMaterialQuery query) {
List<MaterialMainEntity> materialMainList=null; List<MaterialMainEntity> materialMainList = null;
if (StringUtils.isNotEmpty(query.getMaterialNo())) { if (StringUtils.isNotEmpty(query.getMaterialNo())) {
materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, query.getMaterialNo()).list(); materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, query.getMaterialNo()).list();
if (CollUtil.isEmpty(materialMainList)) { if (CollUtil.isEmpty(materialMainList)) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 物料编码的物料信息不存在",query.getMaterialNo())); throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 物料编码的物料信息不存在", query.getMaterialNo()));
} }
if (CollUtil.isNotEmpty(materialMainList) && materialMainList.size() > 1) { if (CollUtil.isNotEmpty(materialMainList) && materialMainList.size() > 1) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在{}多条相同物料编码的物料信息",query.getMaterialNo())); throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在{}多条相同物料编码的物料信息", query.getMaterialNo()));
} }
}else if (StringUtils.isNotEmpty(query.getDrawingNo())) { } else if (StringUtils.isNotEmpty(query.getDrawingNo())) {
materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list(); materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getDrawingNo, query.getDrawingNo()).list();
if (CollUtil.isEmpty(materialMainList)) { if (CollUtil.isEmpty(materialMainList)) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 图号的物料信息不存在",query.getDrawingNo())); throw new NflgBusinessException(STATE.Error, StrUtil.format("{} 图号的物料信息不存在", query.getDrawingNo()));
} }
if (CollUtil.isNotEmpty(materialMainList) && materialMainList.size() > 1) { if (CollUtil.isNotEmpty(materialMainList) && materialMainList.size() > 1) {
throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在多条 {} 图号的物料信息",query.getDrawingNo())); throw new NflgBusinessException(STATE.Error, StrUtil.format("同时存在多条 {} 图号的物料信息", query.getDrawingNo()));
} }
} }
if(CollUtil.isNotEmpty(materialMainList)){ if (CollUtil.isNotEmpty(materialMainList)) {
MaterialMainEntity materialMainEntity = materialMainList.get(0); MaterialMainEntity materialMainEntity = materialMainList.get(0);
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO(); BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
BeanUtil.copyProperties(materialMainEntity, baseMaterialVO); BeanUtil.copyProperties(materialMainEntity, baseMaterialVO);
@ -894,11 +943,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
throw new NflgBusinessException(STATE.Error, "未查询到相关物料信息"); throw new NflgBusinessException(STATE.Error, "未查询到相关物料信息");
} }
public Boolean deleteMaterial(Long bomRowId) throws ExecutionException, InterruptedException { public Boolean deleteMaterial(Long bomRowId) throws ExecutionException, InterruptedException {
@ -911,7 +956,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId); List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
List<BomNewEbomParentVO> delBom=null; List<BomNewEbomParentVO> delBom = null;
if (userRoleService.designer()) { if (userRoleService.designer()) {
delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0 delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0
&& u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) && u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
@ -919,7 +964,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
if(CollUtil.isNotEmpty(delBom)) { if (CollUtil.isNotEmpty(delBom)) {
List<Long> delParentRowId = new ArrayList<>(); List<Long> delParentRowId = new ArrayList<>();
for (BomNewEbomParentVO bom : delBom) { for (BomNewEbomParentVO bom : delBom) {
@ -937,24 +982,24 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 暂存 * 暂存
* * <p>
* 用户临时处理数据数据的处理状态为待处理当用户单击暂存的时候所有的数据都不需要校验直接保存即可 * 用户临时处理数据数据的处理状态为待处理当用户单击暂存的时候所有的数据都不需要校验直接保存即可
*/ */
public Boolean temporary(BomNewEBomParentEditDTO dto){ public Boolean temporary(BomNewEBomParentEditDTO dto) {
EBomEdit eBomEdit=new EBomEdit(); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto); eBomEdit.temporary(dto);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){ if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities ); this.saveOrUpdateBatch(eBomEdit.parentEntities);
} }
if(CollUtil.isNotEmpty(eBomEdit.childEntities)){ if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
} }
if(dto.getParent()!=null){ if (dto.getParent() != null) {
if(dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())){ if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {
if(CollUtil.isNotEmpty(dto.getDelDatas())) { if (CollUtil.isNotEmpty(dto.getDelDatas())) {
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
ebomChildService.removeByIds(rowIdList); ebomChildService.removeByIds(rowIdList);
@ -968,22 +1013,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/** /**
* 提交物料 * 提交物料
*/ */
public Boolean submit(BomNewEBomParentEditDTO dto){ public Boolean submit(BomNewEBomParentEditDTO dto) {
EBomEdit eBomEdit=new EBomEdit(); EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto); eBomEdit.temporary(dto);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){ if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities ); this.saveOrUpdateBatch(eBomEdit.parentEntities);
} }
if(CollUtil.isNotEmpty(eBomEdit.childEntities)){ if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities); ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
} }
if(dto.getParent()!=null){ if (dto.getParent() != null) {
if(dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())){ || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {
if(CollUtil.isNotEmpty(dto.getDelDatas())) { if (CollUtil.isNotEmpty(dto.getDelDatas())) {
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList()); List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
ebomChildService.removeByIds(rowIdList); ebomChildService.removeByIds(rowIdList);

View File

@ -9,12 +9,10 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.base.core.conmon.util.SessionUtil;
import com.nflg.product.bomnew.constant.EBomSourceEnum; import com.nflg.product.bomnew.constant.*;
import com.nflg.product.bomnew.constant.EBomStatusEnum;
import com.nflg.product.bomnew.constant.EbomEditStatusEnum;
import com.nflg.product.bomnew.constant.ProjectTypeInputTypeEnum;
import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO; import com.nflg.product.bomnew.pojo.dto.BomNewEBomParentEditDTO;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomChildEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
@ -23,8 +21,10 @@ import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigVO; import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigVO;
import com.nflg.product.bomnew.service.BomNewEbomParentService; import com.nflg.product.bomnew.service.BomNewEbomParentService;
import com.nflg.product.bomnew.service.MaterialMainService; 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.ListCommonUtil;
import com.nflg.product.bomnew.util.VUtils; import com.nflg.product.bomnew.util.VUtils;
import io.swagger.models.auth.In;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -37,8 +37,16 @@ public class EBomEdit {
public List<BomNewEbomChildEntity> childEntities; public List<BomNewEbomChildEntity> childEntities;
Integer source;
public EBomEdit(Integer source){
this.source=source;
}
BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) { BomNewEbomParentEntity createParentBomInfo(BomNewEbomParentVO vo) {
BomNewEbomParentEntity parent = new BomNewEbomParentEntity(); BomNewEbomParentEntity parent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, vo); BeanUtil.copyProperties(parent, vo);
@ -51,20 +59,26 @@ public class EBomEdit {
// parent.setMaterialName(material.getMaterialName()); // parent.setMaterialName(material.getMaterialName());
// parent.setMaterialDesc(material.getMaterialDesc()); // parent.setMaterialDesc(material.getMaterialDesc());
// parent.setMaterialTexture(material.getMaterial()); // parent.setMaterialTexture(material.getMaterial());
parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum()); // parent.setNum(vo.getNum() == null ? new BigDecimal(1) : vo.getNum());
parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum())); parent.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum()));
parent.setDeviseUserCode(SessionUtil.getUserCode()); parent.setDeviseUserCode(SessionUtil.getUserCode());
parent.setCurrentVersion("A00"); parent.setCurrentVersion("A00");
parent.setDeviseName(SessionUtil.getRealName()); parent.setDeviseName(SessionUtil.getRealName());
parent.setDeptName(SessionUtil.getDepartName()); parent.setDeptName(SessionUtil.getDepartName());
parent.setSourceRowId(0l);
parent.setSource(EBomSourceEnum.FROM_MDM.getValue()); parent.setSource(source);
parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue()); parent.setStatus(EBomStatusEnum.WAIT_CHECK.getValue());
parent.setBomExist(1); parent.setBomExist(1);
parent.setLastVersionIs(1); parent.setLastVersionIs(1);
parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); parent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.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());
return parent; return parent;
} }
@ -114,24 +128,40 @@ public class EBomEdit {
for (BomNewEbomChildEntity child : for (BomNewEbomChildEntity child :
childEntities) { childEntities) {
child.setRowId(IdWorker.getId());
child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
//child.setProjectTypeInputType(ProjectTypeInputTypeEnum.MANUAL_INPUT.getValue());
child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum())); child.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
//新增数据 //新增数据
if(child.getRowId()==null || child.getRowId().longValue()==0){ if(child.getRowId()==null || child.getRowId().longValue()==0){
child.setRowId(IdWorker.getId());
child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId())); child.setIdentityNo(StrUtil.join("-", parent.getRowId(), parent.getRowId()));
child.setSource(EBomSourceEnum.FROM_MDM.getValue()); child.setSource(source);
child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue()); child.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
child.setCreatedTime(LocalDateTime.now()); child.setCreatedTime(LocalDateTime.now());
child.setCreatedBy(SessionUtil.getUserCode()); child.setCreatedBy(SessionUtil.getUserCode());
child.setSourceRowId(0l);
} }
parent.setTotalWeight(NumberUtil.mul(child.getUnitWeight(), child.getNum()));
child.setParentRowId(parent.getRowId()); child.setParentRowId(parent.getRowId());
VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同"); if(StrUtil.isEmpty(child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
}
if(StrUtil.isNotEmpty(parent.getProjectType()) && StrUtil.containsAny(parent.getProjectType(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue())){
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue(),child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_9.getValue());
}
if(StrUtil.equals(ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_F.getValue(),child.getProjectType())){
child.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_10.getValue());
}
}
// VUtils.isTure(parent.getProjectType().equals(child.getProjectType())).throwMessage("父、子级项目类型不能相同");
} }
} }