diff --git a/jnpf-tendering-biz/src/main/java/jnpf/service/impl/ExpertServiceImpl.java b/jnpf-tendering-biz/src/main/java/jnpf/service/impl/ExpertServiceImpl.java index c328f90..87ed1e9 100644 --- a/jnpf-tendering-biz/src/main/java/jnpf/service/impl/ExpertServiceImpl.java +++ b/jnpf-tendering-biz/src/main/java/jnpf/service/impl/ExpertServiceImpl.java @@ -189,33 +189,33 @@ public class ExpertServiceImpl extends ServiceImpl impleme if (StrUtil.isBlank(param.getExpertName())) { throw new DataException("专家名称不能为空"); } - if (StrUtil.isBlank(param.getExpertGroup())) { - throw new DataException("专家组别不能为空"); - } - if (StrUtil.isBlank(param.getSex())) { - throw new DataException("专家性别不能为空"); - } - if (StrUtil.isBlank(param.getPhoneNumber())) { - throw new DataException("专家电话不能为空"); - } - if (StrUtil.isBlank(param.getExpertSources())) { - throw new DataException("专家来源不能为空"); - } - if (StrUtil.isBlank(param.getWorkUnit())) { - throw new DataException("工作单位不能为空"); - } - if (StrUtil.isBlank(param.getPost())) { - throw new DataException("职务不能为空"); - } - if (StrUtil.isBlank(param.getTechnicalPosition())) { - throw new DataException("专业技术职称不能为空"); - } - if (StrUtil.isBlank(param.getProfessionalExpertise())) { - throw new DataException("专业特长不能为空"); - } - if (StrUtil.isBlank(param.getStatus())) { - throw new DataException("专家状态不能为空"); - } +// if (StrUtil.isBlank(param.getExpertGroup())) { +// throw new DataException("专家组别不能为空"); +// } +// if (StrUtil.isBlank(param.getSex())) { +// throw new DataException("专家性别不能为空"); +// } +// if (StrUtil.isBlank(param.getPhoneNumber())) { +// throw new DataException("专家电话不能为空"); +// } +// if (StrUtil.isBlank(param.getExpertSources())) { +// throw new DataException("专家来源不能为空"); +// } +// if (StrUtil.isBlank(param.getWorkUnit())) { +// throw new DataException("工作单位不能为空"); +// } +// if (StrUtil.isBlank(param.getPost())) { +// throw new DataException("职务不能为空"); +// } +// if (StrUtil.isBlank(param.getTechnicalPosition())) { +// throw new DataException("专业技术职称不能为空"); +// } +// if (StrUtil.isBlank(param.getProfessionalExpertise())) { +// throw new DataException("专业特长不能为空"); +// } +// if (StrUtil.isBlank(param.getStatus())) { +// throw new DataException("专家状态不能为空"); +// } break; case "2": if (CollectionUtil.isEmpty(param.getContactInformation())) { @@ -312,7 +312,7 @@ public class ExpertServiceImpl extends ServiceImpl impleme if (StrUtil.isNotBlank(row.getCell(10).getStringCellValue())){ addParam.setWorkingYears(row.getCell(10).getStringCellValue()); } - addParam.setStatus("1"); + addParam.setStatus("0"); addParamList.add(addParam); } for (ExpertDto.AddParam addParam : addParamList) { diff --git a/jnpf-tendering-biz/src/main/java/jnpf/service/impl/LotteryProjectServiceImpl.java b/jnpf-tendering-biz/src/main/java/jnpf/service/impl/LotteryProjectServiceImpl.java index 65de35b..4a14512 100644 --- a/jnpf-tendering-biz/src/main/java/jnpf/service/impl/LotteryProjectServiceImpl.java +++ b/jnpf-tendering-biz/src/main/java/jnpf/service/impl/LotteryProjectServiceImpl.java @@ -81,7 +81,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl extractExpertsInfo = lotteryReview.getExtractExpertsInfo().stream().filter(e->e.getStatus().equals(LotteryProjectDto.ConfirmEnum.JOIN.getCode())).collect(Collectors.toList()); + List extractExpertsInfo = lotteryReview.getExtractExpertsInfo().stream().filter(e -> e.getStatus().equals(LotteryProjectDto.ConfirmEnum.JOIN.getCode())).collect(Collectors.toList()); DownloadVO vo = DownloadVO.builder().build(); - switch (lotteryProject.getLotteryType()){ + switch (lotteryProject.getLotteryType()) { case "1": - if (CollectionUtil.isEmpty(extractExpertsInfo)){ + if (CollectionUtil.isEmpty(extractExpertsInfo)) { throw new DataException("暂未有确认专家,无法打印"); } try { - MockMultipartFile mockMultipartFile = expertPrinting("专家抽取结果打印.docx", extractExpertsInfo); + MockMultipartFile mockMultipartFile = expertPrinting("专家抽取结果打印.docx", extractExpertsInfo, lotteryProject.getProjectName()); String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY); FileInfo fileInfo = fileUploadApi.uploadFile(mockMultipartFile, temporaryFilePath, "专家抽取结果打印.docx"); vo.setName(fileInfo.getFilename()); @@ -354,16 +358,16 @@ public class LotteryProjectServiceImpl extends ServiceImpl data) throws Exception { + private MockMultipartFile expertPrinting(String fileName, List data, String projectName) throws Exception { try (InputStream inputStream = ResourceUtil.getStream("jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx"); XWPFDocument doc = new XWPFDocument(inputStream)) { // 找到标记位置的段落 XWPFParagraph placeholderParagraph = null; + XWPFParagraph textParagraph = null; for (XWPFParagraph paragraph : doc.getParagraphs()) { if (paragraph.getText().contains("{{table_here}}")) { placeholderParagraph = paragraph; break; } + if (paragraph.getText().contains("{{projectName}}")) { + textParagraph = paragraph; + } } if (placeholderParagraph == null) { throw new IllegalStateException("Cannot find placeholder in the document."); } + // 删除包含占位符的段落 XWPFRun run = placeholderParagraph.getRuns().get(0); run.setText(run.getText(0).replace("{{table_here}}", ""), 0); + //替换项目名称 + if (textParagraph != null) { + String join = StrUtil.join("", textParagraph.getRuns().stream().map(te -> te.getText(0)).collect(Collectors.toList())); + XWPFRun xwpfRun = textParagraph.getRuns().get(0); + for (XWPFRun textParagraphRun : textParagraph.getRuns()) { + textParagraphRun.setText(""); + } + xwpfRun.setText(join.replace("{{projectName}}",projectName), 0); + } + // 在占位符位置插入表格 // 插入表格到占位符位置后 @@ -463,18 +482,22 @@ public class LotteryProjectServiceImpl extends ServiceImpl data) throws Exception { + private MockMultipartFile companyPrinting(String fileName, List data, String projectName) throws Exception { try (InputStream inputStream = ResourceUtil.getStream("jnpf/templete/招投标公司打印.docx"); XWPFDocument doc = new XWPFDocument(inputStream)) { // 找到标记位置的段落 XWPFParagraph placeholderParagraph = null; + XWPFParagraph textParagraph = null; for (XWPFParagraph paragraph : doc.getParagraphs()) { if (paragraph.getText().contains("{{table_here}}")) { placeholderParagraph = paragraph; break; } + if (paragraph.getText().contains("{{projectName}}")) { + textParagraph = paragraph; + } } if (placeholderParagraph == null) { @@ -485,6 +508,16 @@ public class LotteryProjectServiceImpl extends ServiceImpl te.getText(0)).collect(Collectors.toList())); + XWPFRun xwpfRun = textParagraph.getRuns().get(0); + for (XWPFRun textParagraphRun : textParagraph.getRuns()) { + textParagraphRun.setText(""); + } + xwpfRun.setText(join.replace("{{projectName}}",projectName), 0); + } + // 在占位符位置插入表格 // 插入表格到占位符位置后 // XWPFTable table = doc.createTable(); @@ -502,7 +535,7 @@ public class LotteryProjectServiceImpl extends ServiceImpl data = JSON.parseArray(s, LotteryProjectDto.ExtractExpertsInfo.class); List data = JSON.parseArray(s2, LotteryProjectDto.ExtractExpertsInfo.class); - try (InputStream inputStream = new FileInputStream(new File("/Users/yangzhenli/Documents/项目/jnpf/浙江出版传媒股份有限公司ERP系统建设项目.docx")); + try (InputStream inputStream = new FileInputStream(new File("/Users/yangzhenli/code/jnpfsoft-jnpf-jnpf-java-cloud-/jnpf-tendering/jnpf-tendering-server/src/main/resources/jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx")); XWPFDocument doc = new XWPFDocument(inputStream)) { // 找到标记位置的段落 XWPFParagraph placeholderParagraph = null; + XWPFParagraph textParagraph = null; for (XWPFParagraph paragraph : doc.getParagraphs()) { if (paragraph.getText().contains("{{table_here}}")) { placeholderParagraph = paragraph; break; } + if (paragraph.getText().contains("{{projectName}}")) { + textParagraph = paragraph; + } } if (placeholderParagraph == null) { @@ -689,6 +726,15 @@ public class LotteryProjectServiceImpl extends ServiceImpl te.getText(0)).collect(Collectors.toList())); + XWPFRun xwpfRun = textParagraph.getRuns().get(0); + for (XWPFRun textParagraphRun : textParagraph.getRuns()) { + textParagraphRun.setText(""); + } + xwpfRun.setText(join.replace("{{projectName}}","测试2"), 0); + } // 在占位符位置插入表格 // 插入表格到占位符位置后 @@ -706,7 +752,7 @@ public class LotteryProjectServiceImpl extends ServiceImpl