/// <summary> /// 获取周期内,字段“Item”所有类型,各自的Qulity总数 /// </summary> public List <ItemQuantity> GetItemsQulity(AkRepastModel model) { List <ItemQuantity> ltResult = new List <ItemQuantity>(); string sql = string.Empty; sql += "SELECT bb.ItemNumber ITEM,count(*)QUANTITY "; sql += "from [AlohaReporting].[dbo].[KITCHEN_Order]aa,[AlohaReporting].[dbo].[KITCHEN_Item]bb,[AlohaReporting].[dbo].[KITCHEN_RoutedItem] cc "; sql += "where aa.posid=bb.posorderid and aa.dateofbusiness=bb.dateofbusiness and bb.dateofbusiness=cc.dateofbusiness "; sql += "and convert(varchar(100),aa.dateofbusiness,23) between '" + AkConfig.StartDate + "' and '" + AkConfig.EndDate + "'"; sql += "and CONVERT(varchar(100), aa.TimeStarted, 108) between '" + model.StartTime + "' and '" + model.EndTime + "'"; sql += "and bb.canceled=0 and bb.id=cc.itemid and cc.station in(2,3) "; sql += "group by bb.itemnumber"; //@1.获取周期内字段“ITEM”起始字符为1的所有dbf记录 DataTable dt = SqlServerHelper.Instance.GetDataTable(AkConfig.ConnAlohaReporting, sql); //@2.分组出每个"Item"的 QUANTITY 之和 var result = from t in dt.AsEnumerable() //group t by new { item = t.Field<int>("ITEM") } into m select new ItemQuantity { Item = t.Field <int>("ITEM"), Quantity = (double)t.Field <int>("QUANTITY") }; if (result != null && result.Count() > 0) { ltResult = result.ToList(); } return(ltResult); }
/// <summary> /// 求出单个Item的标准制作时间 /// </summary> /// <returns></returns> private double GetItemStandCooktime(AkRepastModel model) { //@1.获取周期内,字段“Item”所有类型,各自的Qulity总数 List <ItemQuantity> itemQuantitys = AkDaoHelper.Instance_Threshold.GetItemsQulity(model); //@2.求出item的数量总数 double totalQuantitys = AkDaoHelper.Instance_Threshold.GetTotalQulitys(itemQuantitys); //@3.获取每个Item的Cooktime List <ItemCookTime> temCookTimes = AkDaoHelper.Instance_Threshold.GetItemsCookTime(); //@4.求出单个Item的标准制作时间 var query = from quantitys in itemQuantitys join cookTimes in temCookTimes on quantitys.Item equals cookTimes.Item select new ItemStandardCookTime { Item = quantitys.Item, Quantity = quantitys.Quantity, CookTime = cookTimes.CookTime, ItemPercent = quantitys.Quantity / totalQuantitys, ItemStandCooktime = quantitys.Quantity / totalQuantitys * cookTimes.CookTime }; if (query != null && query.Count() > 0) { var lt = query.ToList(); return(query.Sum(s => s.ItemStandCooktime)); } return(0); }
public List <AkServerReportModel> GetDatas(List <int> lt_repast) { //导出的餐段时间 List <AkRepastModel> allRepast = this.GetRepast(lt_repast); List <AkServerReportModel> ltResult = new List <AkServerReportModel>(); string dateNow = DateTime.Now.ToString("yyyy-MM-dd "); foreach (var item in allRepast) { //开始时分 string startTime = item.StartTime.Substring(0, 5); //结束时分 string endTime = string.Empty; int reapeat = this.RepeatNum(item.StartTime, item.EndTime); #region [餐段的每半小时] for (int i = 0; i < reapeat; i++) { string strStartTime = DateTime.Now.ToString("yyyy-MM-dd ") + startTime; endTime = Convert.ToDateTime(strStartTime).AddMinutes(30).ToString("HH:mm"); #region [小时合计] List <AkServerReportModel> lt_resultTotal1 = new List <AkServerReportModel>(); AddRecode(item.RepastName, startTime, endTime, lt_resultTotal1); setTotalServerData(startTime, endTime, lt_resultTotal1[0]); ltResult.AddRange(lt_resultTotal1); #endregion //本次结束时分数,作为下次开始时分数 startTime = endTime; } #endregion #region [餐段合计] List <AkServerReportModel> lt_resultTotal2 = new List <AkServerReportModel>(); AddRecode(item.RepastName, item.StartTime.Substring(0, 5), item.EndTime.Substring(0, 5), lt_resultTotal2, 1); setTotalServerData(item.StartTime.Substring(0, 5), item.EndTime.Substring(0, 5), lt_resultTotal2[0]); ltResult.AddRange(lt_resultTotal2); #endregion } if (allRepast != null && allRepast.Count == 4) { AkRepastModel repastStart = allRepast[0]; AkRepastModel repastEnd = allRepast[allRepast.Count - 1]; #region [全天合计] List <AkServerReportModel> lt_resultTotal3 = new List <AkServerReportModel>(); AddRecode("全天", repastStart.StartTime.Substring(0, 5), repastEnd.EndTime.Substring(0, 5), lt_resultTotal3, 2); setTotalServerData(repastStart.StartTime.Substring(0, 5), repastEnd.EndTime.Substring(0, 5), lt_resultTotal3[0]); ltResult.AddRange(lt_resultTotal3); #endregion } return(ltResult); }
/// <summary> /// 获取餐段开始时间,结束时间 /// <param name="type"></param> /// <returns></returns> public AkRepastModel GetRepastTime(string type) { AkRepastModel model = null; string sql = "select number,shortname, chitname,longname from [CFCInStoreDB].[dbo].[Item] where item.number=" + type; var dt = SqlServerHelper.Instance.GetDataTable(AkConfig.ConnCFCInStoreDB, sql); if (dt != null && dt.Rows.Count > 0) { model = new AkRepastModel(); model.RepastName = dt.Rows[0]["shortname"].ToString(); model.StartTime = dt.Rows[0]["chitname"].ToString() + ":00"; model.EndTime = dt.Rows[0]["longname"].ToString() + ":00"; } return(model); }
/// <summary> /// 计算周期内的阀值 /// </summary> /// <returns></returns> public int CalculateThresholdValue(AkRepastModel model) { double dbValue = 0; int doorValue = 0; try { dbValue = GetItemStandCooktime(model); if (dbValue > 0) { //阀值:四色五入 doorValue = (int)Math.Round(AkConfig.SysParam.PerTime / dbValue, MidpointRounding.AwayFromZero); } } catch (Exception er) { LogHelper.Error(typeof(AkThreshold) + ".CalculateThresholdValue Exception error=", er.ToString()); } return(doorValue); }
/// <summary> /// 获取厂区数据 /// </summary> /// <param name="lt_repast"></param> /// <param name="ltMergeds"></param> /// <returns></returns> public List <AkProduceReportModel> GetDatas(List <int> lt_repast) { //导出的餐段时间 List <AkRepastModel> allRepast = this.GetRepast(lt_repast); List <AkProduceReportModel> ltResult = new List <AkProduceReportModel>(); //@1.餐段 foreach (var item in allRepast) { //开始时分 string startTime = item.StartTime.Substring(0, 5); //结束时分 string endTime = string.Empty; int reapeat = RepeatNum(item.StartTime, item.EndTime); #region [餐段时间内,每半小时一段] //@2.一个餐段内的,总共半小时段 for (int i = 0; i < reapeat; i++) { string strStartTime = DateTime.Now.ToString("yyyy-MM-dd ") + startTime; endTime = Convert.ToDateTime(strStartTime).AddMinutes(30).ToString("HH:mm"); //该阶段进行数据添加 LogHelper.Info(typeof(AkProduct) + "-> " + item.RepastName + " ", startTime + "-" + endTime); #region [半小时合计] List <AkProduceReportModel> lt_resultTotal1 = new List <AkProduceReportModel>(); AddRecode(item.RepastName, startTime, endTime, lt_resultTotal1); //设置数据值 setTotalProductData(startTime, endTime, lt_resultTotal1[0]); //添加餐段数据 ltResult.AddRange(lt_resultTotal1); #endregion //本次结束时分数,作为下次开始时分数 startTime = endTime; } #endregion #region [餐段合计] List <AkProduceReportModel> lt_resultTotal2 = new List <AkProduceReportModel>(); AddRecode(item.RepastName, item.StartTime.Substring(0, 5), item.EndTime.Substring(0, 5), lt_resultTotal2, 1); //设置数据值 setTotalProductData(item.StartTime.Substring(0, 5), item.EndTime.Substring(0, 5), lt_resultTotal2[0]); //添加餐段数据 ltResult.AddRange(lt_resultTotal2); #endregion } if (allRepast != null && allRepast.Count == 4) { AkRepastModel repastStart = allRepast[0]; AkRepastModel repastEnd = allRepast[allRepast.Count - 1]; #region [Total:合计] List <AkProduceReportModel> lt_resultTotal3 = new List <AkProduceReportModel>(); AddRecode("全天", repastStart.StartTime.Substring(0, 5), repastEnd.EndTime.Substring(0, 5), lt_resultTotal3, 2); setTotalProductData(repastStart.StartTime.Substring(0, 5), repastEnd.EndTime.Substring(0, 5), lt_resultTotal3[0]); ltResult.AddRange(lt_resultTotal3); #endregion } return(ltResult); }
private static void initDateTime(AkRepastModel model, string startTime, string endTime) { model.StartTime = startTime; model.EndTime = endTime; }