wfg 1 year ago
parent
commit
2aae8cc1dd

+ 299 - 196
blade-service/blade-los/src/main/java/org/springblade/los/Util/RegularUtils.java

@@ -2,14 +2,15 @@ package org.springblade.los.Util;
 
 import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.sun.org.apache.xpath.internal.operations.Bool;
+import io.reactivex.Single;
 import org.springblade.los.edi.dto.InttraSiBillDto;
 import org.springblade.los.edi.dto.InttraSiDto;
 import org.springblade.los.edi.dto.InttraSoDto;
 
+import java.math.BigDecimal;
 import java.math.RoundingMode;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -92,6 +93,115 @@ public class RegularUtils {
 		}
 	}
 
+	/**
+	 * 判断字符串长度是否超长
+	 *
+	 * @param line 内容
+	 * @return 结果
+	 */
+	public static String escapeEDILine(String line) {
+		if(line.isEmpty()){
+			return "";
+		} else {
+			return line.replaceAll("\\?", "??").replaceAll("\\+", "?+").replaceAll("'", "?'").replaceAll(":", "?:");
+		}
+	}
+
+	public static int englishToNumber(String englishWord) {
+		String[] words = {"ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX",
+			"SEVEN", "EIGHT", "NINE", "TEN"};
+		int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+
+		for (int i = 0; i < words.length; i++) {
+			if (englishWord.equalsIgnoreCase(words[i])) {
+				return numbers[i];
+			}
+		}
+		return 3; // 默认 3
+	}
+
+	public static String formatTempNumber(BigDecimal num, int len){
+		String S = num.setScale(3, RoundingMode.HALF_UP).toString();
+		while(S.endsWith("0")){
+			S = S.substring(0, S.length()-1);
+		}
+		if(S.endsWith(".")){
+			S = S.substring(0, S.length()-1);
+		}
+		String symbol = "";
+		if(S.equals("0")) {
+			S="";
+		}else{
+			if (S.startsWith("-")) {
+				symbol = "-";
+				S = S.substring(1);
+			}
+			while (S.length() < len) {
+				S = "0" + S;
+			}
+		}
+
+		return symbol + S;
+	}
+
+	/**
+	 * 判断字符串长度是否超长
+	 *
+	 * @param text 内容
+	 * @param lineLen 格式化后每行最大长度,最小值为 2
+	 * @param Escape 是否做转义处理
+	 * @return List<String>结果
+	 */
+	public static List<String> reformatEDIText(String text, int lineLen, Boolean Escape) {
+		List<String> lines = new ArrayList<>();
+		if(!text.isEmpty()){
+			String[] buf = text.split("\n");
+			Pattern p1 = Pattern.compile("[a-zA-Z]");
+			for (String item : buf) {
+				String ln = item.trim();
+				while (!ln.isEmpty()) {
+					if (ln.length() <= lineLen) {
+						lines.add(Escape ?escapeEDILine(ln) : ln);
+						ln = "";
+					} else {
+						if (!p1.matcher(ln.charAt(lineLen - 1) + "").matches()) {
+							if (Escape){
+								lines.add(escapeEDILine(ln.substring(0, lineLen)));
+							} else {
+								lines.add(ln.substring(0, lineLen));
+							}
+							ln = ln.substring(lineLen);
+						} else {
+							int p = -1;
+							for (int i = lineLen - 2; i >= 0; i--) {
+								if (!p1.matcher(ln.charAt(i) + "").matches()) {
+									p = i;
+									break;
+								}
+							}
+							if (p == -1) {
+								if (Escape){
+									lines.add(escapeEDILine(ln.substring(0, lineLen)));
+								} else {
+									lines.add(ln.substring(0, lineLen));
+								}
+								ln = ln.substring(lineLen);
+							} else {
+								if (Escape){
+									lines.add(escapeEDILine(ln.substring(0, p + 1)));
+								} else {
+									lines.add(ln.substring(0, p + 1));
+								}
+								ln = ln.substring(p + 1);
+							}
+						}
+					}
+				}
+			}
+		}
+
+		return lines;
+	}
 
 	public static Map<String, Object> notNullInttraSoDto(InttraSoDto inttraSoDto) {
 		Map<String, Object> map = new HashMap<>();
@@ -258,14 +368,12 @@ public class RegularUtils {
 			if (regularLength(inttraSoDto.getVolumeOfGoods().toString(), 18)) {
 				textLength += "货物体积,";
 			} else {
-				inttraSoDto.setVolumeOfGoods(inttraSoDto.getVolumeOfGoods().setScale(0, RoundingMode.HALF_UP).abs());
+				inttraSoDto.setVolumeOfGoods(inttraSoDto.getVolumeOfGoods().setScale(4, RoundingMode.HALF_UP).abs());
 			}
 		}
 		//总箱数
 		if (ObjectUtils.isNotNull(inttraSoDto.getTotalBoxNumber())) {
-			if (regularLength(inttraSoDto.getTotalBoxNumber().toString(), 18)) {
-				textLength += "总箱数,";
-			}
+
 		}
 		//付款地代码
 		if (ObjectUtils.isNotNull(inttraSoDto.getPaymentLocationCode())) {
@@ -339,17 +447,17 @@ public class RegularUtils {
 				character += "提单号,";
 			}
 		}
-		//运费协议
-		if (ObjectUtils.isNotNull(inttraSoDto.getFreightProtocolNumber())) {
-			Map<String, String> mapString = regularEn(inttraSoDto.getFreightProtocolNumber(),true);
+		//客户订舱约
+		if (ObjectUtils.isNotNull(inttraSoDto.getCorpArgreementNo())) {
+			Map<String, String> mapString = regularEn(inttraSoDto.getCorpArgreementNo(),true);
 			if ("200".equals(mapString.get("code"))) {
 				if (regularLength(mapString.get("susscess"), 30)) {
-					textLength += "运费协议号,";
+					textLength += "客户订舱约号,";
 				} else {
-					inttraSoDto.setFreightProtocolNumber(mapString.get("susscess"));
+					inttraSoDto.setCorpArgreementNo(mapString.get("susscess"));
 				}
 			} else {
-				character += "运费协议号,";
+				character += "客户订舱约号,";
 			}
 		}
 		//主拼号
@@ -425,14 +533,27 @@ public class RegularUtils {
 				character += "航次,";
 			}
 		}
+		if (ObjectUtils.isNotNull(inttraSoDto.getBookingRemarks())) {
+			Map<String, String> mapString = regularEn(inttraSoDto.getCarrierCode(),false);
+			if ("200".equals(mapString.get("code"))) {
+
+			} else {
+				character += "订舱备注,";
+			}
+
+		}
 		//船司代码
-		if (ObjectUtils.isNotNull(inttraSoDto.getVesselCarrierCode())) {
-			Map<String, String> mapString = regularEn(inttraSoDto.getVesselCarrierCode(),true);
+		if (ObjectUtils.isNotNull(inttraSoDto.getCarrierCode())) {
+			Map<String, String> mapString = regularEn(inttraSoDto.getCarrierCode(),true);
 			if ("200".equals(mapString.get("code"))) {
-				if ("HLCU".equals(mapString.get("susscess"))) {
+				// 赫伯罗特 或者 达飞
+				String CC = mapString.get("susscess");
+				if ("HLCU".equals(CC) || "CMDU".equals(CC) || "ANNU".equals(CC) || "CHNL".equals(CC)) {
 					String text = "";
 					if (ObjectUtils.isNotNull(inttraSoDto.getBillNo())) {
 						text += inttraSoDto.getBillNo() + ";";
+					}else{
+						text += ";";
 					}
 					if (ObjectUtils.isNotNull(inttraSoDto.getPaymentType())) {
 						if ("PP".equals(inttraSoDto.getPaymentType())) {
@@ -446,6 +567,8 @@ public class RegularUtils {
 								text += "FREIGHT PAYABLE AT " + inttraSoDto.getPaymentLand() + ";";
 							}
 						}
+					}else{
+						text += ";";
 					}
 					if (ObjectUtils.isNotNull(inttraSoDto.getTransportTermCode())) {
 						if ("29".equals(inttraSoDto.getTransportTermCode())) {
@@ -457,20 +580,41 @@ public class RegularUtils {
 						} else if ("30".equals(inttraSoDto.getTransportTermCode())) {
 							text += "CY to CY;";
 						}
+					}else{
+						text += ";";
 					}
-					if (ObjectUtils.isNotNull(inttraSoDto.getBookingNo())) {
-						text += inttraSoDto.getBookingNo() + ";";
+					if (ObjectUtils.isNotNull(inttraSoDto.getCorpArgreementNo())) {
+						text += inttraSoDto.getCorpArgreementNo() + ";";
+					}else{
+						text += ";";
 					}
 					if (ObjectUtils.isNotNull(inttraSoDto.getPlaceDeliveryName())) {
 						text += inttraSoDto.getPlaceDeliveryName() + ";";
 					} else {
 						text += inttraSoDto.getPlaceReceiptName() + ";";
 					}
-					if (ObjectUtils.isNotNull(inttraSoDto.getCarrySingleRemarks())) {
-						text += inttraSoDto.getCarrySingleRemarks() + ";";
+					if (ObjectUtils.isNotNull(inttraSoDto.getBookingRemarks())) {
+						String bookingRemarks = inttraSoDto.getBookingRemarks().trim();
+						if(!bookingRemarks.isEmpty()) {
+							String[] bookingRemarksArr = bookingRemarks.replaceAll("\r", "").split("\n");
+							// text += String.join((CharSequence) ",", Arrays.stream(bookingRemarksArr).filter(a->!a.trim().isEmpty()));
+							Boolean firstLine = true;
+							for (int i = 0; i < bookingRemarksArr.length; i++) {
+								String line = bookingRemarksArr[i].trim();
+								if(!line.isEmpty()){
+									if(firstLine){
+										text += escapeEDILine(line);
+										firstLine = false;
+									}else{
+										text += ";" + escapeEDILine(line);
+									}
+								}
+							}
+						}
 					}
-					inttraSoDto.setRemarks(text);
-				} else if ("MAEU".equals(mapString.get("susscess"))) {
+					inttraSoDto.setBookingRemarks(text);
+				} else if ("MAEU".equals(CC) || "MCCQ".equals(CC) ) {
+					// 马士基
 					String text = "";
 					if (ObjectUtils.isNotNull(inttraSoDto.getPaymentType())) {
 						if ("PP".equals(inttraSoDto.getPaymentType())) {
@@ -498,27 +642,47 @@ public class RegularUtils {
 					}
 					if (ObjectUtils.isNotNull(inttraSoDto.getPackagesNumber()) && ObjectUtils.isNotNull(inttraSoDto.getPackagesCode())) {
 						text += inttraSoDto.getPageNumber() + " " + inttraSoDto.getPackagesCode();
+					}else{
+						msg += "件数及包装单位,";
 					}
-					if (ObjectUtils.isNotNull(inttraSoDto.getCarrySingleRemarks())) {
-						text += inttraSoDto.getCarrySingleRemarks() + ";";
-					}
-					inttraSoDto.setRemarks(text);
-				} else {
-					//备注
-					if (ObjectUtils.isNull(inttraSoDto.getRemarks())) {
-						msg += "备注,";
-					} else {
-						Map<String, String> mapString1 = regularEn(inttraSoDto.getRemarks(),false);
-						if ("200".equals(mapString1.get("code"))) {
-							if (regularLength(mapString1.get("susscess"), 512)) {
-								textLength += "备注,";
-							} else {
-								inttraSoDto.setRemarks(mapString1.get("susscess"));
+					if (ObjectUtils.isNotNull(inttraSoDto.getBookingRemarks())) {
+						String bookingRemarks = inttraSoDto.getBookingRemarks().trim();
+						if(!bookingRemarks.isEmpty()) {
+							String[] bookingRemarksArr = bookingRemarks.replaceAll("\r", "").split("\n");
+							// text += String.join((CharSequence) ",", Arrays.stream(bookingRemarksArr).filter(a->!a.trim().isEmpty()));
+							Boolean firstLine = true;
+							for (int i = 0; i < bookingRemarksArr.length; i++) {
+								String line = bookingRemarksArr[i].trim();
+								if(!line.isEmpty()){
+									if(firstLine){
+										text += escapeEDILine(line);
+										firstLine = false;
+									}else{
+										text += ";" + escapeEDILine(line);
+									}
+								}
 							}
-						} else {
-							character += "备注,";
 						}
 					}
+					inttraSoDto.setBookingRemarks(text);
+				} else {
+					// 其他船公司不写
+					inttraSoDto.setBookingRemarks("");
+					//备注
+//					if (ObjectUtils.isNull(inttraSoDto.getBookingRemarks())) {
+//						msg += "备注,";
+//					} else {
+//						Map<String, String> mapString1 = regularEn(inttraSoDto.getBookingRemarks(),false);
+//						if ("200".equals(mapString1.get("code"))) {
+//							if (regularLength(mapString1.get("susscess"), 512)) {
+//								textLength += "备注,";
+//							} else {
+//								inttraSoDto.setBookingRemarks(mapString1.get("susscess"));
+//							}
+//						} else {
+//							character += "备注,";
+//						}
+//					}
 				}
 				inttraSoDto.setVesselCarrierCode(mapString.get("susscess"));
 			} else {
@@ -645,94 +809,34 @@ public class RegularUtils {
 			}
 		}
 		//发货人
-		if (ObjectUtils.isNull(inttraSoDto.getHsHipperOne())) {
+		if (ObjectUtils.isNull(inttraSoDto.getHShipper())) {
 			msg += "发货人,";
 		} else {
-			Map<String, String> mapString = regularEn(inttraSoDto.getHsHipperOne(), false);
+			Map<String, String> mapString = regularEn(inttraSoDto.getHShipper(), false);
 			if ("200".equals(mapString.get("code"))) {
-				String hipper = mapString.get("susscess");
-				/*if (regularLength(hipper, 35)) {
-					inttraSoDto.setHsHipperOne(hipper.substring(0, 35));
-					if (regularLength(hipper, 35) && hipper.length() <= 70) {
-						inttraSoDto.setHsHipperTwo(hipper.substring(35));
-					} else if (regularLength(hipper, 70) && hipper.length() <= 105) {
-						inttraSoDto.setHsHipperThree(hipper.substring(70));
-					} else if (regularLength(hipper, 105) && hipper.length() <= 140) {
-						inttraSoDto.setHsHipperFour(hipper.substring(105));
-					} else if (regularLength(hipper, 140) && hipper.length() <= 175) {
-						inttraSoDto.setHsHipperFive(hipper.substring(140));
-					} else {
-						inttraSoDto.setHsHipperFive(hipper.substring(174) + "*");
-						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
-							inttraSoDto.setProductName(inttraSoDto.getProductName() + "*" + hipper.substring(174));
-						}
-					}
-				} else {
-					inttraSoDto.setIdentifying(mapString.get("susscess"));
-				}*/
-				inttraSoDto.setHsHipperOne(mapString.get("susscess"));
+				inttraSoDto.setHShipper(mapString.get("susscess"));
 			} else {
 				character += "发货人,";
 			}
 		}
 		//收货人
-		if (ObjectUtils.isNull(inttraSoDto.getHConsigneeOne())) {
+		if (ObjectUtils.isNull(inttraSoDto.getHConsignee())) {
 			msg += "收货人,";
 		} else {
-			Map<String, String> mapString = regularEn(inttraSoDto.getHConsigneeOne(),false);
+			Map<String, String> mapString = regularEn(inttraSoDto.getHConsignee(),false);
 			if ("200".equals(mapString.get("code"))) {
-				String hConsignee = mapString.get("susscess");
-				/*if (regularLength(hConsignee, 35)) {
-					inttraSoDto.setHConsigneeOne(hConsignee.substring(0, 35));
-					if (regularLength(hConsignee, 35) && hConsignee.length() <= 70) {
-						inttraSoDto.setHConsigneeTwo(hConsignee.substring(35));
-					} else if (regularLength(hConsignee, 70) && hConsignee.length() <= 105) {
-						inttraSoDto.setHConsigneeThree(hConsignee.substring(70));
-					} else if (regularLength(hConsignee, 105) && hConsignee.length() <= 140) {
-						inttraSoDto.setHConsigneeFour(hConsignee.substring(105));
-					} else if (regularLength(hConsignee, 140) && hConsignee.length() <= 175) {
-						inttraSoDto.setHConsigneeFive(hConsignee.substring(140));
-					} else {
-						inttraSoDto.setHConsigneeFive(hConsignee.substring(174) + "*");
-						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
-							inttraSoDto.setProductName(inttraSoDto.getProductName() + "**" + hConsignee.substring(174));
-						}
-					}
-				} else {
-					inttraSoDto.setIdentifying(mapString.get("susscess"));
-				}*/
-				inttraSoDto.setHConsigneeOne(mapString.get("susscess"));
+				inttraSoDto.setHConsignee(mapString.get("susscess"));
 			} else {
 				character += "收货人,";
 			}
 		}
 		//通知人
-		if (ObjectUtils.isNull(inttraSoDto.getHNotifyOne())) {
+		if (ObjectUtils.isNull(inttraSoDto.getHNotify())) {
 			msg += "通知人,";
 		} else {
-			Map<String, String> mapString = regularEn(inttraSoDto.getHConsigneeOne(),false);
+			Map<String, String> mapString = regularEn(inttraSoDto.getHNotify(),false);
 			if ("200".equals(mapString.get("code"))) {
-				String hNotify = mapString.get("susscess");
-				/*if (regularLength(hNotify, 35)) {
-					inttraSoDto.setHNotifyOne(hNotify.substring(0, 35));
-					if (regularLength(hNotify, 35) && hNotify.length() <= 70) {
-						inttraSoDto.setHNotifyTwo(hNotify.substring(35));
-					} else if (regularLength(hNotify, 70) && hNotify.length() <= 105) {
-						inttraSoDto.setHNotifyThree(hNotify.substring(70));
-					} else if (regularLength(hNotify, 105) && hNotify.length() <= 140) {
-						inttraSoDto.setHNotifyFour(hNotify.substring(105));
-					} else if (regularLength(hNotify, 140) && hNotify.length() <= 175) {
-						inttraSoDto.setHNotifyFive(hNotify.substring(140));
-					} else {
-						inttraSoDto.setHNotifyFive(hNotify.substring(174) + "*");
-						if (ObjectUtils.isNotNull(inttraSoDto.getProductName())) {
-							inttraSoDto.setProductName(inttraSoDto.getProductName() + "***" + hNotify.substring(174));
-						}
-					}
-				} else {
-					inttraSoDto.setIdentifying(mapString.get("susscess"));
-				}*/
-				inttraSoDto.setHConsigneeOne(mapString.get("susscess"));
+				inttraSoDto.setHNotify(mapString.get("susscess"));
 			} else {
 				character += "通知人,";
 			}
@@ -750,17 +854,14 @@ public class RegularUtils {
 		}
 		//船司称呼
 		if (ObjectUtils.isNull(inttraSoDto.getCarrierName())) {
-			msg += "船司称,";
+			msg += "船司称,";
 		} else {
 			Map<String, String> mapString = regularEn(inttraSoDto.getCarrierName(),true);
 			if ("200".equals(mapString.get("code"))) {
-				if (regularLength(mapString.get("susscess"), 35)) {
-					textLength += "船司称呼,";
-				} else {
-					inttraSoDto.setCarrierName(mapString.get("susscess"));
-				}
+				String S = mapString.get("susscess");
+				inttraSoDto.setCarrierName(S.substring(0, S.length()));
 			} else {
-				character += "船司称,";
+				character += "船司名称,";
 			}
 		}
 		//联系信息
@@ -939,7 +1040,7 @@ public class RegularUtils {
 		}
 		//货代称呼
 		if (ObjectUtils.isNull(inttraSoDto.getFreightForwarderName())) {
-			msg += "货代称呼,";
+			// msg += "货代称呼,";
 		} else {
 			Map<String, String> mapString = regularEn(inttraSoDto.getFreightForwarderName(),true);
 			if ("200".equals(mapString.get("code"))) {
@@ -991,7 +1092,7 @@ public class RegularUtils {
 		}
 		//发送方联系电话
 		if (ObjectUtils.isNull(inttraSoDto.getSenderTel())) {
-			msg += "发送方联系电话,";
+			// msg += "发送方联系电话,";
 		} else {
 			Map<String, String> mapString = regularEn(inttraSoDto.getSenderTel(),true);
 			if ("200".equals(mapString.get("code"))) {
@@ -1021,9 +1122,6 @@ public class RegularUtils {
 		}
 		//提单份数
 		if (ObjectUtils.isNotNull(inttraSoDto.getBillLadingNumber())) {
-			if (regularLength(inttraSoDto.getBillLadingNumber().toString(), 2)) {
-				textLength += "提单份数,";
-			}
 		}
 		//包装件数
 		if (ObjectUtils.isNull(inttraSoDto.getPackagesNumbers())) {
@@ -1061,20 +1159,20 @@ public class RegularUtils {
 		}
 		//HS 编码
 		if (ObjectUtils.isNotNull(inttraSoDto.getHsCode())) {
-			if (regularLength(inttraSoDto.getHsCode().toString(), 10)) {
+			if (regularLength(inttraSoDto.getHsCode(), 10)) {
 				textLength += "HS 编码,";
 			}
 		}
 		//货描
-		if (ObjectUtils.isNull(inttraSoDto.getProductName())) {
+		if (ObjectUtils.isNull(inttraSoDto.getGoodsDesc())) {
 			msg += "货描,";
 		} else {
-			Map<String, String> mapString = regularEn(inttraSoDto.getProductName(),false);
+			Map<String, String> mapString = regularEn(inttraSoDto.getGoodsDesc(),false);
 			if ("200".equals(mapString.get("code"))) {
 				if (regularLength(mapString.get("susscess"), 512)) {
 					textLength += "货描,";
 				} else {
-					inttraSoDto.setProductName(mapString.get("susscess"));
+					inttraSoDto.setGoodsDesc(mapString.get("susscess"));
 				}
 			} else {
 				character += "货描,";
@@ -1098,105 +1196,110 @@ public class RegularUtils {
 		}
 		//麦头
 		if (ObjectUtils.isNull(inttraSoDto.getMarks())) {
-			msg += "头,";
+			msg += "头,";
 		} else {
 			Map<String, String> mapString = regularEn(inttraSoDto.getMarks(),true);
 			if ("200".equals(mapString.get("code"))) {
 				//35*50
 				if (regularLength(mapString.get("susscess"), 1750)) {
-					textLength += "头,";
+					textLength += "头,";
 				} else {
 					inttraSoDto.setMarks(mapString.get("susscess"));
 				}
 			} else {
-				character += "头,";
+				character += "头,";
 			}
 		}
 		//危险品国际编码
-		if (ObjectUtils.isNotNull(inttraSoDto.getDgUnCode())) {
-			if (regularLength(inttraSoDto.getDgUnCode(), 4)) {
-				textLength += "危险品国际编码,";
-			}
-		}
-		//页号
-		if (ObjectUtils.isNotNull(inttraSoDto.getPageNumber())) {
-			if (regularLength(inttraSoDto.getPageNumber().toString(), 7)) {
-				textLength += "页号,";
-			}
-		}
-		//闪点
-		if (ObjectUtils.isNotNull(inttraSoDto.getDgFlashPoint())) {
-			// todo
-			StringBuilder data = new StringBuilder();
-			boolean status = false;
-			if (inttraSoDto.getDgFlashPoint().indexOf("-") != 0) {
-				data = new StringBuilder(inttraSoDto.getDgFlashPoint().substring(0, inttraSoDto.getDgFlashPoint().indexOf("-")));
-				status = true;
-			}
-			if (regularLength(data.toString(), 3)) {
-				textLength += "闪点,";
-			} else {
-				int count = 3 - data.length();
-				if (status) {
-					for (int i = 0; i < count; i++) {
-						data.insert(0, "0");
+		if (inttraSoDto.getCargoType().equals("danger")) {
+			if (ObjectUtils.isNotNull(inttraSoDto.getDgUnCode())) {
+				if (regularLength(inttraSoDto.getDgUnCode(), 4)) {
+					textLength += "危险品国际编码,";
+				}
+			}else{
+				msg += "危险品国际编码,";
+			}
+			//页号
+			if (ObjectUtils.isNotNull(inttraSoDto.getPageNumber())) {
+				if (regularLength(inttraSoDto.getPageNumber().toString(), 7)) {
+					textLength += "页号,";
+				}
+			}
+			//闪点
+			if (ObjectUtils.isNotNull(inttraSoDto.getDgFlashPoint())) {
+				// todo
+				StringBuilder data = new StringBuilder();
+				boolean status = false;
+				if (inttraSoDto.getDgFlashPoint().indexOf("-") != 0) {
+					data = new StringBuilder(inttraSoDto.getDgFlashPoint().substring(0, inttraSoDto.getDgFlashPoint().indexOf("-")));
+					status = true;
+				}
+				if (regularLength(data.toString(), 3)) {
+					textLength += "闪点,";
+				} else {
+					int count = 3 - data.length();
+					if (status) {
+						for (int i = 0; i < count; i++) {
+							data.insert(0, "0");
+						}
+						inttraSoDto.setDgFlashPoint("-" + data);
 					}
-					inttraSoDto.setDgFlashPoint("-" + data);
 				}
 			}
-		}
-		//应急措施号
-		if (ObjectUtils.isNotNull(inttraSoDto.getEmergencyMeasureNo())) {
-			Map<String, String> mapString = regularEn(inttraSoDto.getEmergencyMeasureNo(),true);
-			if ("200".equals(mapString.get("code"))) {
-				if (regularLength(mapString.get("susscess"), 6)) {
-					textLength += "应急措施号,";
+			//应急措施号
+			if (ObjectUtils.isNotNull(inttraSoDto.getEmergencyMeasureNo())) {
+				Map<String, String> mapString = regularEn(inttraSoDto.getEmergencyMeasureNo(), true);
+				if ("200".equals(mapString.get("code"))) {
+					if (regularLength(mapString.get("susscess"), 6)) {
+						textLength += "应急措施号,";
+					} else {
+						inttraSoDto.setEmergencyMeasureNo(mapString.get("susscess"));
+					}
 				} else {
-					inttraSoDto.setEmergencyMeasureNo(mapString.get("susscess"));
+					character += "应急措施号,";
 				}
-			} else {
-				character += "应急措施号,";
 			}
-		}
-		//危险品备注
-		if (ObjectUtils.isNotNull(inttraSoDto.getDgRemarks())) {
-			Map<String, String> mapString = regularEn(inttraSoDto.getDgRemarks(),false);
-			if ("200".equals(mapString.get("code"))) {
-				if (regularLength(mapString.get("susscess"), 30)) {
-					textLength += "危险品备注,";
+			//危险品备注
+			if (ObjectUtils.isNotNull(inttraSoDto.getDgRemarks())) {
+				Map<String, String> mapString = regularEn(inttraSoDto.getDgRemarks(), false);
+				if ("200".equals(mapString.get("code"))) {
+					if (regularLength(mapString.get("susscess"), 30)) {
+						textLength += "危险品备注,";
+					} else {
+						inttraSoDto.setDgRemarks(mapString.get("susscess"));
+					}
 				} else {
-					inttraSoDto.setDgRemarks(mapString.get("susscess"));
+					character += "危险品备注,";
 				}
-			} else {
-				character += "危险品备注,";
 			}
-		}
-		//危险品联系人
-		if (ObjectUtils.isNotNull(inttraSoDto.getDgContacts())) {
-			Map<String, String> mapString = regularEn(inttraSoDto.getDgContacts(),true);
-			if ("200".equals(mapString.get("code"))) {
-				if (regularLength(mapString.get("susscess"), 35)) {
-					textLength += "危险品联系人,";
+			//危险品联系人
+			if (ObjectUtils.isNotNull(inttraSoDto.getDgContacts())) {
+				Map<String, String> mapString = regularEn(inttraSoDto.getDgContacts(), true);
+				if ("200".equals(mapString.get("code"))) {
+					if (regularLength(mapString.get("susscess"), 35)) {
+						textLength += "危险品联系人,";
+					} else {
+						inttraSoDto.setDgContacts(mapString.get("susscess"));
+					}
 				} else {
-					inttraSoDto.setDgContacts(mapString.get("susscess"));
+					character += "危险品联系人,";
 				}
-			} else {
-				character += "危险品联系人,";
 			}
-		}
-		//危险品电话号码
-		if (ObjectUtils.isNotNull(inttraSoDto.getDgTel())) {
-			Map<String, String> mapString = regularEn(inttraSoDto.getDgTel(),true);
-			if ("200".equals(mapString.get("code"))) {
-				if (regularLength(mapString.get("susscess"), 512)) {
-					textLength += "危险品电话号码,";
+			//危险品电话号码
+			if (ObjectUtils.isNotNull(inttraSoDto.getDgTel())) {
+				Map<String, String> mapString = regularEn(inttraSoDto.getDgTel(), true);
+				if ("200".equals(mapString.get("code"))) {
+					if (regularLength(mapString.get("susscess"), 512)) {
+						textLength += "危险品电话号码,";
+					} else {
+						inttraSoDto.setDgTel(mapString.get("susscess"));
+					}
 				} else {
-					inttraSoDto.setDgTel(mapString.get("susscess"));
+					character += "危险品电话号码,";
 				}
-			} else {
-				character += "危险品电话号码,";
 			}
 		}
+
 		if (ObjectUtils.isNull(inttraSoDto.getBox())) {
 			msg += "箱型代码,";
 		} else {
@@ -2095,7 +2198,7 @@ public class RegularUtils {
 		}
 		//HS 编码
 		if (ObjectUtils.isNotNull(inttraSoDto.getHsCode())) {
-			if (regularLength(inttraSoDto.getHsCode().toString(), 10)) {
+			if (regularLength(inttraSoDto.getHsCode(), 10)) {
 				textLength += "HS 编码,";
 			}
 		}

+ 1 - 1
blade-service/blade-los/src/main/java/org/springblade/los/edi/dto/InttraSiDto.java

@@ -352,7 +352,7 @@ public class InttraSiDto {
 	/**
 	 * HS 编码
 	 */
-	private BigDecimal hsCode;
+	private String hsCode;
 
 	/*     FTX+AAA+++   */
 	/**

+ 18 - 62
blade-service/blade-los/src/main/java/org/springblade/los/edi/dto/InttraSoDto.java

@@ -69,7 +69,7 @@ public class InttraSoDto {
 	/**
 	 * 备注
 	 */
-	private String remarks;
+	private String bookingRemarks;
 
 	/*   FTX+BLC+++   */
 	/**
@@ -99,7 +99,7 @@ public class InttraSoDto {
 	/**
 	 * 总箱数
 	 */
-	private BigDecimal totalBoxNumber;
+	private int totalBoxNumber;
 
 	/*   LOC+57+   */
 	/**
@@ -143,7 +143,7 @@ public class InttraSoDto {
 	/**
 	 * 运费协议号
 	 */
-	private String freightProtocolNumber;
+	private String corpArgreementNo;
 
 	/*   RFF+SI:   */
 	/**
@@ -231,70 +231,21 @@ public class InttraSoDto {
 
 	/*   NAD+CZ+++   */
 	/**
-	 * 发货人 1
+	 * 发货人
 	 */
-	private String hsHipperOne;
-	/**
-	 * 发货人 2
-	 */
-	private String hsHipperTwo;
-	/**
-	 * 发货人 3
-	 */
-	private String hsHipperThree;
-	/**
-	 * 发货人 4
-	 */
-	private String hsHipperFour;
-	/**
-	 * 发货人 5
-	 */
-	private String hsHipperFive;
+	private String hShipper;
 
 	/*   NAD+CN+++   */
 	/**
-	 * 收货人 1
-	 */
-	private String hConsigneeOne;
-	/**
-	 * 收货人 2
-	 */
-	private String hConsigneeTwo;
-	/**
-	 * 收货人 3
-	 */
-	private String hConsigneeThree;
-	/**
-	 * 收货人 4
+	 * 收货人
 	 */
-	private String hConsigneeFour;
-	/**
-	 * 收货人 5
-	 */
-	private String hConsigneeFive;
+	private String hConsignee;
 
 	/*   NAD+NI+++   */
 	/**
-	 * 通知人 1
-	 */
-	private String hNotifyOne;
-	/**
-	 * 通知人 2
-	 */
-	private String hNotifyTwo;
-	/**
-	 * 通知人 3
-	 */
-	private String hNotifyThree;
-	/**
-	 * 通知人 4
-	 */
-	private String hNotifyFour;
-	/**
-	 * 通知人 5
+	 * 通知人
 	 */
-	private String hNotifyFive;
-
+	private String hNotify;
 	/*    NAD+CA+   */
 	/**
 	 * 船司代码
@@ -442,7 +393,7 @@ public class InttraSoDto {
 	/**
 	 * 提单份数
 	 */
-	private BigDecimal billLadingNumber;
+	private int billLadingNumber;
 
 	/*     GID+1+   */
 	/**
@@ -462,13 +413,18 @@ public class InttraSoDto {
 	/**
 	 * HS 编码
 	 */
-	private BigDecimal hsCode;
+	private String hsCode;
+
+	/**
+	 * 货类
+	 */
+	private String cargoType;
 
 	/*     FTX+AAA+++   */
 	/**
-	 * 品名
+	 * 货描
 	 */
-	private String productName;
+	private String goodsDesc;
 
 	/*     MEA+AAE+WT+KGM:   */
 	/**

+ 179 - 300
blade-service/blade-los/src/main/java/org/springblade/los/edi/service/impl/EDISenderServiceImpl.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.los.Util.RegularUtils;
 import org.springblade.los.business.files.entity.FilesCenter;
 import org.springblade.los.edi.dto.*;
 import org.springblade.los.edi.service.IEDISenderService;
@@ -35,8 +36,8 @@ public class EDISenderServiceImpl implements IEDISenderService {
 		Date date = new Date();
 		try {
 			//生成edi文件
-			File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSoDto.getEdiTypes().getCode() + ".txt");
-//			File file = new File("D:/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", sdf1.format(date) + "-edi.text");
+			// File file = new File("/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSoDto.getEdiTypes().getCode() + ".txt");
+			File file = new File("D:/home/minio/file/" + AuthUtil.getTenantId() + "-bladex/upload", inttraSoDto.getEdiTypes().getCode() + ".txt");
 			file.createNewFile();
 			// 打开文件输出流进行写入操作
 			BufferedWriter writer = new BufferedWriter(new FileWriter(file));
@@ -52,11 +53,11 @@ public class EDISenderServiceImpl implements IEDISenderService {
 			writer.newLine();
 			count += 1;
 			/* =================0020=================  */
-			writer.write("BGM+335+" + inttraSoDto.getIdentificationCode() + "+" + inttraSoDto.getFilesFunction() + "'");
+			writer.write("BGM+335+" + inttraSoDto.getIdentificationCode() + "FB+" + inttraSoDto.getFilesFunction() + "'");
 			writer.newLine();
 			count += 1;
 			/* =================0050=================  */
-			writer.write("DTM+137:" + inttraSoDto.getFilesDate() + "203'");
+			writer.write("DTM+137:" + inttraSoDto.getFilesDate() + ":203'");
 			writer.newLine();
 			count += 1;
 			/* =================0060=================  */
@@ -64,7 +65,7 @@ public class EDISenderServiceImpl implements IEDISenderService {
 			writer.newLine();
 			count += 1;
 			/* =================0090=================  */
-			writer.write("FTX+AAI+++" + inttraSoDto.getRemarks() + "'");
+			writer.write("FTX+AAI+++" + inttraSoDto.getBookingRemarks() + "'");
 			writer.newLine();
 			count += 1;
 			if (ObjectUtils.isNotNull(inttraSoDto.getCarrySingleRemarks())) {
@@ -126,11 +127,13 @@ public class EDISenderServiceImpl implements IEDISenderService {
 			count += 1;
 			if (ObjectUtils.isNotNull(inttraSoDto.getBillNo())) {
 				writer.write("RFF+BM:" + inttraSoDto.getBillNo() + "'");
-				writer.newLine();
-				count += 1;
+			}else{
+				writer.write("RFF+BM:'");
 			}
-			if (ObjectUtils.isNotNull(inttraSoDto.getFreightProtocolNumber())) {
-				writer.write("RFF+CT:" + inttraSoDto.getFreightProtocolNumber() + "'");
+			writer.newLine();
+			count += 1;
+			if (ObjectUtils.isNotNull(inttraSoDto.getCorpArgreementNo())) {
+				writer.write("RFF+CT:" + inttraSoDto.getCorpArgreementNo() + "'");
 				writer.newLine();
 				count += 1;
 			}
@@ -163,7 +166,7 @@ public class EDISenderServiceImpl implements IEDISenderService {
 			if (inttraSoDto.getVoyageNo().indexOf("V.") > 0) {
 				throw new RuntimeException("航次中不能存在‘V.’");
 			} else {
-				if ("MAEU".equals(inttraSoDto.getCarrierCode())) {
+				if ("MAEU---AA".equals(inttraSoDto.getCarrierCode())) {
 					writer.write("TDT+20+XXX+1++");
 					if (ObjectUtils.isNotNull(inttraSoDto.getVesselCarrierCode())) {
 						writer.write(inttraSoDto.getVesselCarrierCode() + ":172+++:::XXX'");
@@ -174,8 +177,8 @@ public class EDISenderServiceImpl implements IEDISenderService {
 					}
 				} else {
 					writer.write("TDT+20+" + inttraSoDto.getVoyageNo() + "+1++");
-					if (ObjectUtils.isNotNull(inttraSoDto.getVesselCarrierCode())) {
-						writer.write(inttraSoDto.getVesselCarrierCode() + ":172+++:::" + inttraSoDto.getVesselName() + "'");
+					if (ObjectUtils.isNotNull(inttraSoDto.getCarrierCode())) {
+						writer.write(inttraSoDto.getCarrierCode() + ":172+++:::" + inttraSoDto.getVesselName() + "'");
 						writer.newLine();
 					} else {
 						writer.write(":172+++:::" + inttraSoDto.getVesselName() + "'");
@@ -215,17 +218,19 @@ public class EDISenderServiceImpl implements IEDISenderService {
 			writer.newLine();
 			count += 1;
 			/* =================0630=================  */
-			writer.write("COM+" + inttraSoDto.getSenderTel() + ":TE'");
-			writer.newLine();
-			count += 1;
+			if (ObjectUtils.isNotNull(inttraSoDto.getSenderTel())) {
+				writer.write("COM+" + inttraSoDto.getSenderTel() + ":TE'");
+				writer.newLine();
+				count += 1;
+			}
 			writer.write("COM+" + inttraSoDto.getSenderEmail() + ":EM'");
 			writer.newLine();
 			count += 1;
 			/* =================0580=================  */
 			if (ObjectUtils.isNotNull(inttraSoDto.getFreightForwarderCode())) {
-				writer.write("NAD+FW+" + inttraSoDto.getFreightForwarderCode() + ":160");
+				writer.write("NAD+FW+++" + inttraSoDto.getFreightForwarderCode());
 				if (ObjectUtils.isNotNull(inttraSoDto.getFreightForwarderName())) {
-					writer.write(":86++" + inttraSoDto.getFreightForwarderName() + "'");
+					writer.write(":160:86++" + inttraSoDto.getFreightForwarderName() + "'");
 					writer.newLine();
 				} else {
 					writer.write("'");
@@ -234,308 +239,53 @@ public class EDISenderServiceImpl implements IEDISenderService {
 				count += 1;
 			}
 			/* =================0580=================  */
-			writer.write("NAD+CZ+++" + inttraSoDto.getHsHipperOne());
-			if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperOne())) {
-				String[] arr = inttraSoDto.getHsHipperOne().split("\n");
-				//todo  NAD+CZ
-				List<String> list = new ArrayList<>();
-				Pattern pattern1 = Pattern.compile("[a-zA-Z]");
-				for (String item : arr) {
-					String go = item.trim();
-					while (!go.isEmpty()) {
-						if (go.length() <= 35) {
-							list.add(go);
-							go = "";
-						} else {
-							if (!pattern1.matcher(go.charAt(35) + "").matches()) {
-								list.add(go.substring(0, 35));
-								go = go.substring(35);
-							} else {
-								int p = -1;
-								for (int i = 34; i >= 0; i--) {
-									if (!pattern1.matcher(go.charAt(i) + "").matches()) {
-										p = i;
-										break;
-									} else {
-										list.add(go);
-										go = "";
-									}
-								}
-								if (p == -1) {
-									list.add(go.substring(0, 35));
-									go = go.substring(35);
-								} else {
-									list.add(go.substring(0, p + 1));
-									go = go.substring(p + 1);
-								}
-							}
-						}
-					}
-				}
-			}
-			/*if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperFive())) {
-				if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperTwo())) {
-					writer.write(":" + inttraSoDto.getHsHipperTwo());
-				} else {
-					writer.write(":");
-				}
-				if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperThree())) {
-					writer.write(":" + inttraSoDto.getHsHipperThree());
+			// 处理收发通之前,先处理货描,因为收发通多余的部分要追加到货描
+			List<String> goodsDesc = RegularUtils.reformatEDIText(inttraSoDto.getGoodsDesc(), 35, true);
+			// 发货人
+			List<String> hShipper = RegularUtils.reformatEDIText(inttraSoDto.getHShipper(), 35, true);
+			writer.write("NAD+CZ+++");
+			for (int l=0; l<hShipper.size(); l++){
+				if (l<5) {
+					writer.write((l > 0) ? ((l == 1) ? "+" : ":") : "");
+					writer.write(hShipper.get(l));
 				} else {
-					writer.write(":");
-				}
-				if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperFour())) {
-					writer.write(":" + inttraSoDto.getHsHipperFour());
-				} else {
-					writer.write(":");
+					goodsDesc.add("*" + hShipper.get(l));
 				}
-				writer.write(":" + inttraSoDto.getHsHipperFive());
-			} else {
-				if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperFour())) {
-					if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperTwo())) {
-						writer.write(":" + inttraSoDto.getHsHipperTwo());
-					} else {
-						writer.write(":");
-					}
-					if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperThree())) {
-						writer.write(":" + inttraSoDto.getHsHipperThree());
-					} else {
-						writer.write(":");
-					}
-					writer.write(":" + inttraSoDto.getHsHipperFour());
-				} else {
-					if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperThree())) {
-						if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperTwo())) {
-							writer.write(":" + inttraSoDto.getHsHipperTwo());
-						} else {
-							writer.write(":");
-						}
-						writer.write(":" + inttraSoDto.getHsHipperThree());
-					} else {
-						if (ObjectUtils.isNotNull(inttraSoDto.getHsHipperTwo())) {
-							writer.write(":" + inttraSoDto.getHsHipperTwo());
-						}
-					}
-				}
-			}*/
+			}
 			writer.write("'");
 			writer.newLine();
 			count += 1;
 
-			writer.write("NAD+CN+++" + inttraSoDto.getHConsigneeOne());
-			if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeFive())) {
-				if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeTwo())) {
-					writer.write(":" + inttraSoDto.getHConsigneeTwo());
-				} else {
-					writer.write(":");
-				}
-				if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeThree())) {
-					writer.write(":" + inttraSoDto.getHConsigneeThree());
-				} else {
-					writer.write(":");
-				}
-				if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeFour())) {
-					writer.write(":" + inttraSoDto.getHConsigneeFour());
+			// 发货人
+			List<String> hConsignee = RegularUtils.reformatEDIText(inttraSoDto.getHConsignee(), 35, true);
+			writer.write("NAD+CN+++");
+			for (int l=0; l<hConsignee.size(); l++){
+				if (l<5) {
+					writer.write((l > 0) ? ((l == 1) ? "+" : ":") : "");
+					writer.write(hConsignee.get(l));
 				} else {
-					writer.write(":");
-				}
-				writer.write(":" + inttraSoDto.getHConsigneeFive());
-			} else {
-				if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeFour())) {
-					if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeTwo())) {
-						writer.write(":" + inttraSoDto.getHConsigneeTwo());
-					} else {
-						writer.write(":");
-					}
-					if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeThree())) {
-						writer.write(":" + inttraSoDto.getHConsigneeThree());
-					} else {
-						writer.write(":");
-					}
-					writer.write(":" + inttraSoDto.getHConsigneeFour());
-				} else {
-					if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeThree())) {
-						if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeTwo())) {
-							writer.write(":" + inttraSoDto.getHConsigneeTwo());
-						} else {
-							writer.write(":");
-						}
-						writer.write(":" + inttraSoDto.getHConsigneeThree());
-					} else {
-						if (ObjectUtils.isNotNull(inttraSoDto.getHConsigneeTwo())) {
-							writer.write(":" + inttraSoDto.getHConsigneeTwo());
-						}
-					}
+					goodsDesc.add("**" + hConsignee.get(l));
 				}
 			}
 			writer.write("'");
 			writer.newLine();
 			count += 1;
-			writer.write("NAD+NI+++" + inttraSoDto.getHNotifyOne());
-			if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyFive())) {
-				if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyTwo())) {
-					writer.write(":" + inttraSoDto.getHNotifyTwo());
-				} else {
-					writer.write(":");
-				}
-				if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyThree())) {
-					writer.write(":" + inttraSoDto.getHNotifyThree());
-				} else {
-					writer.write(":");
-				}
-				if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyFour())) {
-					writer.write(":" + inttraSoDto.getHNotifyFour());
-				} else {
-					writer.write(":");
-				}
-				writer.write(":" + inttraSoDto.getHNotifyFive());
-			} else {
-				if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyFour())) {
-					if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyTwo())) {
-						writer.write(":" + inttraSoDto.getHNotifyTwo());
-					} else {
-						writer.write(":");
-					}
-					if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyThree())) {
-						writer.write(":" + inttraSoDto.getHNotifyThree());
-					} else {
-						writer.write(":");
-					}
-					writer.write(":" + inttraSoDto.getHNotifyFour());
+
+			// 发货人
+			List<String> hNotify = RegularUtils.reformatEDIText(inttraSoDto.getHNotify(), 35, true);
+			writer.write("NAD+NI+++");
+			for (int l=0; l<hNotify.size(); l++){
+				if (l<5) {
+					writer.write((l > 0) ? ((l == 1) ? "+" : ":") : "");
+					writer.write(hNotify.get(l));
 				} else {
-					if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyThree())) {
-						if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyTwo())) {
-							writer.write(":" + inttraSoDto.getHNotifyTwo());
-						} else {
-							writer.write(":");
-						}
-						writer.write(":" + inttraSoDto.getHNotifyThree());
-					} else {
-						if (ObjectUtils.isNotNull(inttraSoDto.getHNotifyTwo())) {
-							writer.write(":" + inttraSoDto.getHNotifyTwo());
-						}
-					}
+					goodsDesc.add("***" + hNotify.get(l));
 				}
 			}
 			writer.write("'");
 			writer.newLine();
 			count += 1;
-			/* =================0650=================  */
-			if (ObjectUtils.isNotNull(inttraSoDto.getBillLadingType())) {
-				writer.write("DOC+" + inttraSoDto.getBillLadingType());
-				if (ObjectUtils.isNotNull(inttraSoDto.getPaymentStatus())) {
-					writer.write("+:" + inttraSoDto.getPaymentStatus() + "+:" + inttraSoDto.getBillLadingNumber() + "'");
-					writer.newLine();
-				} else {
-					writer.write("+:+:" + inttraSoDto.getBillLadingNumber() + "'");
-					writer.newLine();
-				}
-				count += 1;
-			}
-			/* =================0910=================  */
-			if (ObjectUtils.isNotNull(inttraSoDto.getPackagesNumbers())) {
-				writer.write("GID+1+" + inttraSoDto.getPackagesNumbers() + ":" + inttraSoDto.getPackagesCode() + "::6");
-				if (ObjectUtils.isNotNull(inttraSoDto.getPackagesDescribe())) {
-					writer.write(":" + inttraSoDto.getPackagesDescribe() + "'");
-					writer.newLine();
-				} else {
-					writer.write("'");
-					writer.newLine();
-				}
-				count += 1;
-			}
-			/* =================0980=================  */
-			if (ObjectUtils.isNotNull(inttraSoDto.getHsCode())) {
-				writer.write("PIA+5+" + inttraSoDto.getHsCode() + ":HS'");
-				writer.newLine();
-				count += 1;
-			}
-			/* =================0990=================  */
-			writer.write("FTX+AAA+++" + inttraSoDto.getProductName() + "'");
-			writer.newLine();
-			count += 1;
-			/* =================1070=================  */
-			writer.write("MEA+AAE+AAW+MTQ:" + inttraSoDto.getMeasurement() + "'");
-			writer.newLine();
-			count += 1;
-			writer.write("MEA+AAE+WT+KGM:" + inttraSoDto.getGrossWeight() + "'");
-			writer.newLine();
-			count += 1;
-			/* =================1160=================  */
-			BigDecimal sum = new BigDecimal(inttraSoDto.getMarks().length()).divide(new BigDecimal("35"), 2, RoundingMode.HALF_UP).setScale(0, RoundingMode.HALF_UP);
-			int subS = 0;
-			int subE = 35;
-			for (int i = 0; i <= sum.intValue(); i++) {
-				String marks = "";
-				if (inttraSoDto.getMarks().length() > subE) {
-					marks = inttraSoDto.getMarks().substring(subS, subE);
-				} else {
-					marks = inttraSoDto.getMarks().substring(subS);
-				}
-				writer.write("PCI++" + marks + "'");
-				writer.newLine();
-				count += 1;
-				subS = subS + 35;
-				subE = subE + 35;
-			}
-			if (ObjectUtils.isNotNull(inttraSoDto.getBox())) {
-				List<Map<String, Object>> mapList = inttraSoDto.getBox();
-				for (Map<String, Object> map1 : mapList) {
-					/* =================1660=================  */
-					writer.write("EQD+CN++" + map1.get("boxCode"));
-					if (ObjectUtils.isNotNull(map1.get("shipperBoxIdentification"))) {
-						writer.write("+" + map1.get("shipperBoxIdentification") + "'");
-						writer.newLine();
-					} else {
-						writer.write("'");
-						writer.newLine();
-					}
-					count += 1;
-					/* =================1670=================  */
-					if (ObjectUtils.isNotNull(map1.get("boxNumber"))) {
-						writer.write("EQN+" + map1.get("boxNumber") + "'");
-						writer.newLine();
-						count += 1;
-					}
-					/* =================1690=================  */
-					if (ObjectUtils.isNotNull(map1.get("ventilation"))) {
-						writer.write("MEA+AAE+AAS+CBM:" + map1.get("ventilation") + "'");
-						writer.newLine();
-						count += 1;
-					}
-					/* =================1740=================  */
-					if (ObjectUtils.isNotNull(map1.get("temperature"))) {
-						writer.write("TMP+2+" + map1.get("temperature"));
-						if (ObjectUtils.isNotNull(map1.get("temperatureUnit"))) {
-							writer.write(":" + map1.get("temperatureUnit") + "'");
-							writer.newLine();
-						} else {
-							writer.write("'");
-							writer.newLine();
-						}
-						count += 1;
-					}
-				}
-			}
-
 
-			if (ObjectUtils.isNotNull(inttraSoDto.getContactInformation())) {
-				writer.write("NAD+MR+++" + inttraSoDto.getContactInformation() + "'");
-				writer.newLine();
-				count += 1;
-			}
-			/* =================0620=================  */
-			if (ObjectUtils.isNotNull(inttraSoDto.getContacts())) {
-				writer.write("CTA+NT+:" + inttraSoDto.getContacts() + "'");
-				writer.newLine();
-				count += 1;
-			}
-			/* =================0630=================  */
-			if (ObjectUtils.isNotNull(inttraSoDto.getAttnEmail())) {
-				writer.write("COM+" + inttraSoDto.getAttnEmail() + ":EM'");
-				writer.newLine();
-				count += 1;
-			}
 			if (ObjectUtils.isNotNull(inttraSoDto.getTransportTermName())) {
 				if ("DOOR".equals(inttraSoDto.getTransportTermName().substring(0, 4))) {
 					/* =================0580=================  */
@@ -669,6 +419,77 @@ public class EDISenderServiceImpl implements IEDISenderService {
 					}
 				}
 			}
+
+			/* =================0650=================  */
+			if (ObjectUtils.isNotNull(inttraSoDto.getBillLadingType())) {
+				writer.write("DOC+" + inttraSoDto.getBillLadingType());
+				if (ObjectUtils.isNotNull(inttraSoDto.getPaymentStatus())) {
+					writer.write("+:" + inttraSoDto.getPaymentStatus() + "++" + inttraSoDto.getBillLadingNumber() + "'");
+					writer.newLine();
+				} else {
+					writer.write("+:++" + inttraSoDto.getBillLadingNumber() + "'");
+					writer.newLine();
+				}
+				count += 1;
+			}
+			/* =================0910=================  */
+			if (ObjectUtils.isNotNull(inttraSoDto.getPackagesNumbers())) {
+				writer.write("GID+1+" + inttraSoDto.getPackagesNumbers() + ":" + inttraSoDto.getPackagesCode() + "::6");
+				if (ObjectUtils.isNotNull(inttraSoDto.getPackagesDescribe())) {
+					writer.write(":" + inttraSoDto.getPackagesDescribe() + "'");
+					writer.newLine();
+				} else {
+					writer.write(":'");
+					writer.newLine();
+				}
+				count += 1;
+			}
+			/* =================0980=================  */
+			if (ObjectUtils.isNotNull(inttraSoDto.getHsCode())) {
+				writer.write("PIA+5+" + inttraSoDto.getHsCode() + ":HS'");
+				writer.newLine();
+				count += 1;
+			}
+			/* =================0990=================  */
+			// writer.write("FTX+AAA+++" + inttraSoDto.getProductName() + "'");
+			for(String line : goodsDesc){
+				writer.write("FTX+AAA+++" + line + "'");
+				writer.newLine();
+				count += 1;
+			}
+			/* =================1070=================  */
+			writer.write("MEA+AAE+AAW+MTQ:" + inttraSoDto.getVolumeOfGoods() + "'");
+			writer.newLine();
+			count += 1;
+			writer.write("MEA+AAE+WT+KGM:" + inttraSoDto.getGrossWeight() + "'");
+			writer.newLine();
+			count += 1;
+			/* =================1160=================  */
+			/*
+			BigDecimal sum = new BigDecimal(inttraSoDto.getMarks().length()).divide(new BigDecimal("35"), 2, RoundingMode.HALF_UP).setScale(0, RoundingMode.HALF_UP);
+			int subS = 0;
+			int subE = 35;
+			for (int i = 0; i <= sum.intValue(); i++) {
+				String marks = "";
+				if (inttraSoDto.getMarks().length() > subE) {
+					marks = inttraSoDto.getMarks().substring(subS, subE);
+				} else {
+					marks = inttraSoDto.getMarks().substring(subS);
+				}
+				writer.write("PCI++" + marks + "'");
+				writer.newLine();
+				count += 1;
+				subS = subS + 35;
+				subE = subE + 35;
+			}
+			 */
+			List<String> goodsMarks = RegularUtils.reformatEDIText(inttraSoDto.getMarks(), 35, true);
+			for(String line : goodsMarks){
+				writer.write("PCI++" + line + "'");
+				writer.newLine();
+				count += 1;
+			}
+
 			/* =================1520=================  */
 			if (ObjectUtils.isNotNull(inttraSoDto.getDgImdgCode())) {
 				writer.write("DGS+IMD+" + inttraSoDto.getDgImdgCode());
@@ -803,6 +624,64 @@ public class EDISenderServiceImpl implements IEDISenderService {
 				count += 1;
 			}
 
+			if (ObjectUtils.isNotNull(inttraSoDto.getBox())) {
+				List<Map<String, Object>> mapList = inttraSoDto.getBox();
+				for (Map<String, Object> map1 : mapList) {
+					/* =================1660=================  */
+					writer.write("EQD+CN++" + map1.get("boxCode"));
+					writer.write("+" + (map1.get("isSoc").equals(1)?"1":"2") + "'");
+					writer.newLine();
+					count += 1;
+					/* =================1670=================  */
+					if (ObjectUtils.isNotNull(map1.get("boxNumber"))) {
+						writer.write("EQN+" + map1.get("boxNumber") + "'");
+						writer.newLine();
+						count += 1;
+					}
+					/* =================1690=================  */
+					if (ObjectUtils.isNotNull(map1.get("ventilation"))) {
+						writer.write("MEA+AAE+AAS+CBM:" + map1.get("ventilation") + "'");
+						writer.newLine();
+						count += 1;
+					}
+					/* =================1740=================  */
+					if (ObjectUtils.isNotNull(map1.get("temperature"))) {
+						writer.write("TMP+2+" + map1.get("temperature"));
+						if (ObjectUtils.isNotNull(map1.get("temperatureUnit"))) {
+							writer.write(":" + map1.get("temperatureUnit") + "'");
+							writer.newLine();
+						} else {
+							writer.write("'");
+							writer.newLine();
+						}
+						count += 1;
+					}
+					if (ObjectUtils.isNotNull(map1.get("humidity"))) {
+						writer.write("MEA+AAE+AAO+HMD:" + map1.get("humidity") + "'");
+						writer.newLine();
+						count += 1;
+					}
+				}
+			}
+
+			if (ObjectUtils.isNotNull(inttraSoDto.getContactInformation())) {
+				writer.write("NAD+MR+++" + inttraSoDto.getContactInformation() + "'");
+				writer.newLine();
+				count += 1;
+			}
+
+			/* =================0620=================  */
+			if (ObjectUtils.isNotNull(inttraSoDto.getContacts())) {
+				writer.write("CTA+NT+:" + inttraSoDto.getContacts() + "'");
+				writer.newLine();
+				count += 1;
+			}
+			/* =================0630=================  */
+			if (ObjectUtils.isNotNull(inttraSoDto.getAttnEmail())) {
+				writer.write("COM+" + inttraSoDto.getAttnEmail() + ":EM'");
+				writer.newLine();
+				count += 1;
+			}
 
 			/* =================2000=================  */
 			count = count + 2;

+ 34 - 23
blade-service/blade-los/src/main/java/org/springblade/los/edi/service/impl/EdiTypesServiceImpl.java

@@ -163,25 +163,31 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				String corpId = details.getCorpId().toString();
 				inttraSoDto.setFileExchangeNumber(sdf1.format(date) + corpId.substring(corpId.length() - 4));
 				inttraSoDto.setInformationNo(inttraSoDto.getFileExchangeNumber());
-				inttraSoDto.setIdentificationCode(details.getMblno() + "FB");
+				if (ObjectUtils.isNotNull(details.getMblno())){
+					inttraSoDto.setIdentificationCode(details.getMblno());
+				}else{
+					inttraSoDto.setIdentificationCode(details.getBookingNo());
+				}
 				if (ObjectUtils.isNotNull(details.getEdiStatus()) && Integer.parseInt(details.getEdiStatus()) > 0) {
-					inttraSoDto.setFilesFunction("5");
+					// 默认 9
+					inttraSoDto.setFilesFunction("9");
 					details.setEdiStatus(Integer.parseInt(details.getEdiStatus()) + 1 + "");
 				} else {
 					inttraSoDto.setFilesFunction("9");
 					details.setEdiStatus("1");
 				}
-				inttraSoDto.setFilesDate(sdf1.format(date));
+				SimpleDateFormat sdf4 = new SimpleDateFormat("yyyyMMddhhmm");
+				inttraSoDto.setFilesDate(sdf4.format(date));
 				inttraSoDto.setTransportTermCode(details.getServiceTerms());
 				inttraSoDto.setLclType("2");
-				inttraSoDto.setRemarks(details.getBookingRemarks());
+				inttraSoDto.setBookingRemarks(details.getBookingRemarks());
 				inttraSoDto.setCarrySingleRemarks(details.getRemarks());
 				inttraSoDto.setWeightOfGoods(details.getGrossWeight().toString());
 				inttraSoDto.setPackagesNumber(details.getQuantity());
 				inttraSoDto.setVolumeOfGoods(details.getMeasurement());
 				Integer sum = details.getQuantityV20() + details.getQuantityV40() + details.getQuantityV45()
 					+ details.getQuantityV48() + details.getQuantityV40hc();
-				inttraSoDto.setTotalBoxNumber(new BigDecimal(sum + ""));
+				inttraSoDto.setTotalBoxNumber(sum);
 				if (ObjectUtils.isNotNull(details.getMpayplace())) {
 					BPorts bPorts = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
 						.eq(BPorts::getTenantId, AuthUtil.getTenantId())
@@ -207,10 +213,10 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				}
 				inttraSoDto.setBookingNo(details.getBookingNo());
 				inttraSoDto.setBillNo(details.getMblno());
-				inttraSoDto.setFreightProtocolNumber(details.getCorpArgreementNo());
+				inttraSoDto.setCorpArgreementNo(details.getCorpArgreementNo());
 				inttraSoDto.setMainPinyin("");
 				inttraSoDto.setOrderNo(details.getBookingNo());
-				inttraSoDto.setJobId(details.getMblno());
+				inttraSoDto.setJobId(details.getBookingNo());
 				inttraSoDto.setPaymentType(details.getMpaymode());
 				inttraSoDto.setVoyageNo(details.getVoyageNo());
 				if (ObjectUtils.isNotNull(details.getVesselId())) {
@@ -259,9 +265,9 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 						inttraSoDto.setPlaceDeliveryName(bPorts.getEnName());
 					}
 				}
-				inttraSoDto.setHsHipperOne(details.getHshipperDetails());
-				inttraSoDto.setHConsigneeOne(details.getHconsigneeDetails());
-				inttraSoDto.setHNotifyOne(details.getHnotifyDetails());
+				inttraSoDto.setHShipper(details.getHshipperDetails());
+				inttraSoDto.setHConsignee(details.getHconsigneeDetails());
+				inttraSoDto.setHNotify(details.getHnotifyDetails());
 				inttraSoDto.setCarrierName(details.getCarrierEnName());
 				if (ObjectUtils.isNotNull(details.getCarrierId())) {
 					BCorps bCorps = bCorpsService.getById(details.getCarrierId());
@@ -280,13 +286,13 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				inttraSoDto.setInttraDoorToAddrOne(details.getInttraDoorToCorpAddr());
 				inttraSoDto.setInttraDoorToContacts(details.getInttraDoorToCorpContacts());
 				inttraSoDto.setInttraDoorToTel(details.getInttraDoorToCorpTel());
-				inttraSoDto.setFreightForwarderCode("los-code");
-				inttraSoDto.setFreightForwarderName("los-call");
+				inttraSoDto.setFreightForwarderCode("JET MARINE");
+				inttraSoDto.setFreightForwarderName("");
 				inttraSoDto.setSenderCodeS("JMSLOGQINGDAO");
 				inttraSoDto.setSenderName("JMS");
-				inttraSoDto.setSenderContacts("Emma chen");
-				inttraSoDto.setSenderTel("JMS-tel");
-				inttraSoDto.setSenderEmail("lag-seataocn@jms-logistics.com");
+				inttraSoDto.setSenderContacts("Yuki Cai");
+				inttraSoDto.setSenderTel("");
+				inttraSoDto.setSenderEmail("cma-seataocn@jms-logistics.com");
 				if ("SEA WAY BILL".equals(details.getIssueType())) {
 					inttraSoDto.setBillLadingType("710");
 				} else {
@@ -297,15 +303,16 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 				} else {
 					inttraSoDto.setPaymentStatus("26");
 				}
-				inttraSoDto.setBillLadingNumber(new BigDecimal(details.getNumberOfOblDigit()));
+				inttraSoDto.setBillLadingNumber(RegularUtils.englishToNumber(details.getNumberOfObl()));
 				inttraSoDto.setPackagesNumbers(details.getQuantity());
 				inttraSoDto.setPackagesCode(details.getPackingUnit());
-				inttraSoDto.setPackagesDescribe("");//包装描述
-				inttraSoDto.setProductName(details.getCommodityDescr());
+				inttraSoDto.setPackagesDescribe(details.getPackingUnit());//包装描述
+				inttraSoDto.setGoodsDesc(details.getCommodityDescr());
 				inttraSoDto.setGrossWeight(details.getGrossWeight());
 				inttraSoDto.setMeasurement(details.getMeasurement());
 				inttraSoDto.setMarks(details.getMarks());
-				inttraSoDto.setHsCode(new BigDecimal(details.getHscode()));
+				inttraSoDto.setHsCode(details.getHscode());
+				inttraSoDto.setCargoType(details.getCargoType());
 				if ("danger".equals(details.getCargoType())) {
 					inttraSoDto.setDgImdgCode(details.getDgImdgCode());
 					inttraSoDto.setPageNumber(new BigDecimal("007"));
@@ -326,22 +333,26 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 					.apply("find_in_set(cntr_type,'" + boxType + "')")
 					.eq(BCntrTypes::getIsDeleted, 0));
 				List<Map<String, Object>> box = new ArrayList<>();
+				int totalPreCntrQty = 0;
 				for (PreContainers item : preContainersList) {
+					totalPreCntrQty+=item.getQuantity();
 					BCntrTypes bCntrTypes = bCntrTypesList.stream().filter(e -> e.getCntrType().equals(item.getCntrTypeCode())).findFirst().orElse(null);
 					if (bCntrTypes != null) {
 						String ediCode = RegularUtils.getEdiCode("INTTRA", bCntrTypes.getExtendedData());
 						Map<String, Object> map = new HashMap<>();
 						map.put("boxCode", ediCode);
 						map.put("boxNumber", item.getQuantity());
-						map.put("shipperBoxIdentification", item.getIsSoc());
-						map.put("temperature", item.getTemperature());
-						map.put("ventilation", item.getVentilation());
+						map.put("isSoc", item.getIsSoc());
+						map.put("temperature", RegularUtils.formatTempNumber(item.getTemperature(), 3));
+						map.put("ventilation", RegularUtils.formatTempNumber(item.getVentilation(), 3));
+						map.put("humidity", RegularUtils.formatTempNumber(item.getHumidity(), 3));
 						map.put("temperatureUnit", item.getTemperatureUnit());
 						box.add(map);
 					} else {
 						throw new RuntimeException("箱型数据错误");
 					}
 				}
+				inttraSoDto.setTotalBoxNumber(totalPreCntrQty);
 				inttraSoDto.setBox(box);
 				inttraSoDto.setRecordRows(new BigDecimal("10"));
 				inttraSoDto.setInformationNoEnd(inttraSoDto.getInformationNo());
@@ -583,7 +594,7 @@ public class EdiTypesServiceImpl extends ServiceImpl<EdiTypesMapper, EdiTypes> i
 					inttraSoDto.setBoxGoodMeasurement(boxGoodMeasurement);
 				}*/
 				if ("danger".equals(details.getCargoType())) {
-					inttraSoDto.setHsCode(new BigDecimal(details.getHscode()));
+					inttraSoDto.setHsCode(details.getHscode());
 					inttraSoDto.setDgImdgCode(details.getDgImdgCode());
 					inttraSoDto.setPageNumber(new BigDecimal("007"));
 					inttraSoDto.setDgUnCode(1);