public void SaveStock(string data, int cid) { //SaveStock([FromBody]SaveTakeStockRequest requestParams) /*string storeId = requestParams.Property("storeId", true); * string checkBatch = requestParams.Property("checkBatch", true); * string userCode = requestParams.Property("userCode", true); * string barcodes = requestParams.Property("barcodes", true); * var barnums = new Dictionary<string, decimal>(); * if (!string.IsNullOrWhiteSpace(barcodes)) * { * var bars = JArray.Parse(barcodes); * for (var i = 0; i < bars.Count; i++) * { * var barjson = JObject.Parse(bars[i].ToString()); * var barc = barjson.Property("barcode", true); * var num = barjson.Property("num", true); * if (string.IsNullOrWhiteSpace(barc) || string.IsNullOrWhiteSpace(num)) * continue; * barnums[barc] = Convert.ToDecimal(num); * } * }*/ if (string.IsNullOrWhiteSpace(data)) { throw new MessageException("参数不能为空!"); } var requestParams = data.ToObject <SaveTakeStockRequest>(); if (requestParams == null) { throw new MessageException("JSON参数不正确!"); } TakeStockService.SaveStock(requestParams.StoreId, requestParams.CheckBatch, requestParams.UserCode, requestParams.TakeStockList.ToDictionary(o => o.Barcode, o => o.Number)); }