刘磊
2024-12-10 53db158b8018fba144a937cf1749cce050855c7a
同步
已修改8个文件
397 ■■■■ 文件已修改
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs 313 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Common/TaskEnum/TaskTypeEnum.cs
@@ -73,9 +73,9 @@
        OutTray = 104,
        /// <summary>
        /// 空托盘出库
        /// NG出库
        /// </summary>
        [Description("空托盘出库")]
        [Description("NG出库")]
        OutNG = 105,
        /// <summary>
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_ITaskInfoService/ITaskService.cs
@@ -250,5 +250,12 @@
        /// <param name="Roadway"></param>
        /// <returns></returns>
        Dt_Task QueryTaskByPalletCode(string palletCode, string Roadway);
        /// <summary>
        /// 查询当前设备是否有移库任务
        /// </summary>
        /// <param name="deviceNo"></param>
        /// <returns></returns>
        Dt_Task QueryRelocationTask(string deviceNo);
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Partial/TaskService.cs
@@ -146,6 +146,15 @@
                    task.NextAddress = stationinfo.stationChildCode;
                    task.TargetAddress = taskDTO.TargetAddress;
                }
                else if (task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.RelocationGroup)
                {
                    task.TaskState = (int)TaskStatus.Created;
                    task.SourceAddress = taskDTO.SourceAddress;
                    task.CurrentAddress = taskDTO.SourceAddress;
                    task.NextAddress = taskDTO.TargetAddress;
                    task.TargetAddress = taskDTO.TargetAddress;
                }
                BaseDal.AddData(task);
                _taskExecuteDetailService.AddTaskExecuteDetail(task.WMSId, "接收WMS任务");
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs
@@ -731,5 +731,10 @@
            }
            return content;
        }
        public Dt_Task QueryRelocationTask(string deviceNo)
        {
            return BaseDal.QueryFirst(x => x.Roadway == deviceNo && x.TaskType == (int)TaskRelocationTypeEnum.Relocation && x.TaskState == (int)TaskStatus.Created);
        }
    }
}
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
@@ -116,6 +116,13 @@
        private Dt_Task? GetTask(CommonStackerStationCrane commonStackerCrane)
        {
            Dt_Task task;
            task = _taskService.QueryRelocationTask(commonStackerCrane.DeviceCode);
            if (task != null)
            {
                return task;
            }
            if (commonStackerCrane.LastTaskType == null)
            {
                task = _taskService.QueryStackerCraneTask(commonStackerCrane.DeviceCode);
@@ -207,7 +214,7 @@
            string[] sourceCodes = task.SourceAddress.Split("-");
            if (sourceCodes.Length == 3)
            {
                stackerCraneTaskCommand.StartRow = (short)(Convert.ToInt16(sourceCodes[0]) % 2 == 0 ? 2:1);
                stackerCraneTaskCommand.StartRow = (short)(Convert.ToInt16(sourceCodes[0]) % 2 == 0 ? 2 : 1);
                stackerCraneTaskCommand.StartColumn = Convert.ToInt16(sourceCodes[1]);
                stackerCraneTaskCommand.StartLayer = Convert.ToInt16(sourceCodes[2]);
            }
@@ -239,7 +246,7 @@
                //}
                //else
                //{
                //}
                stackerCraneTaskCommand.EndRow = (short)(Convert.ToInt16(targetCodes[0]) % 2 == 0 ? 2 : 1);
                stackerCraneTaskCommand.EndColumn = Convert.ToInt16(targetCodes[1]);
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/NotifyFinishTest.cs
@@ -37,6 +37,11 @@
                if (location == null) throw new Exception("未知库位");
                if (_taskRepository.QueryFirst(x => x.SourceAddress == result.LocationID && x.Roadway == location.RoadwayNo) != null)
                {
                    throw new Exception("当前库位已存在任务");
                }
                Dt_StationManager stationManager;
                if (result.IsNG == 1)
                {
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StoragIntegrationServices/MCS/Partial/RequestChangeLocation.cs
@@ -1,4 +1,7 @@
using Newtonsoft.Json;
using AngleSharp.Dom;
using log4net.Core;
using Masuit.Tools;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -6,7 +9,9 @@
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Core;
using WIDESEA_Core.Const;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.WMS;
using WIDESEA_Model.Models;
@@ -25,7 +30,7 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (string.IsNullOrEmpty(json.ToString())) throw new Exception("上传参数为空");
                if (string.IsNullOrEmpty(json.ToString())) throw new Exception("请求参数为空");
                var result = JsonConvert.DeserializeObject<RequestReMove>(json.ToString());
@@ -33,72 +38,262 @@
                if (location == null) throw new Exception("未知库位");
                if (result.MoveType == 5)
                if (_taskRepository.QueryFirst(x => x.SourceAddress == result.LocationID && x.Roadway == location.RoadwayNo) != null)
                {
                    Console.WriteLine($"分容检测柜火警触发:库位{result.LocationID}");
                    //查找消防站台
                    var station = _stationManagerRepository.QueryFirst(t => t.Roadway == location.RoadwayNo
                         && t.stationType == (int)StationManager.FireStation
                         /*&& t. == "Enable"*/);
                    if (station == null)
                    {
                        throw new Exception("消防站台未配置!");
                    }
                    //查找库存信息
                    var barcodeData = _stockInfoRepository.QueryFirst(t => t.LocationCode == location.LocationCode);
                    //托盘码
                    string barcode = string.Empty;
                    if (barcodeData != null)
                    {
                        barcode = barcodeData.PalletCode;
                    }
                    else
                    {
                        //无库存信息,生成随机托盘码
                        barcode = "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000);
                    }
                    int taskNum = _taskRepository.GetTaskNo().Result;
                    Dt_Task task = new Dt_Task
                    {
                        CreateDate = DateTime.Now,
                        Creater = "HK",
                        CurrentAddress = result.LocationID,
                        Grade = 1,
                        Dispatchertime = DateTime.Now,
                        PalletCode = result.PalletBarcode,
                        Roadway = location.RoadwayNo,
                        SourceAddress = result.LocationID,
                        TaskState = (int)TaskOutStatusEnum.OutNew,
                        TaskType = 500,
                        TargetAddress = station.stationLocation,
                        NextAddress = station.stationChildCode,
                        TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
                        TaskId = 0,
                    };
                    // 尝试添加新任务
                    WMSTaskDTO taskDTO = new WMSTaskDTO()
                    {
                        TaskNum = task.TaskNum.Value,
                        Grade = 1,
                        PalletCode = task.PalletCode,
                        RoadWay = task.Roadway,
                        SourceAddress = task.SourceAddress,
                        TargetAddress = task.TargetAddress,
                        TaskState = task.TaskState.Value,
                        Id = 0,
                        TaskType = 500,
                    };
                    throw new Exception("当前库位已存在任务");
                }
                switch (result.MoveType)
                {
                    case 1:
                        CreateMoveTask(location);
                        break;
                    case 5:
                        CreateFireTask(location);
                        break;
                    default:
                        throw new Exception("无效的移库申请类型");
                }
                #region 火警出库
                //if (result.MoveType == 5)
                //{
                //    Console.WriteLine($"分容检测柜火警触发:库位{result.LocationID}");
                //    //查找消防站台
                //    var station = _stationManagerRepository.QueryFirst(t => t.Roadway == location.RoadwayNo
                //         && t.stationType == (int)StationManager.FireStation
                //         /*&& t. == "Enable"*/);
                //    if (station == null)
                //    {
                //        throw new Exception("消防站台未配置!");
                //    }
                //    //查找库存信息
                //    var barcodeData = _stockInfoRepository.QueryFirst(t => t.LocationCode == location.LocationCode);
                //    //托盘码
                //    string barcode = string.Empty;
                //    if (barcodeData != null)
                //    {
                //        barcode = barcodeData.PalletCode;
                //    }
                //    else
                //    {
                //        //无库存信息,生成随机托盘码
                //        barcode = "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000);
                //    }
                //    int taskNum = _taskRepository.GetTaskNo().Result;
                //    Dt_Task task = new Dt_Task
                //    {
                //        CreateDate = DateTime.Now,
                //        Creater = "HK",
                //        CurrentAddress = result.LocationID,
                //        Grade = 1,
                //        Dispatchertime = DateTime.Now,
                //        PalletCode = barcode,
                //        Roadway = location.RoadwayNo,
                //        SourceAddress = result.LocationID,
                //        TaskState = (int)TaskOutStatusEnum.OutNew,
                //        TaskType = 500,
                //        TargetAddress = station.stationLocation,
                //        NextAddress = station.stationChildCode,
                //        TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
                //        TaskId = 0,
                //    };
                //    // 尝试添加新任务
                //    WMSTaskDTO taskDTO = new WMSTaskDTO()
                //    {
                //        TaskNum = task.TaskNum.Value,
                //        Grade = 1,
                //        PalletCode = task.PalletCode,
                //        RoadWay = task.Roadway,
                //        SourceAddress = task.SourceAddress,
                //        TargetAddress = task.TargetAddress,
                //        TaskState = task.TaskState.Value,
                //        Id = 0,
                //        TaskType = 500,
                //    };
                //}
                #endregion
                LogFactory.GetLog("分容移库申请").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("分容移库申请").Info(true, result);
                LogFactory.GetLog("分容移库申请").Info(true, result.ToJsonString());
                return content.OK();
            }
            catch (Exception ex)
            {
                LogFactory.GetLog("分容移库申请").Info(true, $"\r\r--------------------------------------");
                LogFactory.GetLog("分容移库申请").Info(true, ex.Message);
                return content.Error(ex.Message);
            }
        }
        private void CreateMoveTask(DtLocationInfo location)
        {
            Console.WriteLine($"分容申请移库:库位{location.LocationCode}");
            //查找可用库位
            DtLocationInfo CanRelocation = _locationRepository.QueryFirst(x => x.LocationStatus == (int)LocationEnum.Free && x.RoadwayNo == location.RoadwayNo && x.EnalbeStatus == 1 && x.LocationType == 2 && x.Remark == "1");
            if (CanRelocation == null) throw new Exception("申请移库失败:无可用库位");
            //查找库存信息
            var stockInfo = _stockInfoRepository.QueryFirst(t => t.LocationCode == location.LocationCode);
            if (stockInfo == null) throw new Exception("申请移库失败:无库存记录");
            //修改移库目标库位状态
            CanRelocation.LocationStatus = (int)LocationEnum.FreeDisable;
            int taskNum = _taskRepository.GetTaskNo().Result;
            Dt_Task task = new Dt_Task
            {
                CreateDate = DateTime.Now,
                Creater = "HK",
                CurrentAddress = location.LocationCode,
                Grade = 1,
                Dispatchertime = DateTime.Now,
                PalletCode = stockInfo.PalletCode,
                Roadway = location.RoadwayNo,
                SourceAddress = location.LocationCode,
                TaskState = (int)TaskStatus.Created,
                TaskType = (int)TaskRelocationTypeEnum.Relocation,
                TargetAddress = CanRelocation.LocationCode,
                NextAddress = CanRelocation.LocationCode,
                TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
                TaskId = 0,
            };
            // 尝试添加新任务
            WMSTaskDTO taskDTO = new WMSTaskDTO()
            {
                TaskNum = task.TaskNum.Value,
                Grade = 1,
                PalletCode = task.PalletCode,
                RoadWay = task.Roadway,
                SourceAddress = task.SourceAddress,
                TargetAddress = task.TargetAddress,
                TaskState = task.TaskState.Value,
                Id = 0,
                TaskType = task.TaskType,
            };
            var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
            var ReceiveByWMSTask = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveByWMSTask)?.ConfigValue;
            if (ReceiveByWMSTask == null || ipAddress == null)
            {
                throw new Exception("WMS IP 未配置");
            }
            var wmsIpAddrss = ipAddress + ReceiveByWMSTask;
            var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(taskDTO));   //http://localhost:9291/api/Task/ReceiveTask,
            if (respon != null)
            {
                WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString());
                if (respone.Status)
                {
                    //添加WMS任务 并修改库位状态
                    var taskId = _taskRepository.AddData(task);
                    _locationRepository.UpdateData(CanRelocation);
                }
                else
                {
                    throw new Exception("WCS处理失败:" + respone.Message);
                }
            }
            else
            {
                throw new Exception("WCS处理失败");
            }
        }
        private void CreateFireTask(DtLocationInfo location)
        {
            Console.WriteLine($"分容检测柜火警触发:库位{location.LocationCode}");
            //查找消防站台
            var station = _stationManagerRepository.QueryFirst(t => t.Roadway == location.RoadwayNo
                 && t.stationType == (int)StationManager.FireStation
                 /*&& t. == "Enable"*/);
            if (station == null)
            {
                throw new Exception("消防站台未配置!");
            }
            //查找库存信息
            var barcodeData = _stockInfoRepository.QueryFirst(t => t.LocationCode == location.LocationCode);
            //托盘码
            string barcode = string.Empty;
            if (barcodeData != null)
            {
                barcode = barcodeData.PalletCode;
            }
            else
            {
                //无库存信息,生成随机托盘码
                barcode = "M" + DateTime.Now.ToString("MMddHHmmss") + "-" + new Random().Next(100, 1000);
            }
            int taskNum = _taskRepository.GetTaskNo().Result;
            Dt_Task task = new Dt_Task
            {
                CreateDate = DateTime.Now,
                Creater = "HK",
                CurrentAddress = location.LocationCode,
                Grade = 1,
                Dispatchertime = DateTime.Now,
                PalletCode = barcode,
                Roadway = location.RoadwayNo,
                SourceAddress = location.LocationCode,
                TaskState = (int)TaskOutStatusEnum.OutNew,
                TaskType = 500,
                TargetAddress = station.stationLocation,
                NextAddress = station.stationChildCode,
                TaskNum = taskNum, //_taskRepository.GetTaskNo().Result,
                TaskId = 0,
            };
            // 尝试添加新任务
            WMSTaskDTO taskDTO = new WMSTaskDTO()
            {
                TaskNum = task.TaskNum.Value,
                Grade = 1,
                PalletCode = task.PalletCode,
                RoadWay = task.Roadway,
                SourceAddress = task.SourceAddress,
                TargetAddress = task.TargetAddress,
                TaskState = task.TaskState.Value,
                Id = 0,
                TaskType = 500,
            };
            var configs = _configService.GetConfigsByCategory(CateGoryConst.CONFIG_SYS_IPAddress);
            var ipAddress = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.WCSIPAddress)?.ConfigValue;
            var ReceiveByWMSTask = configs.FirstOrDefault(x => x.ConfigKey == SysConfigConst.ReceiveByWMSTask)?.ConfigValue;
            if (ReceiveByWMSTask == null || ipAddress == null)
            {
                throw new Exception("WMS IP 未配置");
            }
            var wmsIpAddrss = ipAddress + ReceiveByWMSTask;
            var respon = HttpHelper.Post(wmsIpAddrss, JsonConvert.SerializeObject(taskDTO));   //http://localhost:9291/api/Task/ReceiveTask,
            if (respon != null)
            {
                WebResponseContent respone = JsonConvert.DeserializeObject<WebResponseContent>(respon.ToString());
                if (respone.Status)
                {
                    var taskId = _taskRepository.AddData(task);
                }
                else
                {
                    throw new Exception("WCS处理失败:" + respone.Message);
                }
            }
            else
            {
                throw new Exception("WCS处理失败");
            }
        }
    }
}
Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -510,8 +510,6 @@
                TaskType = task.TaskType,
            };
            content.OK(data: taskDTO);
        }
        else
            content.Error("添加任务失败");
@@ -764,7 +762,6 @@
        }
    }
    #region 直接出库任务完成
    public async Task<WebResponseContent> CompleteInToOutTaskAsync(Dt_Task task)
    {
@@ -787,6 +784,46 @@
    #endregion
    #region MyRegion
    //private async Task<bool> ExecuteTransaction(DtStockInfo stock, Dt_Task_Hty taskHty, DtLocationInfo locationInfo, int taskId)
    //{
    //    _unitOfWorkManage.BeginTran();
    //    try
    //    {
    //        var isUpdateStock = true;
    //        // 添加历史任务
    //        var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0;
    //        // 修改移库前货位状态
    //        var isUpdateLoc = _locationRepository.UpdateData(locationInfo);
    //        // 删除任务数据
    //        var isTaskDelete = await Delete(taskId);
    //        // 提交或回滚事务
    //        if (isUpdateStock && isTaskHtyAdd && isTaskDelete && isUpdateLoc)
    //        {
    //            LogFactory.GetLog("任务完成").InfoFormat(true, "任务完成", $"事务处理完成,提交事务。添加历史任务:{isTaskHtyAdd},删除任务数据:{isTaskDelete},更新或添加库存:{isUpdateStock},修改移库前货位状态:{isUpdateLoc}");
    //            _unitOfWorkManage.CommitTran();
    //            return true;
    //        }
    //        else
    //        {
    //            LogFactory.GetLog("任务完成").InfoFormat(true, "任务完成", $"数据处理失败,请检查数据是否正确,数据回滚。添加历史任务:{isTaskHtyAdd},删除任务数据:{isTaskDelete},更新库存:{isUpdateStock},修改移库前货位状态:{isUpdateLoc}");
    //            _unitOfWorkManage.RollbackTran();
    //            return false;
    //        }
    //    }
    //    catch (Exception err)
    //    {
    //        LogFactory.GetLog("任务完成").InfoFormat(true, $"任务完成,系统异常,异常信息:{err.Message}", "无参数");
    //        _unitOfWorkManage.RollbackTran();
    //        throw; // 抛出异常以便外部捕获
    //    }
    //}
    #endregion
    #region 检测高温库是否有可出库库存
    public WebResponseContent StockCheckingAsync()