刘磊
2024-12-18 c1f28a6c63036b7e105f578a47d9348812710dad
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -1,4 +1,5 @@
using Masuit.Tools;
using log4net.Core;
using Masuit.Tools;
using WIDESEA_Core.Const;
using WIDESEA_DTO.MOM;
using WIDESEA_DTO.WMS;
@@ -365,6 +366,7 @@
    #region 库位分配
    #region 获取货位
    /// <summary>
    ///
    /// </summary>
@@ -373,8 +375,6 @@
    /// <returns></returns>
    private async Task<DtLocationInfo> RequestLocation(RequestTaskDto requestTask, bool isCheckRequest = false)
    {
        #region 获取货位
        try
        {
            List<DtLocationInfo> locations;
@@ -400,8 +400,9 @@
            return null;
        }
        #endregion 获取货位
    }
    #endregion 获取货位
    #endregion 库位分配
@@ -486,25 +487,69 @@
            return content.Error(ex.Message);
        }
    }
    #endregion
    #region 异常口任务检测
    public async Task<Dt_Task> CheckAbnormalTaskAsync(RequestTaskDto input, Dt_StationManager stationManager)
    {
        try
        {
            if (stationManager.stationType == 15) throw new Exception("");
            // 创建一个TrayCellsStatusDto对象,并赋值
            TrayCellsStatusDto trayCells = new TrayCellsStatusDto()
            {
                Software = "WMS",
                TrayBarcode = input.PalletCode,
                //EquipmentCode = "EQ_CWJZ01"
                EquipmentCode = input.EquiCodeMOM
                EquipmentCode = input.EquiCodeMOM,
                SceneType = "1",
            };
            // 调用GetTrayCellStatusAsync方法,获取整盘电芯
            WebResponseContent content = await GetTrayCellStatusAsync(trayCells);
            // 如果状态为false,则返回content
            if (!content.Status)  //先用实框正常获取整盘电芯数据, 如异常 在次使用空框类型再次获取 再有异常则抛出
            {
                TrayCellsStatusDto trayCells_Empty = new TrayCellsStatusDto()
                {
                    Software = "WMS",
                    TrayBarcode = input.PalletCode,
                    //EquipmentCode = "EQ_CWJZ01"
                    EquipmentCode = input.EquiCodeMOM,
                    SceneType = "4"
                };
                content = await GetTrayCellStatusAsync(trayCells);
            if (!content.Status) throw new Exception(content.Message);
                if (content.Status)   //当做空框入库
                {
                    DtLocationInfo EmptylocationInfo = await RequestLocation(input);
                    if (EmptylocationInfo == null) throw new Exception("库位已满");
                    var Epmtytask = new Dt_Task
                    {
                        CurrentAddress = input.Position,
                        Grade = 3,  //优先处理异常排出口的任务 防止正常需排出异常口的任务堵线
                        Roadway = input.Roadways,
                        TargetAddress = EmptylocationInfo.LocationCode,
                        Dispatchertime = DateTime.Now,
                        MaterialNo = "",
                        NextAddress = input.Roadways,
                        OrderNo = null,
                        PalletCode = input.PalletCode,
                        SourceAddress = stationManager.stationLocation,
                        TaskState = (int)TaskInStatusEnum.Line_InFinish,
                        TaskType = (int)TaskInboundTypeEnum.Inbound,
                        TaskNum = await BaseDal.GetTaskNo(),
                        Creater = "Systeam"
                    };
                    return Epmtytask;
                }
            }
            // 添加组盘信息
            // 将content.Data转换为ResultTrayCellsStatus对象
@@ -512,24 +557,25 @@
            if (result.SerialNos.Count <= 0)
            {
                ConsoleHelper.WriteErrorLine(result.MOMMessage);
                var taskNG = new Dt_Task
                {
                    CurrentAddress = input.Position,
                    Grade = 1,
                    Roadway = input.Roadways,
                    TargetAddress = stationManager.stationNGLocation,
                    Dispatchertime = DateTime.Now,
                    MaterialNo = "",
                    NextAddress = stationManager.stationNGChildCode,
                    OrderNo = null,
                    PalletCode = input.PalletCode,
                    SourceAddress = stationManager.stationLocation,
                    TaskState = (int)TaskInStatusEnum.Line_InFinish,
                    TaskType = (int)TaskOutboundTypeEnum.InToOut,
                    TaskNum = await BaseDal.GetTaskNo(),
                    Creater = "Systeam"
                };
                return taskNG;
                throw new Exception("无电芯数据");
                //var taskNG = new Dt_Task
                //{
                //    CurrentAddress = input.Position,
                //    Grade = 1,
                //    Roadway = input.Roadways,
                //    TargetAddress = stationManager.stationNGLocation,
                //    Dispatchertime = DateTime.Now,
                //    MaterialNo = "",
                //    NextAddress = stationManager.stationNGChildCode,
                //    OrderNo = null,
                //    PalletCode = input.PalletCode,
                //    SourceAddress = stationManager.stationLocation,
                //    TaskState = (int)TaskInStatusEnum.Line_InFinish,
                //    TaskType = (int)TaskOutboundTypeEnum.InToOut,
                //    TaskNum = await BaseDal.GetTaskNo(),
                //    Creater = "Systeam"
                //};
                //return taskNG;
            }
            //Console.WriteLine(result);
@@ -558,20 +604,33 @@
            ////var processResponse = await GetProcessResponseAsync(process, input.Position);
            var isBox = await _boxingInfoRepository.AddDataNavAsync(boxing);
            DtLocationInfo locationInfo = null;
            if (stationManager.Roadway.Contains("FR"))
            {
                locationInfo = await RequestLocation(input, true);
            }
            else
            {
                locationInfo = await RequestLocation(input);
            }
            //DtLocationInfo locationInfo = await RequestLocation(input);
            if (locationInfo == null) throw new Exception("库位已满");
            var task = new Dt_Task
            {
                CurrentAddress = input.Position,
                Grade = 1,
                Grade = 3,  //优先处理异常排出口的任务 防止正常需排出异常口的任务堵线
                Roadway = input.Roadways,
                TargetAddress = stationManager.stationLocation,
                TargetAddress = locationInfo.LocationCode,
                Dispatchertime = DateTime.Now,
                MaterialNo = "",
                NextAddress = input.Roadways,
                OrderNo = null,
                //PalletCode = stockinfo.PalletCode,
                //SourceAddress = stockinfo.LocationCode,
                TaskState = (int)TaskOutStatusEnum.OutNew,
                TaskType = (int)TaskOutboundTypeEnum.OutTray,
                PalletCode = input.PalletCode,
                SourceAddress = stationManager.stationLocation,
                TaskState = (int)TaskInStatusEnum.Line_InFinish,
                TaskType = (int)TaskInboundTypeEnum.Inbound,
                TaskNum = await BaseDal.GetTaskNo(),
                Creater = "Systeam"
            };
@@ -766,7 +825,7 @@
        {
            Dt_StationManager station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == json.Position);
            DtStockInfo stockInfo = _stockInfoRepository.QueryFirst(X => X.IsFull && X.AreaCode == "CWSC3" && X.ProductionLine == "ZJ-7");
            DtStockInfo stockInfo = _stockInfoRepository.QueryFirst(X => X.IsFull && X.AreaCode == "CWSC3" && X.ProductionLine == station.productLine);
            if (stockInfo == null) throw new Exception("库内无满足条件的库存可出库");
            Dt_StationManager OutStation = _stationManagerRepository.QueryFirst(x => x.stationPLC == "1016" && x.stationType == 10);