You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
3.1 KiB
C#
80 lines
3.1 KiB
C#
using DSWeb.Common.DB;
|
|
using DSWeb.Common.Helper;
|
|
using DSWeb.Common.Model;
|
|
using log4net;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using Quartz;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace DSWeb.Job.Common
|
|
{
|
|
/*
|
|
规则:实际开船日期后四天,如果签单方式为正本或者电放,还没有正本邮件则产生该任务。
|
|
每天晚上3点开始跑任务。
|
|
*/
|
|
public class TaskOriginalLostJob : IJob
|
|
{
|
|
private CommonDataContext commonData = new CommonDataContext();
|
|
private BookingDB bookingData = new BookingDB();
|
|
private OpTaskDataContext taskData = new OpTaskDataContext();
|
|
private ILog logger = LogManager.GetLogger("TaskOriginalLostJob");
|
|
|
|
public void Execute(IJobExecutionContext context)
|
|
{
|
|
var timeQuery = DateTime.Now.AddDays(-4);
|
|
var taskType = OpTaskType.OriginalLost.ToString();
|
|
var query = from o in taskData.Orders.AsNoTracking()
|
|
join t in taskData.OpTasks.AsNoTracking() on new
|
|
{
|
|
ordno = o.ORDNO,
|
|
taskType
|
|
} equals new
|
|
{
|
|
ordno = t.RelativeId,
|
|
taskType = t.TASKTYPE
|
|
} into tt
|
|
from t in tt.DefaultIfEmpty()
|
|
where o.ATD.HasValue && o.ATD.Value < timeQuery && t == null && (o.ISSUETYPE == "正本" || o.ISSUETYPE == "电放")
|
|
select new { o.ORDNO, o.MBLNO, o.CORPID, o.CompName, o.OP_ID, o.OP, o.ETD };
|
|
var list = query.ToList();
|
|
logger.Debug($"发现没有正本邮件的记录{list.Count}条");
|
|
foreach (var item in list)
|
|
{
|
|
//插入任务
|
|
OpTask task = new OpTask();
|
|
task.GID = Guid.NewGuid().ToString().Replace("-", "");
|
|
task.TASKNO = $"T{DateTime.Now.ToString("yyMMddHHmmssfff")}";
|
|
task.BSNO = "";
|
|
task.TASKTYPE = OpTaskType.OriginalLost.ToString();
|
|
task.TASKSOURCE = OpTaskSource.Website.ToString();
|
|
task.TASKSTATUS = OpTaskStatus.Create.ToString();
|
|
task.TASKTITLE = $"{item.MBLNO}正本提单未挂出,请及时联系船公司处理。";
|
|
task.MBLNO = item.MBLNO;
|
|
task.CreateTime = DateTime.Now;
|
|
|
|
task.ComId = item.CORPID;
|
|
task.COMNAME = item.CompName;
|
|
task.RelativeId = item.ORDNO;
|
|
task.USERID = item.OP_ID;
|
|
task.UserName = item.OP;
|
|
task.ETD = item.ETD; //任务赋值订舱的etd
|
|
|
|
taskData.OpTasks.Add(task);
|
|
logger.Debug($"{item.MBLNO}没有正本邮件,生成任务");
|
|
|
|
}
|
|
|
|
taskData.SaveChanges();
|
|
logger.Debug($"正本邮件检查完成");
|
|
|
|
}
|
|
}
|
|
}
|