1.优化付款申请推付款单调度2.凭证新增SAP反写
This commit is contained in:
parent
94026016a5
commit
c0e28a9276
|
|
@ -87,7 +87,7 @@ public class ScheduleListPlugin extends AbstractListPlugin {
|
||||||
} else {
|
} else {
|
||||||
log.info("付款排程单:" + bill.getString("billno") + "状态(SAP)" + action + "成功");
|
log.info("付款排程单:" + bill.getString("billno") + "状态(SAP)" + action + "成功");
|
||||||
//反审核
|
//反审核
|
||||||
closeOrUnauditApply(payapply,"unaudit");
|
//closeOrUnauditApply(payapply,"unaudit");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}else if ("B".equals(sourcesystem)) {
|
}else if ("B".equals(sourcesystem)) {
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
||||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||||
import kd.bos.entity.validate.AbstractValidator;
|
import kd.bos.entity.validate.AbstractValidator;
|
||||||
import kd.bos.entity.validate.ErrorLevel;
|
import kd.bos.entity.validate.ErrorLevel;
|
||||||
|
import kd.bos.logging.Log;
|
||||||
|
import kd.bos.logging.LogFactory;
|
||||||
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;
|
||||||
|
|
@ -40,6 +42,8 @@ import static shjh.jhzj7.fi.fi.utils.SapUtils.*;
|
||||||
*/
|
*/
|
||||||
public class PaybillPushSapOperation extends AbstractOperationServicePlugIn implements Plugin {
|
public class PaybillPushSapOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||||
|
|
||||||
|
private final static Log logger = LogFactory.getLog(PaybillPushSapOperation.class);
|
||||||
|
|
||||||
private static final String userName = "bos_user";//用户
|
private static final String userName = "bos_user";//用户
|
||||||
private static final String INTERFACE_ID = "ReversalVoucher";//识别被调接口并进行路由-SAP反清账
|
private static final String INTERFACE_ID = "ReversalVoucher";//识别被调接口并进行路由-SAP反清账
|
||||||
|
|
||||||
|
|
@ -824,6 +828,14 @@ public class PaybillPushSapOperation extends AbstractOperationServicePlugIn impl
|
||||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//更新凭证
|
||||||
|
QFilter voucherFilters = new QFilter("sourcebill", QCP.equals, bill.getPkValue());
|
||||||
|
DynamicObject voucher = BusinessDataServiceHelper.loadSingle("gl_voucher", voucherFilters.toArray());
|
||||||
|
if (voucher != null) {
|
||||||
|
voucher.set("shjh_sappzh",responseData.getNumber());
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{voucher});
|
||||||
|
logger.info("更新金蝶付款款凭证的SAP凭证号");
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
|
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
|
||||||
operateErrorInfo.setMessage("SAP凭证接口返回值解析失败,请查看接口日志");
|
operateErrorInfo.setMessage("SAP凭证接口返回值解析失败,请查看接口日志");
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,15 @@ public class RecPushVoucherOperation extends AbstractOperationServicePlugIn impl
|
||||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//更新凭证
|
||||||
|
QFilter voucherFilters = new QFilter("sourcebill", QCP.equals, recBill.getPkValue());
|
||||||
|
DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(voucherName, voucherFilters.toArray());
|
||||||
|
if (gl_voucher != null) {
|
||||||
|
gl_voucher.set("shjh_sappzh",responseData.getNumber());
|
||||||
|
SaveServiceHelper.save(new DynamicObject[]{gl_voucher});
|
||||||
|
logger.info("更新金蝶收款凭证的SAP凭证号");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
|
OperateErrorInfo operateErrorInfo = new OperateErrorInfo();
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,7 @@ import kd.bos.util.StringUtils;
|
||||||
import kd.sdk.plugin.Plugin;
|
import kd.sdk.plugin.Plugin;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashSet;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时从付款单携带SAP付凭证单号至被动付款入账中心(主要处理sap主动付款场景)
|
* 定时从付款单携带SAP付凭证单号至被动付款入账中心(主要处理sap主动付款场景)
|
||||||
|
|
@ -26,80 +24,76 @@ public class BeiIntelpayBillTask extends AbstractTask implements Plugin {
|
||||||
//付款处理
|
//付款处理
|
||||||
private static final String KEY_PAY="cas_paybill";
|
private static final String KEY_PAY="cas_paybill";
|
||||||
//下拨处理
|
//下拨处理
|
||||||
private static final String KEY_TRANS="fca_transdownbill";
|
private static final String KEY_DOWN="fca_transdownbill";
|
||||||
//收款处理
|
//收款处理
|
||||||
private static final String KEY_REC="cas_recbill";
|
private static final String KEY_REC="cas_recbill";
|
||||||
|
//上划处理
|
||||||
|
private static final String KEY_UP="fca_transupbill";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
|
// 查询条件:借方金额大于0且凭证号为空
|
||||||
/*
|
QFilter q1 = new QFilter("debitamount", QCP.large_than, BigDecimal.ZERO);
|
||||||
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_credentialnums", QCP.equals, "");
|
QFilter q2 = new QFilter("shjh_credentialnums", QCP.equals, "");
|
||||||
DynamicObject[] beiIntelpays = BusinessDataServiceHelper.load("bei_intelpay", "id," +
|
|
||||||
"billno,shjh_credentialnums,recedbillentry,recedbillentry.e_recedbillnumber", new QFilter[]{q1, q2});
|
// 加载需要处理的智能付款单
|
||||||
|
DynamicObject[] beiIntelpays = BusinessDataServiceHelper.load("bei_intelpay",
|
||||||
|
"id,billno,shjh_credentialnums,recedbillentry,recedbillentry.e_recedbillnumber",
|
||||||
|
new QFilter[]{q1, q2});
|
||||||
|
|
||||||
|
// 用于批量保存
|
||||||
|
List<DynamicObject> toSaveList = new ArrayList<>();
|
||||||
|
|
||||||
for (DynamicObject beiIntelpay : beiIntelpays) {
|
for (DynamicObject beiIntelpay : beiIntelpays) {
|
||||||
//下查
|
// 下查关联单据
|
||||||
Map<String, HashSet<Long>> intelPayMap = BFTrackerServiceHelper.findTargetBills("bei_intelpay", new Long[]{(Long) beiIntelpay.getPkValue()});
|
Map<String, HashSet<Long>> intelPayMap = BFTrackerServiceHelper.findTargetBills(
|
||||||
//付款单
|
"bei_intelpay",
|
||||||
if (intelPayMap.containsKey(KEY_PAY)){
|
new Long[]{(Long) beiIntelpay.getPkValue()});
|
||||||
Set<Long> billIds = intelPayMap.get(KEY_PAY);
|
|
||||||
for (Long billId : billIds) {
|
// 尝试从不同类型的关联单据中获取凭证号
|
||||||
DynamicObject payBill = BusinessDataServiceHelper.loadSingle(billId, KEY_PAY);
|
String credentialNum = findCredentialNum(intelPayMap);
|
||||||
if (null != payBill) {
|
|
||||||
if (StringUtils.isNotEmpty(payBill.getString("shjh_credentialnum"))) {
|
if (StringUtils.isNotEmpty(credentialNum)) {
|
||||||
beiIntelpay.set("shjh_credentialnums",payBill.getString("shjh_credentialnum"));//SAP付款凭证号
|
beiIntelpay.set("shjh_credentialnums", credentialNum);
|
||||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
toSaveList.add(beiIntelpay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}else if (intelPayMap.containsKey(KEY_TRANS)){
|
// 批量保存
|
||||||
Set<Long> billIds = intelPayMap.get(KEY_TRANS);
|
if (!toSaveList.isEmpty()) {
|
||||||
for (Long billId : billIds) {
|
SaveServiceHelper.save(toSaveList.toArray(new DynamicObject[0]));
|
||||||
DynamicObject payBill = BusinessDataServiceHelper.loadSingle(billId, KEY_TRANS);
|
|
||||||
if (null != payBill) {
|
|
||||||
if (StringUtils.isNotEmpty(payBill.getString("shjh_sappzh"))) {
|
|
||||||
beiIntelpay.set("shjh_credentialnums",payBill.getString("shjh_sappzh"));//SAP付款凭证号
|
|
||||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从关联单据中查找凭证号
|
||||||
|
*/
|
||||||
|
private String findCredentialNum(Map<String, HashSet<Long>> intelPayMap) {
|
||||||
|
// 定义查找顺序和对应的字段名
|
||||||
|
Map<String, String> keyToFieldMap = new LinkedHashMap<>();
|
||||||
|
keyToFieldMap.put(KEY_PAY, "shjh_credentialnum");
|
||||||
|
keyToFieldMap.put(KEY_DOWN, "shjh_sappzh");
|
||||||
|
keyToFieldMap.put(KEY_REC, "shjh_vouchernum");
|
||||||
|
keyToFieldMap.put(KEY_UP, "shjh_sappzh");
|
||||||
|
|
||||||
|
// 按顺序查找
|
||||||
|
for (Map.Entry<String, String> entry : keyToFieldMap.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
String fieldName = entry.getValue();
|
||||||
|
|
||||||
|
if (intelPayMap.containsKey(key)) {
|
||||||
|
for (Long billId : intelPayMap.get(key)) {
|
||||||
|
DynamicObject bill = BusinessDataServiceHelper.loadSingle(billId, key);
|
||||||
|
if (bill != null) {
|
||||||
|
String credentialNum = bill.getString(fieldName);
|
||||||
|
if (StringUtils.isNotEmpty(credentialNum)) {
|
||||||
|
return credentialNum;
|
||||||
}
|
}
|
||||||
}else if (intelPayMap.containsKey(KEY_REC)){
|
|
||||||
Set<Long> billIds = intelPayMap.get(KEY_REC);
|
|
||||||
for (Long billId : billIds) {
|
|
||||||
DynamicObject payBill = BusinessDataServiceHelper.loadSingle(billId, KEY_REC);
|
|
||||||
if (null != payBill) {
|
|
||||||
if (StringUtils.isNotEmpty(payBill.getString("shjh_vouchernum"))) {
|
|
||||||
beiIntelpay.set("shjh_credentialnums",payBill.getString("shjh_vouchernum"));//SAP付款凭证号
|
|
||||||
SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//接收单据信息:recedbillentry
|
return null;
|
||||||
// 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",
|
|
||||||
// "id,shjh_credentialnum", new QFilter[]{q3});
|
|
||||||
// if (null != paybill) {
|
|
||||||
// if (StringUtils.isNotEmpty(paybill.getString("shjh_credentialnum"))) {
|
|
||||||
// beiIntelpay.set("shjh_credentialnums",paybill.getString("shjh_credentialnum"));//SAP付款凭证号
|
|
||||||
// SaveServiceHelper.save(new DynamicObject[]{beiIntelpay});
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ public class PayApplyFukuanTask extends AbstractTask implements Plugin {
|
||||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||||
// 【单据状态】=已审核
|
// 【单据状态】=已审核
|
||||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");
|
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");
|
||||||
//qFilter.and(new QFilter("billno",QCP.equals,"FKSQ2507070002"));//测试用
|
//qFilter.and(new QFilter("billno",QCP.equals,"FKSQ2507112268"));//测试用
|
||||||
DynamicObject[] collection = BusinessDataServiceHelper.load(AP_PAYAPPLY, "id,billstatus", qFilter.toArray());
|
DynamicObject[] collection = BusinessDataServiceHelper.load(AP_PAYAPPLY, "id,billstatus", qFilter.toArray());
|
||||||
if (collection.length!=0){
|
if (collection.length!=0){
|
||||||
ArrayList<Long> ids = new ArrayList<>();
|
ArrayList<Long> ids = new ArrayList<>();
|
||||||
|
|
@ -95,6 +95,8 @@ public class PayApplyFukuanTask extends AbstractTask implements Plugin {
|
||||||
//付款申请单的id存于排程单的sourcebillid中 如果id无效果,则用sourcebillnumber 对应付款申请单的billno
|
//付款申请单的id存于排程单的sourcebillid中 如果id无效果,则用sourcebillnumber 对应付款申请单的billno
|
||||||
QFilter sqfilter = new QFilter("sourcebillid", QCP.equals, payrequestid);
|
QFilter sqfilter = new QFilter("sourcebillid", QCP.equals, payrequestid);
|
||||||
sqfilter.and("schedulstatus", QCP.equals, "yetchargeback");//排程状态已退单
|
sqfilter.and("schedulstatus", QCP.equals, "yetchargeback");//排程状态已退单
|
||||||
|
sqfilter.and("modifytime",QCP.large_equals,getDate("start"));
|
||||||
|
sqfilter.and("modifytime",QCP.less_equals,getDate("end"));
|
||||||
if (QueryServiceHelper.exists("psd_schedulebill", sqfilter.toArray())) {
|
if (QueryServiceHelper.exists("psd_schedulebill", sqfilter.toArray())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -145,4 +147,25 @@ public class PayApplyFukuanTask extends AbstractTask implements Plugin {
|
||||||
}
|
}
|
||||||
return hasValidDueDate;
|
return hasValidDueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Date getDate(String key){
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
if ("start".equals(key)){
|
||||||
|
// 获取月初(1号 00:00:00.000)
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
calendar.set(Calendar.MINUTE, 0);
|
||||||
|
calendar.set(Calendar.SECOND, 0);
|
||||||
|
calendar.set(Calendar.MILLISECOND, 0);
|
||||||
|
return calendar.getTime();
|
||||||
|
}else if ("end".equals(key)){
|
||||||
|
// 获取下个月1号,然后减1天得到月底(时间部分仍为 00:00:00.000)
|
||||||
|
calendar.add(Calendar.MONTH, 1);
|
||||||
|
calendar.set(Calendar.DAY_OF_MONTH, 1);
|
||||||
|
calendar.add(Calendar.DATE, -1);
|
||||||
|
return calendar.getTime();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue