|
|
|
|
@ -1,10 +1,18 @@
|
|
|
|
|
package com.zhehekeji.web.service.ksec;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.util.StringUtils;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.poi.util.StringUtil;
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLDecoder;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 蜜雪冰城需要展示带中文的批次号
|
|
|
|
|
*/
|
|
|
|
|
@Data
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class LotnumConvert {
|
|
|
|
|
private static final String SPLIT1 = ",";
|
|
|
|
|
private static final String SPLIT2 = "-";
|
|
|
|
|
@ -20,13 +28,15 @@ public class LotnumConvert {
|
|
|
|
|
private String Subtray;
|
|
|
|
|
private String Dop;
|
|
|
|
|
private String Lotnum = "";
|
|
|
|
|
|
|
|
|
|
private String categoryName = "";
|
|
|
|
|
|
|
|
|
|
public LotnumConvert(String lotnum)
|
|
|
|
|
{
|
|
|
|
|
if(StringUtils.isEmpty(lotnum)){
|
|
|
|
|
Lotnum = "";
|
|
|
|
|
}else {
|
|
|
|
|
String[] strings = lotnum.split(SPLIT1);
|
|
|
|
|
if(strings.length == 5)
|
|
|
|
|
{
|
|
|
|
|
if (strings.length == 5) {
|
|
|
|
|
Category = categoryConvert(CATEGORY, strings[0]);
|
|
|
|
|
Quantity = subConvert(QUANTITY, strings[1]);
|
|
|
|
|
Tray = subConvert(TRAY, strings[2]);
|
|
|
|
|
@ -36,22 +46,24 @@ public class LotnumConvert {
|
|
|
|
|
sbf.append(Category).append(SPLIT1).append(Quantity).append(SPLIT1).append(Tray).append(SPLIT1)
|
|
|
|
|
.append(Subtray).append(SPLIT1).append(Dop);
|
|
|
|
|
Lotnum = sbf.toString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
} else {
|
|
|
|
|
Lotnum = lotnum;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String categoryConvert(String key, String string)
|
|
|
|
|
{
|
|
|
|
|
String[] strings = string.split(SPLIT2);
|
|
|
|
|
int index = strings[1].indexOf('(');
|
|
|
|
|
String value = strings[1].substring(0, index);
|
|
|
|
|
String category = key+SPLIT2+value;
|
|
|
|
|
String value = strings[1];
|
|
|
|
|
String category = key+SPLIT2+value ;
|
|
|
|
|
return category;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
LotnumConvert lotnumConvert = new LotnumConvert("lotnum\":\"物料-1020036(奶昔(原味)),??-40,???-81012641,???-TRA202303051162,????-2023-02-14\"");
|
|
|
|
|
System.out.println(lotnumConvert.getLotnum());
|
|
|
|
|
}
|
|
|
|
|
private String subConvert(String key, String string)
|
|
|
|
|
{
|
|
|
|
|
String[] strings = string.split(SPLIT2);
|
|
|
|
|
|