wangxinhui
2025-08-30 cd78554c3da306ed8c866d971bee94457665f80c
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs
@@ -53,7 +53,7 @@
                {
                    return WebResponseContent.Instance.Error($"未找到组盘信息");
                }
                if (stockInfo.StockStatus != StockStatusEmun.退库.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES退库.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES空托退库.ObjToInt())
                if (stockInfo.StockStatus != StockStatusEmun.MES余料退库.ObjToInt() && stockInfo.StockStatus != StockStatusEmun.MES空托退库.ObjToInt())
                {
                    return WebResponseContent.Instance.Error($"该托盘状态不正确,不可申请入库");
                }
@@ -81,22 +81,6 @@
                if (stockInfo.StockStatus == StockStatusEmun.手动组盘暂存.ObjToInt())
                {
                    stockInfo.StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt();
                }
                else if (stockInfo.StockStatus == StockStatusEmun.MES退库.ObjToInt())
                {
                    newTask.TaskType = TaskTypeEnum.MesMatReturn.ObjToInt();
                }
                else if (stockInfo.StockStatus == StockStatusEmun.MES空托退库.ObjToInt())
                {
                    //todo å°æ‰˜ç›˜æš‚时未启用
                    if (stockInfo.PalletType == PalletTypeEnum.MediumPallet.ObjToInt())
                    {
                        newTask.TaskType = TaskTypeEnum.MesPalletLargeReturn.ObjToInt();
                    }
                    else
                    {
                        newTask.TaskType = TaskTypeEnum.MesPalletSmallReturn.ObjToInt();
                    }
                }
                else
                {
@@ -246,7 +230,7 @@
                    {
                        agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
                    }
                    Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == task.PalletCode);
                    Dt_ProStockInfo proStockInfo = _stockRepository.ProStockInfoRepository.Db.Queryable<Dt_ProStockInfo>().Where(x => x.PalletCode == task.PalletCode).Includes(x=>x.proStockInfoDetails).First();
                    if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.MES空托退库.ObjToInt())
                    {
                        task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
@@ -258,6 +242,26 @@
                        proStockInfo.LocationCode = locationInfoEnd.LocationCode;
                        proStockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                        _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo);
                        _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId);
                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.人工完成 : WIDESEA_Core.Enums.OperateTypeEnum.自动完成);
                        _unitOfWorkManage.CommitTran();
                    }
                    else if (proStockInfo != null && proStockInfo.StockStatus == StockStatusEmun.手动组盘入库确认.ObjToInt())
                    {
                        task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
                        proStockInfo.proStockInfoDetails.ForEach(x =>
                        {
                            x.ProStockDetailStatus = StockStatusEmun.入库完成.ObjToInt();
                        });
                        _unitOfWorkManage.BeginTran();
                        if (agvstation != null)
                        {
                            _agvStationInfoRepository.UpdateData(agvstation);
                        }
                        proStockInfo.LocationCode = locationInfoEnd.LocationCode;
                        proStockInfo.StockStatus = StockStatusEmun.入库完成.ObjToInt();
                        _stockRepository.ProStockInfoRepository.UpdateData(proStockInfo);
                        _stockRepository.ProStockInfoDetailRepository.UpdateData(proStockInfo.proStockInfoDetails);
                        _basicService.LocationInfoService.UpdateLocationStatus(locationInfoEnd, proStockInfo.PalletType, LocationStatusEnum.InStock, proStockInfo.WarehouseId);
                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.人工完成 : WIDESEA_Core.Enums.OperateTypeEnum.自动完成);
                        _unitOfWorkManage.CommitTran();
@@ -339,6 +343,7 @@
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// å…¥åº“任务申请分配货位
        /// </summary>
@@ -376,7 +381,7 @@
                {
                    task.TaskStatus = TaskStatusEnum.SC_Execute.ObjToInt();
                }
                LocationStatusEnum lastStatus = (LocationStatusEnum)locationInfo.LocationStatus;
                //更新锁定货位
@@ -521,6 +526,103 @@
            }
            return content;
        }
        private readonly static object _lockerFL = new object();
        /// <summary>
        /// è¾…料入库
        /// </summary>
        /// <returns></returns>
        public WebResponseContent InboundFLTask(string barCode, string startPoint,string matCode,int matCount)
        {
            lock (_lockerFL)
            {
                WebResponseContent content = new WebResponseContent();
                try
                {
                    //string palletCode = @"^C\d{5}$";  // æ­£åˆ™è¡¨è¾¾å¼
                    //bool isValid = Regex.IsMatch(barCode, palletCode);
                    //if (!isValid)
                    //{
                    //    return content.Error($"框码格式错误{barCode}");
                    //}
                    Dt_MaterielInfo materielInfo = _basicRepository.MaterielInfoRepository.QueryFirst(x => x.MaterielCode == matCode && x.MaterielInvOrgId == MaterielInvOrgEnum.新厂.ObjToInt() && x.MaterielSourceType == MaterielTypeEnum.辅料备件.ObjToInt());
                    if (materielInfo == null)
                    {
                        return content.Error($"未找到物料信息{matCode}");
                    }
                    Dt_AGVStationInfo agvstation = _agvStationInfoRepository.QueryFirst(x => x.AGVStationCode == startPoint);
                    if (agvstation == null)
                    {
                        return content.Error($"起点错误{startPoint}");
                    }
                    //判断当前点位是否重复
                    Dt_Task taskOldPoint = BaseDal.QueryFirst(x => x.SourceAddress == startPoint && (x.TaskStatus == TaskStatusEnum.New.ObjToInt() || x.TaskStatus == TaskStatusEnum.AGV_Executing.ObjToInt()));
                    if (taskOldPoint != null)
                    {
                        return content.Error($"站点{startPoint}已存在任务");
                    }
                    Dt_Task taskOld = BaseDal.QueryFirst(x => x.PalletCode == barCode);
                    if (taskOld != null)
                    {
                        return content.Error($"托盘{barCode}任务已存在");
                    }
                    Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
                    if (proStockInfoOld != null)
                    {
                        return content.Error($"托盘{barCode}已存在");
                    }
                    //分配巷道
                    string roadWay = AssignCPRoadwayNo();
                    //获取成品库
                    Dt_Warehouse warehouse = _basicRepository.WarehouseRepository.QueryFirst(x => x.WarehouseCode == WarehouseEnum.LLDCP.ToString());
                    Dt_ProStockInfoDetail proStockInfoDetail = new Dt_ProStockInfoDetail()
                    {
                        ProductCode = matCode,
                        StockQty = matCount,
                        ProStockDetailStatus = StockStatusEmun.手动组盘入库确认.ObjToInt()
                    };
                    Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
                    {
                        PalletCode = barCode,
                        ProStockAttribute = ProStockAttributeEnum.辅料备件.ObjToInt(),
                        PalletType = 1,
                        LocationCode = "",
                        WarehouseId = warehouse.WarehouseId,
                        StockStatus = StockStatusEmun.手动组盘入库确认.ObjToInt(),
                        proStockInfoDetails = new List<Dt_ProStockInfoDetail> { proStockInfoDetail }
                    };
                    Dt_Task newTask = new Dt_Task()
                    {
                        CurrentAddress = startPoint,
                        Grade = 0,
                        NextAddress = "",
                        PalletCode = barCode,
                        Roadway = roadWay,
                        SourceAddress = startPoint,
                        TargetAddress = "",
                        TaskType = TaskTypeEnum.Inbound.ObjToInt(),
                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
                        WarehouseId = warehouse.WarehouseId,
                        PalletType = 1
                    };
                    _unitOfWorkManage.BeginTran();
                    int taskId = BaseDal.AddData(newTask);
                    BaseDal.Db.InsertNav(proStockInfo).Include(x => x.proStockInfoDetails).ExecuteCommand();
                    newTask.TaskId = taskId;
                    _unitOfWorkManage.CommitTran();
                    //推送任务
                    PushTasksToWCS(new List<Dt_Task> { newTask }, "AGV");
                    content.OK("发送成功");
                }
                catch (Exception ex)
                {
                    _unitOfWorkManage.RollbackTran();
                    content.Error(ex.Message);
                }
                return content;
            }
        }
        /// <summary>
        /// å°åˆ·ä½™æ–™é€€æ–™ä»»åŠ¡
        /// </summary>
@@ -581,7 +683,7 @@
                    Roadway = "",
                    SourceAddress = address,
                    TargetAddress = "",
                    TaskType = TaskTypeEnum.PrintBackInbound.ObjToInt(),
                    TaskType = TaskTypeEnum.PrintYLBackInbound.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = warehouseId,
                    PalletType = 1,
@@ -667,7 +769,7 @@
                    Roadway = "",
                    SourceAddress = address,
                    TargetAddress = "",
                    TaskType = TaskTypeEnum.PrintInbound.ObjToInt(),
                    TaskType = TaskTypeEnum.PrintYLInbound.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = warehouseId,
                    PalletType = 1,