|
|
|
@ -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,7 +60,23 @@ public class EleEctronVoucherServiceImpl extends Service implements EleEctronVou
|
|
|
|
|
// 2. 检查响应状态码
|
|
|
|
|
if (response.isOk()) {
|
|
|
|
|
|
|
|
|
|
InputStream inputStream = response.bodyStream();
|
|
|
|
|
// 解析 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()
|
|
|
|
@ -78,6 +97,10 @@ public class EleEctronVoucherServiceImpl extends Service implements EleEctronVou
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|