chengsc
2024-11-02 d567d9d6926abb103f3ab73402134daa6a09ef11
Wms/Wms/Controllers/PdaAsnController.cs
@@ -1,10 +1,13 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Model.ModelVm;
using Model.ModelVm.BllAsnVm;
using Model.ModelVm.PdaVm;
using System;
using System.Security.Claims;
using Wms.Tools;
using WMS.Entity.BllAsnEntity;
using WMS.IBLL.IPdaServer;
namespace Wms.Controllers
@@ -16,11 +19,37 @@
    {
        #region 依赖注入
        private readonly IPdaAsnServer _PdaAsnSvc;
        private readonly ApiUrlConfig _config; //接口交互路径
        public PdaAsnController(IPdaAsnServer pdaAsnSvc)
        public PdaAsnController(IPdaAsnServer pdaAsnSvc, IOptions<ApiUrlConfig> setting)
        {
            _PdaAsnSvc = pdaAsnSvc;
            _PdaAsnSvc = pdaAsnSvc;
            _config = setting.Value;
        }
        #endregion
        #region MyRegion
        /// <summary>
        /// 获取单据明细显示的物料
        /// </summary>
        /// <param name="model">Type:单据类型</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetArrivalNoticesInfo(ArrivalNoticeVm model)
        {
            try
            {
                var models = _PdaAsnSvc.GetArrivalNoticesInfo(model);
                return Ok(new { code = 0, msg = "入库单信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
        #region 公用方法
@@ -37,6 +66,33 @@
                var models = _PdaAsnSvc.GetArrivalNotices(model);
                return Ok(new { code = 0, msg = "入库单信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 根据入库单获取入库总单信息
        /// </summary>
        /// <param name="model">ASNNo:入库单号</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetArrivalNotice(ArrivalNoticeVm model)
        {
            try
            {
                var models = _PdaAsnSvc.GetArrivalNotice(model);
                if (models == null)
                {
                    return Ok(new { code = 1, msg = "入库单信息", data = models });
                }
                else
                {
                    return Ok(new { code = 0, msg = "入库单信息", data = models });
                }
            }
            catch (Exception e)
            {
@@ -132,29 +188,18 @@
        }
        /// <summary>
        /// 绑定托盘
        /// 根据托盘号或箱码获取托盘信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="model">PalletNo:托盘号</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult BindPallet(PdaPalletBindVm model)
        public IActionResult GetPalletBindInfo(BllPalletBind model)
        {
            try
            {
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }
                _PdaAsnSvc.BindPallet(model, int.Parse(UserId),model.Origin);
                var models = _PdaAsnSvc.GetPalletBindInfo(model);
                return Ok(new { code = 0, msg = "绑定成功!" });
                return Ok(new { code = 0, msg = "托盘信息", data = models });
            }
            catch (Exception e)
            {
@@ -186,6 +231,47 @@
                model.CreateUser = int.Parse(UserId);
                var strMsg = _PdaAsnSvc.DelBoxInfo(model);
                if (strMsg == "")
                {
                    return Ok(new { code = 0, msg = "删除组托成功!" });
                }
                else
                {
                    return Ok(new { code = 1, msg = strMsg });
                }
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 删除托盘信息
        /// </summary>
        /// <param name="model">ID\托盘号</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult DelPalletBind(BllPalletBind model)
        {
            try
            {
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }
                model.CreateUser = int.Parse(UserId);
                var strMsg = _PdaAsnSvc.DelPalletBind(model);
                if (strMsg == "")
                {
@@ -352,6 +438,26 @@
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 验证储位(地码)是否可用
        /// </summary>
        /// <param name="model">LocatNo储位地址</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult CheckLocatNo(PalletBindVm model)
        {
            try
            {
                var result = _PdaAsnSvc.CheckLocatNo(model.LocatNo);
                return Ok(new { code = 0, msg = "验证成功!", data = result });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
        #region 零箱入库
@@ -411,7 +517,7 @@
        #endregion
        #region 原料组托
        #region 组托
        /// <summary>
        /// 根据箱码获取标签箱码信息
        /// </summary>
@@ -422,7 +528,7 @@
        {
            try
            {
                var models = _PdaAsnSvc.GetBindBoxInfos(model);
                var models = _PdaAsnSvc.GetBindBoxInfos(model, _config.BoxHost + _config.FuMaGetBoxUrl, _config.BoxHost + _config.FuMaGetTokenUrl);
                return Ok(new { code = 0, msg = "标签箱码信息", data = models });
            }
@@ -431,6 +537,105 @@
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 根据箱码获取标签最小追溯码信息
        /// </summary>
        /// <param name="model">BoxNo:箱号</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetBindBoxInfo2s(BoxInfoVm model)
        {
            try
            {
                var models = _PdaAsnSvc.GetBindBoxInfo2s(model, _config.BoxHost + _config.FuMaGetBoxUrl, _config.BoxHost + _config.FuMaGetTokenUrl);
                return Ok(new { code = 0, msg = "标签箱码信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        [HttpPost]
        public IActionResult GetBindArrivalNoticeDetails(ArrivalNoticeVm model)
        {
            try
            {
                var models = _PdaAsnSvc.GetBindArrivalNoticeDetails(model);
                return Ok(new { code = 0, msg = "入库单明细信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 绑定托盘
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult BindPallet(PdaPalletBindVm model)
        {
            try
            {
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }
                _PdaAsnSvc.BindPallet(model, int.Parse(UserId), model.Origin);
                return Ok(new { code = 0, msg = "绑定成功!" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
        #region 平库入库
        /// <summary>
        /// 平库确认入库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ConfirmInStock(PalletBindVm model)
        {
            try
            {
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }
                model.CreateUser = int.Parse(UserId);
                _PdaAsnSvc.ConfirmInStock(model);
                return Ok(new { code = 0, msg = "入库成功!" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
    }
}