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

This commit is contained in:
大米 2024-04-15 11:05:44 +08:00
commit a524472638
15 changed files with 196 additions and 95 deletions

View File

@ -176,6 +176,8 @@ public class OriginalBomApi extends BaseApi {
ebomParentService.getBaseMapper().updateRootState();
ebomParentService.getBaseMapper().updateRootForWaitReview();
ebomParentService.resetAllBomExist();
return ResultVO.success(result);
}

View File

@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.bomnew.pojo.entity.BomNewEbomParentEntity;
import com.nflg.product.bomnew.pojo.query.BomNewEbomParentQuery;
import com.nflg.product.bomnew.pojo.query.OriginalBomQuery;
import com.nflg.product.bomnew.pojo.vo.*;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomParentVO;
import com.nflg.product.bomnew.pojo.vo.BomNewEbomUpgradeChangeVO;
import com.nflg.product.bomnew.pojo.vo.MaterialHistoryProjectTypeVO;
import com.nflg.product.bomnew.pojo.vo.ReverseReportVO;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
@ -71,5 +73,9 @@ public interface BomNewEbomParentMapper extends BaseMapper<BomNewEbomParentEntit
void updateRootForWaitReview();
void resetBomExist(Long rowId);
Set<String> getMaterialParent(@Param("materialNos") Collection<String> materialNos ,@Param("createdBy") String createdBy);
void resetAllBomExist();
}

View File

@ -71,5 +71,5 @@ public interface BomNewOriginalParentMapper extends BaseMapper<BomNewOriginalPar
Set<String> getMaterialParent(@Param("drawingNos") Collection<String> drawingNos);
void resetBomExist(Long rowId);
}

View File

@ -51,4 +51,6 @@ public interface BomNewPbomParentMapper extends BaseMapper<BomNewPbomParentEntit
Integer checkIsUserRoot(@Param("materialNo") String materialNo, @Param("jobNo") String jobNo);
List<BomNewPbomWorkExcelVO> exportExcel(List<Long> bomRowIds);
void resetBomExist(Long rowId);
}

View File

@ -351,14 +351,19 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewEbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
child.setCurrentVersion(parentEntity.getCurrentVersion());
if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
child.setStatus(parentEntity.getStatus());
child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId());
if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
}
child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName());
// child.setSource(parentEntity.getSource());
@ -390,11 +395,9 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
child.setSuperMaterialStatus(parent.getSuperMaterialStatus());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus());
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
}
}
}
@ -824,10 +827,14 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
public void convertToPBom(EBomToPBomParamDTO paramDto) throws ExecutionException, InterruptedException {
//31 须有虚拟包
List<BomNewEbomParentEntity> parents = this.getBaseMapper().selectBatchIds(paramDto.getBomRowIds());
List<String> noVirPackage = parents.stream().filter(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0).map(BomNewEbomParentEntity::getMaterialNo).collect(Collectors.toList());
VUtils.isTure(CollUtil.isNotEmpty(noVirPackage)).throwMessage("31码须有虚拟包");
for (Long bomRowId : paramDto.getBomRowIds()) {
VUtils.isTure(paramDto.getFacCodes().contains("1020") && parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31")))
.throwMessage("31码不能生成仙桃(1020)的pbom");
VUtils.isTure(parents.stream().anyMatch(u -> u.getMaterialNo().startsWith("31") && u.getVirtrualPackageEnum() <= 0))
.throwMessage("31码须有虚拟包");
for (Long bomRowId : paramDto.getBomRowIds()) {
BomNewEbomParentVO parent = Convert.convert(BomNewEbomParentVO.class, this.getById(bomRowId));
VUtils.isTure(Objects.isNull(parent)).throwMessage("Bom版本不存在" + bomRowId.toString());
LogRecordContext.putVariable("CToPbom", parent);
@ -1824,7 +1831,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
if (eBomEdit.isRootForWaitReview()) {
this.getBaseMapper().updateRootForWaitReview();
}
resetBomExist(dto.getParent().getRowId());
return true;
}
@ -2038,5 +2045,20 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
LogRecordContext.putVariable("bom", ent);
}
/**
* 重置BOM存在状态
* @param rowId 父级节点rowId
*/
public void resetBomExist(Long rowId) {
log.debug("resetBomExist{}", rowId);
this.getBaseMapper().resetBomExist(rowId);
}
/**
* 重置所有BOM存在状态
*/
public void resetAllBomExist() {
log.debug("resetAllBomExist");
this.getBaseMapper().resetAllBomExist();
}
}

View File

@ -191,10 +191,10 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
if (CollUtil.isNotEmpty(parentDrawingNos)) {
List<BomOriginalListVO> childs=new ArrayList<>();
List<BomOriginalListVO> parents = this.getBaseMapper().getParentForDrawingNoSeach(parentDrawingNos, query.getStatus());
materialMainService.intiMaterialInfo(parents, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
if(CollUtil.isNotEmpty(parents)) {
childs = this.getBaseMapper().getChildForDrawingNoSeach(parentDrawingNos, parents.stream().map(u -> u.getRowId()).collect(Collectors.toSet()));
materialMainService.intiMaterialInfo(childs, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
materialMainService.intiMaterialInfo(parents, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
if (CollUtil.isNotEmpty(parents)) {
childs = this.getBaseMapper().getChildForDrawingNoSeach(parentDrawingNos, parents.stream().map(BomOriginalListVO::getRowId).collect(Collectors.toSet()));
materialMainService.intiMaterialInfo(childs, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT2);
childs.stream().filter(f -> StrUtil.isBlank(f.getCurrentVersion())).forEach(f -> {
if (MaterialshouldBomExistUtil.checkShouldBomExist(f.getMaterialCategoryCode(), f.getMaterialGetType())) {
f.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
@ -203,10 +203,6 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
}
});
}
// List<BomOriginalListVO> data = new ArrayList<>();
// data.addAll(parents);
// data.addAll(childs);
// materialMainService.intiMaterialInfo(data, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
result = handSeachToTree(parents, childs);
}
}
@ -221,7 +217,6 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
return result;
}
/**
* 编辑时-暂存
*
@ -233,18 +228,19 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
List<BomOriginalListVO> saveEnts = bom.getBomList().stream().filter(u -> u.getDelIs().equals(0)).collect(Collectors.toList());
List<BomNewOriginalChildEntity> childEntities = Convert.toList(BomNewOriginalChildEntity.class, saveEnts);
// originalChildService.getBaseMapper().deleteByMap(ImmutableMap.of("parent_row_id",bom.getParentRowId()));
childEntities.forEach(u -> {
u.setParentRowId(bom.getParentRowId());
if (submitIs) {
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
}
});
if (CollUtil.isNotEmpty(childEntities)) {
childEntities.forEach(u -> {
u.setParentRowId(bom.getParentRowId());
if (submitIs) {
u.setEditStatus(OriginalEditStatusEnum.HANDLER_FINISHED.getValue());
}
});
//删除行
List<Long> delRowIds = bom.getBomList().stream().map(BomOriginalListVO::getRowId).filter(rowId -> rowId > 0).collect(Collectors.toList());
originalChildService.getBaseMapper().delOriginalChildNotInRowIds(delRowIds, bom.getParentRowId());
originalChildService.saveOrUpdateBatch(childEntities);
resetBomExist(bom.getParentRowId());
}
return true;
@ -295,17 +291,23 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
for (BomOriginalListVO child : parentChild) {
if (bomListMap.containsKey(child.getDrawingNo())) {
BomNewOriginalParentEntity parentEntity = bomListMap.get(child.getDrawingNo());
child.setCurrentVersion(parentEntity.getCurrentVersion());
child.setStatus(parentEntity.getStatus());
if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
// child.setCreatedBy(parentEntity.getCreatedBy());
// child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId());
if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
}
child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName());
child.setSource(parentEntity.getSource());
if (parentEntity.getStatus().equals(OriginalStatusEnum.OVER_CONVERT.getValue())) {
if (Objects.equals(parent.getStatus(), OriginalStatusEnum.UN_CONVERT.getValue())
&& !parentEntity.getStatus().equals(OriginalStatusEnum.UN_CONVERT.getValue())) {
child.setStatus(OriginalStatusEnum.BORROWED_PARTS.getValue());
}
//非本人则为借用件
@ -325,17 +327,11 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
child.setBomRowId(0L);
}
}
try {
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
//child.setStatus(OriginalStatusEnum.UN_CONVERT.getValue());
// child.setEditStatus(OriginalEditStatusEnum.HANDLER_CREATED.getValue());
}
} catch (Exception e) {
e.getMessage();
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
}
}
}
@ -383,11 +379,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
BomNewOriginalParentEntity parentEntity = this.getBaseMapper().selectById(rowId);
OriginalBomDetailTask detailTask = new OriginalBomDetailTask(bomDetail);
ForkJoinTask<List<BomOriginalListVO>> submit = bomDetailPool.submit(detailTask);
List<BomOriginalListVO> result = submit.get();
return result;
return submit.get();
}
/**
@ -526,7 +518,6 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
*
* @return
*/
@Transactional(rollbackFor = Exception.class)
public List<ImportOriginalBomVO> convertToEBom(List<Long> bomRowIds) throws ExecutionException, InterruptedException {
List<BomNewOriginalParentEntity> bomNewOriginalParentEntities = this.getBaseMapper().selectBatchIds(bomRowIds);
@ -550,13 +541,13 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
try {
convertToEBomDo(parent, ebomRowId);
//更新并保存异常信息
ebomParentService.checkAndSaveEBomException(ebomRowId);
} catch (Exception e) {
importOriginalBomVOList.add(new ImportOriginalBomVO(parent.getDrawingNo(), "操作失败:" + e.getMessage()));
throw e;
}
//更新并保存异常信息
ebomParentService.checkAndSaveEBomException(ebomRowId);
}
return importOriginalBomVOList;
}
@ -752,5 +743,7 @@ public class BomNewOriginalParentService extends ServiceImpl<BomNewOriginalParen
excelContextTL.remove();
}
private void resetBomExist(Long rowId) {
this.getBaseMapper().resetBomExist(rowId);
}
}

View File

@ -244,12 +244,16 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
public List<BomNewPbomParentVO> getChild(Long rowId) {
List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
BomNewPbomParentEntity parent = this.getById(rowId);
VUtils.isTure(rowId == 0).throwMessage("参数不正确");
return getChild(this.getById(rowId));
}
public List<BomNewPbomParentVO> getChild(BomNewPbomParentEntity parent) {
//List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(rowId);
//BomNewPbomParentEntity parent = this.getById(rowId);
List<BomNewPbomParentVO> parentChild = this.getBaseMapper().getParentChild(parent.getRowId());
if (CollUtil.isNotEmpty(parentChild)) {
materialMainService.intiMaterialInfo(parentChild, EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT);
List<String> materialNos = parentChild.stream().map(u -> u.getMaterialNo()).collect(Collectors.toList());
List<String> materialNos = parentChild.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toList());
if (CollUtil.isNotEmpty(materialNos)) {
List<BomNewPbomParentEntity> list = this.lambdaQuery().in(BomNewPbomParentEntity::getMaterialNo, materialNos)
.eq(!PBomStatusEnum.PUBLISH.equalsValue(parent.getStatus()), BomNewPbomParentEntity::getLastVersionIs, 1)
@ -266,14 +270,20 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
for (BomNewPbomParentVO child : parentChild) {
if (bomListMap.containsKey(child.getMaterialNo())) {
BomNewPbomParentEntity parentEntity = bomListMap.get(child.getMaterialNo());
child.setCurrentVersion(parentEntity.getCurrentVersion());
if (parentEntity.getShouldBomExist() == 1 && parentEntity.getBomExist() == 0) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
} else {
child.setCurrentVersion(parentEntity.getCurrentVersion());
}
child.setStatus(parentEntity.getStatus());
child.setEditStatus(parentEntity.getEditStatus());
child.setDeviseName(parentEntity.getDeviseName());
child.setDeviseUserCode(parentEntity.getDeviseUserCode());
child.setCreatedTime(parentEntity.getCreatedTime());
child.setBomRowId(parentEntity.getRowId());
if (parentEntity.getBomExist() == 1) {
child.setBomRowId(parentEntity.getRowId());
}
child.setLevelNum(parentEntity.getLevelNum());
child.setDeptName(parentEntity.getDeptName());
child.setChangeDesc(parentEntity.getChangeDesc());
@ -287,9 +297,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
if (parent.getStatus() < PBomStatusEnum.PUBLISH.getValue() && parentEntity.getStatus().equals(PBomStatusEnum.PUBLISH.getValue())) {
child.setStatus(PBomStatusEnum.BORROWED_PARTS.getValue());
}
} else { //无BOM-版本时 确定版本号
//child.setSource(Objects.nonNull(parent) ? parent.getSource() : EBomSourceEnum.FROM_BOM.getValue());
child.setDeviseUserCode(parent.getDeviseUserCode());
child.setDeviseName(parent.getDeviseName());
@ -301,11 +309,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
child.setTechnologyUserName(parent.getTechnologyUserName());
if (MaterialshouldBomExistUtil.checkShouldBomExist(child)) {
child.setCurrentVersion(OriginalConstant.NO_BOM_VERSION);
child.setStatus(parent.getStatus());
} else {
child.setCurrentVersion(OriginalConstant.DEFAULT_BOM_VERSION);
}
}
}
}
@ -325,15 +331,22 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
BomNewPbomParentEntity parent = this.getById(paramDTO.getBomRowId());
VUtils.isTure(Objects.isNull(parent)).throwMessage("参数错误该BOM不存在");
LogRecordContext.putVariable("bom",parent);
List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList());
childList.forEach(u -> {
u.setParentRowId(paramDTO.getBomRowId());
});
pbomChildService.saveOrUpdateBatch(childList);
if (CollUtil.isNotEmpty(paramDTO.getChildList())) {
List<BomNewPbomChildEntity> childList = Convert.toList(BomNewPbomChildEntity.class, paramDTO.getChildList());
childList.forEach(u -> u.setParentRowId(paramDTO.getBomRowId()));
pbomChildService.saveOrUpdateBatch(childList);
parent.setBomExist(1);
} else {
parent.setBomExist(0);
}
parent.setEditStatus(editStatus.getValue());
parent.setModifyTime(LocalDateTime.now());
this.updateById(parent);
if (editStatus == PBomEditStatusEnum.HANDLER_TEMP) {
return getChild(paramDTO.getBomRowId());
return getChild(parent);
} else {
return null;
}
@ -400,16 +413,17 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
// 机加工件 的子级可直接删除
if (parentVO.getMaterialCategoryCode().startsWith("200301")) {
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
resetBomExist(parent.getRowId());
return hasTechnologypackage;
}
//删除辅助物料
List<BomNewPbomParentVO> noDelList = childListVO.stream()
.filter(u -> !u.getMaterialCategoryCode().startsWith("1003") && !u.getMaterialCategoryCode().startsWith("1020") && !u.getMaterialCategoryCode().startsWith("1021"))
.collect(Collectors.toList());
noDelList.removeAll(technologypackages);
VUtils.isTure(CollUtil.isNotEmpty(noDelList)).throwMessage("非机加工件的子级只能删除辅助物料");
pbomChildService.getBaseMapper().delByRowId(paramDTO.getRowIdList());
resetBomExist(parent.getRowId());
return hasTechnologypackage;
}
@ -431,7 +445,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
*/
public void editExport(Long bomRowId, HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
List<BomNewPbomParentVO> child = this.getChild(bomRowId);
BomNewPbomParentEntity parent = this.getById(bomRowId);
List<BomNewPbomParentVO> child = this.getChild(parent);
List<BomNewPbomEditExcelVO> result = Convert.toList(BomNewPbomEditExcelVO.class, child);
new Workbook().addSheet(new ListSheet<>(result)).writeTo(response.getOutputStream());
@ -440,7 +455,8 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public void editExportV2(PBomEditExportParamDTO param, HttpServletResponse response) throws IOException {
EecExcelUtil.setResponseExcelHeader(response, "bom明细列表");
List<BomNewPbomParentVO> child = this.getChild(param.getBomRowId());
BomNewPbomParentEntity parent = this.getById(param.getBomRowId());
List<BomNewPbomParentVO> child = this.getChild(parent);
if (CollUtil.isNotEmpty(param.getRowIds())) {
child = child.stream().filter(u -> param.getRowIds().contains(u.getRowId())).collect(Collectors.toList());
}
@ -1028,4 +1044,7 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
private void resetBomExist(Long rowId) {
this.getBaseMapper().resetBomExist(rowId);
}
}

View File

@ -306,7 +306,6 @@ public class OriginalBomToEBomConvert extends BaseConvert {
// this.eBomChildResult.add(childEntity);
return childEntity;
}
/**
@ -327,7 +326,7 @@ public class OriginalBomToEBomConvert extends BaseConvert {
eBomParent.setSourceRowId(parentEnt.getBomRowId());
eBomParent.setLastVersionIs(1);
eBomParent.setEditStatus(EbomEditStatusEnum.HANDLER_CREATED.getValue());
eBomParent.setModifyTime(LocalDateTime.now());
//eBomParent.setModifyTime(LocalDateTime.now());
eBomParent.setBomExist(parentEnt.getBomRowId() > 0 ? 1 : 0);
eBomParent.setDeviseName(SessionUtil.getRealName());
eBomParent.setDeptName(SessionUtil.getDepartName());

View File

@ -1,7 +1,6 @@
package com.nflg.product.bomnew.service.domain.PBom;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.nflg.product.bomnew.constant.EBomConstant;
@ -9,7 +8,7 @@ import com.nflg.product.bomnew.constant.ProductionFactoryCodeInputTypeEnum;
import com.nflg.product.bomnew.constant.VirtualPackageTypeEnum;
import com.nflg.product.bomnew.pojo.entity.BomNewMbomParentEntity;
import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity;
import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO;
import com.nflg.product.bomnew.util.StringUtil;
import com.nflg.product.bomnew.util.VUtils;
import java.util.ArrayList;
@ -136,12 +135,18 @@ public class ConvertToMBom1020 extends ConvertToMBomBase{
}
private String handlerMaterialNameFor1020(String materialName , String facName){
List<String> nameComp = VUtils.extractMessageByRegular(materialName);
if(CollUtil.isNotEmpty(nameComp) && nameComp.size()>=3){
return StrUtil.join("","(", nameComp.get(0) ,")", "(", nameComp.get(1), facName,")", "(",nameComp.get(2), ")" );
// List<String> nameComp = VUtils.extractMessageByRegular(materialName);
// if(CollUtil.isNotEmpty(nameComp) && nameComp.size()>=3){
// return StrUtil.join("","(", nameComp.get(0) ,")", "(", nameComp.get(1), facName,")", "(",nameComp.get(2), ")" );
// }
// return materialName+facName;
if (StringUtil.countOfChar(materialName, '(') >= 3) {
int start = materialName.indexOf(")");
int end = materialName.lastIndexOf("(");
String name = materialName.substring(start + 2, end - 1);
return StrUtil.format("{}({}{}){}", materialName.substring(0, start + 1), name, facName, materialName.substring(end));
}
return materialName+facName;
return materialName + facName;
}

View File

@ -1,5 +1,7 @@
package com.nflg.product.bomnew.util;
import org.apache.commons.lang3.StringUtils;
/**
* @author 曹鹏飞
* @date 2024-03-29 16:52:05
@ -104,4 +106,15 @@ public class StringUtil {
|| block == Character.UnicodeBlock.GENERAL_PUNCTUATION
|| block == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS;
}
public static int countOfChar(String str, char ch) {
if (StringUtils.isBlank(str)) return 0;
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (str.charAt(i) == ch) {
count++;
}
}
return count;
}
}

View File

@ -190,7 +190,6 @@
where status=4 <include refid="whr"/>
group by material_no) b on a.material_no=b.material_no and a.current_version=b.current_version
where a.status=4
<include refid="whr"/>
</select>
<sql id="getUpgradeChangeListWhr">
@ -348,4 +347,16 @@
#{item}
</foreach>
</select>
<select id="resetBomExist">
UPDATE t_bom_new_ebom_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_ebom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId};
</select>
<select id="resetAllBomExist">
UPDATE t_bom_new_ebom_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_ebom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.status &lt; 4;
</select>
</mapper>

View File

@ -182,7 +182,7 @@
<foreach collection="materialNos" item="materialNo" open="(" separator="," close=")">
#{materialNo}
</foreach>
union all
union
select drawing_no from t_bom_new_original_parent where material_no in
<foreach collection="materialNos" item="materialNo" open="(" separator="," close=")">
#{materialNo}
@ -220,7 +220,6 @@
<foreach collection="drawingNos" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<!-- &lt;!&ndash;物料编码搜索-子级&ndash;&gt;-->
@ -248,4 +247,10 @@
#{item}
</foreach>
</select>
<select id="resetBomExist">
UPDATE t_bom_new_original_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_original_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId};
</select>
</mapper>

View File

@ -222,4 +222,10 @@
</foreach>
order by created_time desc
</select>
<select id="resetBomExist">
UPDATE t_bom_new_pbom_parent p
SET p.bom_exist = (IF(EXISTS (SELECT 1 FROM t_bom_new_pbom_child WHERE parent_row_id = p.row_id), 1, 0))
WHERE p.row_id = #{rowId};
</select>
</mapper>

View File

@ -1,20 +1,12 @@
package com.nflg.product.bomnew.service.test;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.bomnew.pojo.query.OptionalEbomImportChildQuery;
import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO;
import com.nflg.product.bomnew.pojo.vo.OptionalEbomConfigAggregVO;
import com.nflg.product.bomnew.service.MaterialMainService;
import com.nflg.product.bomnew.service.MaterialService;
import jdk.nashorn.internal.ir.annotations.Immutable;
import nflg.product.common.constant.STATE;
import nflg.product.common.vo.ResultVO;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -22,7 +14,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
@RunWith(SpringRunner.class)

View File

@ -1,5 +1,6 @@
package com.nflg.product.bomnew.service.test;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.nflg.product.bomnew.constant.EBomStatusEnum;
@ -75,4 +76,30 @@ public class OtherTest {
String data2="";
Assert.assertEquals(data2,StringUtil.trimText(data1,0));
}
@Test
public void test10() {
String data1 = "(2FBJ9000A2.0)(FJD4500MT搅拌系统(普通))(发货)";
String str1 = data1.substring(data1.indexOf(")") + 2, data1.lastIndexOf("(") - 1);
String data2 = "FJD4500MT搅拌系统(普通)";
Assert.assertEquals(data2, str1);
}
@Test
public void test11() {
String data1 = "(2FBJ9000A2.0)(FJD4500MT搅拌系统普通)(发货)";
String str1 = data1.substring(data1.indexOf(")") + 2, data1.lastIndexOf("(") - 1);
String data2 = "FJD4500MT搅拌系统普通";
Assert.assertEquals(data2, str1);
}
@Test
public void test12() {
String data1 = "(2FBJ9000A2.0)(FJD4500MT系统(普通))(发货)";
int start = data1.indexOf(")");
int end = data1.lastIndexOf("(");
String str1 = data1.substring(start + 2, end - 1);
String data2 = "(2FBJ9000A2.0)(FJD4500MT系统(普通)仙桃)(发货)";
Assert.assertEquals(data2, StrUtil.format("{}({}{}){}", data1.substring(0, start + 1), str1, "仙桃", data1.substring(end)));
}
}