@@ -39,6 +39,11 @@ | |||
<artifactId>spring-boot-starter-data-redis</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.session</groupId> | |||
<artifactId>spring-session-data-redis</artifactId> | |||
</dependency> | |||
<!--spring boot 集成redis所需common-pool2--> | |||
<dependency> | |||
<groupId>org.apache.commons</groupId> | |||
@@ -1,5 +1,6 @@ | |||
package com.ningdatech.pmapi.expert.helper; | |||
import cn.hutool.core.collection.CollUtil; | |||
import com.ningdatech.basic.exception.BizException; | |||
import com.ningdatech.pmapi.expert.model.*; | |||
import com.ningdatech.pmapi.meta.helper.DictionaryCache; | |||
@@ -64,7 +65,9 @@ public class ExpertManageHelper { | |||
tagFieldInfoList.addAll(goodAt); | |||
tagFieldInfoList.addAll(technicalExpertise); | |||
tagFieldInfoList.addAll(industrySector); | |||
tagFieldInfoList.addAll(expertSource); | |||
if(CollUtil.isNotEmpty(expertSource)){ | |||
tagFieldInfoList.addAll(expertSource); | |||
} | |||
for (TagFieldInfo tagFieldInfo : tagFieldInfoList) { | |||
String tagCode = tagFieldInfo.getTagCode(); | |||
TagDTO tagCodeDTO = tagCache.getByTagCode(tagCode); | |||
@@ -2,6 +2,7 @@ package com.ningdatech.pmapi.todocenter.manage; | |||
import cn.hutool.core.codec.Base64; | |||
import cn.hutool.core.collection.CollUtil; | |||
import cn.hutool.core.io.resource.ResourceUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
@@ -1037,7 +1038,7 @@ public class TodoCenterManage { | |||
// 获取本地目录的pdf模板 | |||
String fileName = "预审申请单"; | |||
InputStream htmlInputStream = | |||
this.getClass().getClassLoader().getResourceAsStream("template/" + fileName + ".html"); | |||
this.getClass().getClassLoader().getResourceAsStream("template" + java.io.File.separator + fileName + ".html"); | |||
// 生成pdf字节数组 | |||
byte[] pdf = pdfUtils.generatePdf(htmlInputStream, paramsMap); | |||
@@ -1059,11 +1060,11 @@ public class TodoCenterManage { | |||
} | |||
// 删除输出文件夹下的临时文件 | |||
java.io.File resourcesPath = new java.io.File("pmapi/src/main/resources"); | |||
String reportPath = resourcesPath.getCanonicalPath(); | |||
String path = reportPath + "/template/fileout"; | |||
java.io.File directory = new java.io.File(path); | |||
FileUtils.cleanDirectory(directory); | |||
java.io.File directory = new java.io.File(""); | |||
//pdf输出路径 | |||
String filePath = directory.getAbsolutePath() + java.io.File.separator + "fileout"; | |||
java.io.File directoryPath = new java.io.File(filePath); | |||
FileUtils.cleanDirectory(directoryPath); | |||
} catch (IOException e) { | |||
log.error(e.getMessage()); | |||
} | |||
@@ -1,6 +1,8 @@ | |||
package com.ningdatech.pmapi.todocenter.utils; | |||
import cn.hutool.core.io.FileUtil; | |||
import cn.hutool.core.io.resource.ResourceUtil; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.itextpdf.text.DocumentException; | |||
import com.itextpdf.text.Image; | |||
@@ -42,15 +44,13 @@ public class PdfUtils { | |||
try { | |||
File directory = new File(""); | |||
//pdf输出路径 | |||
String absolutePath = directory.getAbsolutePath(); | |||
String linkPath = "\\pmapi\\src\\main\\resources"; | |||
String filePath = absolutePath + linkPath + "\\template\\fileout"; | |||
//临时文件输出路径 | |||
String filePath = directory.getAbsolutePath() + File.separator + "fileout"; | |||
//字体格式 | |||
String fontPath = directory.getAbsolutePath() + File.separator + "font" + File.separator + "simsun.ttc"; | |||
if(!new File(filePath).exists()){ | |||
new File(filePath).mkdir(); | |||
} | |||
//字体格式 | |||
String FONT = absolutePath + linkPath + "\\template\\simsun.ttc"; | |||
StringBuilder stringBuilder = new StringBuilder(); | |||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(templateHtmlInputStream, StandardCharsets.UTF_8)); | |||
String line; | |||
@@ -92,7 +92,7 @@ public class PdfUtils { | |||
ITextRenderer renderer = new ITextRenderer(); | |||
renderer.setDocument(url); | |||
ITextFontResolver fontResolver = renderer.getFontResolver(); | |||
fontResolver.addFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); | |||
fontResolver.addFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); | |||
renderer.layout(); | |||
renderer.createPDF(os); | |||
os.flush(); | |||
@@ -103,9 +103,9 @@ public class PdfUtils { | |||
// 返回生成的pdf文件字节数组 | |||
return readBytes(inputStream); | |||
} catch (IOException e) { | |||
throw new BizException("生成pdf文件失败!"); | |||
throw new BizException("生成pdf文件失败!" + e.getMessage()); | |||
} catch (DocumentException e) { | |||
throw new BizException("生成pdf文件失败!"); | |||
throw new BizException("生成pdf文件失败!" +e.getMessage()); | |||
} finally { | |||
try { | |||
if (null != inputStream) { | |||
@@ -1,49 +1,38 @@ | |||
package com.ningdatech.pmapi.user.security.auth.config;//package com.ningdatech.pmapi.user.security.auth.config; | |||
// | |||
//import com.ningdatech.basic.util.StrPool; | |||
//import org.springframework.beans.factory.annotation.Value; | |||
//import org.springframework.context.annotation.Bean; | |||
//import org.springframework.context.annotation.Configuration; | |||
// | |||
///** | |||
// * <p> | |||
// * 设置session的过期时间为一天 | |||
// * </p> | |||
// * | |||
// * @Author LiuXinXin | |||
// * @Date 2020/7/29 9:46 上午 | |||
// * @Version 1.0 | |||
// **/ | |||
//@Configuration | |||
//@EnableRedisHttpSession( | |||
// maxInactiveIntervalInSeconds = RedisSessionConfig.SESSION_TIMEOUT, | |||
// redisNamespace = RedisSessionConfig.REDIS_NAMESPACE | |||
//) | |||
//public class RedisSessionConfig { | |||
// | |||
// static final int SESSION_TIMEOUT = 24 * 60 * 60 * 10; | |||
// | |||
// static final String REDIS_NAMESPACE = "#{redisSessionConfig.getRedisNamespace()}"; | |||
// | |||
// @Value("${nd.cache.def.keyPrefix:}") | |||
// private String keyPrefix; | |||
// | |||
// public String getRedisNamespace() { | |||
// return (StrUtils.isBlank(keyPrefix) ? StrPool.EMPTY : keyPrefix + StrPool.COLON) + RedisIndexedSessionRepository.DEFAULT_NAMESPACE; | |||
// } | |||
// | |||
// @Bean | |||
// public CookieHttpSessionIdResolver sessionIdResolver() { | |||
// // 创建 CookieHttpSessionIdResolver 对象 | |||
// CookieHttpSessionIdResolver sessionIdResolver = new CookieHttpSessionIdResolver(); | |||
// // 创建 DefaultCookieSerializer 对象 | |||
// DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer(); | |||
// | |||
// // 设置到 sessionIdResolver 中 | |||
// sessionIdResolver.setCookieSerializer(cookieSerializer); | |||
// cookieSerializer.setCookieName(BizConst.COOKIE_KEY); | |||
// cookieSerializer.setCookieMaxAge(SessionTimeConstant.SESSION_TIME_SECONDS); | |||
// return sessionIdResolver; | |||
// } | |||
// | |||
//} | |||
import com.ningdatech.pmapi.common.constant.BizConst; | |||
import com.ningdatech.pmapi.user.security.auth.constants.SessionTimeConstant; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession; | |||
import org.springframework.session.web.http.CookieHttpSessionIdResolver; | |||
import org.springframework.session.web.http.DefaultCookieSerializer; | |||
/** | |||
* <p> | |||
* 设置session的过期时间为一天 | |||
* </p> | |||
* | |||
* @Author LiuXinXin | |||
* @Date 2020/7/29 9:46 上午 | |||
* @Version 1.0 | |||
**/ | |||
@Configuration | |||
// 设置session的过期时间为一天 | |||
@EnableRedisHttpSession(maxInactiveIntervalInSeconds = 24 * 60 * 60 * 10) | |||
public class RedisSessionConfig { | |||
@Bean | |||
public CookieHttpSessionIdResolver sessionIdResolver() { | |||
// 创建 CookieHttpSessionIdResolver 对象 | |||
CookieHttpSessionIdResolver sessionIdResolver = new CookieHttpSessionIdResolver(); | |||
// 创建 DefaultCookieSerializer 对象 | |||
DefaultCookieSerializer cookieSerializer = new DefaultCookieSerializer(); | |||
sessionIdResolver.setCookieSerializer(cookieSerializer); // 设置到 sessionIdResolver 中 | |||
cookieSerializer.setCookieName(BizConst.COOKIE_KEY); | |||
cookieSerializer.setCookieMaxAge(SessionTimeConstant.SESSION_TIME_SECONDS); | |||
return sessionIdResolver; | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.ningdatech.pmapi.workbench.controller; | |||
import io.swagger.annotations.Api; | |||
import lombok.AllArgsConstructor; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* 工作台前端控制器 | |||
* | |||
* @author CMM | |||
* @since 2023/03/17 15:35 | |||
*/ | |||
@RestController | |||
@AllArgsConstructor | |||
@Api(tags = "工作台控制器") | |||
@RequestMapping("/api/v1/todo-center") | |||
public class WorkbenchController { | |||
} |