diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInspectExportExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInspectExportExcel.java new file mode 100644 index 0000000..215be6c --- /dev/null +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ExportInspectExportExcel.java @@ -0,0 +1,52 @@ +package com.haitonggauto.rtosc.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + + +/** + * 出口进场基本表 + * @TableName customer_export_in + */ +@Data +public class ExportInspectExportExcel { + + @ExcelProperty("序号") + private Integer serialNo; + + @ExcelProperty("船名/航次") + private String shipVoyageName; + + @ExcelProperty("港区") + private String portArea; + + @ExcelProperty("装船日期") + private String unloadDate; + + @ExcelProperty("提单号") + private String billNo; + + @ExcelProperty("报关单号") + private String passport; + + @ExcelProperty("查验日期") + private String inspectTime; + + @ExcelProperty("品牌") + private String brand; + + @ExcelProperty("车型") + private String cartType; + + @ExcelProperty("车架号") + private String vin; + + @ExcelProperty("商品项号") + private String itemNo; + + @ExcelProperty("区") + private String area; + + @ExcelProperty("公司名称") + private String company; +} \ No newline at end of file diff --git a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/InspectExportExcel.java b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportInspectExportExcel.java similarity index 96% rename from nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/InspectExportExcel.java rename to nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportInspectExportExcel.java index 9a583c2..e514704 100644 --- a/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/InspectExportExcel.java +++ b/nuzar-customer-client/src/main/java/com/haitonggauto/rtosc/excel/ImportInspectExportExcel.java @@ -9,7 +9,7 @@ import lombok.Data; * @TableName customer_export_in */ @Data -public class InspectExportExcel { +public class ImportInspectExportExcel { @ExcelProperty("序号") private Integer serialNo; 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 b2a2e6b..dcf6105 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 @@ -14,8 +14,8 @@ import java.util.List; import java.util.Map; -@FeignClient(name = "https://rtops4.haitongauto.com/tos/api") -//@FeignClient(name = "rtos-openapi") +//@FeignClient(name = "https://rtops4.haitongauto.com/tos/api") +@FeignClient(name = "rtos-openapi") public interface NuzarOpenApi { // 根据港区ID获取国家 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 e4ac356..f139809 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 @@ -7,8 +7,8 @@ import org.springframework.web.bind.annotation.*; import java.util.List; -@FeignClient(name = "https://rtops4.haitongauto.com/tos/pub") -//@FeignClient(name = "basic-service") +//@FeignClient(name = "https://rtops4.haitongauto.com/tos/pub") +@FeignClient(name = "basic-service") public interface NuzarPubApi { 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 22c33f2..0424981 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 @@ -12,8 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam; import java.util.List; -@FeignClient(name = "https://rtops4.haitongauto.com/tos/shp") -//@FeignClient(name = "shipment-service") +//@FeignClient(name = "https://rtops4.haitongauto.com/tos/shp") +@FeignClient(name = "shipment-service") public interface NuzarShpApi { @GetMapping("/vesselVoyages/queryVvyName") 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 d8b3e2b..57f6097 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 @@ -2175,19 +2175,19 @@ public class ExportInHandler implements BaseHandler { .eq(CustomerExportIn::getBrand, brand) .eq(CustomerExportIn::getModels, models) .ne(CustomerExportIn::getCartType, "备件"); // 备件的不允许整船导入 - if (StringUtils.equals(type, "0")) { - cQuery.and((wrapper) -> { - wrapper.eq(CustomerExportIn::getCheckStatus, AuditEnum.SUBMIT) - .or() - .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); - }); - } else { - cQuery.and((wrapper) -> { - wrapper.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT) - .or() - .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); - }); - } +// if (StringUtils.equals(type, "0")) { +// cQuery.and((wrapper) -> { +// wrapper.eq(CustomerExportIn::getCheckStatus, AuditEnum.SUBMIT) +// .or() +// .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); +// }); +// } else { +// cQuery.and((wrapper) -> { +// wrapper.eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT) +// .or() +// .eq(CustomerExportIn::getCheckStatus, AuditEnum.AUDIT_REJECT); +// }); +// } List exportInList = customerExportInService.list(cQuery); @@ -2230,14 +2230,14 @@ public class ExportInHandler implements BaseHandler { } } - if (exportIn.getCheckStatus() == AuditEnum.AUDIT_PASS) { // 审核 - errorDataList.addAll(item.getValue().stream().map(p -> { - JSONObject o = JSONObject.from(p); - o.put("status", "审核通过状态的不可导入"); - return o; - }).collect(Collectors.toList())); - return; - } +// if (exportIn.getCheckStatus() == AuditEnum.AUDIT_PASS) { // 审核 +// 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 -> { @@ -3010,7 +3010,7 @@ public class ExportInHandler implements BaseHandler { } if (countryList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getCiyCnname(), item.getOriginPlace())).count() == 0) { JSONObject o = JSONObject.from(item); - o.put("status", "产地代码错误"); + o.put("status", "产地错误"); errorDataList.add(o); return; } @@ -3062,7 +3062,7 @@ public class ExportInHandler implements BaseHandler { } if (energyTypeList.stream().filter(p -> StringUtils.equalsIgnoreCase(p.getText(), item.getEnergyTypeName())).count() == 0) { JSONObject o = JSONObject.from(item); - o.put("status", "源类型不存在"); + o.put("status", "能源类型不存在"); errorDataList.add(o); return; } @@ -3465,4 +3465,13 @@ public class ExportInHandler implements BaseHandler { return ResultUtil.success(rst, String.valueOf(page.getTotal())); } + + private void formatData(List ins) { + if (CollectionUtils.isEmpty(ins)) { + return; + } + ins.stream().forEach(item -> { + + }); + } } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java index 2933e88..ee89420 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/ExportInspectHandler.java @@ -14,20 +14,17 @@ import com.haitonggauto.rtosc.api.NuzarOpenApi; import com.haitonggauto.rtosc.api.NuzarYardApi; import com.haitonggauto.rtosc.api.dto.*; import com.haitonggauto.rtosc.common.context.UserContext; +import com.haitonggauto.rtosc.common.db.query.BaseQuery; import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.common.dto.Result; import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; -import com.haitonggauto.rtosc.common.utils.DateUtils; import com.haitonggauto.rtosc.common.utils.ResultUtil; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.utils.WrapperKit; import com.haitonggauto.rtosc.dto.*; -import com.haitonggauto.rtosc.excel.ExportInCargoExportExcel; -import com.haitonggauto.rtosc.excel.ExportInExportExcel; -import com.haitonggauto.rtosc.excel.InspectExportExcel; +import com.haitonggauto.rtosc.excel.ExportInspectExportExcel; import com.haitonggauto.rtosc.query.CargoQuery; -import com.haitonggauto.rtosc.query.ExportInCheckQuery; import com.haitonggauto.rtosc.query.ExportInspectCheckQuery; import com.haitonggauto.rtosc.query.ExportInspectQuery; import com.haitonggauto.rtosc.repository.entity.*; @@ -262,8 +259,8 @@ public class ExportInspectHandler implements BaseHandler { List inspectStatusStatus = openApi.getInspectStatusStatus(ids); Map collect = inspectStatusStatus.stream().collect(Collectors.toMap(InspectStatusResp::getApplyId, InspectStatusResp::getInspectionStatusNm)); page.getRecords().forEach(item -> { - if (collect.containsKey(item.getId()+"")) { - item.setApiInspectStatus(collect.get(item.getId()+"")); + if (collect.containsKey(item.getId() + "")) { + item.setApiInspectStatus(collect.get(item.getId() + "")); } }); } @@ -287,8 +284,8 @@ public class ExportInspectHandler implements BaseHandler { List inspectStatusStatus = openApi.getInspectStatusStatus(ids); Map collect = inspectStatusStatus.stream().collect(Collectors.toMap(InspectStatusResp::getApplyId, InspectStatusResp::getInspectionStatusNm)); page.getRecords().forEach(item -> { - if (collect.containsKey(item.getId()+"")) { - item.setApiInspectStatus(collect.get(item.getId()+"")); + if (collect.containsKey(item.getId() + "")) { + item.setApiInspectStatus(collect.get(item.getId() + "")); } }); } @@ -319,13 +316,14 @@ public class ExportInspectHandler implements BaseHandler { // 数据拼装 list.stream().forEach(item -> { - List cs = collect.get(item.getId()); + List cs = collect.get(item.getId()); item.setCargos(cs); }); } return ResultUtil.success(list); } + /** * 新增 * @@ -397,8 +395,8 @@ public class ExportInspectHandler implements BaseHandler { @ApiOperation("撤销提交审核") @PostMapping("/submit-check/reverse") public Result submitCheckReverse(@RequestBody - @NotNull(message = "请传入要审核的海关查验ID") - @Size(min = 1, message = "ID列表不能为空") List ids) { + @NotNull(message = "请传入要审核的海关查验ID") + @Size(min = 1, message = "ID列表不能为空") List ids) { customerExportInspectService.lambdaUpdate().set(CustomerExportInspect::getCheckStatus, AuditEnum.SUBMIT).in(CustomerExportInspect::getId, ids).update(); return ResultUtil.success("success"); } @@ -432,8 +430,8 @@ public class ExportInspectHandler implements BaseHandler { @ApiOperation("编辑") @PostMapping("/edit") // 使用LambdaUpdateWrapper只在特定需求下做处理(推荐) 将字段修改为空值的处理方法 - public Result edit(@RequestParam(required = false, defaultValue = "false")Boolean flag, - @RequestBody @Validated(ValidationGroup.update.class) ExportInspectVo form) { + public Result edit(@RequestParam(required = false, defaultValue = "false") Boolean flag, + @RequestBody @Validated(ValidationGroup.update.class) ExportInspectVo form) { if (CollectionUtils.isNotEmpty(form.getCargos())) { List repeat = form.getCargos().stream().collect(Collectors.groupingBy(ExportInspectCargoVo::getVin, Collectors.counting())) .entrySet().stream().filter(entry -> entry.getValue() > 1).map(entry -> entry.getKey()).collect(Collectors.toList()); @@ -494,8 +492,8 @@ public class ExportInspectHandler implements BaseHandler { if (CollectionUtils.isNotEmpty(ids)) { List inspectStatusStatus = openApi.getInspectStatusStatus(ids); Map collect = inspectStatusStatus.stream().collect(Collectors.toMap(InspectStatusResp::getApplyId, InspectStatusResp::getInspectionStatus)); - if (collect.containsKey(exportInspect.getId()+"")) { - exportInspect.setApiInspectStatus(collect.get(exportInspect.getId()+"")); + if (collect.containsKey(exportInspect.getId() + "")) { + exportInspect.setApiInspectStatus(collect.get(exportInspect.getId() + "")); } } @@ -684,8 +682,8 @@ public class ExportInspectHandler implements BaseHandler { } /** - * * 导出excel + * * @param response */ @ApiOperation("导出excel") @@ -698,6 +696,7 @@ public class ExportInspectHandler implements BaseHandler { query.setTradType("E"); query.setPage(1); query.setRows(500); +// query.setSorts(Arrays.asList(new BaseQuery.SortField("shipName", "desc"), new BaseQuery.SortField("voyage", "desc"), new BaseQuery.SortField("billNo", "desc"))); Wrapper queryWrapper = new WrapperKit() { }.changeBaseQueryToWrapper(CustomerExportInspect.class, query); ExcelWriter excelWriter = null; @@ -714,7 +713,7 @@ public class ExportInspectHandler implements BaseHandler { excelWriter = EasyExcel.write(out).build(); - WriteSheet writeSheet = EasyExcel.writerSheet(0, "出口查验计划清单").head(InspectExportExcel.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet(0, "出口查验计划清单").head(ExportInspectExportExcel.class).build(); // 查询数据 Page page = customerExportInspectService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); @@ -752,19 +751,35 @@ public class ExportInspectHandler implements BaseHandler { customerService.wrapperEntity(headers); - // 头映射 - Map collect = headers.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); + // 处理明细数据 - List list = customerExportInspectCargoService.lambdaQuery().in(CustomerExportInspectCargo::getExportInspectId, headers.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); + List list = customerExportInspectCargoService.lambdaQuery() + .in(CustomerExportInspectCargo::getExportInspectId, headers.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); - List details = list.stream().map(item -> { - CustomerExportInspect head = collect.get(item.getExportInspectId()); - InspectExportExcel e = PoMapper.instance.inspectEntity2ExportExcel(head, item); - e.setSerialNo(index.getAndIncrement()); - e.setShipVoyageName(StringUtils.join(head.getShipName(), "/", head.getVoyage())); - return e; - }).collect(Collectors.toList()); + // 表头按照船名,船航,提单号进行分组,找出对应的id + LinkedHashMap> inMap = headers.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipId(), item.getVoyageId(), item.getBillNo()), LinkedHashMap::new, Collectors.toList())); + + + inMap.entrySet().forEach(item -> { + // 头映射 + Map collect = item.getValue().stream().collect(Collectors.toMap(p -> p.getId(), p -> p)); + + List ids = item.getValue().stream().map(p -> p.getId()).collect(Collectors.toList()); + + // 备件号排序 + List details = list.stream().filter(p -> ids.contains(p.getExportInspectId())) + .sorted(Comparator.comparing(CustomerExportInspectCargo::getCartType).reversed()) + .map(p -> { + CustomerExportInspect head = collect.get(p.getExportInspectId()); + ExportInspectExportExcel e = PoMapper.instance.inspectEntity2ExportExcel(head, p); + e.setSerialNo(index.getAndIncrement()); + e.setShipVoyageName(StringUtils.join(head.getShipName(), "/", head.getVoyage())); + return e; + }).collect(Collectors.toList()); + + excelWriter.write(details, writeSheet); + }); - excelWriter.write(details, writeSheet); } } 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 2f7b55a..cb2f22c 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 @@ -4,7 +4,6 @@ import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson2.JSONObject; -import com.alibaba.fastjson2.util.UUIDUtils; import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -20,7 +19,6 @@ import com.haitonggauto.rtosc.common.dto.DictDTO; import com.haitonggauto.rtosc.common.dto.Result; import com.haitonggauto.rtosc.common.enums.ErrorType; import com.haitonggauto.rtosc.common.handler.BaseHandler; -import com.haitonggauto.rtosc.common.utils.DateUtils; import com.haitonggauto.rtosc.common.utils.ResultUtil; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.utils.WrapperKit; @@ -28,7 +26,6 @@ import com.haitonggauto.rtosc.dto.*; import com.haitonggauto.rtosc.excel.*; import com.haitonggauto.rtosc.handler.excel.CustomCellWriteHandler; import com.haitonggauto.rtosc.query.CargoQuery; -import com.haitonggauto.rtosc.query.ExportInCheckQuery; import com.haitonggauto.rtosc.query.ExportLoadCheckQuery; import com.haitonggauto.rtosc.query.ExportLoadQuery; import com.haitonggauto.rtosc.repository.entity.*; @@ -717,6 +714,10 @@ public class ExportLoadHandler implements BaseHandler { List status = openApi.getVinStatus(req); collect = status.stream().collect(Collectors.toMap(WorkStatusDTO::getVinCode, WorkStatusDTO::getWorkStatus)); } + for (CustomerExportLoadCargo cargo : page.getRecords()) { + cargo.setDestPortId(exportLoad.getDestPortId()); + cargo.setDestPort(exportLoad.getDestPort()); + } if (MapUtils.isNotEmpty(collect)) { for (CustomerExportLoadCargo cargo : page.getRecords()) { cargo.setWorkStatus(collect.get(cargo.getVin())); @@ -1409,8 +1410,8 @@ public class ExportLoadHandler implements BaseHandler { //普通下拉数据 Map map = new HashMap<>(); - String[] isZgArray = {"是", "否"}; - map.put(3, isZgArray); + String[] isZgArray = {"正常", "国内中转", "外进转内出", "长江","沿海"}; + map.put(2, isZgArray); //检查类型-子类 Map> inspNameMap = new HashMap<>(); //检查类型-父类 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 3dd28df..65e30fa 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 @@ -22,8 +22,8 @@ import com.haitonggauto.rtosc.common.utils.ResultUtil; import com.haitonggauto.rtosc.common.utils.ValidationGroup; import com.haitonggauto.rtosc.common.utils.WrapperKit; import com.haitonggauto.rtosc.dto.*; -import com.haitonggauto.rtosc.excel.ExportInExportExcel; -import com.haitonggauto.rtosc.excel.InspectExportExcel; +import com.haitonggauto.rtosc.excel.ExportInspectExportExcel; +import com.haitonggauto.rtosc.excel.ImportInspectExportExcel; import com.haitonggauto.rtosc.handler.mapper.PoMapper; import com.haitonggauto.rtosc.query.CargoQuery; import com.haitonggauto.rtosc.query.ExportInspectCheckQuery; @@ -679,7 +679,7 @@ public class ImportInspectHandler implements BaseHandler { excelWriter = EasyExcel.write(out).build(); - WriteSheet writeSheet = EasyExcel.writerSheet(0, "出口查验计划清单").head(InspectExportExcel.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet(0, "出口查验计划清单").head(ImportInspectExportExcel.class).build(); // 查询数据 Page page = customerExportInspectService.page(new Page<>(query.getPage(), query.getRows()), queryWrapper); @@ -717,19 +717,34 @@ public class ImportInspectHandler implements BaseHandler { customerService.wrapperEntity(headers); - // 头映射 - Map collect = headers.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); + // 处理明细数据 - List list = customerExportInspectCargoService.lambdaQuery().in(CustomerExportInspectCargo::getExportInspectId, headers.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); + List list = customerExportInspectCargoService.lambdaQuery() + .in(CustomerExportInspectCargo::getExportInspectId, headers.stream().map(item -> item.getId()).collect(Collectors.toList())).list(); - List details = list.stream().map(item -> { - CustomerExportInspect head = collect.get(item.getExportInspectId()); - InspectExportExcel e = PoMapper.instance.inspectEntity2ExportExcel(head, item); - e.setSerialNo(index.getAndIncrement()); - e.setShipVoyageName(StringUtils.join(head.getShipName(), "/", head.getVoyage())); - return e; - }).collect(Collectors.toList()); + // 表头按照船名,船航,提单号进行分组,找出对应的id + LinkedHashMap> inMap = headers.stream() + .collect(Collectors.groupingBy(item -> StringUtils.joinWith("#$#", item.getShipId(), item.getVoyageId(), item.getBillNo()), LinkedHashMap::new, Collectors.toList())); - excelWriter.write(details, writeSheet); + + inMap.entrySet().forEach(item -> { + // 头映射 + Map collect = item.getValue().stream().collect(Collectors.toMap(p -> p.getId(), p -> p)); + + List ids = item.getValue().stream().map(p -> p.getId()).collect(Collectors.toList()); + + // 备件号排序 + List details = list.stream().filter(p -> ids.contains(p.getExportInspectId())) + .sorted(Comparator.comparing(CustomerExportInspectCargo::getCartType).reversed()) + .map(p -> { + CustomerExportInspect head = collect.get(p.getExportInspectId()); + ExportInspectExportExcel e = PoMapper.instance.inspectEntity2ExportExcel(head, p); + e.setSerialNo(index.getAndIncrement()); + e.setShipVoyageName(StringUtils.join(head.getShipName(), "/", head.getVoyage())); + return e; + }).collect(Collectors.toList()); + + excelWriter.write(details, writeSheet); + }); } } diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/CustomCellWriteHandler.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/CustomCellWriteHandler.java index fd1f708..62c63e7 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/CustomCellWriteHandler.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/excel/CustomCellWriteHandler.java @@ -3,6 +3,8 @@ package com.haitonggauto.rtosc.handler.excel; import com.alibaba.excel.write.handler.SheetWriteHandler; import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.metadata.holder.WriteWorkbookHolder; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddressList; @@ -52,99 +54,103 @@ public class CustomCellWriteHandler implements SheetWriteHandler { // 获取工作簿对象,用于创建存放下拉数据的字典sheet数据页 Workbook workbook = writeWorkbookHolder.getWorkbook(); - // 普通数据,迭代索引,用于存放下拉数据的字典sheet数据页命名 - int index = 1; - for (Map.Entry entry : map.entrySet()) { + if (MapUtils.isNotEmpty(map)) { + // 普通数据,迭代索引,用于存放下拉数据的字典sheet数据页命名 + int index = 1; + for (Map.Entry entry : map.entrySet()) { - // 设置存放下拉数据的字典sheet,并把这些sheet隐藏掉,这样用户交互更友好 - String dictSheetName = "dict_hide_sheet" + index; - Sheet dictSheet = workbook.createSheet(dictSheetName); - // 隐藏字典sheet页 - workbook.setSheetHidden(index++, true); + // 设置存放下拉数据的字典sheet,并把这些sheet隐藏掉,这样用户交互更友好 + String dictSheetName = "dict_hide_sheet" + index; + Sheet dictSheet = workbook.createSheet(dictSheetName); + // 隐藏字典sheet页 + workbook.setSheetHidden(index++, true); - // 设置下拉列表覆盖的行数,从第一行开始到最后一行,这里注意,Excel行的 - // 索引是从0开始的,我这边第0行是标题行,第1行开始时数据化,可根据实 - // 际业务设置真正的数据开始行,如果要设置到最后一行,那么一定注意, - // 最后一行的行索引是1048575,千万别写成1048576,不然会导致下拉列表 - // 失效,出不来 - CellRangeAddressList infoList = new CellRangeAddressList(1, 1048575, entry.getKey(), entry.getKey()); - int rowLen = entry.getValue().length; - for (int i = 0; i < rowLen; i++) { - // 向字典sheet写数据,从第一行开始写,此处可根据自己业务需要,自定 - // 义从第几行还是写,写的时候注意一下行索引是从0开始的即可 - dictSheet.createRow(i).createCell(0).setCellValue(entry.getValue()[i]); + // 设置下拉列表覆盖的行数,从第一行开始到最后一行,这里注意,Excel行的 + // 索引是从0开始的,我这边第0行是标题行,第1行开始时数据化,可根据实 + // 际业务设置真正的数据开始行,如果要设置到最后一行,那么一定注意, + // 最后一行的行索引是1048575,千万别写成1048576,不然会导致下拉列表 + // 失效,出不来 + CellRangeAddressList infoList = new CellRangeAddressList(1, 1048575, entry.getKey(), entry.getKey()); + int rowLen = entry.getValue().length; + for (int i = 0; i < rowLen; i++) { + // 向字典sheet写数据,从第一行开始写,此处可根据自己业务需要,自定 + // 义从第几行还是写,写的时候注意一下行索引是从0开始的即可 + dictSheet.createRow(i).createCell(0).setCellValue(entry.getValue()[i]); + } + + // 设置关联数据公式,这个格式跟Excel设置有效性数据的表达式是一样的 + String refers = dictSheetName + "!$A$1:$A$" + entry.getValue().length; + Name name = workbook.createName(); + name.setNameName(dictSheetName); + // 将关联公式和sheet页做关联 + name.setRefersToFormula(refers); + + // 将上面设置好的下拉列表字典sheet页和目标sheet关联起来 + DataValidationConstraint constraint = helper.createFormulaListConstraint(dictSheetName); + setValidation(sheet, helper, constraint, infoList); } - - // 设置关联数据公式,这个格式跟Excel设置有效性数据的表达式是一样的 - String refers = dictSheetName + "!$A$1:$A$" + entry.getValue().length; - Name name = workbook.createName(); - name.setNameName(dictSheetName); - // 将关联公式和sheet页做关联 - name.setRefersToFormula(refers); - - // 将上面设置好的下拉列表字典sheet页和目标sheet关联起来 - DataValidationConstraint constraint = helper.createFormulaListConstraint(dictSheetName); - setValidation(sheet, helper, constraint, infoList); } - - //检查类型-父类 - Sheet hideSheet = workbook.createSheet("site"); - workbook.setSheetHidden(workbook.getSheetIndex(hideSheet), false); - // 将具体的数据写入到每一行中,行开头为父级区域,后面是子区域。 - int rowId = 0; - Row proviRow = hideSheet.createRow(rowId++); - proviRow.createCell(0).setCellValue("大类列表"); - for (int i = 0; i < proInspNameArray.length; i++) { - Cell proviCell = proviRow.createCell(i + 1); - proviCell.setCellValue(proInspNameArray[i]); - } - //检查类型-子类 - Iterator keyIterator = inspNameArray.keySet().iterator(); - while (keyIterator.hasNext()) { - String key = keyIterator.next(); - List son = inspNameArray.get(key); - - Row row = hideSheet.createRow(rowId++); - row.createCell(0).setCellValue(key); - for (int i = 0; i < son.size(); i++) { - Cell cell = row.createCell(i + 1); - cell.setCellValue(son.get(i)); + if (MapUtils.isNotEmpty(inspNameArray) && MapUtils.isNotEmpty(probPropsNameArray)) { + //检查类型-父类 + Sheet hideSheet = workbook.createSheet("site"); + workbook.setSheetHidden(workbook.getSheetIndex(hideSheet), false); + // 将具体的数据写入到每一行中,行开头为父级区域,后面是子区域。 + int rowId = 0; + Row proviRow = hideSheet.createRow(rowId++); + proviRow.createCell(0).setCellValue("大类列表"); + for (int i = 0; i < proInspNameArray.length; i++) { + Cell proviCell = proviRow.createCell(i + 1); + proviCell.setCellValue(proInspNameArray[i]); } - // 添加名称管理器 - String range = getRange(1, rowId, son.size()); - Name name = workbook.createName(); - name.setNameName(key); - String formula = "site!" + range; - name.setRefersToFormula(formula); - } + //检查类型-子类 + Iterator keyIterator = inspNameArray.keySet().iterator(); + while (keyIterator.hasNext()) { + String key = keyIterator.next(); + List son = inspNameArray.get(key); - //问题属性 - Iterator probPropsNameIterator = probPropsNameArray.keySet().iterator(); - while (probPropsNameIterator.hasNext()) { - String key = probPropsNameIterator.next(); - List son = probPropsNameArray.get(key); - - Row row = hideSheet.createRow(rowId++); - row.createCell(0).setCellValue(key); - for (int i = 0; i < son.size(); i++) { - Cell cell = row.createCell(i + 1); - cell.setCellValue(son.get(i)); + Row row = hideSheet.createRow(rowId++); + row.createCell(0).setCellValue(key); + for (int i = 0; i < son.size(); i++) { + Cell cell = row.createCell(i + 1); + cell.setCellValue(son.get(i)); + } + // 添加名称管理器 + String range = getRange(1, rowId, son.size()); + Name name = workbook.createName(); + name.setNameName(key); + String formula = "site!" + range; + name.setRefersToFormula(formula); + } + + //问题属性 + Iterator probPropsNameIterator = probPropsNameArray.keySet().iterator(); + while (probPropsNameIterator.hasNext()) { + String key = probPropsNameIterator.next(); + List son = probPropsNameArray.get(key); + + Row row = hideSheet.createRow(rowId++); + row.createCell(0).setCellValue(key); + for (int i = 0; i < son.size(); i++) { + Cell cell = row.createCell(i + 1); + cell.setCellValue(son.get(i)); + } + // 添加名称管理器 + String range = getRange(1, rowId, son.size()); + Name name = workbook.createName(); + name.setNameName(key); + String formula = "site!" + range; + name.setRefersToFormula(formula); } - // 添加名称管理器 - String range = getRange(1, rowId, son.size()); - Name name = workbook.createName(); - name.setNameName(key); - String formula = "site!" + range; - name.setRefersToFormula(formula); } ///开始设置(大类小类)下拉框 DataValidationHelper dvHelper = sheet.getDataValidationHelper(); // 大类规则 - DataValidationConstraint expConstraint = dvHelper.createExplicitListConstraint(proInspNameArray); - CellRangeAddressList expRangeAddressList = new CellRangeAddressList(1, 1048575, 3, 3); - setValidation(sheet, dvHelper, expConstraint, expRangeAddressList); +// DataValidationConstraint expConstraint = dvHelper.createExplicitListConstraint(proInspNameArray); +// CellRangeAddressList expRangeAddressList = new CellRangeAddressList(1, 1048575, 3, 3); +// setValidation(sheet, dvHelper, expConstraint, expRangeAddressList); + //检查类型-子类 // 小类规则(各单元格按个设置) diff --git a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java index ee09b94..e5dd4f0 100644 --- a/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java +++ b/nuzar-customer-controller/src/main/java/com/haitonggauto/rtosc/handler/mapper/PoMapper.java @@ -97,5 +97,5 @@ public interface PoMapper { @Mapping(source = "cargo.cartType", target = "cartType") @Mapping(source = "cargo.vin", target = "vin") @Mapping(source = "head.company", target = "company") - InspectExportExcel inspectEntity2ExportExcel(CustomerExportInspect head, CustomerExportInspectCargo cargo); + ExportInspectExportExcel inspectEntity2ExportExcel(CustomerExportInspect head, CustomerExportInspectCargo cargo); } 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 7612fdb..acbc30c 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/CustomerExportLoadCargo.java b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportLoadCargo.java index a260f85..5d43412 100644 --- a/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportLoadCargo.java +++ b/nuzar-customer-repository/src/main/java/com/haitonggauto/rtosc/repository/entity/CustomerExportLoadCargo.java @@ -73,6 +73,14 @@ public class CustomerExportLoadCargo extends BaseEntity implements Serializable @ApiModelProperty(value = "作业状态") private String workStatus; + @TableField(exist = false) + @ApiModelProperty(value = "目的港ID") + private String destPortId; + + @TableField(exist = false) + @ApiModelProperty(value = "目的港") + private String destPort; + @TableField(exist = false) @ApiModelProperty(value = "基本信息") private CustomerExportLoad exportLoad;