parent
5c9223ef1c
commit
0daa867f65
|
@ -205,7 +205,7 @@ public class ApiService {
|
||||||
|
|
||||||
|
|
||||||
String saveRequestBody;
|
String saveRequestBody;
|
||||||
String result = null;
|
String result;
|
||||||
String saveResponseBody;
|
String saveResponseBody;
|
||||||
JSONObject jsonObject;
|
JSONObject jsonObject;
|
||||||
String code;
|
String code;
|
||||||
|
@ -264,7 +264,7 @@ public class ApiService {
|
||||||
data = jsonObject.getJSONObject("data");
|
data = jsonObject.getJSONObject("data");
|
||||||
dynamic.set("shkd_businessnumber", data.getString("code"));
|
dynamic.set("shkd_businessnumber", data.getString("code"));
|
||||||
dynamic.set("shkd_businessid", data.getString("id"));
|
dynamic.set("shkd_businessid", data.getString("id"));
|
||||||
dynamic.set("shkd_businessname", "BIP");
|
dynamic.set("shkd_businessname", "共享系统");
|
||||||
dynamic.set("shkd_pushstatus", "已结算");
|
dynamic.set("shkd_pushstatus", "已结算");
|
||||||
dynamicObjects.add(dynamic);
|
dynamicObjects.add(dynamic);
|
||||||
|
|
||||||
|
@ -287,6 +287,7 @@ public class ApiService {
|
||||||
code = jsonObject.getString("code");
|
code = jsonObject.getString("code");
|
||||||
if ("200".equals(code)) {
|
if ("200".equals(code)) {
|
||||||
dynamic.set("shkd_pushstatus", "已推送");
|
dynamic.set("shkd_pushstatus", "已推送");
|
||||||
|
dynamic.set("shkd_businessname", "共享系统");
|
||||||
dynamicObjects.add(dynamic);
|
dynamicObjects.add(dynamic);
|
||||||
logger.info("银行收付处理 → BIP推送接口 → 成功\n成功单据编号:{}\n成功请求体:{}\n推送成功接口返回数据:{}", dynamic.getString("billno"), saveRequestBody, saveResponseBody);
|
logger.info("银行收付处理 → BIP推送接口 → 成功\n成功单据编号:{}\n成功请求体:{}\n推送成功接口返回数据:{}", dynamic.getString("billno"), saveRequestBody, saveResponseBody);
|
||||||
result = "推送 → 银行收付处理 → 成功";
|
result = "推送 → 银行收付处理 → 成功";
|
||||||
|
@ -328,6 +329,8 @@ public class ApiService {
|
||||||
code = jsonObject.getString("code");
|
code = jsonObject.getString("code");
|
||||||
if ("200".equals(code)) {
|
if ("200".equals(code)) {
|
||||||
dynamic.set("shkd_pushstatus", "已推送");
|
dynamic.set("shkd_pushstatus", "已推送");
|
||||||
|
dynamic.set("shkd_businessname", "共享系统");
|
||||||
|
dynamic.set("shkd_businessid", jsonObject.getJSONArray("data").get(0));
|
||||||
dynamicObjects.add(dynamic);
|
dynamicObjects.add(dynamic);
|
||||||
logger.info("电子回单查询 → BIP推送接口 → 成功\n成功单据编号:{}\n成功请求体:{}\n推送成功接口返回数据:{}",
|
logger.info("电子回单查询 → BIP推送接口 → 成功\n成功单据编号:{}\n成功请求体:{}\n推送成功接口返回数据:{}",
|
||||||
dynamic.getString("billno"), saveRequestBody, saveResponseBody);
|
dynamic.getString("billno"), saveRequestBody, saveResponseBody);
|
||||||
|
@ -340,7 +343,15 @@ public class ApiService {
|
||||||
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
|
"fileflag,filepath,biztype,bankcheckflag,fileserverurl,tcpurl,uploadfilename,username,password," +
|
||||||
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, dynamic.getPkValue())});
|
"bank.bank_cate bankcate", new QFilter[]{new QFilter("id", QCP.equals, dynamic.getPkValue())});
|
||||||
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
|
String pdfUrl = getPdfUrl(viewByDynamicObj.getPageId(), receipts, errMsgList);
|
||||||
logger.info("获取回单附件pdfUrl:{}", pdfUrl);
|
|
||||||
|
Map<String, Object> hashMap = new HashMap<>();
|
||||||
|
hashMap.put("bankpdf", attachmentBase64(pdfUrl));
|
||||||
|
hashMap.put("fileName", dynamic.getString("uploadfilename"));
|
||||||
|
hashMap.put("id", jsonObject.getJSONArray("data").get(0).toString());
|
||||||
|
hashMap.put("receiptno", dynamic.getString("billno"));
|
||||||
|
String attachmentRequestBody = getAttachmentRequestBody(hashMap);
|
||||||
|
String pushResult = pushBill(token, "https://biptestctny.invest.com.cn:8002/iuap-api-auth//yonbip/ctm/bank/tran/update", attachmentRequestBody);
|
||||||
|
logger.info("电子回单查询 → BIP推送附件接口 → \n推送数据:{}\n请求返回结果:{}", attachmentRequestBody, pushResult);
|
||||||
} else {
|
} else {
|
||||||
logger.info("电子回单查询 → BIP推送接口 → 失败\n失败单据编号:{}\n失败请求体:{}\n推送失败接口返回数据:{}",
|
logger.info("电子回单查询 → BIP推送接口 → 失败\n失败单据编号:{}\n失败请求体:{}\n推送失败接口返回数据:{}",
|
||||||
dynamic.getString("billno"), saveRequestBody, saveResponseBody);
|
dynamic.getString("billno"), saveRequestBody, saveResponseBody);
|
||||||
|
@ -699,6 +710,14 @@ public class ApiService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组装提交接口请求体
|
||||||
|
*
|
||||||
|
* @param fullname
|
||||||
|
* @param billnum
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Map<String, Object> getSubmitRequestBody(String fullname, String billnum, String id) {
|
public static Map<String, Object> getSubmitRequestBody(String fullname, String billnum, String id) {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
Map<String, String> innerData = new HashMap<>();
|
Map<String, String> innerData = new HashMap<>();
|
||||||
|
@ -710,6 +729,19 @@ public class ApiService {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getAttachmentRequestBody(Map<String, Object> hashMap) {
|
||||||
|
|
||||||
|
// 创建 JSONObject 并填充数据
|
||||||
|
JSONObject jsonObject = new JSONObject(hashMap);
|
||||||
|
|
||||||
|
// 创建 JSONArray 并添加 JSONObject
|
||||||
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
jsonArray.add(jsonObject);
|
||||||
|
|
||||||
|
// 输出最终的 JSON 数组字符串
|
||||||
|
return jsonArray.toJSONString();
|
||||||
|
}
|
||||||
|
|
||||||
private static String getPdfUrl(String pageId, DynamicObjectCollection receipts, List<String> errMsgList) {
|
private static String getPdfUrl(String pageId, DynamicObjectCollection receipts, List<String> errMsgList) {
|
||||||
List<String> listPdf = new ArrayList<>(10);
|
List<String> listPdf = new ArrayList<>(10);
|
||||||
List<byte[]> resList = new ArrayList<>(10);
|
List<byte[]> resList = new ArrayList<>(10);
|
||||||
|
@ -718,12 +750,10 @@ public class ApiService {
|
||||||
String getTemplateError = (new BeiBizResource()).getGetTemplateError();
|
String getTemplateError = (new BeiBizResource()).getGetTemplateError();
|
||||||
logger.info("ViewReceiptService.getPdfUrl receipts.size=" + receipts.size());
|
logger.info("ViewReceiptService.getPdfUrl receipts.size=" + receipts.size());
|
||||||
if (receipts.size() > 1000) {
|
if (receipts.size() > 1000) {
|
||||||
errMsgList.add(ResManager.loadKDString("请求打印电子回单数量超过1000条,请分批处理。", "ViewReceiptService_6", "tmc-bei-business", new Object[0]));
|
errMsgList.add(ResManager.loadKDString("请求打印电子回单数量超过1000条,请分批处理。", "ViewReceiptService_6", "tmc-bei-business"));
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
Set<Long> pkIds = (Set<Long>) receipts.stream().map((receiptx) -> {
|
Set<Long> pkIds = receipts.stream().map((receiptx) -> receiptx.getLong("id")).collect(Collectors.toSet());
|
||||||
return receiptx.getLong("id");
|
|
||||||
}).collect(Collectors.toSet());
|
|
||||||
Map<Object, Set<MatcherTpl>> receiptTemplate = ReceiptPrintHelper.getMatchReceiptTemplate("bei", "bei_elecreceipt", pkIds, ViewType.LIST, pageId);
|
Map<Object, Set<MatcherTpl>> receiptTemplate = ReceiptPrintHelper.getMatchReceiptTemplate("bei", "bei_elecreceipt", pkIds, ViewType.LIST, pageId);
|
||||||
receiptTemplate.remove("");
|
receiptTemplate.remove("");
|
||||||
long timeMillis = System.currentTimeMillis();
|
long timeMillis = System.currentTimeMillis();
|
||||||
|
@ -737,9 +767,8 @@ public class ApiService {
|
||||||
errMsgList.add(templateError);
|
errMsgList.add(templateError);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
for (Object o : (Set) receiptTemplate.get(receiptID)) {
|
for (MatcherTpl o : receiptTemplate.get(receiptID)) {
|
||||||
MatcherTpl template = (MatcherTpl) o;
|
String templateId = o.getTplId();
|
||||||
String templateId = template.getTplId();
|
|
||||||
logger.info("ViewReceiptService templateForm.keySet=" + templateId);
|
logger.info("ViewReceiptService templateForm.keySet=" + templateId);
|
||||||
String templateFormId = "";
|
String templateFormId = "";
|
||||||
if (EmptyUtil.isNoEmpty(templateId)) {
|
if (EmptyUtil.isNoEmpty(templateId)) {
|
||||||
|
@ -766,12 +795,12 @@ public class ApiService {
|
||||||
Long userId = RequestContext.get().getCurrUserId();
|
Long userId = RequestContext.get().getCurrUserId();
|
||||||
DynamicObjectCollection userObj = QueryServiceHelper.query("bos_user", "id,phone", (new QFilter("id", "=", userId)).toArray());
|
DynamicObjectCollection userObj = QueryServiceHelper.query("bos_user", "id,phone", (new QFilter("id", "=", userId)).toArray());
|
||||||
DynamicObjectCollection configObj = QueryServiceHelper.query("bas_imageconfig", "imageurl,clientid,clientsecret", (new QFilter("enable", "=", "A")).toArray());
|
DynamicObjectCollection configObj = QueryServiceHelper.query("bas_imageconfig", "imageurl,clientid,clientsecret", (new QFilter("enable", "=", "A")).toArray());
|
||||||
InputStream image = ScanServiceImpl.getImage(((DynamicObject) configObj.get(0)).getString("clientid"), ((DynamicObject) configObj.get(0)).getString("clientsecret"), ((DynamicObject) configObj.get(0)).getString("imageurl"), ((DynamicObject) userObj.get(0)).getString("phone"), fileServerUrl);
|
InputStream image = ScanServiceImpl.getImage(configObj.get(0).getString("clientid"), configObj.get(0).getString("clientsecret"), configObj.get(0).getString("imageurl"), userObj.get(0).getString("phone"), fileServerUrl);
|
||||||
ReceiptPrintHelper.imageConvertPdf("", resList, image);
|
ReceiptPrintHelper.imageConvertPdf("", resList, image);
|
||||||
} else if (!uploadFileName.endsWith("pdf") && !uploadFileName.endsWith("PDF")) {
|
} else if (!uploadFileName.endsWith("pdf") && !uploadFileName.endsWith("PDF")) {
|
||||||
if (!uploadFileName.endsWith("ofd") && !uploadFileName.endsWith("OFD")) {
|
if (!uploadFileName.endsWith("ofd") && !uploadFileName.endsWith("OFD")) {
|
||||||
logger.info("fileReceipt url:" + uploadFileName);
|
logger.info("fileReceipt url:" + uploadFileName);
|
||||||
ReceiptPrintHelper.imageConvertPdf(uploadFileName, resList, (InputStream) null);
|
ReceiptPrintHelper.imageConvertPdf(uploadFileName, resList, null);
|
||||||
} else {
|
} else {
|
||||||
logger.info("ofdReceipt url:" + uploadFileName);
|
logger.info("ofdReceipt url:" + uploadFileName);
|
||||||
byte[] bytes = OfdConvertUtil.convertToPdfNew(BeiHelper.getPdfPutStream(uploadFileName, "old"));
|
byte[] bytes = OfdConvertUtil.convertToPdfNew(BeiHelper.getPdfPutStream(uploadFileName, "old"));
|
||||||
|
@ -884,7 +913,7 @@ public class ApiService {
|
||||||
/**
|
/**
|
||||||
* 按照动态对象来创建页面视图,可在后端模拟操作并且修改值触发对应插件
|
* 按照动态对象来创建页面视图,可在后端模拟操作并且修改值触发对应插件
|
||||||
*
|
*
|
||||||
* @return
|
* @return IFormView
|
||||||
*/
|
*/
|
||||||
public static IFormView createViewByDynamicObj(DynamicObject dynamicObj) {
|
public static IFormView createViewByDynamicObj(DynamicObject dynamicObj) {
|
||||||
MainEntityType type = MetadataServiceHelper.getDataEntityType(dynamicObj.getDataEntityType().getName());
|
MainEntityType type = MetadataServiceHelper.getDataEntityType(dynamicObj.getDataEntityType().getName());
|
||||||
|
@ -901,7 +930,7 @@ public class ApiService {
|
||||||
*
|
*
|
||||||
* @param formId:表单标识
|
* @param formId:表单标识
|
||||||
* @param appId:应用id
|
* @param appId:应用id
|
||||||
* @return
|
* @return IFormView
|
||||||
*/
|
*/
|
||||||
public static IFormView createView(String formId, String appId, Object pkId) {
|
public static IFormView createView(String formId, String appId, Object pkId) {
|
||||||
BillShowParameter para = new BillShowParameter();
|
BillShowParameter para = new BillShowParameter();
|
||||||
|
@ -914,4 +943,24 @@ public class ApiService {
|
||||||
SessionManager sm = SessionManager.getCurrent();
|
SessionManager sm = SessionManager.getCurrent();
|
||||||
return sm.getView(para.getPageId());
|
return sm.getView(para.getPageId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String attachmentBase64(String url) {
|
||||||
|
String base64;
|
||||||
|
try (InputStream inputStream = CacheFactory.getCommonCacheFactory().getTempFileCache().getInputStream(url);
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
OutputStream base64OutputStream = Base64.getEncoder().wrap(outputStream)) {
|
||||||
|
byte[] buffer = new byte[4096]; // 使用 4KB 缓冲区
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
base64OutputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
base64OutputStream.flush(); // 确保所有数据都被写入
|
||||||
|
// 获取 Base64 编码后的字节数组
|
||||||
|
byte[] base64Data = outputStream.toByteArray();
|
||||||
|
base64 = new String(base64Data, StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return base64;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,8 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
|
||||||
case "bei_elecreceipt":
|
case "bei_elecreceipt":
|
||||||
DynamicObject[] objects4 = BusinessDataServiceHelper.load("bei_elecreceipt",
|
DynamicObject[] objects4 = BusinessDataServiceHelper.load("bei_elecreceipt",
|
||||||
"id,billno,shkd_pushstatus,fileserverurl,bizdate,oppbankname,description,company,oppbanknumber," +
|
"id,billno,shkd_pushstatus,fileserverurl,bizdate,oppbankname,description,company,oppbanknumber," +
|
||||||
"detaildatetime,accountbank,amount,use,debitamount,creditamount,detailid,uploadfilename"
|
"detaildatetime,accountbank,amount,use,debitamount,creditamount,detailid,uploadfilename," +
|
||||||
|
"shkd_businessnumber,shkd_businessid,shkd_businessname"
|
||||||
, new QFilter("billno", QCP.equals, billNumber).toArray());
|
, new QFilter("billno", QCP.equals, billNumber).toArray());
|
||||||
billObject = objects4[0];
|
billObject = objects4[0];
|
||||||
logger.info("获取银企交易明细查询推送对象 → billObject:{}", billObject);
|
logger.info("获取银企交易明细查询推送对象 → billObject:{}", billObject);
|
||||||
|
|
Loading…
Reference in New Issue