1
wankeda
2025-03-07 b55d324f4b7465f9a7dc50e999346697f5cc35a2
WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Inbound.cs
@@ -20,56 +20,10 @@
{
    public partial class TaskService
    {
        /// <summary>
        /// PDA申请入库--堆垛机立库入库
        /// </summary>
        /// <param name="stationCode">起始地址</param>
        /// <param name="taskType">任务类型--入空,入料</param>
        /// <param name="palletCode">托盘编号</param>
        /// <returns>返回处理结果</returns>
        public WebResponseContent GenerateInboundTask(string stationCode, int taskType, string palletCode)
        {
            string? name = Enum.GetName(typeof(TaskTypeEnum), taskType);
            MethodInfo? methodInfo = GetType().GetMethod(name + "Request");
            if (methodInfo != null)
            {
                WebResponseContent? responseContent = (WebResponseContent?)methodInfo.Invoke(this, new object[] { stationCode, palletCode });
                if (responseContent != null)
                {
                    return responseContent;
                }
            }
            else
            {
                return WebResponseContent.Instance.Error("未找到该任务类型业务");
            }
            return WebResponseContent.Instance.Error("错误");
        }
        /// <summary>
        /// 空托盘入库
        /// </summary>
        /// <param name="stationCode">起始地址</param>
        /// <param name="palletCode">托盘编号</param>
        /// <returns>返回处理结果</returns>
        public WebResponseContent PalletInboundRequest(string stationCode, string palletCode)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                (bool, string) result = CheckRequestInbound(stationCode, palletCode, false);
                if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
                content = AssignLocUpdateData(stationCode, TaskTypeEnum.PalletInbound.ObjToInt(), palletCode, false);
            }
            catch (Exception ex)
            {
                content = WebResponseContent.Instance.Error(ex.Message);
            }
            return content;
        }
        /// <summary>
        /// 物料入库
        /// 立库入库指令上传
        /// </summary>
        /// <param name="stationCode">起始地址</param>
        /// <param name="palletCode">托盘编号</param>
@@ -77,29 +31,26 @@
        public WebResponseContent InboundRequest(SaveModel saveModel)
        {
            string palletCode = saveModel.palletCode;
            if (saveModel.palletCode == null) return WebResponseContent.Instance.Error($"请输入正确托盘号");
            WebResponseContent content = new WebResponseContent();
            try
            {
                Dt_InboundOrderDetail inboundOrderDet = BaseDal.Db.Queryable<Dt_InboundOrderDetail>().Where(x => x.LPNNo == palletCode).First();
                Dt_InboundOrder inboundOrder = BaseDal.Db.Queryable<Dt_InboundOrder>().Where(x => x.Id == inboundOrderDet.OrderId).Includes(x => x.Details).First();
                Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.RoadwayNo == inboundOrder.OutWareHouse);
                if (inboundOrder == null)
                {
                    return WebResponseContent.Instance.Error($"未找到入库单信息");
                }
                Dt_Warehouse warehouse = _basicService.WarehouseService.Repository.QueryFirst(x => x.WarehouseId == inboundOrder.WarehouseId);
                Dt_RoadwayInfo roadwayInfo = _basicService.RoadwayInfoService.Repository.QueryFirst(x => x.RoadwayNo == warehouse.WarehouseCode);
                if (roadwayInfo != null) { }
                if (inboundOrder.Details == null || inboundOrder.Details.Count <= 0)
                {
                    return WebResponseContent.Instance.Error($"未找到入库单明细信息");
                }
                Dt_StockInfo stockInfo1 = BaseDal.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
                if (stockInfo1 != null)
                {
                    return WebResponseContent.Instance.Error($"已存在此托盘库存信息");
                }
                //Dt_InboundOrder dt_Int = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.UpperOrderNo == palletCode);
                //Dt_InboundOrderDetail dt_InboundOrderDetail = _inboundService.InboundOrderDetailService.Repository.QueryFirst(x => x.OrderId == dt_Int.Id);
                if (inboundOrder != null)
                if (stockInfo1 == null)
                {
                    Dt_StockInfo dt_Stock = new()
                    {
@@ -115,10 +66,8 @@
                        Mgeneratetime = DateTime.Now,
                    };
                    _stockService.StockInfoService.Repository.AddData(dt_Stock);
                }
                Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode);
                if (inboundOrderDet != null)
                {
                    Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.GetStockInfo(palletCode);
                    Dt_StockInfoDetail dt_StockInfoDetail = new()
                    {
                        StockId = dt_StockInfo.Id,
@@ -129,7 +78,7 @@
                        LinId = inboundOrderDet.LinId,                    //SerialNumber = targetCodes[2].ToString(),    //包号
                                                                          //BatchNoName = dt_Int.OrderNo,
                        StockQuantity = inboundOrderDet.OrderQuantity,    //重量
                        //OutboundQuantity = 1,    //序列号
                                                                          //OutboundQuantity = 1,    //序列号
                        Status = (int)StockStatusEmun.组盘暂存,
                        Creater = "WMS",
                        CreateDate = DateTime.Now,
@@ -150,7 +99,7 @@
        }
        public string ReceiveWMSInventoryIn = WIDESEA_Core.Helper.AppSettings.Configuration["ReceiveWMSInventoryIn"];
        /// <summary>
        /// 盘点入库
        /// 盘点差异数量回传
        /// </summary>
        /// <returns></returns>
        public WebResponseContent InventoryIn(string name, int qty)
@@ -160,7 +109,6 @@
            {
                Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == name);
                Dt_StockInfoDetail stockInfoDetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id);
                //Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.OrderNo == stockInfoDetail.OrderNo);
                Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderDetailService.Repository.QueryFirst(x => x.LPNNo == stockInfo.PalletCode);
                Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetail.OrderId);
                HouseInventoryIn houseInboundPassBack = new HouseInventoryIn();
@@ -203,18 +151,6 @@
                    houseInboundPassBack.Context.Add("InvOrgId", InvOrgId);
                    var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSInventoryIn, houseInboundPassBack, "立库入库数量回传WMS");
                }
                //          #region 验证数据
                //(bool, string, object ?) result = CheckInboundOrderAddData(orderAddDTO1);
                //          if (!result.Item1) return content = WebResponseContent.Instance.Error(result.Item2);
                //          #endregion
                //          Dt_OutboundOrder inboundOrder = _mapper.Map<Dt_OutboundOrder>(orderAddDTO1);
                //          inboundOrder.OrderStatus = InboundStatusEnum.未开始.ObjToInt();
                //          inboundOrder.OrderType = OutOrderTypeEnum.OutInventory.ObjToInt();
                //          inboundOrder.Creater = "WMS";
                //          inboundOrder.CreateDate = DateTime.Now;
                //          bool a = BaseDal.Db.InsertNav(inboundOrder).Include(x => x.Details).ExecuteCommand();
                content = WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
@@ -290,7 +226,7 @@
                        _basicService.LocationInfoService.UpdateLocationLock(locationInfo, task.TaskNum, StockChangeType.Inbound.ObjToInt(), false);
                    }
                    //下发入库任务至WCS
                    var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, task, "下发任务入库");
                    //var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, task, "下发任务入库");
                    dt_Int.OrderStatus = InboundStatusEnum.入库中.ObjToInt();
                    _inboundService.InbounOrderService.Repository.UpdateData(dt_Int);
                    _basicService.LocationInfoService.Repository.UpdateData(locationInfo);
@@ -320,10 +256,10 @@
            {
                return (false, "该托盘号已有任务");
            }
            //if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null)
            //{
            //    return (false, "当前入库站台已有一条新建任务");
            //}
            if (BaseDal.QueryFirst(x => (x.SourceAddress == stationCode || x.CurrentAddress == stationCode) && x.TaskStatus == InTaskStatusEnum.InNew.ObjToInt()) != null)
            {
                return (false, "当前入库站台已有一条新建任务");
            }
            if (isCheckStock)
            {
                if (stockInfo == null)
@@ -866,20 +802,5 @@
        //        throw;
        //    }
        //}
        public WebResponseContent PalletQueryinventory()
        {
            WebResponseContent content = new WebResponseContent();
            List<Dt_LocationInfo> locationinfoData = _basicService.LocationInfoService.Repository.QueryData(x => x.RoadwayNo == "2" && x.LocationStatus == LocationStatusEnum.Free.ObjToInt()
            && x.LocationType == (int)LocationTypeEnum.EmptyCube && x.EnableStatus == (int)EnableStatusEnum.Normal);
            if (locationinfoData.Count < 20)
            {
                return content = WebResponseContent.Instance.OK(data: 1);
            }
            else
            {
                return content = WebResponseContent.Instance.OK(data: 3);
            }
        }
    }
}