Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
fang 2024-11-29 11:50:41 +08:00
commit 3ccd3ed691
3 changed files with 15 additions and 6 deletions

View File

@ -31,7 +31,7 @@ import java.util.*;
public class ApiService { public class ApiService {
private static final Log logger = LogFactory.getLog(ApiService.class); private static final Log logger = LogFactory.getLog(ApiService.class);
public static String getBIPToken() { public static String getBIPToken(String domainName) {
String access_token = null; String access_token = null;
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
try { try {
@ -43,7 +43,7 @@ public class ApiService {
String signature = generateSignature("appKey" + appKey + "timestamp" + timestamp); String signature = generateSignature("appKey" + appKey + "timestamp" + timestamp);
// 构建URL // 构建URL
String urlString = "https://biptest.ctny.com.cn/iuap-api-auth/open-auth/selfAppAuth/getAccessToken" + String urlString = domainName + "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken" +
"?appKey=22564a240d3140d0b15582aca71a748c" + "?appKey=22564a240d3140d0b15582aca71a748c" +
"&timestamp=" + currentTimeMillis + "&timestamp=" + currentTimeMillis +
"&signature=" + signature; "&signature=" + signature;

View File

@ -50,8 +50,10 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
if ("shkd_generatejson".equals(itemKey)) { if ("shkd_generatejson".equals(itemKey)) {
// 获取想要推送单据编码 // 获取想要推送单据编码
String billNumber = dataEntity.getString("shkd_sourcenumber"); String billNumber = dataEntity.getString("shkd_sourcenumber");
logger.info("获取推送单据编码 → billNumber{}", billNumber);
// 获取想要推送单据类型 // 获取想要推送单据类型
String billMark = dataEntity.getDynamicObject("shkd_sourcebill").getDataEntityType().getName(); String billMark = dataEntity.getDynamicObject("shkd_sourcebill").getString("number");
logger.info("获取推送单据类型 → billMark{}", billMark);
// 获取推送单据对象 // 获取推送单据对象
DynamicObject billObject = BusinessDataServiceHelper.loadSingle(billMark, new QFilter("billno", QCP.equals, billNumber).toArray()); DynamicObject billObject = BusinessDataServiceHelper.loadSingle(billMark, new QFilter("billno", QCP.equals, billNumber).toArray());
logger.info("获取推送对象 → billObject{}", billObject); logger.info("获取推送对象 → billObject{}", billObject);
@ -138,10 +140,12 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
} }
jsonArray.add(json); jsonArray.add(json);
codeEdit.setText(jsonArray.toJSONString()); codeEdit.setText(jsonArray.toJSONString());
logger.info("JSON{}", jsonArray.toJSONString());
} else { } else {
JSONObject resultJson = new JSONObject(); JSONObject resultJson = new JSONObject();
processFloor(resultJson, "data", floors.get(0), floors, billObject); processFloor(resultJson, "data", floors.get(0), floors, billObject);
codeEdit.setText(resultJson.toJSONString()); codeEdit.setText(resultJson.toJSONString());
logger.info("JSON{}", resultJson.toJSONString());
} }
} }
@ -158,15 +162,19 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
} }
if ("shkd_testapi".equals(itemKey)) { if ("shkd_testapi".equals(itemKey)) {
String domainName = dataEntity.getString("shkd_domainname");
String url = dataEntity.getString("shkd_url"); String url = dataEntity.getString("shkd_url");
ApiEntity apiEntity = new ApiEntity(); ApiEntity apiEntity = new ApiEntity();
apiEntity.setURL(url); apiEntity.setURL(domainName + url);
apiEntity.setMethod("POST"); apiEntity.setMethod("POST");
Map<String, Object> headMap = new HashMap<>(); Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json"); headMap.put("Content-Type", "application/json");
apiEntity.setHeaders(headMap); apiEntity.setHeaders(headMap);
Map<String, Object> paramsMap = new HashMap<>(); Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("access_token", ApiService.getBIPToken());
String old_url = "https://biptest.ctny.com.cn";
paramsMap.put("access_token", ApiService.getBIPToken(domainName));
apiEntity.setQueryParams(paramsMap); apiEntity.setQueryParams(paramsMap);
apiEntity.setRequestBody(codeEdit.getText()); apiEntity.setRequestBody(codeEdit.getText());
JSONObject responseBody = ApiEntity.getResponseBody(apiEntity); JSONObject responseBody = ApiEntity.getResponseBody(apiEntity);

View File

@ -32,7 +32,8 @@ public class ApiTestBillPlugin extends AbstractBillPlugIn implements Plugin {
String key = evt.getItemKey(); String key = evt.getItemKey();
if ("shkd_token".equals(key)) { if ("shkd_token".equals(key)) {
String bipToken = ApiService.getBIPToken(); String url = this.getModel().getValue("shkd_url").toString();
String bipToken = ApiService.getBIPToken(url);
this.getView().showTipNotification(bipToken); this.getView().showTipNotification(bipToken);
} }