| | |
| | | return BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrderNo); ; |
| | | } |
| | | |
| | | public WebResponseContent MaterielGroup(SaveModel saveModel) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | var palletCode = saveModel.MainData["palletCode"].ToString(); |
| | | if (string.IsNullOrEmpty(palletCode)) throw new Exception("æçå·ä¸å¯ä¸ºç©º"); |
| | | var orderNo = saveModel.MainData["orderNo"].ToString(); |
| | | if (string.IsNullOrEmpty(orderNo)) throw new Exception("åå·ä¸å¯ä¸ºç©º"); |
| | | var batchNo = saveModel.MainData["batchNo"].ToString(); |
| | | if (string.IsNullOrEmpty(batchNo)) throw new Exception("æ¹å·ä¸å¯ä¸ºç©º"); |
| | | //var StationCode = saveModel.MainData["address"].ToString(); |
| | | //if (string.IsNullOrEmpty(StationCode)) throw new Exception("å°åä¸å¯ä¸ºç©º"); |
| | | |
| | | //Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.InStationCode == StationCode) ?? throw new Exception("æªæ¾å°è¯¥å
¥åºç«å°ï¼è¯·æ£æ¥åºç¡é
置信æ¯!"); |
| | | Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode); |
| | | if (stockInfo != null) throw new Exception($"æçã{palletCode}ãå·²åå¨åºåä¿¡æ¯"); |
| | | stockInfo = new Dt_StockInfo(); |
| | | stockInfo.Details = new List<Dt_StockInfoDetail>(); |
| | | Dt_InboundOrder? inboundOrder = GetInboundOrder(orderNo); |
| | | if (inboundOrder == null) throw new Exception($"æªæ¾å°åå·ä¸ºã{orderNo}ãçå
¥åºå"); |
| | | Dt_InboundOrderDetail? inboundOrderDetail = inboundOrder.Details.Where(x => x.BatchNo == batchNo).FirstOrDefault(); |
| | | if (inboundOrderDetail == null) throw new Exception($"åå·ã{orderNo}ãçå
¥åºåæªæ¾å°æ¹å·ã{batchNo}ã"); |
| | | if (inboundOrderDetail.OrderQuantity - inboundOrderDetail.ReceiptQuantity < 1) throw new Exception($"åå·ã{orderNo}ãçæ¹å·ã{batchNo}ãå¯ç»çæ°éä¸è¶³"); |
| | | |
| | | #region å¤çå
¥åºå |
| | | inboundOrder.OrderStatus = InboundStatusEnum.å
¥åºä¸.ObjToInt(); |
| | | inboundOrderDetail.ReceiptQuantity++; |
| | | inboundOrderDetail.OrderDetailStatus = inboundOrderDetail.OverInQuantity == inboundOrderDetail.OrderQuantity ? OrderDetailStatusEnum.Over.ObjToInt() : OrderDetailStatusEnum.GroupAndInbound.ObjToInt(); |
| | | #endregion |
| | | |
| | | #region æ·»å åºå |
| | | if (stockInfo.Id == 0) |
| | | { |
| | | stockInfo.PalletCode = palletCode; |
| | | stockInfo.StockStatus = StockStatusEmun.ç»çæå.ObjToInt(); |
| | | stockInfo.Creater = "System"; |
| | | stockInfo.Remark = "人工ç»çå
¥åº"; |
| | | } |
| | | Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail() |
| | | { |
| | | Status = StockStatusEmun.ç»çæå.ObjToInt(), |
| | | OrderNo = inboundOrder.OrderNo, |
| | | StockId = stockInfo.Id != 0 ? stockInfo.Id : 0, |
| | | MaterielName = inboundOrderDetail.MaterielName, |
| | | MaterielCode = inboundOrderDetail.MaterielCode, |
| | | BatchNo = inboundOrderDetail.BatchNo, |
| | | StockQuantity = 1, |
| | | SerialNumber = "", |
| | | Creater = "System" |
| | | }; |
| | | stockInfo.Details.Add(stockInfoDetail); |
| | | #endregion |
| | | Db.Ado.BeginTran(); |
| | | BaseDal.UpdateData(inboundOrder); |
| | | _inboundOrderDetailService.UpdateData(inboundOrderDetail); |
| | | _stockService.StockInfoService.AddMaterielGroup(stockInfo); |
| | | Db.Ado.CommitTran(); |
| | | content.OK(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Db.Ado.RollbackTran(); |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | public WebResponseContent QueryOrderDetailInfo(int pageNo, string orderNo) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | Dt_InboundOrder inboundOrder = GetInboundOrder(orderNo); |
| | | List<Dt_InboundOrderDetail> inboundOrderDetails = inboundOrder.Details; |
| | | content.OK(data: inboundOrderDetails); |
| | | return content; |
| | | } |
| | | /// <summary> |
| | | /// ç»ç |
| | | /// </summary> |
| | |
| | | |
| | | |
| | | Dt_StockInfo? stockInfo = _stockService.StockInfoService.GetStockByPalletCode(materielGroupDTO.PalletCode); |
| | | //if (stockInfo != null) throw new Exception($"æçå·ã{materielGroupDTO.PalletCode}ãå·²åå¨"); |
| | | |
| | | (bool, string, object?) result = CheckMaterielGroupParam(materielGroupDTO, matSerialNumberDTOs, materielInfos, materielCodes, inboundOrder, stockInfo); |
| | | if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2); |
| | |
| | | List<Dt_StockInfoDetail> stockInfoDetails = _mapper.Map<List<Dt_StockInfoDetail>>(matSerialNumberDTOs); |
| | | stockInfoDetails.ForEach(x => |
| | | { |
| | | x.Status = 0; |
| | | //x.Status = 0; |
| | | x.Status = StockStatusEmun.ç»çæå.ObjToInt(); |
| | | x.OrderNo = inboundOrder.OrderNo; |
| | | x.MaterielName = materielInfos.FirstOrDefault(v => v.MaterielCode == x.MaterielCode)?.MaterielName ?? ""; |
| | | x.StockId = stockInfo.Id != 0 ? stockInfo.Id : 0; |
| | |
| | | for (int i = 0; i < materielCodes.Count; i++) |
| | | { |
| | | decimal stockQuantity = stockInfoDetails.Where(x => x.MaterielCode == materielCodes[i]).Sum(x => x.StockQuantity); |
| | | inboundOrderDetails.AddRange(_inboundOrderDetailService.UpdateReceiptQuantity(inboundOrder.Details.Where(x => x.MaterielCode == materielCodes[i]).ToList(), stockQuantity)); |
| | | List<Dt_InboundOrderDetail> orderDetails = inboundOrder.Details.Where(x => x.MaterielCode == materielCodes[i]).ToList(); |
| | | if (orderDetails.Count > 0) |
| | | { |
| | | var OrderQuantity = orderDetails.Sum(x => x.OrderQuantity); |
| | | if (OrderQuantity < stockQuantity) throw new Exception("ç»çæ°éè¶
åºåæ®æ°é"); |
| | | inboundOrderDetails.AddRange(_inboundOrderDetailService.UpdateReceiptQuantity(orderDetails, stockQuantity)); |
| | | } |
| | | } |
| | | List<int> updateDetailIds = inboundOrderDetails.Select(x => x.Id).ToList(); |
| | | if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null && inboundOrder.Details.FirstOrDefault(x => !updateDetailIds.Contains(x.Id) && x.OrderDetailStatus != OrderDetailStatusEnum.Over.ObjToInt()) == null) |
| | | { |
| | | inboundOrder.OrderStatus = InboundStatusEnum.å
¥åºå®æ.ObjToInt(); |
| | | BaseDal.DeleteAndMoveIntoHty(inboundOrder, App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | for (int i = 0; i < inboundOrderDetails.Count; i++) |
| | | { |
| | | _inboundOrderDetailService.Repository.DeleteAndMoveIntoHty(inboundOrderDetails[i], App.User.UserId == 0 ? OperateType.èªå¨å®æ : OperateType.äººå·¥å®æ); |
| | | } |
| | | } |
| | | else if (inboundOrder.OrderStatus == InboundStatusEnum.æªå¼å§.ObjToInt()) |
| | | { |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content = WebResponseContent.Instance.Error(ex.Message); |
| | | content.Error(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | |
| | | return (true, "æå", materielGroupDTO); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// PDAå页æ¥è¯¢æ°æ® |
| | | /// </summary> |
| | | /// <param name="pageNo">页ç </param> |
| | | /// <param name="orderNo">订åå·</param> |
| | | /// <returns></returns> |
| | | public WebResponseContent QueryOrderInfo(int pageNo, string orderNo) |
| | | { |
| | | if (string.IsNullOrEmpty(orderNo)) |