wangxinhui
2025-01-17 c9975ff121d58b1c156f991f978afabd58ae6c00
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/InboundOrderService.cs
@@ -423,7 +423,91 @@
            }
            return content;
        }
        /// <summary>
        /// WMS入平库不推单据
        /// </summary>
        /// <param name="warehouseId"></param>
        /// <param name="serNums"></param>
        /// <returns></returns>
        public WebResponseContent InPinKu(int warehouseId, List<string> serNums)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_Warehouse warehouse = _warehouseService.Repository.QueryFirst(x => x.WarehouseId == warehouseId);
                if (warehouse == null)
                {
                    return WebResponseContent.Instance.Error($"未找到该仓库信息");
                }
                List<MatSerNumAnalysisModel> models = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(AnalysisCodeEnum.MatSerNumAnalysis, serNums);
                if (models.Select(x => x.MaterielCode).Distinct().Count() > 1)
                {
                    return WebResponseContent.Instance.Error($"物料不可混放");
                }
                string materielCode = models.FirstOrDefault()?.MaterielCode ?? "";
                Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == materielCode);
                if (materielInfo == null)
                {
                    return WebResponseContent.Instance.Error($"未找到该物料的信息");
                }
                float beforeQuantity = 0;
                Dt_StockInfo stockInfo = new Dt_StockInfo()
                {
                    PalletCode = DateTime.Now.ToString("yyyyMMddHHmmss"),
                    StockStatus = StockStatusEmun.入库完成.ObjToInt(),
                    WarehouseId = warehouse.WarehouseId,
                    PalletType = PalletTypeEnum.SmallPallet.ObjToInt(),
                    LocationCode = "平库位",
                    Details = new List<Dt_StockInfoDetail>()
                };
                List<Dt_StockInfoDetail> stockInfoDetails = new List<Dt_StockInfoDetail>();
                foreach (var model in models)
                {
                    Dt_StockInfoDetail stockInfoDetail = new Dt_StockInfoDetail()
                    {
                        BatchNo = model.LotNo,
                        MaterielCode = materielInfo.MaterielCode,
                        MaterielName = materielInfo.MaterielName,
                        SerialNumber = model.SerialNumber,
                        StockQuantity = model.Quantity,
                        OutboundQuantity = 0,
                        Unit = materielInfo.MaterielUnit,
                        Status = StockStatusEmun.入库完成.ObjToInt(),
                        ProductionDate = model.ProductionDate,
                        EffectiveDate = model.EffectiveDate,
                    };
                    if (stockInfo.Id > 0)
                    {
                        stockInfoDetail.StockId = stockInfo.Id;
                    }
                    stockInfo.Details.Add(stockInfoDetail);
                    stockInfoDetails.Add(stockInfoDetail);
                }
                float totalQuantity = stockInfo.Details.Sum(x => x.StockQuantity);
                _unitOfWorkManage.BeginTran();
                if (stockInfo.Id == 0)
                {
                    _stockRepository.StockInfoRepository.Db.InsertNav(stockInfo).Include(x => x.Details).ExecuteCommand();
                }
                else
                {
                    _stockRepository.StockInfoRepository.Db.UpdateNav(stockInfo).Include(x => x.Details, new UpdateNavOptions() { OneToManyInsertOrUpdate = true }).ExecuteCommand();
                }
                _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfoDetails, beforeQuantity, totalQuantity, StockChangeTypeEnum.Inbound);
                _unitOfWorkManage.CommitTran();
                content.OK();
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                content.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// ç»„盘
        /// </summary>
@@ -764,6 +848,7 @@
                {
                    foreach (var item in stockInfo.Details.GroupBy(x=>x.InboundOrderRowNo).Select(x=>x.Key))
                    {
                        //区分不同批次
                        Dt_StockInfoDetail? dt_StockInfoDetail = stockInfo.Details.Where(x => x.InboundOrderRowNo == item).FirstOrDefault();
                        ERPInboundDetailModel detailModel = new ERPInboundDetailModel()
                        {