1.付款单提交之后 付款标识为被动付款,并且资金计划科目为空,从配置表(shjh_pay_account)携带资金计划科目
2.SAP应付凭证生成付款申请单后,系统自动根据配置表带出资金计划科目 --s
This commit is contained in:
parent
c31f9238b5
commit
7667e54e70
|
|
@ -4,14 +4,23 @@ import com.alibaba.fastjson.JSONArray;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sap.db.jdbc.packet.ErrorLevel;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.operate.result.OperateErrorInfo;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.QueryServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.webapi.PayreceiptQueryControler;
|
||||
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status;
|
||||
|
||||
/**
|
||||
|
|
@ -19,6 +28,8 @@ import static shjh.jhzj7.fi.fi.utils.SapUtils.unlocked_status;
|
|||
*/
|
||||
public class PayApplySaveOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PayApplySaveOperation.class);
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
|
|
@ -26,6 +37,10 @@ public class PayApplySaveOperation extends AbstractOperationServicePlugIn implem
|
|||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
for (DynamicObject bill : dataEntities) {
|
||||
bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"ap_payapply");
|
||||
// DynamicObject shjhMembersubject = xdMembersubject(bill);
|
||||
// bill.set("shjh_membersubject", shjhMembersubject);
|
||||
// SaveServiceHelper.save(new DynamicObject[]{bill});
|
||||
|
||||
String sourcesystem = bill.getString("shjh_sourcesystem");//来源系统:SAP
|
||||
boolean shjhSapwhetherlocking = bill.getBoolean("shjh_sapwhetherlocking");//SAP是否锁定:未锁定
|
||||
if ("A".equals(sourcesystem) && !shjhSapwhetherlocking) {
|
||||
|
|
@ -60,10 +75,113 @@ public class PayApplySaveOperation extends AbstractOperationServicePlugIn implem
|
|||
}else {
|
||||
//成功:更新状态
|
||||
bill.set("shjh_sapwhetherlocking", true);
|
||||
//SAP应付凭证生成付款申请单后,系统自动根据配置表带出资金计划科目
|
||||
DynamicObject shjhMembersubject = xdMembersubject(bill);
|
||||
bill.set("shjh_membersubject", shjhMembersubject);
|
||||
SaveServiceHelper.save(new DynamicObject[]{bill});
|
||||
this.operationResult.addSuccessPkId(bill.getPkValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static DynamicObject xdMembersubject(DynamicObject bill){
|
||||
//SAP应付凭证生成付款申请单后,系统自动根据配置表(shjh_request_account)带出资金计划科目
|
||||
QFilter qFilter = new QFilter("id",QCP.is_notnull,null);
|
||||
//公司范围_多选基础资料
|
||||
DynamicObject applyorg = bill.getDynamicObject("applyorg");
|
||||
if (null != applyorg) {
|
||||
Long orgid = applyorg.getLong("id");
|
||||
QFilter q1 = new QFilter("shjh_companys.fbasedataid", QCP.equals, orgid);
|
||||
qFilter = qFilter.and(q1);
|
||||
}
|
||||
//是否充值类
|
||||
boolean shjhWhetherrechargecateg = bill.getBoolean("shjh_whetherrechargecateg");
|
||||
QFilter q2 = new QFilter("shjh_czl", QCP.equals, shjhWhetherrechargecateg);
|
||||
qFilter = qFilter.and(q2);
|
||||
|
||||
//是否自行采购
|
||||
boolean shjhZxcg = bill.getBoolean("shjh_zxcg");
|
||||
QFilter q3 = new QFilter("shjh_zxcg", QCP.equals, shjhZxcg);
|
||||
qFilter = qFilter.and(q3);
|
||||
|
||||
//外部系统单据类型_多选下拉
|
||||
String shjhExternalsystemdocume = bill.getString("shjh_externalsystemdocume");
|
||||
QFilter q4 = new QFilter("shjh_billtype", QCP.like, "%"+shjhExternalsystemdocume+"%");
|
||||
qFilter = qFilter.and(q4);
|
||||
|
||||
//事业部_多选基础资料,通过申请单的二级部门去映射表查询(shjh_ejbm_syb)
|
||||
DynamicObject shjhSecondarydept = bill.getDynamicObject("shjh_secondarydept");
|
||||
if (null != shjhSecondarydept) {
|
||||
Long deptid = shjhSecondarydept.getLong("id");
|
||||
QFilter q5 = new QFilter("shjh_orgdept.id", QCP.equals, deptid);
|
||||
DynamicObject ejbm_syb = BusinessDataServiceHelper.loadSingle("shjh_ejbm_syb",
|
||||
"shjh_orgdept,shjh_division", q5.toArray());
|
||||
if (null != ejbm_syb) {
|
||||
DynamicObject shjhDivision = ejbm_syb.getDynamicObject("shjh_division");
|
||||
if (null != shjhDivision) {
|
||||
Long divisionid = shjhDivision.getLong("id");
|
||||
QFilter q6 = new QFilter("shjh_division.fbasedataid", QCP.equals, divisionid);
|
||||
qFilter = qFilter.and(q6);
|
||||
}
|
||||
}
|
||||
}
|
||||
//todo:PO号是否为空
|
||||
|
||||
//采购组_文本
|
||||
String procurementteam = bill.getString("shjh_procurementteam");
|
||||
QFilter q7 = new QFilter("shjh_purgroup", QCP.like, "%"+procurementteam+"%");
|
||||
qFilter = qFilter.and(q7);
|
||||
|
||||
//供应商_多选基础资料
|
||||
DynamicObjectCollection entrys = bill.getDynamicObjectCollection("entry");
|
||||
if (!entrys.isEmpty()) {
|
||||
DynamicObject entry = entrys.get(0);
|
||||
String eAsstacttype = entry.getString("e_asstacttype");
|
||||
if ("bd_supplier".equals(eAsstacttype)) {
|
||||
DynamicObject eAsstact = entry.getDynamicObject("e_asstact");//往来户
|
||||
if (null != eAsstact) {
|
||||
Long eAsstactid = eAsstact.getLong("id");
|
||||
QFilter q8 = new QFilter("shjh_supplier.fbasedataid", QCP.equals, eAsstactid);
|
||||
qFilter = qFilter.and(q8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//原因码_多选基础资料
|
||||
DynamicObject shjhYym = bill.getDynamicObject("shjh_yym");
|
||||
if (null != shjhYym) {
|
||||
Long yymid = shjhYym.getLong("id");
|
||||
QFilter q9 = new QFilter("shjh_yym.fbasedataid", QCP.equals, yymid);
|
||||
qFilter = qFilter.and(q9);
|
||||
}
|
||||
|
||||
//会计科目_多选基础资料
|
||||
DynamicObject shjhSapkjkm = bill.getDynamicObject("shjh_sapkjkm");
|
||||
if (null != shjhSapkjkm) {
|
||||
Long kjkmid = shjhSapkjkm.getLong("id");
|
||||
QFilter q10 = new QFilter("shjh_kjkm.fbasedataid", QCP.equals, kjkmid);
|
||||
qFilter = qFilter.and(q10);
|
||||
}
|
||||
|
||||
DynamicObject[] accounts = BusinessDataServiceHelper.load("shjh_request_account", "id,shjh_membersubject", qFilter.toArray());
|
||||
if (accounts.length > 1) {
|
||||
// 根据生效日期,失效日期区间,判断当前时间满足的数据
|
||||
Date currentDate = new Date();
|
||||
QFilter startDateFilter = new QFilter("shjh_begindate", QCP.less_equals, currentDate);
|
||||
QFilter endDateFilter = new QFilter("shjh_enddate", QCP.large_equals, currentDate);
|
||||
QFilter newFilter = qFilter.and(startDateFilter).and(endDateFilter);
|
||||
accounts = BusinessDataServiceHelper.load("shjh_request_account", "id", newFilter.toArray());
|
||||
}
|
||||
if (accounts.length > 0) {
|
||||
// 处理找到符合条件的账户
|
||||
DynamicObject account = accounts[0];
|
||||
account = BusinessDataServiceHelper.loadSingle(account.getPkValue(), "shjh_request_account");
|
||||
return account.getDynamicObject("shjh_membersubject");
|
||||
} else {
|
||||
log.info("没有找到符合条件的资金计划科目");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,122 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.operate;
|
||||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 付款单提交操作
|
||||
* shjh_cas_paybill_ext
|
||||
*/
|
||||
public class PayBillSubmitOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private static final Log log = LogFactory.getLog(PayBillSubmitOperation.class);
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
//付款单提交之后 付款标识为被动付款,并且资金计划科目为空,从配置表(shjh_pay_account)携带资金计划科目
|
||||
DynamicObject[] dataEntities = e.getDataEntities();
|
||||
for (DynamicObject bill : dataEntities) {
|
||||
bill = BusinessDataServiceHelper.loadSingle(bill.getPkValue(),"cas_paybill");
|
||||
DynamicObject paymentidentify = bill.getDynamicObject("paymentidentify");
|
||||
DynamicObject shjhMembersubject = bill.getDynamicObject("shjh_membersubject");
|
||||
if (null != paymentidentify && null == shjhMembersubject) {
|
||||
String paymentidentifyNumber = paymentidentify.getString("number");
|
||||
if ("FKBS02".equals(paymentidentifyNumber)) {
|
||||
//根据配置表携带资金计划科目
|
||||
xdMembersubject(bill);
|
||||
bill.set("shjh_membersubject", shjhMembersubject);
|
||||
SaveServiceHelper.save(new DynamicObject[]{bill});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static DynamicObject xdMembersubject(DynamicObject bill){
|
||||
//付款单,系统自动根据配置表(shjh_pay_account)带出资金计划科目
|
||||
QFilter qFilter = new QFilter("shjh_biztype", QCP.equals,"A");//业务类型:付款
|
||||
//公司范围_多选基础资料
|
||||
DynamicObject openorg = bill.getDynamicObject("openorg");
|
||||
if (null != openorg) {
|
||||
Long orgid = openorg.getLong("id");
|
||||
QFilter q1 = new QFilter("shjh_companys.fbasedataid", QCP.equals, orgid);
|
||||
qFilter = qFilter.and(q1);
|
||||
}
|
||||
//业务大类
|
||||
DynamicObject shjhBizbig = bill.getDynamicObject("shjh_bizbig");
|
||||
if (null != shjhBizbig) {
|
||||
Long shjhBizbigid = shjhBizbig.getLong("id");
|
||||
QFilter q2 = new QFilter("shjh_bizbig.fbasedataid", QCP.equals, shjhBizbigid);
|
||||
qFilter = qFilter.and(q2);
|
||||
}
|
||||
|
||||
//业务小类
|
||||
DynamicObject shjhbizsmall = bill.getDynamicObject("shjh_bizsmall");
|
||||
if (null != shjhbizsmall) {
|
||||
Long shjhbizsmallid = shjhbizsmall.getLong("id");
|
||||
QFilter q3 = new QFilter("shjh_bizsmall.fbasedataid", QCP.equals, shjhbizsmallid);
|
||||
qFilter = qFilter.and(q3);
|
||||
}
|
||||
|
||||
//成本中心 shjh_costcenter
|
||||
DynamicObject shjhCostcenter = bill.getDynamicObject("shjh_costcenter");
|
||||
if (null != shjhCostcenter) {
|
||||
Long costcenterid = shjhCostcenter.getLong("id");
|
||||
QFilter q4 = new QFilter("shjh_cc.fbasedataid", QCP.equals, costcenterid);
|
||||
qFilter = qFilter.and(q4);
|
||||
}
|
||||
|
||||
//原因码 shjh_yym
|
||||
//会计科目 shjh_sapkjkm
|
||||
DynamicObjectCollection entrys = bill.getDynamicObjectCollection("entry");//付款明细
|
||||
if (!entrys.isEmpty()) {
|
||||
DynamicObject entry = entrys.get(0);
|
||||
DynamicObject shjhYym = entry.getDynamicObject("shjh_yym");
|
||||
if (null != shjhYym) {
|
||||
Long yymid = shjhYym.getLong("id");
|
||||
QFilter q5 = new QFilter("shjh_yym.fbasedataid", QCP.equals, yymid);
|
||||
qFilter = qFilter.and(q5);
|
||||
}
|
||||
|
||||
DynamicObject shjhSapkjkm = entry.getDynamicObject("shjh_sapkjkm");
|
||||
if (null != shjhSapkjkm) {
|
||||
Long kjkmid = shjhSapkjkm.getLong("id");
|
||||
QFilter q6 = new QFilter("shjh_kjkm.fbasedataid", QCP.equals, kjkmid);
|
||||
qFilter = qFilter.and(q6);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DynamicObject[] accounts = BusinessDataServiceHelper.load("shjh_pay_account", "id,shjh_membersubject", qFilter.toArray());
|
||||
if (accounts.length > 1) {
|
||||
// 根据生效日期,失效日期区间,判断当前时间满足的数据
|
||||
Date currentDate = new Date();
|
||||
QFilter startDateFilter = new QFilter("shjh_begindate", QCP.less_equals, currentDate);
|
||||
QFilter endDateFilter = new QFilter("shjh_enddate", QCP.large_equals, currentDate);
|
||||
QFilter newFilter = qFilter.and(startDateFilter).and(endDateFilter);
|
||||
accounts = BusinessDataServiceHelper.load("shjh_pay_account", "id", newFilter.toArray());
|
||||
}
|
||||
if (accounts.length > 0) {
|
||||
// 处理找到符合条件的账户
|
||||
DynamicObject account = accounts[0];
|
||||
account = BusinessDataServiceHelper.loadSingle(account.getPkValue(), "shjh_pay_account");
|
||||
return account.getDynamicObject("shjh_membersubject");
|
||||
} else {
|
||||
log.info("没有找到符合条件的资金计划科目");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue