sap清账校验接口、资金计划参考数、预提凭证弹性域

This commit is contained in:
yuxueliang0813 2025-05-06 21:07:43 +08:00
parent d5f7bfed3c
commit d2ad38a107
5 changed files with 79 additions and 25 deletions

View File

@ -53,8 +53,7 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
return; return;
} }
DynamicObject recBill= BusinessDataServiceHelper.loadSingle( DynamicObject recBill= BusinessDataServiceHelper.loadSingle(selectedRows.get(0).getPrimaryKeyValue(),
selectedRows.get(0).getPrimaryKeyValue(),
EntityMetadataCache.getDataEntityType("cas_recbill")); EntityMetadataCache.getDataEntityType("cas_recbill"));
this.changeBillValidator(evt,recBill); this.changeBillValidator(evt,recBill);
}else if ("cancelrec".equals(key)){ }else if ("cancelrec".equals(key)){
@ -71,8 +70,7 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
return; return;
} }
DynamicObject recBill= BusinessDataServiceHelper.loadSingle( DynamicObject recBill= BusinessDataServiceHelper.loadSingle(selectedRows.get(0).getPrimaryKeyValue(),
selectedRows.get(0).getPrimaryKeyValue(),
EntityMetadataCache.getDataEntityType("cas_recbill")); EntityMetadataCache.getDataEntityType("cas_recbill"));
this.cancelRecValidator(evt,recBill); this.cancelRecValidator(evt,recBill);
} }
@ -156,10 +154,12 @@ public class RecBillChangeListExtendPlugin extends AbstractListPlugin implements
JSONObject data = json.getJSONObject("data"); JSONObject data = json.getJSONObject("data");
JSONArray itItems = data.getJSONArray("IT_ITEMS"); JSONArray itItems = data.getJSONArray("IT_ITEMS");
if (itItems != null && !itItems.isEmpty()) { if (itItems != null && !itItems.isEmpty()) {
JSONObject resultItem;
for (int i = 0; i < itItems.size(); i++) { for (int i = 0; i < itItems.size(); i++) {
JSONObject resultItem = itItems.getJSONObject(i); resultItem = itItems.getJSONObject(i);
if ("y".equalsIgnoreCase(resultItem.getString("ZCLEARED"))) { if ("Y".equalsIgnoreCase(resultItem.getString("ZCLEARED")) || "C".equalsIgnoreCase(resultItem.getString("ZCLEARED"))) {
this.getView().showTipNotification("该收款单不满足变更条件该收款单对应的凭证已在SAP清账"); //Y 已清账 C 已冲销
this.getView().showTipNotification("该收款单不满足变更条件该收款单对应的凭证已在SAP清账或冲销");
evt.setCancel(true); evt.setCancel(true);
return; return;
} }

View File

@ -5,7 +5,6 @@ import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.dataentity.utils.StringUtils; import kd.bos.dataentity.utils.StringUtils;
import kd.bos.entity.datamodel.events.PropertyChangedArgs; import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.form.control.events.BeforeItemClickEvent; import kd.bos.form.control.events.BeforeItemClickEvent;
import kd.bos.form.control.events.ItemClickEvent;
import kd.bos.form.events.ClosedCallBackEvent; import kd.bos.form.events.ClosedCallBackEvent;
import kd.bos.form.plugin.AbstractFormPlugin; import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP; import kd.bos.orm.query.QCP;
@ -23,7 +22,6 @@ import java.util.EventObject;
*/ */
public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin { public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin {
@Override @Override
public void registerListener(EventObject e) { public void registerListener(EventObject e) {
super.registerListener(e); super.registerListener(e);
@ -33,6 +31,9 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin {
@Override @Override
public void afterBindData(EventObject e) { public void afterBindData(EventObject e) {
super.afterBindData(e); super.afterBindData(e);
//携带生单规则分录的业务大类,业务小类,成本中心,利润中心到收款处理单头
carryCustomer();
//根据分录清账状态去默认表头的清账状态
String state = (String) this.getModel().getValue(RecFieldsInfo.TOP_BILL_STATUS); String state = (String) this.getModel().getValue(RecFieldsInfo.TOP_BILL_STATUS);
if ("A".equals(state)){ if ("A".equals(state)){
String value = (String) this.getModel().getValue(RecFieldsInfo.CLOSING_STATUS); String value = (String) this.getModel().getValue(RecFieldsInfo.CLOSING_STATUS);
@ -43,10 +44,8 @@ public class RecBillFromPlugin extends AbstractFormPlugin implements Plugin {
} }
} }
} }
//TODO:分录默认清账状态
//携带规则分录的业务大类,业务小类,成本中心,利润中心到收款处理单头
carryCustomer();
} }
private void carryCustomer(){ private void carryCustomer(){
String sourcebilltype = (String)this.getModel().getValue("sourcebilltype");//源单类型:被动付款入账(bei_intelpay) String sourcebilltype = (String)this.getModel().getValue("sourcebilltype");//源单类型:被动付款入账(bei_intelpay)
if (!"bei_intelrec".equals(sourcebilltype)) { if (!"bei_intelrec".equals(sourcebilltype)) {

View File

@ -17,6 +17,7 @@ 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;
import kd.bos.servicehelper.QueryServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import shjh.jhzj7.fi.fi.utils.ApiUtils; import shjh.jhzj7.fi.fi.utils.ApiUtils;
import shjh.jhzj7.fi.fi.utils.JhzjUtils; import shjh.jhzj7.fi.fi.utils.JhzjUtils;
@ -35,6 +36,9 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
private static final String updateVoucherFlag = "update t_cim_revenue set fk_shjh_sendsap=1,shjh_sappzh=? where fid=?;"; private static final String updateVoucherFlag = "update t_cim_revenue set fk_shjh_sendsap=1,shjh_sappzh=? where fid=?;";
private static final String userName = "bos_user";//用户 private static final String userName = "bos_user";//用户
private static final String voucherName = "gl_voucher";//凭证 private static final String voucherName = "gl_voucher";//凭证
private static final String pcName = "shjh_pc";//利润中心
private static final String ccName = "bos_costcenter";//成本中心
private static final String glbdName = "gl_assist_bd";//核算项目组合纵表
private final static Log logger = LogFactory.getLog(RevenueBillOperation.class); private final static Log logger = LogFactory.getLog(RevenueBillOperation.class);
@ -111,13 +115,18 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
//添加用户名过滤条件-操作审核按钮的用户OA用户名 //添加用户名过滤条件-操作审核按钮的用户OA用户名
DynamicObject userinfo = BusinessDataServiceHelper.loadSingleFromCache(RequestContext.get().getCurrUserId(), userName); DynamicObject userinfo = BusinessDataServiceHelper.loadSingleFromCache(RequestContext.get().getCurrUserId(), userName);
String oauser = userinfo.getString("shjh_oauser"); String oauser = userinfo.getString("shjh_oauser");
if(JhzjUtils.isEmpty(oauser)){
IS_HEADER.put("USNAM","资金系统");//用户名
}else{
IS_HEADER.put("USNAM",oauser);//用户名 IS_HEADER.put("USNAM",oauser);//用户名
}
//----------------处理详细入参--获取对应金蝶凭证-------------------- //----------------处理详细入参--获取对应金蝶凭证--------------------
JSONArray IT_ITEM = new JSONArray();//详细 JSONArray IT_ITEM = new JSONArray();//详细
QFilter voucherFilters = new QFilter("sourcebill", QCP.equals, prinfo.getPkValue());//凭证源单ID为预提单 QFilter voucherFilters = new QFilter("sourcebill", QCP.equals, prinfo.getPkValue());//凭证源单ID为预提单
voucherFilters.and(new QFilter("billstatus",QCP.equals,"C"));//凭证状态已审核 voucherFilters.and(new QFilter("billstatus",QCP.equals,"C"));//凭证状态已审核
DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(voucherName, DynamicObject gl_voucher = BusinessDataServiceHelper.loadSingle(voucherName,
"id,sourcebill,entries,entries.account,entries.debitlocal,entries.creditlocal,entries.entrydc,vouchertype", "id,sourcebill,entries,entries.account,entries.assgrp,entries.debitlocal,entries.creditlocal,entries.entrydc,vouchertype",
voucherFilters.toArray()); voucherFilters.toArray());
if (null != gl_voucher) { if (null != gl_voucher) {
IS_HEADER.put("BLART", gl_voucher.getString("vouchertype.number"));//根据金蝶凭证类型设置 IS_HEADER.put("BLART", gl_voucher.getString("vouchertype.number"));//根据金蝶凭证类型设置
@ -125,6 +134,10 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
JSONObject item; JSONObject item;
DynamicObject account; DynamicObject account;
BigDecimal creditlocal; BigDecimal creditlocal;
DynamicObject assgrpinfo;
String asstype;
DynamicObject glassistbd;
DynamicObject hsxminfo;
for (DynamicObject entry : entries) { for (DynamicObject entry : entries) {
item = new JSONObject(); item = new JSONObject();
account = entry.getDynamicObject("account");//科目 account = entry.getDynamicObject("account");//科目
@ -142,10 +155,30 @@ public class RevenueBillOperation extends AbstractOperationServicePlugIn impleme
//设置sap凭证贷方金额 sap通过负数体现贷方 //设置sap凭证贷方金额 sap通过负数体现贷方
item.put("DMBTR", String.valueOf(creditlocal.negate())); item.put("DMBTR", String.valueOf(creditlocal.negate()));
} }
assgrpinfo = entry.getDynamicObject("assgrp");//核算维度(弹性域)
if(assgrpinfo != null){
DynamicObjectCollection gl_assist_bd = QueryServiceHelper.query(glbdName, "asstype,assval",
new QFilter[]{new QFilter("hg.id", QCP.equals, assgrpinfo.getPkValue())});
for (int j = 0; j < gl_assist_bd.size(); j++) {
glassistbd = gl_assist_bd.get(j);
asstype = glassistbd.getString("asstype");//核算项目类型-对应核算维度的字段名
if("f000012".equals(asstype)){
//利润中心 f000012
hsxminfo = QueryServiceHelper.queryOne(pcName, "id,name,number",
new QFilter[]{new QFilter("id", QCP.equals, glassistbd.getLong("assval"))});//维度值
item.put("PRCTR",hsxminfo.getString("number"));//利润中心_利润中心
}else if("f000011".equals(asstype)){
//成本中心 f000011
hsxminfo = QueryServiceHelper.queryOne(ccName, "id,name,number",
new QFilter[]{new QFilter("id", QCP.equals, glassistbd.getLong("assval"))});//维度值
item.put("KOSTL",hsxminfo.getString("number"));//成本中心_成本中心
}
}
}
// item.put("RSTGR", "014");//原因代码_原因码 // item.put("RSTGR", "014");//原因代码_原因码
// item.put("SGTXT", SGTXT);//行项目文本_SAP会计科目行项目号 // item.put("SGTXT", SGTXT);//行项目文本_SAP会计科目行项目号
// item.put("KOSTL",KOSTL);//成本中心_成本中心
// item.put("PRCTR",PRCTR);//利润中心_利润中心
IT_ITEM.add(item); IT_ITEM.add(item);
} }
}else{ }else{

View File

@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson; import com.google.gson.Gson;
import kd.bos.context.RequestContext; import kd.bos.context.RequestContext;
import kd.bos.dataentity.OperateOption;
import kd.bos.dataentity.entity.DynamicObject; import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.dataentity.entity.DynamicObjectCollection; import kd.bos.dataentity.entity.DynamicObjectCollection;
import kd.bos.entity.operate.OperateOptionConst;
import kd.bos.exception.KDException; import kd.bos.exception.KDException;
import kd.bos.logging.Log; import kd.bos.logging.Log;
import kd.bos.logging.LogFactory; import kd.bos.logging.LogFactory;
@ -14,6 +16,7 @@ import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter; import kd.bos.orm.query.QFilter;
import kd.bos.schedule.executor.AbstractTask; import kd.bos.schedule.executor.AbstractTask;
import kd.bos.servicehelper.BusinessDataServiceHelper; import kd.bos.servicehelper.BusinessDataServiceHelper;
import kd.bos.servicehelper.operation.OperationServiceHelper;
import kd.sdk.plugin.Plugin; import kd.sdk.plugin.Plugin;
import kd.tmc.fpm.business.dataproc.save.ReportDataSDKService; import kd.tmc.fpm.business.dataproc.save.ReportDataSDKService;
import kd.tmc.fpm.business.dataproc.save.domain.FpmResponse; import kd.tmc.fpm.business.dataproc.save.domain.FpmResponse;
@ -26,6 +29,7 @@ import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
/** /**
* 定时任务更新付款资金计划的计划参考数 * 定时任务更新付款资金计划的计划参考数
* @author yuxueliang * @author yuxueliang
@ -47,7 +51,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
// qFilter.and("name", QCP.equals, " 编制表");//报表名称--非报表类型名称注释此过滤条件 // qFilter.and("name", QCP.equals, " 编制表");//报表名称--非报表类型名称注释此过滤条件
qFilter.and("enable", QCP.equals, "1");//是否可用 qFilter.and("enable", QCP.equals, "1");//是否可用
qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制 qFilter.and("reportplantype", QCP.equals, "reportplan");//报表类型-计划编制
DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id", qFilter.toArray()); DynamicObject[] collection = BusinessDataServiceHelper.load(entityName, "id,maindimentry", qFilter.toArray());
if(collection.length > 0){ if(collection.length > 0){
//调用SAP应付未清接口按照事业部月份计划科目汇总金额 //调用SAP应付未清接口按照事业部月份计划科目汇总金额
Map<String, BigDecimal> acctamountMap = getSapAR(); Map<String, BigDecimal> acctamountMap = getSapAR();
@ -69,15 +73,26 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
String billno;//资金计划编制单号 String billno;//资金计划编制单号
String result;//反写结果 String result;//反写结果
FpmResponse<Void> frv;//反写结果 FpmResponse<Void> frv;//反写结果
OperateOption option = OperateOption.create();
option.setVariableValue(OperateOptionConst.IGNOREWARN, String.valueOf(false)); // 不执行警告级别校验器
for(DynamicObject doinfo : collection){ for(DynamicObject doinfo : collection){
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName);
billno = doinfo.getString("billno");
logger.info("资金计划编制单号"+billno);
maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录 maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录
if(maindimentrys.isEmpty()){ if(maindimentrys.isEmpty()){
logger.info("资金计划编制单主维度分录为空,不继续反写"+billno); //自动触发调用保存操作现在测试出来前台保存后才会有这个维度分录
// doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName);
OperationServiceHelper.executeOperate("save", entityName, new DynamicObject[]{doinfo}, option);
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName);
maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录
if(maindimentrys.isEmpty()){
logger.info("资金计划编制主维度分录为空"+doinfo.getString("billno"));
continue; continue;
} }
}else{
doinfo = BusinessDataServiceHelper.loadSingle(doinfo.getPkValue(),entityName);
maindimentrys = doinfo.getDynamicObjectCollection("maindimentry");//主维度分录
}
billno = doinfo.getString("billno");
logger.info("资金计划编制单号"+billno);
json_obj = new JSONObject(); json_obj = new JSONObject();
//体系编号 非必填时系统通过编报主体 code确定需保证一个编报主体只关联一个体系 //体系编号 非必填时系统通过编报主体 code确定需保证一个编报主体只关联一个体系
json_obj.put("systemCode",doinfo.getDynamicObject("bodysys").getString("number")); json_obj.put("systemCode",doinfo.getDynamicObject("bodysys").getString("number"));
@ -106,6 +121,9 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
//PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度 //PLANREFERENCEAMT 计划参考值 ACTMAT 已执行额度
mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型 mmInfo.put("templateMetricType","PLANREFERENCEAMT");//度量值预置类型
mmInfo.put("amount",acctamountMap.get(months+accountnum));//写入金额-从SAP接口中获取 mmInfo.put("amount",acctamountMap.get(months+accountnum));//写入金额-从SAP接口中获取
logger.info(billno+"付款计划参考数入参 months "+months);
logger.info(billno+"付款计划参考数入参 accountnum "+accountnum);
logger.info(billno+"付款计划参考数"+acctamountMap.get(months+accountnum));
mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元 mmInfo.put("amountUnit","one");//金额单位 one元 thousand千元 ten_thousand 万元
mms.add(mmInfo); mms.add(mmInfo);
itemInfo.put("metricMembers",mms);//度量值列表 itemInfo.put("metricMembers",mms);//度量值列表
@ -138,6 +156,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
String duedate_ends = sdf.format(cal.getTime()); String duedate_ends = sdf.format(cal.getTime());
// addFilterCondition(IT_LIST, "FAEDT", duedate_starts, duedate_ends);//到期日 // addFilterCondition(IT_LIST, "FAEDT", duedate_starts, duedate_ends);//到期日
addFilterCondition(IT_LIST, "FAEDT", "20241101", duedate_ends);//到期日 addFilterCondition(IT_LIST, "FAEDT", "20241101", duedate_ends);//到期日
// addFilterCondition(IT_LIST, "BELNR", "1900000004", "1900000004");//测试debug 增加科目编号过滤
JSONObject sapresult = SapUtils.vouchers_payable(IT_LIST, "FundPlanPaymentTask"); JSONObject sapresult = SapUtils.vouchers_payable(IT_LIST, "FundPlanPaymentTask");
if(sapresult != null){ if(sapresult != null){
JSONObject data = sapresult.getJSONObject("data"); JSONObject data = sapresult.getJSONObject("data");
@ -179,6 +198,7 @@ public class FundPlanPaymentTask extends AbstractTask implements Plugin {
}else{ }else{
acctamountMap.put(mapkey,amount); acctamountMap.put(mapkey,amount);
} }
logger.info("SAP应付凭证对应资金科目"+mapkey);
//根据二级部门和事业部关系将该笔金额归属到事业部上 //根据二级部门和事业部关系将该笔金额归属到事业部上
// ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_orgdept.number", QCP.equals, deptnum)}); // ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_orgdept.number", QCP.equals, deptnum)});
// if(ppsybinfo != null){ // if(ppsybinfo != null){

View File

@ -67,11 +67,13 @@ public class ClosingStatusValidator extends AbstractValidator {
JSONObject data = json.getJSONObject("data"); JSONObject data = json.getJSONObject("data");
JSONArray itItems = data.getJSONArray("IT_ITEMS"); JSONArray itItems = data.getJSONArray("IT_ITEMS");
if (itItems != null && !itItems.isEmpty()) { if (itItems != null && !itItems.isEmpty()) {
JSONObject resultItem;
for (int i = 0; i < itItems.size(); i++) { for (int i = 0; i < itItems.size(); i++) {
JSONObject resultItem = itItems.getJSONObject(i); resultItem = itItems.getJSONObject(i);
//如果已清金蝶系统提示当前经办人不允许提交需要前往SAP处理反清账后再做收款变更 //如果已清金蝶系统提示当前经办人不允许提交需要前往SAP处理反清账后再做收款变更
if ("y".equalsIgnoreCase(resultItem.getString("ZCLEARED"))) { if ("Y".equalsIgnoreCase(resultItem.getString("ZCLEARED")) || "C".equalsIgnoreCase(resultItem.getString("ZCLEARED"))) {
this.addErrorMessage(dataEntity, "提交失败所选单据在SAP已清账需前往SAP处理反清账后再做收款变更。"); //Y 已清账 C 已冲销
this.addErrorMessage(dataEntity, "提交失败所选单据在SAP已清账或冲销需前往SAP处理后再做收款变更。");
break; break;
} }
} }