chengsc
2025-06-11 74ce2ccbae367b804028fbac431f22865f84427a
Wms/Wms/Controllers/DownApiController.cs
@@ -39,7 +39,7 @@
        private readonly ITaskServer _taskSvc;//任务Svc
        private readonly IBllTaskSyncServer _taskSyncSvc;//任务同步Svc
        private readonly IWaveMageServer _waveSvc;//任务同步Svc
        private readonly IHttpServer _http;//任务同步Svc
        private readonly IHttpServer _http;
        public DownApiController(IOptions<ApiUrlConfig> setting, IExportNoticeServer exNoticeSvc, IPalletBindServer asnPalletBindSvc, IStockCheckServer crCheckSvc, ITaskServer taskSvc, IBllTaskSyncServer taskSyncSvc, IWaveMageServer waveSvc,IHttpServer http)
        {
            _config = setting.Value;
@@ -129,8 +129,9 @@
                var house = _exNoticeSvc.GetHouseBySo(soNo);
                if (house == "W01")
                {
                    var list = _exNoticeSvc.IssueOutHouseMk(soNo, outMode, int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl, out string str);
                    return Ok(new { code = 0, msg = "str" });
                    return Ok(new { code = 0, msg = str });
                }
                else if (house == "W02")
                {
@@ -150,6 +151,58 @@
            }
        }
        /// <summary>
        /// PDA下发出库
        /// </summary>
        /// <param name="soNo"></param>
        /// <param name="soDetailId">出库单明细ID</param>
        /// <param name="outMode">出库地址(平库拣货位)</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult PDAIssueOut(string soNo, string soDetailId,string palletNo,string outMode)
        {
            try
            {
                //获取当前登录的用户ID
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    return Ok(new HttpReturnModel { Success = "-1", Message = "未获取到当前操作人信息"});
                }
                var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(userId))
                {
                    return Ok(new HttpReturnModel { Success = "-1", Message = "未获取到当前操作人信息"});
                }
                //验证出库口
                if (string.IsNullOrWhiteSpace(outMode))
                {
                    return Ok(new HttpReturnModel { Success = "-1", Message = "请选择出库地址" });
                }
                var house = _exNoticeSvc.GetHouseBySo(soNo);
                if (house == "W01")
                {
                    //var list = _exNoticeSvc.IssueOutHouseMk(soNo, outMode, int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl, out string str);
                    return Ok(new HttpReturnModel { Success = "0", Message = "str", Data = "list" });
                }
                else if (house == "W02")
                {
                    var list = _http.IssueOutHouseLk(soNo,soDetailId, outMode,palletNo, int.Parse(userId), _config.WcsHost + _config.IssueComApiUrl, out string str);
                    return Ok(new HttpReturnModel { Success = "0", Message = str, Data = list});
                }
                else
                {
                    return Ok(new HttpReturnModel { Success = "-1", Message = "仓库信息错误,请核实单据信息" });
                }
            }
            catch (Exception e)
            {
                return Ok(new HttpReturnModel { Success = "-1", Message = e.Message });
            }
        }
        /// <summary>
        /// 重新下发出库任务
@@ -276,6 +329,40 @@
        #region WMS接口 被下游系统接口调用
        /// <summary>
        /// WCS申请空托跺组托入库 (叠托盘机)
        /// </summary>
        /// <param name="model">入库单信息</param>
        /// <returns></returns>
        [AllowAnonymous]
        [HttpPost]
        public IActionResult RequestPalletIn(RequestLocate model)
        {
            var logStr = "";
            logStr = $@".\log\WCS\WCS申请空托跺组托入库" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
            try
            {
                var jsonData = JsonConvert.SerializeObject(model);
                LogFile.SaveLogToFile($"WCS申请空托跺组托入库:( {jsonData} ),", logStr);
                var list = _http.RequestPalletIn(model.PalletNo, model.HouseNo, model.palletNum,model.locate);
                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>
@@ -300,7 +387,7 @@
            try
            {
                var list = _http.RequestLocation(model.PalletNo, model.HouseNo);
                var list = _http.RequestLocation(model.PalletNo, model.HouseNo,model.Ceng);
                _asnPalletBindSvc.IssueAsnTask(list, _config.WcsHost+ _config.IssueComApiUrl2);//WCS路径
                
                new OperationASNServer().AddLogOperationAsn("PDA模块", "申请入库", model.PalletNo, "添加", $"申请储位托盘号:{model.PalletNo}的成功信息", int.Parse(userId));
@@ -419,7 +506,7 @@
                        }
                        else if (model.TaskType == "2")
                        {
                            _exNoticeSvc.RelocationSuccess(model.TaskNo, 0);
                            _http.ExMoveSuccess(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "移库完成" });
                        }
                        break;
@@ -435,11 +522,19 @@
                            return Ok(new WcsModel { StatusCode = 0, Msg = "入库完成" });
                        }
                        break;
                    case "3"://移库完成任务、优化储位
                    case "3"://移库单  AGV走这
                        if (model.TaskType == "2") //0:入库 1:出库 2:移库
                        {
                            //填写移库完成代码
                            _http.MoveSuccess(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "移库完成" });
                        }
                        break;
                    case "4"://质检出库
                        if (model.TaskType == "2") //0:入库 1:出库 2:移库
                        {
                            //填写移库完成代码
                            _http.ExMoveSuccess(model.TaskNo, 0);
                            return Ok(new WcsModel { StatusCode = 0, Msg = "移库完成" });
                        }
                        break;
@@ -482,6 +577,93 @@
            }
        }
        /// <summary>
        /// 手动完成的信号 //指令反馈(是否完成)
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ReceiveRenGongSignal(ReceiveWcsSignal model)
        {
            //获取当前登录的用户ID
            var claimsIdentity = this.User.Identity as ClaimsIdentity;
            if (claimsIdentity == null)
            {
                return Ok(new HttpReturnModel { Success = "1", Message = "未获取到当前操作人信息" });
            }
            var userId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
            if (string.IsNullOrWhiteSpace(userId))
            {
                return Ok(new HttpReturnModel { Success = "1", Message = "未获取到当前操作人信息" });
            }
            try
            {
                if (string.IsNullOrEmpty(model.TaskNo) || string.IsNullOrEmpty(model.TaskStatus) || string.IsNullOrEmpty(model.TaskType))
                {
                    return Ok(new HttpReturnModel { Success = "-1", Message = "参数错误" });
                }
                //接收时间
                var orderType = _taskSvc.GetTaskOrderType(model.TaskNo);// 判断单据类型入出移
                switch (orderType)
                {
                    case "0"://入库完成任务
                        if (model.TaskType == "0")//0:入库 1:出库 2:移库
                        {
                            _http.ArrivalSuccess2(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "入库完成" });
                        }
                        break;
                    case "1"://出库完成任务
                        if (model.TaskType == "1")//0:入库 1:出库 2:移库
                        {
                            _exNoticeSvc.ExportSuccess(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "出库完成" });
                        }
                        else if (model.TaskType == "2")
                        {
                            _http.ExMoveSuccess(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "移库完成" });
                        }
                        break;
                    case "2"://盘库完成任务
                        if (model.TaskType == "1")//0:入库 1:出库 2:移库
                        {
                            _crCheckSvc.CheckSuccess(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "盘点出库完成" });
                        }
                        else if (model.TaskType == "0")// 盘点出库托盘回库完成
                        {
                            _http.ArrivalSuccess2(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "入库完成" });
                        }
                        break;
                    case "3"://移库单
                        if (model.TaskType == "2") //0:入库 1:出库 2:移库
                        {
                            //填写移库完成代码
                            _http.MoveSuccess(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "移库完成" });
                        }
                        break;
                    case "4"://质检出库
                        if (model.TaskType == "2") //0:入库 1:出库 2:移库
                        {
                            _http.ExMoveSuccess(model.TaskNo, 0);
                            return Ok(new HttpReturnModel { Success = "0", Message = "移库完成" });
                        }
                        break;
                    default:
                        return Ok(new HttpReturnModel { Success = "-1", Message = "传递的任务状态为失败状态" });
                }
                return Ok(new HttpReturnModel { Success = "-1", Message = "传递的任务状态为失败状态" });
            }
            catch (Exception ex)
            {
                return Ok(new HttpReturnModel { Success = "-1", Message = ex.Message });
            }
        }
        /// <summary>
        /// WCS反馈AGV任务取货完成
        /// </summary>