fix: 优化调整

This commit is contained in:
曹鹏飞 2024-06-29 11:04:21 +08:00
parent b4606483d6
commit f553ceff4d
7 changed files with 144 additions and 16 deletions

View File

@ -515,4 +515,15 @@ public class EbomApi extends BaseApi {
public ResultVO<BomNewEbomParentVO> merge(@Valid @RequestBody @NotEmpty List<Long> rowIds) {
return ResultVO.success(bomNewEbomParentService.merge(rowIds));
}
/**
* 检查下级是否存在Q项
* @param bomRowIds bomRowIds
* @return 检查结果
*/
@PostMapping("checkQ")
@ApiOperation("检查下级是否存在Q项")
public ResultVO<List<CheckBomQVO>> checkQ(@Valid @RequestBody @NotEmpty List<Long> bomRowIds) {
return ResultVO.success(bomNewEbomParentService.checkQ(bomRowIds));
}
}

View File

@ -130,8 +130,9 @@ public class PBomApi extends BaseApi {
@GetMapping("getChild")
@ApiOperation("获取子级")
public ResultVO<List<BomNewPbomParentVO>> getChild(@RequestParam("bomRowId") Long bomRowId){
return ResultVO.success(bomNewPbomParentService.getChild(bomRowId));
public ResultVO<List<BomNewPbomParentVO>> getChild(@RequestParam("bomRowId") Long bomRowId
, @Valid @RequestParam("type") @NotNull Integer type) {
return ResultVO.success(bomNewPbomParentService.getChild(bomRowId, type));
}
@PostMapping("editStaging")

View File

@ -0,0 +1,30 @@
package com.nflg.product.bomnew.pojo.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @author 曹鹏飞
* @date 2024/6/28 15:03:25
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "com-nflg-product-bomnew-pojo-original-vo-CheckBomQVO")
public class CheckBomQVO implements Serializable {
/**
* bom行id
*/
@ApiModelProperty(value = "bom行id")
private Long bomRowId;
/**
* 下级是否存在Q项
*/
@ApiModelProperty(value = "下级是否存在Q项")
private Boolean exists;
}

View File

@ -346,7 +346,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).filter(StrUtil::isNotBlank).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewEbomParentEntity> list = this.lambdaQuery().in(BomNewEbomParentEntity::getMaterialNo, materialNos)
.eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getLastVersionIs, 1)
// .eq(!EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getLastVersionIs, 1)
.eq(EBomStatusEnum.PUBLISHED.equalsValue(parent.getStatus()), BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue()).list();
// if (EBomStatusEnum.CHECKED.equalsValue(parent.getStatus())) {
// list = list.stream().filter(u -> EBomStatusEnum.CHECKED.equalsValue(u.getStatus())).collect(Collectors.toList());
@ -943,7 +943,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
}
//List<Long> bomRowIds = bomTree.stream().filter(u ->!EBomStatusEnum.PUBLISHED.equalsValue(u.getStatus()) && u.getBomRowId() > 0).map(u -> u.getBomRowId()).collect(Collectors.toList());
if (CollUtil.isNotEmpty(eBomToPBom.getAddEBomNew())) {
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), eBomToPBom.getAddEBomNew());
this.getBaseMapper().updateStateBatchByRowIds(EBomStatusEnum.PUBLISHED.getValue(), SessionUtil.getRealName(), eBomToPBom.getAddEBomNew());
//将历史已发布版-转移到正式历史表
eBomToFormal(eBomToPBom.getAddEBomNew(), eBomToPBom.getDelOldEBom() );
}
@ -1700,6 +1700,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
childList.addAll(getChild(v.getBomRowId(), 0));
});
}
materialMainService.intiMaterialInfo(childList, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
vo.setDatas(childList);
}
@ -2787,4 +2788,17 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public List<BomNewPbomParentVO> getReverseBoms(Long parentRowId) {
return baseMapper.getReverseBoms(parentRowId);
}
public List<CheckBomQVO> checkQ(List<Long> bomRowIds) {
List<BomNewEbomChildEntity> children = ebomChildService.lambdaQuery()
.in(BomNewEbomChildEntity::getParentRowId, bomRowIds)
.list();
return bomRowIds.stream().map(bomRowId -> {
CheckBomQVO vo = new CheckBomQVO();
vo.setBomRowId(bomRowId);
vo.setExists(children.stream().anyMatch(c -> c.getParentRowId().equals(bomRowId)
&& StrUtil.equals(c.getProjectType(), ProjectTypeInputTypeEnum.ProjectTypeEnum.TYPE_Q.getValue())));
return vo;
}).collect(Collectors.toList());
}
}

View File

@ -63,6 +63,8 @@ public class BomNewEbomUpgradeChangeService extends ServiceImpl<BomNewEbomUpgrad
ent.setUpdatedTime(LocalDateTime.now());
this.updateById(ent);
IBomNewPbomExportToSAP service = new BomNewPbomExportToSAPImpl(true);
service.exportFromZFB(ent.getMaterialNo(), ent.getFacCode());
}

View File

@ -261,11 +261,12 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream());
}
public List<BomNewPbomParentVO> getChild(Long rowId) {
public List<BomNewPbomParentVO> getChild(Long rowId, Integer type) {
VUtils.isTure(rowId == 0).throwMessage("参数不正确");
return getChild(this.getById(rowId));
return getChild(this.getById(rowId), type);
}
public List<BomNewPbomParentVO> getChild(BomNewPbomParentEntity parent) {
public List<BomNewPbomParentVO> getChild(BomNewPbomParentEntity parent, Integer type) {
//List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
//BomNewPbomParentEntity parent = this.getById(rowId);
List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(parent.getRowId());
@ -316,7 +317,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setVirtualPackageIs(parentEntity.getVirtualPackageIs());
child.setTechnologyUserCode(parentEntity.getTechnologyUserCode());
child.setTechnologyUserName(parentEntity.getTechnologyUserName());
if (parent.getStatus() < PBomStatusEnum.PUBLISH.getValue() && parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) {
if ((type == 0 || parent.getStatus() < PBomStatusEnum.PUBLISH.getValue())
&& parentEntity.getStatus() >= PBomStatusEnum.PUBLISH.getValue()) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
}
} else { //无BOM-版本时 确定版本号
@ -334,6 +336,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
if (type == 0 && child.getStatus() >= EBomStatusEnum.PUBLISHED.getValue()) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
}
}
child.setSapOrderNum(BomUtil.generateSapOrderNum(child.getProjectType(), child.getMaterialCategoryCode()
, child.getFacCode(), child.getMaterialNo(), child.getBomExist()));
@ -370,7 +375,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
this.updateById(parent);
if (editStatus == PBomEditStatusEnum.HANDLER_TEMP) {
return getChild(parent);
return getChild(parent, 0);
} else {
return null;
}
@ -473,7 +478,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void editExport(Long bomRowId, HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
BomNewPbomParentEntity parent = this.getById(bomRowId);
List<BomNewPbomParentVO> child = this.getChild(parent);
List<BomNewPbomParentVO> child = this.getChild(parent, 0);
List<BomNewPbomEditExcelVO> result = Convert.toList(BomNewPbomEditExcelVO.class, child);
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream());
@ -483,7 +488,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void editExportV2(PBomEditExportParamDTO param, HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
BomNewPbomParentEntity parent = this.getById(param.getBomRowId());
List<BomNewPbomParentVO> child = this.getChild(parent);
List<BomNewPbomParentVO> child = this.getChild(parent, 0);
if (CollUtil.isNotEmpty(param.getRowIds())) {
child = child.stream().filter(u -> param.getRowIds().contains(u.getRowId())).collect(Collectors.toList());
}
@ -531,13 +536,14 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
toM.setMaterialDesc(materialDesc);
toM.setMaterialCategoryCode("201201");
toM.setProjectType(packageParam.getProjectType());
toM.setMaterialGetType(1);
Map<String, AddVirtrualMaterialDTO> mMap = materialService.batchAddMaterial(ImmutableList.of(toM));
// String materialNo = materialService.addMaterial(drawingNo, materialName, materialDesc, "201201");
String materialNo = mMap.get(key).getMaterialNo();
BaseMaterialVO resultD = materialMainService.getMaterialBaseInfo(ImmutableList.of(materialNo)).get(0);
//插入工艺包
packageParam.setTechnologyPackageMaterialNo(materialNo);
insertTechnologyPackage(packageParam, result);
insertTechnologyPackage(packageParam);
return resultD;
}
@ -552,18 +558,25 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
}
@Transactional(rollbackFor = Exception.class)
public void insertTechnologyPackage(TechnologyPackageParam technologyPackageParam) {
insertTechnologyPackage(technologyPackageParam, getVO(technologyPackageParam));
VUtils.isTure(StrUtil.isBlank(technologyPackageParam.getTechnologyPackageMaterialNo()))
.throwMessage("物料编号不能为空");
List<BaseMaterialVO> materialVOS = materialMainService.getMaterialBaseInfo(ImmutableList.of(technologyPackageParam.getTechnologyPackageMaterialNo()));
VUtils.isTure(CollUtil.isEmpty(materialVOS)).throwMessage("未找到物料信息");
insertTechnologyPackage(technologyPackageParam, materialVOS.get(0));
}
@Transactional(rollbackFor = Exception.class)
public void insertTechnologyPackage(TechnologyPackageParam technologyPackageParam, BomNewPbomParentVO vo) {
public void insertTechnologyPackage(TechnologyPackageParam technologyPackageParam, BaseMaterialVO vo) {
VUtils.isTure(StrUtil.isBlank(technologyPackageParam.getTechnologyPackageMaterialNo())).throwMessage("工艺包物料编码不能为空");
VUtils.isTure(CollUtil.isEmpty(technologyPackageParam.getRowIds())).throwMessage("请选择要插入工艺包的物料");
if (technologyPackageParam.getRowIds().size() == 1 && Objects.isNull(technologyPackageParam.getLevelBelong())) {
throw new NflgBusinessException(STATE.BusinessError, "单条物料时,请选择上下级");
}
VUtils.isTure(StrUtil.isBlank(vo.getMaterialCategoryCode())).throwMessage("物料分类代码不能为空");
VUtils.isTure(!StrUtil.equals(vo.getMaterialCategoryCode(), MaterialMainConstant.CATEGORYCODE_TECHNOLOGYPACKAGE))
.throwMessage("该物料不是工艺包");
if (vo.getMaterialCategoryCode().startsWith("10")) {
//工艺包只能添加到上级
VUtils.isTure(!Objects.equals(technologyPackageParam.getLevelBelong(), 0)).throwMessage("10分类开头的物料工艺包只能添加到上级");

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.service.domain.PBom;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@ -71,8 +72,20 @@ public class TechnologyPackageParamBuilder {
}
else { //虚拟包作为下级
BomNewPbomParentEntity childParent = buildParentByChild(children.get(0));
buildPbomChildForTechnologyPackage(childParent);
BomNewPbomChildEntity gc = buildPbomChildForTechnologyPackage(childParent);
this.packageParent.add(childParent);
//将选中物料的下级移动到工艺包下去
List<BomNewPbomChildEntity> cpcs = SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery()
.eq(BomNewPbomChildEntity::getParentRowId, childParent.getRowId())
.list();
if (CollUtil.isNotEmpty(cpcs)) {
BomNewPbomParentEntity gp = buildParentForTechnologyPackage(gc);
cpcs.forEach(it -> {
it.setParentRowId(gp.getRowId());
it.setModifyTime(LocalDateTime.now());
});
this.packageChildren.addAll(cpcs);
}
}
@ -87,6 +100,8 @@ public class TechnologyPackageParamBuilder {
.eq(BomNewPbomParentEntity::getLastVersionIs, 1)
.one();
if(Objects.nonNull(oldBom)){
VUtils.isTure(oldBom.getStatus() >= PBomStatusEnum.PUBLISH.getValue())
.throwMessage("不能添加工艺包到借用件下级");
return oldBom;
}
BomNewPbomParentEntity newBom=new BomNewPbomParentEntity();
@ -156,7 +171,48 @@ public class TechnologyPackageParamBuilder {
}
private void buildPbomChildForTechnologyPackage(BomNewPbomParentEntity parent){
private BomNewPbomParentEntity buildParentForTechnologyPackage(BomNewPbomChildEntity child) {
BomNewPbomParentEntity oldBom = SpringUtil.getBean(BomNewPbomParentService.class)
.lambdaQuery().eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo())
.eq(BomNewPbomParentEntity::getFacCode, parent.getFacCode())
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
.last(" limit 1")
.one();
VUtils.isTure(Objects.nonNull(oldBom) && oldBom.getStatus() < PBomStatusEnum.PUBLISH.getValue())
.throwMessage("该工艺包存在未发布的BOM版本");
BomNewPbomParentEntity newBom = new BomNewPbomParentEntity();
newBom.setRowId(IdWorker.getId());
newBom.setDrawingNo(child.getDrawingNo());
newBom.setFacCode(parent.getFacCode());
newBom.setMaterialNo(child.getMaterialNo());
newBom.setMaterialName(child.getMaterialName());
newBom.setMaterialDesc(child.getMaterialDesc());
newBom.setMaterialTexture(child.getMaterialTexture());
newBom.setMaterialUnit(child.getMaterialUnit());
newBom.setNum(new BigDecimal(1));
newBom.setProjectType(child.getProjectType());
newBom.setBomExist(1);
newBom.setLastVersionIs(1);
newBom.setCurrentVersion(Objects.isNull(oldBom) ? VersionUtil.getNextVersion("") : VersionUtil.getNextVersion(oldBom.getCurrentVersion()));
newBom.setDeviseUserCode(SessionUtil.getUserCode());
newBom.setDeviseName(SessionUtil.getRealName());
newBom.setDeptName(SessionUtil.getDepartName());
newBom.setDeptRowId(SessionUtil.getDepartRowId());
newBom.setCreatedBy(SessionUtil.getUserCode());
newBom.setCreatedTime(LocalDateTime.now());
newBom.setTechnologyUserCode(SessionUtil.getUserCode());
newBom.setTechnologyUserName(SessionUtil.getUserName());
newBom.setSourceRowId(0L);
if (Objects.nonNull(oldBom)) {
oldBom.setLastVersionIs(0);
SpringUtil.getBean(BomNewPbomParentService.class).updateById(oldBom);
}
this.packageParent.add(newBom);
return newBom;
}
private BomNewPbomChildEntity buildPbomChildForTechnologyPackage(BomNewPbomParentEntity parent) {
BomNewPbomChildEntity child = new BomNewPbomChildEntity();
List<BomNewPbomChildEntity> parentChildren =SpringUtil.getBean(BomNewPbomChildService.class).lambdaQuery().eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId()).list();
child.setRowId(IdWorker.getId());
@ -177,5 +233,6 @@ public class TechnologyPackageParamBuilder {
child.setModifyTime(LocalDateTime.now());
child.setSourceRowId(0L);
this.packageChildren.add(child);
return child;
}
}