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 4eb975d..50bcb99 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 @@ -83,7 +83,7 @@ public class ExportInVo implements Serializable { @ApiModelProperty(value = "港区", required = true) private String portArea; -// @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "货代ID不能为空") + @NotBlank(groups = {ValidationGroup.insert.class, ValidationGroup.update.class}, message = "货代ID不能为空") @ApiModelProperty(value = "货代ID", required = true) private String freightId; 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 ef9c0bf..406206d 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 @@ -11,14 +11,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.haitonggauto.rtosc.api.NuzarOpenApi; +import com.haitonggauto.rtosc.api.NuzarPubApi; import com.haitonggauto.rtosc.api.NuzarShpApi; -import com.haitonggauto.rtosc.api.dto.CheckVinReq; -import com.haitonggauto.rtosc.api.dto.CityDTO; -import com.haitonggauto.rtosc.api.dto.VinStatusRequest; -import com.haitonggauto.rtosc.api.dto.WorkStatusDTO; +import com.haitonggauto.rtosc.api.dto.*; import com.haitonggauto.rtosc.client.dto.PortEnDTO; import com.haitonggauto.rtosc.client.dto.VinValidDTO; import com.haitonggauto.rtosc.common.context.UserContext; @@ -102,6 +99,9 @@ public class ExportInHandler implements BaseHandler { @Resource private NuzarShpApi shpApi; + @Resource + private NuzarPubApi pubApi; + @ApiOperation("船名航次模糊匹配") @PostMapping("/shipVoyage") public Result> getExportInShipNameList( @@ -527,6 +527,17 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success("success"); } + @ApiOperation("取消提交审核") + @PostMapping("/submit-check/reverse") + public Result submitCheckReverse(@RequestBody + @NotNull(message = "请传入要审核的出口进场ID") + @Size(min = 1, message = "ID列表不能为空") List ids) { + customerExportInService.lambdaUpdate().set(CustomerExportIn::getCheckStatus, AuditEnum.SUBMIT) + .set(CustomerExportIn::getCheckResult, null) + .in(CustomerExportIn::getId, ids).update(); + return ResultUtil.success("success"); + } + @ApiOperation("取消/恢复车架号") @PostMapping("/recover/vin") @Transactional(rollbackFor = {Exception.class}) @@ -1801,6 +1812,8 @@ public class ExportInHandler implements BaseHandler { List energyTypeList = dictHandler.getEnergyTypeList().getData(); // 根据港口ID 获取国家 Map portCountryList = new HashMap<>(); + // 货代列表 + Map companyMap = new HashMap<>(); // 车型明细缓存 Map> carDetailTypeList = new HashMap<>(); @@ -1873,6 +1886,20 @@ public class ExportInHandler implements BaseHandler { errorDataList.add(o); return; } + if (!companyMap.containsKey(item.getFreight())) { + CompanyDTO company = pubApi.getCompanyByName(item.getFreight()); + if (company == null || StringUtils.isEmpty(company.getCueId())) { + companyMap.put(item.getFreight(), ""); + } else { + companyMap.put(item.getFreight(), StringUtils.trim(company.getCueId())); + } + } + if (StringUtils.isEmpty(companyMap.get(item.getFreight()))) { + JSONObject o = JSONObject.from(item); + o.put("status", "货代不存在"); + errorDataList.add(o); + return; + } // 航次必须是HT6、HTTC、HTLG中的一个,否则导入不成功,提示“航次错误 if (!StringUtils.equalsAnyIgnoreCase(item.getVoyage(), "HT6", "HTTC", "HTLG")) { JSONObject o = JSONObject.from(item); @@ -1964,6 +1991,7 @@ public class ExportInHandler implements BaseHandler { in.setCartTypeDetailId(carDetailTypeList.get(in.getCartType()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartTypeDetail())).findFirst().get().getId()); in.setOperateTypeId(operateTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getOperateType())).findFirst().get().getId()); in.setEnergyType(energyTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getEnergyTypeName())).findFirst().get().getId()); + in.setFreightId(companyMap.get(item.getFreight())); in.setApplicantId(UserContext.getUser().getUserId()); in.setTermcd(in.getPortAreaId()); @@ -2084,222 +2112,6 @@ public class ExportInHandler implements BaseHandler { }); }); - /* - EasyExcel.read(file.getInputStream(), ExportInPlanExcel.class, new ReadExcelListener() { - @Override - protected void saveData(List list) { // 保存数据 - ValidatorFactory vf = Validation.buildDefaultValidatorFactory(); - Validator validator = vf.getValidator(); - - List validData = new ArrayList<>(); - - // 需要保存的数据 - List saveData = new ArrayList<>(); - // 数据验证 - list.stream().forEach(item -> { - Set> set = validator.validate(item); - if (CollectionUtils.isEmpty(set)) { // 验证通过的 - validData.add(item); - } else { // 验证失败的 - JSONObject o = JSONObject.from(item); - o.put("status", set.stream().map(p -> p.getMessage()).collect(Collectors.joining(","))); - errorDataList.add(o); - } - }); - - if (CollectionUtils.isEmpty(validData)) { // 数据完整性检验 - return; - } - - // 港区、船名、港口、品牌、车型 - validData.stream().forEach(item -> { - 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 (shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "船名不存在"); - errorDataList.add(o); - return; - } - if (portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortArea())).count() == 0) { - 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", "品牌不存在"); - errorDataList.add(o); - return; - } - if (carTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartType())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "车型不存在"); - errorDataList.add(o); - return; - } - if (countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCiyCnname(), item.getOriginPlace())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "区域代码不存在"); - errorDataList.add(o); - return; - } - // 航次必须是HT6、HTTC、HTLG中的一个,否则导入不成功,提示“航次错误 - if (!StringUtils.equalsAnyIgnoreCase(item.getVoyage(), "HT6", "HTTC", "HTLG")) { - JSONObject o = JSONObject.from(item); - o.put("status", "航次错误"); - errorDataList.add(o); - return; - } - // 运输方式必须是“板车运输、商品车自开、驳船,否则导入不成功,提示“运输方式错误” - if (!StringUtils.equalsAnyIgnoreCase(item.getTransportWay(), "板车运输", "商品车自开", "驳船") || transportWayList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getTransportWay())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "运输方式错误"); - errorDataList.add(o); - return; - } - // 车型明细必须是车型关联的车型明细,否则导入不成功,提示“车型明细错误” - if (!carDetailTypeList.containsKey(item.getCartType())) { - List data = dictHandler.getCartTypeDetailList(carTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartType())).findFirst().get().getId(), null).getData(); - carDetailTypeList.put(item.getCartType(), data); - } - if (carDetailTypeList.get(item.getCartType()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartTypeDetail())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "车型明细错误"); - errorDataList.add(o); - return; - } - // 车型如果是车辆操作模式必须为“港机作业,客户自开”,如果是备件操作模式必须为“铲车、吊车、浮吊”,否则导入不成功,提示“操作模式错误” - if ((StringUtils.equals("车辆", item.getCartType()) && !StringUtils.equalsAny(item.getOperateType(), "港机作业", "自开")) || - (StringUtils.equals("备件", item.getCartType()) && !StringUtils.equalsAny(item.getOperateType(), "铲车", "吊车", "浮吊")) - || operateTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getOperateType())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "操作模式错误"); - errorDataList.add(o); - return; - } - if (energyTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getEnergyTypeName())).count() == 0) { - JSONObject o = JSONObject.from(item); - o.put("status", "源类型不存在"); - errorDataList.add(o); - return; - } - // 验证进场日期是否正确 - Date d = DateUtils.parseDate(StringUtils.trim(item.getEnterTime()), "yyyy/MM/dd"); - - if (d == null) { - JSONObject o = JSONObject.from(item); - o.put("status", "日期格式不正确yyyy/MM/dd"); - errorDataList.add(o); - return; - } - - saveData.add(item); - JSONObject o = JSONObject.from(item); - o.put("status", "导入成功"); - errorDataList.add(o); - }); - - - if (CollectionUtils.isNotEmpty(saveData)) { // 保存新记录 - List collect = saveData.stream().map(item -> { - CustomerExportIn in = PoMapper.instance.excel2Entity(item); - String batchNo = customerService.getSequenceNo("export_in_batch_no", "出口进场", "EI"); - in.setBatchNo(batchNo); - in.setApplyTime(new Date()); - in.setPortId(portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortName())).findFirst().get().getId()); - // 处理国家 - if (!portCountryList.containsKey(in.getPortId())) { - DictDTO dto = dictHandler.getCountryByPortName(in.getPortId()).getData(); - portCountryList.put(in.getPortId(), dto); - } - if (portCountryList.containsKey(in.getPortId())) { - in.setCountryId(portCountryList.get(in.getPortId()).getId()); - in.setCountry(portCountryList.get(in.getPortId()).getText()); - } - - in.setBeginEnterTime(DateUtils.parseDate(StringUtils.trim(item.getEnterTime()), "yyyy/MM/dd")); - in.setEndEnterTime(in.getBeginEnterTime()); - - in.setShipId(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).findFirst().get().getId()); - in.setShipEnName(shipList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getShipName())).findFirst().get().getExtra1()); - in.setPortAreaId(portAreaList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortArea())).findFirst().get().getId()); - in.setBrandId(brandList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getBrand())).findFirst().get().getId()); - in.setCartTypeId(carTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartType())).findFirst().get().getId()); - in.setVoyageId(in.getVoyage()); - in.setOriginPlaceId(countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCiyCnname(), item.getOriginPlace())).findFirst().get().getCiyId()); - in.setTransportWayId(transportWayList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getTransportWay())).findFirst().get().getId()); - in.setCartTypeDetailId(carDetailTypeList.get(in.getCartType()).stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getCartTypeDetail())).findFirst().get().getId()); - in.setOperateTypeId(operateTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getOperateType())).findFirst().get().getId()); - in.setEnergyType(energyTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getEnergyTypeName())).findFirst().get().getId()); - in.setApplicantId(UserContext.getUser().getUserId()); - in.setTermcd(in.getPortAreaId()); - - if (StringUtils.equals("1", type)) { - in.setCheckStatus(AuditEnum.AUDIT); - } else { - in.setCheckStatus(AuditEnum.SUBMIT); - } - return in; - }).collect(Collectors.toList()); - - // 如果是备件自动生成条码 - // 过滤出是备件的 - collect.stream().filter(item -> StringUtils.equals(item.getCartType(), "备件")).forEach(item -> { - // 出口进场计划备件条码生成的规则要变一下,BJ+年月日时分+5随机数,一共要17位 - String prefix = StringUtils.join("BJ", DateUtil.format(new Date(), "yyMMddHHmm")); - List vins = new ArrayList<>(item.getQuantity()); - do { - String vin = prefix + RandomUtil.randomNumbers(5); - if (!vins.contains(vin)) { - vins.add(vin); - } - } while (vins.size() < item.getQuantity()); - List spares = vins.stream().map(p -> { - CustomerExportInCargo entity = new CustomerExportInCargo(); - entity.setCargoType(1); - entity.setVinStatus(1); - entity.setVin(p); - entity.setTermcd(item.getPortAreaId()); - return entity; - }).collect(Collectors.toList()); - - List times = new ArrayList<>(); - CustomerExportInTimes time = new CustomerExportInTimes(); - time.setEnterQuantity(item.getQuantity()); - time.setEnterTime(item.getBeginEnterTime()); - times.add(time); - - customerService.saveExportIn(item, null, times, spares); - - }); - - collect.stream().filter(item -> !StringUtils.equals(item.getCartType(), "备件")).forEach(item -> { - List times = new ArrayList<>(); - CustomerExportInTimes time = new CustomerExportInTimes(); - time.setEnterQuantity(item.getQuantity()); - time.setEnterTime(item.getBeginEnterTime()); - times.add(time); - - customerService.saveExportIn(item, null, times, null); - }); - -// List carts = collect.stream().filter(item -> !StringUtils.equals(item.getCartType(), "备件")).collect(Collectors.toList()); -// -// if (CollectionUtils.isNotEmpty(carts)) { -// customerExportInService.saveBatch(carts); -// } - } - } - }).sheet().doRead(); - - */ - return ResultUtil.success(errorDataList); } 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 a76d1fe..2129304 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 @@ -566,10 +566,11 @@ public class ExportLoadHandler implements BaseHandler { } } + /* if (CollectionUtils.isNotEmpty(page.getRecords()) && StringUtils.equalsIgnoreCase("N", exportLoad.getTradType())) { // 未进港、已收车、装船完成、取消装船、退运、提货 page.setRecords(page.getRecords().stream().filter(item -> StringUtils.equalsAny(item.getWorkStatus(), "未进港", "已收车", "装船完成", "取消装船", "退运", "提货")).collect(Collectors.toList())); - } + }*/ return ResultUtil.success(page); } @@ -1425,8 +1426,10 @@ public class ExportLoadHandler implements BaseHandler { exportLoad.setPortArea(item.getValue().get(0).getPortArea()); exportLoad.setContact(item.getValue().get(0).getContact()); exportLoad.setContactPhone(item.getValue().get(0).getContactPhone()); - exportLoad.setDestPort(item.getValue().get(0).getDestPort()); - exportLoad.setDestPortId(portList.stream().filter(s -> StringUtils.equals(s.getText(), item.getValue().get(0).getDestPort())).findFirst().get().getId()); + if (StringUtils.isNotEmpty(item.getValue().get(0).getDestPort())) { // 内贸目的港可以为空 + exportLoad.setDestPort(item.getValue().get(0).getDestPort()); + exportLoad.setDestPortId(portList.stream().filter(s -> StringUtils.equals(s.getText(), item.getValue().get(0).getDestPort())).findFirst().get().getId()); + } if (StringUtils.equals("1", type)) { exportLoad.setCheckStatus(AuditEnum.AUDIT); } else {