|
|
|
@ -6,18 +6,17 @@ import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.deepoove.poi.XWPFTemplate; |
|
|
|
import com.deepoove.poi.data.*; |
|
|
|
import com.research.common.core.domain.entity.SysUser; |
|
|
|
import com.research.common.utils.DateUtils; |
|
|
|
import com.research.common.utils.file.FileUtils; |
|
|
|
import com.research.system.domain.dto.ClientPrjProOrgDto; |
|
|
|
import com.research.system.domain.dto.ExportDto; |
|
|
|
import com.research.system.domain.dto.GroupDto; |
|
|
|
import com.research.system.domain.dto.OutcomeDto; |
|
|
|
import com.research.system.domain.vo.ClientPrjProjInfoVo; |
|
|
|
import com.research.system.domain.vo.GroupVO; |
|
|
|
import com.research.system.domain.vo.OutcomeVo; |
|
|
|
import com.research.system.service.CooperatorService; |
|
|
|
import com.research.system.service.ExportService; |
|
|
|
import com.research.system.service.KtsGroupService; |
|
|
|
import com.research.system.service.OutcomeService; |
|
|
|
import com.research.system.service.*; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
@ -44,15 +43,25 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
|
|
|
|
@Resource |
|
|
|
private CooperatorService cooperatorService; |
|
|
|
@Value(value = "${research.reportTemplate}") |
|
|
|
private String reportTemplate; |
|
|
|
@Resource |
|
|
|
private KtsGroupService ktsGroupService; |
|
|
|
@Resource |
|
|
|
private OutcomeService outcomeService; |
|
|
|
@Resource |
|
|
|
private ISysUserService sysUserService; |
|
|
|
|
|
|
|
@Value(value = "${research.reportTemplate}") |
|
|
|
private String reportTemplate; |
|
|
|
@Value(value = "${research.reportGrTemplate}") |
|
|
|
private String reportGrTemplate; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public void export(HttpServletResponse response) { |
|
|
|
public void export(HttpServletResponse response, ExportDto.Query dto) { |
|
|
|
if (dto.getType() == 1) { |
|
|
|
exportGr(response, dto); |
|
|
|
return; |
|
|
|
} |
|
|
|
XWPFTemplate template = XWPFTemplate.compile(reportTemplate); |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
List<ClientPrjProjInfoVo.OrgVo> query = cooperatorService.query(new ClientPrjProOrgDto.Query()); |
|
|
|
@ -262,4 +271,238 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void exportGr(HttpServletResponse response, ExportDto.Query dto) { |
|
|
|
XWPFTemplate template = XWPFTemplate.compile(reportGrTemplate); |
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
SysUser sysUser = sysUserService.selectUserById(dto.getUserId()); |
|
|
|
if (sysUser == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
GroupDto.MemberQuery memberQuery = new GroupDto.MemberQuery(); |
|
|
|
memberQuery.setMemberPhone(sysUser.getPhonenumber()); |
|
|
|
List<GroupVO.MemberResult> memberResults = ktsGroupService.queryMemberList(memberQuery); |
|
|
|
if (CollUtil.isNotEmpty(memberResults)) { |
|
|
|
map.put("groupName", memberResults.stream().map(GroupVO.MemberResult::getKtGroupName).collect(Collectors.joining(","))); |
|
|
|
map.put("orgName", memberResults.stream().map(GroupVO.MemberResult::getProjOrgName).collect(Collectors.joining(","))); |
|
|
|
map.put("title", memberResults.stream().map(GroupVO.MemberResult::getTitleName).collect(Collectors.joining(","))); |
|
|
|
map.put("userType", memberResults.stream().map(GroupVO.MemberResult::getTypeName).collect(Collectors.joining(","))); |
|
|
|
map.put("rxTime", memberResults.get(0).getEnrollmentTime()); |
|
|
|
map.put("byTime", memberResults.get(0).getGraduationTime()); |
|
|
|
map.put("readingStatus", memberResults.get(0).getReadingStatusName()); |
|
|
|
map.put("type", memberResults.get(0).getCategoryName()); |
|
|
|
} |
|
|
|
map.put("eMail", sysUser.getEmail()); |
|
|
|
map.put("name", sysUser.getNickName()); |
|
|
|
map.put("phone", sysUser.getUserName()); |
|
|
|
ClientPrjProOrgDto.Query query1 = new ClientPrjProOrgDto.Query(); |
|
|
|
query1.setUsername(sysUser.getUserName()); |
|
|
|
List<ClientPrjProjInfoVo.OrgVo> query = cooperatorService.query(query1); |
|
|
|
|
|
|
|
//合作单位
|
|
|
|
if (CollUtil.isNotEmpty(query)) { |
|
|
|
TextRenderData text1 = Texts.of("单位名称").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("单位类型").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("负责人").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
for (ClientPrjProjInfoVo.OrgVo orgVo : query) { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
orgVo.getOrgName(), |
|
|
|
orgVo.getCategory() == null ? null : orgVo.getCategory() == 0 ? "申报单位" : "合作单位", |
|
|
|
orgVo.getOrgLeader() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table0", tableData); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//项目课题
|
|
|
|
List<GroupVO.Result> groupList = ktsGroupService.queryGroupList(new GroupDto.Query()); |
|
|
|
if (CollUtil.isNotEmpty(groupList)) { |
|
|
|
TextRenderData text1 = Texts.of("单位名称").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("课题").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("负责人").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
for (GroupVO.Result result : groupList) { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
result.getProjOrgName(), |
|
|
|
result.getKtGroupName(), |
|
|
|
result.getName() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table1", tableData); |
|
|
|
} |
|
|
|
//项目成果
|
|
|
|
OutcomeDto.Query query2 = new OutcomeDto.Query(); |
|
|
|
query2.setUsername(sysUser.getUserName()); |
|
|
|
List<OutcomeVo.Result> outcomeList = outcomeService.queryList(query2); |
|
|
|
if (CollUtil.isNotEmpty(outcomeList)) { |
|
|
|
//学术论文
|
|
|
|
Map<Long, List<OutcomeVo.Result>> outcomeMap = outcomeList.stream().collect(Collectors.groupingBy(OutcomeVo.Result::getCategoryId1)); |
|
|
|
List<OutcomeVo.Result> results = outcomeMap.get(1L); |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(results)) { |
|
|
|
TextRenderData text1 = Texts.of("单位名称").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("标题").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("作者").bold().fontSize(12).create(); |
|
|
|
TextRenderData text4 = Texts.of("类型").bold().fontSize(12).create(); |
|
|
|
TextRenderData text5 = Texts.of("刊物").bold().fontSize(12).create(); |
|
|
|
TextRenderData text6 = Texts.of("收录类别").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3, text4, text5, text6).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
for (OutcomeVo.Result result : results) { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
result.getProjOrgName(), |
|
|
|
result.getTitle(), |
|
|
|
result.getAuthors(), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "期刊论文" : result.getAchType() == 1 ? "会议论文" : result.getAchType() == 2 ? "报刊文章" : result.getAchType() == 3 ? "报纸文章" : "学位论文", |
|
|
|
result.getSource(), |
|
|
|
result.getCategoryId2() == null ? null : result.getCategoryId2() == 2 ? "SCI" : result.getCategoryId2() == 3 ? "中文期刊" : "其他" |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table2", tableData); |
|
|
|
} |
|
|
|
List<OutcomeVo.Result> results1 = outcomeMap.get(11L); |
|
|
|
if (CollUtil.isNotEmpty(results1)) { |
|
|
|
TextRenderData text1 = Texts.of("单位名称").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("专利名称").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("专利号").bold().fontSize(12).create(); |
|
|
|
TextRenderData text4 = Texts.of("专利类型").bold().fontSize(12).create(); |
|
|
|
TextRenderData text5 = Texts.of("专利权人").bold().fontSize(12).create(); |
|
|
|
TextRenderData text6 = Texts.of("专利内容").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3, text4, text5, text6).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
for (OutcomeVo.Result result : results1) { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
result.getProjOrgName(), |
|
|
|
result.getTitle(), |
|
|
|
result.getNo(), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "发明专利" : result.getAchType() == 1 ? "实用新型专利" : "外观设计专利", |
|
|
|
result.getAuthors(), |
|
|
|
result.getRemark() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table3", tableData); |
|
|
|
} |
|
|
|
|
|
|
|
//学术交流
|
|
|
|
List<OutcomeVo.Result> results2 = outcomeMap.get(71L); |
|
|
|
if (CollUtil.isNotEmpty(results2)) { |
|
|
|
TextRenderData text1 = Texts.of("标题").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("时间").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("地点").bold().fontSize(12).create(); |
|
|
|
TextRenderData text4 = Texts.of("参与人").bold().fontSize(12).create(); |
|
|
|
TextRenderData text5 = Texts.of("类型").bold().fontSize(12).create(); |
|
|
|
TextRenderData text6 = Texts.of("内容").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3, text4, text5, text6).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
for (OutcomeVo.Result result : results2) { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
result.getTitle(), |
|
|
|
DateUtil.format(result.getPublishDate(), "yyyy-MM-dd"), |
|
|
|
result.getPlace(), |
|
|
|
result.getAuthors(), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "学术讲座" : result.getAchType() == 1 ? "学术会议" : "外出进修", |
|
|
|
result.getRemark() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table4", tableData); |
|
|
|
} |
|
|
|
|
|
|
|
//高层次科技人才
|
|
|
|
List<OutcomeVo.Result> results3 = outcomeMap.get(5L); |
|
|
|
if (CollUtil.isNotEmpty(results3)) { |
|
|
|
Map<Long, List<OutcomeVo.Result>> collect = results3.stream().collect(Collectors.groupingBy(OutcomeVo.Result::getCategoryId2)); |
|
|
|
if (CollUtil.isNotEmpty(collect.get(6L))) { |
|
|
|
TextRenderData text1 = Texts.of("序号").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("姓名").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("性别").bold().fontSize(12).create(); |
|
|
|
TextRenderData text4 = Texts.of("年龄").bold().fontSize(12).create(); |
|
|
|
TextRenderData text5 = Texts.of("职称").bold().fontSize(12).create(); |
|
|
|
TextRenderData text6 = Texts.of("入选人才计划或项目").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3, text4, text5, text6).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
int i = 0; |
|
|
|
for (OutcomeVo.Result result : collect.get(6L)) { |
|
|
|
i++; |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
i + "", |
|
|
|
result.getName(), |
|
|
|
StrUtil.isNotEmpty(result.getSex()) ? "未知" : "0".equals(result.getSex()) ? "女" : "男", |
|
|
|
result.getAge() + "", |
|
|
|
result.getTitle(), |
|
|
|
result.getProjects() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table5", tableData); |
|
|
|
} |
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(collect.get(7L))) { |
|
|
|
TextRenderData text1 = Texts.of("序号").bold().fontSize(12).create(); |
|
|
|
TextRenderData text2 = Texts.of("姓名").bold().fontSize(12).create(); |
|
|
|
TextRenderData text3 = Texts.of("性别").bold().fontSize(12).create(); |
|
|
|
TextRenderData text4 = Texts.of("年龄").bold().fontSize(12).create(); |
|
|
|
TextRenderData text5 = Texts.of("职称晋升").bold().fontSize(12).create(); |
|
|
|
TextRenderData text6 = Texts.of("入选人才计划或项目").bold().fontSize(12).create(); |
|
|
|
RowRenderData headerRow = Rows.of(text1, text2, text3, text4, text5, text6).center().create(); |
|
|
|
Tables.TableBuilder of = Tables.of(headerRow); |
|
|
|
int i = 0; |
|
|
|
for (OutcomeVo.Result result : collect.get(6L)) { |
|
|
|
i++; |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
i + "", |
|
|
|
result.getName(), |
|
|
|
StrUtil.isNotEmpty(result.getSex()) ? "未知" : "0".equals(result.getSex()) ? "女" : "男", |
|
|
|
result.getAge() + "", |
|
|
|
result.getTitle(), |
|
|
|
result.getProjects() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
} |
|
|
|
TableRenderData tableData = of |
|
|
|
.create(); |
|
|
|
map.put("table6", tableData); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
String fileName = "个人报告.docx"; |
|
|
|
// String path = "C:/Users/zzc16/Desktop/项目运行报告.docx";
|
|
|
|
String path = "D:/Projects/research/server/profile/项目运行报告.docx"; |
|
|
|
template.render(map); |
|
|
|
//以文件形式输出
|
|
|
|
template.writeAndClose(Files.newOutputStream(Paths.get(path))); |
|
|
|
|
|
|
|
//3.写出到客户端
|
|
|
|
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); |
|
|
|
FileUtils.setAttachmentResponseHeader(response, fileName); |
|
|
|
FileUtils.writeBytes(path, response.getOutputStream()); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); // 输出详细的异常信息
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|