Commit 7e7913b4 by 陶然

优化

parent 34449a9d
...@@ -33,11 +33,27 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -33,11 +33,27 @@ namespace Kivii.Finances.Seeyon.Extensions
} }
} }
public static ResponseForm<ResponseData> RequestBillForm0710(this JsonServiceClient client, FormMain_OrdinaryInvoice0710 form, IAuthSession session) public static ResponseOrgMember RequestOrgMember(this JsonServiceClient client, string loginName, ResponseToken token)
{
if (client == null) throw new ArgumentNullException("client");
if (loginName.IsNullOrEmpty()) throw new ArgumentNullException("loginName");
try
{
var rtns = client.Get<ResponseOrgMember>($"{Configs.RouteOrgMember}?token={token.id}&&loginName={loginName}");
return rtns;
}
catch (Exception ex)
{
throw new Exception($"{ex.Message},可能原因:当前登录人{loginName},无法与OA账号对应,请联系管理员确认!");
}
}
public static ResponseForm<ResponseData> RequestBillForm0710(this JsonServiceClient client, FormMain_OrdinaryInvoice0710 form, ResponseToken token)
{ {
if (client == null) throw new ArgumentNullException("client"); if (client == null) throw new ArgumentNullException("client");
if (form == null) throw new ArgumentNullException("form"); if (form == null) throw new ArgumentNullException("form");
var token = client.RequestRestToken(session.FullName); //var token = client.RequestRestToken(session.FullName);
var request = new RequestForm<RequestForm_InvoiceApply>(); var request = new RequestForm<RequestForm_InvoiceApply>();
request.appName = Configs.appName;//"collaboration"; request.appName = Configs.appName;//"collaboration";
request.data = new RequestData<RequestForm_InvoiceApply>(); request.data = new RequestData<RequestForm_InvoiceApply>();
...@@ -57,11 +73,11 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -57,11 +73,11 @@ namespace Kivii.Finances.Seeyon.Extensions
return rtns; return rtns;
} }
public static ResponseForm<ResponseData> RequestBillForm0318(this JsonServiceClient client, FormMain_AdvanceInvoice0318 form, IAuthSession session) public static ResponseForm<ResponseData> RequestBillForm0318(this JsonServiceClient client, FormMain_AdvanceInvoice0318 form, ResponseToken token)
{ {
if (client == null) throw new ArgumentNullException("client"); if (client == null) throw new ArgumentNullException("client");
if (form == null) throw new ArgumentNullException("form"); if (form == null) throw new ArgumentNullException("form");
var token = client.RequestRestToken(session.FullName); //var token = client.RequestRestToken(session.FullName);
var request = new RequestForm<RequestForm_InvoiceApply>(); var request = new RequestForm<RequestForm_InvoiceApply>();
request.appName = Configs.appName;//"collaboration"; request.appName = Configs.appName;//"collaboration";
request.data = new RequestData<RequestForm_InvoiceApply>(); request.data = new RequestData<RequestForm_InvoiceApply>();
...@@ -82,8 +98,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -82,8 +98,10 @@ namespace Kivii.Finances.Seeyon.Extensions
} }
public static FormMain_OrdinaryInvoice0710 PayedConvertToForm(this List<InvoiceApply> applys) public static FormMain_OrdinaryInvoice0710 PayedConvertToForm(this List<InvoiceApply> applys, ResponseOrgMember orgMember)
{ {
//var orgMember = client.RequestOrgMember(session.FullName);
if (orgMember == null) throw new Exception("未找到OA登录人员信息!");
var apply = applys[0]; var apply = applys[0];
var bizKvids = applys.ConvertAll(o => o.Kvid.ToString()); var bizKvids = applys.ConvertAll(o => o.Kvid.ToString());
//var strBizKvids = JsonSerializer.SerializeToString(bizKvids); //var strBizKvids = JsonSerializer.SerializeToString(bizKvids);
...@@ -94,9 +112,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -94,9 +112,10 @@ namespace Kivii.Finances.Seeyon.Extensions
rtns.业务编号 = bizKvids; rtns.业务编号 = bizKvids;
rtns.单据编号 = apply.SerialNumber; rtns.单据编号 = apply.SerialNumber;
rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd"); rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd");
rtns.申请部门 = KiviiContext.CurrentMember.DepartmentName; rtns.申请部门 = orgMember.orgDepartmentId;//KiviiContext.CurrentMember.DepartmentName;
rtns.申请人 = apply.OperatorName; rtns.申请人 = orgMember.id;//apply.OperatorName;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票"? "4529935671729733794": "4728848026009816823"); rtns.单位 = orgMember.orgAccountId;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票" ? "4529935671729733794" : "4728848026009816823");
rtns.数量 = "1"; rtns.数量 = "1";
rtns.总金额 = amount.ToString(); rtns.总金额 = amount.ToString();
rtns.金额大写 = amount.ConvertToChinese(); rtns.金额大写 = amount.ConvertToChinese();
...@@ -113,8 +132,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -113,8 +132,10 @@ namespace Kivii.Finances.Seeyon.Extensions
return rtns; return rtns;
} }
public static FormMain_OrdinaryInvoice0710 PayedConvertToForm(this InvoiceApply apply) public static FormMain_OrdinaryInvoice0710 PayedConvertToForm(this InvoiceApply apply, ResponseOrgMember orgMember)
{ {
//var orgMember = client.RequestOrgMember(session.FullName);
if (orgMember == null) throw new Exception("未找到OA登录人员信息!");
var bizKvids = new List<string>(); var bizKvids = new List<string>();
bizKvids.Add(apply.Kvid.ToString()); bizKvids.Add(apply.Kvid.ToString());
var rtns = new FormMain_OrdinaryInvoice0710(); var rtns = new FormMain_OrdinaryInvoice0710();
...@@ -123,9 +144,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -123,9 +144,10 @@ namespace Kivii.Finances.Seeyon.Extensions
rtns.业务编号 = bizKvids; rtns.业务编号 = bizKvids;
rtns.单据编号 = apply.SerialNumber; rtns.单据编号 = apply.SerialNumber;
rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd"); rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd");
rtns.申请部门 = KiviiContext.CurrentMember.DepartmentName; rtns.申请部门 = orgMember.orgDepartmentId;//KiviiContext.CurrentMember.DepartmentName;
rtns.申请人 = apply.OperatorName; rtns.申请人 = orgMember.id;//apply.OperatorName;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票"? "4529935671729733794": "4728848026009816823"); rtns.单位 = orgMember.orgAccountId;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票" ? "4529935671729733794" : "4728848026009816823");
rtns.数量 = "1"; rtns.数量 = "1";
rtns.总金额 = apply.Amount.ToString(); rtns.总金额 = apply.Amount.ToString();
rtns.金额大写 = apply.Amount.ConvertToChinese(); rtns.金额大写 = apply.Amount.ConvertToChinese();
...@@ -142,8 +164,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -142,8 +164,10 @@ namespace Kivii.Finances.Seeyon.Extensions
return rtns; return rtns;
} }
public static FormMain_AdvanceInvoice0318 DebitConvertToForm(this List<InvoiceApply> applys) public static FormMain_AdvanceInvoice0318 DebitConvertToForm(this List<InvoiceApply> applys, ResponseOrgMember orgMember)
{ {
//var orgMember = client.RequestOrgMember(session.FullName);
if (orgMember == null) throw new Exception("未找到OA登录人员信息!");
var apply = applys[0]; var apply = applys[0];
var bizKvids = applys.ConvertAll(o => o.Kvid.ToString()); var bizKvids = applys.ConvertAll(o => o.Kvid.ToString());
//var strBizKvids = JsonSerializer.SerializeToString(bizKvids); //var strBizKvids = JsonSerializer.SerializeToString(bizKvids);
...@@ -154,9 +178,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -154,9 +178,10 @@ namespace Kivii.Finances.Seeyon.Extensions
rtns.业务编号 = bizKvids; rtns.业务编号 = bizKvids;
rtns.单据编号 = apply.SerialNumber; rtns.单据编号 = apply.SerialNumber;
rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd"); rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd");
rtns.申请部门 = KiviiContext.CurrentMember.DepartmentName; rtns.申请部门 = orgMember.orgDepartmentId;//KiviiContext.CurrentMember.DepartmentName;
rtns.申请人 = apply.OperatorName; rtns.申请人 = orgMember.id;//apply.OperatorName;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票"? "4529935671729733794": "4728848026009816823"); rtns.单位 = orgMember.orgAccountId;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票" ? "4529935671729733794" : "4728848026009816823");
rtns.数量 = "1"; rtns.数量 = "1";
rtns.总金额 = amount.ToString(); rtns.总金额 = amount.ToString();
rtns.金额大写 = amount.ConvertToChinese(); rtns.金额大写 = amount.ConvertToChinese();
...@@ -173,8 +198,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -173,8 +198,10 @@ namespace Kivii.Finances.Seeyon.Extensions
return rtns; return rtns;
} }
public static FormMain_AdvanceInvoice0318 DebitConvertToForm(this InvoiceApply apply) public static FormMain_AdvanceInvoice0318 DebitConvertToForm(this InvoiceApply apply, ResponseOrgMember orgMember)
{ {
//var orgMember = client.RequestOrgMember(session.FullName);
if (orgMember == null) throw new Exception("未找到OA登录人员信息!");
var bizKvids = new List<string>(); var bizKvids = new List<string>();
bizKvids.Add(apply.Kvid.ToString()); bizKvids.Add(apply.Kvid.ToString());
var rtns = new FormMain_AdvanceInvoice0318(); var rtns = new FormMain_AdvanceInvoice0318();
...@@ -183,9 +210,10 @@ namespace Kivii.Finances.Seeyon.Extensions ...@@ -183,9 +210,10 @@ namespace Kivii.Finances.Seeyon.Extensions
rtns.业务编号 = bizKvids; rtns.业务编号 = bizKvids;
rtns.单据编号 = apply.SerialNumber; rtns.单据编号 = apply.SerialNumber;
rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd"); rtns.申请日期 = DateTime.Now.ToString("yyyy-MM-dd");
rtns.申请部门 = KiviiContext.CurrentMember.DepartmentName; rtns.申请部门 = orgMember.orgDepartmentId;//KiviiContext.CurrentMember.DepartmentName;
rtns.申请人 = apply.OperatorName; rtns.申请人 = orgMember.id;//apply.OperatorName;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票"? "4529935671729733794": "4728848026009816823"); rtns.单位 = orgMember.orgAccountId;
rtns.发票类型 = apply.Type == "增值税专用发票" ? "-4189929216282050282" : (apply.Type == "增值税普通发票" ? "4529935671729733794" : "4728848026009816823");
rtns.数量 = "1"; rtns.数量 = "1";
rtns.总金额 = apply.Amount.ToString(); rtns.总金额 = apply.Amount.ToString();
rtns.金额大写 = apply.Amount.ConvertToChinese(); rtns.金额大写 = apply.Amount.ConvertToChinese();
......
...@@ -12,9 +12,21 @@ namespace Kivii.Finances.Seeyon ...@@ -12,9 +12,21 @@ namespace Kivii.Finances.Seeyon
public const string TableNameApply = "FINA_Applies"; public const string TableNameApply = "FINA_Applies";
/// <summary>
/// 提交表单接口
/// </summary>
internal static string RouteRequestForm = "/seeyon/rest/bpm/process/start"; internal static string RouteRequestForm = "/seeyon/rest/bpm/process/start";
/// <summary>
/// 获取token接口
/// </summary>
internal static string RouteRestToken = "/seeyon/rest/token"; internal static string RouteRestToken = "/seeyon/rest/token";
/// <summary>
/// 按登录名取人员信息
/// </summary>
internal static string RouteOrgMember = "/seeyon/rest/orgMember";
internal static string appName = "collaboration";//"collaboration";//OA提供 internal static string appName = "collaboration";//"collaboration";//OA提供
internal static string templateCodeAdvanceInvoice = "AdvanceInvoice";//OA提供 internal static string templateCodeAdvanceInvoice = "AdvanceInvoice";//OA提供
internal static string templateCodeOrdinaryInvoice = "OrdinaryInvoice";//OA提供 internal static string templateCodeOrdinaryInvoice = "OrdinaryInvoice";//OA提供
......
...@@ -146,15 +146,17 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -146,15 +146,17 @@ namespace Kivii.Finances.Seeyon.Entities
apply.ThrowIfNull("未找到此业务信息!"); apply.ThrowIfNull("未找到此业务信息!");
if (apply.Status > (int)InvoiceApplyStatus.ProcessAdoption) throw new Exception("当前账单借票非待审批状态,无法申请审批!"); if (apply.Status > (int)InvoiceApplyStatus.ProcessAdoption) throw new Exception("当前账单借票非待审批状态,无法申请审批!");
var session = KiviiContext.Request.GetSession(); var session = KiviiContext.Request.GetSession();
var client = new JsonServiceClient(Configs.BaseUrl);
var token = client.RequestRestToken(session.FullName);
var orgMember = client.RequestOrgMember(session.FullName, token);
var rtns = new RestfulUpdateResponse<InvoiceApply>(); var rtns = new RestfulUpdateResponse<InvoiceApply>();
rtns.Results = new List<InvoiceApply>(); rtns.Results = new List<InvoiceApply>();
var client = new JsonServiceClient(Configs.BaseUrl);
if (apply.OperateType == InvoiceApplyType.Payment) if (apply.OperateType == InvoiceApplyType.Payment)
{ {
var applyForm = apply.PayedConvertToForm(); var applyForm = apply.PayedConvertToForm(orgMember);
var resp = client.RequestBillForm0710(applyForm, session); var resp = client.RequestBillForm0710(applyForm, token);
if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}"); if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}");
apply.BizId = resp.data.subject; apply.BizId = resp.data.subject;
apply.AddOnlyProperties(o => o.BizId); apply.AddOnlyProperties(o => o.BizId);
...@@ -174,8 +176,8 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -174,8 +176,8 @@ namespace Kivii.Finances.Seeyon.Entities
} }
else else
{ {
var applyForm = apply.DebitConvertToForm(); var applyForm = apply.DebitConvertToForm(orgMember);
var resp = client.RequestBillForm0318(applyForm, session); var resp = client.RequestBillForm0318(applyForm, token);
if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}"); if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}");
apply.BizId = resp.data.subject; apply.BizId = resp.data.subject;
apply.AddOnlyProperties(o => o.BizId); apply.AddOnlyProperties(o => o.BizId);
...@@ -214,15 +216,17 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -214,15 +216,17 @@ namespace Kivii.Finances.Seeyon.Entities
var groupType = applys.GroupBy(o => o.OperateType); var groupType = applys.GroupBy(o => o.OperateType);
if (groupType.Count() != 1) throw new Exception("不允许多个申请类型同时申请!"); if (groupType.Count() != 1) throw new Exception("不允许多个申请类型同时申请!");
var session = KiviiContext.Request.GetSession(); var session = KiviiContext.Request.GetSession();
var client = new JsonServiceClient(Configs.BaseUrl);
var token = client.RequestRestToken(session.FullName);
var orgMember = client.RequestOrgMember(session.FullName, token);
var rtns = new RestfulUpdateResponse<InvoiceApply>(); var rtns = new RestfulUpdateResponse<InvoiceApply>();
rtns.Results = new List<InvoiceApply>(); rtns.Results = new List<InvoiceApply>();
var client = new JsonServiceClient(Configs.BaseUrl);
if (groupType.FirstOrDefault().Key == InvoiceApplyType.Payment) if (groupType.FirstOrDefault().Key == InvoiceApplyType.Payment)
{ {
var applyForm = applys.PayedConvertToForm(); var applyForm = applys.PayedConvertToForm(orgMember);
var resp = client.RequestBillForm0710(applyForm, session); var resp = client.RequestBillForm0710(applyForm, token);
if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}"); if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}");
foreach (var apply in applys) foreach (var apply in applys)
{ {
...@@ -245,8 +249,8 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -245,8 +249,8 @@ namespace Kivii.Finances.Seeyon.Entities
} }
else else
{ {
var applyForm = applys.DebitConvertToForm(); var applyForm = applys.DebitConvertToForm(orgMember);
var resp = client.RequestBillForm0318(applyForm, session); var resp = client.RequestBillForm0318(applyForm, token);
if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}"); if (resp.code != "0") throw new Exception($"OA接口调用失败,原因:{resp.message}");
foreach (var apply in applys) foreach (var apply in applys)
{ {
...@@ -303,10 +307,19 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -303,10 +307,19 @@ namespace Kivii.Finances.Seeyon.Entities
/// </summary> /// </summary>
public string 申请日期 { get; set; } public string 申请日期 { get; set; }
/// <summary>
/// 申请人(传人员ID)
/// </summary>
public string 申请人 { get; set; } public string 申请人 { get; set; }
/// <summary>
/// 单位
/// </summary>
public string 单位 { get; set; } public string 单位 { get; set; }
/// <summary>
/// 申请部门(传申请部门ID)
/// </summary>
public string 申请部门 { get; set; } public string 申请部门 { get; set; }
public string 收款单位名称 { get; set; } public string 收款单位名称 { get; set; }
...@@ -363,8 +376,14 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -363,8 +376,14 @@ namespace Kivii.Finances.Seeyon.Entities
/// </summary> /// </summary>
public string 申请日期 { get; set; } public string 申请日期 { get; set; }
/// <summary>
/// 申请人(传人员ID)
/// </summary>
public string 申请人 { get; set; } public string 申请人 { get; set; }
/// <summary>
/// 申请部门(传申请部门)
/// </summary>
public string 申请部门 { get; set; } public string 申请部门 { get; set; }
public string 单位 { get; set; } public string 单位 { get; set; }
...@@ -424,8 +443,14 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -424,8 +443,14 @@ namespace Kivii.Finances.Seeyon.Entities
/// </summary> /// </summary>
public string 申请日期 { get; set; } public string 申请日期 { get; set; }
/// <summary>
/// 申请部门(传部门ID)
/// </summary>
public string 申请部门 { get; set; } public string 申请部门 { get; set; }
/// <summary>
/// 申请人(传人员ID)
/// </summary>
public string 申请人 { get; set; } public string 申请人 { get; set; }
public string 原发票号 { get; set; } public string 原发票号 { get; set; }
...@@ -466,8 +491,14 @@ namespace Kivii.Finances.Seeyon.Entities ...@@ -466,8 +491,14 @@ namespace Kivii.Finances.Seeyon.Entities
/// </summary> /// </summary>
public string 申请日期 { get; set; } public string 申请日期 { get; set; }
/// <summary>
/// 申请部门(传部门ID)
/// </summary>
public string 申请部门 { get; set; } public string 申请部门 { get; set; }
/// <summary>
/// 申请人(传人员ID)
/// </summary>
public string 申请人 { get; set; } public string 申请人 { get; set; }
/// <summary> /// <summary>
......
...@@ -69,5 +69,8 @@ ...@@ -69,5 +69,8 @@
<Name>Kivii.Seeyon.Addons.V4.5</Name> <Name>Kivii.Seeyon.Addons.V4.5</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Resources\南京市产品质量监督检验院OA接口文档.html" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment