wangxinhui
2026-02-10 25d4333015921e7a2445564e7099c1503e0a2eac
ÏîÄ¿´úÂë/WMS/WMSServices/WIDESEA_TaskInfoService/TaskService_Inbound.cs
@@ -21,6 +21,7 @@
using WIDESEA_Common.TaskEnum;
using WIDESEA_Common.WareHouseEnum;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.Basic;
@@ -228,6 +229,11 @@
                        //记录库存变动
                        _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfoOld, oldQty, oldQty < stockInfoOld.StockLength ? stockInfoOld.StockLength- oldQty: oldQty- stockInfoOld.StockLength, StockChangeTypeEnum.MaterielGroup);
                        return content.OK($"老厂领料退库RFID{stockInfoOld.RfidCode}条码{stockInfoOld.PalletCode}");
                    }
                    else if (stockInfoOld != null && stockInfoOld.MaterielInvOrgId == MaterielInvOrgEnum.老厂.ObjToInt() && stockInfoOld.StockStatus == StockStatusEmun.出库完成.ObjToInt() && stockInfoOld.StockLength<=0 && stationCode.IsNullOrEmpty())
                    {
                        _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfoOld, App.User.UserId > 0 ? OperateTypeEnum.人工完成 : OperateTypeEnum.自动完成);
                        throw new Exception($"{palletCode}RFID信息老厂领料后无库存退料");
                    }
                    else if (stockInfoOld != null)
                    {
@@ -982,6 +988,19 @@
                    {
                        agvstation.IsOccupied = WhetherEnum.False.ObjToInt();
                    }
                    //叠盘任务单独完成
                    if (task.TaskType==TaskTypeEnum.EmptyStackPlate.ObjToInt())
                    {
                        task.TaskStatus = TaskStatusEnum.Finish.ObjToInt();
                        _unitOfWorkManage.BeginTran();
                        if (agvstation != null)
                        {
                            _basicRepository.AGVStationInfoRepository.UpdateData(agvstation);
                        }
                        BaseDal.DeleteAndMoveIntoHty(task, App.User.UserId > 0 ? WIDESEA_Core.Enums.OperateTypeEnum.人工完成 : WIDESEA_Core.Enums.OperateTypeEnum.自动完成);
                        _unitOfWorkManage.CommitTran();
                        return content.OK();
                    }
                    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())
                    {
@@ -1226,7 +1245,7 @@
        /// <summary>
        /// æˆå“ç©ºæ‰˜å›žåº“
        /// </summary>
        public WebResponseContent EmptyBackTask(string barCode, string startPoint)
        public WebResponseContent EmptyBackTask(string barCode, string startPoint,int target)
        {
            WebResponseContent content = new WebResponseContent();
            try
@@ -1253,41 +1272,64 @@
                {
                    return content.Error($"托盘{barCode}任务已存在");
                }
                Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
                if (proStockInfoOld!=null)
                Dt_Task newTask = null;
                Dt_ProStockInfo proStockInfo = null;
                if (target==WhetherEnum.False.ObjToInt())//叠盘空托任务
                {
                    return content.Error($"托盘{barCode}已存在");
                    newTask = new Dt_Task()
                    {
                        CurrentAddress = startPoint,
                        Grade = 0,
                        NextAddress = "",
                        PalletCode = barCode,
                        Roadway = agvstation.AGVStationCode.StartsWith("PNT_1") ? "StackPlate1": "StackPlate2",
                        SourceAddress = startPoint,
                        TargetAddress = "",
                        TaskType = TaskTypeEnum.EmptyStackPlate.ObjToInt(),
                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
                        WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
                        PalletType = 1
                    };
                }
                //分配巷道
                string roadWay=AssignCPRoadwayNo();
                Dt_ProStockInfo proStockInfo = new Dt_ProStockInfo()
                else //立库空托任务
                {
                    PalletCode=barCode,
                    ProStockAttribute=ProStockAttributeEnum.空托.ObjToInt(),
                    PalletType=1,
                    LocationCode="",
                    WarehouseId= WarehouseEnum.LLDFL.ObjToInt(),
                    StockStatus=StockStatusEmun.MES空托退库.ObjToInt()
                };
                Dt_Task newTask = new Dt_Task()
                {
                    CurrentAddress = startPoint,
                    Grade = 0,
                    NextAddress = "",
                    PalletCode = barCode,
                    Roadway = roadWay,
                    SourceAddress = startPoint,
                    TargetAddress = "",
                    TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
                    TaskStatus = TaskStatusEnum.New.ObjToInt(),
                    WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
                    PalletType = 1
                };
                    Dt_ProStockInfo proStockInfoOld = _stockRepository.ProStockInfoRepository.QueryFirst(x => x.PalletCode == barCode);
                    if (proStockInfoOld != null)
                    {
                        return content.Error($"托盘{barCode}已存在");
                    }
                    //分配巷道
                    string roadWay = AssignCPRoadwayNo();
                    proStockInfo = new Dt_ProStockInfo()
                    {
                        PalletCode = barCode,
                        ProStockAttribute = ProStockAttributeEnum.空托.ObjToInt(),
                        PalletType = 1,
                        LocationCode = "",
                        WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
                        StockStatus = StockStatusEmun.MES空托退库.ObjToInt()
                    };
                    newTask = new Dt_Task()
                    {
                        CurrentAddress = startPoint,
                        Grade = 0,
                        NextAddress = "",
                        PalletCode = barCode,
                        Roadway = roadWay,
                        SourceAddress = startPoint,
                        TargetAddress = "",
                        TaskType = TaskTypeEnum.EmptyProductBack.ObjToInt(),
                        TaskStatus = TaskStatusEnum.New.ObjToInt(),
                        WarehouseId = WarehouseEnum.LLDFL.ObjToInt(),
                        PalletType = 1
                    };
                }
                _unitOfWorkManage.BeginTran();
                int taskId = BaseDal.AddData(newTask);
                _stockRepository.ProStockInfoRepository.AddData(proStockInfo);
                if (proStockInfo!=null)
                {
                    _stockRepository.ProStockInfoRepository.AddData(proStockInfo);
                }
                newTask.TaskId = taskId;
                _unitOfWorkManage.CommitTran();
                //推送任务