diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ShipStatusVo.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ShipStatusVo.java new file mode 100644 index 0000000..f16be84 --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/dto/ShipStatusVo.java @@ -0,0 +1,23 @@ +package com.haitonggauto.rtosc.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +@ApiModel("船舶状态") +public class ShipStatusVo { + @ApiModelProperty("船ID") + @NotBlank(message = "船ID不能为空") + private String shipId; + + @ApiModelProperty("航次ID") + @NotBlank(message = "航次ID不能为空") + private String voyageId; + + @ApiModelProperty("0取消,1装船确认") + @NotBlank(message = "状态不能为空,0取消,1装船确认") + private String status; +} diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java index c428ee1..a0eb724 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInPlanExcel.java @@ -94,6 +94,13 @@ public class ExportInPlanExcel { @NotBlank(message = "联系方式不能为空") private String contactPhone; + /** + * 港口 + */ + @ExcelProperty("*国家") + @NotBlank(message = "国家不能为空") + private String country; + /** * 港口 */ @@ -259,10 +266,10 @@ public class ExportInPlanExcel { * 源类型 */ @ExcelProperty("*能源类型") - @NotBlank(message = "*能源类型不能为空") +// @NotBlank(message = "*能源类型不能为空") private String energyTypeName; @ExcelProperty("*是否二手车") - @NotBlank(message = "是否是二手车不能为空") +// @NotBlank(message = "是否是二手车不能为空") private String secondHand; } \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java index b864494..fd12d82 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/DepartureQuery.java @@ -8,6 +8,7 @@ import com.haitonggauto.rtosc.repository.enums.AuditEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; import java.util.List; @@ -42,11 +43,13 @@ public class DepartureQuery extends BaseQuery { private String batchNo; @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "开始申请时间") @DbQuery(field = "applyTime", symbol = SqlSymbol.GTE) private Date beginApplyTime; @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "结束申请时间") @DbQuery(field = "applyTime", symbol = SqlSymbol.LTE) private Date endApplyTime; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java index ecfdb2c..d8b4861 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/ExportInQuery.java @@ -8,6 +8,7 @@ import com.haitonggauto.rtosc.repository.enums.AuditEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; import java.util.List; @@ -34,11 +35,13 @@ public class ExportInQuery extends BaseQuery { private String portAreaId; @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "开始进场时间") @DbQuery(field = "applyTime", symbol = SqlSymbol.GTE) private Date beginEnterTime; @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "结束进场时间") @DbQuery(field = "applyTime", symbol = SqlSymbol.LTE) private Date endEnterTime; @@ -76,6 +79,9 @@ public class ExportInQuery extends BaseQuery { @ApiModelProperty(value = "港口ID") private String portId; + @ApiModelProperty(value = "货代ID") + private String freightId; + @ApiModelProperty(hidden = true) @DbQuery(field = "vin", symbol = SqlSymbol.IN) private List vins; diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/FreeTradeQuery.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/FreeTradeQuery.java index 414c4b0..fb7885f 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/FreeTradeQuery.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/query/FreeTradeQuery.java @@ -9,6 +9,7 @@ import com.haitonggauto.rtosc.repository.enums.AuditEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; import java.util.List; @@ -24,11 +25,13 @@ public class FreeTradeQuery extends BaseQuery { private String cargoCode; @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "开始时间") @DbQuery(field = "createDate", symbol = SqlSymbol.GT) private Date beginCreateDate; @JsonFormat(pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern = "yyyy-MM-dd") @ApiModelProperty(value = "结束时间") @DbQuery(field = "createDate", symbol = SqlSymbol.LTE) private Date endCreateDate; 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 2f1e2fa..5a1f3cc 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 @@ -18,6 +18,9 @@ import java.util.Map; @FeignClient(name = "rtos-openapi") public interface NuzarOpenApi { + @GetMapping("/miniapp/getDownCountry") + List getCountryList(); + // 根据港区ID获取国家 @GetMapping(value = "/miniapp/portAreaManage/getCountry") PortAreaCountryDTO getPortAreaCountry(@RequestParam("potId") String potId); @@ -133,4 +136,8 @@ public interface NuzarOpenApi { // 查询获物信息 @GetMapping("/miniapp/machineType/dict") List getMachineType(); + + // 获取绑定货代 + @GetMapping("/rtos/user/getFreightId") + List getUserBindFreight(); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java index 002383b..e73d77c 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarPubApi.java @@ -11,7 +11,6 @@ import java.util.List; @FeignClient(name = "basic-service") public interface NuzarPubApi { - //车辆操作模式 @GetMapping(value = "/typeRef/domain/OPPROC_MODE") List getOperateTypeList(); @@ -48,6 +47,9 @@ public interface NuzarPubApi { @GetMapping(value = "/city/queryOrigin") List getCountryList(@RequestParam("key") String key); + @GetMapping(value = "/city/queryOriginAll") + List getAllCountryList(@RequestParam("key") String key); + // 运输方式 @GetMapping(value = "/typeRef/domain/TRANSPORT_TYPE") List getTransportWayList(); diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java index 0424981..19b7001 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarShpApi.java @@ -29,4 +29,7 @@ public interface NuzarShpApi { @GetMapping("/vesselVoyages/queryByKey") List queryVoyageByKey(@RequestParam("ieType") String ieType, @RequestParam("key") String key, @RequestParam("pamId") String pamId, @RequestParam("spmId") String spmId , @RequestParam("tradeType") String tradeType); + + @PostMapping("/vesselVoyages/shipNameFilter") + List checkShipStatus(@RequestBody List req); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarYardApi.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarYardApi.java index 991f731..34dba83 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarYardApi.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/NuzarYardApi.java @@ -12,8 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam; import java.util.List; -@FeignClient(name = "https://rtops4.haitongauto.com/tos/yard") -//@FeignClient(name = "yard-service") +//@FeignClient(name = "https://rtops4.haitongauto.com/tos/yard") +@FeignClient(name = "yard-service") public interface NuzarYardApi { @PostMapping("/yardCustomsRelease/queryCustomNoByvvyIdAndMnf") diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/FreightVo.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/FreightVo.java new file mode 100644 index 0000000..e677026 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/FreightVo.java @@ -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; + +@ApiModel("货代信息") +@Data +public class FreightVo implements Serializable { + + @ApiModelProperty("客户简称") + private String cueAbbreviation; + + @ApiModelProperty("客户中文名称") + private String cueCnname; + + @ApiModelProperty("客户中文名称") + private String cueTypes; + + private String cueId; +} diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PortDTO.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PortDTO.java index cf0e4ec..cabf053 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PortDTO.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/api/dto/PortDTO.java @@ -14,4 +14,5 @@ public class PortDTO implements Serializable { private String potEnname; + private String potCtycd; } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DictHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DictHandler.java index 6d825d3..0ad36d7 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DictHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/DictHandler.java @@ -145,6 +145,7 @@ public class DictHandler implements BaseHandler { dto.setId(item.getPotId()); dto.setText(item.getPotCnname()); dto.setExtra1(item.getPotEnname()); + dto.setExtra2(item.getPotCtycd()); // 港口的国家ID return dto; }).collect(Collectors.toList()); } @@ -239,6 +240,21 @@ public class DictHandler implements BaseHandler { return ResultUtil.success(list); } + @ApiOperation("国家城市全量") + @PostMapping("/city/queryAllOrigin") + public Result> getAllCountryList(@RequestParam(required = false) String q) { + + List list = nuzarPubApi.getAllCountryList(q); + + if (CollectionUtils.isEmpty(list)) { + return ResultUtil.success(Collections.emptyList()); + } else { + + } + + return ResultUtil.success(list); + } + // 运输方式 @ApiOperation("运输方式") @PostMapping("/transportWay") 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 c880343..cbccafa 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 @@ -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.ExcelValidationUtils; import com.haitonggauto.rtosc.query.CargoQuery; import com.haitonggauto.rtosc.query.ExportInCheckQuery; import com.haitonggauto.rtosc.query.ExportInQuery; @@ -47,6 +48,10 @@ 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; @@ -390,6 +395,17 @@ public class ExportInHandler implements BaseHandler { customerService.wrapperEntity(list); if (CollectionUtils.isNotEmpty(list)) { + // 港口和国家的英文明称 + Map portMap = new HashMap<>(); + Map countryMap = new HashMap<>(); + List countryIds = list.stream().map(item -> item.getCountryId()).distinct().collect(Collectors.toList()); + List portIds = list.stream().map(item -> item.getPortId()).distinct().collect(Collectors.toList()); + + List portByIds = openApi.getPortByIds(portIds); + List countryByIds = openApi.getCountryByIds(countryIds); + portMap.putAll(portByIds.stream().collect(Collectors.toMap(item -> item.getPotId(), item -> item.getPotEnname()))); + countryMap.putAll(countryByIds.stream().collect(Collectors.toMap(item -> item.getCtyId(), item -> item.getCtyEnname()))); + List cargos = customerExportInCargoService.lambdaQuery() .in(CustomerExportInCargo::getExportInId, list.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); @@ -399,6 +415,33 @@ public class ExportInHandler implements BaseHandler { // 数据拼装 list.stream().forEach(item -> { List cs = collect.get(item.getId()); + + item.setPortEnName(portMap.get(item.getPortId())); + item.setCountryEnName(countryMap.get(item.getCountryId())); + + if (CollectionUtils.isNotEmpty(cs)) { + // 获取作业状态 + Map statCollect = null; + List vins = cs.stream().map(s -> s.getVin()).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(vins)) { + VinStatusRequest req = new VinStatusRequest(); + req.setBusinessType("IN_PORT"); + req.setImportExportType("E"); + req.setVinCodeList(vins); + if (!StringUtils.equalsAnyIgnoreCase(item.getVoyageId(), "HT6", "HTLG", "HTTC")) { + req.setVvyId(item.getVoyageId()); + } + List status = openApi.getVinStatus(req); + statCollect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); + } + + if (MapUtils.isNotEmpty(statCollect)) { + for (CustomerExportInCargo cargo : cs) { + cargo.setWorkStatus(statCollect.get(cargo.getVin())); + } + } + } + item.setVins(cs); }); } @@ -734,7 +777,7 @@ public class ExportInHandler implements BaseHandler { nQuery.select("sum(quantity) as quantity, sum(volume) as volume, sum(weight) as weight") .eq("bill_num", exportIn.getBillNum()) .eq("ship_id", exportIn.getShipId()) - .eq("voyage_id", exportIn.getVoyageId()); + .eq("voyage_id", exportIn.getVoyageId()).ne("check_status", AuditEnum.AUDIT_REJECT); Map map = customerExportInService.getMap(nQuery); if (MapUtils.isEmpty(map)) { map = new HashMap<>(); @@ -746,10 +789,10 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "数量不得超过单票件数"); } if (exportIn.getEachWeight().divide(new BigDecimal(1000)).compareTo(((BigDecimal) map.get("weight")).add(exportIn.getWeight())) < 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "重量不得超过单票重量"); +// return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "重量不得超过单票重量"); } if (exportIn.getEachVolume().compareTo(((BigDecimal) map.get("volume")).add(exportIn.getVolume()).multiply(new BigDecimal(exportIn.getQuantity()))) < 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "体积不得超过单票体积"); +// return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "体积不得超过单票体积"); } // 数量必须≤单票件数,否则不能跳转下一步,并提示“数量不得超过单票件数” 通过自定义验证组件实现 @@ -793,6 +836,16 @@ public class ExportInHandler implements BaseHandler { public Result submitCheck(@RequestBody @NotNull(message = "请传入要审核的出口进场ID") @Size(min = 1, message = "ID列表不能为空") List ids) { + List list = customerExportInCargoService.query() + .select("count(id) as num, export_in_id") + .in("export_in_id", ids) + .groupBy("export_in_id") + .having("count(id) > 0") + .list(); + if (list.size() != ids.size()) { + return ResultUtil.failure(ErrorType.PARAMS_ERROR.id(), "请补充车架号等信息后,再提交审核"); + } + // 有没有明细的不允许提交审核 customerExportInService.lambdaUpdate().set(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT) .set(CustomerExportIn::getCheckResult, null) .in(CustomerExportIn::getId, ids).update(); @@ -807,6 +860,7 @@ public class ExportInHandler implements BaseHandler { .eq(CustomerExportIn::getShipId, form.getShipId()) .eq(CustomerExportIn::getVoyageId, form.getVoyageId()) .eq(CustomerExportIn::getCheckStatus, AuditEnum.SUBMIT) + .exists("select id from customer_export_in_cargo where customer_export_in_cargo.export_in_id=customer_export_in.id") .eq(CustomerExportIn::getCreateBy, UserContext.getUser().getUserId()).update(); return ResultUtil.success("success"); } @@ -1064,7 +1118,7 @@ public class ExportInHandler implements BaseHandler { nQuery.select("sum(quantity) as quantity, sum(volume) as volume, sum(weight) as weight") .eq("ship_id", exportIn.getShipId()) .eq("voyage_id", exportIn.getVoyageId()) - .eq("bill_num", exportIn.getBillNum()).ne("id", exportIn.getId()); + .eq("bill_num", exportIn.getBillNum()).ne("check_status", AuditEnum.AUDIT_REJECT).ne("id", exportIn.getId()); Map vmap = customerExportInService.getMap(nQuery); if (MapUtils.isEmpty(vmap)) { vmap = new HashMap<>(); @@ -1076,10 +1130,10 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "数量不得超过单票件数"); } if (exportIn.getEachWeight().divide(new BigDecimal(1000)).compareTo(((BigDecimal) vmap.get("weight")).add(exportIn.getWeight())) < 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "重量不得超过单票重量"); +// return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "重量不得超过单票重量"); } if (exportIn.getEachVolume().compareTo(((BigDecimal) vmap.get("volume")).add(exportIn.getVolume().multiply(new BigDecimal(exportIn.getQuantity())))) < 0) { - return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "体积不得超过单票体积"); +// return ResultUtil.failure(ErrorType.PROGRAM_ERROR.id(), "体积不得超过单票体积"); } //* 异常情况有,必填项车架号,车架号必须17位,数据重复,如果重复进行覆盖更新 @@ -1216,10 +1270,6 @@ public class ExportInHandler implements BaseHandler { if (row) { List list = customerExportInService.lambdaQuery().in(CustomerExportIn::getId, check.getIds()).list(); - if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { - customerService.syncAddExportInToOld(list); - } - // 记录日志 for (CustomerExportIn exportIn : list) { LogRecordDTO log = new LogRecordDTO(); @@ -1231,6 +1281,10 @@ public class ExportInHandler implements BaseHandler { EsLogApprovalUtil.writeLog(log); } + if (check.getCheckStatus() == AuditEnum.AUDIT_PASS) { + customerService.syncAddExportInToOld(list); + } + return ResultUtil.success("success"); } @@ -2023,7 +2077,7 @@ public class ExportInHandler implements BaseHandler { cargo.setExportInId(exportIn.getId()); cargo.setBrand(exportIn.getBrand()); cargo.setBrandId(exportIn.getBrandId()); - cargo.setCargoType(0); + cargo.setCargoType(1); cargo.setVin(p.getVin()); cargo.setTermcd(exportIn.getPortAreaId()); cargo.setVinStatus(1); @@ -2213,6 +2267,8 @@ public class ExportInHandler implements BaseHandler { // }); // } + // 同一个型号可能存在多个进港计划 + List exportInList = customerExportInService.list(cQuery); if (CollectionUtils.isEmpty(exportInList)) { // 船名,航次等不存在 @@ -2224,12 +2280,15 @@ public class ExportInHandler implements BaseHandler { return; } + // 计划总数量 + int planQuantity = exportInList.stream().mapToInt(p -> p.getQuantity()).sum(); + // 找到和本次数量一致的 - Optional first = exportInList.stream().filter(p -> p.getQuantity() == item.getValue().size()).findFirst(); +// Optional first = exportInList.stream().filter(p -> p.getQuantity() == item.getValue().size()).findFirst(); - CustomerExportIn exportIn = first.isPresent() ? first.get() : null; + CustomerExportIn exportIn = exportInList.get(0); - if (exportIn == null) { + if (planQuantity != item.getValue().size()) { errorDataList.addAll(item.getValue().stream().map(p -> { JSONObject o = JSONObject.from(p); o.put("status", "数量不一致不允许导入"); @@ -2238,7 +2297,8 @@ public class ExportInHandler implements BaseHandler { return; } - ids.add(exportIn.getId()); + ids.addAll(exportInList.stream().map(p -> p.getId()).collect(Collectors.toList())); +// ids.add(exportIn.getId()); // 已生成装船计划,不能导入 List havePlans = openApi.haveShipPlan(exportIn.getVoyageId()); @@ -2263,26 +2323,44 @@ public class ExportInHandler implements BaseHandler { // return; // } - if (exportIn.getEnterQuantity() != item.getValue().size()) { - errorDataList.addAll(item.getValue().stream().map(p -> { - JSONObject o = JSONObject.from(p); - o.put("status", "车架号数量和实际货物数量不符合,无法导入"); - return o; - }).collect(Collectors.toList())); - return; +// if (exportIn.getEnterQuantity() != item.getValue().size()) { +// errorDataList.addAll(item.getValue().stream().map(p -> { +// JSONObject o = JSONObject.from(p); +// o.put("status", "车架号数量和实际货物数量不符合,无法导入"); +// return o; +// }).collect(Collectors.toList())); +// return; +// } + // 按计划中的件数进行VIN的分配 + int j = 0; + List cargos = new ArrayList<>(); + for (CustomerExportIn e : exportInList) { + int n = e.getQuantity(); + for (int i= 0; i < n; i++) { + CustomerExportInCargo cargo = new CustomerExportInCargo(); + cargo.setBrandId(e.getBrandId()); + cargo.setBrand(e.getBrand()); + cargo.setExportInId(e.getId()); + cargo.setCargoType(0); + cargo.setVin(item.getValue().get(j++).getVin()); + cargo.setTermcd(e.getPortAreaId()); + cargo.setVinStatus(1); + + cargos.add(cargo); + } } - List cargos = item.getValue().stream().map(p -> { - CustomerExportInCargo cargo = new CustomerExportInCargo(); - cargo.setBrandId(exportIn.getBrandId()); - cargo.setBrand(exportIn.getBrand()); - cargo.setExportInId(exportIn.getId()); - cargo.setCargoType(0); - cargo.setVin(p.getVin()); - cargo.setTermcd(exportIn.getPortAreaId()); - cargo.setVinStatus(1); - return cargo; - }).collect(Collectors.toList()); +// List cargos = item.getValue().stream().map(p -> { +// CustomerExportInCargo cargo = new CustomerExportInCargo(); +// cargo.setBrandId(exportIn.getBrandId()); +// cargo.setBrand(exportIn.getBrand()); +// cargo.setExportInId(exportIn.getId()); +// cargo.setCargoType(0); +// cargo.setVin(p.getVin()); +// cargo.setTermcd(exportIn.getPortAreaId()); +// cargo.setVinStatus(1); +// return cargo; +// }).collect(Collectors.toList()); List vins = cargos.stream().map(p -> p.getVin()).collect(Collectors.toList()); @@ -2866,37 +2944,127 @@ public class ExportInHandler implements BaseHandler { XSSFWorkbook workbook = new XSSFWorkbook(inputStream); - XSSFSheet sheet = workbook.getSheetAt(1); + { + XSSFSheet sheet = workbook.getSheet("城市列表"); - // 车型 - XSSFRow row = sheet.getRow(0); - if (row == null) { - row = sheet.createRow(0); + // 城市基础数据 + List countryList = dictHandler.getAllCountryList(null).getData(); + List list = countryList.stream().map(item -> item.getCiyCnname()).collect(Collectors.toList()); + String[] str = list.toArray(new String[list.size()]); + + for (int i = 0; i < str.length; i++) { + XSSFRow row = sheet.getRow(i); + if (row == null) { + row = sheet.createRow(i); + } + XSSFCell cell = row.getCell(0); + if (cell == null) { + cell = row.createCell(0); + } + cell.setCellValue(str[i]); + } } - for (int i = 0; i < carTypeList.size(); i++) { - XSSFCell cell = row.getCell(i); - if (cell == null) { -// XSSFCellStyle cellStyle = row.getCell(i).getCellStyle(); - cell = row.createCell(i); -// cell.setCellStyle(cellStyle); - } - cell.setCellValue(carTypeList.get(i).getText()); - // 车型明细 - List data = dictHandler.getCartTypeDetailList(carTypeList.get(i).getId(), null).getData(); - for (int j = 0; j < data.size(); j++) { - XSSFRow r = sheet.getRow(j + 1); - if (r == null) { - r = sheet.createRow(j + 1); - } - XSSFCell c = r.getCell(i); - if (c == null) { -// XSSFCellStyle cellStyle = r.getCell(i).getCellStyle(); - c = r.createCell(i); -// c.setCellStyle(cellStyle); - } - c.setCellValue(data.get(j).getText()); + // 车型 及 车型明细 + { + XSSFSheet sheet = workbook.getSheet("车型管理"); + + XSSFRow row = sheet.getRow(0); + if (row == null) { + row = sheet.createRow(0); } + for (int i = 0; i < carTypeList.size(); i++) { + XSSFCell cell = row.getCell(i); + if (cell == null) { + cell = row.createCell(i); + } + cell.setCellValue(carTypeList.get(i).getText()); + + // 车型明细 + List data = dictHandler.getCartTypeDetailList(carTypeList.get(i).getId(), null).getData(); + for (int j = 0; j < data.size(); j++) { + XSSFRow r = sheet.getRow(j + 1); + if (r == null) { + r = sheet.createRow(j + 1); + } + XSSFCell c = r.getCell(i); + if (c == null) { + c = r.createCell(i); + } + c.setCellValue(data.get(j).getText()); + } + } + } + + // 车型及操作模式 + { + List operateTypeList = dictHandler.getOperateTypeList("车辆").getData(); // 车辆操作模式 + List spareTypeList = dictHandler.getOperateTypeList("备件").getData(); // 备件操作模式 + + XSSFSheet sheet = workbook.getSheet("车辆备件"); + + XSSFRow row = sheet.getRow(0); + if (row == null) { + row = sheet.createRow(0); + } + for (int i = 0; i < carTypeList.size(); i++) { + XSSFCell cell = row.getCell(i); + if (cell == null) { + cell = row.createCell(i); + } + cell.setCellValue(carTypeList.get(i).getText()); + + // 操作模式 + List data = StringUtils.equals("备件", carTypeList.get(i).getText()) ? spareTypeList : operateTypeList; + for (int j = 0; j < data.size(); j++) { + XSSFRow r = sheet.getRow(j + 1); + if (r == null) { + r = sheet.createRow(j + 1); + } + XSSFCell c = r.getCell(i); + if (c == null) { + c = r.createCell(i); + } + c.setCellValue(data.get(j).getText()); + } + } + } + + // 国家与港口 + { + XSSFSheet sheet = workbook.getSheet("国家港口"); + + List countryList = openApi.getCountryList(); + List list = pubApi.getPortList(); + + XSSFRow row = sheet.getRow(0); + if (row == null) { + row = sheet.createRow(0); + } + for (int i = 0; i < countryList.size(); i++) { + XSSFCell cell = row.getCell(i); + if (cell == null) { + cell = row.createCell(i); + } + cell.setCellValue(countryList.get(i).getCtyCnname()); + + String ctyId = countryList.get(i).getCtyId(); + // 港口 + List collect = list.stream().filter(item -> StringUtils.equals(item.getPotCtycd(), ctyId)).collect(Collectors.toList()); + for (int j = 0; j < collect.size(); j++) { + XSSFRow r = sheet.getRow(j + 1); + if (r == null) { + r = sheet.createRow(j + 1); + } + XSSFCell c = r.getCell(i); + if (c == null) { + c = r.createCell(i); + } + c.setCellValue(collect.get(j).getPotCnname()); + } + } + + } OutputStream out = response.getOutputStream(); @@ -2940,6 +3108,11 @@ public class ExportInHandler implements BaseHandler { // 验证通过的数据 List successDataList = new ArrayList<>(); + // 获取用户绑定的货代 + List userBindFreight = openApi.getUserBindFreight();; + + // 国家数据 + List countryList = openApi.getCountryList(); // 港口基础数据 List portList = dictHandler.getPortList(null).getData(); // 船名基础数据 @@ -2950,8 +3123,8 @@ public class ExportInHandler implements BaseHandler { List brandList = dictHandler.getBrandList(null).getData(); // 车型基础数据 List carTypeList = dictHandler.getCartTypeList(null).getData(); - // 国家基础数据 - List countryList = dictHandler.getCountryList(null).getData(); + // 产地基础数据 + List originPlaceList = dictHandler.getAllCountryList(null).getData(); // 运输模式 List transportWayList = dictHandler.getTransportWayList(null).getData(); // 操作模式 @@ -2961,7 +3134,7 @@ public class ExportInHandler implements BaseHandler { // 新能源类型 List energyTypeList = dictHandler.getEnergyTypeList().getData(); // 根据港口ID 获取国家 - Map portCountryList = new HashMap<>(); +// Map portCountryList = new HashMap<>(); // 货代列表 Map companyMap = new HashMap<>(); // 货物性质 @@ -3004,7 +3177,14 @@ public class ExportInHandler implements BaseHandler { // 港区、船名、港口、品牌、车型 validData.stream().forEach(item -> { - if (portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortName())).count() == 0) { + if (countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCtyCnname(), item.getCountry())).count() == 0) { + JSONObject o = JSONObject.from(item); + o.put("status", "国家不存在"); + errorDataList.add(o); + 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) { JSONObject o = JSONObject.from(item); o.put("status", "港口不存在"); errorDataList.add(o); @@ -3034,7 +3214,7 @@ public class ExportInHandler implements BaseHandler { errorDataList.add(o); return; } - if (countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCiyCnname(), item.getOriginPlace())).count() == 0) { + if (originPlaceList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCiyCnname(), item.getOriginPlace())).count() == 0) { JSONObject o = JSONObject.from(item); o.put("status", "产地错误"); errorDataList.add(o); @@ -3048,6 +3228,14 @@ public class ExportInHandler implements BaseHandler { companyMap.put(item.getFreight(), StringUtils.trim(company.getCueId())); } } + if (StringUtils.equals(type, "0")) {// 验证货代不一致 + if (CollectionUtils.isEmpty(userBindFreight) || userBindFreight.stream().filter(s -> StringUtils.equalsAny(item.getFreight(), s.getCueCnname(), s.getCueAbbreviation())).count() == 0) { + JSONObject o = JSONObject.from(item); + o.put("status", "登录账号绑定货代不一致"); + errorDataList.add(o); + return; + } + } if (StringUtils.isEmpty(companyMap.get(item.getFreight()))) { JSONObject o = JSONObject.from(item); o.put("status", "货代不存在"); @@ -3092,11 +3280,25 @@ public class ExportInHandler implements BaseHandler { 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; + if (!StringUtils.equals("备件", item.getCartType())) { + if (StringUtils.isEmpty(item.getEnergyTypeName())) { + JSONObject o = JSONObject.from(item); + o.put("status", "能源类型不能为空"); + errorDataList.add(o); + return; + } + if (StringUtils.isEmpty(item.getSecondHand())) { + 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; + } } if (goodsNature.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getPtrDesc(), item.getNatureFlagName())).count() == 0) { JSONObject o = JSONObject.from(item); @@ -3162,16 +3364,9 @@ public class ExportInHandler implements BaseHandler { 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.setCountryId(countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCtyCnname(), item.getCountry())).findFirst().get().getCtyId()); + in.setPortId(portList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getPortName()) && StringUtils.equals(p.getExtra2(), in.getCountryId())).findFirst().get().getId()); if (StringUtils.isNotEmpty(item.getEnterTime())) { // 验证进场时间是否正确 @@ -3185,12 +3380,14 @@ public class ExportInHandler implements BaseHandler { 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.setOriginPlaceId(originPlaceList.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.setSpecWorkId(specWorkList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getSpecWork())).findFirst().get().getId()); - in.setEnergyType(energyTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getEnergyTypeName())).findFirst().get().getId()); + if (!StringUtils.equals("备件", item.getCartType())) { + 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()); @@ -3228,6 +3425,7 @@ public class ExportInHandler implements BaseHandler { cQuery.eq(CustomerExportIn::getShipId, shipId); cQuery.eq(CustomerExportIn::getVoyageId, voyageId); cQuery.eq(CustomerExportIn::getBillNum, billNo); + cQuery.ne(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); List exportInList = customerExportInService.list(cQuery); @@ -3247,22 +3445,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 -> { @@ -3400,12 +3598,15 @@ public class ExportInHandler implements BaseHandler { @ApiOperation("出口进场计划船名航次") @PostMapping("/plan/ship") public Result> getExportInPlanShipList( + @RequestParam(required = false) @NotBlank(message = "港区ID不能为空") String portAreaId, @RequestParam(required = false, defaultValue = "1") Integer current, @RequestParam(required = false, defaultValue = "10") Integer size, @RequestParam(required = false) String q) { QueryWrapper query = new QueryWrapper<>(); query.select("distinct ship_id, ship_name, ship_en_name"); query.eq("check_status", AuditEnum.AUDIT_PASS); + query.eq("port_area_id", portAreaId); + query.eq("load_ship_flag", 0); if (StringUtils.isNotEmpty(q)) { query.and((wrapper) -> { wrapper.like("ship_name", q); @@ -3428,6 +3629,16 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success(rst, String.valueOf(page.getTotal())); } + @ApiOperation("装船确认状态通知") + @PostMapping("/ship/load/confirm") + public Result shipLoadConfirm(@RequestBody @Validated ShipStatusVo vo) { + customerExportInService.lambdaUpdate().eq(CustomerExportIn::getShipId, vo.getShipId()) + .eq(CustomerExportIn::getVoyageId, vo.getVoyageId()) + .set(CustomerExportIn::getLoadShipFlag, StringUtils.equals("0", vo.getStatus()) ? 0 : 1) + .update(); + return ResultUtil.success("success"); + } + @ApiOperation("出口进场计划航次") @PostMapping("/plan/voyage") public Result> getPlanVoyageList( 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 9610da4..82d5cbd 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 @@ -1036,10 +1036,10 @@ public class ExportLoadHandler implements BaseHandler { List successDataList = new ArrayList<>(); // 要保存的表头 - Map heads = new LinkedHashMap<>(); + Map heads = new LinkedHashMap<>(); // 要保存的明细 - Map> details = new HashMap<>(); + Map> details = new HashMap<>(); // 港口基础数据 @@ -1221,8 +1221,8 @@ public class ExportLoadHandler implements BaseHandler { exportLoad.setApplyTime(new Date()); exportLoad.setApplicantId(UserContext.getUser().getUserId()); - heads.put(exportIn.getId(), exportLoad); - details.put(exportIn.getId(), saveCargos); + heads.put(item.getKey(), exportLoad); + details.put(item.getKey(), saveCargos); } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelValidationUtils.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelValidationUtils.java new file mode 100644 index 0000000..706c212 --- /dev/null +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/ExcelValidationUtils.java @@ -0,0 +1,252 @@ +package com.haitonggauto.rtosc.handler.excel; + +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.xssf.usermodel.*; + +import java.io.FileOutputStream; +import java.util.*; + +/** + * excel验证工具类 + * + * @author chenchuancheng github.com/meethigher + * @since 2023/08/20 23:55 + */ +public class ExcelValidationUtils { + + + private static final int minRow = 1; + + private static final int maxRow = 100; + + private static final boolean debugHideSheet = false; + + + /** + * 创建一个xlsx + * + * @return {@link XSSFWorkbook} + */ + public static XSSFWorkbook createOneXLSX() { + return new XSSFWorkbook(); + } + + /** + * 为xlsx添加一个sheet + * + * @param wb xlsx + * @param sheetName sheet名 + * @param headers 首行标题头 + * @return sheet + */ + public static XSSFSheet addOneSheet(XSSFWorkbook wb, String sheetName, String[] headers) { + XSSFSheet st = wb.createSheet(sheetName); + //表头样式 + CellStyle style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); // 创建一个居中格式 + //字体样式 + Font fontStyle = wb.createFont(); + fontStyle.setFontName("微软雅黑"); + fontStyle.setFontHeightInPoints((short) 12); + style.setFont(fontStyle); + //单元格格式为文本 + XSSFDataFormat format = wb.createDataFormat(); + style.setDataFormat(format.getFormat("@")); + //写标题 + XSSFRow row = st.createRow(0); + st.createFreezePane(0, 1, 0, 1); + for (int i = 0; i < headers.length; i++) { + String value = headers[i]; + XSSFCell cell = row.createCell(i); + st.setColumnWidth(i, value.length() * 1000); + cell.setCellStyle(style); + st.setDefaultColumnStyle(i, style); + cell.setCellValue(value); + } + return st; + } + + + /** + * 添加两层级联数据 + * + * @param wb xlsx + * @param targetSheet 目标sheet + * @param linkageData 两层级联数据 + * @param parentCol 父列 + * @param childCol 孩子列 + * @param parentColIdentifier 父列标识符 + * @return {@link XSSFSheet} + */ + public static XSSFSheet addLinkageDataValidation(XSSFWorkbook wb, XSSFSheet targetSheet, Map> linkageData, + int parentCol, int childCol, String parentColIdentifier) { + XSSFSheet hideSt = wb.createSheet(); + wb.setSheetHidden(wb.getSheetIndex(hideSt), !debugHideSheet); + int rowId = 0; + Set keySet = linkageData.keySet(); + for (String parent : keySet) { + List sonList = linkageData.get(parent); + XSSFRow row = hideSt.createRow(rowId++); + row.createCell(0).setCellValue(parent); + for (int i = 0; i < sonList.size(); i++) { + XSSFCell cell = row.createCell(i + 1); + cell.setCellValue(sonList.get(i)); + } + // 添加名称管理器,1表示b列,从b列开始往后,都是子级 + String range = getRange(1, rowId, sonList.size()); + Name name = wb.createName(); + name.setNameName(parent); + String formula = hideSt.getSheetName() + "!" + range; + name.setRefersToFormula(formula); + } + //创建表达式校验 + XSSFDataValidationHelper helper = new XSSFDataValidationHelper(targetSheet); + +// //父级校验,如需生成更多,用户手动拖拽下拉即可。此操作会导致数组内容总长度超过255时报错 +// DataValidation parentValidation = helper.createValidation(helper.createExplicitListConstraint(keySet.toArray(new String[0])), +// new CellRangeAddressList(minRow, maxRow, parentCol, parentCol)); +// parentValidation.createErrorBox("错误", "请选择正确的父级类型"); +// parentValidation.setShowErrorBox(true); +// parentValidation.setSuppressDropDownArrow(true); +// targetSheet.addValidationData(parentValidation); + + //解决长度为255的问题 + Name name = wb.createName(); + name.setNameName(hideSt.getSheetName()); + name.setRefersToFormula(hideSt.getSheetName() + "!$A$1:$A$" + keySet.size()); + DataValidation parentValidation = helper.createValidation(helper.createFormulaListConstraint(hideSt.getSheetName()), new CellRangeAddressList(minRow, maxRow, parentCol, parentCol)); + parentValidation.createErrorBox("错误", "请选择正确的父级类型"); + parentValidation.setShowErrorBox(true); + targetSheet.addValidationData(parentValidation); + + //子级校验,如需生成更多,用户手动拖拽下拉即可 + for (int i = minRow; i < maxRow; i++) { + DataValidation childValidation = helper.createValidation(helper.createFormulaListConstraint("INDIRECT(" + parentColIdentifier + "" + (i + 1) + ")"), + new CellRangeAddressList(i, i, childCol, childCol)); + childValidation.createErrorBox("错误", "请选择正确的子级类型"); + childValidation.setShowErrorBox(true); + childValidation.setSuppressDropDownArrow(true); + targetSheet.addValidationData(childValidation); + } + + return hideSt; + } + + /** + * 添加简单下拉列表验证-下拉列表总内容不超过255字符 + * + * @param st sheet + * @param dropDownList 下拉列表数据 + * @param firstCol 开始列,从0开始 + * @param lastCol 结束列,从0开始 + */ + public static void addSimpleDropDownListValidation(XSSFSheet st, String[] dropDownList, int firstCol, int lastCol) { + XSSFDataValidationHelper helper = new XSSFDataValidationHelper(st); + XSSFDataValidationConstraint constraint = (XSSFDataValidationConstraint) helper.createExplicitListConstraint(dropDownList); + CellRangeAddressList addressList = new CellRangeAddressList(minRow, maxRow, firstCol, lastCol); + XSSFDataValidation validation = (XSSFDataValidation) helper.createValidation(constraint, addressList); + validation.setSuppressDropDownArrow(true); + validation.setShowErrorBox(true); + st.addValidationData(validation); + } + + + /** + * 添加复杂下拉列表验证-下拉列表总内容允许超过255字符 + * + * @param wb xlsx + * @param dropDownList 下拉列表数据 + * @param firstCol 开始列,从0开始 + * @param lastCol 结束列,从0开始 + */ + public static void addComplexDropDownListValidation(XSSFWorkbook wb, XSSFSheet st, String[] dropDownList, int firstCol, int lastCol) { + XSSFSheet hideSt = wb.createSheet(); + wb.setSheetHidden(wb.getSheetIndex(hideSt), !debugHideSheet); + XSSFDataValidationHelper helper = new XSSFDataValidationHelper(st); + for (int i = 0, length = dropDownList.length; i < length; i++) { + String value = dropDownList[i]; + XSSFRow row = hideSt.createRow(i); + XSSFCell cell = row.createCell(0); + cell.setCellValue(value); + } + //解决长度为255的问题 + Name name = wb.createName(); + name.setNameName(hideSt.getSheetName()); + name.setRefersToFormula(hideSt.getSheetName() + "!$A$1:$A$" + dropDownList.length); + DataValidation parentValidation = helper.createValidation(helper.createFormulaListConstraint(hideSt.getSheetName()), new CellRangeAddressList(minRow, maxRow, firstCol, lastCol)); + parentValidation.createErrorBox("错误", "请选择正确的类型"); + parentValidation.setShowErrorBox(true); + st.addValidationData(parentValidation); + } + + + /** + * 计算formula + * + * @param offset 偏移量,如果给0,表示从A列开始,1,就是从B列 + * @param rowId 第几行 + * @param colCount 一共多少列 + * @return 如果给入参 1,1,10. 表示从B1-K1。最终返回 $B$1:$K$1 + */ + private static String getRange(int offset, int rowId, int colCount) { + char start = (char) ('A' + offset); + if (colCount <= 25) { + char end = (char) (start + colCount - 1); + return "$" + start + "$" + rowId + ":$" + end + "$" + rowId; + } else { + char endPrefix = 'A', endSuffix; + if ((colCount - 25) / 26 == 0 || colCount == 51) {// 26-51之间,包括边界(仅两次字母表计算) + if ((colCount - 25) % 26 == 0) {// 边界值 + endSuffix = (char) ('A' + 25); + } else { + endSuffix = (char) ('A' + (colCount - 25) % 26 - 1); + } + } else {// 51以上 + if ((colCount - 25) % 26 == 0) { + endSuffix = (char) ('A' + 25); + endPrefix = (char) (endPrefix + (colCount - 25) / 26 - 1); + } else { + endSuffix = (char) ('A' + (colCount - 25) % 26 - 1); + endPrefix = (char) (endPrefix + (colCount - 25) / 26); + } + } + return "$" + start + "$" + rowId + ":$" + endPrefix + endSuffix + "$" + rowId; + } + } + + private final static String[] headers = new String[]{ + "性别", + "省", + "市", + "区", + }; + + + private static Map> 省级() { + Map> map = new HashMap<>(); + map.put("湖北省(可以吗)", Arrays.asList("武汉市", "襄阳市")); + map.put("吉林省", Arrays.asList("长春市", "吉林市")); + return map; + } + + private static Map> 市级() { + Map> map = new HashMap<>(); + map.put("武汉市", Arrays.asList("洪山区", "江夏区")); + map.put("长春市", Arrays.asList("宽城区", "南关区")); + return map; + } + + public static void main(String[] args) throws Exception { + + + XSSFWorkbook wb = createOneXLSX(); + XSSFSheet st = addOneSheet(wb, "data", headers); + addSimpleDropDownListValidation(st, new String[]{"男", "女"}, 0, 0); + addLinkageDataValidation(wb, st, 省级(), 1, 2, "B"); + addLinkageDataValidation(wb, st, 市级(), 2, 3, "C"); + + + wb.write(new FileOutputStream("d:\\aaa.xlsx")); + } +} 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 0a1a5a3..e8a691e 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 @@ -31,6 +31,7 @@ import java.util.*; import java.util.stream.Collectors; @Service +@Slf4j public class CustomerServiceImpl implements CustomerService { @Autowired @@ -787,6 +788,7 @@ public class CustomerServiceImpl implements CustomerService { @Override @Async public void syncAddExportInToOld(List list) { + log.info("进入同步方法"); if (!syncConfig.getSync() || CollectionUtils.isEmpty(list)) { // 没有打开同步或,列表为空真直接返回 return; } @@ -830,11 +832,13 @@ public class CustomerServiceImpl implements CustomerService { try { + log.info("同步老系统:" + JSONObject.toJSONString(req)); + String post = OkHttpUtils.post(syncConfig.getUrl() + "/execInPortPlanAdd", OkHttpUtils.buildJsonRequestBody(JSONObject.toJSONString(req)), null); JSONObject rst = JSONObject.parseObject(post); - System.err.println(rst.toJSONString()); + log.info("同步老系统结果:" + JSONObject.toJSONString(rst)); if (StringUtils.equals("0", rst.getString("success"))) { throw new RuntimeException("请求参数:" + JSONObject.toJSONString(req) + ", 错误信息:" + rst.getString("errmsg")); diff --git a/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx b/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx index b219172..5eb4381 100644 Binary files a/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx and b/nuzar-customer-controller/src/main/resources/templates/in_temp.xlsx differ diff --git a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java index 1553276..c69c371 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportIn.java @@ -447,6 +447,10 @@ public class CustomerExportIn extends BaseEntity implements Serializable { @ApiModelProperty(value = "审核状态") private AuditEnum checkStatus; + @TableField(value = "load_ship_flag") + @ApiModelProperty(value = "是否装船确认") + private Integer loadShipFlag = 0; + @TableField(exist = false) @ApiModelProperty(value = "进场日期", hidden = true) private Date tmpEnterDate; diff --git a/nuzar-customer-repository/src/main/resources/mapper/CustomerExportLoadMapper.xml b/nuzar-customer-repository/src/main/resources/mapper/CustomerExportLoadMapper.xml index 6f1d692..cae6725 100644 --- a/nuzar-customer-repository/src/main/resources/mapper/CustomerExportLoadMapper.xml +++ b/nuzar-customer-repository/src/main/resources/mapper/CustomerExportLoadMapper.xml @@ -69,6 +69,8 @@ + +