using log4net ;
using Newtonsoft.Json ;
using Newtonsoft.Json.Linq ;
using Quartz ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.IO ;
using System.Linq ;
using System.Text ;
using HcUtility.Core ;
using HcUtility.Comm ;
using System.Data.Entity ;
namespace JobPingTaiWork
{
public class blnopack
{
//private static MBLNOList;
}
public class JobWLXXSave : IJob
{
private ILog log = LogManager . GetLogger ( typeof ( JobWLXXSave ) ) ;
private string connStr { get ; set ; }
private string TimeType { get ; set ; }
private Int32 StartDays { get ; set ; }
private Int32 EndDays { get ; set ; }
/ /
private Int32 StartTime_single { get ; set ; }
private Int32 EndTime_single { get ; set ; }
public void Execute ( IJobExecutionContext context )
{
log . Debug ( $"Execute开始" ) ;
try
{
connStr = context . JobDetail . JobDataMap . GetString ( "ConnectString" ) ;
StartDays = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "StartDays" ) ) ;
EndDays = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "EndDays" ) ) ;
TimeType = context . JobDetail . JobDataMap . GetString ( "TimeType" ) ;
StartTime_single = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "StartTime_single" ) ) ;
EndTime_single = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "EndTime_single" ) ) ;
log . Debug ( $"连接字符串:{connStr}" ) ;
log . Debug ( $"起始天数:{StartDays}" ) ;
log . Debug ( $"终止天数:{EndDays}" ) ;
log . Debug ( $"时间类型:{TimeType}" ) ;
var nowhour = DateTime . Now . Hour ;
var sqlQuery = " Select case when isnull(HBLNO,'')<>'' then HBLNO else MBLNO end MBLNO,MFNO from op_seae_edi " ;
var queryfield = "" ;
if ( TimeType = = "录入日期" )
{
queryfield = " INPUTDATE " ;
}
if ( TimeType = = "发送日期" )
{
queryfield = " SENDTIME " ;
}
if ( TimeType = = "开船日期" )
{
queryfield = " ETD " ;
}
var startdate = DateTime . Now . AddDays ( - StartDays ) . ToString ( "yyyy-MM-dd" ) ;
var enddate = DateTime . Now . AddDays ( - EndDays + 1 ) . ToString ( "yyyy-MM-dd" ) ;
if ( StartTime_single < = nowhour & & nowhour < EndTime_single )
{
startdate = DateTime . Now . AddDays ( 0 ) . ToString ( "yyyy-MM-dd" ) ;
enddate = DateTime . Now . AddDays ( 1 ) . ToString ( "yyyy-MM-dd" ) ;
}
sqlQuery + = string . Format ( " where isnull(HBLNO,'')='' and {0}>='{1}' and {2}<'{3}' " , queryfield , startdate , queryfield , enddate ) ;
sqlQuery + = " and not exists (select 1 from op_seae_edi_status where mfno=op_seae_edi.mfno and statustext= '接受申报' ) and dbo.getblno(mfno) not in(select mblno from wlxx_mblno) and isnull(ISdelete,0)=0" +
" and getdate()> DATEADD(minute,10, SENDTIME) " +
" order by " + queryfield ;
var MBLNOList = DoWork . GetMBLNOList ( connStr , sqlQuery ) ;
if ( MBLNOList . Count = = 0 )
{
log . Debug ( "没有要发送的数据!" ) ;
return ;
}
//然后将所有提单号存入数据库
var SaveSql = Local_Mblnomb . getSaveSql ( MBLNOList ) ;
using ( SqlConnection dbcon = new SqlConnection ( connStr ) )
{
dbcon . Open ( ) ;
using ( SqlTransaction trans = dbcon . BeginTransaction ( ) )
{
//增加判断 如果
foreach ( string Sqlitem in SaveSql )
{
if ( ! string . IsNullOrWhiteSpace ( Sqlitem ) )
{
//log.Debug($"TaskSqlitem: {TaskSqlitem}");
SqlCommand cmd = new SqlCommand ( Sqlitem , dbcon , trans ) ;
cmd . ExecuteNonQuery ( ) ;
}
}
trans . Commit ( ) ;
}
dbcon . Close ( ) ;
}
}
catch ( Exception ex )
{
log . Error ( ex . Message ) ;
log . Error ( ex . StackTrace ) ;
}
}
private void DoSendMessage ( string mblno )
{
}
}
public class JobWLXXGet : IJob
{
private ILog log = LogManager . GetLogger ( typeof ( JobWLXXGet ) ) ;
private string connStr { get ; set ; }
private string reqUrl { get ; set ; }
private Int32 reqTimeout { get ; set ; }
public void Execute ( IJobExecutionContext context )
{
try
{
connStr = context . JobDetail . JobDataMap . GetString ( "ConnectString" ) ;
reqUrl = context . JobDetail . JobDataMap . GetString ( "ReqUrl" ) ;
reqTimeout = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "RequestTimeout" ) ) ;
log . Debug ( $"连接字符串:{connStr}" ) ;
log . Debug ( $"请求URL: {reqUrl}" ) ;
log . Debug ( $"请求超时:{reqTimeout}" ) ;
EdiStatusDAL . connstr = connStr ;
//查找wlxx_mblno 当中最早的数据
var getsqlstr = "select * from wlxx_mblno where id = (select min(id) from wlxx_mblno)" ;
var MBLNOList = DoWork . GetMBLNOList ( connStr , getsqlstr ) ;
if ( MBLNOList . Count = = 0 )
{
log . Debug ( "没有要查询的数据!" ) ;
return ;
}
var MBLNO = MBLNOList [ 0 ] . MBLNO ;
var MFNO = MBLNOList [ 0 ] . MFNO ;
//访问url获取爬取的数据
//字段说明: http://123.234.225.158:32222/manage/file
JObject reqObj = new JObject ( ) ;
reqObj . Add ( "user_key" , "QDDJY" ) ;
reqObj . Add ( "user_secret" , "YGH2020" ) ;
//下方此处无关权限 只用于区分调用来源
reqObj . Add ( "customer_id" , "DY_DingShiWuLiuXinXi" ) ;
reqObj . Add ( "customer_name" , "大简云定时读取物流信息" ) ;
reqObj . Add ( "web_code" , "HLW_CD" ) ;
reqObj . Add ( "bno" , new JValue ( MBLNO ) ) ;
reqObj . Add ( "vessel_name" , "" ) ;
reqObj . Add ( "voyage_no" , "" ) ;
reqObj . Add ( "wharf_name" , "" ) ;
reqObj . Add ( "req_type" , "0" ) ;
reqObj . Add ( "web_user" , "" ) ;
reqObj . Add ( "web_psw" , "" ) ;
reqObj . Add ( "wltype" , "WLXX" ) ;
string mailAddr = "" ;
string rtn = "" ;
List < WLXXModel > mList ;
RepWLXXModel mWLXX ;
try
{
//log.Debug($"请求数据:{reqObj}");
//rtn = WebRequestHelper.DoPost(reqUrl, reqObj.ToString(Newtonsoft.Json.Formatting.None), reqTimeout * 1000);
//log.Debug($"返回数据:{rtn}");
//rtn = @"{""code"": 200, ""data"": [{""ChuKouBaoGuan"": """", ""FangXingShiJian"": """", ""FangXingZhuangTai"": ""未放行"", ""HuoWuZhuangTai"": ""进、出口货物"", ""ISFenDan"": false, ""JianShu"": ""212"", ""MBLNO"": ""HDMUTAOZ27376200"", ""ShenBaoXiangShu"": ""1"", ""YARDNAME"": ""HLW_CD"", ""YuPeiJieGuo"": ""接受申报"", ""YuPeiShiJian"": ""2023/5/10 13:29:46"", ""YunDiJieGuo"": ""未申报"", ""YunDiShiJian"": """", ""ZhongLiang"": ""17530.20"", ""ZhuangZaiJieGuo"": ""未申报"", ""ZhuangZaiShiJian"": """", ""ZuDanInfo"": ""HDMUTAOZ27376200"", ""vessel"": ""YM TRAVEL"", ""voyage"": ""009E""}], ""msg"": ""ok"", ""request"": ""POST /v1/real/query""}";
try
{
var PortResult = Newtonsoft . Json . JsonConvert . DeserializeObject < RepWLXXModel > ( rtn ) ;
//测试数据
//MBLNO = "HDMUTAOZ27376200";
//MFNO = "7f86e5e6-912f-4e01-b0ee-14b5f0ad62d4";
if ( PortResult . code = = 200 )
{
var portstatus = PortResult . data [ 0 ] ;
edistatusMb newStatusRecord = new edistatusMb ( ) ;
//var laststatus = portstatus.getlaststatus();
var Localstatuslist = EdiStatusDAL . GetDataList ( connStr , " MFNO='" + MFNO + "' " ) ;
var PortStatusList = portstatus . getstatusList ( ) ;
if ( PortStatusList . Count > 0 )
{
foreach ( var newstatus in PortStatusList )
{
var upd = false ;
if ( Localstatuslist . Count > 0 )
foreach ( var status in Localstatuslist )
{
if ( status . GetValue ( "statustext" ) = = newstatus . status )
{
if ( newstatus . needinsert ( ) )
{
newStatusRecord = status ;
newStatusRecord . SetValue ( "statustime" , newstatus . timestr ) ;
//newStatusRecord.SetValue("statustime", newstatus.timestr);
newStatusRecord . SetValue ( "ShenBaoXiangShu" , portstatus . ShenBaoXiangShu ) ;
newStatusRecord . DbOperationType = DbOperationType . DbotUpd ;
//result = SaveStatus(newStatusRecord, headdata.MFNO);
upd = true ;
EdiStatusDAL . Update ( newStatusRecord ) ;
}
else
{
newStatusRecord = status ;
EdiStatusDAL . Delete ( newStatusRecord ) ;
}
}
}
if ( ! upd & & newstatus . needinsert ( ) )
{
//循环完了没找到同状态 则新增一条
//newStatusRecord.SetValue("gid", Guid.NewGuid().ToString());
newStatusRecord . SetValue ( "mfno" , MFNO ) ;
if ( ! string . IsNullOrWhiteSpace ( newstatus . timestr ) )
newStatusRecord . SetValue ( "statustime" , newstatus . timestr ) ;
newStatusRecord . SetValue ( "statustext" , newstatus . status ) ;
newStatusRecord . SetValue ( "ShenBaoXiangShu" , portstatus . ShenBaoXiangShu ) ;
newStatusRecord . DbOperationType = DbOperationType . DbotIns ;
newStatusRecord . SetValue ( "mblno" , MBLNO ) ;
EdiStatusDAL . Insert ( newStatusRecord ) ;
}
}
DelMinMblno ( connStr ) ;
}
}
else {
if ( PortResult . msg . Contains ( "单号信息不存在" ) )
{
}
log . Debug ( $"【{MBLNO}】code={PortResult.code}:" + PortResult . msg ) ;
DelMinMblno ( connStr ) ;
}
//if (rtn.Contains("单号信息不存在"))
//{
// DelMinMblno(connStr);
//}
//else
//if (rtn.Contains("验证码") || rtn.Contains("无可用账号") || rtn.Contains("当前单号无信息"))
//{
// log.Debug($"没有查询到{MBLNO}的信息");
//}
//else
//{
//}
}
catch ( Exception e )
{
log . Debug ( $"saveerror1: {e.Message}" ) ;
}
}
catch ( Exception ex )
{
log . Debug ( $"saveerror2: {ex.Message}" ) ;
}
}
catch ( Exception ex )
{
log . Debug ( $"catch: {ex.Message}" ) ;
log . Error ( ex . Message ) ;
log . Error ( ex . StackTrace ) ;
}
}
/// <summary>
/// 从待读数据中去掉id最小的那个 也就是最早的那个 代表已读取
/// </summary>
/// <param name="connStr"></param>
public static void DelMinMblno ( string connStr )
{
var _r = DoWork . ExecSql ( connStr , " delete from wlxx_mblno where id =(select min(id) from wlxx_mblno ) " ) ;
}
public static void DelMinMblno_1 ( string connStr )
{
var _r = DoWork . ExecSql ( connStr , " delete from wlxx_mblno_1 where id =(select min(id) from wlxx_mblno_1 ) " ) ;
}
}
//public class JobWLXX_GetDelay : IJob
//{
// //从WLXX_MBLNO_DELAY表中查找时间合适的数据
// //插入到WLXX_MBLNO表中 并将其ID数字放置在靠前位置
// private ILog log = LogManager.GetLogger(typeof(JobWLXX_GetDelay));
// private string connStr { get; set; }
// private string reqUrl { get; set; }
// private Int32 reqTimeout { get; set; }
// private Int32 ReadDealyMinutes { get; set; }
// public void Execute(IJobExecutionContext context)
// {
// try
// {
// connStr = context.JobDetail.JobDataMap.GetString("ConnectString");
// reqUrl = context.JobDetail.JobDataMap.GetString("ReqUrl");
// reqTimeout = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("RequestTimeout"));
// ReadDealyMinutes = Convert.ToInt32(context.JobDetail.JobDataMap.GetString("ReadDealyMinutes"));
// log.Debug($"连接字符串:{connStr}");
// log.Debug($"请求URL: {reqUrl}");
// log.Debug($"请求超时:{reqTimeout}");
// log.Debug($"读取未完成后延迟时间(分钟): {ReadDealyMinutes}");
// EdiStatusDAL.connstr = connStr;
// //查找 WLXX_MBLNO_DELAY 当中时间早于当前时间的数据
// var getsqlstr = "select * from WLXX_MBLNO_DELAY where READTIME<=getdate()";
// var MBLNOList = DoWork.GetMBLNOList(connStr, getsqlstr);
// if (MBLNOList.Count == 0)
// {
// log.Debug("没有要查询的数据!");
// return;
// }
// var id = MBLNOList[0].id;
// var MBLNO = MBLNOList[0].MBLNO;
// var MFNO = MBLNOList[0].MFNO;
// //访问url获取爬取的数据
// JObject reqObj = new JObject();
// reqObj.Add("yardid", "WLXX");
// reqObj.Add("mblno", new JValue(MBLNO));
// reqObj.Add("isweb", "2");
// reqObj.Add("wltype", "WLXX");
// string mailAddr = "";
// string rtn = "";
// List<WLXXModel> mList;
// RepWLXXModel mWLXX;
// try
// {
// log.Debug($"请求数据:{reqObj}");
// rtn = WebRequestHelper.DoPost(reqUrl, reqObj.ToString(Newtonsoft.Json.Formatting.None), reqTimeout * 1000);
// log.Debug($"返回数据:{rtn}");
// try
// {
// if (rtn.Contains("单号信息不存在"))
// {
// DelMinMblno(connStr);
// DelayMblno(connStr, id);
// }
// else
// if (rtn.Contains("验证码") || rtn.Contains("无可用账号") || rtn.Contains("当前单号无信息"))
// {
// log.Debug($"没有查询到{MBLNO}的信息");
// DelayMblno(connStr, id);
// }
// else
// {
// var PortResult = Newtonsoft.Json.JsonConvert.DeserializeObject<RepWLXXModel>(rtn);
// var portstatus = PortResult.message[0];
// edistatusMb newStatusRecord = new edistatusMb();
// //var laststatus = portstatus.getlaststatus();
// var Localstatuslist = EdiStatusDAL.GetDataList(connStr, " MFNO='" + MFNO + "' ");
// var PortStatusList = portstatus.getstatusList();
// if (PortStatusList.Count > 0)
// {
// foreach (var newstatus in PortStatusList)
// {
// var upd = false;
// if (Localstatuslist.Count > 0)
// foreach (var status in Localstatuslist)
// {
// if (status.GetValue("statustext") == newstatus.status)
// {
// if (newstatus.needinsert())
// {
// newStatusRecord = status;
// newStatusRecord.SetValue("statustime", newstatus.timestr);
// //newStatusRecord.SetValue("statustime", newstatus.timestr);
// newStatusRecord.SetValue("ShenBaoXiangShu", portstatus.ShenBaoXiangShu);
// newStatusRecord.DbOperationType = DbOperationType.DbotUpd;
// //result = SaveStatus(newStatusRecord, headdata.MFNO);
// upd = true;
// EdiStatusDAL.Update(newStatusRecord);
// }
// else
// {
// newStatusRecord = status;
// EdiStatusDAL.Delete(newStatusRecord);
// }
// }
// }
// if (!upd && newstatus.needinsert())
// {
// //循环完了没找到同状态 则新增一条
// //newStatusRecord.SetValue("gid", Guid.NewGuid().ToString());
// newStatusRecord.SetValue("mfno", MFNO);
// if (!string.IsNullOrWhiteSpace(newstatus.timestr))
// newStatusRecord.SetValue("statustime", newstatus.timestr);
// newStatusRecord.SetValue("statustext", newstatus.status);
// newStatusRecord.SetValue("ShenBaoXiangShu", portstatus.ShenBaoXiangShu);
// newStatusRecord.DbOperationType = DbOperationType.DbotIns;
// newStatusRecord.SetValue("mblno", MBLNO);
// EdiStatusDAL.Insert(newStatusRecord);
// }
// }
// //如果有接受申报或装载放行 则删除WLXX_MBLNO_DELAY当中的该提单号数据
// if (portstatus.临时读取完成())
// {
// DelDelayMblno(connStr, id);
// }
// else
// {
// DelayMblno(connStr, id);
// }
// DelMinMblno(connStr);
// }
// }
// }
// catch (Exception e)
// {
// log.Debug($"saveerror1: {e.Message}");
// }
// }
// catch (Exception ex)
// {
// log.Debug($"saveerror2: {ex.Message}");
// }
// }
// catch (Exception ex)
// {
// log.Debug($"catch: {ex.Message}");
// log.Error(ex.Message);
// log.Error(ex.StackTrace);
// }
// }
// public static void DelMinMblno(string connStr)
// {
// var _r = DoWork.ExecSql(connStr, " delete from wlxx_mblno where id =(select min(id) from wlxx_mblno ) ");
// }
// public static void DelayMblno(string connStr,string id)
// {
// var _r = DoWork.ExecSql(connStr, " update WLXX_MBLNO_DELAY set READTIME=dateadd(minute,2,getdate()) where id= "+id);
// }
// public static void DelDelayMblno(string connStr, string id)
// {
// var _r0 = DoWork.ExecSql(connStr, " update OP_SEAE_EDI_FENDANSEND set CANSEND=1 where mblno=(select mblno from WLXX_MBLNO_DELAY where id= " + id+")");
// var _r = DoWork.ExecSql(connStr, " delete from WLXX_MBLNO_DELAY where id= " + id);
// }
//}
public class JobWLXXSave_D6 : IJob
{
private ILog log = LogManager . GetLogger ( typeof ( JobWLXXSave_D6 ) ) ;
private string connStr { get ; set ; }
private string TimeType { get ; set ; }
private Int32 StartDays { get ; set ; }
private Int32 EndDays { get ; set ; }
//private Int32 ChaXunJianGe { get; set; }
public void Execute ( IJobExecutionContext context )
{
log . Debug ( $"Execute开始" ) ;
try
{
connStr = context . JobDetail . JobDataMap . GetString ( "ConnectString" ) ;
StartDays = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "StartDays" ) ) ;
EndDays = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "EndDays" ) ) ;
TimeType = context . JobDetail . JobDataMap . GetString ( "TimeType" ) ;
log . Debug ( $"连接字符串:{connStr}" ) ;
log . Debug ( $"起始天数:{StartDays}" ) ;
log . Debug ( $"终止天数:{EndDays}" ) ;
log . Debug ( $"时间类型:{TimeType}" ) ;
var queryfield = "录入日期" ;
if ( TimeType = = "录入日期" )
{
queryfield = " 录入日期 " ;
}
//if (TimeType == "发送日期")
//{
// queryfield = " SENDTIME ";
//}
if ( TimeType = = "开船日期" )
{
queryfield = " 开船日期 " ;
}
var startdate = DateTime . Now . AddDays ( - StartDays ) . ToString ( "yyyy-MM-dd" ) ;
var enddate = DateTime . Now . AddDays ( - EndDays + 1 ) . ToString ( "yyyy-MM-dd" ) ;
/ * select s . *
from (
select * , row_number ( ) over ( partition by [ 手 机 号 ] order by [ 店 铺 ] ) as group_idx
from table_name
) s
where s . group_idx = 1 * /
var sqlQuery = " select 编号 MFNO,case when isnull(分提单号,'')<>'' then 分提单号 else 主提单号 end MBLNO,case when isnull(分提单号,'')<>'' then 0 else 1 end ISMAIN from t_op_seae_edi " ;
sqlQuery + = string . Format ( " where isnull(分提单号,'')='' and EDI类型='CN' and {0}>='{1}' and {2}<'{3}' and isnull(申报状态,'')='' order by 录入日期 desc" , queryfield , startdate , queryfield , enddate ) ;
//sqlQuery += " and not exists (select 1 from op_seae_edi_status where mfno=op_seae_edi.mfno and statustext= '装载放行' ) and dbo.getblno(mfno) not in(select mblno from wlxx_mblno) order by " + queryfield;
var MBLNOList = DoWork . GetMBLNOList_D6 ( connStr , sqlQuery ) ;
if ( MBLNOList . Count = = 0 )
{
log . Debug ( "没有要发送的数据!" ) ;
return ;
}
//然后将所有提单号存入数据库
var SaveSql = Local_Mblnomb . getSaveSql_D6 ( MBLNOList ) ;
using ( SqlConnection dbcon = new SqlConnection ( connStr ) )
{
dbcon . Open ( ) ;
using ( SqlTransaction trans = dbcon . BeginTransaction ( ) )
{
//增加判断 如果
foreach ( string Sqlitem in SaveSql )
{
if ( ! string . IsNullOrWhiteSpace ( Sqlitem ) )
{
//log.Debug($"TaskSqlitem: {TaskSqlitem}");
SqlCommand cmd = new SqlCommand ( Sqlitem , dbcon , trans ) ;
cmd . ExecuteNonQuery ( ) ;
}
}
trans . Commit ( ) ;
}
dbcon . Close ( ) ;
}
}
catch ( Exception ex )
{
log . Error ( ex . Message ) ;
log . Error ( ex . StackTrace ) ;
}
}
private void DoSendMessage ( string mblno )
{
}
}
public class JobWLXXGet_D6 : IJob
{
private ILog log = LogManager . GetLogger ( typeof ( JobWLXXGet_D6 ) ) ;
private string connStr { get ; set ; }
private string reqUrl { get ; set ; }
private Int32 reqTimeout { get ; set ; }
public void Execute ( IJobExecutionContext context )
{
try
{
connStr = context . JobDetail . JobDataMap . GetString ( "ConnectString" ) ;
reqUrl = context . JobDetail . JobDataMap . GetString ( "ReqUrl" ) ;
reqTimeout = Convert . ToInt32 ( context . JobDetail . JobDataMap . GetString ( "RequestTimeout" ) ) ;
log . Debug ( $"连接字符串:{connStr}" ) ;
log . Debug ( $"请求URL: {reqUrl}" ) ;
log . Debug ( $"请求超时:{reqTimeout}" ) ;
EdiStatusDAL . connstr = connStr ;
//查找wlxx_mblno 当中最早的数据
var getsqlstr = "select * from wlxx_mblno where id = (select min(id) from wlxx_mblno)" ;
var MBLNOList = DoWork . GetMBLNOList_D6 ( connStr , getsqlstr ) ;
if ( MBLNOList . Count = = 0 )
{
log . Debug ( "没有要查询的数据!" ) ;
return ;
}
var MBLNO = MBLNOList [ 0 ] . MBLNO ;
var MFNO = MBLNOList [ 0 ] . MFNO ;
var ISMAIN = MBLNOList [ 0 ] . ISMAIN ;
//访问url获取爬取的数据
JObject reqObj = new JObject ( ) ;
reqObj . Add ( "user_key" , "QDDJY" ) ;
reqObj . Add ( "user_secret" , "YGH2020" ) ;
//下方此处无关权限 只用于区分调用来源
reqObj . Add ( "customer_id" , "DY_DingShiWuLiuXinXi" ) ;
reqObj . Add ( "customer_name" , "大简云定时读取物流信息" ) ;
reqObj . Add ( "web_code" , "HLW_CD" ) ;
reqObj . Add ( "bno" , new JValue ( MBLNO ) ) ;
reqObj . Add ( "vessel_name" , "" ) ;
reqObj . Add ( "voyage_no" , "" ) ;
reqObj . Add ( "wharf_name" , "" ) ;
reqObj . Add ( "req_type" , "0" ) ;
reqObj . Add ( "web_user" , "" ) ;
reqObj . Add ( "web_psw" , "" ) ;
reqObj . Add ( "wltype" , "WLXX" ) ;
string mailAddr = "" ;
string rtn = "" ;
List < WLXXModel > mList ;
RepWLXXModel mWLXX ;
try
{
log . Debug ( $"请求数据:{reqObj}" ) ;
rtn = WebRequestHelper . DoPost ( reqUrl , reqObj . ToString ( Newtonsoft . Json . Formatting . None ) , reqTimeout * 1000 ) ;
log . Debug ( $"返回数据:{rtn}" ) ;
try
{
var PortResult = Newtonsoft . Json . JsonConvert . DeserializeObject < RepWLXXModel > ( rtn ) ;
if ( PortResult . code = = 200 )
{
//if (rtn.Contains("单号信息不存在"))
//{
// DelMinMblno(connStr);
//}
//else
//if (rtn.Contains("验证码") || rtn.Contains("无可用账号") || rtn.Contains("当前单号无信息"))
//{
// log.Debug($"没有查询到{MBLNO}的信息");
//}
//else
//{
var portstatus = PortResult . data [ 0 ] ;
edistatusMb newStatusRecord = new edistatusMb ( ) ;
//var laststatus = portstatus.getlaststatus();
var Localstatuslist = EdiStatusDAL_D6 . GetDataList ( connStr , " 编号='" + MFNO + "' " ) ;
if ( Localstatuslist . Count > 0 )
{
var localrecord = Localstatuslist [ 0 ] ;
//如果数据里的这条信息状态与返回状态不同
if ( localrecord . GetValue ( "申报状态" ) ! = portstatus . getlaststatus_str_D6 ( ISMAIN ) )
{
EdiStatusDAL_D6 . Update ( portstatus , localrecord . GetValue ( "编号" ) , ISMAIN ) ;
}
}
DelMinMblno ( connStr ) ;
}
else
{
if ( PortResult . msg . Contains ( "单号信息不存在" ) )
{
//DelMinMblno(connStr);
}
log . Debug ( $"【{MBLNO}】code={PortResult.code}:" + PortResult . msg ) ;
DelMinMblno ( connStr ) ;
}
}
catch ( Exception e )
{
log . Debug ( $"saveerror1: {e.Message}" ) ;
}
}
catch ( Exception ex )
{
log . Debug ( $"saveerror2: {ex.Message}" ) ;
}
}
catch ( Exception ex )
{
log . Debug ( $"catch: {ex.Message}" ) ;
log . Error ( ex . Message ) ;
log . Error ( ex . StackTrace ) ;
}
}
public static void DelMinMblno ( string connStr )
{
var _r = DoWork . ExecSql ( connStr , " delete from wlxx_mblno where id =(select min(id) from wlxx_mblno ) " ) ;
}
}
}