SVN r1013

SVN-Revision: r1013
This commit is contained in:
tdx
2025-10-11 03:45:52 +00:00
parent abf0727509
commit 6b797dde6b
2 changed files with 254 additions and 0 deletions
@@ -57,6 +57,13 @@ namespace Lskj.QueryEssentialInfo
MessageUtil.Show("个税申报完成");
}));
break;
case "2":
YLJQuery();
Invoke(new Action(() =>
{
MessageUtil.Show("个人养老金查询完成");
}));
break;
}
}
catch (Exception ex)
@@ -126,6 +133,22 @@ namespace Lskj.QueryEssentialInfo
SetProcessMsg($"正在查询专项附加数据...");
string getAdditionCode = QueryApiUtil.GetAddition(out string getAdditionResult, out string getAdditionMsg);
if (!getAdditionCode.Equals("0"))
{
if (getAdditionMsg.Equals("还未通过税务共享平台获取专项附加或员工还未上报专项附加"))
{
for (int i = 0; i < 5; i++)
{
getAdditionResult = "";
getAdditionMsg = "";
getAdditionCode = QueryApiUtil.GetAddition(out getAdditionResult, out getAdditionMsg);
if (getAdditionCode.Equals("0"))
{
break;
}
}
}
}
if (!getAdditionCode.Equals("0"))
{
throw new Exception($"查询数据失败\r\n{getAdditionMsg}");
}
@@ -375,6 +398,120 @@ namespace Lskj.QueryEssentialInfo
}));
}
/// <summary>
/// 养老金查询
/// </summary>
private void YLJQuery()
{
QueryApiUtil.Init(out string initResult, out string initMsg);
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 yljfqCode = QueryApiUtil.GetYLJFQ(out string yljfqResult, out string yljfqMsg);
if (!yljfqCode.Equals("0"))
{
for (int i = 0; i < 5; i++)
{
yljfqResult = "";
yljfqMsg = "";
yljfqCode = QueryApiUtil.GetYLJFQ(out yljfqResult, out yljfqMsg);
if (yljfqCode.Equals("0"))
{
break;
}
}
}
if (!yljfqCode.Equals("0"))
{
throw new Exception($"发起查询失败\r\n{yljfqMsg}");
}
else
{
string yljmxCode = QueryApiUtil.GetYLJMX(out string yljmxResult, out string yljmxMsg);
if (!yljmxCode.Equals("0"))
{
throw new Exception($"查询数据失败\r\n{yljmxMsg}");
}
else
{
JObject yljJObject = (JObject)JsonConvert.DeserializeObject(yljmxResult);
if (yljJObject.ContainsKey("data") && yljJObject["data"] is JArray)
{
JArray yljDataJArray = (JArray)yljJObject["data"];
foreach (JObject item in yljDataJArray)
{
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();
}
}
}
}
Invoke(new Action(() =>
{
this.Close();
}));
}
/// <summary>
/// 个税申报
/// </summary>
private void GSSBQuery()
@@ -601,6 +601,123 @@ namespace Lskj.QueryEssentialInfo
return code;
}
/// <summary>
/// 发起个人养老金查询
/// </summary>
/// <param name="resultRead"></param>
/// <param name="resultMsg"></param>
/// <returns></returns>
public static string GetYLJFQ(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/ylj/fqcx";
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("busiTypeCode", mainRow["busiTypeCode"] + "");
pmsJObject.Add("requestId", Guid.NewGuid().ToString().Replace("-", "").ToLower());
pmsJObject.Add("accountId", "1");
pmsJObject.Add("qysh", mainRow["qysh"] + "");
pmsJObject.Add("operator", mainRow["operator"] + "");
pmsJObject.Add("dknd", mainRow["dknd"] + "");
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;
}
/// <summary>
/// 获取个人养老金明细
/// </summary>
public static string GetYLJMX(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/ylj/list";
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("busiTypeCode", mainRow["busiTypeCode"] + "");
pmsJObject.Add("requestId", Guid.NewGuid().ToString().Replace("-", "").ToLower());
pmsJObject.Add("accountId", "1");
pmsJObject.Add("qysh", mainRow["qysh"] + "");
pmsJObject.Add("operator", mainRow["operator"] + "");
pmsJObject.Add("dknd", mainRow["dknd"] + "");
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;
}
/// <summary>
/// 个税申报
/// </summary>
/// <param name="resultRead"></param>