同步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.io.IOUtils;
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.springframework.core.io.ClassPathResource;
import org.springframework.transaction.annotation.Transactional;
@ -80,6 +76,7 @@ import java.util.stream.Collectors;
@RequestMapping("/ee")
@Api(tags = "出口进场")
@Validated
@Slf4j
public class ExportInHandler implements BaseHandler {
@Resource
@ -342,6 +339,7 @@ public class ExportInHandler implements BaseHandler {
if (CollectionUtils.isNotEmpty(page.getRecords())) {
QueryWrapper<CustomerExportIn> q = new QueryWrapper<>();
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.groupBy("port_area_id, ship_id, voyage_id");
@ -1629,7 +1627,7 @@ public class ExportInHandler implements BaseHandler {
@ApiOperation("车架号导入(数组形式)")
@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<>();
// 数量不一致
@ -1642,6 +1640,8 @@ public class ExportInHandler implements BaseHandler {
List<ExportVinExcel> validData = vinList.getData();
// 对不完整的数据进行筛选
try {
// 不能有重复的车架号
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());
@ -1756,6 +1756,11 @@ public class ExportInHandler implements BaseHandler {
}
return ResultUtil.success(rst);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
}
@ApiOperation("车架号导入模板下载")
@ -1799,7 +1804,8 @@ public class ExportInHandler implements BaseHandler {
@ApiOperation("车架号导入(文件形式)")
@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);
List<Long> havePlans = openApi.haveShipPlan(exportIn.getVoyageId());
@ -1958,6 +1964,10 @@ public class ExportInHandler implements BaseHandler {
}
return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage());
}
}
@ApiOperation("备件号导入模板下载")
@ -2001,7 +2011,8 @@ public class ExportInHandler implements BaseHandler {
@ApiOperation("备件号导入")
@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);
List<Long> havePlans = openApi.haveShipPlan(exportIn.getVoyageId());
@ -2144,6 +2155,10 @@ public class ExportInHandler implements BaseHandler {
}
return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
}
@ApiOperation("整船清单导入模板下载")
@ -2189,7 +2204,7 @@ public class ExportInHandler implements BaseHandler {
@PostMapping("/import-to-add")
public Result<List<JSONObject>> upload(
@ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException {
MultipartFile file) {
// 所有读取的数据
List<ExportInExcel> dataList = new ArrayList<>();
@ -2202,6 +2217,8 @@ public class ExportInHandler implements BaseHandler {
// 需要清空的
List<Long> ids = new ArrayList<>();
try {
// 要保存到数据库的数据
List<CustomerExportInCargo> saveCargos = new ArrayList<>();
@ -2340,7 +2357,7 @@ public class ExportInHandler implements BaseHandler {
List<CustomerExportInCargo> cargos = new ArrayList<>();
for (CustomerExportIn e : exportInList) {
int n = e.getQuantity();
for (int i= 0; i < n; i++) {
for (int i = 0; i < n; i++) {
CustomerExportInCargo cargo = new CustomerExportInCargo();
cargo.setBrandId(e.getBrandId());
cargo.setBrand(e.getBrand());
@ -2434,6 +2451,10 @@ public class ExportInHandler implements BaseHandler {
}
return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
}
@ApiOperation("整票备件号导入模板下载")
@ -2479,7 +2500,7 @@ public class ExportInHandler implements BaseHandler {
@PostMapping("/import-to-add/spare")
public Result<List<JSONObject>> uploadSpare(
@ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException {
MultipartFile file) {
// 所有读取的数据
List<ExportInBillSpareExcel> dataList = new ArrayList<>();
@ -2495,6 +2516,8 @@ public class ExportInHandler implements BaseHandler {
// 要保存到数据库的数据
List<CustomerExportInCargo> saveCargos = new ArrayList<>();
try {
EasyExcel.read(file.getInputStream(), ExportLoadExcel.class, new ReadExcelListener<ExportInBillSpareExcel>() {
@Override
protected void saveData(List<ExportInBillSpareExcel> list) { // 保存数据
@ -2695,6 +2718,10 @@ public class ExportInHandler implements BaseHandler {
}
return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
}
@ApiOperation("导入删除")
@ -3102,7 +3129,7 @@ public class ExportInHandler implements BaseHandler {
@PostMapping("/exportIn/plan/import-to-add")
public Result<List<JSONObject>> exportInPlanUpload(
@ApiParam(name = "操作方式, 0为前端1为审核端") @RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException {
MultipartFile file) {
// 所有读取的数据
List<ExportInPlanExcel> dataList = new ArrayList<>();
@ -3112,8 +3139,11 @@ public class ExportInHandler implements BaseHandler {
// 验证通过的数据
List<JSONObject> successDataList = new ArrayList<>();
try {
// 获取用户绑定的货代
List<FreightVo> userBindFreight = openApi.getUserBindFreight();;
List<FreightVo> userBindFreight = openApi.getUserBindFreight();
;
// 国家数据
List<CityDTO> countryList = openApi.getCountryList();
@ -3138,7 +3168,7 @@ public class ExportInHandler implements BaseHandler {
// 新能源类型
List<DictDTO> energyTypeList = dictHandler.getEnergyTypeList().getData();
// 根据港口ID 获取国家
// Map<String, DictDTO> portCountryList = new HashMap<>();
// Map<String, DictDTO> portCountryList = new HashMap<>();
// 货代列表
Map<String, String> companyMap = new HashMap<>();
// 货物性质
@ -3449,22 +3479,22 @@ public class ExportInHandler implements BaseHandler {
// 重量
double totalWeight = exportInList.stream().map(p -> p.getWeight().doubleValue()).mapToDouble(p -> p).sum() + item.getValue().stream().map(p -> p.getWeight().doubleValue()).mapToDouble(p -> p).sum();
if (new BigDecimal(totalWeight).compareTo(lastE.getEachWeight().divide(new BigDecimal(1000))) > 0) {
// errorDataList.addAll(item.getValue().stream().map(p -> {
// JSONObject o = JSONObject.from(p);
// o.put("status", "重量不得超过单票重量");
// return o;
// }).collect(Collectors.toList()));
// return;
// errorDataList.addAll(item.getValue().stream().map(p -> {
// JSONObject o = JSONObject.from(p);
// o.put("status", "重量不得超过单票重量");
// return o;
// }).collect(Collectors.toList()));
// return;
}
// 体积
double totalVolume = exportInList.stream().map(p -> p.getVolume().doubleValue()).mapToDouble(p -> p).sum() + item.getValue().stream().map(p -> p.getVolume().doubleValue()).mapToDouble(p -> p).sum();
if (new BigDecimal(totalVolume).compareTo(lastE.getEachVolume()) > 0) {
// errorDataList.addAll(item.getValue().stream().map(p -> {
// JSONObject o = JSONObject.from(p);
// o.put("status", "体积不得超过单票体积");
// return o;
// }).collect(Collectors.toList()));
// return;
// errorDataList.addAll(item.getValue().stream().map(p -> {
// JSONObject o = JSONObject.from(p);
// o.put("status", "体积不得超过单票体积");
// return o;
// }).collect(Collectors.toList()));
// return;
}
successDataList.addAll(item.getValue().stream().map(p -> {
@ -3504,11 +3534,11 @@ public class ExportInHandler implements BaseHandler {
request.setVvyIds(Arrays.asList(vvyId));
request.setPartAmount(ss.getQuantity());
request.setMnfBl(ss.getBillNum());
// Map<String, List<TransitPartResp>> rst = openApi.getTransitPart(request);
// Map<String, List<TransitPartResp>> rst = openApi.getTransitPart(request);
List<String> vins = new ArrayList<>();
if (StringUtils.equals(ss.getNatureFlagName(), "正常")) { // 需要自动生成
// vins.addAll(rst.get(vvyId).stream().map(t -> t.getVinCode()).collect(Collectors.toList()));
// vins.addAll(rst.get(vvyId).stream().map(t -> t.getVinCode()).collect(Collectors.toList()));
// 出口进场计划备件条码生成的规则要变一下BJ+年月日时分+5随机数一共要17位
String prefix = StringUtils.join("BJ", DateUtil.format(new Date(), "yyMMddHHmm"));
do {
@ -3555,6 +3585,10 @@ public class ExportInHandler implements BaseHandler {
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);
}

View File

@ -39,6 +39,7 @@ import com.nuzar.rtops.log.dto.LogRecordDTO;
import com.nuzar.rtops.log.service.EsLogApprovalUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
@ -66,6 +67,7 @@ import java.util.stream.Collectors;
@RequestMapping("/el")
@Api(tags = "出口装船")
@Validated
@Slf4j
public class ExportLoadHandler implements BaseHandler {
@Resource
@ -1025,7 +1027,7 @@ public class ExportLoadHandler implements BaseHandler {
@ApiOperation("外贸整船车辆导入")
@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<>();
@ -1041,6 +1043,7 @@ public class ExportLoadHandler implements BaseHandler {
// 要保存的明细
Map<String, List<CustomerExportLoadCargo>> details = new HashMap<>();
try {
// 港口基础数据
List<DictDTO> portList = dictHandler.getPortList(null).getData();
@ -1235,7 +1238,7 @@ public class ExportLoadHandler implements BaseHandler {
if (MapUtils.isNotEmpty(heads)) {
heads.entrySet().forEach(item -> {
CustomerExportLoad exportLoad= item.getValue();
CustomerExportLoad exportLoad = item.getValue();
String batchNo = customerService.getSequenceNo("export_load_batch_no", "出口装船", "EL");
exportLoad.setBatchNo(batchNo);
customerService.saveExportLoad(exportLoad, details.get(item.getKey()));
@ -1243,6 +1246,10 @@ public class ExportLoadHandler implements BaseHandler {
}
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("外贸整船备件导入")
@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<>();
@ -1300,6 +1307,8 @@ public class ExportLoadHandler implements BaseHandler {
// 要保存的数据
List<CustomerExportLoad> heads = new ArrayList<>();
try {
// 港口基础数据
List<DictDTO> portList = dictHandler.getPortList(null).getData();
@ -1335,7 +1344,7 @@ public class ExportLoadHandler implements BaseHandler {
}
// 首先按对船名般次提单进行分组
Map<String, List<ExportLoadSpareExcel>> collect = validData.stream().collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(),item.getDestPort()), Collectors.toList()));
Map<String, List<ExportLoadSpareExcel>> collect = validData.stream().collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipName(), item.getVoyage(), item.getBillNo(), item.getBrand(), item.getDestPort()), Collectors.toList()));
collect.entrySet().forEach(item -> {
String[] keys = StringUtils.split(item.getKey(), "#$#");
@ -1425,6 +1434,10 @@ public class ExportLoadHandler implements BaseHandler {
}
return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
}
@ApiOperation("导入删除")
@ -1489,7 +1502,7 @@ public class ExportLoadHandler implements BaseHandler {
@ApiOperation("内贸整船车辆导入")
@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<>();
@ -1503,6 +1516,8 @@ public class ExportLoadHandler implements BaseHandler {
Map<String, CustomerExportLoad> heads = new LinkedHashMap<>();
Map<String, List<CustomerExportLoadCargo>> details = new HashMap<>();
try {
// 结算单位
Map<String, String> companyMap = new HashMap<>();
// List<CompanyDTO> companyList = pubApi.getCompanyList(Arrays.asList("7"));
@ -1585,19 +1600,19 @@ public class ExportLoadHandler implements BaseHandler {
errorDataList.add(o);
return;
}
if (!voyageMap.containsKey(StringUtils.join(item.getShipName(),item.getVoyage()))) {
if (!voyageMap.containsKey(StringUtils.join(item.getShipName(), item.getVoyage()))) {
VoyageReq req = new VoyageReq();
req.setSpmName(item.getShipName());
req.setVvyName(item.getVoyage());
List<VoyageResp> resp = shpApi.queryVvyListByVvNameAndSpmName(Arrays.asList(req));
// VoyageDTO v = shpApi.getVoyageNameByVvyName(item.getVoyage());
if (CollectionUtils.isEmpty(resp)) {
voyageMap.put(StringUtils.join(item.getShipName(),item.getVoyage()), "");
voyageMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), "");
} else {
voyageMap.put(StringUtils.join(item.getShipName(),item.getVoyage()),StringUtils.trim(resp.get(0).getVvyId()));
voyageMap.put(StringUtils.join(item.getShipName(), item.getVoyage()), StringUtils.trim(resp.get(0).getVvyId()));
}
}
if (StringUtils.isEmpty(voyageMap.get(StringUtils.join(item.getShipName(),item.getVoyage())))) {
if (StringUtils.isEmpty(voyageMap.get(StringUtils.join(item.getShipName(), item.getVoyage())))) {
JSONObject o = JSONObject.from(item);
o.put("status", "航次不存在");
errorDataList.add(o);
@ -1758,7 +1773,7 @@ public class ExportLoadHandler implements BaseHandler {
exportLoad.setShipId(shipList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[0])).findFirst().get().getId());
exportLoad.setShipName(keys[0]);
exportLoad.setShipEnName(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), keys[0])).findFirst().get().getExtra1());
exportLoad.setVoyageId(voyageMap.get(StringUtils.join(keys[0],keys[1])));
exportLoad.setVoyageId(voyageMap.get(StringUtils.join(keys[0], keys[1])));
exportLoad.setVoyage(keys[1]);
exportLoad.setBillNo(keys[2]);
exportLoad.setBrandId(brandList.stream().filter(s -> StringUtils.equalsIgnoreCase(s.getText(), keys[3])).findFirst().get().getId());
@ -1812,6 +1827,10 @@ public class ExportLoadHandler implements BaseHandler {
}
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
@ -61,6 +62,7 @@ import java.util.stream.Collectors;
@RequestMapping("/spz")
@Api(tags = "特保区")
@Validated
@Slf4j
public class FreeTradeHandler implements BaseHandler {
@Resource
@ -410,7 +412,7 @@ public class FreeTradeHandler implements BaseHandler {
@PostMapping("/import-to-add")
public Result<List<JSONObject>> upload(
@RequestParam(required = false, defaultValue = "0") String type,
MultipartFile file) throws IOException {
MultipartFile file) {
// 所有读取的数据
List<FreeTradeExcel> dataList = new ArrayList<>();
@ -420,6 +422,8 @@ public class FreeTradeHandler implements BaseHandler {
// 验证成功的数据
List<JSONObject> successDataList = new ArrayList<>();
try {
EasyExcel.read(file.getInputStream(), FreeTradeExcel.class, new ReadExcelListener<FreeTradeExcel>() {
@Override
protected void saveData(List<FreeTradeExcel> list) { // 保存数据
@ -510,6 +514,10 @@ public class FreeTradeHandler implements BaseHandler {
customerFreeTradeService.saveBatch(save);
return ResultUtil.success(errorDataList);
} catch (Exception e) {
log.error("错误信息", e);
return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), e.getMessage());
}
}
@ApiOperation("导入删除")

View File

@ -847,7 +847,7 @@ public class CustomerServiceImpl implements CustomerService {
}
} catch (Exception e) {
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.setResponseStr(e.getMessage());
customerExportInSyncLogService.save(log);