parent
f198d19b1d
commit
d05ce5b36e
|
@ -1,10 +1,16 @@
|
||||||
package shkd.sys.sys.plugin.api;
|
package shkd.sys.sys.plugin.api;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import kd.bos.dataentity.entity.DynamicObject;
|
import kd.bos.dataentity.entity.DynamicObject;
|
||||||
import kd.bos.openapi.api.plugin.ApiSavePlugin;
|
import kd.bos.openapi.api.plugin.ApiSavePlugin;
|
||||||
|
import kd.bos.openapi.api.plugin.ApiSerializerPlugin;
|
||||||
|
import kd.bos.openapi.api.plugin.SerializerResult;
|
||||||
|
import kd.bos.openapi.common.constant.MediaType;
|
||||||
import kd.bos.orm.query.QCP;
|
import kd.bos.orm.query.QCP;
|
||||||
import kd.bos.orm.query.QFilter;
|
import kd.bos.orm.query.QFilter;
|
||||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||||
|
import kd.bos.servicehelper.user.UserServiceHelper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -14,14 +20,16 @@ import java.util.Map;
|
||||||
* @Author Tao
|
* @Author Tao
|
||||||
* @Date 2024/11/7
|
* @Date 2024/11/7
|
||||||
*/
|
*/
|
||||||
public class PayBillApiSavePlugin implements ApiSavePlugin {
|
public class PayBillApiSavePlugin implements ApiSavePlugin, ApiSerializerPlugin {
|
||||||
|
private static final long serialVersionUID = 7055073356277386444L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
|
public List<Map<String, Object>> preHandleRequestData(List<Map<String, Object>> reqData) {
|
||||||
//付款处理 → 收款人ID payee → 付款银行.编码 payerbank_number payeetype 收款人类型 → payeenumber 收款人编码
|
//付款处理 → 收款人ID payee → 付款银行.编码 payerbank_number payeetype 收款人类型 → payeenumber 收款人编码
|
||||||
//payeracctbank_number 付款银行账号.number
|
//payeracctbank_number 付款银行账号.number
|
||||||
|
|
||||||
//收款处理 → 付款人ID payer → 收款银行.number payeebank_number payertype 付款人类型 → payernumber 付款人编码
|
//收款处理 → 付款人ID payer → 收款银行.number payeebank_number payertype 付款人类型 → payernumber 付款人编码
|
||||||
//accountbank_number 收款银行账号.number
|
//accountbank_number 收款银行账号.number
|
||||||
|
|
||||||
//重复支付校验
|
//重复支付校验
|
||||||
|
|
||||||
|
@ -33,6 +41,7 @@ public class PayBillApiSavePlugin implements ApiSavePlugin {
|
||||||
String fieldName2;//字段名称(收/付款银行.number)
|
String fieldName2;//字段名称(收/付款银行.number)
|
||||||
for (Map<String, Object> map : reqData) {
|
for (Map<String, Object> map : reqData) {
|
||||||
Object payeetype = map.get("payeetype");//如果是收款人类型 则为付款处理保存接口
|
Object payeetype = map.get("payeetype");//如果是收款人类型 则为付款处理保存接口
|
||||||
|
Object payertype = map.get("payertype");//如果是付款人类型 则为收款处理保存接口
|
||||||
if (payeetype != null) {
|
if (payeetype != null) {
|
||||||
objectType = payeetype.toString();
|
objectType = payeetype.toString();
|
||||||
objectNumber = map.get("payeenumber").toString();
|
objectNumber = map.get("payeenumber").toString();
|
||||||
|
@ -40,19 +49,47 @@ public class PayBillApiSavePlugin implements ApiSavePlugin {
|
||||||
|
|
||||||
bankNumber = map.get("payeracctbank_number").toString();
|
bankNumber = map.get("payeracctbank_number").toString();
|
||||||
fieldName2 = "payerbank_number";
|
fieldName2 = "payerbank_number";
|
||||||
} else {
|
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
||||||
objectType = map.get("payertype").toString();
|
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
||||||
|
map.put(fieldName1, dynamicObject.getString("id"));
|
||||||
|
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payertype != null){
|
||||||
|
objectType = payertype.toString();
|
||||||
objectNumber = map.get("payernumber").toString();
|
objectNumber = map.get("payernumber").toString();
|
||||||
fieldName1 = "payer";
|
fieldName1 = "payer";
|
||||||
|
|
||||||
bankNumber = map.get("accountbank_number").toString();
|
bankNumber = map.get("accountbank_number").toString();
|
||||||
fieldName2 = "payeebank_number";
|
fieldName2 = "payeebank_number";
|
||||||
|
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
||||||
|
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
||||||
|
map.put(fieldName1, dynamicObject.getString("id"));
|
||||||
|
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
||||||
}
|
}
|
||||||
DynamicObject dynamicObject = BusinessDataServiceHelper.loadSingle(objectType, "id", new QFilter("billno", QCP.equals, objectNumber).toArray());
|
|
||||||
DynamicObject amAccountbank = BusinessDataServiceHelper.loadSingle("am_accountbank", "id,bank,bank.number", new QFilter("number", QCP.equals, bankNumber).toArray());
|
// shkd_businessid
|
||||||
map.put(fieldName1, dynamicObject.getString("id"));
|
// shkd_businessnumber
|
||||||
map.put(fieldName2, amAccountbank.getDynamicObject("bank").getString("number"));
|
// shkd_businessname
|
||||||
}
|
}
|
||||||
return reqData;
|
return reqData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SerializerResult serialize(Object response, String accept, String contentType) {
|
||||||
|
try {
|
||||||
|
if (contentType.contains(MediaType.APPLICATION_JSON)) {
|
||||||
|
//返回text文本
|
||||||
|
String responseStr = new ObjectMapper().writeValueAsString(response);
|
||||||
|
return new SerializerResult(MediaType.TEXT_PLAIN, "实际返回:" + responseStr);
|
||||||
|
} else {
|
||||||
|
//其他类型的出参序列化
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
//处理异常时严禁抛出异常,可以定义自己的错误返回信息
|
||||||
|
String result="...";
|
||||||
|
return new SerializerResult(MediaType.TEXT_PLAIN,result);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue