public decimal GetNoMoney(ConsumeInfo consumeInfo, Retail retail) { //不找零的消费 积分+储值+抹除+优惠券+店铺活动优惠 var holy = consumeInfo.Score + consumeInfo.CardMoney + consumeInfo.Erase + retail.CouponConsume + retail.StoreActivityDiscount; return(holy); }
public ConsumeInfo QueryOneById(string order_id) { ConsumeInfo consume_info = null; DataTable dt = ExecuteDataTable(@"select * from sales where order_id=@order_id", new MySqlParameter("@order_id", order_id)); if (dt.Rows.Count > 0) { consume_info = new ConsumeInfo(); consume_info.order_id = (string)dt.Rows[0]["order_id"]; consume_info.dt = (DateTime)dt.Rows[0]["dt"]; consume_info.discounted_value = Convert.ToDecimal(dt.Rows[0]["discounted_value"]); consume_info.score = (int)dt.Rows[0]["score"]; consume_info.pledge_amount = (decimal)dt.Rows[0]["pledge_amount"]; consume_info.total_amount = (decimal)dt.Rows[0]["total_amount"]; consume_info.comment = (string)dt.Rows[0]["comment"]; consume_info.optr_id = (int)dt.Rows[0]["operator_id"]; consume_info.from_value_card = (decimal)dt.Rows[0]["from_value_card"]; if (dt.Rows[0].Table.Columns.Contains("pay_mode")) { consume_info.pay_mode = (int)dt.Rows[0]["pay_mode"]; } } return(consume_info); }
/// <summary> /// 循环遍历ParaId,获取该ParaId的平均值(得到所有ParaId的值) /// </summary> /// <param name="AllParaId">所有ParaId</param> /// <param name="errMsg"></param> /// <returns></returns> public List <ConsumeInfo> GetInfos(string beginTime, string endTime, out string errMsg) { this.init(); errMsg = ""; //counts = 0; List <ConsumeInfo> cInfoList = new List <ConsumeInfo>(); //获取outtable表 List <ParaTableInfo> infoList = GetInfo(out errMsg); //获取所有ParaId //string ParaId = GetParaId(out counts,out errMsg); if (infoList.Count > 0) { foreach (var info in infoList) { if (!string.IsNullOrEmpty(info.OutTableName)) { ConsumeInfo pa = new ConsumeInfo(); string sql = "select avg(D_VALUE) as value from " + info.OutTableName + " where T_PARAID='" + info.ParaId + "' "; if (!String.IsNullOrEmpty(beginTime) && !String.IsNullOrEmpty(endTime)) { sql += " and T_DATETIME between '" + beginTime + "' and '" + endTime + "'"; } else { if (!String.IsNullOrEmpty(beginTime)) { sql += " and T_DATETIME>'" + beginTime + "'"; } if (!String.IsNullOrEmpty(endTime)) { sql += " and T_DATETIME<'" + endTime + "'"; } } DataTable dt = new DataTable(); if (rlDBType == "SQL") { // sql = "select ID_KEY,班次名,起始时间,结束时间 from 班次时间表 order by ID_KEY"; //dt = DBsql.RunDataTable(sql, out errMsg); } else { dt = DBdb2.RunDataTable(sql, out errMsg); } if (dt != null) { pa.Name = info.ParaDesc; pa.Count = string.IsNullOrEmpty(dt.Rows[0][0].ToString()) ? 0 : Convert.ToDouble(dt.Rows[0][0].ToString()); cInfoList.Add(pa); } } } } return(cInfoList); }
public float GetScore(ConsumeInfo consumeInfo, Retail retail, ScoreRule scoreRule) { if (scoreRule == null || scoreRule.ConsumeUnit <= 0 || scoreRule.ScoreUnit <= 0) { return(0); } var payMoney = consumeInfo.ConsumeCoun - GetNoMoney(consumeInfo, retail); // 消费/积分比例 float unitConsu = scoreRule.ConsumeUnit; float unitScore = scoreRule.ScoreUnit; var score = (float)Math.Round(payMoney) / unitConsu * unitScore; return(score); }
public void ProcessRequest(HttpContext context) { string beginTime = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString(); string endTime = string.Empty; string timeType = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString(); string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString(); //根据选择的时间段,设置开始时间和结束时间 switch (timeType) { case "1": //月度平均值 DateTime dt1 = new DateTime(); dt1 = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01"); beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-"); endTime = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-"); break; case "2": //季度平均值 switch (quarterType) { case "0": //一季度 string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00"; beginTime = ti; endTime = beginTime.Substring(0, 4) + "-03-31 23:59:59"; break; case "1": //二季度 string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00"; beginTime = ti1; endTime = beginTime.Substring(0, 4) + "-06-30 23:59:59"; break; case "2": //三季度 string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00"; beginTime = ti2; endTime = beginTime.Substring(0, 4) + "-09-30 23:59:59"; break; case "3": //四季度 string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00"; beginTime = ti3; endTime = beginTime.Substring(0, 4) + "-12-31 23:59:59"; break; } break; case "3": //年度平均值 string tim = beginTime.Substring(0, 4); beginTime = tim + "-01-01 00:00:00"; endTime = tim + "-12-31 23:59:59"; break; } AllInfo allinfo = new AllInfo(); List <ConsumeInfo> infoList; infoList = bl.get(beginTime, endTime, out errMsg); //平均值柱状图 infos tmp = new infos(); tmp.name = new ArrayList(); tmp.value = new ArrayList(); foreach (ConsumeInfo tmps in infoList) { tmp.name.Add(tmps.Name); tmp.value.Add(Math.Round(tmps.Count, 2)); } allinfo.ZhuTu = tmp; //饼状图 ArrayList ConsumeList = new ArrayList(); ArrayList tmsp; foreach (ConsumeInfo tmps in infoList) { tmsp = new ArrayList(); tmsp.Add(tmps.Name); tmsp.Add(Math.Round(tmps.Count, 2)); ConsumeList.Add(tmsp); } allinfo.ConsumeList = ConsumeList; //环比柱状图 List <infos> info = new List <infos>(); //七月份 infos ht = new infos(); ht.time = DateTime.Parse(beginTime).Month + "月份"; ht.name = new ArrayList(); ht.value = new ArrayList(); foreach (ConsumeInfo tmps in infoList) { ht.name.Add(tmps.Name); ht.value.Add(Math.Round(tmps.Count, 2)); } info.Add(ht); //六月份 infos sixMonth = new infos(); sixMonth.name = new ArrayList(); sixMonth.value = new ArrayList(); string beforBeginTime = DateTime.Parse(beginTime).AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss"); string beforEndTime = DateTime.Parse(beforBeginTime).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); sixMonth.time = DateTime.Parse(beforBeginTime).Month + "月份"; List <ConsumeInfo> beforInfoList = bl.get(beforBeginTime, beforEndTime, out errMsg); foreach (ConsumeInfo tmps in beforInfoList) { sixMonth.name.Add(tmps.Name); sixMonth.value.Add(Math.Round(tmps.Count, 2)); } info.Add(sixMonth); //环比 infos SsHb = new infos(); SsHb.time = "环比增长"; SsHb.name = new ArrayList(); SsHb.value = new ArrayList(); foreach (ConsumeInfo infos in infoList) { ConsumeInfo c = beforInfoList.Where(t => t.Name == infos.Name).FirstOrDefault(); SsHb.name.Add(c.Name); if (infos.Count > 0) { SsHb.value.Add(Math.Round(((infos.Count - c.Count) / infos.Count) * 100, 2)); } else { SsHb.value.Add(0); } } info.Add(SsHb); allinfo.Hb = info; string content = allinfo.ToJsonItem(); context.Response.ContentType = "text/json;charset=gb2312;"; context.Response.Write(content); context.Response.End(); }
public void AddSupplyPodConsumeInfo(evolib.SupplyPod.ConsumeType type, ConsumeInfo info) { infos[type] = info; }
/// <summary> /// 得到绑定汽机和锅炉总的耗差值(TargetType:耗差类型:0可控耗差,1不可控耗差。ConsumeType:指标类型:0锅炉指标,1汽机指标) /// </summary> /// <returns></returns> public List <ConsumeInfo> GetAllInfo(string beginTime, string endTime, string unitId, out string errMsg) { List <ConsumeInfo> infoList = new List <ConsumeInfo>(); List <TmpInfoE> infos = new List <TmpInfoE>(); ConsumeInfo a = new ConsumeInfo(); a.Count = 0; ConsumeInfo b = new ConsumeInfo(); b.Count = 0; ConsumeInfo c = new ConsumeInfo(); c.Count = 0; ConsumeInfo d = new ConsumeInfo(); d.Count = 0; ConsumeInfo e = new ConsumeInfo(); e.Count = 0; ////总的耗差值。 infos = GetFirstInfo(unitId, out errMsg); foreach (var i in infos) { DataTable dt = new DataTable(); ////分六类 //总耗差。 dt = GetBaseAll(i.TableName, beginTime, endTime, unitId, i.ParaId + "_B", -1, -1, out errMsg); if (dt != null) { foreach (DataRow dr in dt.Rows) { a.Count += String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString()); } } //汽机可控 dt = GetBaseAll(i.TableName, beginTime, endTime, unitId, i.ParaId + "_B", 0, 1, out errMsg); if (dt != null) { foreach (DataRow dr in dt.Rows) { b.Count += String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString()); } } //锅炉可控 dt = GetBaseAll(i.TableName, beginTime, endTime, unitId, i.ParaId + "_B", 0, 0, out errMsg); if (dt != null) { foreach (DataRow dr in dt.Rows) { c.Count += String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString()); } } //汽机不可控 dt = GetBaseAll(i.TableName, beginTime, endTime, unitId, i.ParaId + "_B", 1, 1, out errMsg); if (dt != null) { foreach (DataRow dr in dt.Rows) { d.Count += String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString()); } } //锅炉不可控 dt = GetBaseAll(i.TableName, beginTime, endTime, unitId, i.ParaId + "_B", 1, 0, out errMsg); if (dt != null) { foreach (DataRow dr in dt.Rows) { e.Count += String.IsNullOrEmpty(dr["counts"].ToString()) ? 0 : Convert.ToDouble(dr["counts"].ToString()); } } } infoList.Add(a); infoList.Add(b); infoList.Add(c); infoList.Add(d); infoList.Add(e); return(infoList); }
public void ProcessRequest(HttpContext context) { string beginTime = context.Request["beginTime"] == null ? string.Empty : context.Request["beginTime"].ToString(); string endTime = string.Empty; string timeType = context.Request["timeType"] == null ? string.Empty : context.Request["timeType"].ToString(); string quarterType = context.Request["quarterType"] == null ? string.Empty : context.Request["quarterType"].ToString(); //根据选择的时间段,设置开始时间和结束时间 switch (timeType) { case "1": //月度平均值 DateTime dt1 = new DateTime(); dt1 = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01"); beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-"); endTime = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-"); break; case "2": //季度平均值 switch (quarterType) { case "0": //一季度 string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00"; beginTime = ti; endTime = beginTime.Substring(0, 4) + "-03-31 23:59:59"; break; case "1": //二季度 string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00"; beginTime = ti1; endTime = beginTime.Substring(0, 4) + "-06-30 23:59:59"; break; case "2": //三季度 string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00"; beginTime = ti2; endTime = beginTime.Substring(0, 4) + "-09-30 23:59:59"; break; case "3": //四季度 string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00"; beginTime = ti3; endTime = beginTime.Substring(0, 4) + "-12-31 23:59:59"; break; } break; case "3": //年度平均值 string tim = beginTime.Substring(0, 4); beginTime = tim + "-01-01 00:00:00"; endTime = tim + "-12-31 23:59:59"; break; } TmpInfoE allInfo = new TmpInfoE(); List <ConsumeInfo> infoList = new List <ConsumeInfo>(); infoList = bl.get(beginTime, endTime, out errMsg); ConsumeInfo info = new ConsumeInfo(); info.ConsumeValue = 23; info.Name = "七月份耗差平均"; info.RealValue = 34; info.StandardValue = 12.4; infoList.Add(info); info = new ConsumeInfo(); info.ConsumeValue = 23; info.Name = "七月份分项比例"; info.RealValue = 34; info.StandardValue = 12.4; infoList.Add(info); //表格 //string content = infoList.ToJsonItem(); int count = 0; object obj = new { total = count, rows = infoList }; //列名 //List<column> col = new List<column>(); //foreach (var info in infoList) //{ // column c = new column(); // c.field = info.Name; // c.title = info.Name; // c.width = "150px"; // c.align = "center"; //} //string lm = JsonConvert.SerializeObject(col); string result = JsonConvert.SerializeObject(infoList); context.Response.ContentType = "text/json;charset=gb2312;"; context.Response.Write(result); }
/// <summary> /// 循环遍历ParaId,获取该ParaId的平均值(得到所有ParaId的值) /// </summary> /// <param name="AllParaId">所有ParaId</param> /// <param name="errMsg"></param> /// <returns></returns> public List <ConsumeInfo> GetInfos(string capacityLevel, string unitType, string BoilerId, string SteamId, string beginTime, string endTime, out string errMsg) { this.init(); errMsg = ""; //counts = 0; List <ConsumeInfo> cInfoList = new List <ConsumeInfo>(); //获取outtable表 List <ParaTableInfo> infoList = GetInfo(capacityLevel, unitType, BoilerId, SteamId, out errMsg); //获取所有ParaId //string ParaId = GetParaId(out counts,out errMsg); if (infoList.Count > 0) { for (int i = 0; i < infoList.Count; i++) { //foreach (var info in infoList) //{ if (!string.IsNullOrEmpty(infoList[i].OutTableName)) { ConsumeInfo pa = new ConsumeInfo(); string sql = "select T_UNITID, avg(D_VALUE) as value from " + infoList[i].OutTableName + " where T_PARAID='" + infoList[i].ParaId + "' "; if (!String.IsNullOrEmpty(beginTime) && !String.IsNullOrEmpty(endTime)) { sql += " and T_DATETIME between '" + beginTime + "' and '" + endTime + "'"; } else { if (!String.IsNullOrEmpty(beginTime)) { sql += " and T_DATETIME>'" + beginTime + "'"; } if (!String.IsNullOrEmpty(endTime)) { sql += " and T_DATETIME<'" + endTime + "'"; } } sql += " group by T_UNITID"; DataTable dt = new DataTable(); if (rlDBType == "SQL") { // sql = "select ID_KEY,班次名,起始时间,结束时间 from 班次时间表 order by ID_KEY"; //dt = DBsql.RunDataTable(sql, out errMsg); } else { dt = DBdb2.RunDataTable(sql, out errMsg); } if (dt != null && dt.Rows.Count > 0) { pa.Name = infoList[i].UnitName; pa.Count = string.IsNullOrEmpty(dt.Rows[0]["value"].ToString()) ? 0 : Convert.ToDouble(dt.Rows[0]["value"].ToString()); cInfoList.Add(pa); } } //} //删除已经计算过的机组 List <ParaTableInfo> tmp = infoList.Where(infos => infos.UnitId == infoList[i].UnitId).ToList(); foreach (var tmpInfo in tmp) { infoList.Remove(tmpInfo); } } } return(cInfoList); }
private void QueryData() { string beginTime = Request["beginTime"] == null ? string.Empty : Request["beginTime"].ToString(); string endTime = string.Empty; string timeType = Request["timeType"] == null ? string.Empty : Request["timeType"].ToString(); string quarterType = Request["quarterType"] == null ? string.Empty : Request["quarterType"].ToString(); //根据选择的时间段,设置quarterType开始时间和结束时间 switch (timeType) { case "1": //月度平均值 DateTime dt1 = new DateTime(); dt1 = Convert.ToDateTime(beginTime.Substring(0, 7) + "-01"); beginTime = dh.GetFirstDayOfMonth(dt1).ToString().Replace("/", "-"); endTime = dh.GetLastDayOfMonth(dt1).ToString().Replace("/", "-"); break; case "2": //季度平均值 switch (quarterType) { case "0": //一季度 string ti = beginTime.Substring(0, 4) + "-01-01 00:00:00"; beginTime = ti; endTime = beginTime.Substring(0, 4) + "-03-31 23:59:59"; break; case "1": //二季度 string ti1 = beginTime.Substring(0, 4) + "-04-01 00:00:00"; beginTime = ti1; endTime = beginTime.Substring(0, 4) + "-06-30 23:59:59"; break; case "2": //三季度 string ti2 = beginTime.Substring(0, 4) + "-07-01 00:00:00"; beginTime = ti2; endTime = beginTime.Substring(0, 4) + "-09-30 23:59:59"; break; case "3": //四季度 string ti3 = beginTime.Substring(0, 4) + "-10-01 00:00:00"; beginTime = ti3; endTime = beginTime.Substring(0, 4) + "-12-31 23:59:59"; break; } break; case "3": //年度平均值 string tim = beginTime.Substring(0, 4); beginTime = tim + "-01-01 00:00:00"; endTime = tim + "-12-31 23:59:59"; break; } //先根据paraId,取出所有paraId的outtable,循环outtable,取平均值。 AllInfo allInfo = new AllInfo(); ArrayList list = new ArrayList(); IList <Hashtable> iList = new List <Hashtable>(); Hashtable ht = null; List <ConsumeInfo> infoList; infoList = bl.get(beginTime, endTime, out errMsg); //记录七月份数据,供分项比例用 List <ConsumeInfo> tmpList = new List <ConsumeInfo>(); List <ConsumeInfo> beforInfoList; infos tmpZhuTu = new infos(); double tmpCount = 0.00; string beforBeginTime = DateTime.Parse(beginTime).AddMonths(-1).ToString("yyyy-MM-dd HH:mm:ss"); string beforEndTime = DateTime.Parse(beforBeginTime).AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss"); beforInfoList = bl.get(beforBeginTime, beforEndTime, out errMsg); for (int j = 0; j < 4; j++) { ht = new Hashtable(); //总耗差 double allCount = 0; //infoList = new List<ConsumeInfo>(); switch (j) { case 0: ht.Add("记录时间", DateTime.Parse(beginTime).Month + "月份耗差平均"); tmpList = infoList; allCount = infoList.Select(info => info.Count).Sum(); ht.Add("总耗差", Math.Round(allCount, 4)); //平均值柱状图 ArrayList name = new ArrayList(); ArrayList value = new ArrayList(); foreach (ConsumeInfo tmp in infoList) { ht.Add(tmp.Name, Math.Round(tmp.Count, 3)); name.Add(tmp.Name); value.Add(Math.Round(tmp.Count, 3)); } tmpZhuTu.name = name; tmpZhuTu.value = value; tmpCount = allCount; //ht.Add("总耗差", allCount); iList.Add(ht); break; case 1: ht.Add("记录时间", DateTime.Parse(beginTime).Month + "月份分项比列"); ht.Add("总耗差", 100.00); if (tmpCount > 0) { foreach (ConsumeInfo tmp in tmpList) { ht.Add(tmp.Name, Math.Round((tmp.Count / tmpCount) * 100, 3)); } } else { foreach (ConsumeInfo tmp in tmpList) { ht.Add(tmp.Name, 0); } } iList.Add(ht); break; case 2: ht.Add("记录时间", DateTime.Parse(beforBeginTime).Month + "月份耗差平均"); allCount = beforInfoList.Select(info => info.Count).Sum(); ht.Add("总耗差", allCount); foreach (ConsumeInfo tmp in beforInfoList) { ht.Add(tmp.Name, Math.Round(tmp.Count, 3)); // allCount += tmp.Count; } //ht.Add("总耗差", allCount); iList.Add(ht); break; case 3: ht.Add("记录时间", DateTime.Parse(beginTime).Month + "月份环比" + DateTime.Parse(beforBeginTime).Month + "月份增长"); foreach (ConsumeInfo infos in tmpList) { ConsumeInfo c = beforInfoList.Where(t => t.Name == infos.Name).FirstOrDefault(); //SsHb.name.Add(c.Name); if (infos.Count > 0) { //SsHb.value.Add(Math.Round(((infos.Count - c.Count) / infos.Count) * 100, 2)); ht.Add(c.Name, Math.Round(((infos.Count - c.Count) / infos.Count) * 100, 2)); } else { ht.Add(c.Name, 0); } } iList.Add(ht); break; } } string str = this.CreateDataGridColumnModel(iList); object obj = new { rows = iList, columns = str }; string result = JsonConvert.SerializeObject(obj); Response.Write(result); Response.End(); }