diff --git a/插件库/Lskj.QueryEssentialInfo/DllBaseClass.cs b/插件库/Lskj.QueryEssentialInfo/DllBaseClass.cs new file mode 100644 index 0000000..f3e2945 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/DllBaseClass.cs @@ -0,0 +1,51 @@ +using Lskj.Business; +using Lskj.Model; +using Lskj.Util; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Lskj.QueryEssentialInfo +{ + /// + /// c#库被调用统一接口类 + /// + public sealed class DllBaseClass : IForm + { + public DllBaseClass() + { + } + public DllBaseClass(string[] obj) + { + try + { + FrmMain main = new FrmMain(); + main.Model = new DynamicQueryEssential(obj); + this.SubForm = main; + } + catch (Exception ex) + { + LogUtil.WriteError("Lskj.QueryEssentialInfo.dll--参数错误-->" + obj.ToString(), ex); + } + } + /// + /// 窗口 + /// + public Form SubForm { get; set; } + } + public class DynamicQueryEssential : DynamicModel + { + public string MainSourceSql; + public string DetailSourceSql; + /// + /// 执行类型0:专项附加查询1:个税申报 + /// + public string ExecMode = "0"; + public DynamicQueryEssential(string[] args) : base(args) + { + if (args.Length > 5 && !string.IsNullOrWhit \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/FrmMain.Designer.cs b/插件库/Lskj.QueryEssentialInfo/FrmMain.Designer.cs new file mode 100644 index 0000000..032a2d8 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/FrmMain.Designer.cs @@ -0,0 +1,92 @@ + +namespace Lskj.QueryEssentialInfo +{ + partial class FrmMain + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows 窗体设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + this.panel2 = new System.Windows.Forms.Panel(); + this.labelCurrentItem = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.label3 = new System.Windows.Forms.Label(); + this.progressBarCurrent = new System.Windows.Forms.ProgressBar(); + this.panel2.SuspendLayout(); + this.panel1.SuspendLayout(); + this.SuspendLayout(); + // + // panel2 + // + this.panel2.Controls.Add(this.labelCurrentItem); + this.panel2.Controls.Add(this.progressBarCurrent); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.ForeColor = System.Drawing.SystemColors.ControlDark; + this.panel2.Location = new System.Drawing.Point(0, 31); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(473, 56); + this.panel2.TabIndex = 10; + // + // labelCurrentItem + // + this.labelCurrentItem.AutoSize = true; + this.labelCurrentItem.Location = new System.Drawing.Point(14, 16); + this.labelCurrentItem.Name = "labelCurrentItem"; + this.labelCurrentItem.Size = new System.Drawing.Size(65, 12); + this.labelCurrentItem.TabIndex = 0; + this.labelCurrentItem.Text = "正在查询:"; + // + // panel1 + // + this.panel1.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.panel1.Controls.Add(this.label3); + this.panel1.Dock = System.Windows.Forms.DockStyle.Top; + this.panel1.Location = new System.Drawing.Point(0, 0); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(473, 31); + this.panel1.TabIndex = 9; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label3.Location = new System.Drawing.Point(11, 8); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(161, 12); + this.label3.TabIndex = 0; + this.label3.Text = "系统正在查询专项附加扣除"; + // + // progressBarCurrent + // + this.progressBarCurrent.Location = new System.Drawing.Point(15, 33); + this.progressBarCurrent.Name = "progressBarCurrent"; + this.progressBarCurrent.Size = new System.Drawing.Size(446, 12); + this.progressBarCurrent.Step = 1; + this.progressBarCurrent.TabIndex = 5; + // + // FrmMain + // + this.Appearance.BackColor = System.Drawing.SystemColors.Control; + this.Appearance.Optio \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/FrmMain.cs b/插件库/Lskj.QueryEssentialInfo/FrmMain.cs new file mode 100644 index 0000000..0785e39 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/FrmMain.cs @@ -0,0 +1,394 @@ +using Lskj.Business.Impl; +using Lskj.Control; +using Lskj.Core; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Lskj.QueryEssentialInfo +{ + public partial class FrmMain : BaseForm + { + public DynamicQueryEssential Model; + public FrmMain() + { + InitializeComponent(); + this.Load += OnFrmMainLoad; + } + /// + /// 初始化时 + /// + /// + /// + private void OnFrmMainLoad(object sender, EventArgs e) + { + try + { + progressBarCurrent.Maximum = 100; + progressBarCurrent.Value = 0; + QueryApiUtil.mainRow = BaseImpl.GetDataRowResult(Model.MainSourceSql); + QueryApiUtil.detailTab = BaseImpl.GetDataTableResult(Model.DetailSourceSql); + Task.Factory.StartNew(() => + { + try + { + switch (Model.ExecMode) + { + case "0": + ZXFJQuery(); + Invoke(new Action(() => + { + MessageUtil.Show("专项附加查询完成"); + })); + break; + case "1": + GSSBQuery(); + Invoke(new Action(() => + { + MessageUtil.Show("个税申报完成"); + })); + break; + } + } + catch (Exception ex) + { + Invoke(new Action(() => + { + MessageUtil.Show(ex.Message); + this.Close(); + })); + } + }); + } + catch (Exception ex) + { + MessageUtil.Show(ex.Message); + this.Close(); + } + } + /// + /// 查询专项附加 + /// + private void ZXFJQuery() + { + if (QueryApiUtil.detailTab.AsEnumerable().Where(n => !(n["p_emp_addTag"] + "").Equals("1")).Count() > 0) + { + SetProcessMsg($"正在报送人员..."); + string personCode = QueryApiUtil.Person(out string personResult, out string personMsg); + if (!personCode.Equals("0")) + { + throw new Exception($"报送失败\r\n{personMsg}"); + } + SetProcessMsg($"正在查询报送人员..."); + string personQueryCode = QueryApiUtil.PersonQuery(out string personQueryResult, out string personQueryMsg); + if (!personQueryCode.Equals("0")) + { + throw new Exception($"报送查询失败\r\n{personQueryMsg}"); + } + else + { + JObject personQueryJObject = (JObject)JsonConvert.DeserializeObject(personQueryResult); + if (personQueryJObject["data"] is JArray) + { + JArray personQueryJArray = (JArray)personQueryJObject["data"]; + foreach (JObject personJObject in personQueryJArray) + { + string name = personJObject["name"] + ""; + string sfzh = personJObject["sfzh"] + ""; + string bszt = personJObject["bszt"] + ""; + string sfyzzt = personJObject["sfyzzt"] + ""; + if (bszt.Equals("报送成功") && sfyzzt.Equals("验证成功")) + { + SqlHelper.ExecuteNonQuery($"update p_employeeTab set p_emp_addTag = 1 where p_emp_idcardnum = '{sfzh}'"); + } + SetProcessMsg($"已报送:{name}"); + } + } + } + } + QueryApiUtil.detailTab = BaseImpl.GetDataTableResult(Model.DetailSourceSql); + Invoke(new Action(() => + { + progressBarCurrent.Maximum = QueryApiUtil.detailTab.AsEnumerable().Where(n => (n["p_emp_addTag"] + "").Equals("1")).Count(); + })); + SetProcessMsg($"正在同步专项附加数据..."); + string postAdditionCode = QueryApiUtil.PostAddition(out string postAdditionResult, out string postAdditionMsg); + SetProcessMsg($"正在查询专项附加数据..."); + string getAdditionCode = QueryApiUtil.GetAddition(out string getAdditionResult, out string getAdditionMsg); + if (!getAdditionCode.Equals("0")) + { + throw new Exception($"查询数据失败\r\n{getAdditionMsg}"); + } + else + { + JObject additionJObject = (JObject)JsonConvert.DeserializeObject(getAdditionResult); + if (additionJObject["data"] is JObject) + { + JObject additionDataJObject = (JObject)additionJObject["data"]; + if (additionDataJObject.ContainsKey("list") && additionDataJObject["list"] is JArray) + { + string ysyf = QueryApiUtil.mainRow["ysyf"] + ""; + JArray additionListJArray = (JArray)additionDataJObject["list"]; + foreach (JObject item in additionListJArray) + { + StringBuilder sqlBuilder = new StringBuilder(); + string peopleName = item["peopleName"] + ""; + string idNumber = item["idNumber"] + ""; + sqlBuilder.AppendLine($"delete from p_gszxfjkctab where idnumber = '{idNumber}' and itemid = '{ysyf}';"); + string sylrAccumulate = item["sylrAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','赡养老人','{sylrAccumulate}','','{idNumber}','{ysyf}');"); + string znjyAccumulate = item["znjyAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','子女教育','{znjyAccumulate}','','{idNumber}','{ysyf}');"); + string xljxjyAccumulate = item["xljxjyAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','学历继续教育','{xljxjyAccumulate}','','{idNumber}','{ysyf}');"); + string zyzgjxjyAccumulate = item["zyzgjxjyAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','专业资格继续教育','{zyzgjxjyAccumulate}','','{idNumber}','{ysyf}');"); + string zfdklxAccumulate = item["zfdklxAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','住房贷款利息','{zfdklxAccumulate}','','{idNumber}','{ysyf}');"); + string zfzjAccumulate = item["zfzjAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','租房租金','{zfzjAccumulate}','','{idNumber}','{ysyf}');"); + string yyezhfAccumulate = item["yyezhfAccumulate"] + ""; + sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{peopleName}','婴幼儿照护','{yyezhfAccumulate}','','{idNumber}','{ysyf}');"); + if (!string.IsNullOrEmpty(sqlBuilder.ToString())) + { + BaseImpl.ExecSqlValue(sqlBuilder.ToString()); + } + SetProcessMsg($"已查询:{peopleName}"); + SetProcessBar(); + } + } + } + } + #region 已弃用 + //string token = ""; + //string aggOrgId = ""; + //string accountId = ""; + //if ((string.IsNullOrEmpty(token) || string.IsNullOrEmpty(aggOrgId)) && QueryApiUtil.AlterTable("p_systemtab", "queryEssentialToken", "varchar(1000)") && QueryApiUtil.AlterTable("p_systemtab", "queryEssentialAggOrgId", "varchar(200)")) + //{ + // DataRow tokenRow = BaseImpl.GetDataRowResult("select queryEssentialToken,queryEssentialAggOrgId from p_systemtab"); + // token = tokenRow["queryEssentialToken"] + ""; + // aggOrgId = tokenRow["queryEssentialAggOrgId"] + ""; + // if (string.IsNullOrEmpty(token)) + // { + // QueryApiUtil.GetToken(ref token, ref aggOrgId); + // } + //} + //string checkPasswordMsg = ""; + //string checkPasswordCode = QueryApiUtil.CheckPassword(ref token, ref aggOrgId, ref accountId, ref checkPasswordMsg); + //if (!checkPasswordCode.Equals("2000")) + //{ + // QueryApiUtil.GetToken(ref token, ref aggOrgId); + // checkPasswordMsg = ""; + // checkPasswordCode = QueryApiUtil.CheckPassword(ref token, ref aggOrgId, ref accountId, ref checkPasswordMsg); + //} + //if (!checkPasswordCode.Equals("2000")) + //{ + // throw new Exception($"验证失败\r\n{checkPasswordMsg}"); + //} + //string employeeInfoCode = QueryApiUtil.QueryEssentialEmployeeInfo(ref token, ref aggOrgId, ref accountId, out string employeeInfoResult); + //if (employeeInfoCode.Equals("2000") || employeeInfoCode.Equals("-9998")) + //{ + // if (employeeInfoCode.Equals("2000")) + // { + // JObject employeeInfoJObject = (JObject)JsonConvert.DeserializeObject(employeeInfoResult); + // string success = employeeInfoJObject.ContainsKey("success") ? employeeInfoJObject["success"] + "" : ""; + // string message = employeeInfoJObject.ContainsKey("message") ? employeeInfoJObject["message"] + "" : ""; + // if (success.Equals("true", StringComparison.OrdinalIgnoreCase)) + // { + // string taskId = employeeInfoJObject["data"]["taskId"] + ""; + // string backStates = "0"; + // string backSuccess = ""; + // string backMessage = ""; + // int waitCount = 1; + // while (backStates.Equals("0") || backStates.Equals("1")) + // { + // SetProcessMsg($"等待报送数据返回({waitCount})..."); + // string employeeInfoBackCode = QueryApiUtil.QueryEssentialEmployeeInfoFeedback(taskId, ref token, ref aggOrgId, ref accountId, out string employeeInfoBackResult); + // if (employeeInfoBackCode.Equals("2000")) + // { + // JObject employeeInfoBackJObject = (JObject)JsonConvert.DeserializeObject(employeeInfoBackResult); + // backSuccess = employeeInfoBackJObject.ContainsKey("success") ? employeeInfoBackJObject["success"] + "" : ""; + // if (backSuccess.Equals("true", StringComparison.OrdinalIgnoreCase)) + // { + // backMessage = employeeInfoBackJObject["data"]["taskStatusName"] + ""; + // backStates = employeeInfoBackJObject["data"]["taskStatus"] + ""; + // if (backStates.Equals("3"))//已完成 + // { + // JArray resultArray = (JArray)employeeInfoBackJObject["data"]["result"]; + // foreach (JObject result in resultArray) + // { + // string xm = result["xm"] + ""; + // string zjhm = result["zzhm"] + ""; + // SqlHelper.ExecuteNonQuery($"update p_employeeTab set p_emp_addTag = 1 where p_emp_idcardnum = '{zjhm}'"); + // SetProcessMsg($"已报送:{xm}"); + // SetProcessBar(); + // } + // } + // if (backStates.Equals("2")) + // { + // string errorMessage = employeeInfoBackJObject["data"]["message"] + ""; + // throw new Exception($"报送反馈请求失败\r\n{errorMessage}"); + // } + // } + // } + // else + // { + // throw new Exception($"报送反馈请求失败\r\n{employeeInfoBackResult}"); + // } + // } + // } + // } + //} + //else + //{ + // throw new Exception($"报送失败\r\n{employeeInfoResult}"); + //} + //string queryInfoCode = QueryApiUtil.QueryEssentialInfo(ref token, ref aggOrgId, ref accountId, out string queryInfoResult); + //if (queryInfoCode.Equals("2000") || queryInfoCode.Equals("-9998")) + //{ + // if (queryInfoCode.Equals("2000")) + // { + // JObject queryInfoJObject = (JObject)JsonConvert.DeserializeObject(queryInfoResult); + // string success = queryInfoJObject.ContainsKey("success") ? queryInfoJObject["success"] + "" : ""; + // string message = queryInfoJObject.ContainsKey("message") ? queryInfoJObject["message"] + "" : ""; + // if (success.Equals("true", StringComparison.OrdinalIgnoreCase)) + // { + // string taskId = queryInfoJObject["data"]["taskId"] + ""; + // string backStates = "0"; + // string backSuccess = ""; + // string backMessage = ""; + // int waitCount = 1; + // while (backStates.Equals("0") || backStates.Equals("1")) + // { + // SetProcessMsg($"等待查询数据返回({waitCount})..."); + // string queryInfoBackCode = QueryApiUtil.QueryEssentialInfoFeedback(taskId, ref token, ref aggOrgId, ref accountId, out string queryInfoBackResult); + // if (queryInfoBackCode.Equals("2000")) + // { + // JObject queryInfoBackJObject = (JObject)JsonConvert.DeserializeObject(queryInfoBackResult); + // backSuccess = queryInfoBackJObject.ContainsKey("success") ? queryInfoBackJObject["success"] + "" : ""; + // if (backSuccess.Equals("true", StringComparison.OrdinalIgnoreCase)) + // { + // backMessage = queryInfoBackJObject["data"]["taskStatusName"] + ""; + // backStates = queryInfoBackJObject["data"]["taskStatus"] + ""; + // if (backStates.Equals("3")) + // { + // string itemId = QueryApiUtil.mainRow["skssq"] + ""; + // JArray resultArray = (JArray)queryInfoBackJObject["data"]["result"]; + // foreach (JObject result in resultArray) + // { + // StringBuilder sqlBuilder = new StringBuilder(); + // string xm = result["xm"] + ""; + // string zzlx = result["zzlx"] + ""; + // string zzhm = result["zzhm"] + ""; + // sqlBuilder.AppendLine($"delete from p_gszxfjkctab where idnumber = '{zzhm}' and itemid = '{itemId}';"); + // #region 子女教育 + // JArray znjys = (JArray)result["znjys"]; + // foreach (JObject znjy in znjys) + // { + // string znjyxm = znjy["xm"] + ""; + // sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{xm}','子女教育','2000','{znjyxm}','{zzhm}','{itemId}');"); + // } + // #endregion + // #region 赡养老人 + // if (result["sylrs"] is JObject) + // { + // JObject sylrs = (JObject)result["sylrs"]; + // string ftje = sylrs["ftje"] + ""; + // sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{xm}','赡养老人','{ftje}','','{zzhm}','{itemId}');"); + // } + // #endregion + // #region 住房租金 + // JArray fwzls = (JArray)result["fwzls"]; + // foreach (JObject fwzl in fwzls) + // { + // string zfzlhtbh = fwzl["zfzlhtbh"] + ""; + // sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{xm}','住房租金','1500','{zfzlhtbh}','{zzhm}','{itemId}');"); + // } + // #endregion + // #region 住房贷款 + // JArray fwdks = (JArray)result["fwdks"]; + // foreach (JObject fwdk in fwdks) + // { + // string zsh = fwdk["zsh"] + ""; + // sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{xm}','住房贷款','1000','{zsh}','{zzhm}','{itemId}');"); + // } + // #endregion + // #region 继续教育 + // JArray jxjys = (JArray)result["jxjys"]; + // foreach (JObject jxjy in jxjys) + // { + // string zsmc = jxjy["zsmc"] + ""; + // sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{xm}','继续教育','400','{zsmc}','{zzhm}','{itemId}');"); + // } + // #endregion + // #region 婴幼儿照护 + // JArray yyezhls = (JArray)result["yyezhls"]; + // foreach (JObject yyezhl in yyezhls) + // { + // string yyexm = yyezhl["xm"] + ""; + // sqlBuilder.AppendLine($"insert into p_gszxfjkctab (employeename,type,money,bak,idnumber,itemid) values ('{xm}','婴幼儿照护','2000','{yyexm}','{zzhm}','{itemId}');"); + // } + // #endregion + // SqlHelper.ExecuteNonQuery(sqlBuilder.ToString()); + // SetProcessMsg($"已查询:{xm}"); + // SetProcessBar(); + // } + // } + // if (backStates.Equals("2")) + // { + // string errorMessage = queryInfoBackJObject["data"]["message"] + ""; + // throw new Exception($"报送反馈请求失败\r\n{errorMessage}"); + // } + // } + // } + // else + // { + // throw new Exception($"数据请求反馈失败\r\n{queryInfoBackResult}"); + // } + // Thread.Sleep(1000); + // } + // Invoke(new Action(() => + // { + // MessageUtil.Show(backMessage); + // })); + // } + // } + //} + //else + //{ + // throw new Exception($"数据请求失败\r\n{queryInfoResult}"); + //} + #endregion + Invoke(new Action(() => + { + this.Close(); + })); + } + /// + /// 个税申报 + /// + private void GSSBQuery() + { + SetProcessMsg($"正在进行个税申报..."); + string submitCode = QueryApiUtil.Submit(out string submitResult, out string submitMsg); + if (!submitCode.Equals("0")) + { + throw new Exception($"个税申报失败\r\n{submitMsg}"); + } + SetProcessMsg($"正在查询个税申报结果..."); + string submitQueryCode = "-99"; + while (!submitQueryCode.Equals("0")) + { + submitQueryCode = QueryApiUtil.SubmitQuery(out string submitQueryResult, out string submitQueryMsg); + if (!submitQueryCode.Equals("0")) + { + \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/FrmMain.resx b/插件库/Lskj.QueryEssentialInfo/FrmMain.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/FrmMain.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/Lskj.QueryEssentialInfo.csproj b/插件库/Lskj.QueryEssentialInfo/Lskj.QueryEssentialInfo.csproj new file mode 100644 index 0000000..9e6311b --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/Lskj.QueryEssentialInfo.csproj @@ -0,0 +1,117 @@ + + + + + Debug + AnyCPU + {4CAF9151-C465-4CCE-B2C3-DF272DD6371D} + Library + Lskj.QueryEssentialInfo + Lskj.QueryEssentialInfo + v4.0 + 512 + true + + + x86 + true + full + false + ..\..\Debug\Lib\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + ..\Lskj.LserpAll\packages\BouncyCastle.1.8.9\lib\BouncyCastle.Crypto.dll + + + + + + False + D:\工作\lserp_cs_6.0\引用DLL\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + Form + + + FrmMain.cs + + + + + + FrmMain.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {7EAFCCC2-A18F-49E9-85C6-A984966CFD01} + Lskj.Business + + + {447CDC40-659F-4CCA-9ED6-8E818B4CF8BF} + Lskj.Control + + + {2A1BE6AC-1077-491B-A754-C5822FE8121E} + Lskj.Core + + + {52BC40E0-C0C6-4F78-996B-CAE028D209CA} + Lskj.Model + + + {A51BF642-6543-4DE3-8948-83F558B72BD4} + Lskj.Util + + + + \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/Properties/AssemblyInfo.cs b/插件库/Lskj.QueryEssentialInfo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a963a15 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/Properties/AssemblyInfo.cs @@ -0,0 +1,9 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("Lskj.QueryEssentialInfo")] +[assembly: AssemblyDescript \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/Properties/Resources.Designer.cs b/插件库/Lskj.QueryEssentialInfo/Properties/Resources.Designer.cs new file mode 100644 index 0000000..68fefb2 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/Properties/Resources.Designer.cs @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + + +namespace Lskj.QueryEssentialInfo.Properties +{ + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/Properties/Resources.resx b/插件库/Lskj.QueryEssentialInfo/Properties/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/Properties/Settings.Designer.cs b/插件库/Lskj.QueryEssentialInfo/Properties/Settings.Designer.cs new file mode 100644 index 0000000..fef0bf4 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/Properties/Settings.Designer.cs @@ -0,0 +1 @@ +//------------------------------------------------------------------------------ \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/Properties/Settings.settings b/插件库/Lskj.QueryEssentialInfo/Properties/Settings.settings new file mode 100644 index 0000000..3964565 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/插件库/Lskj.QueryEssentialInfo/QueryApiUtil.cs b/插件库/Lskj.QueryEssentialInfo/QueryApiUtil.cs new file mode 100644 index 0000000..aa9bc9e --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/QueryApiUtil.cs @@ -0,0 +1,675 @@ +using Lskj.Business.Impl; +using Lskj.Control.BrowserSetting; +using Lskj.Core; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Security.Cryptography; +using System.Text; + +namespace Lskj.QueryEssentialInfo +{ + public static class QueryApiUtil + { + public static DataRow mainRow; + public static DataTable detailTab; + /// + /// 获取操作token + /// + public static void GetToken(ref string token, ref string aggOrgId) + { + token = ""; + aggOrgId = ""; + try + { + string url = "http://openapi.51fpcloud.com/v2/public/token"; + HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + string client_id = mainRow["client_id"] + ""; + string client_secret = mainRow["client_secret"] + ""; + string authorization = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{client_id}:{client_secret}")); + headerDic.Add("Authorization", $"Basic {authorization}"); + Dictionary pmsDic = new Dictionary(); + pmsDic.Add("nsrsbh", mainRow["nsrsbh"] + ""); + HttpWebResponse webResponse = HttpTools.Post(url, "", pmsDic, headerDic, HttpTools.Method.POST); + string result = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(result)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(result); + string code = resultJObject["code"] + ""; + string msg = resultJObject["msg"] + ""; + if (code.Equals("0")) + { + token = resultJObject["data"]["token"] + ""; + aggOrgId = resultJObject["data"]["aggOrgId"] + ""; + SqlHelper.ExecuteNonQuery(string.Format("update p_systemtab set queryEssentialToken = '{0}'", token)); + SqlHelper.ExecuteNonQuery(string.Format("update p_systemtab set queryEssentialAggOrgId = '{0}'", aggOrgId)); + } + else + { + throw new Exception($"获取token失败\r\n{msg}"); + } + } + } + catch (Exception) + { + throw; + } + } + /// + /// 专项附加扣除查询 + /// + /// + /// + /// + public static string CheckPassword(ref string token, ref string aggOrgId, ref string accountId, ref string message) + { + string code = "-9999"; + try + { + string url = "http://openapi.51fpcloud.com/v2/iit/check/checkPassword"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + headerDic.Add("token", token); + JObject pmsJObject = new JObject(); + if (detailTab != null && detailTab.Rows.Count > 0) + { + pmsJObject.Add("aggOrgId", aggOrgId); + pmsJObject.Add("checkPassword", "Y"); + pmsJObject.Add("nsrsbh", mainRow["nsrsbh"] + ""); + pmsJObject.Add("qymc", mainRow["qymc"] + ""); + pmsJObject.Add("mmlx", mainRow["mmlx"] + ""); + pmsJObject.Add("sbmm", RsaEntryUtil.Encrypt(mainRow["sbmm"] + "", RsaEntryUtil.ToXmlPublicKey("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC+vuYMGtTU+42wwbaFX+PkCuSeoREKe5V4EJMi553Gc03ficUdpLHIFdEjAMHAxepwm3RAGLwyxYFK/S93k8GYMuV35L2Nj/cVeHS8scsdqXzqLUKaI4wj438OI6HDh7rWsw1M5EgMsoZvQqja53+SgD3mgIy3XyILbmA5jUp2IwIDAQAB"))); + pmsJObject.Add("areaid", mainRow["areaid"] + ""); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + string resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + message = resultJObject["message"] + ""; + if (code.Equals("2000")) + { + accountId = resultJObject["data"]["accountId"] + ""; + } + } + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 专项附加扣除查询 + /// + /// + /// + /// + public static string QueryEssentialInfo(ref string token, ref string aggOrgId, ref string accountId, out string resultRead) + { + string code = "-9999"; + resultRead = ""; + try + { + string url = "http://openapi.51fpcloud.com/v2/iit/declare/queryEssentialInfo"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + headerDic.Add("token", token); + JObject pmsJObject = new JObject(); + if (detailTab != null && detailTab.Rows.Count > 0) + { + pmsJObject.Add("aggOrgId", aggOrgId); + pmsJObject.Add("accountId", accountId); + pmsJObject.Add("skssq", mainRow["skssq"] + ""); + JArray rylbJArray = new JArray(); + { + foreach (DataRow detailRow in detailTab.Rows) + { + string addTag = detailRow["p_emp_addTag"] + ""; + if (addTag.Equals("0")) + { + continue; + } + JObject rylbJObject = new JObject(); + rylbJObject.Add("xm", detailRow["xm"] + ""); + rylbJObject.Add("zzlx", detailRow["zzlx"] + ""); + rylbJObject.Add("zzhm", detailRow["zzhm"] + ""); + rylbJArray.Add(rylbJObject); + } + } + pmsJObject.Add("rylb", rylbJArray); + if (rylbJArray.Count > 0) + { + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + } + } + else + { + code = "-9998"; + } + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 专项附加扣除查询反馈 + /// + /// + /// + /// + public static string QueryEssentialInfoFeedback(string taskId, ref string token, ref string aggOrgId, ref string accountId, out string resultRead) + { + string code = "-9999"; + resultRead = ""; + try + { + string url = "http://openapi.51fpcloud.com/v2/iit/declare/queryEssentialInfoFeedback"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + headerDic.Add("token", token); + JObject pmsJObject = new JObject(); + pmsJObject.Add("aggOrgId", aggOrgId); + pmsJObject.Add("accountId", accountId); + pmsJObject.Add("taskId", taskId); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 获取企业人员 + /// + /// + /// + /// + /// + /// + public static string QueryEssentialCompanyEmployee(ref string token, ref string aggOrgId, ref string accountId, out string resultRead) + { + string code = "-9999"; + resultRead = ""; + try + { + string url = "http://openapi.51fpcloud.com/v2/iit/data/getCompanyEmployee"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + headerDic.Add("token", token); + JObject pmsJObject = new JObject(); + pmsJObject.Add("aggOrgId", aggOrgId); + pmsJObject.Add("accountId", accountId); + pmsJObject.Add("pageNo", "1"); + pmsJObject.Add("pageSize", "100"); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 人员报送 + /// + /// + /// + /// + /// + /// + public static string QueryEssentialEmployeeInfo(ref string token, ref string aggOrgId, ref string accountId, out string resultRead) + { + string code = "-9999"; + resultRead = ""; + try + { + string url = "http://openapi.51fpcloud.com/v2/iit/declare/declareEmployeeInfo"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + headerDic.Add("token", token); + JObject pmsJObject = new JObject(); + pmsJObject.Add("aggOrgId", aggOrgId); + pmsJObject.Add("accountId", accountId); + pmsJObject.Add("skssq", mainRow["skssq"] + ""); + JArray rylbArray = new JArray(); + foreach (DataRow detailRow in detailTab.Rows) + { + string addTag = detailRow["p_emp_addTag"] + ""; + if (addTag.Equals("1")) + { + continue; + } + JObject rylbJObject = new JObject(); + rylbJObject.Add("xm", detailRow["xm"] + ""); + rylbJObject.Add("zzlx", detailRow["zzlx"] + ""); + rylbJObject.Add("zzhm", detailRow["zzhm"] + ""); + rylbJObject.Add("lxdh", detailRow["lxdh"] + ""); + rylbJObject.Add("nsrzt", detailRow["nsrzt"] + ""); + rylbJObject.Add("sfgy", detailRow["sfgy"] + ""); + rylbJObject.Add("rzsgrq", detailRow["rzsgrq"] + ""); + rylbJObject.Add("xb", detailRow["xb"] + ""); + rylbJObject.Add("csny", detailRow["csny"] + ""); + rylbJObject.Add("gj", detailRow["gj"] + ""); + rylbJObject.Add("rydq", detailRow["rydq"] + ""); + rylbArray.Add(rylbJObject); + } + pmsJObject.Add("rylb", rylbArray); + if (rylbArray.Count > 0) + { + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + } + } + else + { + code = "-9998"; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 人员报送反馈 + /// + /// + /// + /// + /// + /// + public static string QueryEssentialEmployeeInfoFeedback(string taskId, ref string token, ref string aggOrgId, ref string accountId, out string resultRead) + { + string code = "-9999"; + resultRead = ""; + try + { + string url = "http://openapi.51fpcloud.com/v2/iit/declare/getEmployeeInfoFeedback"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + headerDic.Add("token", token); + JObject pmsJObject = new JObject(); + pmsJObject.Add("aggOrgId", aggOrgId); + pmsJObject.Add("accountId", accountId); + pmsJObject.Add("taskId", taskId); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 同步人员 + /// + public static string Person(out string resultRead, out string resultMsg) + { + string code = "-9999"; + resultRead = ""; + resultMsg = ""; + try + { + string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/syn/person"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + DateTime utcNow = DateTime.UtcNow; + string date = utcNow.ToString("r", CultureInfo.InvariantCulture); + string host = "api.baiwangjs.com"; + string x_htjs_nonce = Guid.NewGuid().ToString().ToLower(); + string x_htjs_ua = "1.8.0_181 64 bit, sdk-ver=1.0.0"; + headerDic.Add("Date", DateTime.UtcNow.ToString()); + headerDic.Add("host", host); + headerDic.Add("x-htjs-nonce", x_htjs_nonce); + headerDic.Add("x-htjs-ua", x_htjs_ua); + headerDic.Add("Authorization", $"{GetAuthorization(date, host, x_htjs_nonce, x_htjs_ua)}"); + JObject pmsJObject = new JObject(); + pmsJObject.Add("busiTypeCode", mainRow["busiTypeCode"] + ""); + pmsJObject.Add("qysh", mainRow["qysh"] + ""); + pmsJObject.Add("operator", mainRow["operator"] + ""); + JArray bizlistJArray = new JArray(); + foreach (DataRow detailRow in detailTab.Rows) + { + string addTag = detailRow["p_emp_addTag"] + ""; + if (!addTag.Equals("1")) + { + continue; + } + JObject bizDataJObject = new JObject(); + bizDataJObject.Add("name", detailRow["name"] + ""); + bizDataJObject.Add("idType", detailRow["idType"] + ""); + bizDataJObject.Add("idNumber", detailRow["idNumber"] + ""); + bizDataJObject.Add("sex", detailRow["sex"] + ""); + bizDataJObject.Add("birthday", detailRow["birthday"] + ""); + bizDataJObject.Add("employType", detailRow["employType"] + ""); + bizDataJObject.Add("employedDate", detailRow["employedDate"] + ""); + bizDataJObject.Add("phoneNumber", detailRow["phoneNumber"] + ""); + bizDataJObject.Add("isDeductExpense", detailRow["isDeductExpense"] + ""); + bizlistJArray.Add(bizDataJObject); + } + pmsJObject.Add("bizDataList", bizlistJArray); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + resultMsg = resultJObject["msg"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 报送查询 + /// + public static string PersonQuery(out string resultRead, out string resultMsg) + { + string code = "-9999"; + resultRead = ""; + resultMsg = ""; + try + { + string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/person/submit/query"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + DateTime utcNow = DateTime.UtcNow; + string date = utcNow.ToString("r", CultureInfo.InvariantCulture); + string host = "api.baiwangjs.com"; + string x_htjs_nonce = Guid.NewGuid().ToString().ToLower(); + string x_htjs_ua = "1.8.0_181 64 bit, sdk-ver=1.0.0"; + headerDic.Add("Date", DateTime.UtcNow.ToString()); + headerDic.Add("host", host); + headerDic.Add("x-htjs-nonce", x_htjs_nonce); + headerDic.Add("x-htjs-ua", x_htjs_ua); + headerDic.Add("Authorization", $"{GetAuthorization(date, host, x_htjs_nonce, x_htjs_ua)}"); + JObject pmsJObject = new JObject(); + pmsJObject.Add("busiTypeCode", mainRow["busiTypeCode"] + ""); + pmsJObject.Add("qysh", mainRow["qysh"] + ""); + pmsJObject.Add("operator", mainRow["operator"] + ""); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + resultMsg = resultJObject["msg"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 同步专项附加 + /// + public static string PostAddition(out string resultRead, out string resultMsg) + { + string code = "-9999"; + resultRead = ""; + resultMsg = ""; + try + { + string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/syn/special/addition"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + DateTime utcNow = DateTime.UtcNow; + string date = utcNow.ToString("r", CultureInfo.InvariantCulture); + string host = "api.baiwangjs.com"; + string x_htjs_nonce = Guid.NewGuid().ToString().ToLower(); + string x_htjs_ua = "1.8.0_181 64 bit, sdk-ver=1.0.0"; + headerDic.Add("Date", DateTime.UtcNow.ToString()); + headerDic.Add("host", host); + headerDic.Add("x-htjs-nonce", x_htjs_nonce); + headerDic.Add("x-htjs-ua", x_htjs_ua); + headerDic.Add("Authorization", $"{GetAuthorization(date, host, x_htjs_nonce, x_htjs_ua)}"); + JObject pmsJObject = new JObject(); + pmsJObject.Add("busiTypeCode", mainRow["busiTypeCode"] + ""); + pmsJObject.Add("qysh", mainRow["qysh"] + ""); + pmsJObject.Add("operator", mainRow["operator"] + ""); + pmsJObject.Add("ysyf", mainRow["ysyf"] + ""); + JArray idNumberjArray = new JArray(); + foreach (DataRow detailRow in detailTab.Rows) + { + string addTag = detailRow["p_emp_addTag"] + ""; + if (!addTag.Equals("1")) + { + continue; + } + string idNumber = detailRow["idNumber"] + ""; + idNumberjArray.Add(idNumber); + } + pmsJObject.Add("idNumberList", idNumberjArray); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + resultMsg = resultJObject["msg"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 获取专项附加 + /// + public static string GetAddition(out string resultRead, out string resultMsg) + { + string code = "-9999"; + resultRead = ""; + resultMsg = ""; + try + { + string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/acquire/special/addition"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + DateTime utcNow = DateTime.UtcNow; + string date = utcNow.ToString("r", CultureInfo.InvariantCulture); + string host = "api.baiwangjs.com"; + string x_htjs_nonce = Guid.NewGuid().ToString().ToLower(); + string x_htjs_ua = "1.8.0_181 64 bit, sdk-ver=1.0.0"; + headerDic.Add("Date", DateTime.UtcNow.ToString()); + headerDic.Add("host", host); + headerDic.Add("x-htjs-nonce", x_htjs_nonce); + headerDic.Add("x-htjs-ua", x_htjs_ua); + headerDic.Add("Authorization", $"{GetAuthorization(date, host, x_htjs_nonce, x_htjs_ua)}"); + JObject pmsJObject = new JObject(); + pmsJObject.Add("busiTypeCode", mainRow["busiTypeCode"] + ""); + pmsJObject.Add("qysh", mainRow["qysh"] + ""); + pmsJObject.Add("operator", mainRow["operator"] + ""); + pmsJObject.Add("ysyf", mainRow["ysyf"] + ""); + JArray idNumberjArray = new JArray(); + foreach (DataRow detailRow in detailTab.Rows) + { + string addTag = detailRow["p_emp_addTag"] + ""; + if (!addTag.Equals("1")) + { + continue; + } + string idNumber = detailRow["idNumber"] + ""; + idNumberjArray.Add(idNumber); + } + pmsJObject.Add("idNumberList", idNumberjArray); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + resultMsg = resultJObject["msg"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 个税申报 + /// + /// + /// + /// + public static string Submit(out string resultRead, out string resultMsg) + { + string code = "-9999"; + resultRead = ""; + resultMsg = ""; + try + { + string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/submit"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + DateTime utcNow = DateTime.UtcNow; + string date = utcNow.ToString("r", CultureInfo.InvariantCulture); + string host = "api.baiwangjs.com"; + string x_htjs_nonce = Guid.NewGuid().ToString().ToLower(); + string x_htjs_ua = "1.8.0_181 64 bit, sdk-ver=1.0.0"; + headerDic.Add("Date", DateTime.UtcNow.ToString()); + headerDic.Add("host", host); + headerDic.Add("x-htjs-nonce", x_htjs_nonce); + headerDic.Add("x-htjs-ua", x_htjs_ua); + headerDic.Add("Authorization", $"{GetAuthorization(date, host, x_htjs_nonce, x_htjs_ua)}"); + JObject pmsJObject = new JObject(); + pmsJObject.Add("busiTypeCode", mainRow["busiTypeCode"] + ""); + pmsJObject.Add("qysh", mainRow["qysh"] + ""); + pmsJObject.Add("operator", mainRow["operator"] + ""); + pmsJObject.Add("skssqQ", mainRow["skssqQ"] + ""); + pmsJObject.Add("skssqZ", mainRow["skssqZ"] + ""); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + resultMsg = resultJObject["msg"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 个税申报查询 + /// + public static string SubmitQuery(out string resultRead, out string resultMsg) + { + string code = "-9999"; + resultRead = ""; + resultMsg = ""; + try + { + string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/submit/query"; + HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8); + Dictionary headerDic = new Dictionary(); + DateTime utcNow = DateTime.UtcNow; + string date = utcNow.ToString("r", CultureInfo.InvariantCulture); + string host = "api.baiwangjs.com"; + string x_htjs_nonce = Guid.NewGuid().ToString().ToLower(); + string x_htjs_ua = "1.8.0_181 64 bit, sdk-ver=1.0.0"; + headerDic.Add("Date", DateTime.UtcNow.ToString()); + headerDic.Add("host", host); + headerDic.Add("x-htjs-nonce", x_htjs_nonce); + headerDic.Add("x-htjs-ua", x_htjs_ua); + headerDic.Add("Authorization", $"{GetAuthorization(date, host, x_htjs_nonce, x_htjs_ua)}"); + JObject pmsJObject = new JObject(); + pmsJObject.Add("busiTypeCode", mainRow["busiTypeCode"] + ""); + pmsJObject.Add("qysh", mainRow["qysh"] + ""); + pmsJObject.Add("operator", mainRow["operator"] + ""); + pmsJObject.Add("skssqQ", mainRow["skssqQ"] + ""); + pmsJObject.Add("skssqZ", mainRow["skssqZ"] + ""); + HttpWebResponse webResponse = HttpTools.Post(url, JsonConvert.SerializeObject(pmsJObject), null, headerDic, HttpTools.Method.POST); + resultRead = new StreamReader(webResponse.GetResponseStream(), Encoding.UTF8).ReadToEnd(); + if (webResponse != null && !string.IsNullOrEmpty(resultRead)) + { + JObject resultJObject = (JObject)JsonConvert.DeserializeObject(resultRead); + code = resultJObject["code"] + ""; + resultMsg = resultJObject["msg"] + ""; + } + } + catch (Exception) + { + throw; + } + return code; + } + /// + /// 获取Authorization + /// + public static string GetAuthorization(string date, string host, string x_htjs_nonce, string x_htjs_ua) + { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.AppendLine("POST /v2/cloud/queryUniqueSign HTTP/1.1"); + stringBuilder.AppendLine($"date: {date}"); + stringBuilder.AppendLine($"host: {host}"); + stringBuilder.AppendLine($"x-htjs-nonce: {x_htjs_nonce}"); + stringBuilder.AppendLine($"x-htjs-ua: {x_htjs_ua}"); + string value = $"hmac username=\"{GetHmacSha256("", "")}\", algorithm=\"hmac-sha256\", headers=\"request-line date host x-htjs-nonce x-htjs-ua\", signature=\"{GetHmacSha256("", stringBuilder.ToString())}\""; + return value; + } + /// + /// 获取HmacSha256 + /// + /// + /// + /// + public static string GetHmacSha256(string key, string value) + { + string rtnValue = ""; + byte[] keyBytes = Encoding.UTF8.GetBytes(key); + byte[] valueBytes = Encoding.UTF8.GetBytes(value); + using (var hmacsha256 = n \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/RsaEncryUtil.cs b/插件库/Lskj.QueryEssentialInfo/RsaEncryUtil.cs new file mode 100644 index 0000000..61689bf --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/RsaEncryUtil.cs @@ -0,0 +1,17 @@ +using Org.BouncyCastle.Crypto.Parameters; +using Org.BouncyCastle.Security; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Security.Cryptography; +using System.Text; + +namespace Lskj.QueryEssentialInfo +{ + public static class RsaEntryUtil + { + public static byte[] Encrypt(string plainText, string publicKeyXml) + { + byte[] dataToEncrypt = Encoding.UTF8.GetBytes(plainText); + using (RSACryptoServi \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/app.config b/插件库/Lskj.QueryEssentialInfo/app.config new file mode 100644 index 0000000..7473e07 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/插件库/Lskj.QueryEssentialInfo/packages.config b/插件库/Lskj.QueryEssentialInfo/packages.config new file mode 100644 index 0000000..a4b9563 --- /dev/null +++ b/插件库/Lskj.QueryEssentialInfo/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file