| | |
| | | _invokeERPService = invokeERPService; |
| | | } |
| | | /// <summary> |
| | | /// æ¥æ¶ERPæååºåºå |
| | | /// æ¥æ¶ERPæååºåºåä¿¡æ¯(订ååºåº/å¯å®åºåº) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> ProductDeliveryOrder(ErpProOutOrderDTO outOrderDTO) |
| | |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// éå®ææ´¾ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public async Task<WebResponseContent> ProductSpecifyVer(ErpProductSpecifyVerDTO erpProductSpecifyVerDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x=>x.WarehouseCode==erpProductSpecifyVerDTO.WaType); |
| | | if (warehouse == null) |
| | | return await Task.FromResult(content.Error($"æªæ¾å°{erpProductSpecifyVerDTO.WaType}ä»åºä¿¡æ¯")); |
| | | //æ¥è¯¢å¯ææ´¾åºå |
| | | List<Dt_ProStockInfo> proStockInfos = Db.Queryable<Dt_ProStockInfo>().Where(x => x.ProStockAttribute == ProStockAttributeEnum.æå.ObjToInt()) |
| | | .Includes(x => x.proStockInfoDetails) |
| | | .Where(x => x.proStockInfoDetails |
| | | .Any(v => |
| | | v.SaleOrder == erpProductSpecifyVerDTO.OrderNo |
| | | && v.ProductCode == erpProductSpecifyVerDTO.PCode |
| | | && v.ProductVersion == erpProductSpecifyVerDTO.PVer |
| | | && v.LotNumber == erpProductSpecifyVerDTO.PLot |
| | | && v.DateCode == erpProductSpecifyVerDTO.DateCode |
| | | && (v.SpecifyVer==null||v.SpecifyVer=="") |
| | | )) |
| | | .ToList(); |
| | | List<Dt_ProStockInfoDetail> proStockInfoDetails = new List<Dt_ProStockInfoDetail>(); |
| | | List<Dt_ProStockInfoDetail> specifyVerDetails = new List<Dt_ProStockInfoDetail>(); |
| | | if (proStockInfos==null) |
| | | return await Task.FromResult(content.Error("å¯ææ´¾åºåä¸åå¨")); |
| | | proStockInfos = proStockInfos.OrderBy(x => x.proStockInfoDetails.FirstOrDefault()?.DateCode).ThenBy(x => x.CreateDate).ThenBy(x => x.proStockInfoDetails.Sum(x => x.StockPcsQty)).ToList(); |
| | | foreach (var item in proStockInfos) |
| | | { |
| | | proStockInfoDetails.AddRange(item.proStockInfoDetails); |
| | | } |
| | | if (proStockInfoDetails.Sum(x=>x.StockPcsQty)< erpProductSpecifyVerDTO.QtyPcs) |
| | | return await Task.FromResult(content.Error($"å¯ææ´¾åºåæ°éä¸è¶³,å¯ç¨:{proStockInfoDetails.Sum(x => x.StockPcsQty)}")); |
| | | float overQty = 0; |
| | | foreach (var item in proStockInfoDetails) |
| | | { |
| | | specifyVerDetails.Add(item); |
| | | overQty += item.StockPcsQty; |
| | | //已满足è·åæ°éä¸åæ´æ¹ |
| | | if (overQty>= erpProductSpecifyVerDTO.QtyPcs) |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | specifyVerDetails.ForEach(x => |
| | | { |
| | | x.SpecifyVer = erpProductSpecifyVerDTO.Ver; |
| | | }); |
| | | _unitOfWorkManage.BeginTran(); |
| | | _stockRepository.ProStockInfoDetailRepository.UpdateData(specifyVerDetails); |
| | | _unitOfWorkManage.CommitTran(); |
| | | content.OK("ææ´¾æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _unitOfWorkManage.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return await Task.FromResult(content); |
| | | } |
| | | /// <summary> |
| | | /// æååºå¾
åè´§åº(å¹³åº)+忥ERPåºåº(ç»å®äºåºåºååºå) |
| | | /// </summary> |
| | | /// <returns></returns> |