From 03276621b69d1af77953cccc369b4f05044160e8 Mon Sep 17 00:00:00 2001 From: zoujiangtao Date: Wed, 18 Dec 2024 11:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=86=85=E5=AE=B9=EF=BC=9A?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=20=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=EF=BC=9A=E5=AE=9A=E6=97=B6=E6=8E=A8=E9=80=81=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E8=87=B3BIP=20=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=82=B9?= =?UTF-8?q?=E6=B1=9F=E6=B6=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shkd/sys/sys/mservice/ApiService.java | 24 +++++++++---------- .../sys/plugin/form/ApiMappingBillPlugin.java | 24 ++----------------- .../sys/sys/plugin/task/PushTaskPlugin.java | 11 +-------- 3 files changed, 14 insertions(+), 45 deletions(-) diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java index a9816c8..db5e4b3 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/mservice/ApiService.java @@ -10,7 +10,6 @@ import kd.bos.logging.LogFactory; import kd.bos.orm.query.QCP; import kd.bos.orm.query.QFilter; import kd.bos.servicehelper.BusinessDataServiceHelper; -import okhttp3.OkHttpClient; import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; @@ -34,8 +33,6 @@ import java.util.*; */ public class ApiService { private static final Log logger = LogFactory.getLog(ApiService.class); - - private static final OkHttpClient client = new OkHttpClient(); private static final String APP_KEY = "22564a240d3140d0b15582aca71a748c"; private static final String API_ENDPOINT = "/iuap-api-auth/open-auth/selfAppAuth/getAccessToken"; @@ -150,7 +147,7 @@ public class ApiService { * * @param dynamic 某个单据的 某条需要推送的数据 注:映射字段必须包含在其中,缺失字段会报错 * @param systemName 推送系统标识 - * @return + * @return 推送结果 */ public static String paymentSlipsJson(DynamicObject dynamic, String systemName, List dynamicObjects) { @@ -273,7 +270,7 @@ public class ApiService { * * @param dynamic 推送数据对象 * @param mapping API映射对象数据 - * @return + * @return 组装完成的请求体数据 */ public static String assembleRequestBody(DynamicObject dynamic, DynamicObject mapping) { // 获取数据表信息 @@ -398,7 +395,7 @@ public class ApiService { // 付款金额 BigDecimal debitamount = billObject.getBigDecimal("debitamount"); // 收款金额 - BigDecimal creditamount = billObject.getBigDecimal("creditamount"); +// BigDecimal creditamount = billObject.getBigDecimal("creditamount"); if (debitamount.compareTo(BigDecimal.ZERO) != 0) { value = billObject.get("debitamount"); } else { @@ -408,7 +405,7 @@ public class ApiService { // 付款金额 BigDecimal debitamount = billObject.getBigDecimal("debitamount"); // 收款金额 - BigDecimal creditamount = billObject.getBigDecimal("creditamount"); +// BigDecimal creditamount = billObject.getBigDecimal("creditamount"); if (debitamount.compareTo(BigDecimal.ZERO) != 0) { value = "1";//支出 } else { @@ -474,9 +471,9 @@ public class ApiService { if ("String".equals(tartype) || "Date".equals(tartype)) { jsonObject.put(key, value); } else if ("Integer".equals(tartype)) { - jsonObject.put(key, Integer.parseInt(value.toString())); + jsonObject.put(key, Integer.parseInt(String.valueOf(value))); } else if ("BigDecimal".equals(tartype)) { - jsonObject.put(key, new BigDecimal(value.toString())); + jsonObject.put(key, new BigDecimal(String.valueOf(value))); } else if ("对象".equals(tartype)) { JSONObject childJson = new JSONObject(); processFloor(childJson, key, getChildren(floors, dynamicObject.getString("shkd_tarfield")), floors, billObject); @@ -512,9 +509,10 @@ public class ApiService { /** * 推送单条数据 * - * @param dataEntity - * @param requestBody - * @return + * @param dataEntity API映射数据对象 + * @param linkUrl 请求URL + * @param requestBody 请求体数据 + * @return 推送结果 */ private static String pushBill(DynamicObject dataEntity, String linkUrl, String requestBody) { // 响应数据 @@ -566,7 +564,7 @@ public class ApiService { errorContent.append(errorLine); } errorReader.close(); - formattedContent = "响应失败: " + errorContent.toString(); + formattedContent = "响应失败: " + errorContent; } } catch (Exception e) { formattedContent = "请求失败," + e.getMessage(); diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java index 6fc0340..1878226 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/form/ApiMappingBillPlugin.java @@ -130,26 +130,6 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { } } - - /** - * 获取子对象集合 - * - * @param floors 所有层级的所有对象 - * @param parentKey 父节点的shkd_tarfield - * @return 子对象集合 - */ - private List getChildren(List> floors, String parentKey) { - List children = new ArrayList<>(); - for (List floor : floors) { - for (DynamicObject dynamicObject : floor) { - if (parentKey.equals(dynamicObject.getString("shkd_parentfield"))) { - children.add(dynamicObject); - } - } - } - return children; - } - private void parseJson(Object obj, int level, String parentKey) { if (obj instanceof JSONObject) { JSONObject json = (JSONObject) obj; @@ -227,8 +207,8 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin { /** * 格式化JSON字符串 -> 添加缩进 * - * @param sb - * @param indentLevel + * @param sb 待添加缩进的StringBuilder对象 + * @param indentLevel 添加空格的字符串坐标 */ private void addIndent(StringBuilder sb, int indentLevel) { for (int i = 0; i < indentLevel; i++) { diff --git a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java index f4a68f3..0514793 100644 --- a/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java +++ b/sys/shkd-sys-sys/src/main/java/shkd/sys/sys/plugin/task/PushTaskPlugin.java @@ -1,7 +1,5 @@ package shkd.sys.sys.plugin.task; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.kingdee.bos.qing.util.DateUtils; import kd.bos.context.RequestContext; import kd.bos.dataentity.entity.DynamicObject; @@ -15,7 +13,6 @@ import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.operation.SaveServiceHelper; import kd.sdk.plugin.Plugin; import shkd.sys.sys.mservice.ApiService; -import shkd.sys.sys.plugin.form.ApiMappingBillPlugin; import java.text.ParseException; import java.time.LocalDate; @@ -49,7 +46,6 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { } List dynamicObjects; - String billName; List dynamicObjectList = new ArrayList<>(); if (billMark != null) { switch (billMark.toString()) { @@ -80,7 +76,6 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { .and("billstatus", QCP.equals, "D").toArray()); dynamicObjects = Arrays.asList(objects2); dynamicObjects.forEach(dynamicObject -> ApiService.paymentSlipsJson(dynamicObject, "BIP", dynamicObjectList)); - billName = "收款处理"; break; // 银行收付处理 case "bei_transdetail_cas": @@ -90,7 +85,6 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { "shkd_businessnumber,shkd_businessid,shkd_businessname" , new QFilter("bizdate", QCP.large_equals, date).and("shkd_pushstatus", QCP.not_equals, "已推送").toArray()); dynamicObjects = Arrays.asList(objects3); - billName = "银行收付处理"; break; // 支付结果推送(付款处理支付结果定时推送) case "cas_paybill_result": @@ -110,12 +104,9 @@ public class PushTaskPlugin extends AbstractTask implements Plugin { .and("shkd_pushstatus", QCP.equals, "结算失败").toArray()); dynamicObjects = Arrays.asList(objects4); dynamicObjects.addAll(Arrays.asList(objects5)); - dynamicObjects.forEach(dynamicObject -> { - ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjectList); - }); + dynamicObjects.forEach(dynamicObject -> ApiService.paymentSlipsJson(dynamicObject, "BIPNO", dynamicObjectList)); SaveServiceHelper.save(dynamicObjectList.toArray(new DynamicObject[0])); default: - return; } } }