|
|
|
|
using DSWeb.Common.DbContexts;
|
|
|
|
|
using DSWeb.Common.DbContexts.Model;
|
|
|
|
|
using DSWeb.Common.Helper;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Quartz;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
|
|
|
|
namespace DSWeb.Job.ReceiptOfLCL
|
|
|
|
|
{
|
|
|
|
|
public class ReceiptOfLCLJob : IJob
|
|
|
|
|
{
|
|
|
|
|
private ILog logger = LogManager.GetLogger("ReceiptOfLCLJob");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
|
|
|
{
|
|
|
|
|
logger.Debug("运行测试");
|
|
|
|
|
UpdSendState();
|
|
|
|
|
}
|
|
|
|
|
public void UpdSendState()
|
|
|
|
|
{
|
|
|
|
|
OpSeaePxDbContenxt context = new OpSeaePxDbContenxt();
|
|
|
|
|
var yytoday =DateTime.Now.AddDays(-5);
|
|
|
|
|
var lis = context.OpSeaePx.Where(p => p.ShenBaoZhuangTai == "发送成功" &&( p.ReceiptState != "已审批通过" || p.ReceiptState==null) && p.SendTim > yytoday).ToList();
|
|
|
|
|
var user_key = context.SysParamSet.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "pPinXiangSpiderUserId");
|
|
|
|
|
var user_secret = context.SysParamSet.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "pPinXiangSpiderUserSecret");
|
|
|
|
|
var url = context.SysParamSet.AsNoTracking().FirstOrDefault(p => p.PARAMNAME == "pPxSendSpiderStatusUrl");
|
|
|
|
|
logger.Debug("本次执行调度条数"+lis.Count());
|
|
|
|
|
foreach (var item in lis)
|
|
|
|
|
{
|
|
|
|
|
var jobjSend = new JObject();
|
|
|
|
|
jobjSend.Add("user_key", user_key.PARAMVALUE);
|
|
|
|
|
jobjSend.Add("user_secret", user_secret.PARAMVALUE);
|
|
|
|
|
jobjSend.Add("bno", item.MBLNO);
|
|
|
|
|
var strJson = JsonConvert.SerializeObject(jobjSend);
|
|
|
|
|
logger.Debug("发送调度json" + strJson);
|
|
|
|
|
var data = WebRequestHelper.DoPost(url.PARAMVALUE, strJson, timeout: 180000);
|
|
|
|
|
logger.Debug("返回结果" + JsonConvert.SerializeObject(data));
|
|
|
|
|
JObject jobjRtn = JObject.Parse(data);
|
|
|
|
|
var oplist= context.OpSeaePxTips.Where(p => p.PXID == item.Gid).ToList();
|
|
|
|
|
if (jobjRtn != null)
|
|
|
|
|
{
|
|
|
|
|
if (jobjRtn["code"].ToString() == "200")
|
|
|
|
|
{
|
|
|
|
|
logger.Debug(item.MBLNO+"调取成功");
|
|
|
|
|
logger.Debug("depot_status" + jobjRtn["msg"]["depot_status"].ToString());
|
|
|
|
|
Dictionary<string, DateTime> dic1 = new Dictionary<string, DateTime>();
|
|
|
|
|
var depot_status = jobjRtn["msg"]["depot_status"].ToString();
|
|
|
|
|
var depot_time= jobjRtn["msg"]["depot_time"].ToString();
|
|
|
|
|
if (!string.IsNullOrEmpty(depot_time)) {
|
|
|
|
|
dic1.Add(depot_status,Convert.ToDateTime(depot_time));
|
|
|
|
|
}
|
|
|
|
|
var order_status = jobjRtn["msg"]["order_status"].ToString();
|
|
|
|
|
var order_time = jobjRtn["msg"]["order_time"].ToString();
|
|
|
|
|
if (!string.IsNullOrEmpty(order_time))
|
|
|
|
|
{
|
|
|
|
|
dic1.Add(order_status, Convert.ToDateTime(order_time));
|
|
|
|
|
}
|
|
|
|
|
var release_status = jobjRtn["msg"]["release_status"].ToString();
|
|
|
|
|
var release_time = jobjRtn["msg"]["release_time"].ToString();
|
|
|
|
|
if (!string.IsNullOrEmpty(release_time))
|
|
|
|
|
{
|
|
|
|
|
dic1.Add(release_status, Convert.ToDateTime(release_time));
|
|
|
|
|
}
|
|
|
|
|
var shipto_status = jobjRtn["msg"]["shipto_status"].ToString();
|
|
|
|
|
var shipto_time = jobjRtn["msg"]["shipto_time"].ToString();
|
|
|
|
|
if (!string.IsNullOrEmpty(shipto_time))
|
|
|
|
|
{
|
|
|
|
|
dic1.Add(shipto_status, Convert.ToDateTime(shipto_time));
|
|
|
|
|
}
|
|
|
|
|
var sluice_status = jobjRtn["msg"]["sluice_status"].ToString();
|
|
|
|
|
var sluice_time = jobjRtn["msg"]["sluice_time"].ToString();
|
|
|
|
|
if (!string.IsNullOrEmpty(sluice_time))
|
|
|
|
|
{
|
|
|
|
|
dic1.Add(sluice_status, Convert.ToDateTime(sluice_time));
|
|
|
|
|
}
|
|
|
|
|
var dic= dic1.OrderBy(x => x.Value).ToList();
|
|
|
|
|
foreach (var itc in dic)
|
|
|
|
|
{
|
|
|
|
|
if (oplist.Where(x=>x.PXSTATUS==itc.Key).ToList().Count==0)
|
|
|
|
|
{
|
|
|
|
|
OpSeaePxTips tips = new OpSeaePxTips();
|
|
|
|
|
tips.GID = Guid.NewGuid().ToString();
|
|
|
|
|
tips.PXID = item.Gid;
|
|
|
|
|
tips.PXSTATUS = itc.Key;
|
|
|
|
|
tips.@operator = item.LuRuRen;
|
|
|
|
|
tips.optime = DateTime.Now;
|
|
|
|
|
tips.remark = itc.Key;
|
|
|
|
|
context.OpSeaePxTips.Add(tips);
|
|
|
|
|
|
|
|
|
|
item.ReceiptState = itc.Key;
|
|
|
|
|
item.ReceiptTim = itc.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
context.Entry(item).State = System.Data.Entity.EntityState.Modified;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
context.SaveChanges();
|
|
|
|
|
logger.Debug("调度完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|