parent
21c09d2be3
commit
b4cfd0aaf6
|
@ -6,6 +6,8 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.openapi.api.plugin.ApiSavePlugin;
|
||||
import kd.bos.openapi.api.plugin.ApiSerializerPlugin;
|
||||
import kd.bos.openapi.api.plugin.SerializerResult;
|
||||
|
@ -24,13 +26,14 @@ import java.util.Map;
|
|||
* @Date 2024/11/7
|
||||
*/
|
||||
public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin {
|
||||
private static final Log logger = LogFactory.getLog(PayBillApiSavePlugin.class);
|
||||
private static final long serialVersionUID = 7055073356277386444L;
|
||||
private String shkd_businessid;
|
||||
private String shkd_businessnumber;
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
|
||||
|
||||
logger.info("接口调用接口参数:{}", reqData);
|
||||
//付款处理 → 收款人ID payee → 付款银行.编码 payerbank_number payeetype 收款人类型 → payeenumber 收款人编码
|
||||
//payeracctbank_number 付款银行账号.number
|
||||
|
||||
|
@ -51,6 +54,7 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
Object payeetype = map.get("payeetype");//如果是收款人类型 则为付款处理保存接口
|
||||
Object payertype = map.get("payertype");//如果是付款人类型 则为收款处理保存接口
|
||||
if (payeetype != null) {
|
||||
logger.info("进入付款处理单API");
|
||||
objectType = payeetype.toString();
|
||||
objectNumber = map.get("payeenumber").toString();
|
||||
fieldName1 = "payee";
|
||||
|
@ -58,12 +62,14 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
bankNumber = map.get("payeracctbank_number").toString();
|
||||
fieldName2 = "payerbank_number";
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
||||
logger.info("objectType:{},objectNumber:{}", objectType, objectNumber);
|
||||
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
||||
logger.info("amAccountbank:{}", amAccountbank);
|
||||
map.put(fieldName1, dynamicObject.getString("id"));
|
||||
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
||||
}
|
||||
|
||||
if (payertype != null){
|
||||
if (payertype != null) {
|
||||
objectType = payertype.toString();
|
||||
objectNumber = map.get("payernumber").toString();
|
||||
fieldName1 = "payer";
|
||||
|
@ -71,7 +77,9 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
bankNumber = map.get("accountbank_number").toString();
|
||||
fieldName2 = "payeebank_number";
|
||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
||||
logger.info("objectType:{},objectNumber:{}", objectType, objectNumber);
|
||||
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
||||
logger.info("amAccountbank:{}", amAccountbank);
|
||||
map.put(fieldName1, dynamicObject.getString("id"));
|
||||
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
||||
}
|
||||
|
@ -80,14 +88,17 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
// shkd_businessid
|
||||
// shkd_businessnumber
|
||||
// shkd_businessname
|
||||
logger.info("最终处理 → 调用接口参数:{}", reqData);
|
||||
}
|
||||
return reqData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SerializerResult serialize(Object response, String accept, String contentType) {
|
||||
logger.info("进入serialize方法");
|
||||
try {
|
||||
if (contentType.contains(MediaType.APPLICATION_JSON)) {
|
||||
logger.info("进入if");
|
||||
//返回text文本
|
||||
String responseStr = new ObjectMapper().writeValueAsString(response);
|
||||
JSONObject jsonObject = JSON.parseObject(responseStr);
|
||||
|
@ -100,13 +111,15 @@ public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin
|
|||
result.getJSONObject(0).put("shkd_businessnumber", shkd_businessnumber);
|
||||
return new SerializerResult(MediaType.TEXT_PLAIN, jsonObject.toJSONString());
|
||||
} else {
|
||||
logger.info("进入else");
|
||||
//其他类型的出参序列化
|
||||
return null;
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
logger.info("catch");
|
||||
//处理异常时严禁抛出异常,可以定义自己的错误返回信息
|
||||
String result="...";
|
||||
return new SerializerResult(MediaType.TEXT_PLAIN,result);
|
||||
String result = "...";
|
||||
return new SerializerResult(MediaType.TEXT_PLAIN, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue