1.被动付款入账_定时从付款单携带SAP应付凭证单号
2.若来源为SAP,调用SAP状态修改接口__付款申请关闭调用SAP凭证关闭接口 3.付款排程单列表:退单/作废调通SAP凭证退单/作废状态 --s
This commit is contained in:
parent
e20d9c1415
commit
533be5bc9a
|
|
@ -0,0 +1,80 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.form;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.datamodel.ListSelectedRow;
|
||||
import kd.bos.entity.datamodel.ListSelectedRowCollection;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.form.events.AfterDoOperationEventArgs;
|
||||
import kd.bos.list.plugin.AbstractListPlugin;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
|
||||
import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status;
|
||||
|
||||
/**
|
||||
* 付款排程单列表插件
|
||||
*/
|
||||
public class ScheduleListPlugin extends AbstractListPlugin {
|
||||
|
||||
private static final Log log = LogFactory.getLog(ScheduleListPlugin.class);
|
||||
@Override
|
||||
public void afterDoOperation(AfterDoOperationEventArgs args) {
|
||||
super.afterDoOperation(args);
|
||||
//退单/作废调通SAP凭证退单/作废状态 退单:chargeback 作废:discard
|
||||
String operateKey = args.getOperateKey();
|
||||
OperationResult operationResult = args.getOperationResult();
|
||||
if (operationResult.isSuccess()) {
|
||||
if ("chargeback".equals(operateKey) || "discard".equals(operateKey)) {
|
||||
String status = "chargeback".equals(operateKey)? "04" : "05";
|
||||
processRows(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void processRows(String status) {
|
||||
ListSelectedRowCollection rows = this.getSelectedRows();
|
||||
for (ListSelectedRow row : rows) {
|
||||
Long pk = (Long) row.getPrimaryKeyValue();
|
||||
DynamicObject bill = BusinessDataServiceHelper.loadSingle(pk, "psd_schedulebill");
|
||||
if (bill != null) {
|
||||
String shjhSapuniquevalue = bill.getString("shjh_sapuniquevalue");
|
||||
if (shjhSapuniquevalue != null && !shjhSapuniquevalue.isEmpty()) {
|
||||
JSONArray IT_INPUT = createInputJSONArray(bill, status);
|
||||
JSONObject jsonObjects = unlocked_status(IT_INPUT, bill.getString("billno"));
|
||||
String code = jsonObjects.getString("code");
|
||||
String action = "04".equals(status)? "退单" : "作废";
|
||||
if (!"0".equals(code)) {
|
||||
log.info("付款排程单:" + bill.getString("billno") + "状态" + action + "失败:" + jsonObjects.getString("msg"));
|
||||
} else {
|
||||
log.info("付款排程单:" + bill.getString("billno") + "状态" + action + "成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private JSONArray createInputJSONArray(DynamicObject bill, String status) {
|
||||
JSONArray IT_INPUT = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String FM_CompanyCode = "";
|
||||
if (bill.getDynamicObject("company") != null) {
|
||||
FM_CompanyCode = bill.getDynamicObject("company").getString("number");
|
||||
}
|
||||
jsonObject.put("bukrs", FM_CompanyCode);
|
||||
jsonObject.put("belnr", bill.getString("shjh_credentialnum"));
|
||||
jsonObject.put("gjahr", bill.getString("shjh_voucheryear"));
|
||||
jsonObject.put("stasus", status);
|
||||
String cname = "";
|
||||
if (null!= bill.getDynamicObject("creator")) {
|
||||
cname = bill.getDynamicObject("creator").getString("number");//创建人,工号_申请人
|
||||
}
|
||||
//jsonObject.put("cname", cname);//创建人,工号
|
||||
jsonObject.put("cname", "GH001657");//todo:创建人,工号
|
||||
jsonObject.put("zjddjid", "" + bill.getPkValue());
|
||||
jsonObject.put("zjddjbh", bill.getString("billno"));
|
||||
IT_INPUT.add(jsonObject);
|
||||
return IT_INPUT;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,26 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status;
|
||||
|
||||
/**
|
||||
* 付款申请单据操作插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class PayrequestBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PayrequestBillOperation.class);
|
||||
|
||||
/**
|
||||
* 操作校验通过之后,开启事务之前,触发此事件;
|
||||
* 插件可以在此事件,对通过校验的数据,进行整理
|
||||
|
|
@ -35,4 +44,48 @@ public class PayrequestBillOperation extends AbstractOperationServicePlugIn impl
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String operationKey = e.getOperationKey();
|
||||
if ("closepay".equals(operationKey)) {
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
for (DynamicObject bill : dataEntities) {
|
||||
//若来源为SAP,调用SAP状态修改接口
|
||||
String shjhSapuniquevalue = bill.getString("shjh_sapuniquevalue");//获取SAP唯一值
|
||||
if (shjhSapuniquevalue!= null && !shjhSapuniquevalue.isEmpty()) {
|
||||
|
||||
//调关闭接口
|
||||
JSONArray IT_INPUT = new JSONArray();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
String FM_CompanyCode = "";
|
||||
if (null!= bill.getDynamicObject("applyorg")) {
|
||||
FM_CompanyCode = bill.getDynamicObject("applyorg").getString("number");//公司编码_申请付款组织
|
||||
}
|
||||
jsonObject.put("bukrs",FM_CompanyCode);//公司代码_申请付款组织
|
||||
jsonObject.put("belnr", bill.getString("shjh_vouchernum"));//会计凭证编号_SAP应付凭证号
|
||||
jsonObject.put("gjahr", bill.getString("shjh_voucheryear"));//会计年度_SAP应付凭证会计年度
|
||||
jsonObject.put("stasus", "03");//状态 01:锁定,02:解锁,03:关闭,04:退单:05:作废
|
||||
String cname = "";
|
||||
if (null!= bill.getDynamicObject("creator")) {
|
||||
cname = bill.getDynamicObject("creator").getString("number");//创建人,工号_申请人
|
||||
}
|
||||
// jsonObject.put("cname", cname);//创建人,工号
|
||||
jsonObject.put("cname", "GH001657");//todo:创建人,工号
|
||||
jsonObject.put("zjddjid", ""+bill.getPkValue());//金蝶单据ID
|
||||
jsonObject.put("zjddjbh", bill.getString("billno"));//金蝶单据编号
|
||||
IT_INPUT.add(jsonObject);
|
||||
|
||||
JSONObject jsonObjects = unlocked_status(IT_INPUT,bill.getString("billno"));
|
||||
String code = (String)jsonObjects.get("code");
|
||||
if (!"0".equals(code)) {
|
||||
log.info("付款申请单:"+bill.getString("billno")+"状态关闭失败:" + jsonObject.get("msg"));
|
||||
}else {
|
||||
log.info("付款申请单:"+bill.getString("billno")+"状态关闭成功");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package shjh.jhzj7.fi.fi.plugin.task;
|
|||
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
|
|
@ -21,16 +22,31 @@ public class BeiIntelpayBillTask extends AbstractTask implements Plugin {
|
|||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
|
||||
/*
|
||||
select fsourcebillnumber from T_CAS_PaymentBill where fbillno = 'PV-202503-000162';
|
||||
UPDATE T_CAS_PaymentBill SET shjh_credentialnum = 'cs001' where fbillno = 'PV-202503-000162';
|
||||
*/
|
||||
QFilter q1 = new QFilter("debitamount",QCP.large_than, BigDecimal.ZERO);
|
||||
QFilter q2 = new QFilter("shjh_credentialnum", QCP.equals, "");
|
||||
DynamicObject[] beiIntelpays = BusinessDataServiceHelper.load("bei_intelpay", "id,billno,shjh_credentialnum", new QFilter[]{q1, q2});
|
||||
DynamicObject[] beiIntelpays = BusinessDataServiceHelper.load("bei_intelpay", "id,billno,shjh_credentialnum,recedbillentry," +
|
||||
"recedbillentry.e_recedbillnumber", new QFilter[]{q1, q2});
|
||||
for (DynamicObject beiIntelpay : beiIntelpays) {
|
||||
//获取付款单
|
||||
QFilter q3 = new QFilter("sourcebillnumber", QCP.equals, beiIntelpay.getString("billno"));////源单编码
|
||||
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{q3});
|
||||
if (null != paybill) {
|
||||
beiIntelpay.set("shjh_credentialnum",paybill.getString("shjh_credentialnum"));//SAP应付凭证单号
|
||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
||||
//接收单据信息:recedbillentry
|
||||
DynamicObjectCollection recedbillentry = beiIntelpay.getDynamicObjectCollection("recedbillentry");
|
||||
if (!recedbillentry.isEmpty()) {
|
||||
DynamicObject object = recedbillentry.get(0);
|
||||
if (null != object) {
|
||||
String recedbillnumber = object.getString("e_recedbillnumber");//接收单据编号
|
||||
if (null != recedbillnumber && !recedbillnumber.isEmpty()) {
|
||||
//获取付款单
|
||||
QFilter q3 = new QFilter("billno", QCP.equals, recedbillnumber);//单据编号
|
||||
DynamicObject paybill = BusinessDataServiceHelper.loadSingle("cas_paybill", new QFilter[]{q3});
|
||||
if (null != paybill) {
|
||||
beiIntelpay.set("shjh_credentialnum",paybill.getString("shjh_credentialnum"));//SAP应付凭证单号
|
||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import static shjh.jhzj7.fi.fi.webapi.ApplyAdjustBillControler.loadOrgByCompanyN
|
|||
public class VouchernumControler {
|
||||
private static final String Apimenthod = "费控-SAP付款凭证号接口";
|
||||
private static final Log log = LogFactory.getLog(VouchernumControler.class);
|
||||
private static final String apimenthod = "/paybill_vouchernum";
|
||||
private static final String apimenthod = "/sapvouchernum";
|
||||
|
||||
@ApiPostMapping(value = apimenthod, desc = "费控-SAP付款凭证号接口")
|
||||
public CustomApiResult<ApiResult> paybill_vouchernum(@NotNull @Valid @ApiRequestBody(value = "入参json格式数据") PaybillVoucherNumModel paybillVouchertbill) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue