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());
}
@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-导入")
public ResultVO<List<BomNewEBomImportExcelDTO>> createBomImport(@RequestParam(value = "file") MultipartFile file) throws IOException {
if (file != null && !file.getOriginalFilename().endsWith("xls") && !file.getOriginalFilename().endsWith("xlsx")) {
public ResultVO<Boolean> 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(file.getInputStream(), BomNewEBomImportExcelDTO.class);
materialMainService.intiMaterialInfo(result, BomNewEBomImportExcelDTO::getMaterialNo);
return ResultVO.success(result);
bomNewEbomParentService.createBomImport(dto,dto.getFile().getInputStream());
return ResultVO.success(true);
}
@PostMapping("createBom")
@ApiOperation("创建BOM")
public ResultVO<Boolean> createBom(@RequestBody BomNewEBomCreateDTO createDTO) {
@ -232,6 +241,19 @@ public class EbomApi extends BaseApi {
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")
@ApiOperation("查询物料信息")

View File

@ -25,4 +25,18 @@ public enum ProjectTypeInputTypeEnum implements ValueEnum<Integer> {
private final Integer value;
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.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.lang.TypeReference;
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.toolkit.IdWorker;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -40,6 +42,7 @@ import org.ttzero.excel.entity.ListSheet;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.*;
@ -145,8 +148,6 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
/**
* 获取物料所有父节点
*
@ -352,61 +353,62 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 初始化bom 异常信息
*
* @param list
*/
public void initBomException (List<BomNewEbomParentVO> list){
CheckEBomException checkEBomException=new CheckEBomException(list);
public void initBomException(List<BomNewEbomParentVO> list) {
CheckEBomException checkEBomException = new CheckEBomException(list);
checkEBomException.initException();
}
/**
* 初始化bom 异常信息
*
* @param bomRowId bom行ID
*/
public void initBomException (Long bomRowId) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
public void initBomException(Long bomRowId) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
checkEBomException.initException();
}
/**
* 检查 并保存异常信息
*/
public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException=new CheckEBomException(bomRowId);
public void checkAndSaveEBomException(Long bomRowId) throws ExecutionException, InterruptedException {
CheckEBomException checkEBomException = new CheckEBomException(bomRowId);
checkEBomException.initException();
List<BomNewEbomParentVO> allBomDetail = checkEBomException.getAllBomDetail();
//父级
List<BomNewEbomParentVO> parents = allBomDetail.stream().filter(u -> u.getBomRowId() > 0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) {
List<BomNewEbomParentEntity> pentList=new ArrayList<>();
parents.forEach(k->{
BomNewEbomParentEntity pEnt=new BomNewEbomParentEntity();
List<BomNewEbomParentEntity> pentList = new ArrayList<>();
parents.forEach(k -> {
BomNewEbomParentEntity pEnt = new BomNewEbomParentEntity();
pEnt.setRowId(k.getBomRowId());
pEnt.setExceptionStatus(k.getExceptionStatus());
pentList.add(pEnt);
});
if(CollUtil.isNotEmpty(pentList)){
if (CollUtil.isNotEmpty(pentList)) {
this.updateBatchById(pentList);
}
}
//子级
List<BomNewEbomParentVO> child = allBomDetail.stream().filter(u -> u.getRowId() > 0).collect(Collectors.toList());
if (CollUtil.isNotEmpty(parents)) {
List<BomNewEbomChildEntity> childList=new ArrayList<>();
parents.forEach(k->{
BomNewEbomChildEntity pEnt=new BomNewEbomChildEntity();
List<BomNewEbomChildEntity> childList = new ArrayList<>();
parents.forEach(k -> {
BomNewEbomChildEntity pEnt = new BomNewEbomChildEntity();
pEnt.setRowId(k.getRowId());
pEnt.setExceptionStatus(k.getExceptionStatus());
childList.add(pEnt);
});
if(CollUtil.isNotEmpty(childList)){
if (CollUtil.isNotEmpty(childList)) {
ebomChildService.updateBatchById(childList);
}
}
}
@ -478,21 +480,22 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
/**
* 发起变更
*
* @param bomRowIds
*/
@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<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,不能发起变更");
List<BomNewEbomParentEntity> parentResult=new ArrayList<>();
List<BomNewEbomChildEntity> childResult=new ArrayList<>();
VUtils.isTure(CollUtil.isNotEmpty(notConvertToPbom)).throwMessage(StrUtil.join(",", notConvertToPbom) + "未转PBom,不能发起变更");
List<BomNewEbomParentEntity> parentResult = new ArrayList<>();
List<BomNewEbomChildEntity> childResult = new ArrayList<>();
for (Long bomRowId : bomRowIds) {
BomNewEbomParentEntity parent = this.getById(bomRowId);
List<BomNewEbomChildEntity> child = ebomChildService.lambdaQuery().eq(BomNewEbomChildEntity::getParentRowId, bomRowId).list();
BomNewEbomParentEntity newParent=new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent,newParent);
BomNewEbomParentEntity newParent = new BomNewEbomParentEntity();
BeanUtil.copyProperties(parent, newParent);
newParent.setRowId(IdWorker.getId());
newParent.setLastVersionIs(1);
newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion()));
@ -501,19 +504,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
parentResult.add(newParent);
parentResult.add(parent);
for (BomNewEbomChildEntity childEnt :child) {
BomNewEbomChildEntity newChild=new BomNewEbomChildEntity();
BeanUtil.copyProperties(childEnt,newChild);
for (BomNewEbomChildEntity childEnt : child) {
BomNewEbomChildEntity newChild = new BomNewEbomChildEntity();
BeanUtil.copyProperties(childEnt, newChild);
newChild.setRowId(IdWorker.getId());
newChild.setParentRowId(newParent.getRowId());
childResult.add(newChild);
}
}
if(CollUtil.isNotEmpty(parentResult)){
if (CollUtil.isNotEmpty(parentResult)) {
this.saveOrUpdateBatch(parentResult);
}
if(CollUtil.isNotEmpty(childResult)){
if (CollUtil.isNotEmpty(childResult)) {
ebomChildService.saveOrUpdateBatch(childResult);
}
@ -532,19 +535,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
};
EecExcelUtil.eecExcel("bom列表", listSheet, response);
}
/**
* 计算BOM树高度
*
* @param
*/
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)) {
for (BomNewEbomParentEntity bom : list) {
bom.setRootIs(1);
List<BomNewEbomParentVO> bomDetail = this.getBaseMapper().getParentChild(bom.getRowId());
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
EBomDetailTask detailTask = new EBomDetailTask(bomDetail);
detailTask.setLevelNum(1);
ForkJoinTask<List<BomNewEbomParentVO>> submit = bomDetailPool.submit(detailTask);
submit.get();
@ -568,12 +572,30 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
this.compucteLevelNum();
} 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,46 +868,73 @@ 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) {
BomNewEbomEditDetailVO vo = new BomNewEbomEditDetailVO();
BomNewEbomParentEntity parent = this.getBaseMapper().selectById(bomRowId);
BomNewEbomParentVO parentVO = Convert.convert(BomNewEbomParentVO.class, parent);
List<BomNewEbomParentVO> parentList = new ArrayList<>();
parentList.add(parentVO);
materialMainService.intiMaterialInfo(parentList);
BomNewEbomParentEntity parent= this.getById(bomRowId);
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.setParent(parentList.get(0));
vo.setParent(parentVO);
return vo;
}
public BomNewEbomParentVO queryMaterial(BomNewEbomMaterialQuery query) {
List<MaterialMainEntity> materialMainList=null;
List<MaterialMainEntity> materialMainList = null;
if (StringUtils.isNotEmpty(query.getMaterialNo())) {
materialMainList = materialMainService.lambdaQuery().eq(MaterialMainEntity::getMaterialNo, query.getMaterialNo()).list();
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) {
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();
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) {
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);
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
BomNewEbomParentVO baseMaterialVO = new BomNewEbomParentVO();
BeanUtil.copyProperties(materialMainEntity, baseMaterialVO);
baseMaterialVO.setExceptionStatus(materialMainEntity.getMaterialState());
@ -894,11 +943,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
throw new NflgBusinessException(STATE.Error, "未查询到相关物料信息");
}
}
public Boolean deleteMaterial(Long bomRowId) throws ExecutionException, InterruptedException {
@ -911,15 +956,15 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<BomNewEbomParentVO> bomTree = getBomTree(bomRowId);
List<BomNewEbomParentVO> delBom=null;
List<BomNewEbomParentVO> delBom = null;
if (userRoleService.designer()) {
delBom = bomTree.stream().filter(u -> u.getBomRowId() > 0
&& u.getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
&& EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))
&& EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()))
.collect(Collectors.toList());
}
if(CollUtil.isNotEmpty(delBom)) {
if (CollUtil.isNotEmpty(delBom)) {
List<Long> delParentRowId = new ArrayList<>();
for (BomNewEbomParentVO bom : delBom) {
@ -931,30 +976,59 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
return true;
return true;
}
/**
* 暂存
*
* 用户临时处理数据数据的处理状态为待处理当用户单击暂存的时候所有的数据都不需要校验直接保存即可
* <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);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
this.saveOrUpdateBatch(eBomEdit.parentEntities );
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if(CollUtil.isNotEmpty(eBomEdit.childEntities)){
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
if (dto.getParent() != null) {
if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {
if (CollUtil.isNotEmpty(dto.getDelDatas())) {
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
ebomChildService.removeByIds(rowIdList);
}
}
}
return true;
}
/**
* 提交物料
*/
public Boolean submit(BomNewEBomParentEditDTO dto) {
EBomEdit eBomEdit = new EBomEdit(EBomSourceEnum.FROM_MDM.getValue());
eBomEdit.temporary(dto);
if (CollectionUtil.isNotEmpty(eBomEdit.parentEntities)) {
this.saveOrUpdateBatch(eBomEdit.parentEntities);
}
if (CollUtil.isNotEmpty(eBomEdit.childEntities)) {
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
if(dto.getParent()!=null){
if(dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue()) || dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())){
if(CollUtil.isNotEmpty(dto.getDelDatas())) {
if (dto.getParent() != null) {
if (dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())) {
if (CollUtil.isNotEmpty(dto.getDelDatas())) {
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
ebomChildService.removeByIds(rowIdList);
@ -962,37 +1036,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
}
return true;
return true;
}
/**
* 提交物料
*/
public Boolean submit(BomNewEBomParentEditDTO dto){
EBomEdit eBomEdit=new EBomEdit();
eBomEdit.temporary(dto);
if(CollectionUtil.isNotEmpty(eBomEdit.parentEntities)){
this.saveOrUpdateBatch(eBomEdit.parentEntities );
}
if(CollUtil.isNotEmpty(eBomEdit.childEntities)){
ebomChildService.saveOrUpdateBatch(eBomEdit.childEntities);
}
if(dto.getParent()!=null){
if(dto.getParent().getSource().equals(EBomSourceEnum.FROM_MDM.getValue())
|| dto.getParent().getSource().equals(EBomSourceEnum.FROM_EXCE.getValue())){
if(CollUtil.isNotEmpty(dto.getDelDatas())) {
List<Long> rowIdList = dto.getDelDatas().stream().filter(u -> u.getRowId().longValue() > 0).map(BomNewEbomParentVO::getRowId).collect(Collectors.toList());
ebomChildService.removeByIds(rowIdList);
}
}
}
return true;
}
}

View File

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