public async Task UpdateBatchAsync(Ps_Batch data) { using (var db = DBContext.Client(ConnectionString)) { await db.Updateable(data).IgnoreColumns("PicFront", "PicBehind").ExecuteCommandAsync(); } }
public async Task InsertBatchAsync(Ps_Batch data) { using (var db = DBContext.Client(ConnectionString)) { await db.Insertable(data).ExecuteCommandAsync(); } }
public BatchHelper(ICollectorStore store) { _store = store; if (LineBatch != null) { LineBatch.Clear(); } else { LineBatch = new ConcurrentDictionary <string, Ps_Batch>(); } var batch = new Ps_Batch(); batch.Status = 1; LineBatch.TryAdd(line1_key, batch); batch = new Ps_Batch(); batch.Status = 1; LineBatch.TryAdd(line2_key, batch); batch = new Ps_Batch(); batch.Status = 1; LineBatch.TryAdd(line4_key, batch); batch = new Ps_Batch(); batch.Status = 1; LineBatch.TryAdd(line5_key, batch); }
public LineManager() { ZCZT = false; Item = new Ps_Batch(); }
/// <summary> /// /// </summary> /// <param name="readData">读取数据</param> /// <param name="dtNow">当前时间</param> /// <param name="line_zt">装车状态</param> /// <param name="line_chp">车牌号</param> /// <param name="line_sdzcbs">设定装车包数</param> /// <param name="line_skzl">刷卡重量</param> /// <param name="line_dxsz">垛型设置</param> /// <param name="line_jhzqcs">计划抓取次数</param> /// <param name="line_sjzqbs">实际抓取包数</param> /// <param name="line_id">产线编号</param> /// <returns></returns> private async Task SaveLineBatchData(Dictionary <string, object> readData , DateTime dtNow , string line_key , string line_zt , string line_chp , string line_sdzcbs , string line_skzl , string line_dxsz , string line_jhzqcs , string line_sjzqbs , string truck_width , string truck_heigth , string truck_long , int line_id) { if (LineBatch[line_key].Status == 0) {//当前正在装车中 if (Convert.ToInt32(readData[line_sjzqbs]) > 0) { LineBatch[line_key].RealPackages = Convert.ToInt32(readData[line_sjzqbs]); } if (Convert.ToInt32(readData[line_jhzqcs]) > 0) { LineBatch[line_key].SnatchCount = Convert.ToInt32(readData[line_jhzqcs]); } if (LineBatch[line_key].LoadingWeight == 0) { LineBatch[line_key].LoadingWeight = Convert.ToDecimal(readData[line_skzl]); } if (LineBatch[line_key].PlanPackages == 0) { LineBatch[line_key].PlanPackages = Convert.ToInt32(readData[line_sdzcbs]); } if (LineBatch[line_key].TruckSizeWidth == 0) { LineBatch[line_key].TruckSizeWidth = Convert.ToInt32(readData[truck_width]); } if (LineBatch[line_key].TruckSizeHeight == 0) { LineBatch[line_key].TruckSizeHeight = Convert.ToInt32(readData[truck_heigth]); } if (LineBatch[line_key].TruckSizeLong == 0) { LineBatch[line_key].TruckSizeLong = Convert.ToInt32(readData[truck_long]); } if (LineBatch[line_key].StackType == 0) { LineBatch[line_key].StackType = Convert.ToInt32(readData[line_dxsz]); } if (Convert.ToBoolean(readData[line_zt]) == false) {//结束装车 LineBatch[line_key].Status = 1; LineBatch[line_key].RealPackages = LineBatch[line_key].PlanPackages; LineBatch[line_key].EndTime = dtNow; await _store.UpdateBatchAsync(LineBatch[line_key]); } } else {//当前车道装车完毕 var cph = readData[line_chp].ToString(); if (Convert.ToBoolean(readData[line_zt]) == true && !string.IsNullOrWhiteSpace(cph)) { if (cph == LineBatch[line_key].TruckLicense && LineBatch[line_key].Status == 1 && LineBatch[line_key].StartTime >= DateTime.Now.AddMinutes(-30)) {//继续装车 LineBatch[line_key].Status = 0; await _store.UpdateBatchAsync(LineBatch[line_key]); } else {//开始装车 LineBatch[line_key] = null; LineBatch[line_key] = new Ps_Batch(); LineBatch[line_key].Id = Convert.ToInt64(System.DateTime.Now.ToString("yyMMddHHmmssfff") + new Random().Next(0, 9999).ToString()); LineBatch[line_key].ProduceDate = Convert.ToInt32(dtNow.ToString("yyyyMMdd")); LineBatch[line_key].LineId = line_id; LineBatch[line_key].StartTime = dtNow; LineBatch[line_key].Status = 0; LineBatch[line_key].TruckLicense = cph; LineBatch[line_key].PlanPackages = Convert.ToInt32(readData[line_sdzcbs]); LineBatch[line_key].LoadingWeight = Convert.ToDecimal(readData[line_skzl]); LineBatch[line_key].StackType = Convert.ToInt32(readData[line_dxsz]); LineBatch[line_key].SnatchCount = Convert.ToInt32(readData[line_jhzqcs]); LineBatch[line_key].TruckSizeWidth = Convert.ToInt32(readData[truck_width]); LineBatch[line_key].TruckSizeHeight = Convert.ToInt32(readData[truck_heigth]); LineBatch[line_key].TruckSizeLong = Convert.ToInt32(readData[truck_long]); } await _store.InsertBatchAsync(LineBatch[line_key]); } } }