Ejemplo n.º 1
0
        public string GetMeterList(MeterReq req)
        {
            var user = JsonConvert.DeserializeObject <AllInOne_UserInfo>(Session["user"].ToString());
            var r    = AllFunc.Instance.GetMeterList(req, user);

            if (r.HttpCode == 200)
            {
                Session["GetMeterListReq"] = JsonConvert.SerializeObject(req);
            }
            return(JsonConvert.SerializeObject(r));
        }
Ejemplo n.º 2
0
        public List <DeviceView> GetList(MeterReq req, int size, AllInOne_UserInfo user)
        {
            var lastCId = "";

            if ((bool)user.isStaff)
            {
                lastCId = AllInOne_UserInfoOper.Instance.GetFatherLastCId(user);
            }
            else
            {
                lastCId = AllInOne_UserInfoOper.Instance.GetLastCId(user);
            }
            var search = req.search ?? "";
            var order  = req.orderField;
            var desc   = Convert.ToBoolean(req.isDesc);
            var index  = Convert.ToInt32(req.pageIndex);
            //var size = 5;
            var orderStr = $"order by {order} ";

            if (desc)
            {
                orderStr += " desc ";
            }
            else
            {
                orderStr += " asc ";
            }
            var dict = new Dictionary <string, string>
            {
                { "@search", $"%{search}%" },
                { "@search2", search },
                { "@lastcid", lastCId },
            };

            var condition = $" 1=1 and (cid1=@lastcid or cid2=@lastcid or cid3=@lastcid or cid4=@lastcid) ";

            var name = req.lastName;

            if (name != null)
            {
                var cid = AllInOne_UserInfoOper.Instance.GetLastCIdByName(name);

                if (cid != null)
                {
                    dict.Add("cid", cid);
                    condition += $" and  (cid1=@cid or cid2=@cid or cid3=@cid or cid4=@cid) ";
                }
                else
                {
                    return(new List <DeviceView>());
                }
            }

            if (!search.IsNullOrEmpty())
            {
                condition += $" and (deviceNo=@search2 or customerNo=@search2 or communicateNo=@search2 or customerName like @search or address like @search or meterNo like @search ) ";
            }

            if (req.meterTypeNo != null)
            {
                condition += $" and meterTypeNo='{req.meterTypeNo}' ";
            }
            if (req.factoryNo != null)
            {
                condition += $" and factoryNo='{req.factoryNo}' ";
            }
            if (req.openState != null)
            {
                condition += $" and openState={req.openState} ";
            }
            if (req.fluidNo != null)
            {
                condition += $" and fluidNo='{req.fluidNo}' ";
            }
            if (req.Operator != null)
            {
                condition += $" and Operator='{req.Operator}' ";
            }

            return(SqlHelper.Instance.GvpForDeviceView <DeviceView>("DeviceView", $@"select distinct meterNo,
                                communicateNo,
                                barCode,
                                customerNo,
                                meterTypeNo,
                                factoryNo,
                                openState,
                                caliber,
                                ProtocolNo,
                                baseVolume,
                                fluidNo,
                                lat,
                                lng,
                                remark,
                                defineNo1,
                                defineNo2,
                                defineNo3,
                                buildTime,
                                editTime,
                                Operator,
                                deviceNo,
                                collectorNo,
                                MeterType,
                                isConcentrate,
                                AlarmTimes,
                                AlarmInvTime,
                                CommMode,
                                LinkMode,
                                factoryName,
                                meterTypeName,
                                openStateName,
                                fluidName,
                                customerName,
                                address,
                                LoginState,
                                FMState,
                                FMStateMsg,
                                LoginStateMsg,
                                customerType,
CustTypeName from DeviceView ", condition, index, size, orderStr, dict));
            //for (int i = 0; i < list.Count; i++)
            //{
            //    if (list[i].userName == "admin")
            //        list[i].userName = user.admin;
            //}
            // return list;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取设备总数
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public int GetCount(MeterReq req, AllInOne_UserInfo user)
        {
            var lastCId = "";

            if ((bool)user.isStaff)
            {
                lastCId = AllInOne_UserInfoOper.Instance.GetFatherLastCId(user);
            }
            else
            {
                lastCId = AllInOne_UserInfoOper.Instance.GetLastCId(user);
            }

            var search = req.search ?? "";
            var dict   = new Dictionary <string, string>
            {
                { "@search", $"%{search}%" },
                { "@search2", search },
                { "@lastcid", lastCId },
            };

            var condition = $" 1=1 and (cid1=@lastcid or cid2=@lastcid or cid3=@lastcid or cid4=@lastcid) ";

            var name = req.lastName;

            if (name != null)
            {
                var cid = AllInOne_UserInfoOper.Instance.GetLastCIdByName(name);

                if (cid != null)
                {
                    dict.Add("cid", cid);
                    condition += $" and  (cid1=@cid or cid2=@cid or cid3=@cid or cid4=@cid) ";
                }
                else
                {
                    return(0);
                }
            }

            if (!search.IsNullOrEmpty())
            {
                condition += $" and (deviceNo=@search2 or customerNo=@search2 or communicateNo=@search2 or customerName like @search or address like @search or meterNo like @search ) ";
            }

            if (req.meterTypeNo != null)
            {
                condition += $" and meterTypeNo='{req.meterTypeNo}' ";
            }
            if (req.factoryNo != null)
            {
                condition += $" and factoryNo='{req.factoryNo}' ";
            }
            if (req.openState != null)
            {
                condition += $" and openState={req.openState} ";
            }
            if (req.fluidNo != null)
            {
                condition += $" and fluidNo='{req.fluidNo}' ";
            }
            if (req.Operator != null)
            {
                condition += $" and Operator='{req.Operator}' ";
            }
            var list = SqlHelper.Instance.GdcForDeviceView <DeviceView>("DeviceView", condition, dict);

            return(list.Count);
        }