|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package com.engine.fssecond.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.api.formmode.page.util.Util;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.fssecond.entity.GenerateDocParams;
|
|
|
|
@ -57,27 +60,47 @@ public class EleEctronVoucherServiceImpl extends Service implements EleEctronVou
|
|
|
|
|
// 2. 检查响应状态码
|
|
|
|
|
if (response.isOk()) {
|
|
|
|
|
|
|
|
|
|
InputStream inputStream = response.bodyStream();
|
|
|
|
|
//附件生成
|
|
|
|
|
int imageFileid = generateImageFileid(inputStream, fileName);
|
|
|
|
|
GenerateDocParams generateDocParams = GenerateDocParams.builder()
|
|
|
|
|
.imageFileid(imageFileid)
|
|
|
|
|
.fileName(fileName)
|
|
|
|
|
.creater(user.getUID())
|
|
|
|
|
.docCreateDate(TimeUtil.getCurrentDateString())
|
|
|
|
|
.docCreateTime(TimeUtil.getOnlyCurrentTimeString())
|
|
|
|
|
.maincategory(Integer.parseInt(maincategory))
|
|
|
|
|
.subcategory(Integer.parseInt(subcategory))
|
|
|
|
|
.seccategory(Integer.parseInt(seccategory))
|
|
|
|
|
.docType(1)
|
|
|
|
|
.docExtendname(".pdf")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
fileMap.put("imageFileid", imageFileid);
|
|
|
|
|
fileMap.put("fileName", fileName);
|
|
|
|
|
|
|
|
|
|
int docId = generateDocId(user, generateDocParams);
|
|
|
|
|
fileMap.put("docId", docId);
|
|
|
|
|
// 解析 JSON 响应
|
|
|
|
|
String body = response.body();
|
|
|
|
|
JSONObject json = JSONUtil.parseObj(body);
|
|
|
|
|
|
|
|
|
|
// 检查 success 和 code
|
|
|
|
|
if (json.getBool("success") && "1000000000".equals(json.getStr("code"))) {
|
|
|
|
|
// 提取 data 数组
|
|
|
|
|
JSONArray dataArray = json.getJSONArray("data");
|
|
|
|
|
byte[] bytes = new byte[dataArray.size()];
|
|
|
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
|
bytes[i] = dataArray.getInt(i).byteValue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将字节数组转换为 InputStream
|
|
|
|
|
InputStream inputStream = new ByteArrayInputStream(bytes);
|
|
|
|
|
|
|
|
|
|
//InputStream inputStream = response.bodyStream();
|
|
|
|
|
//附件生成
|
|
|
|
|
int imageFileid = generateImageFileid(inputStream, fileName);
|
|
|
|
|
GenerateDocParams generateDocParams = GenerateDocParams.builder()
|
|
|
|
|
.imageFileid(imageFileid)
|
|
|
|
|
.fileName(fileName)
|
|
|
|
|
.creater(user.getUID())
|
|
|
|
|
.docCreateDate(TimeUtil.getCurrentDateString())
|
|
|
|
|
.docCreateTime(TimeUtil.getOnlyCurrentTimeString())
|
|
|
|
|
.maincategory(Integer.parseInt(maincategory))
|
|
|
|
|
.subcategory(Integer.parseInt(subcategory))
|
|
|
|
|
.seccategory(Integer.parseInt(seccategory))
|
|
|
|
|
.docType(1)
|
|
|
|
|
.docExtendname(".pdf")
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
fileMap.put("imageFileid", imageFileid);
|
|
|
|
|
fileMap.put("fileName", fileName);
|
|
|
|
|
|
|
|
|
|
int docId = generateDocId(user, generateDocParams);
|
|
|
|
|
fileMap.put("docId", docId);
|
|
|
|
|
}else {
|
|
|
|
|
fileMap.put("msg",json);
|
|
|
|
|
//fileMap.put("msg",json.getStr("data"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
fileMap.put("msg","接口调用失败 ->"+response.toString());
|
|
|
|
|