/// <summary> /// 给PLC的统计信息 /// </summary> /// <returns></returns> public async Task <TotalInfo> GetLocsInfoAsync() { TotalInfo info = new TotalInfo(); Log log = LogFactory.GetLogger("GetLocsInfoAsync"); try { CWICCard cwiccd = new CWICCard(); List <Location> locLst = await new CWLocation().FindLocationListAsync(); List <Customer> custsLst = await cwiccd.FindCustListAsync(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP); int total = 0; int temp = 0; for (int i = 0; i < locLst.Count; i++) { Location loc = locLst[i]; if (loc.Type == EnmLocationType.Normal) { if (loc.Status == EnmLocationStatus.Space) { total++; if (!custsLst.Exists(cc => cc.Warehouse == loc.Warehouse && cc.LocAddress == loc.Address)) { temp++; } } } } info.Total = total; info.Temp = temp; } catch (Exception ex) { log.Error(ex.ToString()); info.Total = 99; info.Temp = 99; } return(info); }
public async Task <LocStatInfo> GetLocStatisInfoAsync() { int total = 0; int occupy = 0; int space = 0; int fix = 0; int bspace = 0; int sspace = 0; try { CWICCard cwiccd = new CWICCard(); List <Location> locLst = await new CWLocation().FindLocationListAsync(); List <Customer> custsLst = await cwiccd.FindCustListAsync(cu => cu.Type == EnmICCardType.FixedLocation || cu.Type == EnmICCardType.VIP); for (int i = 0; i < locLst.Count; i++) { Location loc = locLst[i]; #region if (loc.Type != EnmLocationType.Hall && loc.Type != EnmLocationType.Invalid) { total++; } bool isFixLoc = false; if (custsLst.Exists(cc => cc.LocAddress == loc.Address && cc.Warehouse == loc.Warehouse)) { fix++; isFixLoc = true; } if (loc.Type == EnmLocationType.Normal) { if (loc.Status == EnmLocationStatus.Space) { if (!isFixLoc) { space++; if (loc.LocSize.Length == 3) { string last = loc.LocSize.Substring(2); if (last == "1") { sspace++; } else if (last == "2") { bspace++; } } } } else if (loc.Status == EnmLocationStatus.Occupy) { occupy++; } } #endregion } } catch (Exception ex) { Log log = LogFactory.GetLogger("GetLocStatisInfoAsync"); log.Error(ex.ToString()); } LocStatInfo info = new LocStatInfo(); info.Total = total; info.Occupy = occupy; info.Space = space; info.SmallSpace = sspace; info.BigSpace = bspace; info.FixLoc = fix; return(info); }