//获取排队等候人数ByUnit public object GetWaitInfoByUnit(Dictionary <string, object> json) { WriterReceiveLog("GetWaitInfoByUnit", script.Serialize(json)); var unitSeq = json["unitSeq"].ToString(); var list = new BQueueBLL().GetModelList(unitSeq, 0); return(new { method = "GetWaitInfoByUnit", code = 1, desc = "处理成功", result = list.Select(s => new { unitSeq = unitSeq, waitCount = list.Count, }) }); }
//获取排队等候人数 按部门业务分组 public object GetWaitInfoAll() { var list = new BQueueBLL().GetModelList(c => c.ticketTime.Date == DateTime.Now.Date && c.state == 0); var glist = list.GroupBy(g => g.unitSeq).ToList(); var grlist = list.GroupBy(g => new { g.unitSeq, g.busTypeSeq }).ToList(); return(new { method = "GetWaitInfoAll", code = 1, desc = "处理成功", result = glist.Select(s => new { unitSeq = s.Key, waitCount = s.Count(), unitBusi = grlist.Where(g => g.Key.unitSeq == s.Key).Select(k => new { unitSeq = k.Key.unitSeq, busiSeq = k.Key.busTypeSeq, waitCount = k.Count() }).ToList() }).ToList() }); }
//获取当前排队信息 private object GetQueueById(int Id) { var qBll = new BQueueBLL(); object obj = new object(); var model = qBll.GetModel(Id); if (model == null) { return(new { method = "GetQueueInfo", code = 0, desc = "无此编号的排队数据", result = new { } }); } var areaWindowStr = GetAreaWindowsStr(model.unitSeq, model.busTypeSeq); var isGreen = GetVipLever(model); var list = qBll.GetModelList(model.busTypeSeq, model.unitSeq, 0).Where(q => q.ID < model.ID).ToList(); int waitNo = list.Count;//计算等候人数 if (model.state == 1) { //已叫号/已处理 var call = new BCallBLL().GetModel(f => f.qId == Id && f.state != 2); if (call == null) { return(new { method = "GetQueueInfo", code = 0, desc = "无此编号的叫号数据", result = new { } }); } else { var currentState = call.ticketTime.Date != DateTime.Now.Date ? "已过期" : (call.state == -1 || call.state == 1) ? "已完成" : "已叫号"; obj = new { method = "GetQueueInfo", code = 1, desc = "处理成功", result = new { id = model.ID, area = areaWindowStr[0], windowStr = areaWindowStr[1], currentState = currentState, windowNo = "", waitCount = waitNo, unitSeq = model.unitSeq, unitName = model.unitName, busySeq = model.busTypeSeq, busyName = model.busTypeName, ticketNumber = model.ticketNumber, ticketTime = model.ticketTime.ToString("yyyy-MM-dd HH:mm:ss"), reserveSeq = model.reserveSeq, cardId = model.idCard, vip = isGreen, wxId = model.wxId } }; } } else { //排队中 obj = new { method = "GetQueueInfo", code = 1, desc = "处理成功", result = new { id = model.ID, area = areaWindowStr[0], windowStr = areaWindowStr[1], currentState = "排队中", windowNo = "", waitCount = waitNo, unitSeq = model.unitSeq, unitName = model.unitName, busySeq = model.busTypeSeq, busyName = model.busTypeName, ticketNumber = model.ticketNumber, ticketTime = model.ticketTime.ToString("yyyy-MM-dd HH:mm:ss"), reserveSeq = model.reserveSeq, cardId = model.idCard, vip = isGreen, wxId = model.wxId } }; } return(obj); }
//进行排队 private object OutQueueNo(string unitSeq, string unitName, string busiSeq, string busiName, string personName, string idCard, string wxId) { #region 验证业务扩展属性 var qBll = new BQueueBLL(); var ticketStart = ""; var att = baList.Where(b => b.unitSeq == unitSeq && b.busiSeq == busiSeq).FirstOrDefault(); var list = qBll.GetModelList(busiSeq, unitSeq, 0); int waitNo = list.Count;//计算等候人数 if (att != null) { ticketStart = att.ticketPrefix; } else { return(new { method = "ProcessQueue", code = 0, desc = "当前部门以及业务类型未获取到扩展属性,无法排队", idcard = idCard, result = new { } }); } #endregion #region 排队 var queue = qBll.QueueLine(unitSeq, unitName, busiSeq, busiName, ticketStart, idCard, personName, wxId); #endregion #region 日志相关 string strLog = string.Format("已出票:部门[{0}],业务[{1}],票号[{2}],预约号[{3}],身份证号[{4}],姓名[{5}],时间[{6}]。", queue.unitName, queue.busTypeName, queue.ticketNumber, queue.reserveSeq, idCard, personName, DateTime.Now); WriterQueueLog(strLog); new TOprateLogBLL().Insert(new TOprateLogModel() { oprateFlag = wxId, oprateType = "微信端排队", oprateClassifyType = "出票", oprateTime = DateTime.Now, oprateLog = strLog }); #endregion #region 返回数据组织 var areaWindowStr = GetAreaWindowsStr(unitSeq, busiSeq); var isGreen = GetVipLever(queue); object obj = new { method = "ProcessQueue", code = 1, desc = "处理成功", idcard = idCard, result = new { id = queue.ID, area = areaWindowStr[0], windowStr = areaWindowStr[1], waitCount = waitNo, unitSeq = queue.unitSeq, unitName = queue.unitName, busySeq = queue.busTypeSeq, busyName = queue.busTypeName, ticketNumber = queue.ticketNumber, ticketTime = queue.ticketTime.ToString("yyyy-MM-dd HH:mm:ss"), cardId = queue.idCard, reserveSeq = queue.reserveSeq, vip = isGreen, } }; return(obj); #endregion }
//1.身份证验证 //2.取号时间段验证 //3.取号数量验证 ArrayList CheckLimit(string methodName, string idCard, string unitSeq, string busiSeq) { var qBll = new BQueueBLL(); ArrayList arry = new ArrayList(); arry.Add(true); //验证同一个身份证不能在一个部门一个业务排队2次(未处理的) var isCan = qBll.IsCanQueueO(idCard, busiSeq, unitSeq); if (Convert.ToBoolean(isCan[0]) == false) { var err = new { method = methodName, code = 0, desc = "此身份证同类业务未办理,请办理完成后再次取号", idcard = idCard, result = new { } }; arry.Clear(); arry.Add(false); arry.Add(err); return(arry); } ArrayList arr = GetLimitBySeq(unitSeq, busiSeq); if (arr == null) { var err = new { method = methodName, code = 0, desc = "该业务类型当前时间段不能取号或未配置取号限制条件", idcard = idCard, result = new { } }; arry.Clear(); arry.Add(false); arry.Add(err); return(arry); } int max = Convert.ToInt32(arr[0]); DateTime start = Convert.ToDateTime(arr[1]); DateTime end = Convert.ToDateTime(arr[2]); var mList = qBll.GetModelList(busiSeq, unitSeq, start, end); if (max <= mList.Count) { var err = new { method = methodName, code = 0, desc = "该业务类型当前时间段排队数量已达上限", idcard = idCard, result = new { } }; arry.Clear(); arry.Add(false); arry.Add(err); return(arry); } return(arry); }
//推送提醒 public object PushNotify(string Id) { var qBll = new BQueueBLL(); var oId = Convert.ToInt32(Id); object obj = new object(); var model = qBll.GetModel(oId); if (model == null) { return(new { method = "PushNotify", code = 0, desc = "无此编号的排队数据,排队已失效,请核查", result = new { } }); } else { if (model.state == 0) { return(new { method = "PushNotify", code = 0, desc = "该排队数据已失效,请核查", result = new { } }); } } var list = qBll.GetModelList(model.busTypeSeq, model.unitSeq, 0); var cModel = new BCallBLL().GetModel(f => f.qId == oId && f.state != 2); var areaWindowStr = GetAreaWindowsStr(model.unitSeq, model.busTypeSeq); var waitNo = 1; //返回该条数据以及三条待叫号数据 var objresult = new { method = "PushNotify", code = 1, desc = "处理成功", result = new { currentQueue = new { state = "已叫号", id = model.ID, ticketNumber = model.ticketNumber, windowName = cModel.windowNumber, unitSeq = model.unitSeq, unitName = model.unitName, busySeq = model.busTypeSeq, busyName = model.busTypeName, reserveSeq = model.reserveSeq, area = areaWindowStr[0], windowStr = areaWindowStr[1], cardId = model.idCard, vip = GetVipLever(model), wxId = model.wxId, }, waitQueue = list.OrderBy(o => o.ID).Take(3).Select(s => new { id = s.ID, area = areaWindowStr[0], windowStr = areaWindowStr[1], currentState = "排队中", windowNo = "", waitCount = waitNo++, unitSeq = s.unitSeq, unitName = s.unitName, busySeq = s.busTypeSeq, busyName = s.busTypeName, ticketNumber = s.ticketNumber, ticketTime = s.ticketTime.ToString("yyyy-MM-dd HH:mm:ss"), reserveSeq = s.reserveSeq, cardId = s.idCard, vip = GetVipLever(s), wxId = s.wxId }).ToList() } }; return(objresult); }