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 */ if (FormCC.stationView == null) { SystemWarningMsg._lbl_alert_DataProcess_269 = $"{rgvLocation.ToString()}-获取PLC对象为null"; continue; } 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) { //推送plc 人工放行 using (StationServiceClient client = new StationServiceClient()) { var res = await client.WriteStation_PersonAllowAsync((int)EDevice.Station, false, rgvLocation); if (!res.result) { SystemWarningMsg._lbl_alert_DataProcess_269 = $"{rgvLocation.ToString()}- 推送plc 人工放行 失败,WriteStation_PersonAllowAsync 返回:{res.resMsg}"; continue; } else { Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-推送plc 人工放行 成功,WriteStation_PersonAllowAsync,参数: 站点{rgvLocation}"); } } //写入报警信息 await MyExtendHelper.WriteBoolPlcDataForWarning(PlcWarningGloble.Num_269_1); SystemWarningMsg._lbl_alert_DataProcess_269 = $"{rgvLocation.ToString()},根据UPI:{upiCode}没有找到对象 "; continue; //*/ } //推送plc解析完成 using (StationServiceClient client = new StationServiceClient()) { var res = await client.WriteQiTaoInfoAsync((int)EDevice.Station, rgvLocation, true); if (!res.result) { SystemWarningMsg._lbl_alert_DataProcess_269 = $"{rgvLocation.ToString()}- 推送plc解析完成 失败,WriteQiTaoInfoAsync返回:{res.resMsg}"; continue; } else { Log4NetHelper.WriteInfoLog(logType, $"{rgvLocation.ToString()}-推送plc解析完成 成功,WriteQiTaoInfoAsync,参数: 站点{rgvLocation}"); } } upiObj.AreaCode = (int)AreaCodeEnum.待缓存分拣区; //记录板件队列表 var queueData = wmsDB.mes_upi_linequeue.Where(x => x.Upi == upiObj.UPI).FirstOrDefault(); if (queueData != null) { wmsDB.mes_upi_linequeue.Remove(queueData); } mes_upi_linequeue addUpiLineQueue = ClassHelper.RotationMapping(upiObj); addUpiLineQueue.Id = Yitter.IdGenerator.YitIdHelper.NextId(); addUpiLineQueue.Location = "269"; addUpiLineQueue.AreaCode = (int)AreaCodeEnum.待缓存分拣区; addUpiLineQueue.Upi = upiObj.UPI; addUpiLineQueue.UpiFlag = (int)UpiFlagEnum.正常; addUpiLineQueue.UpiStatus = (int)UpiStatusEnum.初始; addUpiLineQueue.CreateTime = DateTime.Now; addUpiLineQueue.CreateUserName = SysGloble.WCSSystem; wmsDB.mes_upi_linequeue.Add(addUpiLineQueue); WmsRecordUpiProcessHandler.SaveWmsRecordUpiProcess(wmsDB, upiObj, "269", "首次扫码"); wmsDB.SaveChanges(); //*/ } } } } catch (Exception ex) { SystemWarningMsg._lbl_alert_DataProcess_269 += " 出现异常:" + ex.Message + SysGloble.SPLIT_STR; Log4NetHelper.WriteErrorLog(logType, " 出现异常:" + ex.Message, ex); } } } } }