|
|
@@ -18,8 +18,11 @@ 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.PreContainers;
|
|
|
import org.springblade.los.business.sea.entity.SeaBillsDetail;
|
|
|
import org.springblade.los.business.sea.service.IBillsService;
|
|
|
+import org.springblade.los.business.sea.service.IContainersService;
|
|
|
+import org.springblade.los.business.sea.service.IPreContainersService;
|
|
|
import org.springblade.los.business.sea.service.ITemplateImportService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@@ -34,6 +37,7 @@ import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
|
import java.nio.file.StandardCopyOption;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author :jixinyuan
|
|
|
@@ -50,6 +54,9 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
|
|
|
private final IBillsService billsService;
|
|
|
|
|
|
+ private final IContainersService containersService;
|
|
|
+ private final IPreContainersService preContainersService;
|
|
|
+
|
|
|
public static double splitNumericPrefixFromString(String str){
|
|
|
str=str.replace(" ","").trim();
|
|
|
String str2="", str3="";
|
|
|
@@ -1141,6 +1148,14 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
SeaBillsDetail seaBillsDetail = new SeaBillsDetail();
|
|
|
List<Containers> containersList = new ArrayList<>();
|
|
|
|
|
|
+ int cntrCount = containersService.count(new LambdaQueryWrapper<Containers>()
|
|
|
+ .eq(Containers::getPid, bills.getId())
|
|
|
+ .eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Containers::getIsDeleted, 0));
|
|
|
+ if(cntrCount>0){
|
|
|
+ throw new RuntimeException("该业务已经配箱,请删除配箱后再导入!");
|
|
|
+ }
|
|
|
+
|
|
|
// 创建临时文件
|
|
|
Path tempFile = Files.createTempFile("prefix", "suffix");
|
|
|
// 将MultipartFile的内容复制到临时文件
|
|
|
@@ -1199,6 +1214,8 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
sbLines.setLength(0);
|
|
|
String portName = getSheetCellValueAsString(sheet, r, 1);
|
|
|
if (ObjectUtils.isNotNull(portName)) {
|
|
|
+ /*
|
|
|
+ // 港口不导
|
|
|
BPorts ports = bPortsService.getOne(new LambdaQueryWrapper<BPorts>()
|
|
|
.eq(BPorts::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(BPorts::getIsDeleted, 0)
|
|
|
@@ -1229,6 +1246,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
bills.setPlaceDeliveryNamePrint(ports.getEnName());
|
|
|
}
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
System.out.println(val0 + ":" + portName);
|
|
|
} else if (val0.equals("SHIPPINGMARK")) {
|
|
|
@@ -1265,6 +1283,14 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
String cntrNo = getSheetCellValueAsString(sheet, cr, 1);
|
|
|
if(cntrType.length()==4 && cntrNo.length()==11) {
|
|
|
Containers containers = new Containers();
|
|
|
+ containers.setId(null);
|
|
|
+ containers.setPid(bills.getId());
|
|
|
+ containers.setBranchId(bills.getBranchId());
|
|
|
+ containers.setBillNo(bills.getBillNo());
|
|
|
+ containers.setCreateUser(bills.getCreateUser());
|
|
|
+ containers.setCreateUserName(bills.getCreateUserName());
|
|
|
+ containers.setTenantId(AuthUtil.getTenantId());
|
|
|
+
|
|
|
containers.setCntrTypeCode(cntrType);
|
|
|
containers.setCntrNo(cntrNo);
|
|
|
containers.setSealNo(getSheetCellValueAsString(sheet, cr, 2));
|
|
|
@@ -1287,10 +1313,13 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
|
|
|
sumQty.setScale(0, BigDecimal.ROUND_HALF_UP);
|
|
|
bills.setQuantity(sumQty);
|
|
|
+ bills.setCfsQuantity(sumQty);
|
|
|
sumGw.setScale(3, BigDecimal.ROUND_HALF_UP);
|
|
|
bills.setGrossWeight(sumGw);
|
|
|
+ bills.setCfsGrossWeight(sumGw);
|
|
|
sumVol.setScale(3, BigDecimal.ROUND_HALF_UP);
|
|
|
bills.setMeasurement(sumVol);
|
|
|
+ bills.setCfsMeasurement(sumVol);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1324,8 +1353,55 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
|
|
|
bills.setCommodityDescr(sbLines.toString().trim());
|
|
|
|
|
|
+ List<PreContainers> preContainers = preContainersService.list(new LambdaQueryWrapper<PreContainers>()
|
|
|
+ .eq(PreContainers::getIsDeleted, 0)
|
|
|
+ .eq(PreContainers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PreContainers::getPid, bills.getId()));
|
|
|
+
|
|
|
+ // 比较预配箱与海信文件中的配箱箱型、数量
|
|
|
+ if(preContainers.size()==0 && containersList.size()>0){
|
|
|
+ throw new RuntimeException("预配箱箱型数量与文件中箱号不匹配!");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < preContainers.size(); i++) {
|
|
|
+ PreContainers pc = preContainers.get(i);
|
|
|
+ List<Containers> aList = containersList.stream().filter(f->f.getCntrTypeCode().equals(pc.getCntrTypeCode())).collect(Collectors.toList());
|
|
|
+ if(!pc.getQuantity().equals(aList.size())){
|
|
|
+ throw new RuntimeException("预配箱箱型数量与文件中箱号不匹配!");
|
|
|
+ }
|
|
|
+ for (int j = 0; j < aList.size(); j++) {
|
|
|
+ Containers cntr = aList.get(j);
|
|
|
+ cntr.setId(pc.getId());
|
|
|
+ cntr.setTeu(pc.getTeu());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Containers> aList = containersList.stream().filter(f->ObjectUtils.isNull(f.getId())).collect(Collectors.toList());
|
|
|
+ if(aList.size()>0){
|
|
|
+ throw new RuntimeException("预配箱箱型数量与文件中箱号不匹配!");
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int j = 0; j < containersList.size(); j++) {
|
|
|
+ Containers cntr = containersList.get(j);
|
|
|
+ cntr.setId(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ // containersService.removeByPid(bills.getId(), "");
|
|
|
+ /*
|
|
|
+ if(containersList.size()>0) {
|
|
|
+ // 保存配箱箱号明细
|
|
|
+ containersService.submitList(containersList);
|
|
|
+
|
|
|
+ // 重新提取配箱箱号明细
|
|
|
+ containersList = containersService.list(new LambdaQueryWrapper<Containers>()
|
|
|
+ .eq(Containers::getPid, bills.getId())
|
|
|
+ .eq(Containers::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(Containers::getIsDeleted, 0));
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
bills.setContainersList(containersList);
|
|
|
- bills.setPreContainersList(new ArrayList<>());
|
|
|
+ bills.setPreContainersList(preContainers);
|
|
|
bills.setContainersReportsList(new ArrayList<>());
|
|
|
bills.setFeeCenterListC(new ArrayList<>());
|
|
|
bills.setFeeCenterListD(new ArrayList<>());
|
|
|
@@ -1333,6 +1409,7 @@ public class TemplateImportServiceImpl implements ITemplateImportService {
|
|
|
bills.setWaitingBoxList(new ArrayList<>());
|
|
|
bills.setDetail(seaBillsDetail);
|
|
|
resetBillsNullValuesAsEmptyString(bills);
|
|
|
+
|
|
|
return R.data(bills);
|
|
|
}
|
|
|
|