예제 #1
0
        /// <summary>
        /// 初始化界面用
        /// </summary>
        /// <returns></returns>
        public async Task <JsonResult> GetLocationList()
        {
            Log log = LogFactory.GetLogger("GetLocationList");

            try
            {
                CWICCard cwiccd = new CWICCard();

                List <Location> locList      = await new CWLocation().FindLocationListAsync();
                List <Customer> bindCustsLst = await cwiccd.FindCustListAsync(cc => cc.Type == EnmICCardType.FixedLocation || cc.Type == EnmICCardType.VIP);

                List <LocsMapping> mappingsLst = new List <LocsMapping>();
                foreach (Location loc in locList)
                {
                    Customer cust     = bindCustsLst.Find(cc => cc.LocAddress == loc.Address && cc.Warehouse == loc.Warehouse);
                    int      isfix    = 0;
                    string   custname = "";
                    string   deadline = "";
                    string   rcdplate = "";

                    if (cust != null)
                    {
                        isfix    = 1;
                        custname = cust.UserName;
                        deadline = cust.Deadline.ToString();
                        rcdplate = cust.PlateNum;
                    }
                    LocsMapping map = new LocsMapping
                    {
                        Warehouse = loc.Warehouse,
                        Address   = loc.Address,
                        LocSide   = loc.LocSide,
                        LocColumn = loc.LocColumn,
                        LocLayer  = loc.LocLayer,
                        Type      = loc.Type,
                        Status    = loc.Status,
                        LocSize   = loc.LocSize,
                        ICCode    = loc.ICCode,
                        WheelBase = loc.WheelBase,
                        CarWeight = loc.CarWeight,
                        CarSize   = loc.CarSize,
                        InDate    = loc.InDate.ToString(),
                        PlateNum  = loc.PlateNum,
                        IsFixLoc  = isfix,
                        CustName  = custname,
                        Deadline  = deadline,
                        RcdPlate  = rcdplate
                    };
                    mappingsLst.Add(map);
                }
                var nback = new
                {
                    code = 1,
                    data = mappingsLst
                };
                return(Json(nback, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
            }
            var bback = new
            {
                code = 0,
                data = "系统异常"
            };

            return(Json(bback, JsonRequestBehavior.AllowGet));
        }