md
This commit is contained in:
parent
3095154f7a
commit
012dc29b20
@ -1763,7 +1763,6 @@ public class EmisBaseService {
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char ch = text.charAt(i);
|
||||
int charWidth = Integer.valueOf(ch) > 255 ? 2 : 1; // 判断字符宽度,中文字符宽度为2,英文字符宽度为1
|
||||
|
||||
// 如果当前字符加上当前行已有字符宽度超过最大字符宽度,需要另起一行
|
||||
if (currentWidth + charWidth > intLenMax) {
|
||||
lines.add(currentLine);
|
||||
@ -1935,10 +1934,10 @@ public class EmisBaseService {
|
||||
|
||||
order.put("address", WaybillHelper.removeUnSeeChar(address));
|
||||
// 地址拆分为多行
|
||||
String[] addrArr=WordUtils.wrap(address,48).split("\n");
|
||||
List<String> addrList=WaybillHelper.wrap(address,48);
|
||||
for(int i=0;i<4;i++) {
|
||||
try{
|
||||
order.put("address"+(i+1),addrArr[i]);
|
||||
order.put("address"+(i+1),addrList.get(i));
|
||||
}catch (Exception ex){
|
||||
order.put("address"+(i+1),"");
|
||||
}
|
||||
@ -1961,10 +1960,10 @@ public class EmisBaseService {
|
||||
order.put("sendAddress",WaybillHelper.removeUnSeeChar(sendAddress) );
|
||||
|
||||
// 地址拆分为多行
|
||||
String[] sAddrArr=WordUtils.wrap(sendAddress,48).split("\n");
|
||||
List<String> sAddrList=WaybillHelper.wrap(sendAddress,48);
|
||||
for(int i=0;i<4;i++) {
|
||||
try{
|
||||
order.put("sendAddress"+(i+1),sAddrArr[i]);
|
||||
order.put("sendAddress"+(i+1),sAddrList.get(i));
|
||||
}catch (Exception ex){
|
||||
order.put("sendAddress"+(i+1)," ");
|
||||
}
|
||||
@ -2085,11 +2084,11 @@ public class EmisBaseService {
|
||||
String remark= WaybillHelper.removeUnSeeChar(waybill.getRemark());
|
||||
order.put("remark",remark);
|
||||
|
||||
// 地址拆分为多行
|
||||
String[] remarkArr=WordUtils.wrap(remark,40).split("\n");
|
||||
// 备注拆分为多行
|
||||
List<String> remarkList=WaybillHelper.wrap(remark,40);
|
||||
for(int i=0;i<4;i++) {
|
||||
try{
|
||||
order.put("remark"+(i+1),remarkArr[i]);
|
||||
order.put("remark"+(i+1),remarkList.get(i));
|
||||
}catch (Exception ex){
|
||||
order.put("remark"+(i+1),"");
|
||||
}
|
||||
@ -2996,11 +2995,12 @@ public class EmisBaseService {
|
||||
// System.out.println(Integer.valueOf(subBillSuffix));
|
||||
|
||||
|
||||
String txt="NO.7,Chun Hong Industrial Park, National Road No.4, Svay Chrum Village Beckchan Commune ,Angsnoul District,Kandal provinve, Cambodia.";
|
||||
List mlist=splitTextToLines(txt,48);
|
||||
// String txt="NO.7,Chun Hong Industrial Park, National Road No.4, Svay Chrum Village Beckchan Commune ,Angsnoul District,Kandal provinve, Cambodia.";
|
||||
String txt="江苏省南京市建邺区云龙山路68号苏美达国际大厦21楼";
|
||||
List mlist=splitTextToLines(txt,40);
|
||||
System.out.println(JSON.toJSONString(mlist));
|
||||
|
||||
String s1=WordUtils.wrap(txt,48);
|
||||
String s1=WordUtils.wrap(txt,40);
|
||||
String[] sAddrArr=s1.split("\n");
|
||||
System.out.println(JSON.toJSONString(sAddrArr));
|
||||
for(int i=0;i<4;i++) {
|
||||
|
||||
@ -121,7 +121,7 @@ public class EmisWaybillProblemInfoServiceImpl extends EmisBaseService implement
|
||||
}
|
||||
|
||||
// 删除该问题件的扫描轨迹
|
||||
emisTmsScanRecordMapper.deletePromScanRecord(emisWaybillProblemInfo.getId().toString(),emisWaybillProblemInfo.getMainBillCode());
|
||||
emisTmsScanRecordMapper.deletePromScanRecord(id.toString(),emisWaybillProblemInfo.getMainBillCode());
|
||||
|
||||
// 删除问题件
|
||||
emisWaybillProblemInfoMapper.deleteEmisWaybillProblemInfoById(id);
|
||||
|
||||
@ -13,15 +13,16 @@ import com.xdadan.erp.common.utils.StringUtils;
|
||||
import com.xdadan.erp.emis.domain.enumtype.EmisBizErrorType;
|
||||
import com.xdadan.erp.emis.domain.exception.EmisBizError;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.text.WordUtils;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import java.net.URLDecoder;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Slf4j
|
||||
public class WaybillHelper {
|
||||
@ -303,70 +304,66 @@ public class WaybillHelper {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字符串是否包含中文
|
||||
*
|
||||
* @param str 待校验字符串
|
||||
* @return true 包含中文字符 false 不包含中文字符
|
||||
*/
|
||||
public static boolean isContainChinese(String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
str=" ";
|
||||
}
|
||||
Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\!|\\,|\\。|\\(|\\)|\\《|\\》|\\“|\\”|\\?|\\:|\\;|\\【|\\】]");
|
||||
Matcher m = p.matcher(str);
|
||||
if (m.find()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static List<String> wrapStrToLines(String text, int intLenMax) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
String currentLine = "";
|
||||
int currentWidth = 0;
|
||||
|
||||
// 遍历原字符串的每个字符
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char ch = text.charAt(i);
|
||||
int charWidth = Integer.valueOf(ch) > 255 ? 2 : 1; // 判断字符宽度,中文字符宽度为2,英文字符宽度为1
|
||||
// 如果当前字符加上当前行已有字符宽度超过最大字符宽度,需要另起一行
|
||||
if (currentWidth + charWidth > intLenMax) {
|
||||
lines.add(currentLine);
|
||||
currentLine = ""; // 重置当前行
|
||||
currentWidth = 0; // 重置当前字符宽度
|
||||
}
|
||||
|
||||
currentLine += ch;
|
||||
currentWidth += charWidth;
|
||||
}
|
||||
// 添加最后一行
|
||||
lines.add(currentLine);
|
||||
return lines;
|
||||
}
|
||||
|
||||
public static List<String> wrap(String str, int wrapLength) {
|
||||
if(isContainChinese(str)){
|
||||
return wrapStrToLines(str,wrapLength-4);
|
||||
}else{
|
||||
String wrapStr= WordUtils.wrap(str,wrapLength);
|
||||
return Arrays.asList(wrapStr.split("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
//1: 1.02 1.1 1.11
|
||||
// 1.02*10 = 10.2 , 1.11*10 = 11.1
|
||||
// 0.2
|
||||
|
||||
// double m=0.000001D;
|
||||
// double vw=m*(1000000.0D/5000.0D);
|
||||
// double d= Double.parseDouble(dfCalc.format(vw));
|
||||
// get_double = Double.parseDouble(df.format(result_value));
|
||||
// vw 1.005D
|
||||
// double w=calcSettledWeight(vw,"2");
|
||||
// double w=calcSettledFee(1.49D,"2");
|
||||
// System.out.println(w);
|
||||
// System.out.println(d);
|
||||
|
||||
try {
|
||||
//
|
||||
// long startAll = System.currentTimeMillis();
|
||||
//
|
||||
// for(int i=0;i<100;i++) {
|
||||
// long start = System.currentTimeMillis();
|
||||
// JSONObject rst = WaybillHelper.parseChinaAddress("13818415183 孙丹 广西壮族自治区南宁市西乡塘区衡阳街道广西省南宁市衡阳西路34号大院"+i);
|
||||
// System.out.println(rst);
|
||||
// long end4 = System.currentTimeMillis();
|
||||
// System.out.println("escape time single:" + (end4 - start) + "ms");
|
||||
// }
|
||||
// long endAll = System.currentTimeMillis();
|
||||
|
||||
// System.out.println("All escape time:" + (endAll - startAll) + "ms");
|
||||
|
||||
// 6000 167
|
||||
// 3333 300
|
||||
// 5000 0.1
|
||||
float volumeWeight=5.9f;
|
||||
System.out.println(WaybillHelper.calcSettledWeight(volumeWeight,"2"));
|
||||
// System.out.println(WaybillHelper.calcSettledWeight(volumeWeight,"4"));
|
||||
|
||||
// System.out.println(removeUnSeeChar(" Phuc)"));
|
||||
// String input=" Phuc)";
|
||||
// for (char c : input.toCharArray()) {
|
||||
// if (Character.isISOControl(c)) {
|
||||
// System.out.println("包含不可见字符:" + c);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// String str="T123213\n1231232,";
|
||||
// str=WaybillHelper.formatQueryValue(str);
|
||||
// String billCode="SF9189239821389";
|
||||
// int len=billCode.length();
|
||||
// String mainBillCode=billCode.substring(0,len-4);
|
||||
// System.out.print(mainBillCode);
|
||||
|
||||
|
||||
String m1="T7080300117632\n" +
|
||||
"T7080300001794";
|
||||
String m1="江苏省南京市建邺区云龙山路68号苏美达国际大厦21楼";
|
||||
System.out.println(m1);
|
||||
String m2 = WaybillHelper.formatQueryValue(m1);
|
||||
System.out.println(m2);
|
||||
List<String> m1List = WaybillHelper.wrap(m1,48);
|
||||
System.out.println(JSON.toJSONString(m1List));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user