Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangqinbin
2022-04-02 12:08:45 +08:00
4 changed files with 8 additions and 107 deletions

View File

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>com.chinaunicom.ebtp</groupId> <groupId>com.chinaunicom.ebtp</groupId>
<artifactId>mall-ebtp-cloud-parent</artifactId> <artifactId>mall-ebtp-cloud-parent</artifactId>
<version>2.0.1-SNAPSHOT</version> <version>2.1.1-SNAPSHOT</version>
</parent> </parent>
<groupId>com.chinaunicom.mall.ebtp</groupId> <groupId>com.chinaunicom.mall.ebtp</groupId>
@ -20,7 +20,7 @@
<dependency> <dependency>
<groupId>com.chinaunicom.mall.ebtp</groupId> <groupId>com.chinaunicom.mall.ebtp</groupId>
<artifactId>uboot-core</artifactId> <artifactId>uboot-core</artifactId>
<version>2.0.1-SNAPSHOT</version> <version>2.1.1-SNAPSHOT</version>
</dependency> </dependency>

View File

@ -1,7 +1,6 @@
package com.chinaunicom.mall.ebtp.extend.feign.client; package com.chinaunicom.mall.ebtp.extend.feign.client;
import com.chinaunicom.mall.ebtp.extend.feign.client.factory.DocumentCenterServiceFallbackFactory; import com.chinaunicom.mall.ebtp.extend.feign.client.factory.DocumentCenterServiceFallbackFactory;
import com.chinaunicom.mall.ebtp.extend.feign.config.FeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
@ -14,8 +13,7 @@ import org.springframework.web.bind.annotation.RequestParam;
*/ */
@FeignClient(value = "${mconfig.feign.name.documentcenter}", @FeignClient(value = "${mconfig.feign.name.documentcenter}",
fallbackFactory = DocumentCenterServiceFallbackFactory.class, fallbackFactory = DocumentCenterServiceFallbackFactory.class)
configuration = FeignConfiguration.class)
public interface DocumentCenterService { public interface DocumentCenterService {
/** /**

View File

@ -1,95 +0,0 @@
package com.chinaunicom.mall.ebtp.extend.feign.config;
import com.alibaba.fastjson.JSONObject;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
@Slf4j
@Configuration
public class FeignConfiguration implements RequestInterceptor {
@Value("${document.clientHttpUrl}")
private String clientHttpUrl;
@Override
public void apply(RequestTemplate requestTemplate) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (attributes != null) {
HttpServletRequest request = attributes.getRequest();
log.info("token=======requestTemplate.headers" + requestTemplate.headers());
String access_token = request.getHeader("Authorization");
log.info("token=======" + access_token);
if (access_token == null || StringUtils.isBlank(access_token)) {
access_token = getAccessToken();
log.info("token=======access_token===" + access_token);
requestTemplate.header(HttpHeaders.AUTHORIZATION, "Bearer " + access_token);
}
} else {
String access_token = getAccessToken();
log.info("token=======attributes==null===" + access_token);
requestTemplate.header(HttpHeaders.AUTHORIZATION, "Bearer " + access_token);
}
}
private String getAccessToken() {
StringBuffer strBf = new StringBuffer();
try {
URL realUrl = new URL(clientHttpUrl);
//将realUrl以 open方法返回的urlConnection 连接强转为HttpURLConnection连接 (标识一个url所引用的远程对象连接)
HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();// 此时cnnection只是为一个连接对象,待连接中
//设置连接输出流为true,默认false (post请求是以流的方式隐式的传递参数)
connection.setDoOutput(true);
//设置连接输入流为true
connection.setDoInput(true);
//设置请求方式为post
connection.setRequestMethod("POST");
//post请求缓存设为false
connection.setUseCaches(false);
//设置该HttpURLConnection实例是否自动执行重定向
connection.setInstanceFollowRedirects(true);
//设置请求头里面的各个属性 (以下为设置内容的类型,设置为经过urlEncoded编码过的from参数)
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8");
//建立连接 (请求未开始,直到connection.getInputStream()方法调用时才发起,以上各个参数设置需在此方法之前进行)
connection.connect();
//创建输入输出流,用于往连接里面输出携带的参数,(输出内容为?后面的内容)
DataOutputStream dataout = new DataOutputStream(connection.getOutputStream());
// String query = data.toString();
// //将参数输出到连接
// dataout.write(query.getBytes("UTF-8"));
// 输出完成后刷新并关闭流
dataout.flush();
dataout.close(); // 重要且易忽略步骤 (关闭流,切记!)
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
String lines;
while ((lines = reader.readLine()) != null) {
lines = new String(lines.getBytes(), "utf-8");
strBf.append(lines);
}
reader.close();
connection.disconnect();
log.info("toke返回数据---------------------- " + strBf.toString());
} catch (Exception e) {
log.info("toke返回数据---------------------- " + e.getMessage());
}
JSONObject json = JSONObject.parseObject(strBf.toString());
if ((boolean) json.get("success")) {
return ((JSONObject) json.get("data")).get("value").toString();
}
return null;
}
}

View File

@ -125,20 +125,18 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService {
File f = new File(path + "merged.pdf"); File f = new File(path + "merged.pdf");
FileOutputStream fos = null; FileOutputStream fos = null;
FontSettings.getDefaultInstance().setFontsFolder(fontAddress, true);
try { try {
FontSettings.getDefaultInstance().setFontsFolder(fontAddress, true);
fos = new FileOutputStream(f); fos = new FileOutputStream(f);
com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx"); com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx");
doc.save(fos, SaveFormat.PDF); doc.save(fos, SaveFormat.PDF);
fos.flush();
} catch (Exception e) { } catch (Exception e) {
log.info(ExceptionUtil.stacktraceToString(e)); log.info(ExceptionUtil.stacktraceToString(e));
} finally { } finally {
source.close(); IOUtils.closeQuietly(source);
addObj.close(); IOUtils.closeQuietly(addObj);
if (fos != null) { IOUtils.closeQuietly(fos);
fos.flush();
fos.close();
}
} }