diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java
index 3d3044e..39303f7 100644
--- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java
+++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInVo.java
@@ -25,7 +25,7 @@ import java.util.List;
@Data
@ApiModel(value = "出口进场基本表", description = "")
@MoreThan(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, field1 = "quantity", field2 = "eachQuantity", message = "数量不得超过单票件数")
-@DependsOn(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, field1 = "natureFlagName", fields = {"transferShipId", "transferShipName", "transferVoyageId", "transferVoyage"}, message = "货物性质为“正常”时,中转船ID,中转船名,中转航次ID,中转航次为空, 否则必填")
+@DependsOn(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, field1 = "natureFlagName", fields = {"transferShipId", "transferShipName", "transferVoyageId", "transferVoyage"}, message = "货物性质为“正常”时,中转船名,中转航次为空, 否则必填")
public class ExportInVo implements Serializable {
@ApiModelProperty(value = "是否直接提交审核")
diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExportExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExportExcel.java
index 963b362..30658a9 100644
--- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExportExcel.java
+++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInExportExcel.java
@@ -83,7 +83,7 @@ public class ExportInExportExcel {
@ExcelProperty("单票件数")
private Integer eachQuantity;
- @ExcelProperty("单票重量(吨)")
+ @ExcelProperty("单票重量(千克)")
private BigDecimal eachWeight;
@ExcelProperty("单票体积")
diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java
index a0eb724..cc4564d 100644
--- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java
+++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java
@@ -37,7 +37,7 @@ import java.util.Date;
* 19.源类型必须是是新能源、不是新能源,否则的导入不成功
*/
@Data
-@DependsOn(field1 = "natureFlagName", fields = {"transferShipName", "transferVoyage"}, message = "货物性质为“正常”时,中转船ID,中转船名,中转航次ID,中转航次为空, 否则必填")
+@DependsOn(field1 = "natureFlagName", fields = {"transferShipName", "transferVoyage"}, message = "货物性质为“正常”时,中转船名,中转航次为空, 否则必填")
public class ExportInPlanExcel {
/**
diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java
index 556e1fd..d53b5ab 100644
--- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java
+++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportLoadInsideExcel.java
@@ -9,7 +9,7 @@ import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
@Data
-@DependsOn(field1 = "natureFlagName", fields = {"transferShipName", "transferVoyage"}, message = "货物性质为“正常”时,中转船ID,中转船名,中转航次ID,中转航次为空, 否则必填")
+@DependsOn(field1 = "natureFlagName", fields = {"transferShipName", "transferVoyage"}, message = "货物性质为“正常”时,中转船名,中转航次为空, 否则必填")
public class ExportLoadInsideExcel {
@ExcelProperty("*船名")
diff --git a/nuzar-customer-controller/Dockerfile b/nuzar-customer-controller/Dockerfile
index f33c2f2..7b45921 100644
--- a/nuzar-customer-controller/Dockerfile
+++ b/nuzar-customer-controller/Dockerfile
@@ -2,6 +2,7 @@ FROM adoptopenjdk/openjdk8:ubi
WORKDIR /home
COPY target/*.jar /home/app.jar
EXPOSE 9000
+EXPOSE 18085
ENV TZ "Asia/Shanghai"
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime
ENV PROFILES_OPTS=""
diff --git a/nuzar-customer-controller/pom.xml b/nuzar-customer-controller/pom.xml
index e1cebcd..c112359 100644
--- a/nuzar-customer-controller/pom.xml
+++ b/nuzar-customer-controller/pom.xml
@@ -81,6 +81,20 @@
org.elasticsearch.client
7.17.2
+
+ com.nuzar
+ nuzar-xxl-starter
+
+
+ org.apache.groovy
+ groovy
+ 4.0.19
+
+
+ com.google.code.gson
+ gson
+ 2.9.0
+
diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java
index e73d77c..8201058 100644
--- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java
+++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java
@@ -78,4 +78,8 @@ public interface NuzarPubApi {
@GetMapping(value = "/shipManage/queryLikeShipManage")
List getShipList(@RequestParam("key") String key, @RequestParam("query") String query, @RequestParam("spmId") String spmId
, @RequestParam("valid") String valid, @RequestParam("vslCd") String vslCd, @RequestParam("vslCnname") String vslCnname, @RequestParam("vslEnnameList") List vslEnnameList);
+
+ // 类型匹配
+ @PostMapping("/attachment/mappingMap")
+ PubMappingMapDto getPubMapping();
}
diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PubMappingMapDto.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PubMappingMapDto.java
new file mode 100644
index 0000000..36e1ad7
--- /dev/null
+++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PubMappingMapDto.java
@@ -0,0 +1,23 @@
+package com.haitonggauto.rtosc.api.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+@Data
+@ApiModel("字典映射关系")
+public class PubMappingMapDto implements Serializable {
+
+ @ApiModelProperty(value ="车型-车型明细-code")
+ private Map> vehicleDetail;
+
+ @ApiModelProperty(value ="车型-操作模式-code")
+ private Map> opprocMode;
+
+ @ApiModelProperty(value ="国家-港口-id")
+ private Map> port;
+}
diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java
index 60fe97c..105c87e 100644
--- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java
+++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInHandler.java
@@ -26,6 +26,7 @@ import com.haitonggauto.rtosc.common.handler.BaseHandler;
import com.haitonggauto.rtosc.common.utils.*;
import com.haitonggauto.rtosc.dto.*;
import com.haitonggauto.rtosc.excel.*;
+import com.haitonggauto.rtosc.handler.excel.ExcelMergeUtil;
import com.haitonggauto.rtosc.handler.excel.ExcelValidationUtils;
import com.haitonggauto.rtosc.query.CargoQuery;
import com.haitonggauto.rtosc.query.ExportInCheckQuery;
@@ -798,7 +799,8 @@ public class ExportInHandler implements BaseHandler {
if (CollectionUtils.isNotEmpty(cargos)) { // 验证车架号
// 查询 车架号在系统中是否已经存在, 编辑的和新增的判断方式是不一样的
List vins = cargos.stream().map(item -> item.getVin()).collect(Collectors.toList());
- List exists = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins));
+ List exists = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT));
if (CollectionUtils.isNotEmpty(exists)) {
// 查询出对应的港区
List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, exists.stream().map(item -> item.getExportInId()).collect(Collectors.toList())).list();
@@ -1143,7 +1145,9 @@ public class ExportInHandler implements BaseHandler {
if (CollectionUtils.isNotEmpty(cargos)) {
// 查询 车架号在系统中是否已经存在, 编辑的和新增的判断方式是不一样的
List vins = cargos.stream().map(item -> item.getVin()).collect(Collectors.toList());
- List exists = customerExportInCargoService.list(new LambdaQueryWrapper().isNotNull(CustomerExportInCargo::getExportInId).in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
+ List exists = customerExportInCargoService.list(new LambdaQueryWrapper().isNotNull(CustomerExportInCargo::getExportInId).in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT)
+ .ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
if (CollectionUtils.isNotEmpty(exists)) {
// 查询出对应的港区
List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, exists.stream().map(item -> item.getExportInId()).collect(Collectors.toList())).list();
@@ -1581,7 +1585,8 @@ public class ExportInHandler implements BaseHandler {
// 移除oExists已经存在的
List vins = form.getVins().stream().filter(item -> !oExists.contains(item)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(vins)) {
- List exists = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins));
+ List exists = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT));
List existVins = exists.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 查询出对应的港区
@@ -1683,7 +1688,8 @@ public class ExportInHandler implements BaseHandler {
List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
- List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins));
+ List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT));
List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@@ -1907,7 +1913,9 @@ public class ExportInHandler implements BaseHandler {
List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
- List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
+ List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT)
+ .ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@@ -2099,7 +2107,9 @@ public class ExportInHandler implements BaseHandler {
List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
- List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
+ List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT)
+ .ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@@ -2273,6 +2283,7 @@ public class ExportInHandler implements BaseHandler {
.eq(CustomerExportIn::getBillNum, billNo)
.eq(CustomerExportIn::getBrand, brand)
.eq(CustomerExportIn::getModels, models)
+ .ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT)
.ne(CustomerExportIn::getCartType, "备件"); // 备件的不允许整船导入
// if (StringUtils.equals(type, "0")) {
// cQuery.and((wrapper) -> {
@@ -2386,7 +2397,10 @@ public class ExportInHandler implements BaseHandler {
List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
- List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
+ List existCargos = customerExportInCargoService
+ .list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT)
+ .ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@@ -2598,7 +2612,7 @@ public class ExportInHandler implements BaseHandler {
if (exportIn == null) {
errorDataList.addAll(item.getValue().stream().map(p -> {
JSONObject o = JSONObject.from(p);
- o.put("status", "数量不一致不允许导入");
+ o.put("status", "未匹配到数量一致的进港计划");
return o;
}).collect(Collectors.toList()));
return;
@@ -2653,7 +2667,9 @@ public class ExportInHandler implements BaseHandler {
List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
- List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
+ List existCargos = customerExportInCargoService.list(new LambdaQueryWrapper().in(CustomerExportInCargo::getVin, vins)
+ .notExists("select id from customer_export_in where customer_export_in.id=customer_export_in_cargo.export_in_id and customer_export_in.check_status={0}", AuditEnum.AUDIT_REJECT)
+ .ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@@ -2787,7 +2803,14 @@ public class ExportInHandler implements BaseHandler {
String fileName = URLEncoder.encode(DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN) + "出口进港计划清单", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
- excelWriter = EasyExcel.write(out).build();
+ //合并坐标
+ int[] mergeColumeIndex = {22,23,24};
+ //从第二行后开始合并
+ int mergeRowIndex = 1;
+
+ excelWriter = EasyExcel.write(out)
+ .registerWriteHandler(new ExcelMergeUtil(9, mergeRowIndex, mergeColumeIndex))
+ .build();
WriteSheet writeSheet = EasyExcel.writerSheet(0, "出口进港计划").head(ExportInExportExcel.class).build();
@@ -3143,7 +3166,8 @@ public class ExportInHandler implements BaseHandler {
// 获取用户绑定的货代
List userBindFreight = openApi.getUserBindFreight();
- ;
+
+ PubMappingMapDto pubMapping = pubApi.getPubMapping();
// 国家数据
List countryList = openApi.getCountryList();
@@ -3218,12 +3242,18 @@ public class ExportInHandler implements BaseHandler {
return;
}
String tmpCountryId = countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCtyCnname(), item.getCountry())).findFirst().get().getCtyId();
- if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortName()) && StringUtils.equals(tmpCountryId, p.getExtra2())).count() == 0) {
+ if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortName())).count() == 0) {
JSONObject o = JSONObject.from(item);
o.put("status", "港口不存在");
errorDataList.add(o);
return;
}
+ if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortName()) && StringUtils.equals(tmpCountryId, p.getExtra2())).count() == 0) {
+ JSONObject o = JSONObject.from(item);
+ o.put("status", "国家和港口不匹配");
+ errorDataList.add(o);
+ return;
+ }
if (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).count() == 0) {
JSONObject o = JSONObject.from(item);
o.put("status", "船名不存在");
@@ -3236,6 +3266,15 @@ public class ExportInHandler implements BaseHandler {
errorDataList.add(o);
return;
}
+ // 港区要和航次进行匹配
+ if (!((StringUtils.equals(item.getPortArea(), "外高桥") && StringUtils.equals(item.getVoyage(), "HT6")) ||
+ (StringUtils.equals(item.getPortArea(), "临港") && StringUtils.equals(item.getVoyage(), "HTLG")) ||
+ (StringUtils.equals(item.getPortArea(), "太仓") && StringUtils.equals(item.getVoyage(), "HTTC")))) {
+ JSONObject o = JSONObject.from(item);
+ o.put("status", "港区和航次不匹配");
+ errorDataList.add(o);
+ return;
+ }
if (brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getBrand())).count() == 0) {
JSONObject o = JSONObject.from(item);
o.put("status", "品牌不存在");
@@ -3248,6 +3287,7 @@ public class ExportInHandler implements BaseHandler {
errorDataList.add(o);
return;
}
+ String tmpCarTypeId = carTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartType())).findFirst().get().getId();
if (originPlaceList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCiyCnname(), item.getOriginPlace())).count() == 0) {
JSONObject o = JSONObject.from(item);
o.put("status", "产地错误");
@@ -3297,7 +3337,7 @@ public class ExportInHandler implements BaseHandler {
}
if (carDetailTypeList.get(item.getCartType()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartTypeDetail())).count() == 0) {
JSONObject o = JSONObject.from(item);
- o.put("status", "车型明细错误");
+ o.put("status", "车型明细错误或者车型和车型明细不匹配");
errorDataList.add(o);
return;
}
@@ -3308,6 +3348,13 @@ public class ExportInHandler implements BaseHandler {
errorDataList.add(o);
return;
}
+ String tmpOperateTypeId = operateTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getOperateType())).findFirst().get().getId();
+ if (MapUtils.isEmpty(pubMapping.getOpprocMode()) || !pubMapping.getOpprocMode().containsKey(tmpCarTypeId) || CollectionUtils.isEmpty(pubMapping.getOpprocMode().get(tmpCarTypeId)) || !pubMapping.getOpprocMode().get(tmpCarTypeId).contains(tmpOperateTypeId)) {
+ JSONObject o = JSONObject.from(item);
+ o.put("status", "车型和操作模式不匹配");
+ errorDataList.add(o);
+ return;
+ }
if (specWorkList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getSpecWork())).count() == 0) {
JSONObject o = JSONObject.from(item);
o.put("status", "特殊作业错误");
@@ -3372,6 +3419,12 @@ public class ExportInHandler implements BaseHandler {
errorDataList.add(o);
return;
}
+ if (bDate.getTime() > eDate.getTime()) {
+ JSONObject o = JSONObject.from(item);
+ o.put("status", "进场开始日期晚于进场结束日期");
+ errorDataList.add(o);
+ return;
+ }
if (StringUtils.isNotEmpty(item.getEnterTime())) {
// 验证进场时间是否正确
Date d = DateUtils.parseDate(StringUtils.trim(item.getEnterTime()), "yyyy/MM/dd HH:mm");
diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java
new file mode 100644
index 0000000..ff2e9b0
--- /dev/null
+++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelMergeUtil.java
@@ -0,0 +1,100 @@
+package com.haitonggauto.rtosc.handler.excel;
+
+import com.alibaba.excel.metadata.Head;
+import com.alibaba.excel.metadata.data.WriteCellData;
+import com.alibaba.excel.write.handler.CellWriteHandler;
+import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
+import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.util.CellRangeAddress;
+
+import java.util.List;
+
+public class ExcelMergeUtil implements CellWriteHandler {
+ private int[] mergeColumnIndex;
+ private int mergeRowIndex;
+ private int baseColIndex;
+
+ public ExcelMergeUtil() {
+ }
+
+ public ExcelMergeUtil(int baseColIndex, int mergeRowIndex, int[] mergeColumnIndex) {
+ this.baseColIndex = baseColIndex;
+ this.mergeRowIndex = mergeRowIndex;
+ this.mergeColumnIndex = mergeColumnIndex;
+ }
+
+ @Override
+ public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row, Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {
+
+ }
+
+ @Override
+ public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
+
+ }
+
+
+
+
+ @Override
+ public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
+
+ //当前行
+ int curRowIndex = cell.getRowIndex();
+ //当前列
+ int curColIndex = cell.getColumnIndex();
+
+ if (curRowIndex > mergeRowIndex) {
+ for (int i = 0; i < mergeColumnIndex.length; i++) {
+ if (curColIndex == mergeColumnIndex[i]) {
+ mergeWithPrevRow(writeSheetHolder, cell, curRowIndex, curColIndex);
+ break;
+ }
+ }
+ }
+
+ }
+
+ /**
+ * 当前单元格向上合并
+ *
+ * @param writeSheetHolder
+ * @param cell 当前单元格
+ * @param curRowIndex 当前行
+ * @param curColIndex 当前列
+ */
+ private void mergeWithPrevRow(WriteSheetHolder writeSheetHolder, Cell cell, int curRowIndex, int curColIndex) {
+ Object curData = cell.getCellType() == CellType.STRING ? cell.getStringCellValue() : cell.getNumericCellValue();
+ Cell preCell = cell.getSheet().getRow(curRowIndex - 1).getCell(curColIndex);
+ Object preData = preCell.getCellType()== CellType.STRING ? preCell.getStringCellValue() : preCell.getNumericCellValue();
+ // 将当前单元格数据与上一个单元格数据比较
+ Boolean dataBool = preData.equals(curData);
+ //此处需要注意,获取每一行第二列数据和上一行第一列数据进行比较,如果相等合并,getCell里面的值,是名称所在列的下标
+ System.err.println(cell.getRow().getCell(baseColIndex).getStringCellValue());
+ Boolean bool = cell.getRow().getCell(baseColIndex).getStringCellValue().equals(cell.getSheet().getRow(curRowIndex - 1).getCell(baseColIndex).getStringCellValue());
+ if (dataBool && bool) {
+ Sheet sheet = writeSheetHolder.getSheet();
+ List mergeRegions = sheet.getMergedRegions();
+ boolean isMerged = false;
+ for (int i = 0; i < mergeRegions.size() && !isMerged; i++) {
+ CellRangeAddress cellRangeAddr = mergeRegions.get(i);
+ // 若上一个单元格已经被合并,则先移出原有的合并单元,再重新添加合并单元
+ if (cellRangeAddr.isInRange(curRowIndex - 1, curColIndex)) {
+ sheet.removeMergedRegion(i);
+ cellRangeAddr.setLastRow(curRowIndex);
+ sheet.addMergedRegion(cellRangeAddr);
+ isMerged = true;
+ }
+ }
+ // 若上一个单元格未被合并,则新增合并单元
+ if (!isMerged) {
+ CellRangeAddress cellRangeAddress = new CellRangeAddress(curRowIndex - 1, curRowIndex, curColIndex, curColIndex);
+ sheet.addMergedRegion(cellRangeAddress);
+ }
+ }
+ }
+}
diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java
new file mode 100644
index 0000000..a9786d0
--- /dev/null
+++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/job/SyncToOldHandler.java
@@ -0,0 +1,72 @@
+package com.haitonggauto.rtosc.job;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.haitonggauto.rtosc.common.context.UserContext;
+import com.haitonggauto.rtosc.common.dto.LoginUser;
+import com.haitonggauto.rtosc.common.utils.OkHttpUtils;
+import com.haitonggauto.rtosc.config.SyncConfig;
+import com.haitonggauto.rtosc.repository.entity.CustomerExportInSyncLog;
+import com.haitonggauto.rtosc.repository.service.CustomerExportInSyncLogService;
+import com.nuzar.common.security5.common.util.SecurityUtils;
+import com.xxl.job.core.context.XxlJobHelper;
+import com.xxl.job.core.handler.annotation.XxlJob;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Component
+public class SyncToOldHandler {
+
+ @Resource
+ private CustomerExportInSyncLogService syncLogService;
+
+ @Resource
+ private SyncConfig syncConfig;
+
+ /**
+ * 1、同步进港计划
+ */
+ @XxlJob("exportInSyncHandler")
+ public void exportInSyncHandler() throws Exception {
+ XxlJobHelper.log("同步开始");
+
+ Page page = syncLogService.lambdaQuery().like(CustomerExportInSyncLog::getResponseStr, "Failed to connect to").page(new Page<>(1, 10));
+
+ List collect = page.getRecords().stream().map(item -> item.getRequestStr()).collect(Collectors.toList());
+
+ XxlJobHelper.log("需要同步的数据:" + JSONObject.toJSONString(collect));
+
+ // 异步时,变量会丢失
+// LoginUser tmpUser = new LoginUser();
+// tmpUser.setUserId(SecurityUtils.getUserId());
+// tmpUser.setRoleId(0L);
+// tmpUser.setAdmin(true);
+//
+// UserContext.setUser(tmpUser);
+ for (CustomerExportInSyncLog item : page.getRecords()) {
+ try {
+
+ XxlJobHelper.log("同步老系统:" + item.getRequestStr());
+
+ String post = OkHttpUtils.post(syncConfig.getUrl() + "/execInPortPlanAdd", OkHttpUtils.buildJsonRequestBody(item.getRequestStr()), null);
+
+ JSONObject rst = JSONObject.parseObject(post);
+
+ XxlJobHelper.log("同步老系统结果:" + JSONObject.toJSONString(rst));
+
+ if (StringUtils.equals("0", rst.getString("success"))) {
+ throw new RuntimeException("请求参数:" + item.getRequestStr() + ", 错误信息:" + rst.getString("errmsg"));
+ }
+
+ // 成功后就删除
+ syncLogService.removeById(item);
+ } catch (Exception e) {
+ XxlJobHelper.log("同步失败:" + e.getMessage());
+ }
+ }
+ }
+}
diff --git a/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx b/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx
index 02a3a7f..fb98092 100644
Binary files a/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx and b/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx differ