|
|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.los.business.sea.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
@@ -7,9 +8,15 @@ 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.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.los.basic.ports.entity.BPorts;
|
|
|
+import org.springblade.los.basic.ports.service.IBPortsService;
|
|
|
+import org.springblade.los.basic.vessels.entity.BVessels;
|
|
|
+import org.springblade.los.basic.vessels.service.IBVesselsService;
|
|
|
import org.springblade.los.business.sea.entity.Bills;
|
|
|
import org.springblade.los.business.sea.entity.Containers;
|
|
|
+import org.springblade.los.business.sea.entity.SeaBillsDetail;
|
|
|
import org.springblade.los.business.sea.service.ITemplateImportService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -31,10 +38,14 @@ import java.util.List;
|
|
|
@AllArgsConstructor
|
|
|
public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
|
|
|
+ private final IBVesselsService bVesselsService;
|
|
|
+
|
|
|
+ private final IBPortsService bPortsService;
|
|
|
|
|
|
@Override
|
|
|
public R<Bills> importOne(MultipartFile file) throws Exception {
|
|
|
Bills bills = new Bills();
|
|
|
+ SeaBillsDetail seaBillsDetail = new SeaBillsDetail();
|
|
|
// 创建临时文件
|
|
|
Path tempFile = Files.createTempFile("prefix", "suffix");
|
|
|
// 将MultipartFile的内容复制到临时文件
|
|
|
@@ -63,7 +74,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
}
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(shipper)) {
|
|
|
- bills.setHshipperDetails(shipper.toString());
|
|
|
+ seaBillsDetail.setHshipperDetails(shipper.toString());
|
|
|
+// bills.setHshipperDetails(shipper.toString());
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
} else {
|
|
|
throw new RuntimeException("发货人提单描述不能为空");
|
|
|
@@ -76,7 +88,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
}
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(consignee)) {
|
|
|
- bills.setHconsigneeDetails(consignee.toString());
|
|
|
+ seaBillsDetail.setHconsigneeDetails(consignee.toString());
|
|
|
+// bills.setHconsigneeDetails(consignee.toString());
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
} else {
|
|
|
throw new RuntimeException("收货人提单描述不能为空");
|
|
|
@@ -89,7 +102,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
}
|
|
|
}
|
|
|
if (ObjectUtils.isNotNull(notifyParty)) {
|
|
|
- bills.setHnotifyDetails(notifyParty.toString());
|
|
|
+ seaBillsDetail.setHnotifyDetails(notifyParty.toString());
|
|
|
+// bills.setHnotifyDetails(notifyParty.toString());
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
} else {
|
|
|
throw new RuntimeException("通知人提单描述不能为空");
|
|
|
@@ -108,7 +122,18 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
if (vslVoy.contains("/")) {
|
|
|
String vsl = vslVoy.substring(0, vslVoy.indexOf("/"));
|
|
|
String voy = vslVoy.substring(vslVoy.indexOf("/") + 1);
|
|
|
- bills.setVesselEnName(vsl);
|
|
|
+ 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);
|
|
|
@@ -122,32 +147,83 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//POR
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(19).getCell(1))) {
|
|
|
String por = sheet.getRow(19).getCell(1).getStringCellValue();
|
|
|
+ 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);
|
|
|
- bills.setPlaceReceiptName(por);
|
|
|
+
|
|
|
} else {
|
|
|
throw new RuntimeException("收货港不能为空");
|
|
|
}
|
|
|
//POL
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(19).getCell(4))) {
|
|
|
String pol = sheet.getRow(19).getCell(4).getStringCellValue();
|
|
|
+ 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);
|
|
|
- bills.setPolEnName(pol);
|
|
|
} else {
|
|
|
throw new RuntimeException("装运港不能为空");
|
|
|
}
|
|
|
//POD
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(20).getCell(1))) {
|
|
|
String pod = sheet.getRow(20).getCell(1).getStringCellValue();
|
|
|
+ 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);
|
|
|
- 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();
|
|
|
+ if (ObjectUtils.isNotNull(placeOfDelivery)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .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());
|
|
|
+ }
|
|
|
+ }
|
|
|
System.out.println("placeOfDelivery:" + placeOfDelivery);
|
|
|
- bills.setDestinationName(placeOfDelivery);
|
|
|
} else {
|
|
|
throw new RuntimeException("目的港不能为空");
|
|
|
}
|
|
|
@@ -239,8 +315,20 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//FINAL DESTINATION FOR THE MERCHANT’S REFERENCE
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(51).getCell(4))) {
|
|
|
String finalDestination = sheet.getRow(51).getCell(4).getStringCellValue();
|
|
|
+ if (ObjectUtils.isNotNull(finalDestination)) {
|
|
|
+ BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
+ .eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(BPorts::getIsDeleted, 0)
|
|
|
+ .eq(BPorts::getEnName, finalDestination)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ports != null) {
|
|
|
+ bills.setFinalDestinationId(ports.getId());
|
|
|
+ bills.setFinalDestinationCode(ports.getCode());
|
|
|
+ bills.setFinalDestinationName(ports.getEnName());
|
|
|
+ bills.setFinalDestinationNamePrint(ports.getEnName());
|
|
|
+ }
|
|
|
+ }
|
|
|
System.out.println("finalDestination:" + finalDestination);
|
|
|
- bills.setFinalDestinationName(finalDestination);
|
|
|
}
|
|
|
bills.setContainersList(new ArrayList<>());
|
|
|
bills.setPreContainersList(new ArrayList<>());
|
|
|
@@ -249,6 +337,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
bills.setFeeCenterListD(new ArrayList<>());
|
|
|
bills.setFilesList(new ArrayList<>());
|
|
|
bills.setWaitingBoxList(new ArrayList<>());
|
|
|
+ bills.setDetail(seaBillsDetail);
|
|
|
//将字符串为null的赋默认值为""
|
|
|
Field[] fields = bills.getClass().getDeclaredFields();
|
|
|
for (Field field : fields) {
|
|
|
@@ -270,6 +359,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
@Override
|
|
|
public R<Bills> importPilBooking(MultipartFile file) throws Exception {
|
|
|
Bills bills = new Bills();
|
|
|
+ SeaBillsDetail seaBillsDetail = new SeaBillsDetail();
|
|
|
// 创建临时文件
|
|
|
Path tempFile = Files.createTempFile("prefix", "suffix");
|
|
|
// 将MultipartFile的内容复制到临时文件
|
|
|
@@ -283,7 +373,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//SHIPPER
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(2).getCell(0))) {
|
|
|
String shipper = sheet.getRow(2).getCell(0).getStringCellValue();
|
|
|
- bills.setHshipperDetails(shipper);
|
|
|
+// bills.setHshipperDetails(shipper);
|
|
|
+ seaBillsDetail.setHshipperDetails(shipper);
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
} else {
|
|
|
throw new RuntimeException("托运人不能为空");
|
|
|
@@ -291,7 +382,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//CONSIGNEE
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(9).getCell(0))) {
|
|
|
String consignee = sheet.getRow(9).getCell(0).getStringCellValue();
|
|
|
- bills.setHconsigneeDetails(consignee);
|
|
|
+ seaBillsDetail.setHconsigneeDetails(consignee);
|
|
|
+// bills.setHconsigneeDetails(consignee);
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
} else {
|
|
|
throw new RuntimeException("收货人不能为空");
|
|
|
@@ -299,7 +391,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//NOTIFY PARTY
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(16).getCell(0))) {
|
|
|
String notifyParty = sheet.getRow(16).getCell(0).getStringCellValue();
|
|
|
- bills.setHnotifyDetails(notifyParty);
|
|
|
+// bills.setHnotifyDetails(notifyParty);
|
|
|
+ seaBillsDetail.setHnotifyDetails(notifyParty);
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
} else {
|
|
|
throw new RuntimeException("通知人不能为空");
|
|
|
@@ -359,6 +452,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
bills.setFeeCenterListD(new ArrayList<>());
|
|
|
bills.setFilesList(new ArrayList<>());
|
|
|
bills.setWaitingBoxList(new ArrayList<>());
|
|
|
+ bills.setDetail(seaBillsDetail);
|
|
|
Field[] fields = bills.getClass().getDeclaredFields();
|
|
|
for (Field field : fields) {
|
|
|
try {
|
|
|
@@ -379,6 +473,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
@Override
|
|
|
public R<Bills> importPilCutOffOrders(MultipartFile file) throws Exception {
|
|
|
Bills bills = new Bills();
|
|
|
+ SeaBillsDetail seaBillsDetail = new SeaBillsDetail();
|
|
|
// 创建临时文件
|
|
|
Path tempFile = Files.createTempFile("prefix", "suffix");
|
|
|
// 将MultipartFile的内容复制到临时文件
|
|
|
@@ -392,7 +487,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//SHIPPER
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(2).getCell(0))) {
|
|
|
String shipper = sheet.getRow(2).getCell(0).getStringCellValue();
|
|
|
- bills.setHshipperDetails(shipper);
|
|
|
+// bills.setHshipperDetails(shipper);
|
|
|
+ seaBillsDetail.setHshipperDetails(shipper);
|
|
|
System.out.println("shipper:" + shipper);
|
|
|
} else {
|
|
|
throw new RuntimeException("托运人不能为空");
|
|
|
@@ -400,7 +496,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//CONSIGNEE
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(9).getCell(0))) {
|
|
|
String consignee = sheet.getRow(9).getCell(0).getStringCellValue();
|
|
|
- bills.setHconsigneeDetails(consignee);
|
|
|
+ seaBillsDetail.setHconsigneeDetails(consignee);
|
|
|
+// bills.setHconsigneeDetails(consignee);
|
|
|
System.out.println("consignee:" + consignee);
|
|
|
} else {
|
|
|
throw new RuntimeException("收货人不能为空");
|
|
|
@@ -408,7 +505,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
//NOTIFY PARTY
|
|
|
if (ObjectUtils.isNotNull(sheet.getRow(16).getCell(0))) {
|
|
|
String notifyParty = sheet.getRow(16).getCell(0).getStringCellValue();
|
|
|
- bills.setHnotifyDetails(notifyParty);
|
|
|
+ seaBillsDetail.setHnotifyDetails(notifyParty);
|
|
|
+// bills.setHnotifyDetails(notifyParty);
|
|
|
System.out.println("notifyParty:" + notifyParty);
|
|
|
} else {
|
|
|
throw new RuntimeException("通知人不能为空");
|
|
|
@@ -461,6 +559,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
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 {
|