| | |
| | | using WIDESEA_ISquareCabinRepository; |
| | | using WIDESEA_ISquareCabinServices; |
| | | using WIDESEA_Model.Models; |
| | | using WIDESEA_Model.Models.SquareCabin; |
| | | using WIDESEA_SquareCabinRepository; |
| | | using static WIDESEA_DTO.SquareCabin.OrderDto; |
| | | using static WIDESEA_DTO.SquareCabin.TowcsDto; |
| | |
| | | { |
| | | return new ApiResponse<Dt_Inventory> { code ="500",msg = "请æ±åæ°æ æ" }; |
| | | } |
| | | |
| | | BaseDal.Db.Ado.BeginTran();//å¼å¯äºå¡ |
| | | foreach (var detail in request.details) |
| | | { |
| | | // å
æ¥åºåæ¯å¦åå¨ |
| | | var entity = Db.Queryable<Dt_Inventory>() |
| | | .First(x => x.Goods_no == detail.productCode); |
| | | // å
æ¥åºåæ¯å¦åå¨ï¼æç
§äº§åç¼å·åæ¹æ¬¡æ¥å¯»æ¾ï¼ |
| | | var entity = BaseDal.Db.Queryable<Dt_Inventory>() |
| | | .First(x => x.Goods_no == detail.productCode && x.Batch_num == detail.batchNo); |
| | | //å°éåä¸çæ°éè¿è¡ç´¯å |
| | | decimal orderQty = detail.orderDetails?.Sum(x => Convert.ToDecimal(x.quantity)) ?? 0; |
| | | decimal diffQty = detail.stocktakingDetails?.Sum(x => Convert.ToDecimal(x.differenceQuantity)) ?? 0; |
| | | //decimal orderQty = detail.orderDetails?.Sum(x => Convert.ToDecimal(x.quantity)) ?? 0; |
| | | //decimal diffQty = detail.stocktakingDetails?.Sum(x => Convert.ToDecimal(x.differenceQuantity)) ?? 0; |
| | | // å®å
¨è½¬æ¢ |
| | | |
| | | //æ£å¸¸åºå
¥åº |
| | | decimal orderQty = detail.orderDetails?.Sum(x => decimal.TryParse(x.quantity, out var q) ? q : 0) ?? 0; |
| | | //çç¹çäº |
| | | decimal diffQty = detail.stocktakingDetails?.Sum(x => Convert.ToDecimal(x.differenceQuantity)) ?? 0; |
| | | if (entity == null) |
| | | { |
| | | // 妿ä¸åå¨ï¼æ°å»ºä¸æ¡ |
| | |
| | | Goods_no = detail.productCode ?? detail.productName, |
| | | Reservoirarea = "é»è®¤åºåº", |
| | | Batch_num = detail.batchNo, |
| | | //ä¸å¡åºå |
| | | Business_qty = 0, |
| | | //å®é
åºå |
| | | Actual_qty = 0 |
| | | }; |
| | | } |
| | |
| | | { |
| | | foreach (var stock in detail.stocktakingDetails) |
| | | { |
| | | //æ¯æ¬¡é½åªæ¿ä¸æ¡æç»ä¸çæ°é |
| | | decimal diff = Convert.ToDecimal(stock.differenceQuantity); |
| | | if (stock.IsProfit == "1") // çç |
| | | { |
| | | entity.Actual_qty += diff; |
| | | entity.Business_qty += diff;//妿ççäºå¤äºï¼å°±å°ä¸å¡æ°é+ï¼çäºåç¸å |
| | | } |
| | | else // çäº |
| | | { |
| | | entity.Actual_qty -= diff; |
| | | if (entity.Actual_qty < 0) entity.Actual_qty = 0; |
| | | entity.Business_qty -= diff; |
| | | //if (entity.Business_qty < 0) entity.Business_qty = 0; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | // ä¿åæ°æ® |
| | | if (entity.Id == 0) // æ°å»º |
| | | Db.Insertable(entity).ExecuteCommand(); |
| | | BaseDal.Db.Insertable(entity).ExecuteCommand(); |
| | | else // æ´æ° |
| | | Db.Updateable(entity).ExecuteCommand(); |
| | | BaseDal.Db.Updateable(entity).ExecuteCommand(); |
| | | } |
| | | |
| | | BaseDal.Db.Ado.CommitTran(); // æäº¤äºå¡ |
| | | return new ApiResponse<Dt_Inventory> {code = "0", msg = "æå" }; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | BaseDal.Db.Ado.RollbackTran();//åæ»äºå¡ |
| | | return new ApiResponse<Dt_Inventory> { code = "500", msg = ex.Message }; |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ¨éå¼å¸¸ä¿¡æ¯ç»ä¸æ¸¸ç³»ç»1.å
¥åºåæ¥å£ï¼2.å
¥åºåæ¥å®ææ¥å£ï¼3.åºåºåæ¥å£ï¼4.åºåºæ¥å®ææ¥å£ï¼5.è¯ååºç¡ä¿¡æ¯åæ¥æ¥å£ï¼6.ä¾åºåä¿¡æ¯æ¥å£ï¼7.客æ·ä¿¡æ¯æ¥å£ï¼8.åºå |
| | | /// </summary> |