Exemplo n.º 1
0
        public int GetCount(ProductForMachineModel machineInfo)
        {
            var result = 0;


            var conditions = new List <Condition>();

            if (!string.IsNullOrEmpty(machineInfo.MachineId))
            {
                conditions.Add(new Condition
                {
                    LeftBrace    = " AND ",
                    ParamName    = "MachineId",
                    DbColumnName = "a.machine_id",
                    ParamValue   = machineInfo.MachineId,
                    Operation    = ConditionOperate.Equal,
                    RightBrace   = "",
                    Logic        = ""
                });
            }
            conditions.Add(new Condition
            {
                LeftBrace    = "  ",
                ParamName    = "",
                DbColumnName = "a.wares_id",
                ParamValue   = "",
                Operation    = ConditionOperate.GroupBy,
                RightBrace   = "",
                Logic        = ""
            });

            result = GenerateDal.LoadDataTableByConditions(CommonSqlKey.GetProductByMachineCount, conditions).Rows.Count;

            return(result);
        }
Exemplo n.º 2
0
        // 返回支付结果,需要出货的东东

        /*
         * public string GetPayResult(string k)
         * {
         *  KeyJsonModel keyJsonInfo = AnalizeKey(k);
         *  ISale _isale = new SalesService();
         *  //trade_status: (0:待支付,1:支付成功待出货,2:支付成功且已全部出货,3:支付成功部分出货成功未退款,4:支付成功部分出货成功已退款,5:支付成功此货道出货全部出货失败未退款,6:支付成功此货道出货全部出货失败已退款)
         *  List<KeyTunnelModel> lstSales = _isale.GetPayResult("", "1", keyJsonInfo.m);
         *  if (lstSales.Count == 0)
         *  {
         *      return "";
         *  }
         *  return JsonHandler.GetJsonStrFromObject(lstSales,false);
         * }
         *
         * //出货后,告诉汇报出货情况并更新库存
         * public string GetOutResult(string k)
         * {
         *
         *  KeyJsonModel keyJsonInfo = AnalizeKey(k);
         *  int result = _IMachine.PutPayResult(keyJsonInfo);
         *  if (result == 1)
         *  {
         *      var tns = from m in keyJsonInfo.t
         *                where m.s=="3" || m.s=="5"
         *                select m.tn;
         *
         *      RefundController refund = new RefundController();
         *      refund.PostRefund(tns.ToList<string>());
         *  }
         *
         *  return result==1?"OK":"NG";
         * }
         *
         * // 心跳
         * //[EnableCors("AllowSpecificOrigin")]
         *
         * public string GetHeartBeep(string k)
         * {
         *  KeyJsonModel keyJsonInfo = AnalizeKey(k);
         *  DataTable dt = _IMachine.GetBeepHeart(keyJsonInfo.m);
         *  if (dt.Rows.Count > 0)
         *  {
         *      return "{\"OK\":"+JsonHandler.DataTable2Json(dt) + "}";
         *  }
         *  else
         *  {
         *      return "{\"OK\":\"\"}";
         *  }
         *
         * }
         *
         * // 上报机器下行处理结果
         * public string GetHandleResult(string k)
         * {
         *  ToMachineModel toMachineInfo = JsonHandler.GetObjectFromJson<ToMachineModel>(k);
         *  int result = _IMachine.GetHandleResult(toMachineInfo.m, toMachineInfo.s);
         *  return result == 1 ? "OK" : "NG";
         * }
         *
         * //向机器下行价格
         * public string GetToMachinePrice(string k)
         * {
         *  Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(k);
         *  return JsonHandler.DataTable2Json(_IMachine.GetToMachinePrice(values["m"], Convert.ToInt32(values["start"]), Convert.ToInt32(values["len"])));
         * }
         *
         * //向机器下行当前补货库存
         * public string GetToMachineStock(string k)
         * {
         *  Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(k);
         *  return JsonHandler.DataTable2Json(_IMachine.GetToMachineStock(values["m"], Convert.ToInt32(values["start"]), Convert.ToInt32(values["len"])));
         * }
         *
         * //一键补货
         * public string GetFullfilGood(string k)
         * {
         *  KeyJsonModel keyJsonInfo = AnalizeKey(k);
         *  int result = _IMachine.GetFullfilGood(keyJsonInfo.m);
         *  return result == 1 ? "OK" : "NG";
         * }
         *
         * //按货道补货
         * public string GetFullfilGoodByTunnel(string k)
         * {
         *  KeyJsonModel keyJsonInfo = AnalizeKey(k);
         *  int result = _IMachine.GetFullfilGoodByTunnel(keyJsonInfo);
         *  return result == 1 ? "OK" : "NG";
         * }
         *
         * //机器端设置价格和最大库存上报
         * public string GetReportMaxStockAndPrice(string k)
         * {
         *  //FileHandler.LogMachineData(new string[] { "GetReportMaxStockAndPrice", k, DateTime.Now.ToString() });
         *  //LogMachineData(new string[] {"GetReportMaxStockAndPrice",k,DateTime.Now.ToString()});
         *  PriceAndMaxStock priceAndMaxStock = JsonHandler.GetObjectFromJson<PriceAndMaxStock>(k);
         *  int result = _IMachine.PostMaxStockAndPrice(priceAndMaxStock.t, priceAndMaxStock.m);
         *  return result == 1 ? "OK" : "NG";
         * }
         *
         * //取机器设置接口
         * public string GetMachineSetting(string k)
         * {
         *  KeyJsonModel keyJsonInfo = AnalizeKey(k);
         *  DataTable dt = _IMachine.GetMachineSetting(keyJsonInfo.m);
         *  return JsonHandler.DataTable2Json(dt);
         * }
         *
         */
        #endregion

        //取销售的商品列表
        public ResultObj <List <ProductForMachineModel> > GetProductByMachine(string k = "", int pageIndex = 1, int pageSize = 10)
        {
            //KeyJsonModel keyJsonInfo = AnalizeKey(k);
            // IProduct service = new ProductService();
            //List<ProductModel> products = service.GetAllProducts();
            //k = "ABC123456789";
            //机器运行情况

            /*
             * DataTable dt = _IMachine.GetMachineByMachineId(k);
             * if (dt == null || dt.Rows.Count == 0)
             * {
             *  return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不存在", new Pagination { });
             * }
             * //判断机器是否在线 时间大于十五分钟为离线
             * if (string.IsNullOrEmpty(dt.Rows[0][0].ToString()))
             * {
             *  return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不在线", new Pagination { });
             * }
             * int intval = Convert.ToInt32(dt.Rows[0][0]);
             * if (intval > 900)
             * {
             *  return Content(new List<ProductForMachineModel>(), ResultCode.Success, "机器不在线", new Pagination { });
             * }
             */

            if (!MachineHelper.IsOnline(k))
            {
                return(Content(new List <ProductForMachineModel>(), ResultCode.Success, "机器不在线", new Pagination {
                }));
            }

            ProductForMachineModel machineInfo = new ProductForMachineModel();

            machineInfo.MachineId = k;
            machineInfo.PageIndex = pageIndex;
            machineInfo.PageSize  = pageSize;
            var users      = _IMachine.GetProductByMachine(machineInfo);
            int totalcount = _IMachine.GetCount(machineInfo);

            var pagination = new Pagination {
                PageSize = pageSize, PageIndex = pageIndex, StartIndex = 0, TotalRows = totalcount, TotalPage = 0
            };

            //var log = LogManager.GetLogger("FycnApi", typeof(Startup));
            //log.Info("test");
            //string jsonUser = HttpUtility.UrlDecode(JsonHandler.GetJsonStrFromObject(users));
            //log.Info(jsonUser);
            return(Content(users, pagination));
        }
Exemplo n.º 3
0
        //取商品列表
        public List <ProductForMachineModel> GetProductByMachine(ProductForMachineModel machineInfo)
        {
            var conditions = new List <Condition>();

            if (!string.IsNullOrEmpty(machineInfo.MachineId))
            {
                conditions.Add(new Condition
                {
                    LeftBrace    = " AND ",
                    ParamName    = "MachineId",
                    DbColumnName = "a.machine_id",
                    ParamValue   = machineInfo.MachineId,
                    Operation    = ConditionOperate.Equal,
                    RightBrace   = "",
                    Logic        = ""
                });
            }
            conditions.Add(new Condition
            {
                LeftBrace    = "  ",
                ParamName    = "",
                DbColumnName = "a.wares_id",
                ParamValue   = "",
                Operation    = ConditionOperate.GroupBy,
                RightBrace   = "",
                Logic        = ""
            });
            conditions.Add(new Condition
            {
                LeftBrace    = "  ",
                ParamName    = "ResourceUrl",
                DbColumnName = "",
                ParamValue   = ConfigHandler.ResourceUrl,
                Operation    = ConditionOperate.None,
                RightBrace   = "",
                Logic        = ""
            });
            conditions.AddRange(CreatePaginConditions(machineInfo.PageIndex, machineInfo.PageSize));
            return(GenerateDal.LoadByConditions <ProductForMachineModel>(CommonSqlKey.GetProductByMachine, conditions));
        }