Merge branch 'feature/DM/nflg-bom' of http://112.74.186.154:3000/nflj/nflg_project into feature/DM/nflg-bom

This commit is contained in:
jing's 2023-12-21 19:40:27 +08:00
commit 85e077feed
4 changed files with 108 additions and 0 deletions

View File

@ -129,6 +129,16 @@ public class EbomApi extends BaseApi {
return ResultVO.success(true); return ResultVO.success(true);
}
@PostMapping("upgradeChanges")
@ApiOperation("发起变更")
public ResultVO<Boolean> upgradeChanges(@RequestBody List<Long> bomRowIds) {
VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要发起变更的物料");
bomNewEbomParentService.upgradeChanges(bomRowIds);
return ResultVO.success(true);
} }
@PostMapping("exportBom") @PostMapping("exportBom")

View File

@ -448,6 +448,49 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
} }
} }
/**
* 发起变更
* @param bomRowIds
*/
@Transactional(rollbackFor = Exception.class)
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<>();
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);
newParent.setRowId(IdWorker.getId());
newParent.setLastVersionIs(1);
newParent.setCurrentVersion(VersionUtil.getNextVersionForSmallVersion(parent.getCurrentVersion()));
parent.setLastVersionIs(0);
parentResult.add(newParent);
parentResult.add(parent);
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)){
this.saveOrUpdateBatch(parentResult);
}
if(CollUtil.isNotEmpty(childResult)){
ebomChildService.saveOrUpdateBatch(childResult);
}
}
public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException { public void exportBom(List<Long> bomRowIds, HttpServletResponse response) throws IOException {

View File

@ -67,6 +67,9 @@ public class CheckEBomException {
} else if (StrUtil.isBlank(vo.getProjectType())) { } else if (StrUtil.isBlank(vo.getProjectType())) {
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue()); vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_8.getValue());
} }
else if (StrUtil.isBlank(vo.getNoticeNums())){
vo.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_11.getValue());
}
} }
checkOther(); checkOther();

View File

@ -4,6 +4,10 @@ package com.nflg.product.bomnew.util;
import cn.hutool.core.convert.Convert; import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Objects;
/** /**
* 版本 工具类 * 版本 工具类
* *
@ -14,6 +18,9 @@ public class VersionUtil {
static final String versionPrefix = "A"; static final String versionPrefix = "A";
/**
* 获取下一个版本号(大版本)
*/
public static String getNextVersion(String preVersion) { public static String getNextVersion(String preVersion) {
if (StrUtil.isBlank(preVersion)) { if (StrUtil.isBlank(preVersion)) {
return versionPrefix + "00"; return versionPrefix + "00";
@ -22,4 +29,49 @@ public class VersionUtil {
Integer versionNum = Convert.toInt(StrUtil.replace(preVersion, "A", "")) + 1; Integer versionNum = Convert.toInt(StrUtil.replace(preVersion, "A", "")) + 1;
return versionPrefix + StrUtil.padPre(versionNum.toString(), 2, '0'); return versionPrefix + StrUtil.padPre(versionNum.toString(), 2, '0');
} }
/**
* 获取下一个小版本号(小版本)
*/
public static String getNextVersionForSmallVersion(String preVersion) {
if (StrUtil.isBlank(preVersion)) {
return versionPrefix + "00";
}
return versionPrefix + generateNextVersion(preVersion);
}
private static String generateNextVersion(String previousVersion) {
// Split the previous version number into its components
String[] previousComponents = previousVersion.replace(versionPrefix, "").split("\\.");
int previousMajor = Integer.parseInt(previousComponents[0]);
int previousMinor = previousComponents.length < 2 ? 0 : Integer.parseInt(previousComponents[1]);
// Generate the next version number by incrementing the minor version number
int nextMinor = previousMinor + 1;
int nextMajor = previousMajor;
// Determine if the next version will be a major release
boolean isMajorRelease = false;
if (nextMinor >= 10 && previousComponents.length > 2) {
isMajorRelease = true;
nextMajor = previousMajor + 1;
nextMinor = 0;
}
// Build the next version number components
String nextVersion = StrUtil.padPre(String.valueOf(nextMajor), 2, "0") + "." + nextMinor;
// Append any additional components for a major release
if (isMajorRelease && previousComponents.length > 2) {
String[] additionalComponents = Arrays.copyOfRange(previousComponents, 2, previousComponents.length);
nextVersion += additionalComponents;
}
return nextVersion;
}
} }