1
hwh
2024-08-05 01f8f2c627fe0b95acc68b12df828cc966df0bad
Wms/Wms/Controllers/PdaSoController.cs
@@ -12,6 +12,8 @@
using Model.ModelDto;
using Model.ModelVm;
using Wms.Tools;
using Utility;
using System.Security.Cryptography;
namespace Wms.Controllers
{
@@ -23,14 +25,15 @@
        #region 依赖注入
        private readonly ApiUrlConfig _config; //接口交互路径
        private readonly IPdaSoServer _pdaSoSvc;
        private readonly UserManager _userManager;
        public PdaSoController(IOptions<ApiUrlConfig> setting,IPdaSoServer pdaSoSvc)
        public PdaSoController(IOptions<ApiUrlConfig> setting, IPdaSoServer pdaSoSvc, UserManager userManager)
        {
            _config = setting.Value;
            _pdaSoSvc = pdaSoSvc;
            _userManager = userManager;
        }
        #endregion
        /// <summary>
@@ -39,25 +42,10 @@
        /// <param name="model">PalletNo:托盘条码</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult IsEnableOkPalletNo(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task IsEnableOkPalletNo(PdaSoVm model)
        {
            try
            {
                var strMsg = _pdaSoSvc.IsEnableOkPalletNo(model.PalletNo);
                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 });
            }
            await _pdaSoSvc.IsEnableOkPalletNo(model.PalletNo);
        }
        /// <summary>
@@ -66,18 +54,10 @@
        /// <param name="model">PalletNo:托盘号</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetRunSoNoticeList(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<string>> GetRunSoNoticeList(PdaSoVm model)
        {
            try
            {
                var list = _pdaSoSvc.GetRunSoNoticeList(model.PalletNo,model.Type);
                return Ok(new { code = 0, msg = "出库单信息", data = list });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            return await _pdaSoSvc.GetRunSoNoticeList(model.PalletNo, model.Type);
        }
        /// <summary>
@@ -86,18 +66,10 @@
        /// <param name="model">PalletNo:托盘码、SoNo:单据号</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetSoSkuLotNoListByPallet(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task GetSoSkuLotNoListByPallet(PdaSoVm model)
        {
            try
            {
                var models = _pdaSoSvc.GetSoSkuLotNoListByPallet(model.PalletNo, model.SoNo);
                return Ok(new { code = 0, msg = "物料-批次信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            var models = await _pdaSoSvc.GetSoSkuLotNoListByPallet(model.PalletNo, model.SoNo);
        }
        /// <summary>
@@ -106,18 +78,10 @@
        /// <param name="model">SoDetailId:出库单明细ID、PalletNo:托盘码</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetOutlets(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<OutPdaInfo> GetOutlets(PdaSoVm model)
        {
            try
            {
                var models = _pdaSoSvc.GetOutlets(model.SoDetailId, model.PalletNo);
                return Ok(new { code = 0, msg = "托盘上物料等信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            return await _pdaSoSvc.GetOutlets(model.SoDetailId, model.PalletNo);
        }
        /// <summary>
@@ -126,18 +90,10 @@
        /// <param name="model">SoDetailId:出库单明细ID</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetPlanAndFinishQty(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<OutPdaInfo> GetPlanAndFinishQty(PdaSoVm model)
        {
            try
            {
                var models = _pdaSoSvc.GetPlanAndFinishQty(model.SoDetailId);
                return Ok(new { code = 0, msg = "出库单明细数量信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            return await _pdaSoSvc.GetPlanAndFinishQty(model.SoDetailId);
        }
        /// <summary>
@@ -146,18 +102,10 @@
        /// <param name="model">BoxNo:箱码号</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetDataComBoxInfo(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<dynamic> GetDataComBoxInfo(PdaSoVm model)
        {
            try
            {
                var models = _pdaSoSvc.GetDataComBoxInfo(model.SoDetailId,model.PalletNo, model.BoxNo, model.BoxNo3);
                return Ok(new { code = 0, msg = "箱码信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            return await _pdaSoSvc.GetDataComBoxInfo(model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3);
        }
        /// <summary>
@@ -166,51 +114,10 @@
        /// <param name="model">BoxNo:箱码号</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetAllotPlnInfo(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<dynamic> GetAllotPlnInfo(PdaSoVm model)
        {
            try
            {
                var models = _pdaSoSvc.GetAllotPlnInfo(model.SoDetailId, model.PalletNo);
                return Ok(new { code = 0, msg = "箱码信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 出库pda拣货
        /// </summary>
        /// <param name="model">SoDetailId:出库单明细ID、PalletNo:托盘码</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult SoSetPick(PdaSoVm model)
        {
            try
            {
                //获取当前登录的用户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 = "未获取到当前操作人信息" });
                }
                _pdaSoSvc.SoSetPick(model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3,model.PickQty ,int.Parse(userId));
                return Ok(new { code = 0, msg = "拣货完成", data = "" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
            return await _pdaSoSvc.GetAllotPlnInfo(model.SoDetailId, model.PalletNo);
        }
        /// <summary>
@@ -219,30 +126,22 @@
        /// <param name="model">SoDetailId:出库单明细ID、PalletNo:托盘码</param> 
        /// <returns></returns>
        [HttpPost]
        public IActionResult SoSetQtyPick(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task SoSetPick(PdaSoVm model)
        {
            try
            {
                //获取当前登录的用户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 = "未获取到当前操作人信息" });
                }
            await _pdaSoSvc.SoSetPick(model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, _userManager.UserId);
        }
                _pdaSoSvc.SoSetQtyPick(model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty,  int.Parse(userId));
                return Ok(new { code = 0, msg = "拣货完成", data = "" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        /// <summary>
        /// 出库pda拣货
        /// </summary>
        /// <param name="model">SoDetailId:出库单明细ID、PalletNo:托盘码</param>
        /// <returns></returns>
        [HttpPost]
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task SoSetQtyPick(PdaSoVm model)
        {
            await _pdaSoSvc.SoSetQtyPick(model.SoNo, model.SoDetailId, model.PalletNo, model.PickQty, _userManager.UserId);
        }
@@ -252,36 +151,10 @@
        /// <param name="model">空托盘出库</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult IssuePlnOutHouse(OutModePalletVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<string> IssuePlnOutHouse(OutModePalletVm 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("未获取到用户信息");
                }
                var strMsg = _pdaSoSvc.IssuePlnOutHouse(model, int.Parse(UserId), _config.WcsHost + _config.IssueComApiUrl);
                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 });
            }
            return await _pdaSoSvc.IssuePlnOutHouse(model, _userManager.UserId, _config.WcsHost + _config.IssueComApiUrl);
        }
@@ -293,17 +166,10 @@
        /// <param name="palletNo">托盘号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetPingKuInfoByPallet(string soNo, string palletNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<dynamic> GetPingKuInfoByPallet(string soNo, string palletNo)
        {
            try
            {
                var list = _pdaSoSvc.GetPingKuInfoByPallet(soNo,palletNo);
                return Ok(new { data = list, code = 0, msg = "获取平库托盘信息成功" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = "获取平库托盘信息错误:" + e.Message });
            }
            return await _pdaSoSvc.GetPingKuInfoByPallet(soNo, palletNo);
        }
        /// <summary>
@@ -313,31 +179,10 @@
        /// <param name="palletNo">托盘号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult PlaneExportSuccess(string soNo, string palletNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task PlaneExportSuccess(string soNo, string palletNo)
        {
            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("未获取到用户信息");
                }
                int uid = Convert.ToInt32(UserId);
                _pdaSoSvc.PlaneExportSuccess(soNo, palletNo, uid);
                return Ok(new { data = "", code = 0, msg = "平库出库成功" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = "平库出库错误:"+e.Message });
            }
            await _pdaSoSvc.PlaneExportSuccess(soNo, palletNo, _userManager.UserId);
        }
@@ -347,30 +192,10 @@
        /// <param name="palletNo">托盘号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSampleType(string palletNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<string> GetSampleType(string palletNo)
        {
            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("未获取到用户信息");
                }
                var type = _pdaSoSvc.GetSampleType(palletNo);
                return Ok(new { data = type, code = 0, msg = "获取取样类型" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = "获取取样类型错误:" + e.Message });
            }
            return await _pdaSoSvc.GetSampleType(palletNo);
        }
        /// <summary>
@@ -379,19 +204,10 @@
        /// <param name="palletNo">托盘号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetAsnNoByPallet(string palletNo)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task<List<string>> GetAsnNoByPallet(string palletNo)
        {
            try
            {
                var type = _pdaSoSvc.GetAsnNoByPallet(palletNo);
                return Ok(new { data = type, code = 0, msg = "获取入库单据" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = "获取入库单据错误:" + e.Message });
            }
            return await _pdaSoSvc.GetAsnNoByPallet(palletNo);
        }
        /// <summary>
        /// 取样出库拣货(标签)
@@ -399,31 +215,10 @@
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult SampleSoSetPick(PdaSoVm model)
        [ServiceFilter(typeof(ApiResponseActionFilter))]
        public async Task SampleSoSetPick(PdaSoVm 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("未获取到用户信息");
                }
                int uid = Convert.ToInt32(UserId);
                _pdaSoSvc.SampleSoSetPick(model.Type,model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, model.AsnNo, uid);
                return Ok(new { data = "", code = 0, msg = "(标签)取样出库拣货" });
            }
            catch (Exception e)
            {
                return Ok(new { data = "", code = 1, msg = "(标签)取样出库拣货错误:" + e.Message });
            }
            await _pdaSoSvc.SampleSoSetPick(model.Type, model.SoNo, model.SoDetailId, model.PalletNo, model.BoxNo, model.BoxNo3, model.PickQty, model.AsnNo, _userManager.UserId);
        }
        /// <summary>
        /// 取样出库拣货(无标签)