#使用技巧#两个数据中心实现跨数据中心进行取数
一、业务需求
需求描述:需要实现两个数据跨数据中心取数,需要写一个插件放在服务器目录下面来执行。
二、实现步骤
首先需要保证两个数据中的科目以及核算维度的基础资料是相同的,以方便取数。
在报表的API工具里面进行测试
具体实现的公式是:=ACCTAPI("034","6405.99|[HSWD03_SYS~+~部门~+~BM000007]|[ZDY0003~+~收入支出~+~ZC0113]","JF","PRE001",RptInfo("RY"),RptInfo("RP"),RptInfo("RP"),0)+Acct("","6405.99[ZDY0003~+~收入支出项~+~ZC0113]","JF","","","",""),这是依据acct公式来进行设置的,利用ACCTAPI来进行设置公式
示例代码:
using Kingdee.BOS;
using Kingdee.BOS.App.KDSCaculateService.Function;
using Kingdee.BOS.WebApi.Client;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Text;
namespace QRAV.GL.Report.API.ServicePlugIn
{
public class CusAcct : AbstractCustomServicePlugIn
{
public override int MinArgs => 8;
public override int MaxArgs => 8;
public override object GetFunctionValue(Context ctx, KDSContext kdsContext, string[] args)
{
using (StreamWriter streamWriter = new StreamWriter("C:\\KingdeeCloudLog\\DBDSyncLog.txt", append: true))
{
streamWriter.WriteLine("开始调用接口:");
}
Dictionary<string, string> dictionary = new Dictionary<string, string>();
using (StreamWriter streamWriter2 = new StreamWriter("C:\\KingdeeCloudLog\\DBDSyncLog.txt", append: true))
{
streamWriter2.WriteLine("获取参数:");
}
dictionary.Add("AcctZB", args[0]);
dictionary.Add("AcctNumber", args[1].ToString());
dictionary.Add("DataType", args[2].ToString());
dictionary.Add("CurrencyNumber", args[3].ToString());
dictionary.Add("Year", args[4].ToString());
dictionary.Add("StartPeriod", args[5].ToString());
dictionary.Add("EndPeriod", args[6].ToString());
dictionary.Add("AccountLevel", args[7].ToString());
K3CloudApiClient k3CloudApiClient = new K3CloudApiClient("星空的网址");
string text = k3CloudApiClient.ValidateLogin("账号的id", "Administrator", "管理员密码", 2052);
int num = Extensions.Value<int>((IEnumerable<JToken>)JObject.Parse(text).get_Item("LoginResultType"));
if (num != 1)
{
return "API登陆失败!";
}
string cDCReportData = GetCDCReportData(dictionary);
string[] array = dictionary["AcctNumber"].Split('|');
string text2 = array[0];
int num2 = array.Length - 1;
List<List<string>> list = new List<List<string>>();
for (int i = 0; i < num2; i++)
{
string text3 = array[i + 1].Replace("[", "").Replace("]", "").Replace("~+~", "|");
string[] array2 = text3.Split('|');
List<string> list2 = new List<string>();
for (int j = 0; j < array2.Length; j++)
{
if (!array2[j].Equals("") && array2[j] != null)
{
list2.Add(array2[j]);
}
}
list.Add(list2);
}
string[] list3 = new string[list.Count];
for (int k = 0; k < list.Count; k++)
{
List<string> list4 = list[k];
list3[k] = list4[2];
}
DataTable dataTable = new DataTable();
dataTable.Columns.Add("AcctNumber");
dataTable.Columns.Add("FlexNumber");
dataTable.Columns.Add("FlexName");
dataTable.Columns.Add("Amount");
dataTable.Columns.Add("IsDetail");
DataTable dataTable2 = new DataTable();
dataTable2.Columns.Add("AcctNumber");
dataTable2.Columns.Add("FISDETAIL");
dataTable2 = getAcctTable(k3CloudApiClient);
if (cDCReportData != "" || cDCReportData != null)
{
JObject val = JObject.Parse(cDCReportData);
if (val != null)
{
string text4 = ((object)val.get_Item("Result")).ToString();
JObject val2 = JObject.Parse(text4);
if (val2 != null && Convert.ToBoolean(((object)val2.get_Item("IsSuccess")).ToString()))
{
int num3 = Convert.ToInt32(((object)val2.get_Item("RowCount")).ToString());
if (num3 > 0)
{
string text5 = ((object)val2.get_Item("Rows")).ToString();
JArray val3 = JArray.Parse(text5);
for (int l = 0; l < val3.get_Count(); l++)
{
JArray val4 = JArray.Parse(((object)val3.get_Item(l)).ToString());
DataRow dataRow = dataTable.NewRow();
dataRow["AcctNumber"] = ((object)val4.get_Item(0)).ToString();
dataRow["FlexNumber"] = ((object)val4.get_Item(1)).ToString();
dataRow["FlexName"] = ((object)val4.get_Item(2)).ToString();
dataRow["Amount"] = ((object)val4.get_Item(3)).ToString();
if (((object)val4.get_Item(0)).ToString().Trim() != "")
{
DataRow[] array3 = dataTable2.Select("AcctNumber ='" + ((object)val4.get_Item(0)).ToString() + "'");
bool flag = false;
if (array3.Length != 0)
{
flag = Convert.ToBoolean(array3[0]["FISDETAIL"].ToString().Trim());
}
if (flag)
{
dataRow["IsDetail"] = 1;
}
else
{
dataRow["IsDetail"] = 0;
}
}
else
{
dataRow["IsDetail"] = null;
}
dataTable.Rows.Add(dataRow);
}
}
}
}
}
List<int> vis = new List<int>();
for (int m = 0; m < list3.Length; m++)
{
vis.Add(0);
}
List<string> listRow = new List<string>();
List<List<string>> ListPer = new List<List<string>>();
if (list3.Length != 0)
{
permutation(0, vis.Count, ref list3, ref listRow, ref vis, ref ListPer);
}
StringBuilder stringBuilder = new StringBuilder();
for (int n = 0; n < ListPer.Count; n++)
{
List<string> list5 = ListPer[n];
StringBuilder stringBuilder2 = new StringBuilder();
for (int num4 = 0; num4 < list5.Count; num4++)
{
stringBuilder2.Append(list5[num4].ToString());
if (num4 != list5.Count - 1)
{
stringBuilder2.Append("/");
}
}
stringBuilder.Append("FlexNumber like '%").Append(stringBuilder2.ToString()).Append("%'");
if (n != ListPer.Count - 1)
{
stringBuilder.Append(" or ");
}
}
decimal num5 = default(decimal);
if (text2 != null && text2 != "")
{
if (stringBuilder.Length > 0)
{
DataRow[] array4 = dataTable.Select("AcctNumber like '" + text2 + "%' and IsDetail='1'");
if (array4.Length != 0)
{
DataTable dataTable3 = ToDataTable(array4);
DataRow[] array5 = dataTable3.Select(stringBuilder.ToString());
for (int num6 = 0; num6 < array5.Length; num6++)
{
if (array5[num6]["Amount"] != null && array5[num6]["Amount"].ToString().Trim() != "")
{
num5 += Convert.ToDecimal(array5[num6]["Amount"].ToString());
}
}
}
}
else
{
DataRow[] array6 = dataTable.Select("AcctNumber like '" + text2 + "%' and IsDetail='1' and FlexNumber <> ''");
for (int num7 = 0; num7 < array6.Length; num7++)
{
if (array6[num7]["Amount"] != null && array6[num7]["Amount"].ToString().Trim() != "")
{
num5 += Convert.ToDecimal(array6[num7]["Amount"].ToString());
}
}
}
}
return num5;
}
private void permutation(int step, int len, ref string[] list, ref List<string> listRow, ref List<int> vis, ref List<List<string>> ListPer)
{
if (step == len)
{
List<string> list2 = new List<string>();
listCopy(
#使用技巧#两个数据中心实现跨数据中心进行取数
一、业务需求需求描述:需要实现两个数据跨数据中心取数,需要写一个插件放在服务器目录下面来执行。二、实现步骤首先需要保证两个数据中的...
点击下载文档
上一篇:常用简单报表项目勾稽关系下一篇:#使用技巧#
本文2024-09-16 18:55:57发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-25321.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章
阅读排行
确认删除?