diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java index e6ca4cc..b14f11f 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ExportInspectCargoVo.java @@ -53,7 +53,7 @@ public class ExportInspectCargoVo implements Serializable { * 区域( 从基础数据获取区道位信息) */ @ApiModelProperty(value = "区域", required = true) - @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "区域不能为空") +// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "区域不能为空") private String area; /** diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarOpenApi.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarOpenApi.java index 8b6e283..1ef9219 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarOpenApi.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarOpenApi.java @@ -126,6 +126,9 @@ public interface NuzarOpenApi { @PostMapping("/customer/shipment/shipLoad/transitPart") Map> getTransitPart(@RequestBody TransitPartRequest request); + @PostMapping("/customer/shipment/shipLoad/transitVinCode") + List getTransitGoods(@RequestBody TransitRequest req); + // 根据ID获取国家 @PostMapping("/miniapp/country/queryByIds") List getCountryByIds(@RequestBody List req); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitPartResp.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitPartResp.java index f19b719..a34b774 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitPartResp.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitPartResp.java @@ -13,4 +13,6 @@ public class TransitPartResp implements Serializable { private String workStatus; private String vinCode; + + private String model; } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitRequest.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitRequest.java new file mode 100644 index 0000000..2918551 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/TransitRequest.java @@ -0,0 +1,18 @@ +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; + +@Data +@ApiModel("国际中转货物") +public class TransitRequest implements Serializable { + @ApiModelProperty("提单号") + private List mnfBls; + + @ApiModelProperty("航次ID") + private List vvyIds; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java index ab4466e..fe955af 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DepartureHandler.java @@ -1288,8 +1288,6 @@ public class DepartureHandler implements BaseHandler { req.setVvyId(form.getVoyageId()); req.setVinCodeList(strings); List resp = openApi.vinCheckInfo(req); - System.err.println(JSON.toJSONString(req)); - System.err.println(JSON.toJSONString(resp)); List checkResps = resp.stream().filter(s -> !s.getHasShutoutScan()).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(checkResps)) { 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 bb14d27..f6e4047 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 @@ -1289,23 +1289,17 @@ public class ExportInHandler implements BaseHandler { public Result delete(@RequestBody @NotNull(message = "请传入要删除的出口进场ID") @Size(min = 1, message = "请传入要删除的出口进场ID") List ids) { - for (Long id : ids) { - // 货物已开始作业,也不能删除 - List list = customerExportInCargoService.lambdaQuery().eq(CustomerExportInCargo::getExportInId, id).isNotNull(CustomerExportInCargo::getWorkStatus).list(); - if (CollectionUtils.isNotEmpty(list)) { - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "货物已开始作业,也不能删除"); - } - // 待提交,已驳回的可以删除 - CustomerExportIn exportIn = customerExportInService.getById(id); - if (exportIn == null) { - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "要删除的ID不存在"); - } - if (exportIn.getCheckStatus() == AuditEnum.SUBMIT || exportIn.getCheckStatus() == AuditEnum.AUDIT_REJECT || exportIn.getCheckStatus() == AuditEnum.AUDIT) { - customerService.delExportIn(id); - } else { - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "已审核通过的不可删除"); - } + // 货物已开始作业,也不能删除 + Long w = customerExportInCargoService.lambdaQuery() + .in(CustomerExportInCargo::getExportInId, ids).isNotNull(CustomerExportInCargo::getWorkStatus).count(); + if (w > 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "货物已开始作业,不能删除"); } + Long a = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, ids).eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_PASS).count(); + if (a > 0) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "已审核通过的不可删除"); + } + customerService.delExportInBatch(ids); return ResultUtil.success("success"); } @@ -4095,7 +4089,7 @@ public class ExportInHandler implements BaseHandler { in.setTermcd(in.getPortAreaId()); in.setVolume(in.getLength().multiply(in.getWidth()).multiply(in.getHeight()).setScale(4, RoundingMode.HALF_UP)); // 计算体积 in.setNatureFlag(goodsNature.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getPtrDesc(), item.getNatureFlagName())).findFirst().get().getPtrCode()); - if (!StringUtils.equals(item.getNatureFlagName(), "正常")) { + if (StringUtils.equalsAny(in.getNatureFlagName(), "内进转外出", "外进转内出", "国际中转", "国内中转")) { in.setTransferShipId(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getTransferShipName())).findFirst().get().getId()); in.setTransferVoyageId(voyageMap.get(in.getTransferShipName()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getVvyName(), item.getTransferVoyage())).findFirst().get().getVvyId()); } @@ -4115,6 +4109,7 @@ public class ExportInHandler implements BaseHandler { Map> inMap = collect.stream() .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipId(), item.getVoyageId(), item.getBillNum()), Collectors.toList())); + String tip = null; inMap.entrySet().forEach(item -> { String[] keys = StringUtils.split(item.getKey(), "#$#"); @@ -4189,79 +4184,149 @@ public class ExportInHandler implements BaseHandler { }); if (CollectionUtils.isNotEmpty(errorDataList)) { -// errorDataList.addAll(successDataList); return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", errorDataList); } inMap.entrySet().forEach(item -> { - String[] keys = StringUtils.split(item.getKey(), "#$#"); - String shipId = keys[0]; // 船名 - String voyageId = keys[1]; // 航次 - String billNo = keys[2]; // 提单号 - - // 查询出已存在的数据 - LambdaQueryWrapper cQuery = new LambdaQueryWrapper<>(); - cQuery.eq(CustomerExportIn::getShipId, shipId); - cQuery.eq(CustomerExportIn::getVoyageId, voyageId); - cQuery.eq(CustomerExportIn::getBillNum, billNo); - - List exportInList = customerExportInService.list(cQuery); - // 单票件件,毛,体 CustomerExportIn lastE = item.getValue().get(item.getValue().size() - 1); // 以最后一个为标准 - // 如果是备件自动生成条码 - // 过滤出是备件 - item.getValue().stream().filter(ss -> StringUtils.equals(ss.getCartType(), "备件")).forEach(ss -> { - // 判断是否是国际中转航次ID - String vvyId = ss.getVoyageId(); - TransitPartRequest request = new TransitPartRequest(); - request.setVvyIds(Arrays.asList(vvyId)); - request.setPartAmount(ss.getQuantity()); - request.setMnfBl(ss.getBillNum()); - // Map> rst = openApi.getTransitPart(request); - - List vins = new ArrayList<>(); - if (StringUtils.equals(ss.getNatureFlagName(), "正常")) { // 需要自动生成 - // vins.addAll(rst.get(vvyId).stream().map(t -> t.getVinCode()).collect(Collectors.toList())); - // 出口进场计划备件条码生成的规则要变一下,BJ+年月日时分+5随机数,一共要17位 - vins = genBjNo(ss.getQuantity(), null); + // 判断是否为国际中转 + if (StringUtils.equals("国际中转", lastE.getNatureFlagName())) { + TransitRequest req = new TransitRequest(); + req.setMnfBls(Arrays.asList(lastE.getBillNum())); + req.setVvyIds(Arrays.asList(lastE.getTransferVoyageId())); + List goods = openApi.getTransitGoods(req); + boolean bflag = false; + if (CollectionUtils.isEmpty(goods)) { + JSONObject o = new JSONObject(); + o.put("billNum", lastE.getBillNum()); + o.put("status", "不存在该提单的卸船清单"); + errorDataList.add(o); + } else { + int sum = item.getValue().stream().mapToInt(s -> s.getQuantity()).sum(); // 进场的数量 + if (sum != goods.size()) { + JSONObject o = new JSONObject(); + o.put("billNum", lastE.getBillNum()); + o.put("status", "卸船清单中数量与进港计划中数量不匹配"); + errorDataList.add(o); + } else { + bflag = true; + } } - List spares = vins.stream().map(p -> { - CustomerExportInCargo entity = new CustomerExportInCargo(); - entity.setCargoType(1); - entity.setVinStatus(1); - entity.setVin(p); - entity.setTermcd(ss.getPortAreaId()); - return entity; - }).collect(Collectors.toList()); + // 如果数量匹配 + if (bflag) { + // 车辆 + List cars = goods.stream().filter(s -> !StringUtils.startsWithIgnoreCase(s.getVinCode(), "BJ")).collect(Collectors.toList()); + List spares = goods.stream().filter(s -> StringUtils.startsWithIgnoreCase(s.getVinCode(), "BJ")).collect(Collectors.toList()); - List times = new ArrayList<>(); - CustomerExportInTimes time = new CustomerExportInTimes(); - time.setEnterQuantity(ss.getQuantity()); - time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate()); - times.add(time); + for (CustomerExportIn ss : item.getValue()) { + List times = new ArrayList<>(); + CustomerExportInTimes time = new CustomerExportInTimes(); + time.setEnterQuantity(ss.getQuantity()); + time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate()); + times.add(time); + ss.setEachVolume(lastE.getEachVolume()); + ss.setEachQuantity(lastE.getEachQuantity()); + ss.setEachWeight(lastE.getEachWeight()); - ss.setEachVolume(lastE.getEachVolume()); - ss.setEachQuantity(lastE.getEachQuantity()); - ss.setEachWeight(lastE.getEachWeight()); + // 按型号优先匹配 + if (StringUtils.equals(ss.getCartType(), "备件")) { + List sList = new ArrayList<>(); + for (int k = 0; k < ss.getQuantity(); k++) { + CustomerExportInCargo entity = new CustomerExportInCargo(); + entity.setCargoType(1); + entity.setVinStatus(1); + Optional first = spares.stream().filter(t -> StringUtils.equals(t.getModel(), ss.getModels())).findFirst(); + if (!first.isPresent()) { + first = spares.stream().findFirst(); + } + TransitPartResp resp = first.get(); + entity.setVin(resp.getVinCode()); + spares.remove(resp); + entity.setTermcd(ss.getPortAreaId()); + sList.add(entity); + } + customerService.saveExportIn(ss, null, times, sList); + } else { // 车辆 + List sList = new ArrayList<>(); + for (int k = 0; k < ss.getQuantity(); k++) { + CustomerExportInCargo entity = new CustomerExportInCargo(); + entity.setCargoType(0); + entity.setVinStatus(1); + Optional first = cars.stream().filter(t -> StringUtils.equals(t.getModel(), ss.getModels())).findFirst(); + if (!first.isPresent()) { + first = cars.stream().findFirst(); + } + TransitPartResp resp = first.get(); + entity.setVin(resp.getVinCode()); + cars.remove(resp); + entity.setTermcd(ss.getPortAreaId()); + sList.add(entity); + } + customerService.saveExportIn(ss, sList, times, null); + } + } + } else { + item.getValue().stream().forEach(ss -> { + List times = new ArrayList<>(); + CustomerExportInTimes time = new CustomerExportInTimes(); + time.setEnterQuantity(ss.getQuantity()); + time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate()); + times.add(time); - customerService.saveExportIn(ss, null, times, spares); + ss.setEachVolume(lastE.getEachVolume()); + ss.setEachQuantity(lastE.getEachQuantity()); + ss.setEachWeight(lastE.getEachWeight()); - }); + customerService.saveExportIn(ss, null, times, null); + }); + } + } else { + // 如果是备件自动生成条码 + // 过滤出是备件 + item.getValue().stream().filter(ss -> StringUtils.equals(ss.getCartType(), "备件")).forEach(ss -> { + List vins = new ArrayList<>(); + if (StringUtils.equals(ss.getNatureFlagName(), "正常")) { // 需要自动生成 + // 出口进场计划备件条码生成的规则要变一下,BJ+年月日时分+5随机数,一共要17位 + vins = genBjNo(ss.getQuantity(), null); + } + List spares = vins.stream().map(p -> { + CustomerExportInCargo entity = new CustomerExportInCargo(); + entity.setCargoType(1); + entity.setVinStatus(1); + entity.setVin(p); + entity.setTermcd(ss.getPortAreaId()); + return entity; + }).collect(Collectors.toList()); - item.getValue().stream().filter(ss -> !StringUtils.equals(ss.getCartType(), "备件")).forEach(ss -> { - List times = new ArrayList<>(); - CustomerExportInTimes time = new CustomerExportInTimes(); - time.setEnterQuantity(ss.getQuantity()); - time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate()); - times.add(time); + List times = new ArrayList<>(); + CustomerExportInTimes time = new CustomerExportInTimes(); + time.setEnterQuantity(ss.getQuantity()); + time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate()); + times.add(time); - ss.setEachVolume(lastE.getEachVolume()); - ss.setEachQuantity(lastE.getEachQuantity()); - ss.setEachWeight(lastE.getEachWeight()); + ss.setEachVolume(lastE.getEachVolume()); + ss.setEachQuantity(lastE.getEachQuantity()); + ss.setEachWeight(lastE.getEachWeight()); - customerService.saveExportIn(ss, null, times, null); - }); + customerService.saveExportIn(ss, null, times, spares); + + }); + + item.getValue().stream().filter(ss -> !StringUtils.equals(ss.getCartType(), "备件")).forEach(ss -> { + List times = new ArrayList<>(); + CustomerExportInTimes time = new CustomerExportInTimes(); + time.setEnterQuantity(ss.getQuantity()); + time.setEnterTime(ss.getTmpEnterDate() == null ? ss.getBeginEnterTime() : ss.getTmpEnterDate()); + times.add(time); + + ss.setEachVolume(lastE.getEachVolume()); + ss.setEachQuantity(lastE.getEachQuantity()); + ss.setEachWeight(lastE.getEachWeight()); + + customerService.saveExportIn(ss, null, times, null); + }); + } }); } catch (ExcelDataConvertException e) { return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:" + e.getRowIndex() + " 列:" + e.getColumnIndex()); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java index f271be8..bbb7341 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportLoadHandler.java @@ -544,9 +544,7 @@ public class ExportLoadHandler implements BaseHandler { if (count > 0) { return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "只能删除待审核,待提交,已驳回的数据"); } - for (Long id : ids) { - customerService.delExportLoad(id); - } + customerService.delExportLoadBatch(ids); return ResultUtil.success("success"); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java index c55519a..9ac26b8 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ImportInspectHandler.java @@ -1088,8 +1088,10 @@ public class ImportInspectHandler implements BaseHandler { if (StringUtils.isNotEmpty(head.getVoyage())) { head.setVoyageId(in.getVvyId()); } -// head.setApplyObjId(in.getFreightId()); -// head.setApplyObj(in.getFreight()); + if (StringUtils.equals("0", type)) { + head.setApplyObjId(userBindFreight.get(0).getCueId()); + head.setApplyObj(userBindFreight.get(0).getCueCnname()); + } if (StringUtils.isEmpty(head.getCompany())) { head.setCompany(head.getApplyObj()); } @@ -1144,7 +1146,9 @@ public class ImportInspectHandler implements BaseHandler { return o; }).collect(Collectors.toList())); } catch (ExcelDataConvertException e) { - return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex()); + JSONObject obj = new JSONObject(); + obj.put("status", "导入数据错误,请确认导入数据模板是否正确, 行:"+e.getRowIndex()+" 列:" + e.getColumnIndex()); + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "导入失败", Arrays.asList(obj)); } catch (Exception e) { log.error("上传错误", e); return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), e.getMessage()); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java index 64dde4a..aac5615 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/CustomerService.java @@ -35,6 +35,12 @@ public interface CustomerService { */ void delExportIn(Long id); + /** + * 批量删除 + * @param id + */ + void delExportInBatch(List id); + /** * 修改 * @param exportIn @@ -57,6 +63,8 @@ public interface CustomerService { */ void delExportLoad(Long id); + void delExportLoadBatch(List ids); + /** * 修改出口装船 * @param imp // 是否是导入, 导入的时候不处理删除 diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java index 307cd1b..17a663d 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/service/impl/CustomerServiceImpl.java @@ -254,6 +254,23 @@ public class CustomerServiceImpl implements CustomerService { exportInService.removeById(id); } + @Override + @Transactional(rollbackFor = {Exception.class}) + public void delExportInBatch(List ids) { + // 删除时间表 + { + exportInTimesService.lambdaUpdate().in(CustomerExportInTimes::getExportInId, ids).remove(); + } + + // 删除货物表 + { + exportInCargoService.lambdaUpdate().in(CustomerExportInCargo::getExportInId, ids).remove(); + } + + // 删除表头 + exportInService.lambdaUpdate().in(CustomerExportIn::getId, ids).remove(); + } + @Override @Transactional(rollbackFor = {Exception.class}) public void updateExportIn(Boolean imp, CustomerExportIn exportIn, List cargos, List times, List spares) { @@ -382,6 +399,18 @@ public class CustomerServiceImpl implements CustomerService { exportLoadService.removeById(id); } + @Override + @Transactional(rollbackFor = {Exception.class}) + public void delExportLoadBatch(List ids) { + // 删除货物表 + { + exportLoadCargoService.lambdaUpdate().in(CustomerExportLoadCargo::getExportLoadId, ids).remove(); + } + + // 删除表头 + exportLoadService.lambdaUpdate().in(CustomerExportLoad::getId, ids).remove(); + } + @Override @Transactional(rollbackFor = {Exception.class}) public void updateExportLoad(Boolean imp, CustomerExportLoad exportLoad, List cargos) {