From cc654d6e45cbee090c6cd9d5afbc696217c81cbe Mon Sep 17 00:00:00 2001 From: dengyu Date: Mon, 19 Aug 2024 11:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BF=E9=80=9A=E8=B4=A6=E5=8D=95=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E3=80=82=E5=BE=AE=E8=B0=83=EF=BC=8C=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=B6message=E4=B8=BAstring=EF=BC=8C=E9=9D=9E=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=97=B6message=E4=B8=8D=E6=98=AFstring=EF=BC=8C?= =?UTF-8?q?=E9=9C=80=E6=AD=A3=E5=B8=B8=E8=A7=A3=E6=9E=90=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- JobAutoCreateFee/JobYt2D6Fee.cs | 8 ++ JobAutoCreateFee/JobYt2D7Fee.cs | 137 +++++++++++++++++++------------- 2 files changed, 91 insertions(+), 54 deletions(-) diff --git a/JobAutoCreateFee/JobYt2D6Fee.cs b/JobAutoCreateFee/JobYt2D6Fee.cs index 2ee6172e..f28a48c6 100644 --- a/JobAutoCreateFee/JobYt2D6Fee.cs +++ b/JobAutoCreateFee/JobYt2D6Fee.cs @@ -327,6 +327,14 @@ namespace JobCreateFee public string end_time { get; set; } public string company { get; set; } = "CMA_TAO"; } + + public class josnYtData_State + { + public string status { get; set; } + + public string message { get; set; } + + } public class josnYtData { public string status { get; set; } diff --git a/JobAutoCreateFee/JobYt2D7Fee.cs b/JobAutoCreateFee/JobYt2D7Fee.cs index d623ede4..1fd2835b 100644 --- a/JobAutoCreateFee/JobYt2D7Fee.cs +++ b/JobAutoCreateFee/JobYt2D7Fee.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Text; using System.Data.Entity; using JobAutoCreateFee.Model; +using System.Runtime.Remoting; namespace JobCreateFee @@ -61,12 +62,6 @@ namespace JobCreateFee reqObj.end_time = yesterday; reqObj.company = "CMA_TAO"; - var sendstr = JsonConvert.SerializeObject(reqObj); - log.Debug($"发送包{reqObj.company}:{sendstr}"); - - //发送请求数据 - string rtnStr_CMA_TAO = WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000); - //var testrtnobject = new josnYtData(); //testrtnobject.status = "1"; //var testfee = new JsonYtFee(); @@ -86,6 +81,12 @@ namespace JobCreateFee //testrtnobject.message.Add(testfee); //var rtn = JsonConvert.SerializeObject(testrtnobject); + var sendstr = JsonConvert.SerializeObject(reqObj); + log.Debug($"发送包{reqObj.company}:{sendstr}"); + + //发送请求数据 + string rtnStr_CMA_TAO = "{\"message\":\"未查询出数据\",\"status\":\"0\"}"; + rtnStr_CMA_TAO=WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000); log.Debug($"数据返回{reqObj.company}:{rtnStr_CMA_TAO}"); //var objRtn = JsonConvert.DeserializeAnonymousType(rtn, new { status = "", message = "" }); @@ -94,14 +95,17 @@ namespace JobCreateFee reqObj.company = "CMA_DLC"; sendstr = JsonConvert.SerializeObject(reqObj); log.Debug($"发送包{reqObj.company}:{sendstr}"); - string rtnStr_CMA_DLC = WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000); + string rtnStr_CMA_DLC = "{\"message\":\"未查询出数据\",\"status\":\"0\"}"; + rtnStr_CMA_DLC=WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000); log.Debug($"数据返回{reqObj.company}:{rtnStr_CMA_DLC}"); reqObj.company = "CMA_TXG"; sendstr = JsonConvert.SerializeObject(reqObj); log.Debug($"发送包{reqObj.company}:{sendstr}"); - string rtnStr_CMA_TXG = WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000); + string rtnStr_CMA_TXG = "{\"message\":\"未查询出数据\",\"status\":\"0\"}"; + //"{\"message\":[{\"applicant_code\":\"hhcma\",\"barcode\":\"1056936938466968\",\"bookingno\":\"TJN0471222\",\"ctn_no\":\"TEMU0083340\",\"ctn_type\":\"20ST\",\"fee\":\"1.0\",\"operatetime\":\"2024-08-18 12:27:00\",\"operatetype\":\"打印通知单\",\"printType\":\"纸面\",\"secondPrintFee\":\"30.0\",\"trans_port_code\":\"MXZLO\",\"vessel\":\"GREGOS\",\"voyage\":\"0WU0VE\",\"yard\":\"克运物流\"},{\"applicant_code\":\"hhcma\",\"barcode\":\"1058836938466967\",\"bookingno\":\"TJN0471222\",\"ctn_no\":\"CMAU3066259\",\"ctn_type\":\"20ST\",\"fee\":\"1.0\",\"operatetime\":\"2024-08-18 12:27:00\",\"operatetype\":\"打印通知单\",\"printType\":\"纸面\",\"secondPrintFee\":\"30.0\",\"trans_port_code\":\"MXZLO\",\"vessel\":\"GREGOS\",\"voyage\":\"0WU0VE\",\"yard\":\"克运物流\"},{\"applicant_code\":\"hhcma\",\"barcode\":\"1084536938466966\",\"bookingno\":\"TJN0471222\",\"ctn_no\":\"TEMU5580118\",\"ctn_type\":\"20ST\",\"fee\":\"1.0\",\"operatetime\":\"2024-08-18 12:27:00\",\"operatetype\":\"打印通知单\",\"printType\":\"纸面\",\"secondPrintFee\":\"30.0\",\"trans_port_code\":\"MXZLO\",\"vessel\":\"GREGOS\",\"voyage\":\"0WU0VE\",\"yard\":\"克运物流\"},{\"applicant_code\":\"hhcma\",\"barcode\":\"1041136938466965\",\"bookingno\":\"TJN0471222\",\"ctn_no\":\"TCLU7442738\",\"ctn_type\":\"20ST\",\"fee\":\"1.0\",\"operatetime\":\"2024-08-18 12:27:00\",\"operatetype\":\"打印通知单\",\"printType\":\"纸面\",\"secondPrintFee\":\"30.0\",\"trans_port_code\":\"MXZLO\",\"vessel\":\"GREGOS\",\"voyage\":\"0WU0VE\",\"yard\":\"克运物流\"}],\"status\":\"1\"}"; + rtnStr_CMA_DLC=WebRequestHelper.DoPost(reqUrl, sendstr, reqTimeout * 1000); log.Debug($"数据返回{reqObj.company}:{rtnStr_CMA_TXG}"); DealReturnJson(rtnStr_CMA_TAO); @@ -110,70 +114,95 @@ namespace JobCreateFee void DealReturnJson(string rtn) { - var objRtn = JsonConvert.DeserializeObject(rtn); - if (objRtn.status == "1") + try { - //var parseJsonObj = JsonConvert.DeserializeObject>(objRtn.message); + log.Debug($"开始解析:{rtn}"); + try { - //1 记录进t_op_ytfee_log 表 - //2 遍历信息,将同提单号的费用合起来 - //3 遍历提单号,寻找业务,判断业务能否增加费用 - //3.1 业务是否已退仓 - //3.2 业务是否费用锁定 - //3.3 业务会计期间是否已锁帐 - //以上情况分别发送邮件提醒 - //4 如能增加费用 则插入费用 - - using (SqlConnection dbcon = new SqlConnection(connStr)) + var candeal = JsonConvert.DeserializeObject(rtn); + if (candeal.status == "0") { - var hp = new YTFEEHelper(); - var FEELIST = new List(); - dbcon.Open(); + log.Debug($"解析结束:status={candeal.status}:{candeal.message}"); + return; + } + } + catch (Exception e) { + + } - foreach (var returndata in objRtn.message) + var objRtn = JsonConvert.DeserializeObject(rtn); + if (objRtn.status == "1") + { + //var parseJsonObj = JsonConvert.DeserializeObject>(objRtn.message); + try + { + //1 记录进t_op_ytfee_log 表 + //2 遍历信息,将同提单号的费用合起来 + //3 遍历提单号,寻找业务,判断业务能否增加费用 + //3.1 业务是否已退仓 + //3.2 业务是否费用锁定 + //3.3 业务会计期间是否已锁帐 + //以上情况分别发送邮件提醒 + //4 如能增加费用 则插入费用 + + using (SqlConnection dbcon = new SqlConnection(connStr)) { - //测试数据 - //if (returndata.bookingno != "QGD0721089") continue; + var hp = new YTFEEHelper(); + var FEELIST = new List(); + dbcon.Open(); - if (returndata.fee == "" || returndata.fee == null) returndata.fee = "0"; - if (returndata.ydFee == "" || returndata.ydFee == null) returndata.ydFee = "0"; - if (returndata.secondPrintFee == "" || returndata.secondPrintFee == null) returndata.secondPrintFee = "0"; + foreach (var returndata in objRtn.message) + { + //测试数据 + //if (returndata.bookingno != "QGD0721089") continue; - var D7BS = GETD7OPSEAEBS(returndata, YTD7Condition, dbcon); + if (returndata.fee == "" || returndata.fee == null) returndata.fee = "0"; + if (returndata.ydFee == "" || returndata.ydFee == null) returndata.ydFee = "0"; + if (returndata.secondPrintFee == "" || returndata.secondPrintFee == null) returndata.secondPrintFee = "0"; - string sql = " INSERT INTO t_op_ytfee_log([bsno],[vessel],[voyage],[bookingno],[ctn_type],[ctn_no],[yard],[operatetime],[operatetype]"; - sql = sql + ",[printType],[fee],[ydFee],[secondPrintFee],[applicant_code]) values ('" + D7BS.BSNO + "','" + returndata.vessel + "'"; - sql = sql + ",'" + returndata.voyage + "','" + returndata.bookingno + "','" + returndata.ctn_type + "','" + returndata.ctn_no + "','" + returndata.yard + "'"; - sql = sql + ",'" + returndata.operatetime + "','" + returndata.operatetype + "','" + returndata.printType + "','" + returndata.fee - + "','" + returndata.ydFee + "','" + returndata.secondPrintFee + "','" + returndata.applicant_code + "')"; - SqlCommand cmd = new SqlCommand(sql, dbcon); - cmd.ExecuteNonQuery(); + var D7BS = GETD7OPSEAEBS(returndata, YTD7Condition, dbcon); - D7BS.ENTEROPERATOR = ENTEROPERATOR; + string sql = " INSERT INTO t_op_ytfee_log([bsno],[vessel],[voyage],[bookingno],[ctn_type],[ctn_no],[yard],[operatetime],[operatetype]"; + sql = sql + ",[printType],[fee],[ydFee],[secondPrintFee],[applicant_code]) values ('" + D7BS.BSNO + "','" + returndata.vessel + "'"; + sql = sql + ",'" + returndata.voyage + "','" + returndata.bookingno + "','" + returndata.ctn_type + "','" + returndata.ctn_no + "','" + returndata.yard + "'"; + sql = sql + ",'" + returndata.operatetime + "','" + returndata.operatetype + "','" + returndata.printType + "','" + returndata.fee + + "','" + returndata.ydFee + "','" + returndata.secondPrintFee + "','" + returndata.applicant_code + "')"; + SqlCommand cmd = new SqlCommand(sql, dbcon); + cmd.ExecuteNonQuery(); - hp.addYTFee(returndata, D7BS, YTD7NoUseCORPID); - } - //hp.makefee(); + D7BS.ENTEROPERATOR = ENTEROPERATOR; - hp.SendMail(); + hp.addYTFee(returndata, D7BS, YTD7NoUseCORPID); + } + //hp.makefee(); - dbcon.Close(); + hp.SendMail(); - hp.makefee_应付(); + dbcon.Close(); + + hp.makefee_应付(); + } } - } - catch (Exception e) - { - log.Debug($"记录插入错误:{e.Message}"); + catch (Exception e) + { + log.Debug($"记录插入错误:{e.Message}"); - } + } + } + else + { + log.Debug($"数据返回错误:{objRtn.message}"); + } } - else + catch (Exception e) { - log.Debug($"数据返回错误:{objRtn.message}"); + log.Debug($"解析错误:{JsonConvert.SerializeObject(e) }"); + } + finally { + log.Debug($"解析完成"); } } @@ -247,8 +276,8 @@ namespace JobCreateFee } catch (Exception ex) { - log.Error(ex.Message); - log.Error(ex.StackTrace); + log.Error($"execute错误:{JsonConvert.SerializeObject(ex)}"); + //log.Error(ex.StackTrace); } }