|
|
@@ -3,8 +3,10 @@ package org.springblade.los.business.sea.service.impl;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.los.business.sea.entity.Bills;
|
|
|
import org.springblade.los.business.sea.entity.Containers;
|
|
|
@@ -17,6 +19,7 @@ import java.math.BigDecimal;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -156,13 +159,13 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
throw new RuntimeException("签单方式不能为空");
|
|
|
}
|
|
|
//PAYMODE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(21).getCell(4))) {
|
|
|
+ /*if (ObjectUtils.isNotNull(sheet.getRow(21).getCell(4))) {
|
|
|
String payMode = sheet.getRow(21).getCell(4).getStringCellValue();
|
|
|
System.out.println("payMode:" + payMode);
|
|
|
bills.setHpaymode(payMode);
|
|
|
} else {
|
|
|
throw new RuntimeException("运费支付方式不能为空");
|
|
|
- }
|
|
|
+ }*/
|
|
|
//PLACE OF ISSUE
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(22).getCell(1))) {
|
|
|
String placeOfIssue = sheet.getRow(22).getCell(1).getStringCellValue();
|
|
|
@@ -180,21 +183,21 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
throw new RuntimeException("付费地不能为空");
|
|
|
}
|
|
|
//CONTRACTNO
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(1))) {
|
|
|
+ /*if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(1))) {
|
|
|
String contractno = sheet.getRow(23).getCell(1).getStringCellValue();
|
|
|
System.out.println("contractno:" + contractno);
|
|
|
bills.setCorpArgreementNo(contractno);
|
|
|
} else {
|
|
|
throw new RuntimeException("约号不能为空");
|
|
|
- }
|
|
|
+ }*/
|
|
|
//VOLUME
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(4))) {
|
|
|
+ /*if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(4))) {
|
|
|
String volume = sheet.getRow(23).getCell(4).getStringCellValue();
|
|
|
System.out.println("volume:" + volume);
|
|
|
bills.setQuantityCntrDescr(volume);
|
|
|
} else {
|
|
|
throw new RuntimeException("箱型箱量不能为空");
|
|
|
- }
|
|
|
+ }*/
|
|
|
//MARKS
|
|
|
StringBuilder marks = new StringBuilder();
|
|
|
for (int i = 25; i <= 46; i++) {
|
|
|
@@ -364,55 +367,6 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
} else {
|
|
|
throw new RuntimeException("通知人不能为空");
|
|
|
}
|
|
|
- //VSL/VOY
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(24).getCell(0))) {
|
|
|
- String vslVoy = sheet.getRow(24).getCell(0).getStringCellValue();
|
|
|
- if (vslVoy.contains("/")) {
|
|
|
- String vsl = vslVoy.substring(0, vslVoy.indexOf("/"));
|
|
|
- String voy = vslVoy.substring(vslVoy.indexOf("/"));
|
|
|
- bills.setVesselEnName(vsl);
|
|
|
- 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("船名或船期不能为空");
|
|
|
- }
|
|
|
- //POL
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(24).getCell(3))) {
|
|
|
- String pol = sheet.getRow(24).getCell(3).getStringCellValue();
|
|
|
- System.out.println("pol:" + pol);
|
|
|
- bills.setPolEnName(pol);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("装货港不能为空");
|
|
|
- }
|
|
|
- //POD
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(24).getCell(5))) {
|
|
|
- String pod = sheet.getRow(24).getCell(5).getStringCellValue();
|
|
|
- System.out.println("pod:" + pod);
|
|
|
- bills.setPodEnName(pod);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("卸货港不能为空");
|
|
|
- }
|
|
|
- //POR
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(26).getCell(0))) {
|
|
|
- String por = sheet.getRow(26).getCell(0).getStringCellValue();
|
|
|
- System.out.println("por:" + por);
|
|
|
- bills.setPlaceReceiptName(por);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("收货港不能为空");
|
|
|
- }
|
|
|
- //PLACE OF DELIVERY
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(26).getCell(3))) {
|
|
|
- String placeOfDelivery = sheet.getRow(26).getCell(3).getStringCellValue();
|
|
|
- System.out.println("placeOfDelivery:" + placeOfDelivery);
|
|
|
- bills.setDestinationName(placeOfDelivery);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("交货地不能为空");
|
|
|
- }
|
|
|
//B/L NO
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(26).getCell(5))) {
|
|
|
String blno = sheet.getRow(26).getCell(5).getStringCellValue();
|
|
|
@@ -421,183 +375,46 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
} else {
|
|
|
throw new RuntimeException("提单号不能为空");
|
|
|
}
|
|
|
- //KIND OF B/L
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(21).getCell(1))) {
|
|
|
- String kindOfBl = sheet.getRow(21).getCell(1).getStringCellValue();
|
|
|
- System.out.println("kindOfBl:" + kindOfBl);
|
|
|
- bills.setIssueType(kindOfBl);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("签单方式不能为空");
|
|
|
- }
|
|
|
- //PAYMODE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(21).getCell(4))) {
|
|
|
- String payMode = sheet.getRow(21).getCell(4).getStringCellValue();
|
|
|
- System.out.println("payMode:" + payMode);
|
|
|
- bills.setHpaymode(payMode);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("运费支付方式不能为空");
|
|
|
- }
|
|
|
- //PLACE OF ISSUE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(22).getCell(1))) {
|
|
|
- String placeOfIssue = sheet.getRow(22).getCell(1).getStringCellValue();
|
|
|
- System.out.println("placeOfIssue:" + placeOfIssue);
|
|
|
- bills.setIssueAt(placeOfIssue);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("签单地不能为空");
|
|
|
- }
|
|
|
- //FREIGHT PAYABLE AT
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(22).getCell(4))) {
|
|
|
- String freightPayAbleAt = sheet.getRow(22).getCell(4).getStringCellValue();
|
|
|
- System.out.println("freightPayAbleAt:" + freightPayAbleAt);
|
|
|
- bills.setHpayplace(freightPayAbleAt);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("付费地不能为空");
|
|
|
- }
|
|
|
- //CONTRACTNO
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(1))) {
|
|
|
- String contractno = sheet.getRow(23).getCell(1).getStringCellValue();
|
|
|
- System.out.println("contractno:" + contractno);
|
|
|
- bills.setCorpArgreementNo(contractno);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("约号不能为空");
|
|
|
- }
|
|
|
- //VOLUME
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(4))) {
|
|
|
- String volume = sheet.getRow(23).getCell(4).getStringCellValue();
|
|
|
- System.out.println("volume:" + volume);
|
|
|
- bills.setQuantityCntrDescr(volume);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("箱型箱量不能为空");
|
|
|
- }
|
|
|
//MARKS
|
|
|
- StringBuilder marks = new StringBuilder();
|
|
|
- for (int i = 25; i <= 46; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(0))) {
|
|
|
- marks.append(sheet.getRow(i).getCell(0).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(marks)) {
|
|
|
- System.out.println("marks:" + marks);
|
|
|
- bills.setMarks(marks.toString());
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(0))) {
|
|
|
+ String marks = sheet.getRow(28).getCell(0).getStringCellValue();
|
|
|
+ System.out.println("blno:" + marks);
|
|
|
+ bills.setMarks(marks);
|
|
|
} else {
|
|
|
throw new RuntimeException("唛头不能为空");
|
|
|
}
|
|
|
//BAGS
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(1))) {
|
|
|
- double bags = sheet.getRow(25).getCell(1).getNumericCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(2))) {
|
|
|
+ double bags = sheet.getRow(28).getCell(2).getNumericCellValue();
|
|
|
System.out.println("bags:" + bags);
|
|
|
bills.setQuantity(new BigDecimal(bags));
|
|
|
} else {
|
|
|
throw new RuntimeException("件数不能为空");
|
|
|
}
|
|
|
//DESCRIPTION
|
|
|
- StringBuilder description = new StringBuilder();
|
|
|
- for (int i = 25; i <= 46; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(2))) {
|
|
|
- description.append(sheet.getRow(i).getCell(2).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(description)) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(3))) {
|
|
|
+ String description = sheet.getRow(28).getCell(3).getStringCellValue();
|
|
|
System.out.println("description:" + description);
|
|
|
- bills.setCommodityDescr(description.toString());
|
|
|
+ bills.setCommodityDescr(description);
|
|
|
} else {
|
|
|
- throw new RuntimeException("提单上货物描述不能为空");
|
|
|
+ throw new RuntimeException("件数不能为空");
|
|
|
}
|
|
|
//G.W.
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(4))) {
|
|
|
- double gw = sheet.getRow(25).getCell(4).getNumericCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(6))) {
|
|
|
+ double gw = sheet.getRow(28).getCell(6).getNumericCellValue();
|
|
|
System.out.println("gw:" + gw);
|
|
|
bills.setGrossWeight(new BigDecimal(gw));
|
|
|
} else {
|
|
|
throw new RuntimeException("毛重不能为空");
|
|
|
}
|
|
|
//MEAS
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(6))) {
|
|
|
- double meas = sheet.getRow(25).getCell(6).getNumericCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(7))) {
|
|
|
+ double meas = sheet.getRow(28).getCell(7).getNumericCellValue();
|
|
|
System.out.println("meas:" + meas);
|
|
|
bills.setMeasurement(new BigDecimal(meas));
|
|
|
} else {
|
|
|
throw new RuntimeException("体积不能为空");
|
|
|
}
|
|
|
- //REMARK
|
|
|
- StringBuilder remark = new StringBuilder();
|
|
|
- for (int i = 47; i <= 50; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- remark.append(sheet.getRow(i).getCell(1).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(remark)) {
|
|
|
- System.out.println("remark:" + remark);
|
|
|
- bills.setRemarks(remark.toString());
|
|
|
- }
|
|
|
- //FINAL DESTINATION FOR THE MERCHANT’S REFERENCE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(51).getCell(4))) {
|
|
|
- String finalDestination = sheet.getRow(51).getCell(4).getStringCellValue();
|
|
|
- System.out.println("finalDestination:" + finalDestination);
|
|
|
- bills.setFinalDestinationName(finalDestination);
|
|
|
- }
|
|
|
-
|
|
|
- /*for (int i = 0; i <= sheet.getLastRowNum(); i++) {
|
|
|
- String rowStr = "";
|
|
|
- //循环获取sheet页的每一行
|
|
|
- Row row = sheet.getRow(i);
|
|
|
- //循环每一行的每一个单元格
|
|
|
- for (int l = 0; l <= 6; l++) {
|
|
|
- //判断是否是合并单元格并返回值
|
|
|
- String value = getValue(sheet, i, row.getCell(l).getColumnIndex());
|
|
|
- //数值为空说明不是合并单元格或者当前单元格为空,则直接获取当前单元格值
|
|
|
- if ("".equals(value)) {
|
|
|
- if (ObjectUtils.isNull(row.getCell(l))) {
|
|
|
- value = "";
|
|
|
- } else {
|
|
|
- CellType cellType = row.getCell(l).getCellTypeEnum();
|
|
|
- switch (cellType.name()) {
|
|
|
- case "STRING":
|
|
|
- value = row.getCell(l).getStringCellValue();
|
|
|
- // 处理字符串类型的值
|
|
|
- break;
|
|
|
- case "NUMERIC":
|
|
|
- value = row.getCell(l).getNumericCellValue() + "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "FORMULA":
|
|
|
- value = row.getCell(l).getNumericCellValue() + "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "_NONE":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "BLANK":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "BOOLEAN":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "ERROR":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- // 可以添加其他类型的处理
|
|
|
- default:
|
|
|
- System.out.println("cellType:" + cellType.name());
|
|
|
- throw new RuntimeException("数据类型错误");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- rowStr += "--" + value;
|
|
|
- }
|
|
|
- for (Cell cell : row) {
|
|
|
- //判断是否是合并单元格并返回值
|
|
|
- String value = getValue(sheet, i, cell.getColumnIndex());
|
|
|
- //数值为空说明不是合并单元格或者当前单元格为空,则直接获取当前单元格值
|
|
|
- if("".equals(value)){
|
|
|
- value=cell.getStringCellValue();
|
|
|
- }
|
|
|
- rowStr+="--"+value;
|
|
|
- }*/
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|
|
|
@@ -614,294 +431,109 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
Workbook workbook = new HSSFWorkbook(fis);
|
|
|
Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
|
|
|
|
|
- //TO
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(1).getCell(1))) {
|
|
|
- String to = sheet.getRow(1).getCell(1).getStringCellValue();
|
|
|
- System.out.println("TO:" + to);
|
|
|
- }
|
|
|
- //ATTN
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(2).getCell(1))) {
|
|
|
- String attn = sheet.getRow(2).getCell(1).getStringCellValue();
|
|
|
- System.out.println("attn:" + attn);
|
|
|
- }
|
|
|
//SHIPPER
|
|
|
- StringBuilder shipper = new StringBuilder();
|
|
|
- for (int i = 3; i <= 7; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- shipper.append(sheet.getRow(i).getCell(1).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(shipper)) {
|
|
|
- bills.setHshipperDetails(shipper.toString());
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(2).getCell(0))) {
|
|
|
+ String shipper = sheet.getRow(2).getCell(0).getStringCellValue();
|
|
|
+ bills.setHshipperDetails(shipper);
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
} else {
|
|
|
- throw new RuntimeException("发货人提单描述不能为空");
|
|
|
+ throw new RuntimeException("托运人不能为空");
|
|
|
}
|
|
|
//CONSIGNEE
|
|
|
- StringBuilder consignee = new StringBuilder();
|
|
|
- for (int i = 8; i <= 12; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- consignee.append(sheet.getRow(i).getCell(1).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(consignee)) {
|
|
|
- bills.setHconsigneeDetails(consignee.toString());
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(9).getCell(0))) {
|
|
|
+ String consignee = sheet.getRow(9).getCell(0).getStringCellValue();
|
|
|
+ bills.setHconsigneeDetails(consignee);
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
} else {
|
|
|
- throw new RuntimeException("收货人提单描述不能为空");
|
|
|
+ throw new RuntimeException("收货人不能为空");
|
|
|
}
|
|
|
//NOTIFY PARTY
|
|
|
- StringBuilder notifyParty = new StringBuilder();
|
|
|
- for (int i = 13; i <= 17; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- notifyParty.append(sheet.getRow(i).getCell(1).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(notifyParty)) {
|
|
|
- bills.setHnotifyDetails(notifyParty.toString());
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(16).getCell(0))) {
|
|
|
+ String notifyParty = sheet.getRow(16).getCell(0).getStringCellValue();
|
|
|
+ bills.setHnotifyDetails(notifyParty);
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
} else {
|
|
|
- throw new RuntimeException("通知人提单描述不能为空");
|
|
|
- }
|
|
|
- //B/L NO
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(18).getCell(1))) {
|
|
|
- String blno = sheet.getRow(18).getCell(1).getStringCellValue();
|
|
|
- System.out.println("blno:" + blno);
|
|
|
- bills.setMblno(blno);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("提单号不能为空");
|
|
|
- }
|
|
|
- //VSL/VOY
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(18).getCell(4))) {
|
|
|
- String vslVoy = sheet.getRow(18).getCell(4).getStringCellValue();
|
|
|
- if (vslVoy.contains("/")) {
|
|
|
- String vsl = vslVoy.substring(0, vslVoy.indexOf("/"));
|
|
|
- String voy = vslVoy.substring(vslVoy.indexOf("/"));
|
|
|
- bills.setVesselEnName(vsl);
|
|
|
- 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(19).getCell(1))) {
|
|
|
- String por = sheet.getRow(19).getCell(1).getStringCellValue();
|
|
|
- System.out.println("por:" + por);
|
|
|
- bills.setPlaceReceiptName(por);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("收货港不能为空");
|
|
|
- }
|
|
|
- //POL
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(19).getCell(4))) {
|
|
|
- String pol = sheet.getRow(19).getCell(4).getStringCellValue();
|
|
|
- System.out.println("pol:" + pol);
|
|
|
- bills.setPolEnName(pol);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("装运港不能为空");
|
|
|
- }
|
|
|
- //POD
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(20).getCell(1))) {
|
|
|
- String pod = sheet.getRow(20).getCell(1).getStringCellValue();
|
|
|
- System.out.println("pod:" + pod);
|
|
|
- bills.setPodEnName(pod);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("卸货港不能为空");
|
|
|
- }
|
|
|
- //PLACE OF DELIVERY
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(20).getCell(4))) {
|
|
|
- String placeOfDelivery = sheet.getRow(20).getCell(4).getStringCellValue();
|
|
|
- System.out.println("placeOfDelivery:" + placeOfDelivery);
|
|
|
- bills.setDestinationName(placeOfDelivery);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("目的港不能为空");
|
|
|
- }
|
|
|
- //KIND OF B/L
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(21).getCell(1))) {
|
|
|
- String kindOfBl = sheet.getRow(21).getCell(1).getStringCellValue();
|
|
|
- System.out.println("kindOfBl:" + kindOfBl);
|
|
|
- bills.setIssueType(kindOfBl);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("签单方式不能为空");
|
|
|
- }
|
|
|
- //PAYMODE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(21).getCell(4))) {
|
|
|
- String payMode = sheet.getRow(21).getCell(4).getStringCellValue();
|
|
|
- System.out.println("payMode:" + payMode);
|
|
|
- bills.setHpaymode(payMode);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("运费支付方式不能为空");
|
|
|
- }
|
|
|
- //PLACE OF ISSUE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(22).getCell(1))) {
|
|
|
- String placeOfIssue = sheet.getRow(22).getCell(1).getStringCellValue();
|
|
|
- System.out.println("placeOfIssue:" + placeOfIssue);
|
|
|
- bills.setIssueAt(placeOfIssue);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("签单地不能为空");
|
|
|
- }
|
|
|
- //FREIGHT PAYABLE AT
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(22).getCell(4))) {
|
|
|
- String freightPayAbleAt = sheet.getRow(22).getCell(4).getStringCellValue();
|
|
|
- System.out.println("freightPayAbleAt:" + freightPayAbleAt);
|
|
|
- bills.setHpayplace(freightPayAbleAt);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("付费地不能为空");
|
|
|
- }
|
|
|
- //CONTRACTNO
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(1))) {
|
|
|
- String contractno = sheet.getRow(23).getCell(1).getStringCellValue();
|
|
|
- System.out.println("contractno:" + contractno);
|
|
|
- bills.setCorpArgreementNo(contractno);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("约号不能为空");
|
|
|
- }
|
|
|
- //VOLUME
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(23).getCell(4))) {
|
|
|
- String volume = sheet.getRow(23).getCell(4).getStringCellValue();
|
|
|
- System.out.println("volume:" + volume);
|
|
|
- bills.setQuantityCntrDescr(volume);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("箱型箱量不能为空");
|
|
|
+ throw new RuntimeException("通知人不能为空");
|
|
|
}
|
|
|
//MARKS
|
|
|
- StringBuilder marks = new StringBuilder();
|
|
|
- for (int i = 25; i <= 46; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(0))) {
|
|
|
- marks.append(sheet.getRow(i).getCell(0).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(marks)) {
|
|
|
- System.out.println("marks:" + marks);
|
|
|
- bills.setMarks(marks.toString());
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(0))) {
|
|
|
+ String marks = sheet.getRow(28).getCell(0).getStringCellValue();
|
|
|
+ System.out.println("blno:" + marks);
|
|
|
+ bills.setMarks(marks);
|
|
|
} else {
|
|
|
throw new RuntimeException("唛头不能为空");
|
|
|
}
|
|
|
//BAGS
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(1))) {
|
|
|
- double bags = sheet.getRow(25).getCell(1).getNumericCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(2))) {
|
|
|
+ double bags = sheet.getRow(28).getCell(2).getNumericCellValue();
|
|
|
System.out.println("bags:" + bags);
|
|
|
bills.setQuantity(new BigDecimal(bags));
|
|
|
} else {
|
|
|
throw new RuntimeException("件数不能为空");
|
|
|
}
|
|
|
//DESCRIPTION
|
|
|
- StringBuilder description = new StringBuilder();
|
|
|
- for (int i = 25; i <= 46; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(2))) {
|
|
|
- description.append(sheet.getRow(i).getCell(2).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(description)) {
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(3))) {
|
|
|
+ String description = sheet.getRow(28).getCell(3).getStringCellValue();
|
|
|
System.out.println("description:" + description);
|
|
|
- bills.setCommodityDescr(description.toString());
|
|
|
+ bills.setCommodityDescr(description);
|
|
|
} else {
|
|
|
- throw new RuntimeException("提单上货物描述不能为空");
|
|
|
+ throw new RuntimeException("件数不能为空");
|
|
|
}
|
|
|
//G.W.
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(4))) {
|
|
|
- double gw = sheet.getRow(25).getCell(4).getNumericCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(6))) {
|
|
|
+ double gw = sheet.getRow(28).getCell(6).getNumericCellValue();
|
|
|
System.out.println("gw:" + gw);
|
|
|
bills.setGrossWeight(new BigDecimal(gw));
|
|
|
} else {
|
|
|
throw new RuntimeException("毛重不能为空");
|
|
|
}
|
|
|
//MEAS
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(25).getCell(6))) {
|
|
|
- double meas = sheet.getRow(25).getCell(6).getNumericCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(sheet.getRow(28).getCell(7))) {
|
|
|
+ double meas = sheet.getRow(28).getCell(7).getNumericCellValue();
|
|
|
System.out.println("meas:" + meas);
|
|
|
bills.setMeasurement(new BigDecimal(meas));
|
|
|
} else {
|
|
|
throw new RuntimeException("体积不能为空");
|
|
|
}
|
|
|
- //REMARK
|
|
|
- StringBuilder remark = new StringBuilder();
|
|
|
- for (int i = 47; i <= 50; i++) {
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(i).getCell(1))) {
|
|
|
- remark.append(sheet.getRow(i).getCell(1).getStringCellValue());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(remark)) {
|
|
|
- System.out.println("remark:" + remark);
|
|
|
- bills.setRemarks(remark.toString());
|
|
|
- }
|
|
|
- //FINAL DESTINATION FOR THE MERCHANT’S REFERENCE
|
|
|
- if (ObjectUtils.isNotNull(sheet.getRow(51).getCell(4))) {
|
|
|
- String finalDestination = sheet.getRow(51).getCell(4).getStringCellValue();
|
|
|
- System.out.println("finalDestination:" + finalDestination);
|
|
|
- bills.setFinalDestinationName(finalDestination);
|
|
|
- }
|
|
|
-
|
|
|
- /*for (int i = 0; i <= sheet.getLastRowNum(); i++) {
|
|
|
- String rowStr = "";
|
|
|
- //循环获取sheet页的每一行
|
|
|
- Row row = sheet.getRow(i);
|
|
|
- //循环每一行的每一个单元格
|
|
|
- for (int l = 0; l <= 6; l++) {
|
|
|
- //判断是否是合并单元格并返回值
|
|
|
- String value = getValue(sheet, i, row.getCell(l).getColumnIndex());
|
|
|
- //数值为空说明不是合并单元格或者当前单元格为空,则直接获取当前单元格值
|
|
|
- if ("".equals(value)) {
|
|
|
- if (ObjectUtils.isNull(row.getCell(l))) {
|
|
|
- value = "";
|
|
|
- } else {
|
|
|
- CellType cellType = row.getCell(l).getCellTypeEnum();
|
|
|
- switch (cellType.name()) {
|
|
|
- case "STRING":
|
|
|
- value = row.getCell(l).getStringCellValue();
|
|
|
- // 处理字符串类型的值
|
|
|
- break;
|
|
|
- case "NUMERIC":
|
|
|
- value = row.getCell(l).getNumericCellValue() + "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "FORMULA":
|
|
|
- value = row.getCell(l).getNumericCellValue() + "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "_NONE":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "BLANK":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "BOOLEAN":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- case "ERROR":
|
|
|
- value = "";
|
|
|
- // 处理数字类型的值
|
|
|
- break;
|
|
|
- // 可以添加其他类型的处理
|
|
|
- default:
|
|
|
- System.out.println("cellType:" + cellType.name());
|
|
|
- throw new RuntimeException("数据类型错误");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- rowStr += "--" + value;
|
|
|
- }
|
|
|
- for (Cell cell : row) {
|
|
|
- //判断是否是合并单元格并返回值
|
|
|
- String value = getValue(sheet, i, cell.getColumnIndex());
|
|
|
- //数值为空说明不是合并单元格或者当前单元格为空,则直接获取当前单元格值
|
|
|
- if("".equals(value)){
|
|
|
- value=cell.getStringCellValue();
|
|
|
- }
|
|
|
- rowStr+="--"+value;
|
|
|
- }*/
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public R<List<Containers>> importHisense(MultipartFile file) throws Exception {
|
|
|
- return null;
|
|
|
+ List<Containers> containersList = new ArrayList<>();
|
|
|
+
|
|
|
+ // 创建临时文件
|
|
|
+ Path tempFile = Files.createTempFile("prefix", "suffix");
|
|
|
+ // 将MultipartFile的内容复制到临时文件
|
|
|
+ Files.copy(file.getInputStream(), tempFile, StandardCopyOption.REPLACE_EXISTING);
|
|
|
+
|
|
|
+ // 创建FileInputStream来读取临时文件
|
|
|
+ FileInputStream fis = new FileInputStream(tempFile.toFile());
|
|
|
+// Workbook workbook = new HSSFWorkbook(fis);
|
|
|
+ Workbook workbook = new XSSFWorkbook(fis);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0); // 获取第一个工作表
|
|
|
+
|
|
|
+ for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
|
|
+ Containers containers = new Containers();
|
|
|
+ //循环获取sheet页的每一行
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if (ObjectUtils.isNotNull(row.getCell(1))) {
|
|
|
+ containers.setCntrNo(row.getCell(1).getStringCellValue());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(row.getCell(2))) {
|
|
|
+ containers.setSealNo(row.getCell(2).getStringCellValue());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(row.getCell(3))) {
|
|
|
+ containers.setQuantity(BigDecimal.valueOf(row.getCell(3).getNumericCellValue()));
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(row.getCell(4))) {
|
|
|
+ containers.setGrossWeight(BigDecimal.valueOf(row.getCell(4).getNumericCellValue()));
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(row.getCell(5))) {
|
|
|
+ containers.setMeasurement(BigDecimal.valueOf(row.getCell(5).getNumericCellValue()));
|
|
|
+ }
|
|
|
+ containersList.add(containers);
|
|
|
+ }
|
|
|
+ return R.data(containersList);
|
|
|
}
|
|
|
}
|