Beispiel #1
0
 public ResultQuotaLogs GetQuotaLogs()
 {
     var inputValue = _ntsPage.Request.Form["Inputs"];
     var query = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryQuotaLogContract>(inputValue);
     var result = new OperateQuotaBll().GetQuotaLogs(query);
     return result;
 }
Beispiel #2
0
        public int DealQuota()
        {
            var inputValue = _ntsPage.Request.Form["Inputs"];
            var query = Newtonsoft.Json.JsonConvert.DeserializeObject<QuotaDataContact>(inputValue);
            query.UserName = Framework.Common.Utils.GetCookie("userid");
            var result = new OperateQuotaBll().InsertOrEditQuota(query);

            return result;
        }
        public override string FormateContent(object primaryKey)
        {
            try
            {
                #region 变量

                string content = string.Empty;
                int id = (int)primaryKey;
                string itemCodeName = string.Empty;
                string objectDes = string.Empty;
                string editTime = string.Empty;
                string quotaDate = string.Empty;
                string type = string.Empty;
                string oldValue = string.Empty;
                string newValue = string.Empty;
                string objectUnit = string.Empty;
                OperateQuotaBll quotaOper = new OperateQuotaBll();
                #endregion

                #region 数据来源

                var quotaInfo = quotaOper.GetQuotaInfoById(id);
                var itemCodeInfo = new NTS.WEB.BLL.Itemcode().GetItemcodeList(string.Format(" and itemcodenumber='{0}'", quotaInfo.QuotaData.ItemCode), "")[0];
                QuotaLog newQoutaLog = quotaInfo.QuotaLogList[0];

                #endregion

                #region 组织数据

                itemCodeName = itemCodeInfo.ItemCodeName;
                objectUnit = itemCodeInfo.Unit;
                objectDes = quotaInfo.QuotaData.ObjectDesc;
                newValue = quotaInfo.QuotaData.QuotaValue.ToString();
                editTime = newQoutaLog.LogTime.ToString("yyyy年MM月dd日HH时mm分ss秒");
                type = quotaInfo.QuotaData.QuotaType == QuotaType.Month ? "月" : "年";
                if (quotaInfo.QuotaData.QuotaType == QuotaType.Month)
                {
                    quotaDate = string.Format("{0}年{1}月", quotaInfo.QuotaData.QuotaTime.Year, quotaInfo.QuotaData.QuotaTime.Month);
                }
                else if (quotaInfo.QuotaData.QuotaType == QuotaType.Year)
                {
                    quotaDate = string.Format("{0}年", quotaInfo.QuotaData.QuotaTime.Year);
                }

                if (quotaInfo.QuotaLogList.Count > 1)
                {
                    QuotaLog oldQUotaLog = quotaInfo.QuotaLogList[1];
                    oldValue = oldQUotaLog.QuotaValue.ToString();
                    content = string.Format("{0}用户于{1}修改\"{2}-{3}-{4}定额\":修改前为{5}kwh,修改后为{6}{7}。", _userName, editTime, objectDes, itemCodeName, type, oldValue, newValue, objectUnit);
                }
                else if (quotaInfo.QuotaLogList.Count == 1)
                {
                    content = string.Format("{0}用户于{1}添加\"{2}-{3}-{4}定额\":{5}{6}。", _userName, editTime, objectDes, itemCodeName, type, newValue, objectUnit);
                }
                return content;

                #endregion
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
        }
        /// <summary>
        /// 获取定额告警列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public ResultQuotaAlarmList GetQuotaAlarmList(Model.QueryQuotaAlarmContact query)
        {
            ResultQuotaAlarmList result = new ResultQuotaAlarmList();
            result.ResultInfo = new ExecuteResult();
            result.QuotaAlarmList = new List<QuotaAlarmData>();
            result.Page = new Padding();
            try
            {
                StringBuilder where = new StringBuilder();

                #region 组织条件
                if (!string.IsNullOrEmpty(query.ItemCode))
                {
                    where.Append(string.Format(" and itemcode='{0}'", query.ItemCode));
                }
                if (query.AlarmType != 0)
                {
                    where.Append(string.Format(" and alarmtype={0}", query.AlarmType));
                }
                if (query.QuotaType != 0)
                {
                    where.Append(string.Format(" and quotatype={0}", query.QuotaType));
                }
                if (!string.IsNullOrEmpty(query.ObjectName))
                {
                    where.Append(string.Format(" and objectdesc like '%{0}%'", query.ObjectName.Trim()));
                }
                #endregion

                var list = quotaAlarmOperator.GetQuotaAlarmList(where.ToString());
                while ((query.PageCurrent - 1) * query.PageSize >= list.Count())
                {
                    query.PageCurrent--;
                }
                result.QuotaAlarmList = list
                    .Select(p => new QuotaAlarmData
                    {
                        AlarmType = p.AlarmType,
                        Id = p.Id,
                        ItemCode = p.ItemCode,
                        ObjectDesc = p.ObjectDesc,
                        ObjectId = p.ObjectId,
                        ObjectType = p.ObjectType,
                        Percent = p.Percent,
                        QuotaType = p.QuotaType
                    }).Skip((query.PageCurrent - 1) * query.PageSize).Take(query.PageSize).ToList();
                result.Page.Current = query.PageCurrent;
                result.Page.Total = list.Count();

                //设置itemName 及 alarmName(减少全部转换)
                var itemList = new OperateQuotaBll().GetAllItemcodeList();
                var alarmTypeList = GetAlarmTypes("QoutaAlarm");
                foreach (var item in result.QuotaAlarmList)
                {
                    item.ItemName = GetItemNameByItemNumber(item.ItemCode, itemList);
                    item.AlarmName = GetAlarmNameByValue(item.AlarmType.ToString(), alarmTypeList);
                }

                result.ResultInfo.Success = true;
                return result;
            }
            catch (Exception ex)
            {
                result.ResultInfo.Success = false;
                result.ResultInfo.ExceptionMsg = ex.Message;
                result.ResultInfo.ExtendContent = null;
                return result;
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取定额告警列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public ResultQuotaAlarmList GetQuotaAlarmList(Model.QueryQuotaAlarmContact query)
        {
            ResultQuotaAlarmList result = new ResultQuotaAlarmList();

            result.ResultInfo     = new ExecuteResult();
            result.QuotaAlarmList = new List <QuotaAlarmData>();
            result.Page           = new Padding();
            try
            {
                StringBuilder where = new StringBuilder();

                #region 组织条件
                if (!string.IsNullOrEmpty(query.ItemCode))
                {
                    where.Append(string.Format(" and itemcode='{0}'", query.ItemCode));
                }
                if (query.AlarmType != 0)
                {
                    where.Append(string.Format(" and alarmtype={0}", query.AlarmType));
                }
                if (query.QuotaType != 0)
                {
                    where.Append(string.Format(" and quotatype={0}", query.QuotaType));
                }
                if (!string.IsNullOrEmpty(query.ObjectName))
                {
                    where.Append(string.Format(" and objectdesc like '%{0}%'", query.ObjectName.Trim()));
                }
                #endregion

                var list = quotaAlarmOperator.GetQuotaAlarmList(where.ToString());
                while ((query.PageCurrent - 1) * query.PageSize >= list.Count())
                {
                    query.PageCurrent--;
                }
                result.QuotaAlarmList = list
                                        .Select(p => new QuotaAlarmData
                {
                    AlarmType  = p.AlarmType,
                    Id         = p.Id,
                    ItemCode   = p.ItemCode,
                    ObjectDesc = p.ObjectDesc,
                    ObjectId   = p.ObjectId,
                    ObjectType = p.ObjectType,
                    Percent    = p.Percent,
                    QuotaType  = p.QuotaType
                }).Skip((query.PageCurrent - 1) * query.PageSize).Take(query.PageSize).ToList();
                result.Page.Current = query.PageCurrent;
                result.Page.Total   = list.Count();

                //设置itemName 及 alarmName(减少全部转换)
                var itemList      = new OperateQuotaBll().GetAllItemcodeList();
                var alarmTypeList = GetAlarmTypes("QoutaAlarm");
                foreach (var item in result.QuotaAlarmList)
                {
                    item.ItemName  = GetItemNameByItemNumber(item.ItemCode, itemList);
                    item.AlarmName = GetAlarmNameByValue(item.AlarmType.ToString(), alarmTypeList);
                }

                result.ResultInfo.Success = true;
                return(result);
            }
            catch (Exception ex)
            {
                result.ResultInfo.Success       = false;
                result.ResultInfo.ExceptionMsg  = ex.Message;
                result.ResultInfo.ExtendContent = null;
                return(result);
            }
        }