1
dengjunjie
2025-05-08 092971a8ba7848f024427694c642959d0fbc8599
ÏîÄ¿´úÂë/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/Base/InboundOrderService.cs
@@ -87,7 +87,7 @@
                    if (!content.Status)
                        throw new Exception(content.Message);
                }
                BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
                Db.Ado.CommitTran();
                content = WebResponseContent.Instance.OK();
@@ -111,13 +111,13 @@
            {
                if (saveModel.DetailData == null || saveModel.DetailData.Count == 0) throw new Exception($"入库单明细不能为空");
                List<InboundOrderDetailAddDTO> inboundOrderDetail = saveModel.DetailData.DicToIEnumerable<InboundOrderDetailAddDTO>();
                if (inboundOrderDetail.FirstOrDefault(x => x.OrderDetailStatus > 0) != null) throw new Exception($"订单已开始组盘入库");
                var inboundOrderDetails = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => saveModel.DelKeys.Contains(x.Id)).ToList();
                if (inboundOrderDetails.Count > 0)
                {
                    if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null)
                        throw new Exception($"存在已组盘工单,已先解盘");
                }
                //if (inboundOrderDetail.FirstOrDefault(x => x.OrderDetailStatus > 0) != null) throw new Exception($"订单已开始组盘入库");
                //var inboundOrderDetails = _inboundOrderDetailService.Db.Queryable<Dt_InboundOrderDetail>().Where(x => saveModel.DelKeys.Contains(x.Id)).ToList();
                //if (inboundOrderDetails.Count > 0)
                //{
                //    if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null)
                //        throw new Exception($"存在已组盘工单,已先解盘");
                //}
                content = base.UpdateData(saveModel);
            }
            catch (Exception ex)
@@ -132,19 +132,19 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                var inboundOrders = BaseDal.QueryData(x => keys.Contains(x.Id));
                if (inboundOrders.FirstOrDefault(x => x.OrderStatus != InboundStatusEnum.未开始.ObjToInt()) != null)
                    throw new Exception($"入库单存在组盘入库信息");
                foreach (var inboundOrder in inboundOrders)
                //var inboundOrders = BaseDal.QueryData(x => keys.Contains(x.Id));
                var inboundOrders = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).Where(x => keys.Contains(x.Id)).ToList();
                if (inboundOrders.Count < 1) throw new Exception("未找到入库单");
                List<Dt_InboundOrderDetail> orderDetails = new List<Dt_InboundOrderDetail>();
                foreach (var item in inboundOrders)
                {
                    var inboundOrderDetails = BaseDal.Db.Queryable<Dt_InboundOrder>().Includes(x => x.Details).First(x => x.OrderNo == inboundOrder.OrderNo).Details;
                    if (inboundOrderDetails != null || inboundOrderDetails.Count > 0)
                    {
                        if (inboundOrderDetails.FirstOrDefault(x => x.OrderDetailStatus != OrderDetailStatusEnum.New.ObjToInt()) != null)
                            throw new Exception($"入库单【{inboundOrder.OrderNo}】存在组盘入库信息");
                    }
                    if (item.Details.Where(x => x.ReceiptQuantity != x.OverInQuantity).Any())
                        throw new Exception("存在未入库完成托盘");
                    orderDetails.AddRange(item.Details);
                    item.Details = null;
                }
                content = base.DeleteData(keys);
                BaseDal.DeleteAndMoveIntoHty(inboundOrders, OperateType.人工删除);
                content.Status = _inboundOrderDetailService.Repository.DeleteAndMoveIntoHty(orderDetails, OperateType.人工删除);
            }
            catch (Exception ex)
            {
@@ -177,7 +177,7 @@
                return (false, "有物料信息未录入,请录入物料信息", inboundOrderAddDTO);
            }
            if (BaseDal.QueryFirst(x => x.UpperOrderNo == inboundOrderAddDTO.UpperOrderNo && !string.IsNullOrEmpty(x.UpperOrderNo)) != null)
            if (BaseDal.QueryFirst(x => x.OrderNo == inboundOrderAddDTO.orderNo && !string.IsNullOrEmpty(x.OrderNo)) != null)
            {
                return (false, "单据已存在", inboundOrderAddDTO);
            }