|
|
@@ -2,6 +2,7 @@ package org.springblade.los.business.sea.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.sun.org.apache.xpath.internal.operations.Bool;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
@@ -127,6 +128,27 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
return splitNumericPrefixFromString(str);
|
|
|
}
|
|
|
|
|
|
+ public static Boolean stringBuilderIsNotEmpty(StringBuilder sb){
|
|
|
+ return ObjectUtils.isNotNull(sb) && !sb.toString().trim().isEmpty();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void resetBillsNullValuesAsEmptyString(Bills bills){
|
|
|
+ //将字符串为null的赋默认值为""
|
|
|
+ Field[] fields = bills.getClass().getDeclaredFields();
|
|
|
+ for (Field field : fields) {
|
|
|
+ try {
|
|
|
+ field.setAccessible(true); // 使得私有属性也可以访问
|
|
|
+ if (field.getType() == String.class) {
|
|
|
+ Object value = field.get(bills);
|
|
|
+ if (value == null) {
|
|
|
+ field.set(bills, "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
@Override
|
|
|
public R<Bills> importOne(MultipartFile file) throws Exception {
|
|
|
Bills bills = new Bills();
|
|
|
@@ -157,11 +179,11 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
StringBuilder shipper = new StringBuilder();
|
|
|
for (int i = 3; i <= 7; i++) {
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- shipper.append(getSheetCellValueAsString(sheet, i, 1));
|
|
|
+ shipper.append(getSheetCellValueAsString(sheet, i, 1) + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(shipper)) {
|
|
|
- seaBillsDetail.setHshipperDetails(shipper.toString());
|
|
|
+ if (stringBuilderIsNotEmpty(shipper)) {
|
|
|
+ seaBillsDetail.setHshipperDetails(shipper.toString().trim());
|
|
|
// bills.setHshipperDetails(shipper.toString());
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
} else {
|
|
|
@@ -171,11 +193,11 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
StringBuilder consignee = new StringBuilder();
|
|
|
for (int i = 8; i <= 12; i++) {
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- consignee.append(getSheetCellValueAsString(sheet, i, 1));
|
|
|
+ consignee.append(getSheetCellValueAsString(sheet, i, 1) + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(consignee)) {
|
|
|
- seaBillsDetail.setHconsigneeDetails(consignee.toString());
|
|
|
+ if (stringBuilderIsNotEmpty(consignee)) {
|
|
|
+ seaBillsDetail.setHconsigneeDetails(consignee.toString().trim());
|
|
|
// bills.setHconsigneeDetails(consignee.toString());
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
} else {
|
|
|
@@ -185,11 +207,11 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
StringBuilder notifyParty = new StringBuilder();
|
|
|
for (int i = 13; i <= 17; i++) {
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- notifyParty.append(getSheetCellValueAsString(sheet, i, 1));
|
|
|
+ notifyParty.append(getSheetCellValueAsString(sheet, i, 1) + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(notifyParty)) {
|
|
|
- seaBillsDetail.setHnotifyDetails(notifyParty.toString());
|
|
|
+ if (stringBuilderIsNotEmpty(notifyParty)) {
|
|
|
+ seaBillsDetail.setHnotifyDetails(notifyParty.toString().trim());
|
|
|
// bills.setHnotifyDetails(notifyParty.toString());
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
} else {
|
|
|
@@ -250,7 +272,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
System.out.println("por:" + por);
|
|
|
|
|
|
} else {
|
|
|
- throw new RuntimeException("收货港不能为空");
|
|
|
+ throw new RuntimeException("收货地不能为空");
|
|
|
}
|
|
|
//POL
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(19).getCell(4))) {
|
|
|
@@ -304,10 +326,10 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
.eq(BPorts::getEnName, placeOfDelivery)
|
|
|
.last("limit 1"));
|
|
|
if (ports != null) {
|
|
|
- bills.setDestinationId(ports.getId());
|
|
|
- bills.setDestinationCode(ports.getCode());
|
|
|
- bills.setDestinationName(ports.getEnName());
|
|
|
- bills.setDestinationNamePrint(ports.getEnName());
|
|
|
+ bills.setPlaceDeliveryId(ports.getId());
|
|
|
+ bills.setPlaceDeliveryCode(ports.getCode());
|
|
|
+ bills.setPlaceDeliveryName(ports.getEnName());
|
|
|
+ bills.setPlaceDeliveryNamePrint(ports.getEnName());
|
|
|
}
|
|
|
}
|
|
|
System.out.println("placeOfDelivery:" + placeOfDelivery);
|
|
|
@@ -342,12 +364,12 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
StringBuilder marks = new StringBuilder();
|
|
|
for (int i = 25; i <= 46; i++) {
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(0))) {
|
|
|
- marks.append(getSheetCellValueAsString(sheet, i, 0));
|
|
|
+ marks.append(getSheetCellValueAsString(sheet, i, 0) + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(marks)) {
|
|
|
+ if (stringBuilderIsNotEmpty(marks)) {
|
|
|
System.out.println("marks:" + marks);
|
|
|
- bills.setMarks(marks.toString());
|
|
|
+ bills.setMarks(marks.toString().trim());
|
|
|
} else {
|
|
|
throw new RuntimeException("唛头不能为空");
|
|
|
}
|
|
|
@@ -363,10 +385,10 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
StringBuilder description = new StringBuilder();
|
|
|
for (int i = 25; i <= 46; i++) {
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(2))) {
|
|
|
- description.append(getSheetCellValueAsString(sheet, i, 2));
|
|
|
+ description.append(getSheetCellValueAsString(sheet, i, 2) + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(description)) {
|
|
|
+ if (stringBuilderIsNotEmpty(description)) {
|
|
|
System.out.println("description:" + description);
|
|
|
bills.setCommodityDescr(description.toString());
|
|
|
} else {
|
|
|
@@ -392,12 +414,12 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
StringBuilder remark = new StringBuilder();
|
|
|
for (int i = 47; i <= 50; i++) {
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- remark.append(getSheetCellValueAsString(sheet, i, 1));
|
|
|
+ remark.append(getSheetCellValueAsString(sheet, i, 1) + "\r\n");
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotNull(remark)) {
|
|
|
+ if (stringBuilderIsNotEmpty(remark)) {
|
|
|
System.out.println("remark:" + remark);
|
|
|
- bills.setRemarks(remark.toString());
|
|
|
+ bills.setRemarks(remark.toString().trim());
|
|
|
}
|
|
|
//FINAL DESTINATION FOR THE MERCHANT’S REFERENCE
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(51).getCell(4))) {
|
|
|
@@ -417,6 +439,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
}
|
|
|
System.out.println("finalDestination:" + finalDestination);
|
|
|
}
|
|
|
+
|
|
|
bills.setContainersList(new ArrayList<>());
|
|
|
bills.setPreContainersList(new ArrayList<>());
|
|
|
bills.setContainersReportsList(new ArrayList<>());
|
|
|
@@ -426,20 +449,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
bills.setWaitingBoxList(new ArrayList<>());
|
|
|
bills.setDetail(seaBillsDetail);
|
|
|
//将字符串为null的赋默认值为""
|
|
|
- Field[] fields = bills.getClass().getDeclaredFields();
|
|
|
- for (Field field : fields) {
|
|
|
- try {
|
|
|
- field.setAccessible(true); // 使得私有属性也可以访问
|
|
|
- if (field.getType() == String.class) {
|
|
|
- Object value = field.get(bills);
|
|
|
- if (value == null) {
|
|
|
- field.set(bills, "");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ resetBillsNullValuesAsEmptyString(bills);
|
|
|
+
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|
|
|
@@ -458,47 +469,193 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
|
|
|
|
|
//SHIPPER
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(2).getCell(0))) {
|
|
|
- String shipper = getSheetCellValueAsString(sheet, 2,0);
|
|
|
-// bills.setHshipperDetails(shipper);
|
|
|
- seaBillsDetail.setHshipperDetails(shipper);
|
|
|
+ StringBuilder shipper = new StringBuilder();
|
|
|
+ for(int r=2; r<=6; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 3; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ shipper.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(shipper)) {
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("托运人不能为空");
|
|
|
+ seaBillsDetail.setHshipperDetails(shipper.toString().trim());
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("发货人不能为空");
|
|
|
}
|
|
|
+
|
|
|
//CONSIGNEE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(9).getCell(0))) {
|
|
|
- String consignee = getSheetCellValueAsString(sheet, 9, 0);
|
|
|
- seaBillsDetail.setHconsigneeDetails(consignee);
|
|
|
-// bills.setHconsigneeDetails(consignee);
|
|
|
+ StringBuilder consignee = new StringBuilder();
|
|
|
+ for(int r=9; r<=13; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 3; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ consignee.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(consignee)) {
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
- } else {
|
|
|
+ seaBillsDetail.setHconsigneeDetails(consignee.toString().trim());
|
|
|
+ }else{
|
|
|
throw new RuntimeException("收货人不能为空");
|
|
|
}
|
|
|
//NOTIFY PARTY
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(16).getCell(0))) {
|
|
|
- String notifyParty = getSheetCellValueAsString(sheet, 16, 0);
|
|
|
-// bills.setHnotifyDetails(notifyParty);
|
|
|
- seaBillsDetail.setHnotifyDetails(notifyParty);
|
|
|
+ StringBuilder notifyParty = new StringBuilder();
|
|
|
+ for(int r=16; r<=20; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 3; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notifyParty.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(notifyParty)) {
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
- } else {
|
|
|
+ seaBillsDetail.setHnotifyDetails(notifyParty.toString().trim());
|
|
|
+ }else{
|
|
|
throw new RuntimeException("通知人不能为空");
|
|
|
}
|
|
|
+ //VSL/VOY
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(0))) {
|
|
|
+ String vslVoy = getSheetCellValueAsString(sheet, 23, 0);
|
|
|
+ if (vslVoy.contains("/")) {
|
|
|
+ String vsl = vslVoy.substring(0, vslVoy.indexOf("/"));
|
|
|
+ String voy = vslVoy.substring(vslVoy.indexOf("/") + 1);
|
|
|
+ if (ObjectUtils.isNotNull(vsl)) {
|
|
|
+ BVessels vessels = bVesselsService.getOne(new LambdaQueryWrapper<BVessels>()
|
|
|
+ .eq(BVessels::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BVessels::getIsDeleted, 0)
|
|
|
+ .eq(BVessels::getEnName, vsl)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (vessels != null) {
|
|
|
+ bills.setVesselEnName(vessels.getEnName());
|
|
|
+ bills.setVesselCnName(vessels.getCnName());
|
|
|
+ bills.setVesselId(vessels.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bills.setVoyageNo(voy);
|
|
|
+ System.out.println("vsl:" + vsl);
|
|
|
+ System.out.println("voy:" + voy);
|
|
|
+ System.out.println("vslVoy:" + vslVoy);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("船名航次不能为空");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("船名航次不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // POR
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(0))) {
|
|
|
+ String por = getSheetCellValueAsString(sheet, 25, 0);
|
|
|
+ if (ObjectUtils.isNotNull(por)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, por)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPlaceReceiptId(ports.getId());
|
|
|
+ bills.setPlaceReceiptCode(ports.getCode());
|
|
|
+ bills.setPlaceReceiptName(ports.getEnName());
|
|
|
+ bills.setPlaceReceiptNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("por:" + por);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("收货地不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //POL
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(3))) {
|
|
|
+ String pol = getSheetCellValueAsString(sheet, 23, 3);
|
|
|
+ if (ObjectUtils.isNotNull(pol)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, pol)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPolId(ports.getId());
|
|
|
+ bills.setPolCode(ports.getCode());
|
|
|
+ bills.setPolCnName(ports.getCnName());
|
|
|
+ bills.setPolEnName(ports.getEnName());
|
|
|
+ bills.setPolNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("pol:" + pol);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("装运港不能为空");
|
|
|
+ }
|
|
|
+ //POD
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(5))) {
|
|
|
+ String pod = getSheetCellValueAsString(sheet, 23, 5);
|
|
|
+ if (ObjectUtils.isNotNull(pod)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, pod)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPodId(ports.getId());
|
|
|
+ bills.setPodCode(ports.getCode());
|
|
|
+ bills.setPodCnName(ports.getCnName());
|
|
|
+ bills.setPodEnName(ports.getEnName());
|
|
|
+ bills.setPodNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("pod:" + pod);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("卸货港不能为空");
|
|
|
+ }
|
|
|
+ //Place of Delivery
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(3))) {
|
|
|
+ String delivery = getSheetCellValueAsString(sheet, 25, 3);
|
|
|
+ if (ObjectUtils.isNotNull(delivery)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, delivery)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPlaceDeliveryId(ports.getId());
|
|
|
+ bills.setPlaceDeliveryCode(ports.getCode());
|
|
|
+ bills.setPlaceDeliveryName(ports.getEnName());
|
|
|
+ bills.setPlaceDeliveryNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("delivery:" + delivery);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("交货地不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
//B/L NO
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(26).getCell(5))) {
|
|
|
- String blno = getSheetCellValueAsString(sheet, 26, 5);
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(5))) {
|
|
|
+ String blno = getSheetCellValueAsString(sheet, 25, 5);
|
|
|
System.out.println("blno:" + blno);
|
|
|
bills.setMblno(blno);
|
|
|
} else {
|
|
|
throw new RuntimeException("提单号不能为空");
|
|
|
}
|
|
|
//MARKS
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(0))) {
|
|
|
- String marks = getSheetCellValueAsString(sheet, 28, 0);
|
|
|
- System.out.println("blno:" + marks);
|
|
|
- bills.setMarks(marks);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("唛头不能为空");
|
|
|
+ StringBuilder marks = new StringBuilder();
|
|
|
+ for(int r=28; r<=44; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 0; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ marks.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(marks)) {
|
|
|
+ System.out.println("marks:" + marks.toString().trim());
|
|
|
+ bills.setMarks(marks.toString().trim());
|
|
|
}
|
|
|
//BAGS
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(2))) {
|
|
|
@@ -509,12 +666,30 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
throw new RuntimeException("件数不能为空");
|
|
|
}
|
|
|
//DESCRIPTION
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(3))) {
|
|
|
- String description = getSheetCellValueAsString(sheet, 28, 3);
|
|
|
- System.out.println("description:" + description);
|
|
|
- bills.setCommodityDescr(description);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("件数不能为空");
|
|
|
+ StringBuilder description = new StringBuilder();
|
|
|
+ String hscode = "";
|
|
|
+ Boolean findHsCode = false;
|
|
|
+ for(int r=28; r<=44; r++) {
|
|
|
+ String line = "";
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(3))) {
|
|
|
+ line = getSheetCellValueAsString(sheet, r, 3);
|
|
|
+ }
|
|
|
+ if(!findHsCode){
|
|
|
+ findHsCode = line.toUpperCase().startsWith("HS CODE:");
|
|
|
+ if(findHsCode){
|
|
|
+ hscode = line.substring(8).trim();
|
|
|
+ bills.setHscode(hscode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!findHsCode) {
|
|
|
+ description.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(description)) {
|
|
|
+ System.out.println("description:" + description.toString().trim());
|
|
|
+ bills.setCommodityDescr(description.toString().trim());
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("货物描述不能为空");
|
|
|
}
|
|
|
//G.W.
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(6))) {
|
|
|
@@ -532,6 +707,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
} else {
|
|
|
throw new RuntimeException("体积不能为空");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
bills.setContainersList(new ArrayList<>());
|
|
|
bills.setPreContainersList(new ArrayList<>());
|
|
|
bills.setContainersReportsList(new ArrayList<>());
|
|
|
@@ -540,20 +717,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
bills.setFilesList(new ArrayList<>());
|
|
|
bills.setWaitingBoxList(new ArrayList<>());
|
|
|
bills.setDetail(seaBillsDetail);
|
|
|
- Field[] fields = bills.getClass().getDeclaredFields();
|
|
|
- for (Field field : fields) {
|
|
|
- try {
|
|
|
- field.setAccessible(true); // 使得私有属性也可以访问
|
|
|
- if (field.getType() == String.class) {
|
|
|
- Object value = field.get(bills);
|
|
|
- if (value == null) {
|
|
|
- field.set(bills, "");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ resetBillsNullValuesAsEmptyString(bills);
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|
|
|
@@ -572,59 +736,231 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
|
|
|
|
|
//SHIPPER
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(2).getCell(0))) {
|
|
|
- String shipper = getSheetCellValueAsString(sheet, 2, 0);
|
|
|
-// bills.setHshipperDetails(shipper);
|
|
|
- seaBillsDetail.setHshipperDetails(shipper);
|
|
|
+ StringBuilder shipper = new StringBuilder();
|
|
|
+ for(int r=2; r<=6; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 3; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ shipper.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(shipper)) {
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("托运人不能为空");
|
|
|
+ seaBillsDetail.setHshipperDetails(shipper.toString().trim());
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("发货人不能为空");
|
|
|
}
|
|
|
+
|
|
|
//CONSIGNEE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(9).getCell(0))) {
|
|
|
- String consignee = getSheetCellValueAsString(sheet, 9, 0);
|
|
|
- seaBillsDetail.setHconsigneeDetails(consignee);
|
|
|
-// bills.setHconsigneeDetails(consignee);
|
|
|
+ StringBuilder consignee = new StringBuilder();
|
|
|
+ for(int r=9; r<=13; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 3; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ consignee.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(consignee)) {
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
- } else {
|
|
|
+ seaBillsDetail.setHconsigneeDetails(consignee.toString().trim());
|
|
|
+ }else{
|
|
|
throw new RuntimeException("收货人不能为空");
|
|
|
}
|
|
|
//NOTIFY PARTY
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(16).getCell(0))) {
|
|
|
- String notifyParty = getSheetCellValueAsString(sheet, 16, 0);
|
|
|
- seaBillsDetail.setHnotifyDetails(notifyParty);
|
|
|
-// bills.setHnotifyDetails(notifyParty);
|
|
|
+ StringBuilder notifyParty = new StringBuilder();
|
|
|
+ for(int r=16; r<=20; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 3; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ notifyParty.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(notifyParty)) {
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
- } else {
|
|
|
+ seaBillsDetail.setHnotifyDetails(notifyParty.toString().trim());
|
|
|
+ }else{
|
|
|
throw new RuntimeException("通知人不能为空");
|
|
|
}
|
|
|
- //MARKS
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(0))) {
|
|
|
- String marks = getSheetCellValueAsString(sheet, 28, 0);
|
|
|
- System.out.println("blno:" + marks);
|
|
|
- bills.setMarks(marks);
|
|
|
+ //VSL/VOY
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(0))) {
|
|
|
+ String vslVoy = getSheetCellValueAsString(sheet, 23, 0);
|
|
|
+ if (vslVoy.contains("/")) {
|
|
|
+ String vsl = vslVoy.substring(0, vslVoy.indexOf("/"));
|
|
|
+ String voy = vslVoy.substring(vslVoy.indexOf("/") + 1);
|
|
|
+ if (ObjectUtils.isNotNull(vsl)) {
|
|
|
+ BVessels vessels = bVesselsService.getOne(new LambdaQueryWrapper<BVessels>()
|
|
|
+ .eq(BVessels::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BVessels::getIsDeleted, 0)
|
|
|
+ .eq(BVessels::getEnName, vsl)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (vessels != null) {
|
|
|
+ bills.setVesselEnName(vessels.getEnName());
|
|
|
+ bills.setVesselCnName(vessels.getCnName());
|
|
|
+ bills.setVesselId(vessels.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bills.setVoyageNo(voy);
|
|
|
+ System.out.println("vsl:" + vsl);
|
|
|
+ System.out.println("voy:" + voy);
|
|
|
+ System.out.println("vslVoy:" + vslVoy);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("船名航次不能为空");
|
|
|
+ }
|
|
|
} else {
|
|
|
- throw new RuntimeException("唛头不能为空");
|
|
|
+ throw new RuntimeException("船名航次不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // POR
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(0))) {
|
|
|
+ String por = getSheetCellValueAsString(sheet, 25, 0);
|
|
|
+ if (ObjectUtils.isNotNull(por)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, por)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPlaceReceiptId(ports.getId());
|
|
|
+ bills.setPlaceReceiptCode(ports.getCode());
|
|
|
+ bills.setPlaceReceiptName(ports.getEnName());
|
|
|
+ bills.setPlaceReceiptNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("por:" + por);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("收货地不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //POL
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(3))) {
|
|
|
+ String pol = getSheetCellValueAsString(sheet, 23, 3);
|
|
|
+ if (ObjectUtils.isNotNull(pol)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, pol)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPolId(ports.getId());
|
|
|
+ bills.setPolCode(ports.getCode());
|
|
|
+ bills.setPolCnName(ports.getCnName());
|
|
|
+ bills.setPolEnName(ports.getEnName());
|
|
|
+ bills.setPolNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("pol:" + pol);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("装运港不能为空");
|
|
|
+ }
|
|
|
+ //POD
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(5))) {
|
|
|
+ String pod = getSheetCellValueAsString(sheet, 23, 5);
|
|
|
+ if (ObjectUtils.isNotNull(pod)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, pod)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPodId(ports.getId());
|
|
|
+ bills.setPodCode(ports.getCode());
|
|
|
+ bills.setPodCnName(ports.getCnName());
|
|
|
+ bills.setPodEnName(ports.getEnName());
|
|
|
+ bills.setPodNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("pod:" + pod);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("卸货港不能为空");
|
|
|
+ }
|
|
|
+ //Place of Delivery
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(3))) {
|
|
|
+ String delivery = getSheetCellValueAsString(sheet, 25, 3);
|
|
|
+ if (ObjectUtils.isNotNull(delivery)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, delivery)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setPlaceDeliveryId(ports.getId());
|
|
|
+ bills.setPlaceDeliveryCode(ports.getCode());
|
|
|
+ bills.setPlaceDeliveryName(ports.getEnName());
|
|
|
+ bills.setPlaceDeliveryNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ System.out.println("delivery:" + delivery);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("交货地不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //B/L NO
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(5))) {
|
|
|
+ String blno = getSheetCellValueAsString(sheet, 25, 5);
|
|
|
+ System.out.println("blno:" + blno);
|
|
|
+ bills.setMblno(blno);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("提单号不能为空");
|
|
|
+ }
|
|
|
+ //MARKS
|
|
|
+ StringBuilder marks = new StringBuilder();
|
|
|
+ for(int r=28; r<=44; r++) {
|
|
|
+ String line = "";
|
|
|
+ for (int i = 0; i <= 0; i++) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(i))) {
|
|
|
+ line += getSheetCellValueAsString(sheet, r, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ marks.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(marks)) {
|
|
|
+ System.out.println("marks:" + marks.toString().trim());
|
|
|
+ bills.setMarks(marks.toString().trim());
|
|
|
}
|
|
|
//BAGS
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(2))) {
|
|
|
- double bags = getSheetCellValueAsNumericPrefix(sheet, 28, 2);
|
|
|
+ double bags = getSheetCellValueAsNumericPrefix(sheet,28, 2);
|
|
|
System.out.println("bags:" + bags);
|
|
|
bills.setQuantity(new BigDecimal(bags));
|
|
|
} else {
|
|
|
throw new RuntimeException("件数不能为空");
|
|
|
}
|
|
|
//DESCRIPTION
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(3))) {
|
|
|
- String description = getSheetCellValueAsString(sheet, 28, 3);
|
|
|
- System.out.println("description:" + description);
|
|
|
- bills.setCommodityDescr(description);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("件数不能为空");
|
|
|
+ StringBuilder description = new StringBuilder();
|
|
|
+ String hscode = "";
|
|
|
+ Boolean findHsCode = false;
|
|
|
+ for(int r=28; r<=44; r++) {
|
|
|
+ String line = "";
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(r).getCell(3))) {
|
|
|
+ line = getSheetCellValueAsString(sheet, r, 3);
|
|
|
+ }
|
|
|
+ if(!findHsCode){
|
|
|
+ findHsCode = line.toUpperCase().startsWith("HS CODE:");
|
|
|
+ if(findHsCode){
|
|
|
+ hscode = line.substring(8).trim();
|
|
|
+ bills.setHscode(hscode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!findHsCode) {
|
|
|
+ description.append(line + "\r\n");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (stringBuilderIsNotEmpty(description)) {
|
|
|
+ System.out.println("description:" + description.toString().trim());
|
|
|
+ bills.setCommodityDescr(description.toString().trim());
|
|
|
+ }else{
|
|
|
+ throw new RuntimeException("货物描述不能为空");
|
|
|
}
|
|
|
//G.W.
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(6))) {
|
|
|
- double gw = getSheetCellValueAsNumericPrefix(sheet, 28, 6);
|
|
|
+ double gw = getSheetCellValueAsNumericPrefix(sheet,28,6);
|
|
|
System.out.println("gw:" + gw);
|
|
|
bills.setGrossWeight(new BigDecimal(gw));
|
|
|
} else {
|
|
|
@@ -632,35 +968,23 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
}
|
|
|
//MEAS
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(7))) {
|
|
|
- double meas = getSheetCellValueAsNumericPrefix(sheet, 28,7);
|
|
|
+ double meas = getSheetCellValueAsNumericPrefix(sheet,28,7);
|
|
|
System.out.println("meas:" + meas);
|
|
|
bills.setMeasurement(new BigDecimal(meas));
|
|
|
} else {
|
|
|
throw new RuntimeException("体积不能为空");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
bills.setContainersList(new ArrayList<>());
|
|
|
bills.setPreContainersList(new ArrayList<>());
|
|
|
bills.setContainersReportsList(new ArrayList<>());
|
|
|
bills.setFeeCenterListC(new ArrayList<>());
|
|
|
bills.setFeeCenterListD(new ArrayList<>());
|
|
|
- bills.setFeeCenterList(new ArrayList<>());
|
|
|
bills.setFilesList(new ArrayList<>());
|
|
|
bills.setWaitingBoxList(new ArrayList<>());
|
|
|
bills.setDetail(seaBillsDetail);
|
|
|
- Field[] fields = bills.getClass().getDeclaredFields();
|
|
|
- for (Field field : fields) {
|
|
|
- try {
|
|
|
- field.setAccessible(true); // 使得私有属性也可以访问
|
|
|
- if (field.getType() == String.class) {
|
|
|
- Object value = field.get(bills);
|
|
|
- if (value == null) {
|
|
|
- field.set(bills, "");
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (IllegalAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
+ resetBillsNullValuesAsEmptyString(bills);
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|