| | |
| | | while (needQuantity > 0) |
| | | { |
| | | Dt_StockInfo stockInfo = stockInfos[index]; |
| | | float useableStockQuantity = stockInfo.Details.Where(x => x.MaterielCode == materielCode).Sum(x => x.StockQuantity - x.OutboundQuantity); |
| | | if (useableStockQuantity < needQuantity && useableStockQuantity>0) |
| | | // 计ç®å¯ç¨åºåæ¶è½¬æ¢ä¸ºdecimal |
| | | decimal useableStockQuantity = stockInfo.Details |
| | | .Where(x => x.MaterielCode == materielCode) |
| | | .Sum(x => (decimal)x.StockQuantity - (decimal)x.OutboundQuantity); |
| | | |
| | | // å°needQuantity转æ¢ä¸ºdecimalè¿è¡æ¯è¾ |
| | | if (useableStockQuantity < (decimal)needQuantity && useableStockQuantity > 0) |
| | | { |
| | | stockInfo.Details.ForEach(x => x.OutboundQuantity = x.StockQuantity); |
| | | needQuantity -= useableStockQuantity; |
| | | stockInfo.Details.ForEach(x => |
| | | x.OutboundQuantity = x.StockQuantity); |
| | | |
| | | // 使ç¨decimalè¿è¡è®¡ç®åå转åfloat |
| | | needQuantity = (float)((decimal)needQuantity - useableStockQuantity); |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode) |
| | | { |
| | | if (x.StockQuantity - x.OutboundQuantity >= needQuantity) |
| | | // å°ç¸å
³å¼è½¬æ¢ä¸ºdecimalè¿è¡ç²¾ç¡®è®¡ç® |
| | | decimal currentStock = (decimal)x.StockQuantity; |
| | | decimal currentOutbound = (decimal)x.OutboundQuantity; |
| | | decimal currentNeed = (decimal)needQuantity; |
| | | decimal available = currentStock - currentOutbound; |
| | | |
| | | if (available >= currentNeed) |
| | | { |
| | | x.OutboundQuantity += needQuantity; |
| | | x.OutboundQuantity = (float)(currentOutbound + currentNeed); |
| | | needQuantity = 0; |
| | | } |
| | | else |
| | | { |
| | | needQuantity -= (x.StockQuantity - x.OutboundQuantity); |
| | | needQuantity = (float)(currentNeed - available); |
| | | x.OutboundQuantity = x.StockQuantity; |
| | | } |
| | | } |
| | |
| | | outStocks.Add(stockInfo); |
| | | index++; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | var requestBody = new |
| | | { |
| | | msgtype = "text", |
| | | text = new { content = "å°æ´ä¸»äººè¯´: å°æ´è¦åå°å¦å¤©ä¸ç¬¬ä¸ææå¥½" }, |
| | | text = new { content = "ééæ¶æ¯æ¨é" }, |
| | | }; |
| | | var jsonBody = JsonConvert.SerializeObject(requestBody); |
| | | var content = new StringContent(jsonBody, Encoding.UTF8, "application/json"); |