chengsc
2025-05-10 3d6ef3897a77dec54be7057299e1be1d10589336
Wms/Wms/Controllers/DownApiController.cs
@@ -21,6 +21,7 @@
using Model.ModelVm.BllCheckVm;
using System.Collections.Generic;
using System.Security.Policy;
using WMS.IBLL;
namespace Wms.Controllers
{
@@ -38,7 +39,8 @@
        private readonly ITaskServer _taskSvc;//任务Svc
        private readonly IBllTaskSyncServer _taskSyncSvc;//任务同步Svc
        private readonly IWaveMageServer _waveSvc;//任务同步Svc
        public DownApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IPalletBindServer asnPalletBindSvc, IStockCheckServer crCheckSvc, ITaskServer taskSvc, IBllTaskSyncServer taskSyncSvc, IWaveMageServer waveSvc)
        private readonly IHttpServer _http;//任务同步Svc
        public DownApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IPalletBindServer asnPalletBindSvc, IStockCheckServer crCheckSvc, ITaskServer taskSvc, IBllTaskSyncServer taskSyncSvc, IWaveMageServer waveSvc,IHttpServer http)
        {
            _config = setting.Value;
            _exNoticeSvc = exNoticeSvc;
@@ -47,6 +49,7 @@
            _taskSvc = taskSvc;
            _taskSyncSvc = taskSyncSvc;
            _waveSvc = waveSvc;
            _http = http;
        }
        #region WMS接口 调用下游系统接口 
@@ -273,38 +276,6 @@
        #region WMS接口 被下游系统接口调用
        /// <summary>
        /// 绑定信息返回巷道口
        /// </summary>
        /// <param name="model">入库单信息</param>
        /// <returns></returns>
        //[AllowAnonymous]
        //[HttpPost]
        //public IActionResult BindRequestRoadWay(BoxPalletBindVm model)
        //{
        //    var logStr = $@".\log\WCS\WCS托盘绑定-申请巷道" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
        //    try
        //    {
        //        var jsonData = JsonConvert.SerializeObject(model);
        //        LogFile.SaveLogToFile($"WCS托盘绑定-申请巷道:( {jsonData} ),", logStr);
        //        _asnPalletBindSvc.BindPalletStock(model, 0);
        //        //申请巷道
        //        var list = _asnPalletBindSvc.RequestRoadWay(model.PalletNo, "W01");
        //        LogFile.SaveLogToFile($"WCS托盘绑定-申请巷道返回:( {JsonConvert.SerializeObject(list)} ),", logStr);
        //        return Ok(new { Success = 0, Message = "托盘绑定-申请巷道成功", TaskList = list });
        //    }
        //    catch (Exception e)
        //    {
        //        LogFile.SaveLogToFile($"WCS托盘绑定-申请巷道返回:( {e.Message} ),", logStr);
        //        return Ok(new ErpModel { Success = -1, Message = e.Message });
        //    }
        //}
        /// <summary>
        /// PDA 人工申请储位 (立体库)
        /// </summary>
        /// <param name="model">入库单信息</param>
@@ -329,16 +300,16 @@
            try
            {
                var list = _asnPalletBindSvc.RequestLocation(model.PalletNo, model.HouseNo);
                _asnPalletBindSvc.IssueAsnTask(list, _config.ErpHost+ _config.AsnFinishUrl);//agv路径
                var list = _http.RequestLocation(model.PalletNo, model.HouseNo);
                _asnPalletBindSvc.IssueAsnTask(list, _config.WcsHost+ _config.IssueComApiUrl2);//WCS路径
                
                new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo, "申请储位", $"申请储位托盘号:{model.PalletNo}的成功信息", int.Parse(userId));
                new OperationASNServer().AddLogOperationAsn("PDA模块", "申请入库", model.PalletNo, "添加", $"申请储位托盘号:{model.PalletNo}的成功信息", int.Parse(userId));
                return Ok(new HttpReturnModel { Success = "0", Message = "申请储位成功", Data = list });
            }
            catch (Exception e)
            {
                new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo, "申请储位", $"申请储位托盘号:{model.PalletNo}的失败信息", int.Parse(userId));
                new OperationASNServer().AddLogOperationAsn("PDA模块", "申请入库", model.PalletNo, "添加", $"申请储位托盘号:{model.PalletNo}的失败信息", int.Parse(userId));
                return Ok(new HttpReturnModel { Success = "-1", Message = e.Message });
            }
@@ -363,19 +334,15 @@
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"WCS申请巷道:( {jsonData} ),", logStr);
                var list = _asnPalletBindSvc.RequestMiJiRoadWay(model.PalletNo, model.HouseNo);
                var list = _http.RequestMiJiRoadWay(model.PalletNo, model.HouseNo);
                LogFile.SaveLogToFile($"WCS申请巷道返回:( {JsonConvert.SerializeObject(list)} ),", logStr);
                //new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8),
                //    "申请巷道", $"申请巷道托盘号:{model.PalletNo.Substring(0, 8)}的成功信息", 2);
                return Ok(new { Success = 0, Message = "申请巷道成功", TaskList = list });
            }
            catch (Exception e)
            {
                LogFile.SaveLogToFile($"WCS申请巷道返回:( {e.Message} ),", logStr);
                //new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8),
                //"申请巷道", $"申请巷道托盘号:{model.PalletNo.Substring(0, 8)}的失败信息", 2);
                return Ok(new ErpModel { Success = -1, Message = e.Message });
            }
@@ -390,37 +357,19 @@
        [HttpPost]
        public IActionResult RequestMiJiLocation(RequestLocate model)
        {
            //获取当前登录的用户ID
            //var claimsIdentity = this.User.Identity as ClaimsIdentity;
            //if (claimsIdentity == null)
            //{
            //    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
            //}
            //var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
            //if (string.IsNullOrWhiteSpace(userId))
            //{
            //    return Ok(new { code = 1, msg = "未获取到当前操作人信息" });
            //}
            //string palletno = model.PalletNo;
            var logStr = "";
            
            logStr = $@".\log\WCS\WCS申请储位" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"WCS申请储位:( {jsonData} ),", logStr);
                
                string pallet = model.PalletNo.Substring(0, 8);
                var list = _asnPalletBindSvc.RequestMiJiLocation(pallet, model.HouseNo, model.RoadwayNo);
                var list = _http.RequestMiJiLocation(pallet, model.HouseNo, model.RoadwayNo);
                LogFile.SaveLogToFile($"WCS申请储位返回:( {JsonConvert.SerializeObject(list)} ),", logStr);
                //new OperationASNServer().AddLogOperationAsn("入库作业", "入库日志", model.PalletNo.Substring(0, 8), "申请储位", $"申请储位托盘号:{model.PalletNo.Substring(0, 8)}的成功信息", 2);// int.Parse(userId)
                //LogFile.SaveLogToFile($"WMS申请储位成功:( {JsonConvert.SerializeObject(list)} ),", logStr);
                
                return Ok(new { Success = 0, Message = "申请储位成功", TaskList = list });
            }
@@ -458,7 +407,7 @@
                    case "0"://入库完成任务
                        if (model.TaskType == "0")//0:入库 1:出库 2:移库
                        {
                            _asnPalletBindSvc.ArrivalSuccess(model.TaskNo, 0);
                            _http.ArrivalSuccess2(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "入库完成" });
                        }
                        break;
@@ -482,7 +431,7 @@
                        }
                        else if (model.TaskType == "0")// 盘点出库托盘回库完成
                        {
                            _asnPalletBindSvc.ArrivalSuccess(model.TaskNo, 0);
                            _http.ArrivalSuccess2(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "入库完成" });
                        }
                        break;
@@ -503,6 +452,33 @@
            }
        }
        /// <summary>
        /// 接受wcs返回的信号 平库取货完成任务反馈
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult UpLocateByAgvOut(ReceiveWcsSignal model)
        {
            try
            {
                //记录log
                var logStr = $@".\log\WCS\取货完成任务反馈" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"AGV取货完成WCS任务反馈:( {jsonData} ),", logStr);
                if (string.IsNullOrEmpty(model.TaskNo))
                {
                    return Ok(new WcsModel { StatusCode = -1, Msg = "接口数据不正确,任务号为空" });
                }
                _http.UpLocateByAgvOut(model.TaskNo,0);
                return Ok(new WcsModel { StatusCode = 0, Msg = "接收成功" });
            }
            catch (Exception ex)
            {
                return Ok(new WcsModel { StatusCode = -1, Msg = ex.Message });
            }
        }
        /// <summary>
        /// WCS反馈AGV任务取货完成