Browse Source

update

yangzhenli
V26772074 1 year ago
parent
commit
3bf76dd12e
  1. 56
      jnpf-tendering-biz/src/main/java/jnpf/service/impl/ExpertServiceImpl.java
  2. 88
      jnpf-tendering-biz/src/main/java/jnpf/service/impl/LotteryProjectServiceImpl.java
  3. BIN
      jnpf-tendering-server/src/main/resources/jnpf/templete/招投标公司打印.docx
  4. BIN
      jnpf-tendering-server/src/main/resources/jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx

56
jnpf-tendering-biz/src/main/java/jnpf/service/impl/ExpertServiceImpl.java

@ -189,33 +189,33 @@ public class ExpertServiceImpl extends ServiceImpl<ExpertMapper, Expert> impleme
if (StrUtil.isBlank(param.getExpertName())) { if (StrUtil.isBlank(param.getExpertName())) {
throw new DataException("专家名称不能为空"); throw new DataException("专家名称不能为空");
} }
if (StrUtil.isBlank(param.getExpertGroup())) { // if (StrUtil.isBlank(param.getExpertGroup())) {
throw new DataException("专家组别不能为空"); // throw new DataException("专家组别不能为空");
} // }
if (StrUtil.isBlank(param.getSex())) { // if (StrUtil.isBlank(param.getSex())) {
throw new DataException("专家性别不能为空"); // throw new DataException("专家性别不能为空");
} // }
if (StrUtil.isBlank(param.getPhoneNumber())) { // if (StrUtil.isBlank(param.getPhoneNumber())) {
throw new DataException("专家电话不能为空"); // throw new DataException("专家电话不能为空");
} // }
if (StrUtil.isBlank(param.getExpertSources())) { // if (StrUtil.isBlank(param.getExpertSources())) {
throw new DataException("专家来源不能为空"); // throw new DataException("专家来源不能为空");
} // }
if (StrUtil.isBlank(param.getWorkUnit())) { // if (StrUtil.isBlank(param.getWorkUnit())) {
throw new DataException("工作单位不能为空"); // throw new DataException("工作单位不能为空");
} // }
if (StrUtil.isBlank(param.getPost())) { // if (StrUtil.isBlank(param.getPost())) {
throw new DataException("职务不能为空"); // throw new DataException("职务不能为空");
} // }
if (StrUtil.isBlank(param.getTechnicalPosition())) { // if (StrUtil.isBlank(param.getTechnicalPosition())) {
throw new DataException("专业技术职称不能为空"); // throw new DataException("专业技术职称不能为空");
} // }
if (StrUtil.isBlank(param.getProfessionalExpertise())) { // if (StrUtil.isBlank(param.getProfessionalExpertise())) {
throw new DataException("专业特长不能为空"); // throw new DataException("专业特长不能为空");
} // }
if (StrUtil.isBlank(param.getStatus())) { // if (StrUtil.isBlank(param.getStatus())) {
throw new DataException("专家状态不能为空"); // throw new DataException("专家状态不能为空");
} // }
break; break;
case "2": case "2":
if (CollectionUtil.isEmpty(param.getContactInformation())) { if (CollectionUtil.isEmpty(param.getContactInformation())) {
@ -312,7 +312,7 @@ public class ExpertServiceImpl extends ServiceImpl<ExpertMapper, Expert> impleme
if (StrUtil.isNotBlank(row.getCell(10).getStringCellValue())){ if (StrUtil.isNotBlank(row.getCell(10).getStringCellValue())){
addParam.setWorkingYears(row.getCell(10).getStringCellValue()); addParam.setWorkingYears(row.getCell(10).getStringCellValue());
} }
addParam.setStatus("1"); addParam.setStatus("0");
addParamList.add(addParam); addParamList.add(addParam);
} }
for (ExpertDto.AddParam addParam : addParamList) { for (ExpertDto.AddParam addParam : addParamList) {

88
jnpf-tendering-biz/src/main/java/jnpf/service/impl/LotteryProjectServiceImpl.java

@ -81,7 +81,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
lotteryProject.setType(LotteryProjectDto.TypeEnum.ONESELF.getCode()); lotteryProject.setType(LotteryProjectDto.TypeEnum.ONESELF.getCode());
lotteryProject.setStatus(LotteryProjectDto.StatusEnum.TO_BE_EXTRACTED.getCode()); lotteryProject.setStatus(LotteryProjectDto.StatusEnum.TO_BE_EXTRACTED.getCode());
lotteryProject.setStatusName(LotteryProjectDto.StatusEnum.TO_BE_EXTRACTED.getDescribe()); lotteryProject.setStatusName(LotteryProjectDto.StatusEnum.TO_BE_EXTRACTED.getDescribe());
if (null != param.getBidEvaluationTime()) {
lotteryProject.setBidOpeningTime(LocalDate.parse(LocalDateTimeUtil.format(param.getBidEvaluationTime(), "yyyy-MM-dd"))); lotteryProject.setBidOpeningTime(LocalDate.parse(LocalDateTimeUtil.format(param.getBidEvaluationTime(), "yyyy-MM-dd")));
}
UserInfo userInfo = userProvider.get(); UserInfo userInfo = userProvider.get();
lotteryProject.setUserDeptId(userInfo.getOrganizeId()); lotteryProject.setUserDeptId(userInfo.getOrganizeId());
//添加根子单数据 //添加根子单数据
@ -102,7 +104,9 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
throw new DataException("id不能为空"); throw new DataException("id不能为空");
} }
LotteryProject lotteryProject = BeanUtil.copyProperties(param, LotteryProject.class); LotteryProject lotteryProject = BeanUtil.copyProperties(param, LotteryProject.class);
if (null != param.getBidEvaluationTime()) {
lotteryProject.setBidOpeningTime(LocalDate.parse(LocalDateTimeUtil.format(param.getBidEvaluationTime(), "yyyy-MM-dd"))); lotteryProject.setBidOpeningTime(LocalDate.parse(LocalDateTimeUtil.format(param.getBidEvaluationTime(), "yyyy-MM-dd")));
}
UserInfo userInfo = userProvider.get(); UserInfo userInfo = userProvider.get();
; ;
lotteryProject.setUpdateId(userInfo.getUserId()); lotteryProject.setUpdateId(userInfo.getUserId());
@ -332,18 +336,18 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
} }
//校验打印类型 //校验打印类型
LotteryProject lotteryProject = this.getById(lotteryReview.getRelationId()); LotteryProject lotteryProject = this.getById(lotteryReview.getRelationId());
if (null==lotteryReview.getExtractExpertsInfo()){ if (null == lotteryReview.getExtractExpertsInfo()) {
throw new DataException("未抽取专家,无法打印[2]"); throw new DataException("未抽取专家,无法打印[2]");
} }
List<LotteryProjectDto.ExtractExpertsInfo> extractExpertsInfo = lotteryReview.getExtractExpertsInfo().stream().filter(e->e.getStatus().equals(LotteryProjectDto.ConfirmEnum.JOIN.getCode())).collect(Collectors.toList()); List<LotteryProjectDto.ExtractExpertsInfo> extractExpertsInfo = lotteryReview.getExtractExpertsInfo().stream().filter(e -> e.getStatus().equals(LotteryProjectDto.ConfirmEnum.JOIN.getCode())).collect(Collectors.toList());
DownloadVO vo = DownloadVO.builder().build(); DownloadVO vo = DownloadVO.builder().build();
switch (lotteryProject.getLotteryType()){ switch (lotteryProject.getLotteryType()) {
case "1": case "1":
if (CollectionUtil.isEmpty(extractExpertsInfo)){ if (CollectionUtil.isEmpty(extractExpertsInfo)) {
throw new DataException("暂未有确认专家,无法打印"); throw new DataException("暂未有确认专家,无法打印");
} }
try { try {
MockMultipartFile mockMultipartFile = expertPrinting("专家抽取结果打印.docx", extractExpertsInfo); MockMultipartFile mockMultipartFile = expertPrinting("专家抽取结果打印.docx", extractExpertsInfo, lotteryProject.getProjectName());
String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY); String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY);
FileInfo fileInfo = fileUploadApi.uploadFile(mockMultipartFile, temporaryFilePath, "专家抽取结果打印.docx"); FileInfo fileInfo = fileUploadApi.uploadFile(mockMultipartFile, temporaryFilePath, "专家抽取结果打印.docx");
vo.setName(fileInfo.getFilename()); vo.setName(fileInfo.getFilename());
@ -354,16 +358,16 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
break; break;
case "2": case "2":
try { try {
if (CollectionUtil.isEmpty(extractExpertsInfo)){ if (CollectionUtil.isEmpty(extractExpertsInfo)) {
throw new DataException("暂未有确认公司,无法打印"); throw new DataException("暂未有确认公司,无法打印");
} }
MockMultipartFile mockMultipartFile = companyPrinting("招投标公司抽取结果打印.docx", extractExpertsInfo); MockMultipartFile mockMultipartFile = companyPrinting("招投标公司抽取结果打印.docx", extractExpertsInfo,lotteryProject.getProjectName());
String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY); String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY);
FileInfo fileInfo = fileUploadApi.uploadFile(mockMultipartFile, temporaryFilePath, "招投标公司抽取结果打印.docx"); FileInfo fileInfo = fileUploadApi.uploadFile(mockMultipartFile, temporaryFilePath, "招投标公司抽取结果打印.docx");
vo.setName(fileInfo.getFilename()); vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + "招投标公司抽取结果打印.docx"); vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + "招投标公司抽取结果打印.docx");
} catch (Exception e) { } catch (Exception e) {
log.error("专家抽取结果打印异常", e); log.error("公司抽取结果打印异常", e);
} }
break; break;
} }
@ -372,27 +376,42 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
return vo; return vo;
} }
private MockMultipartFile expertPrinting(String fileName, List<LotteryProjectDto.ExtractExpertsInfo> data) throws Exception { private MockMultipartFile expertPrinting(String fileName, List<LotteryProjectDto.ExtractExpertsInfo> data, String projectName) throws Exception {
try (InputStream inputStream = ResourceUtil.getStream("jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx"); try (InputStream inputStream = ResourceUtil.getStream("jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx");
XWPFDocument doc = new XWPFDocument(inputStream)) { XWPFDocument doc = new XWPFDocument(inputStream)) {
// 找到标记位置的段落 // 找到标记位置的段落
XWPFParagraph placeholderParagraph = null; XWPFParagraph placeholderParagraph = null;
XWPFParagraph textParagraph = null;
for (XWPFParagraph paragraph : doc.getParagraphs()) { for (XWPFParagraph paragraph : doc.getParagraphs()) {
if (paragraph.getText().contains("{{table_here}}")) { if (paragraph.getText().contains("{{table_here}}")) {
placeholderParagraph = paragraph; placeholderParagraph = paragraph;
break; break;
} }
if (paragraph.getText().contains("{{projectName}}")) {
textParagraph = paragraph;
}
} }
if (placeholderParagraph == null) { if (placeholderParagraph == null) {
throw new IllegalStateException("Cannot find placeholder in the document."); throw new IllegalStateException("Cannot find placeholder in the document.");
} }
// 删除包含占位符的段落 // 删除包含占位符的段落
XWPFRun run = placeholderParagraph.getRuns().get(0); XWPFRun run = placeholderParagraph.getRuns().get(0);
run.setText(run.getText(0).replace("{{table_here}}", ""), 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<LotteryProjectMapper,
} }
} }
private MockMultipartFile companyPrinting(String fileName, List<LotteryProjectDto.ExtractExpertsInfo> data) throws Exception { private MockMultipartFile companyPrinting(String fileName, List<LotteryProjectDto.ExtractExpertsInfo> data, String projectName) throws Exception {
try (InputStream inputStream = ResourceUtil.getStream("jnpf/templete/招投标公司打印.docx"); try (InputStream inputStream = ResourceUtil.getStream("jnpf/templete/招投标公司打印.docx");
XWPFDocument doc = new XWPFDocument(inputStream)) { XWPFDocument doc = new XWPFDocument(inputStream)) {
// 找到标记位置的段落 // 找到标记位置的段落
XWPFParagraph placeholderParagraph = null; XWPFParagraph placeholderParagraph = null;
XWPFParagraph textParagraph = null;
for (XWPFParagraph paragraph : doc.getParagraphs()) { for (XWPFParagraph paragraph : doc.getParagraphs()) {
if (paragraph.getText().contains("{{table_here}}")) { if (paragraph.getText().contains("{{table_here}}")) {
placeholderParagraph = paragraph; placeholderParagraph = paragraph;
break; break;
} }
if (paragraph.getText().contains("{{projectName}}")) {
textParagraph = paragraph;
}
} }
if (placeholderParagraph == null) { if (placeholderParagraph == null) {
@ -485,6 +508,16 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
XWPFRun run = placeholderParagraph.getRuns().get(0); XWPFRun run = placeholderParagraph.getRuns().get(0);
run.setText(run.getText(0).replace("{{table_here}}", ""), 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);
}
// 在占位符位置插入表格 // 在占位符位置插入表格
// 插入表格到占位符位置后 // 插入表格到占位符位置后
// XWPFTable table = doc.createTable(); // XWPFTable table = doc.createTable();
@ -502,7 +535,7 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
// // 填充表格数据 // // 填充表格数据
for (LotteryProjectDto.ExtractExpertsInfo datum : data) { for (LotteryProjectDto.ExtractExpertsInfo datum : data) {
int i = 0; int i = 0;
int startRowNum=1; int startRowNum = 1;
for (ExpertDto.ContactInformation contactInformation : datum.getContactInformation()) { for (ExpertDto.ContactInformation contactInformation : datum.getContactInformation()) {
XWPFTableRow row = table.createRow(); XWPFTableRow row = table.createRow();
row.getCell(0).setText(datum.getId()); row.getCell(0).setText(datum.getId());
@ -512,15 +545,15 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
row.getCell(3).setText(contactInformation.getContactPhone()); row.getCell(3).setText(contactInformation.getContactPhone());
row.getCell(4).setText(datum.getRemark()); row.getCell(4).setText(datum.getRemark());
if (i == 0) { if (i == 0) {
startRowNum=table.getRows().indexOf(row); startRowNum = table.getRows().indexOf(row);
datum.setId(""); datum.setId("");
datum.setCompanyName(""); datum.setCompanyName("");
} }
i++; i++;
} }
mergeCellsVertically(table,0,startRowNum,(datum.getContactInformation().size()-1)+startRowNum); mergeCellsVertically(table, 0, startRowNum, (datum.getContactInformation().size() - 1) + startRowNum);
mergeCellsVertically(table,1,startRowNum,(datum.getContactInformation().size()-1)+startRowNum); mergeCellsVertically(table, 1, startRowNum, (datum.getContactInformation().size() - 1) + startRowNum);
mergeCellsVertically(table,4,startRowNum,(datum.getContactInformation().size()-1)+startRowNum); mergeCellsVertically(table, 4, startRowNum, (datum.getContactInformation().size() - 1) + startRowNum);
} }
// 保存Word文档 // 保存Word文档
@ -670,16 +703,20 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
"]"; "]";
// List<LotteryProjectDto.ExtractExpertsInfo> data = JSON.parseArray(s, LotteryProjectDto.ExtractExpertsInfo.class); // List<LotteryProjectDto.ExtractExpertsInfo> data = JSON.parseArray(s, LotteryProjectDto.ExtractExpertsInfo.class);
List<LotteryProjectDto.ExtractExpertsInfo> data = JSON.parseArray(s2, LotteryProjectDto.ExtractExpertsInfo.class); List<LotteryProjectDto.ExtractExpertsInfo> 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)) { XWPFDocument doc = new XWPFDocument(inputStream)) {
// 找到标记位置的段落 // 找到标记位置的段落
XWPFParagraph placeholderParagraph = null; XWPFParagraph placeholderParagraph = null;
XWPFParagraph textParagraph = null;
for (XWPFParagraph paragraph : doc.getParagraphs()) { for (XWPFParagraph paragraph : doc.getParagraphs()) {
if (paragraph.getText().contains("{{table_here}}")) { if (paragraph.getText().contains("{{table_here}}")) {
placeholderParagraph = paragraph; placeholderParagraph = paragraph;
break; break;
} }
if (paragraph.getText().contains("{{projectName}}")) {
textParagraph = paragraph;
}
} }
if (placeholderParagraph == null) { if (placeholderParagraph == null) {
@ -689,6 +726,15 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
// 删除包含占位符的段落 // 删除包含占位符的段落
XWPFRun run = placeholderParagraph.getRuns().get(0); XWPFRun run = placeholderParagraph.getRuns().get(0);
run.setText(run.getText(0).replace("{{table_here}}", ""), 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}}","测试2"), 0);
}
// 在占位符位置插入表格 // 在占位符位置插入表格
// 插入表格到占位符位置后 // 插入表格到占位符位置后
@ -706,7 +752,7 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
// // 填充表格数据 // // 填充表格数据
for (LotteryProjectDto.ExtractExpertsInfo datum : data) { for (LotteryProjectDto.ExtractExpertsInfo datum : data) {
int i = 0; int i = 0;
int startRowNum=1; int startRowNum = 1;
for (ExpertDto.ContactInformation contactInformation : datum.getContactInformation()) { for (ExpertDto.ContactInformation contactInformation : datum.getContactInformation()) {
XWPFTableRow row = table.createRow(); XWPFTableRow row = table.createRow();
row.getCell(0).setText(datum.getId()); row.getCell(0).setText(datum.getId());
@ -716,15 +762,15 @@ public class LotteryProjectServiceImpl extends ServiceImpl<LotteryProjectMapper,
row.getCell(3).setText(contactInformation.getContactPhone()); row.getCell(3).setText(contactInformation.getContactPhone());
row.getCell(4).setText(datum.getRemark()); row.getCell(4).setText(datum.getRemark());
if (i == 0) { if (i == 0) {
startRowNum=table.getRows().indexOf(row); startRowNum = table.getRows().indexOf(row);
datum.setId(""); datum.setId("");
datum.setCompanyName(""); datum.setCompanyName("");
} }
i++; i++;
} }
mergeCellsVertically(table,0,startRowNum,(datum.getContactInformation().size()-1)+startRowNum); mergeCellsVertically(table, 0, startRowNum, (datum.getContactInformation().size() - 1) + startRowNum);
mergeCellsVertically(table,1,startRowNum,(datum.getContactInformation().size()-1)+startRowNum); mergeCellsVertically(table, 1, startRowNum, (datum.getContactInformation().size() - 1) + startRowNum);
mergeCellsVertically(table,4,startRowNum,(datum.getContactInformation().size()-1)+startRowNum); mergeCellsVertically(table, 4, startRowNum, (datum.getContactInformation().size() - 1) + startRowNum);
} }
// // 在该行中添加三个单元格 // // 在该行中添加三个单元格

BIN
jnpf-tendering-server/src/main/resources/jnpf/templete/招投标公司打印.docx

Binary file not shown.

BIN
jnpf-tendering-server/src/main/resources/jnpf/templete/浙江出版传媒股份有限公司ERP系统建设项目.docx

Binary file not shown.
Loading…
Cancel
Save