移动平台第三方系统集成方案V1.0
2.0版本,新增了消息推送及发送待办转已办的消息的功能,详见:
https://vip.kingdee.com/article/45809396501512192
1. 适用环境:7.x版本(2018年8月10号以后),6.x版本(2018年4月26号以后);
2. 路径:cloud后台,系统管理---第三方系统登录授权
3. 配置:
如图,所示,填写应用id,名称,以及集成用户(即对应的用户名称);
根据上述消息生成授权链接:
参考代码如下:
namespace Kingdee.BOS.Mobile.FormPlugIns
{
[Description("第三方授权登录")]
public class TestLoginBySign : AbstractMobilePlugin
{
public override void AfterBindData(EventArgs e)
{
base.AfterBindData(e);
}
public override void AfterButtonClick(Core.DynamicForm.PlugIn.Args.AfterButtonClickEventArgs e)
{
base.AfterButtonClick(e);
if (e.Key.EqualsIgnoreCase("FButton"))
{
string acctID = this.View.Model.GetValue("FAcctID").ToString();
string username = this.View.Model.GetValue("FUserName").ToString();
string appId = this.View.Model.GetValue("FAppID").ToString();
string appSecret = this.View.Model.GetValue("FAppSecret").ToString();
int lcId = 2052;
//时间戳
long timestamp = DateTimeFormatUtils.CurrentTimeMillis() / 1000;
//签名
string[] arr = new string[] { acctID, username, appId, appSecret, timestamp.ToString() };
string sign = Kingdee.BOS.Util.SHA1Util.GetSignature(arr);
//url
string url = string.Format("http://localhost/k3cloud/mobile/k3cloudForPhone.html?acctid={0}&username={1}&appid={2}&sign={3}×tamp={4}&lcid={5}&formid=BOS_MOB_ActivityEdit&formtype=mobileform", acctID, username, appId, sign, timestamp, lcId);
this.View.GetControl("FUrl").SetValue(url);
this.View.UpdateView("FUrl");
}
}
}
}
如果是java环境没有获得签名的包;也可以自己够家里:
public class SHA1Util
{
/// <summary>
/// SHA1签名
/// </summary>
/// <param name="arr"></param>
/// <returns></returns>
public static string GetSignature(string[] arr)
{
//1. 将数组进行排序
//2. 将数组拼接成一个字符串进行sha1加密
Array.Sort(arr, StringComparer.Ordinal);
var arrString = string.Join("", arr);
var sha1 = SHA1.Create();
var sha1Arr = sha1.ComputeHash(Encoding.UTF8.GetBytes(arrString));
StringBuilder enText = new StringBuilder();
foreach (var b in sha1Arr)
{
enText.AppendFormat("{0:x2}", b);
}
return enText.ToString();
}
}
第三方集成打开业务审批待办列表,待办详情,代码示例:
public override voidAfterButtonClick(Core.DynamicForm.PlugIn.Args.AfterButtonClickEventArgs e)
{
base.AfterButtonClick(e);
if (e.Key.EqualsIgnoreCase("FButton"))
{
string acctID =this.View.Model.GetValue("FAcctID").ToString();
string username =this.View.Model.GetValue("FUserName").ToString();
string appId = this.View.Model.GetValue("FAppID").ToString();
string appSecret =this.View.Model.GetValue("FAppSecret").ToString();
int lcId = 2052;
//时间戳
long timestamp = DateTimeFormatUtils.CurrentTimeMillis() / 1000;
//签名
string[] arr = new string[] { acctID, username, appId, appSecret,timestamp.ToString() };
string sign =Kingdee.BOS.Util.SHA1Util.GetSignature(arr);
//业务审批列表:待办列表:Mob_WfToList,已办列表:Mob_WfDonelist,我发起的-进行中:Mob_WfRunningList,我发起的-已完成:Mob_WfCompletedList
string formid = "Mob_WfTodoList";
string formtype = "mobilelist"; string url = string.Format("http://172.17.1.117/k3cloud/mobile/k3cloudForPhone.html?acctid={0}&username={1}&appid={2}&sign={3}×tamp={4}&lcid={5}&formid={6}&formtype={7}", acctID, username, appId, sign, timestamp, lcId, formid, formtype);
this.View.GetControl("FUrl").SetValue(url);
this.View.UpdateView("FUrl");
formid ="MOB_DistributionWFBill";//单据详情跳转页面
formtype ="mobileform";
string pkid ="5cab1a32b049d5";//单据详情主键
//业务审批单据详情
url = string.Format("http://172.17.1.117/k3cloud/mobile/k3cloudForPhone.html?acctid={0}&username={1}&appid={2}&sign={3}×tamp={4}&lcid={5}&formid={6}&formtype={7}&pkid={8}",acctID, username, appId, sign, timestamp, lcId, formid, formtype, pkid);
this.View.GetControl("F_kd_Url").SetValue(url);
this.View.UpdateView("F_kd_Url");
}
移动平台第三方系统集成方案V1.0
本文2024-09-23 04:15:30发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164147.html