diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java index 2f097f7f..d8771396 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/api/user/PBomApi.java @@ -1,6 +1,7 @@ package com.nflg.product.bomnew.api.user; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.metadata.IPage; import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.starter.annotation.LogRecord; @@ -16,7 +17,9 @@ import com.nflg.product.bomnew.pojo.query.BomNewPbomParentQuery; import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.BomCopyCheckResultVO; import com.nflg.product.bomnew.pojo.vo.BomNewPbomParentVO; +import com.nflg.product.bomnew.pojo.vo.BomNewPbomWorkExcelVO; import com.nflg.product.bomnew.service.*; +import com.nflg.product.bomnew.util.EecExcelUtil; import com.nflg.product.bomnew.util.VUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -27,6 +30,7 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -75,35 +79,51 @@ public class PBomApi extends BaseApi { } @PostMapping("exportWorkDetailsListByPage") - @ApiOperation("导出工作列表--导出") + @ApiOperation("导出工作列表--按查询条件") @LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表") - public void exportWorkDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException { - bomNewPbomParentService.workDetailsExcel(query,response); + public void exportWorkDownLoad(@RequestBody BomNewPbomParentQuery query, HttpServletResponse response) throws IOException { + //bomNewPbomParentService.workDetailsExcel(query,response); + IPage data = bomNewPbomParentService.workDetailsListByPage(query); + List out = new ArrayList<>(); + if (!data.getRecords().isEmpty()) { + out = Convert.toList(BomNewPbomWorkExcelVO.class, data.getRecords()); + } + EecExcelUtil.export(response, out, BomNewPbomWorkExcelVO.class, "pbom明细列表"); } @PostMapping("releaseListDownLoad") - @ApiOperation("PBom已发布工作列表--导出") + @ApiOperation("导出正式列表--按查询条件") @LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表") public void releaseListDownLoad(@RequestBody BomNewPbomParentQuery query ,HttpServletResponse response) throws IOException { - bomNewPbomParentService.releaseListExcel(query,response); + //bomNewPbomParentService.releaseListExcel(query,response); + IPage data = bomNewPbomParentService.releaseListByPage(query); + List out = new ArrayList<>(); + if (!data.getRecords().isEmpty()) { + out = Convert.toList(BomNewPbomWorkExcelVO.class, data.getRecords()); + } + EecExcelUtil.export(response, out, BomNewPbomWorkExcelVO.class, "pbom已发布工作列表"); } -// @PostMapping("exportWorkDetailsListByPage") -// @ApiOperation("导出工作列表--导出") -// @LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表") -// public void exportWorkDownLoad(@RequestBody List bomRowIds, HttpServletResponse response) throws IOException { -// List data = bomNewPbomParentService.exportExcel(bomRowIds); -// //new Workbook().addSheet(new ListSheet<>(data)).writeTo(response.getOutputStream()); -// EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom明细列表"); -// } -// -// @PostMapping("releaseListDownLoad") -// @ApiOperation("PBom已发布工作列表--导出") -// @LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表") -// public void releaseListDownLoad(@RequestBody List bomRowIds, HttpServletResponse response) throws IOException { -// List data = bomNewPbomParentService.exportExcel(bomRowIds); -// EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom已发布明细列表"); -// } + @PostMapping("exportWorkDetailsListByIds") + @ApiOperation("导出工作列表--按rowid") + @LogRecord(success = "PBom-导出工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-导出工作列表") + public void exportWorkDownLoad(@RequestBody List bomRowIds, HttpServletResponse response) throws IOException { + VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的行"); + + List data = bomNewPbomParentService.exportExcel(bomRowIds); + //new Workbook().addSheet(new ListSheet<>(data)).writeTo(response.getOutputStream()); + EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom明细列表"); + } + + @PostMapping("releaseListDownLoadByIds") + @ApiOperation("导出正式列表--按rowid") + @LogRecord(success = "PBom-导出已发布工作列表,操作结果:{{#_ret}}", bizNo = "",type = "PBom-已发布工作列表") + public void releaseListDownLoad(@RequestBody List bomRowIds, HttpServletResponse response) throws IOException { + VUtils.isTure(CollUtil.isEmpty(bomRowIds)).throwMessage("请选择要导出的行"); + + List data = bomNewPbomParentService.exportExcel(bomRowIds); + EecExcelUtil.export(response, data, BomNewPbomWorkExcelVO.class, "pbom已发布明细列表"); + } @GetMapping("getChild") @ApiOperation("获取子级") diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index ddbf0aef..caee4bc6 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -112,7 +112,7 @@ public class BomNewPbomParentService extends ServiceImpl parentMaterialByMaterialNo = getParentMaterialByMaterialNo(materialNo).stream().collect(Collectors.toList()); + List parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo)); parentMaterialByMaterialNo.add(materialNo); if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { List parents = this.getBaseMapper().getParentForMaterialNoSeach(StrUtil.isBlank(userRoleService.getUserFactory()) ? userRoleService.getUserFactory() : query.getFacCode(), parentMaterialByMaterialNo); @@ -131,7 +131,7 @@ public class BomNewPbomParentService extends ServiceImpl(); + return new Page<>(); } else { Page result = this.getBaseMapper().workDetailsListByPage(new Page<>(query.getPage(), query.getPageSize()), query, userRoleService.getUserFactory()); materialMainService.intiMaterialInfo(result.getRecords(), EBomConstant.EBOM_IGNORED_FIELDS_INIT_MATERIAL_DEFAULT); @@ -141,8 +141,8 @@ public class BomNewPbomParentService extends ServiceImpl handSeachToTree(List parents, List childs) { Page resutlData = new Page<>(); - Set parentSet = parents.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); - Set childSet = childs.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); + Set parentSet = parents.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet()); + Set childSet = childs.stream().map(BaseMaterialVO::getMaterialNo).collect(Collectors.toSet()); Set difference = Sets.difference(parentSet, childSet); List resultParents = parents.stream().filter(u -> difference.contains(u.getMaterialNo())).collect(Collectors.toList()); resutlData.setTotal(difference.size());