进港导出

This commit is contained in:
dengjun 2024-03-12 13:05:03 +08:00
parent 10c018cb81
commit b31b25b6ff
12 changed files with 284 additions and 17 deletions

View File

@ -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 = "是否直接提交审核")

View File

@ -83,7 +83,7 @@ public class ExportInExportExcel {
@ExcelProperty("单票件数")
private Integer eachQuantity;
@ExcelProperty("单票重量(")
@ExcelProperty("单票重量(千克")
private BigDecimal eachWeight;
@ExcelProperty("单票体积")

View File

@ -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 {
/**

View File

@ -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("*船名")

View File

@ -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=""

View File

@ -81,6 +81,20 @@
<groupId>org.elasticsearch.client</groupId>
<version>7.17.2</version>
</dependency>
<dependency>
<groupId>com.nuzar</groupId>
<artifactId>nuzar-xxl-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>4.0.19</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies>
<build>

View File

@ -78,4 +78,8 @@ public interface NuzarPubApi {
@GetMapping(value = "/shipManage/queryLikeShipManage")
List<ShipDTO> 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<String> vslEnnameList);
// 类型匹配
@PostMapping("/attachment/mappingMap")
PubMappingMapDto getPubMapping();
}

View File

@ -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<String, List<String>> vehicleDetail;
@ApiModelProperty(value ="车型-操作模式-code")
private Map<String,List<String>> opprocMode;
@ApiModelProperty(value ="国家-港口-id")
private Map<String, List<String>> port;
}

View File

@ -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<String> vins = cargos.stream().map(item -> item.getVin()).collect(Collectors.toList());
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins));
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<CustomerExportIn> 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<String> vins = cargos.stream().map(item -> item.getVin()).collect(Collectors.toList());
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().isNotNull(CustomerExportInCargo::getExportInId).in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<CustomerExportIn> 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<String> vins = form.getVins().stream().filter(item -> !oExists.contains(item)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(vins)) {
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins));
List<CustomerExportInCargo> exists = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<String> existVins = exists.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 查询出对应的港区
@ -1683,7 +1688,8 @@ public class ExportInHandler implements BaseHandler {
List<String> vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins));
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<String> existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@ -1907,7 +1913,9 @@ public class ExportInHandler implements BaseHandler {
List<String> vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<String> existVins = existCargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(existCargos)) {
@ -2099,7 +2107,9 @@ public class ExportInHandler implements BaseHandler {
List<String> vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<String> 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<String> vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List<CustomerExportInCargo> existCargos = customerExportInCargoService
.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<String> 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<String> vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList());
// 验证哪些车架号已经存在了
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().in(CustomerExportInCargo::getVin, vins).ne(CustomerExportInCargo::getExportInId, exportIn.getId()));
List<CustomerExportInCargo> existCargos = customerExportInCargoService.list(new LambdaQueryWrapper<CustomerExportInCargo>().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<String> 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<FreightVo> userBindFreight = openApi.getUserBindFreight();
;
PubMappingMapDto pubMapping = pubApi.getPubMapping();
// 国家数据
List<CityDTO> 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");

View File

@ -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<WriteCellData<?>> 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<CellRangeAddress> 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);
}
}
}
}

View File

@ -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<CustomerExportInSyncLog> page = syncLogService.lambdaQuery().like(CustomerExportInSyncLog::getResponseStr, "Failed to connect to").page(new Page<>(1, 10));
List<String> 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());
}
}
}
}