using Admin.NET.Application;
using iWareCC.Common.Helper;
using iWareCC.StationService;
using iWareCommon.Common.Globle;
using iWareCommon.Utils;
using iWareModel;
using iWareSql.DBModel;
using iWareSql.WmsDBModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using XiGang.Core.Model;
namespace iWareCC.ThreadService
{
///
/// 269工位
///
public static class DataProcess_269
{
///
/// 269工位
///
public static async void Handler()
{
var alertMsg = "";
LogType logType = LogType.DataProcess_269;
while (true)
{
Thread.Sleep(1000);//休眠2秒,将休眠写到前面,是为了下面的continue方法执行后不显示错误信息的提示!!!【EditBy shaocx,2022-05-24】
SystemWarningMsg._lbl_alert_DataProcess_269 = string.Empty;
try
{
//if (SystemValue.isAllowRuning_DataProcess_269 && SystemValue.isStartedModel)
if (SystemValue.isStartedModel)
{
var rgvLocation = StationLocationEnum.首次扫码工位.ToString();
/*
* 1、从数据库中判断是否齐套
* 2、根据齐套结果,推送给PLC
*/
var obj = FormCC.stationView.R_StationForReadCommList.Where(x => x.StationCode == rgvLocation.ToString()).FirstOrDefault();
if (obj.R_ReqParseData)
{
var result = obj.R_ReadCodeResult;
if (string.IsNullOrEmpty(result))
{
SystemWarningMsg._lbl_alert_DataProcess_269 = $"{rgvLocation.ToString()}-请求了解码,但是结果是空的,此次循环结束";
continue;
}
var upiCode = result;
using (WmsDBModel wmsDB = new WmsDBModel())
{
var upiObj = wmsDB.mes_batchOrderUPI_new.Where(x => x.UPI == upiCode).FirstOrDefault();
if (upiObj == null)
{
SystemWarningMsg._lbl_alert_DataProcess_269 = $"{rgvLocation.ToString()},根据UPI:{upiCode}没有找到对象 ";
continue;
}
upiObj.AreaCode = (int)AreaCodeEnum.待缓存分拣区;
wmsDB.SaveChanges();
}
}
}
}
catch (Exception ex)
{
SystemWarningMsg._lbl_alert_DataProcess_269 += " 出现异常:" + ex.Message + SysGloble.SPLIT_STR;
Log4NetHelper.WriteErrorLog(logType, " 出现异常:" + ex.Message, ex);
}
}
}
}
}