dengjunjie
6 天以前 4f39dcc195f28fa275fc2d065fbf1bf6a46c21b7
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Service/InboundOrderService.cs
@@ -36,6 +36,81 @@
            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>