|
|
|
|
using FluentScheduler;
|
|
|
|
|
using log4net;
|
|
|
|
|
using POSV.WindowsService.Core.OrderPackage;
|
|
|
|
|
using POSV.WindowsService.Core.Utils;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using POSV.Service;
|
|
|
|
|
using POSV.Service.Utils;
|
|
|
|
|
|
|
|
|
|
namespace POSV.WindowsService.Core.Job
|
|
|
|
|
{
|
|
|
|
|
public class Huacai2chupinJob : IJob
|
|
|
|
|
{
|
|
|
|
|
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
private bool isRunning = false;
|
|
|
|
|
|
|
|
|
|
public void Execute()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (isRunning)
|
|
|
|
|
{
|
|
|
|
|
logger.Debug("执行中,请稍候...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
logger.Debug("执行已划菜待出品数据通知到出品显示器");
|
|
|
|
|
isRunning = true;
|
|
|
|
|
List<string> result = null;
|
|
|
|
|
using (var db = Global.Instance.OpenDataBase)
|
|
|
|
|
{
|
|
|
|
|
var sql = @"select distinct p.[serviceId] from [pos_order_item] p
|
|
|
|
|
where p.[huacai2chupinStatus] = 0
|
|
|
|
|
and p.[huacaiTime] is not null
|
|
|
|
|
and p.[huacaiTime] < '{0}'
|
|
|
|
|
and p.[chupinDevice] is not null
|
|
|
|
|
and p.[chupinDevice] != 'None'
|
|
|
|
|
order by p.[huacaiTime], p.[huacai2chupinNum];";
|
|
|
|
|
result = db.Fetch<string>(string.Format(sql, DateTime.Now.AddMinutes(-1).ToString("yyyy-MM-dd HH:mm:ss")));
|
|
|
|
|
}
|
|
|
|
|
if (result != null)
|
|
|
|
|
{
|
|
|
|
|
//更新发送次数
|
|
|
|
|
lock (Global.Instance.SyncLock)
|
|
|
|
|
{
|
|
|
|
|
foreach (var id in result)
|
|
|
|
|
{
|
|
|
|
|
SQLiteUtils.Execute("update pos_order_item set huacai2chupinNum = huacai2chupinNum + 1 where id = '" + id + "' and huacai2chupinStatus = 0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (var id in result)
|
|
|
|
|
{
|
|
|
|
|
OrderPackage.OrderUtils.SendHuacaiOrder2Chupin(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logger.Error(ex, "通知出品数据异常");
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
isRunning = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|