parent
f5933260b2
commit
03276621b6
|
@ -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<DynamicObject> 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();
|
||||
|
|
|
@ -130,26 +130,6 @@ public class ApiMappingBillPlugin extends AbstractFormPlugin implements Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取子对象集合
|
||||
*
|
||||
* @param floors 所有层级的所有对象
|
||||
* @param parentKey 父节点的shkd_tarfield
|
||||
* @return 子对象集合
|
||||
*/
|
||||
private List<DynamicObject> getChildren(List<List<DynamicObject>> floors, String parentKey) {
|
||||
List<DynamicObject> children = new ArrayList<>();
|
||||
for (List<DynamicObject> 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++) {
|
||||
|
|
|
@ -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<DynamicObject> dynamicObjects;
|
||||
String billName;
|
||||
List<DynamicObject> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue