同步BUG修复

This commit is contained in:
dengjun 2024-03-05 17:09:09 +08:00
parent bdf6232e15
commit cdf82b1963
4 changed files with 1847 additions and 1786 deletions

View File

@ -48,10 +48,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationConstraint;
import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.*; import org.apache.poi.xssf.usermodel.*;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -80,6 +76,7 @@ import java.util.stream.Collectors;
@RequestMapping("/ee") @RequestMapping("/ee")
@Api(tags = "出口进场") @Api(tags = "出口进场")
@Validated @Validated
@Slf4j
public class ExportInHandler implements BaseHandler { public class ExportInHandler implements BaseHandler {
@Resource @Resource
@ -342,6 +339,7 @@ public class ExportInHandler implements BaseHandler {
if (CollectionUtils.isNotEmpty(page.getRecords())) { if (CollectionUtils.isNotEmpty(page.getRecords())) {
QueryWrapper<CustomerExportIn> q = new QueryWrapper<>(); QueryWrapper<CustomerExportIn> q = new QueryWrapper<>();
q.in("voyage_id", page.getRecords().stream().map(item -> item.getVoyageId()).collect(Collectors.toList())); q.in("voyage_id", page.getRecords().stream().map(item -> item.getVoyageId()).collect(Collectors.toList()));
q.eq("check_status", AuditEnum.AUDIT_PASS);
q.select("sum(quantity) as quantity, port_area_id, ship_id, voyage_id"); q.select("sum(quantity) as quantity, port_area_id, ship_id, voyage_id");
q.groupBy("port_area_id, ship_id, voyage_id"); q.groupBy("port_area_id, ship_id, voyage_id");
@ -1629,7 +1627,7 @@ public class ExportInHandler implements BaseHandler {
@ApiOperation("车架号导入(数组形式)") @ApiOperation("车架号导入(数组形式)")
@PostMapping("/import-vin-data") @PostMapping("/import-vin-data")
public Result<List<JSONObject>> importVinData(@RequestBody @Validated ImportVinVo vinList) throws IOException { public Result<List<JSONObject>> importVinData(@RequestBody @Validated ImportVinVo vinList) {
// 船名航次不存在 // 船名航次不存在
List<ExportVinExcel> noShipList = new ArrayList<>(); List<ExportVinExcel> noShipList = new ArrayList<>();
// 数量不一致 // 数量不一致
@ -1642,6 +1640,8 @@ public class ExportInHandler implements BaseHandler {
List<ExportVinExcel> validData = vinList.getData(); List<ExportVinExcel> validData = vinList.getData();
// 对不完整的数据进行筛选 // 对不完整的数据进行筛选
try {
// 不能有重复的车架号 // 不能有重复的车架号
List<String> list = validData.stream().collect(Collectors.groupingBy(ExportVinExcel::getVin, Collectors.counting())) List<String> list = validData.stream().collect(Collectors.groupingBy(ExportVinExcel::getVin, Collectors.counting()))
.entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList());
@ -1756,6 +1756,11 @@ public class ExportInHandler implements BaseHandler {
} }
return ResultUtil.success(rst); return ResultUtil.success(rst);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("车架号导入模板下载") @ApiOperation("车架号导入模板下载")
@ -1799,7 +1804,8 @@ public class ExportInHandler implements BaseHandler {
@ApiOperation("车架号导入(文件形式)") @ApiOperation("车架号导入(文件形式)")
@PostMapping("/import-vin") @PostMapping("/import-vin")
public Result<List<JSONObject>> importVin(@RequestParam(required = false) @NotNull(message = "出口进场ID不能为空") Long id, MultipartFile file) throws IOException { public Result<List<JSONObject>> importVin(@RequestParam(required = false) @NotNull(message = "出口进场ID不能为空") Long id, MultipartFile file) {
try {
CustomerExportIn exportIn = customerExportInService.getById(id); CustomerExportIn exportIn = customerExportInService.getById(id);
List<Long> havePlans = openApi.haveShipPlan(exportIn.getVoyageId()); List<Long> havePlans = openApi.haveShipPlan(exportIn.getVoyageId());
@ -1958,6 +1964,10 @@ public class ExportInHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("备件号导入模板下载") @ApiOperation("备件号导入模板下载")
@ -2001,7 +2011,8 @@ public class ExportInHandler implements BaseHandler {
@ApiOperation("备件号导入") @ApiOperation("备件号导入")
@PostMapping("/import-spare") @PostMapping("/import-spare")
public Result<List<JSONObject>> importSpare(@RequestParam(required = false) @NotNull(message = "出口进场ID不能为空") Long id, MultipartFile file) throws IOException { public Result<List<JSONObject>> importSpare(@RequestParam(required = false) @NotNull(message = "出口进场ID不能为空") Long id, MultipartFile file) {
try {
CustomerExportIn exportIn = customerExportInService.getById(id); CustomerExportIn exportIn = customerExportInService.getById(id);
List<Long> havePlans = openApi.haveShipPlan(exportIn.getVoyageId()); List<Long> havePlans = openApi.haveShipPlan(exportIn.getVoyageId());
@ -2144,6 +2155,10 @@ public class ExportInHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("整船清单导入模板下载") @ApiOperation("整船清单导入模板下载")
@ -2189,7 +2204,7 @@ public class ExportInHandler implements BaseHandler {
@PostMapping("/import-to-add") @PostMapping("/import-to-add")
public Result<List<JSONObject>> upload( public Result<List<JSONObject>> upload(
@ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type, @ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException { MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<ExportInExcel> dataList = new ArrayList<>(); List<ExportInExcel> dataList = new ArrayList<>();
@ -2202,6 +2217,8 @@ public class ExportInHandler implements BaseHandler {
// 需要清空的 // 需要清空的
List<Long> ids = new ArrayList<>(); List<Long> ids = new ArrayList<>();
try {
// 要保存到数据库的数据 // 要保存到数据库的数据
List<CustomerExportInCargo> saveCargos = new ArrayList<>(); List<CustomerExportInCargo> saveCargos = new ArrayList<>();
@ -2434,6 +2451,10 @@ public class ExportInHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("整票备件号导入模板下载") @ApiOperation("整票备件号导入模板下载")
@ -2479,7 +2500,7 @@ public class ExportInHandler implements BaseHandler {
@PostMapping("/import-to-add/spare") @PostMapping("/import-to-add/spare")
public Result<List<JSONObject>> uploadSpare( public Result<List<JSONObject>> uploadSpare(
@ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type, @ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException { MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<ExportInBillSpareExcel> dataList = new ArrayList<>(); List<ExportInBillSpareExcel> dataList = new ArrayList<>();
@ -2495,6 +2516,8 @@ public class ExportInHandler implements BaseHandler {
// 要保存到数据库的数据 // 要保存到数据库的数据
List<CustomerExportInCargo> saveCargos = new ArrayList<>(); List<CustomerExportInCargo> saveCargos = new ArrayList<>();
try {
EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener<ExportInBillSpareExcel>() { EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener<ExportInBillSpareExcel>() {
@Override @Override
protected void saveData(List<ExportInBillSpareExcel> list) { // 保存数据 protected void saveData(List<ExportInBillSpareExcel> list) { // 保存数据
@ -2695,6 +2718,10 @@ public class ExportInHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("导入删除") @ApiOperation("导入删除")
@ -3102,7 +3129,7 @@ public class ExportInHandler implements BaseHandler {
@PostMapping("/exportIn/plan/import-to-add") @PostMapping("/exportIn/plan/import-to-add")
public Result<List<JSONObject>> exportInPlanUpload( public Result<List<JSONObject>> exportInPlanUpload(
@ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type, @ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException { MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<ExportInPlanExcel> dataList = new ArrayList<>(); List<ExportInPlanExcel> dataList = new ArrayList<>();
@ -3112,8 +3139,11 @@ public class ExportInHandler implements BaseHandler {
// 验证通过的数据 // 验证通过的数据
List<JSONObject> successDataList = new ArrayList<>(); List<JSONObject> successDataList = new ArrayList<>();
try {
// 获取用户绑定的货代 // 获取用户绑定的货代
List<FreightVo> userBindFreight = openApi.getUserBindFreight();; List<FreightVo> userBindFreight = openApi.getUserBindFreight();
;
// 国家数据 // 国家数据
List<CityDTO> countryList = openApi.getCountryList(); List<CityDTO> countryList = openApi.getCountryList();
@ -3555,6 +3585,10 @@ public class ExportInHandler implements BaseHandler {
customerService.saveExportIn(ss, null, times, null); customerService.saveExportIn(ss, null, times, null);
}); });
}); });
} catch (Exception e) {
log.error("上传错误", e);
return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage());
}
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} }

View File

@ -39,6 +39,7 @@ import com.nuzar.rtops.log.dto.LogRecordDTO;
import com.nuzar.rtops.log.service.EsLogApprovalUtil; import com.nuzar.rtops.log.service.EsLogApprovalUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -66,6 +67,7 @@ import java.util.stream.Collectors;
@RequestMapping("/el") @RequestMapping("/el")
@Api(tags = "出口装船") @Api(tags = "出口装船")
@Validated @Validated
@Slf4j
public class ExportLoadHandler implements BaseHandler { public class ExportLoadHandler implements BaseHandler {
@Resource @Resource
@ -1025,7 +1027,7 @@ public class ExportLoadHandler implements BaseHandler {
@ApiOperation("外贸整船车辆导入") @ApiOperation("外贸整船车辆导入")
@PostMapping("/outside/import-to-add") @PostMapping("/outside/import-to-add")
public Result<List<JSONObject>> outsideUpload(@RequestParam(required = false) String type, MultipartFile file) throws IOException { public Result<List<JSONObject>> outsideUpload(@RequestParam(required = false) String type, MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<ExportLoadExcel> dataList = new ArrayList<>(); List<ExportLoadExcel> dataList = new ArrayList<>();
@ -1041,6 +1043,7 @@ public class ExportLoadHandler implements BaseHandler {
// 要保存的明细 // 要保存的明细
Map<String, List<CustomerExportLoadCargo>> details = new HashMap<>(); Map<String, List<CustomerExportLoadCargo>> details = new HashMap<>();
try {
// 港口基础数据 // 港口基础数据
List<DictDTO> portList = dictHandler.getPortList(null).getData(); List<DictDTO> portList = dictHandler.getPortList(null).getData();
@ -1243,6 +1246,10 @@ public class ExportLoadHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ -1287,7 +1294,7 @@ public class ExportLoadHandler implements BaseHandler {
@ApiOperation("外贸整船备件导入") @ApiOperation("外贸整船备件导入")
@PostMapping("/outside/spare/import-to-add") @PostMapping("/outside/spare/import-to-add")
public Result<List<JSONObject>> outsideSpareUpload(@RequestParam(required = false) String type, MultipartFile file) throws IOException { public Result<List<JSONObject>> outsideSpareUpload(@RequestParam(required = false) String type, MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<ExportLoadSpareExcel> dataList = new ArrayList<>(); List<ExportLoadSpareExcel> dataList = new ArrayList<>();
@ -1300,6 +1307,8 @@ public class ExportLoadHandler implements BaseHandler {
// 要保存的数据 // 要保存的数据
List<CustomerExportLoad> heads = new ArrayList<>(); List<CustomerExportLoad> heads = new ArrayList<>();
try {
// 港口基础数据 // 港口基础数据
List<DictDTO> portList = dictHandler.getPortList(null).getData(); List<DictDTO> portList = dictHandler.getPortList(null).getData();
@ -1425,6 +1434,10 @@ public class ExportLoadHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("导入删除") @ApiOperation("导入删除")
@ -1489,7 +1502,7 @@ public class ExportLoadHandler implements BaseHandler {
@ApiOperation("内贸整船车辆导入") @ApiOperation("内贸整船车辆导入")
@PostMapping("/inside/import-to-add") @PostMapping("/inside/import-to-add")
public Result<List<JSONObject>> insideUpload(@RequestParam(required = false) String type, MultipartFile file) throws IOException { public Result<List<JSONObject>> insideUpload(@RequestParam(required = false) String type, MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<ExportLoadInsideExcel> dataList = new ArrayList<>(); List<ExportLoadInsideExcel> dataList = new ArrayList<>();
@ -1503,6 +1516,8 @@ public class ExportLoadHandler implements BaseHandler {
Map<String, CustomerExportLoad> heads = new LinkedHashMap<>(); Map<String, CustomerExportLoad> heads = new LinkedHashMap<>();
Map<String, List<CustomerExportLoadCargo>> details = new HashMap<>(); Map<String, List<CustomerExportLoadCargo>> details = new HashMap<>();
try {
// 结算单位 // 结算单位
Map<String, String> companyMap = new HashMap<>(); Map<String, String> companyMap = new HashMap<>();
// List<CompanyDTO> companyList = pubApi.getCompanyList(Arrays.asList("7")); // List<CompanyDTO> companyList = pubApi.getCompanyList(Arrays.asList("7"));
@ -1812,6 +1827,10 @@ public class ExportLoadHandler implements BaseHandler {
} }
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
/* /*

View File

@ -36,6 +36,7 @@ import com.nuzar.rtops.log.dto.LogRecordDTO;
import com.nuzar.rtops.log.service.EsLogApprovalUtil; import com.nuzar.rtops.log.service.EsLogApprovalUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -61,6 +62,7 @@ import java.util.stream.Collectors;
@RequestMapping("/spz") @RequestMapping("/spz")
@Api(tags = "特保区") @Api(tags = "特保区")
@Validated @Validated
@Slf4j
public class FreeTradeHandler implements BaseHandler { public class FreeTradeHandler implements BaseHandler {
@Resource @Resource
@ -410,7 +412,7 @@ public class FreeTradeHandler implements BaseHandler {
@PostMapping("/import-to-add") @PostMapping("/import-to-add")
public Result<List<JSONObject>> upload( public Result<List<JSONObject>> upload(
@RequestParam(required = false, defaultValue = "0") String type, @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException { MultipartFile file) {
// 所有读取的数据 // 所有读取的数据
List<FreeTradeExcel> dataList = new ArrayList<>(); List<FreeTradeExcel> dataList = new ArrayList<>();
@ -420,6 +422,8 @@ public class FreeTradeHandler implements BaseHandler {
// 验证成功的数据 // 验证成功的数据
List<JSONObject> successDataList = new ArrayList<>(); List<JSONObject> successDataList = new ArrayList<>();
try {
EasyExcel.read(file.getInputStream(), FreeTradeExcel.class, new ReadExcelListener<FreeTradeExcel>() { EasyExcel.read(file.getInputStream(), FreeTradeExcel.class, new ReadExcelListener<FreeTradeExcel>() {
@Override @Override
protected void saveData(List<FreeTradeExcel> list) { // 保存数据 protected void saveData(List<FreeTradeExcel> list) { // 保存数据
@ -510,6 +514,10 @@ public class FreeTradeHandler implements BaseHandler {
customerFreeTradeService.saveBatch(save); customerFreeTradeService.saveBatch(save);
return ResultUtil.success(errorDataList); return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
} }
@ApiOperation("导入删除") @ApiOperation("导入删除")

View File

@ -847,7 +847,7 @@ public class CustomerServiceImpl implements CustomerService {
} }
} catch (Exception e) { } catch (Exception e) {
CustomerExportInSyncLog log = new CustomerExportInSyncLog(); CustomerExportInSyncLog log = new CustomerExportInSyncLog();
log.setBatchNo(StringUtils.joinWith(",", list.stream().map(p -> p.getBatchNo()).collect(Collectors.toList()))); log.setBatchNo(item.getBatchNo());
log.setRequestStr(JSONObject.toJSONString(req)); log.setRequestStr(JSONObject.toJSONString(req));
log.setResponseStr(e.getMessage()); log.setResponseStr(e.getMessage());
customerExportInSyncLogService.save(log); customerExportInSyncLogService.save(log);