fix: 修复“仙桃”的位置
This commit is contained in:
parent
376bf37de1
commit
53a39c3a25
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue