SVN r1100
SVN-Revision: r1100
This commit is contained in:
@@ -9,6 +9,8 @@ using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -33,6 +35,10 @@ namespace Lskj.QueryEssentialInfo
|
||||
{
|
||||
try
|
||||
{
|
||||
const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
|
||||
const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
|
||||
ServicePointManager.SecurityProtocol |= Tls12;
|
||||
|
||||
progressBarCurrent.Maximum = 100;
|
||||
progressBarCurrent.Value = 0;
|
||||
QueryApiUtil.mainRow = BaseImpl.GetDataRowResult(Model.MainSourceSql);
|
||||
@@ -64,6 +70,13 @@ namespace Lskj.QueryEssentialInfo
|
||||
MessageUtil.Show("个人养老金查询完成");
|
||||
}));
|
||||
break;
|
||||
case "3":
|
||||
DSFXZQuery();
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
MessageUtil.Show("第三方薪资查询完成");
|
||||
}));
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -577,6 +590,90 @@ namespace Lskj.QueryEssentialInfo
|
||||
}));
|
||||
}
|
||||
/// <summary>
|
||||
/// 三方薪资查询
|
||||
/// </summary>
|
||||
private void DSFXZQuery()
|
||||
{
|
||||
QueryApiUtil.Init(out string initResult, out string initMsg);
|
||||
var rowsEnumerable = QueryApiUtil.detailTab.AsEnumerable();
|
||||
if (rowsEnumerable.Where(n => string.IsNullOrEmpty(n["p_emp_addTag"] + "") || (n["p_emp_addTag"] + "").Equals("0")).Count() > 0)
|
||||
{
|
||||
SetProcessMsg($"正在报送人员...");
|
||||
string personCode = QueryApiUtil.Person(out string personResult, out string personMsg);
|
||||
if (!personCode.Equals("0"))
|
||||
{
|
||||
throw new Exception($"报送失败\r\n{personMsg}");
|
||||
}
|
||||
SetProcessMsg($"正在查询报送人员...");
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
SetProcessMsg($"正在查询报送人员...({i + 1}秒)");
|
||||
}
|
||||
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("验证成功"))
|
||||
{
|
||||
DataRow selectRow = rowsEnumerable.Where(n => (n["idNumber"] + "").Equals(sfzh)).FirstOrDefault();
|
||||
if (selectRow != null)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery($"update hr_grdkfptab set p_emp_addTag = 1 where hr_ID_Card = '{sfzh}'");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DataRow selectRow = rowsEnumerable.Where(n => (n["idNumber"] + "").Equals(sfzh)).FirstOrDefault();
|
||||
if (selectRow != null)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery($"update hr_grdkfptab set p_emp_addTag = 2,error_msg='{bszt},{sfyzzt}' where hr_ID_Card = '{sfzh}'");
|
||||
}
|
||||
}
|
||||
SetProcessMsg($"已报送:{name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QueryApiUtil.detailTab = BaseImpl.GetDataTableResult(Model.DetailSourceSql);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
rowsEnumerable = QueryApiUtil.detailTab.AsEnumerable();
|
||||
int maxCount = rowsEnumerable.Where(n => (n["p_emp_addTag"] + "").Equals("1")).Count();
|
||||
if (maxCount > 0)
|
||||
{
|
||||
progressBarCurrent.Maximum = rowsEnumerable.Where(n => (n["p_emp_addTag"] + "").Equals("1")).Count();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"人员报送失败,员工未成功上报专项附加");
|
||||
}
|
||||
}));
|
||||
SetProcessMsg($"正在同步收入...");
|
||||
string dsfxzCode = QueryApiUtil.GetDSFXZ(out string dsfxzResult, out string dsfxzMsg);
|
||||
if (!dsfxzCode.Equals("0"))
|
||||
{
|
||||
throw new Exception($"同步收入失败\r\n{dsfxzMsg}");
|
||||
}
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.Close();
|
||||
}));
|
||||
}
|
||||
/// <summary>
|
||||
/// 个税申报
|
||||
/// </summary>
|
||||
private void GSSBQuery()
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
{
|
||||
public static class QueryApiUtil
|
||||
{
|
||||
public static string urlStart = "https://api.baiwangjs.com/swgx-saas/swgxpt-shishi-cpsbmk/v2";
|
||||
public static DataRow mainRow;
|
||||
public static DataTable detailTab;
|
||||
/// <summary>
|
||||
@@ -351,7 +352,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/gsmycsh";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/gsmycsh";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -395,7 +396,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/syn/person";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/syn/person";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -421,15 +422,15 @@ namespace Lskj.QueryEssentialInfo
|
||||
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"] + "");
|
||||
bizDataJObject.Add("name", detailRow.Table.Columns.Contains("name") ? detailRow["name"] + "" : "");
|
||||
bizDataJObject.Add("idType", detailRow.Table.Columns.Contains("idType") ? detailRow["idType"] + "" : "");
|
||||
bizDataJObject.Add("idNumber", detailRow.Table.Columns.Contains("idNumber") ? detailRow["idNumber"] + "" : "");
|
||||
bizDataJObject.Add("sex", detailRow.Table.Columns.Contains("sex") ? detailRow["sex"] + "" : "");
|
||||
bizDataJObject.Add("birthday", detailRow.Table.Columns.Contains("birthday") ? detailRow["birthday"] + "" : "");
|
||||
bizDataJObject.Add("employType", detailRow.Table.Columns.Contains("employType") ? detailRow["employType"] + "" : "");
|
||||
bizDataJObject.Add("employedDate", detailRow.Table.Columns.Contains("employedDate") ? detailRow["employedDate"] + "" : "");
|
||||
bizDataJObject.Add("phoneNumber", detailRow.Table.Columns.Contains("phoneNumber") ? detailRow["phoneNumber"] + "" : "");
|
||||
bizDataJObject.Add("isDeductExpense", detailRow.Table.Columns.Contains("isDeductExpense") ? detailRow["isDeductExpense"] + "" : "");
|
||||
bizlistJArray.Add(bizDataJObject);
|
||||
}
|
||||
pmsJObject.Add("bizDataList", bizlistJArray);
|
||||
@@ -458,7 +459,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/person/submit/query";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/person/submit/query";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -500,7 +501,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/syn/special/addition";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/syn/special/addition";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -555,7 +556,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/acquire/special/addition";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/acquire/special/addition";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -613,7 +614,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/acquire/ylj/fqcx";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/acquire/ylj/fqcx";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -670,7 +671,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/acquire/ylj/list";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/acquire/ylj/list";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -730,7 +731,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/submit";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/submit";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -774,7 +775,7 @@ namespace Lskj.QueryEssentialInfo
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = "http://swgxs.poc.htjs.net:9019/v2/web/sbmk/personal-tax/api/v1/submit/query";
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/submit/query";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
DateTime utcNow = DateTime.UtcNow;
|
||||
@@ -809,6 +810,73 @@ namespace Lskj.QueryEssentialInfo
|
||||
return code;
|
||||
}
|
||||
/// <summary>
|
||||
/// 发起个人养老金查询
|
||||
/// </summary>
|
||||
/// <param name="resultRead"></param>
|
||||
/// <param name="resultMsg"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetDSFXZ(out string resultRead, out string resultMsg)
|
||||
{
|
||||
string code = "-9999";
|
||||
resultRead = "";
|
||||
resultMsg = "";
|
||||
try
|
||||
{
|
||||
string url = $"{urlStart}/web/sbmk/personal-tax/api/v1/syn/income";
|
||||
HttpTools.setting("application/json", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||
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("qysh", mainRow["qysh"] + "");
|
||||
pmsJObject.Add("operator", mainRow["qysh"] + "");
|
||||
pmsJObject.Add("skssqQ", mainRow["qysh"] + "");
|
||||
pmsJObject.Add("skssqZ", mainRow["qysh"] + "");
|
||||
JArray bizDataListJArry = new JArray();
|
||||
JArray incomeDataListJArry = new JArray();
|
||||
foreach (DataRow detailRow in detailTab.Rows)
|
||||
{
|
||||
JObject incomeDataJObject = new JObject();
|
||||
string addTag = detailRow["p_emp_addTag"] + "";
|
||||
if (!addTag.Equals("1"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
incomeDataJObject.Add("name", detailRow["name"] + "");
|
||||
incomeDataJObject.Add("idType", detailRow["idType"] + "");
|
||||
incomeDataJObject.Add("idNumber", detailRow["idNumber"] + "");
|
||||
incomeDataJObject.Add("income", detailRow["income"] + "");
|
||||
incomeDataListJArry.Add(incomeDataJObject);
|
||||
}
|
||||
JObject bizDataJObject = new JObject();
|
||||
bizDataJObject.Add("incomeTypeCode", "101060100010500");
|
||||
bizDataJObject.Add("incomeDataList", incomeDataListJArry);
|
||||
bizDataListJArry.Add(bizDataJObject);
|
||||
pmsJObject.Add("bizDataList", bizDataListJArry);
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取Authorization
|
||||
/// </summary>
|
||||
public static string GetAuthorization(string date, string host, string x_htjs_nonce, string x_htjs_ua)
|
||||
@@ -833,4 +901,26 @@ namespace Lskj.QueryEssentialInfo
|
||||
string rtnValue = "";
|
||||
byte[] keyBytes = Encoding.UTF8.GetBytes(key);
|
||||
byte[] valueBytes = Encoding.UTF8.GetBytes(value);
|
||||
using (var hmacsha256 = n
|
||||
using (var hmacsha256 = new HMACSHA256(keyBytes))
|
||||
{
|
||||
byte[] hashValue = hmacsha256.ComputeHash(valueBytes);
|
||||
rtnValue = Convert.ToBase64String(hashValue);
|
||||
}
|
||||
return rtnValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// MD5加密
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetMD5Hash(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
using (MD5 md5 = MD5.Create())
|
||||
{
|
||||
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
|
||||
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
||||
StringBuilder sb = new StringBuil
|
||||
Reference in New Issue
Block a user