|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.json.JSONUtil; |
|
|
|
import com.deepoove.poi.XWPFTemplate; |
|
|
|
import com.deepoove.poi.data.*; |
|
|
|
import com.research.common.core.domain.entity.SysUser; |
|
|
|
@ -13,9 +14,11 @@ 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.po.KtsKtGroupMember; |
|
|
|
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.persist.mapper.KtsKtGroupMemberMapper; |
|
|
|
import com.research.system.service.*; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.http.MediaType; |
|
|
|
@ -49,6 +52,8 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
private OutcomeService outcomeService; |
|
|
|
@Resource |
|
|
|
private ISysUserService sysUserService; |
|
|
|
@Resource |
|
|
|
private KtsKtGroupMemberMapper ktsKtGroupMemberMapper; |
|
|
|
|
|
|
|
@Value(value = "${research.reportTemplate}") |
|
|
|
private String reportTemplate; |
|
|
|
@ -127,7 +132,16 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
result.getProjOrgName(), |
|
|
|
result.getTitle(), |
|
|
|
result.getAuthors(), |
|
|
|
//[{"label":"Ma,Yongsheng","value":"","type":0},
|
|
|
|
// {"label":"Yang,Wenming","value":"","type":1},
|
|
|
|
// {"label":"Lin,Qitai","value":"","type":1},
|
|
|
|
// {"label":"Li,Meiming","value":"","type":2},
|
|
|
|
// {"label":"Li,Zehao","value":"","type":0},
|
|
|
|
// {"label":"Xing,Yugang","value":"","type":0},
|
|
|
|
// {"label":"Wei,Lei","value":"","type":0},
|
|
|
|
// {"label":"Duan,Wangping","value":"","type":0},
|
|
|
|
// {"label":"Wei,Xiaochun","value":"","type":2}]
|
|
|
|
getAuthorsJson(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 ? "中文期刊" : "其他" |
|
|
|
@ -154,7 +168,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
result.getTitle(), |
|
|
|
result.getNo(), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "发明专利" : result.getAchType() == 1 ? "实用新型专利" : "外观设计专利", |
|
|
|
result.getAuthors(), |
|
|
|
getAuthorsJson(result.getAuthors()), |
|
|
|
result.getRemark() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
@ -180,7 +194,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
result.getTitle(), |
|
|
|
DateUtil.format(result.getPublishDate(), "yyyy-MM-dd"), |
|
|
|
result.getPlace(), |
|
|
|
result.getAuthors(), |
|
|
|
getAuthorsJson(result.getAuthors()), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "学术讲座" : result.getAchType() == 1 ? "学术会议" : "外出进修", |
|
|
|
result.getRemark() |
|
|
|
).center().create(); |
|
|
|
@ -272,15 +286,82 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* //[{"label":"Ma,Yongsheng","value":"","type":0},
|
|
|
|
* // {"label":"Yang,Wenming","value":"","type":1},
|
|
|
|
* // {"label":"Lin,Qitai","value":"","type":1},
|
|
|
|
* // {"label":"Li,Meiming","value":"","type":2},
|
|
|
|
* // {"label":"Li,Zehao","value":"","type":0},
|
|
|
|
* // {"label":"Xing,Yugang","value":"","type":0},
|
|
|
|
* // {"label":"Wei,Lei","value":"","type":0},
|
|
|
|
* // {"label":"Duan,Wangping","value":"","type":0},
|
|
|
|
* // {"label":"Wei,Xiaochun","value":"","type":2}]
|
|
|
|
* 处理作者 找出label中的信息,并且value=0加角标1 value=1加角标* |
|
|
|
* @param author |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
/** |
|
|
|
* 解析作者信息并根据type值添加相应角标 |
|
|
|
* @param authorsJson 包含作者信息的JSON字符串 |
|
|
|
* @return 格式化后的作者字符串 |
|
|
|
*/ |
|
|
|
private String getAuthorsJson(String authorsJson) { |
|
|
|
if (StrUtil.isBlank(authorsJson)) { |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
// 使用@SuppressWarnings注解抑制警告,因为运行时类型是正确的
|
|
|
|
List<Map> authorList = JSONUtil.toList(authorsJson, Map.class); |
|
|
|
|
|
|
|
StringBuilder result = new StringBuilder(); |
|
|
|
for (int i = 0; i < authorList.size(); i++) { |
|
|
|
Map<String, Object> author = authorList.get(i); |
|
|
|
String label = (String) author.get("label"); |
|
|
|
Integer type = (Integer) author.get("type"); |
|
|
|
|
|
|
|
if (label != null) { |
|
|
|
result.append(label); |
|
|
|
|
|
|
|
// 根据type值添加角标
|
|
|
|
if (type != null) { |
|
|
|
if (type == 0) { |
|
|
|
result.append("¹"); // 上标1
|
|
|
|
} else if (type == 1) { |
|
|
|
result.append("*"); // 星号
|
|
|
|
} else if (type == 2) { |
|
|
|
// type为2不添加特殊标记,可根据需要调整
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 如果不是最后一个元素,添加分隔符
|
|
|
|
if (i < authorList.size() - 1) { |
|
|
|
result.append(", "); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return result.toString(); |
|
|
|
} catch (Exception e) { |
|
|
|
// 解析失败时返回原始值
|
|
|
|
return authorsJson; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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()); |
|
|
|
KtsKtGroupMember ktsKtGroupMember = ktsKtGroupMemberMapper.selectByPrimaryKey(dto.getUserId()); |
|
|
|
if (ktsKtGroupMember == null) { |
|
|
|
throw new RuntimeException("用户不存在"); |
|
|
|
} |
|
|
|
SysUser sysUser = sysUserService.selectUserByUserName(ktsKtGroupMember.getMemberPhone()); |
|
|
|
if (sysUser == null) { |
|
|
|
return; |
|
|
|
throw new RuntimeException("用户不存在"); |
|
|
|
} |
|
|
|
GroupDto.MemberQuery memberQuery = new GroupDto.MemberQuery(); |
|
|
|
memberQuery.setMemberPhone(sysUser.getPhonenumber()); |
|
|
|
memberQuery.setMemberPhone(ktsKtGroupMember.getMemberPhone()); |
|
|
|
List<GroupVO.MemberResult> memberResults = ktsGroupService.queryMemberList(memberQuery); |
|
|
|
if (CollUtil.isNotEmpty(memberResults)) { |
|
|
|
map.put("groupName", memberResults.stream().map(GroupVO.MemberResult::getKtGroupName).collect(Collectors.joining(","))); |
|
|
|
@ -362,7 +443,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
RowRenderData rowRenderData = Rows.of( |
|
|
|
result.getProjOrgName(), |
|
|
|
result.getTitle(), |
|
|
|
result.getAuthors(), |
|
|
|
getAuthorsJson(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 ? "中文期刊" : "其他" |
|
|
|
@ -389,7 +470,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
result.getTitle(), |
|
|
|
result.getNo(), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "发明专利" : result.getAchType() == 1 ? "实用新型专利" : "外观设计专利", |
|
|
|
result.getAuthors(), |
|
|
|
getAuthorsJson(result.getAuthors()), |
|
|
|
result.getRemark() |
|
|
|
).center().create(); |
|
|
|
of.addRow(rowRenderData).center(); |
|
|
|
@ -415,7 +496,7 @@ public class ExportServiceImpl implements ExportService { |
|
|
|
result.getTitle(), |
|
|
|
DateUtil.format(result.getPublishDate(), "yyyy-MM-dd"), |
|
|
|
result.getPlace(), |
|
|
|
result.getAuthors(), |
|
|
|
getAuthorsJson(result.getAuthors()), |
|
|
|
result.getAchType() == null ? null : result.getAchType() == 0 ? "学术讲座" : result.getAchType() == 1 ? "学术会议" : "外出进修", |
|
|
|
result.getRemark() |
|
|
|
).center().create(); |
|
|
|
|