Ejemplo n.º 1
0
        /// <summary>
        /// 给栏目绑定指标 页面
        /// </summary>
        /// <param name="keyValue">栏目Id</param>
        /// <param name="indexType">所属平台 0web平台 1安卓平台 2App</param>
        /// <param name="Templet">所属栏目</param>
        /// <returns></returns>
        public ActionResult TerminalBindForm(string keyValue, int indexType, int Templet)
        {
            Operator                     user       = OperatorProvider.Provider.Current();
            DepartmentEntity             userdept   = new DepartmentBLL().GetCompany(user.DeptId);
            TerminalDataSetBLL           dataSetBLL = new TerminalDataSetBLL();
            List <TerminalDataSetEntity> indexlist  = new List <TerminalDataSetEntity>();

            indexlist = dataSetBLL.GetList().Where(p => p.IsOpen == 1).ToList();
            //if (indexType == 2)
            //{
            //    indexlist = dataSetBLL.GetList().Where(p => p.IsOpen == 1 && (p.DataSetType == indexType.ToString() )).ToList(); //所有的手机APP指标
            //}
            //else
            //{
            //    indexlist = dataSetBLL.GetList().Where(p => p.IsOpen == 1 && (p.DataSetType == indexType.ToString() || p.DataSetType == null)).ToList(); //所有的终端指标
            //}

            //查询本IndexType的栏目
            var titleIds = manageBLL.GetList(userdept.DepartmentId, indexType).Where(x => x.Templet == Templet).Select(x => x.Id);
            //查找所有的关联关系
            IIndexAssocationBLL          indexAssocationBLL = new IIndexAssocationBLL();
            List <IndexAssocationEntity> indices            = indexAssocationBLL.GetListByTitleId(titleIds.ToArray());

            //先剔除非本IndexType的关联关系
            indices = indices.Where(x => titleIds.Contains(x.TitleId)).ToList();
            //查询未被其他标题绑定的指标
            var BindIds     = indices.Where(x => x.TitleId != keyValue).Select(p => p.DataSetId); //非当前标题 已经的被帮的指标
            var thisBindIds = indices.Where(x => x.TitleId == keyValue).Select(p => p.DataSetId); //当前标题绑定的指标
            var data        = indexlist.Where(x => !BindIds.Contains(x.Id)).ToList();             //当前标题 可显示的指标

            ViewBag.ChceckIds = thisBindIds.ToList();
            ViewBag.TitleId   = keyValue;
            return(View(data));
        }
Ejemplo n.º 2
0
 public ActionResult RemoveTitle(string keyValue)
 {
     try
     {
         manageBLL.Remove(keyValue);
         //删除与指标的关联关系
         IIndexAssocationBLL assocationBLL = new IIndexAssocationBLL();
         //先查出该标题下所有的指标
         List <IndexAssocationEntity> entities = assocationBLL.GetListByTitleId(keyValue);
         assocationBLL.Remove(entities);
         return(Success("操作成功"));
     }
     catch (Exception ex)
     {
         return(Error(ex.Message));
     }
 }
Ejemplo n.º 3
0
        public ActionResult BindForm(string keyValue, int indexType)
        {
            if (indexType != 0)//为1则是安卓终端的指标配置
            {
                return(RedirectToAction("TerminalBindForm", new { keyValue, indexType }));
            }
            Operator   user       = OperatorProvider.Provider.Current();
            DataSetBLL dataSetBLL = new DataSetBLL();
            var        indexlist  = dataSetBLL.GetList(null).Where(p => p.IsOpen == 1).ToList(); //所有的指标
            //查找所有的关联关系
            IIndexAssocationBLL          indexAssocationBLL = new IIndexAssocationBLL();
            List <IndexAssocationEntity> indices            = indexAssocationBLL.GetList(user.DeptId);
            //查询未被其他标题绑定的指标
            var BindIds     = indices.Where(x => x.TitleId != keyValue).Select(p => p.DataSetId); //非当前标题 已经的被帮的指标
            var thisBindIds = indices.Where(x => x.TitleId == keyValue).Select(p => p.DataSetId); //当前标题绑定的指标
            var data        = indexlist.Where(x => !BindIds.Contains(x.Id)).ToList();             //当前标题 可显示的指标

            ViewBag.ChceckIds = thisBindIds.ToList();
            ViewBag.TitleId   = keyValue;
            return(View(data));
        }
Ejemplo n.º 4
0
        public ActionResult SaveAssociation(string titleId, string indexIdStr)
        {
            try
            {
                List <string>       indexIds      = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(indexIdStr);
                IIndexAssocationBLL assocationBLL = new IIndexAssocationBLL();
                //先查出该标题下所有的指标
                List <IndexAssocationEntity> oldEntity = assocationBLL.GetListByTitleId(titleId);
                //要删除的数据
                List <IndexAssocationEntity> delEntity = oldEntity.Where(x => !indexIds.Contains(x.DataSetId)).ToList();
                //要新增进去的数据
                var      oldids = oldEntity.Select(o => o.DataSetId).ToList();
                var      addIds = indexIds.Where(p => !oldids.Contains(p)).ToList();
                Operator user   = OperatorProvider.Provider.Current();
                List <IndexAssocationEntity> addEntitys = new List <IndexAssocationEntity>();

                addIds.ForEach(setId =>
                {
                    addEntitys.Add(new IndexAssocationEntity()
                    {
                        Id        = Guid.NewGuid().ToString(),
                        DataSetId = setId,
                        DeptId    = user.DeptId,
                        TitleId   = titleId
                    });
                });
                assocationBLL.Remove(delEntity);
                assocationBLL.Insert(addEntitys);

                return(Success("操作成功"));
            }
            catch (Exception ex)
            {
                return(Error("保存失败:" + ex.Message));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchDeptId">所查询的指标的部门ID 一般为电厂的Id</param>
        /// <param name="userId">当前用户的Id 取数据用</param>
        /// <param name="indexType">指标类型 0管理平台  1安卓终端  2手机APP </param>
        /// <param name="userDeptId">当前用户的所属的部门Id   取数据用</param>
        /// <param name="terminalType">查询类型         0月 1季  2年</param>
        /// <param name="templet">模板 所属的模板  1第一套  2 第二套 以此类推</param>
        /// <returns></returns>
        public List <IndexManageModel> GetIndexData(string searchDeptId, string userId, int indexType, string userDeptId, string terminalType, int?templet)
        {
            TerminalDataSetBLL terminalDataSetBLL = new TerminalDataSetBLL();
            IndexManageBLL     indexManageBLL     = new IndexManageBLL();

            List <TerminalDataSetEntity> entitys = terminalDataSetBLL.GetList().Where(p => p.IsOpen == 1).ToList(); //先取所有的指标
                                                                                                                    //再取所有的分类
            List <IndexManageEntity> manageEntities = indexManageBLL.GetList(searchDeptId, indexType, null, templet).Where(p => p.IsShow == 1).ToList();
            //获取分类底下的指标
            List <IndexAssocationEntity> indexAssocationEntities = new IIndexAssocationBLL().GetListByTitleId(manageEntities.Select(p => p.Id).ToArray());
            //查询并组装指标值的数据
            var dataSetIds = indexAssocationEntities.Select(x => x.DataSetId);//所有的指标的Ids
            Dictionary <string, string> dic = new Dictionary <string, string>();

            entitys.Where(x => dataSetIds.Contains(x.Id)).ToList().ForEach(x => {
                dic.Add(x.Code + "-" + x.Name, terminalType);
            });//应该要绑定的所有的指标

            List <KeyValue> keyValues = FindAllCount(userId, userDeptId, dic);
            //List<KeyValue> keyValues = FindAllCount(userId, userDeptId, terminalType);
            List <IndexManageModel> models = new List <IndexManageModel>();

            if (manageEntities != null && manageEntities.Count > 0)
            {
                manageEntities.ForEach(title =>
                {
                    //生成分类
                    IndexManageModel model = new IndexManageModel()
                    {
                        TitleId   = title.Id,
                        TitleName = title.Title,
                        Srot      = title.Sort
                    };
                    //生成指标
                    var datasetIds = indexAssocationEntities.Where(p => p.TitleId == title.Id).Select(p => p.DataSetId);
                    List <TerminalDataSetEntity> terminals = entitys.Where(x => datasetIds.Contains(x.Id)).ToList();
                    List <IndexModel> indexModels          = new List <IndexModel>();
                    terminals.ForEach(terminal =>
                    {
                        //组装数据

                        IndexModel indexModel = new IndexModel()
                        {
                            Key     = terminal.Code,
                            Name    = terminal.Name,
                            Sort    = terminal.Sort,
                            IsBZ    = terminal.IsBZ,
                            Unit    = terminal.Unint,
                            Icon    = string.IsNullOrWhiteSpace(terminal.IconUrl) ? null : Config.GetValue("AppUrl") + terminal.IconUrl,
                            Address = terminal.Address
                                      //Value = thisKv == null ? "0" : thisKv.value
                        };
                        if (terminal.IsBZ == "1" && keyValues != null && keyValues.Count > 0)
                        {
                            var thisKv       = keyValues.FirstOrDefault(p => p.key == terminal.Code);
                            indexModel.Value = thisKv == null ? "0" : thisKv.value;
                        }
                        indexModels.Add(indexModel);
                    });
                    model.AddChilds(indexModels);
                    models.Add(model);
                });
            }
            return(models);
        }