chengsc
2025-06-11 1c2541b283ce6ba855e67c476412dffe2c693480
Wms/Wms/Controllers/PdaAsnController.cs
@@ -1,16 +1,20 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Model.InterFaceModel;
using Model.ModelDto.BllAsnDto;
using Model.ModelDto.DataDto;
using Model.ModelVm;
using Model.ModelVm.BllAsnVm;
using Model.ModelVm.PdaVm;
using Model.ModelVm.SysVm;
using Newtonsoft.Json;
using System;
using System.Security.Claims;
using Utility;
using Utility.Tools;
using Wms.Tools;
using WMS.BLL.LogServer;
using WMS.Entity.BllAsnEntity;
using WMS.Entity.DataEntity;
@@ -23,11 +27,15 @@
    [Authorize]
    public class PdaAsnController : ControllerBase
    {
        private readonly ApiUrlConfig _config; //接口交互路径
        private readonly IPdaAsnServer _PdaAsnSvc;
        private readonly UserManager _userManager;
        public PdaAsnController(IPdaAsnServer pdaAsnSvc)
        public PdaAsnController(IOptions<ApiUrlConfig> setting, IPdaAsnServer pdaAsnSvc,UserManager userManager)
        {
            _PdaAsnSvc = pdaAsnSvc;
            _config = setting.Value;
            _PdaAsnSvc = pdaAsnSvc;
            _userManager = userManager;
        }
        
@@ -175,7 +183,27 @@
        {
            try
            {
                var models = _PdaAsnSvc.GetBindBoxInfos(model);
                var models = _PdaAsnSvc.GetBindBoxInfos(model, _config.BoxHost + _config.GetBoxUrl);
                return Ok(new { code = 0, msg = "标签箱码信息", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 根据箱码获取标签箱码信息(车间入库-获取WMS生成的箱信息)
        /// </summary>
        /// <param name="boxNo">BoxNo:箱号</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetWmsBoxInfos(string boxNo)
        {
            try
            {
                var models = _PdaAsnSvc.GetWmsBoxInfos(boxNo);
                return Ok(new { code = 0, msg = "标签箱码信息", data = models });
            }
@@ -212,14 +240,90 @@
            }
        }
        /// <summary>
        /// 根据单据获取标签数量
        /// </summary>
        /// <param name="model">ASNNo:入库单、ASNDetailNo:入库单明细号</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetBoxCountByAsn(PalletBindVm model)
        {
            try
            {
                var list = _PdaAsnSvc.GetBoxCountByAsn(model.ASNNo,model.ASNDetailNo);
                return Ok(new { code = 0, msg = "根据单据获取标签数量", data= list});
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        /// <summary>
        /// 绑定托盘
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ChejianIn(PdaPalletBindVm model)
        {
            try
            {
                if (_userManager.UserId ==0)
                {
                    throw new Exception("未获取到用户信息");
                }
                if (model.TableType == 0)
                {
                    _PdaAsnSvc.ChejianIn(model.PalletNo,model.BoxNo,model.SkuQty,model.AreaNo, _userManager.UserId);
                }
                else if (model.TableType == 1)
                {
                    _PdaAsnSvc.ChejianQtyIn(model.PalletNo,model.SkuNo,model.LotNo,model.SkuQty,model.AreaNo, _userManager.UserId);
                }
                return Ok(new { code = 0, msg = "绑定成功!" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        //---------------------------------------------申请入库页面----------------------------------------------------------------------
        /// <summary>
        /// 保存指定的储位
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult SaveAppointLocate(PalletBindVm model)
        {
            try
            {
                _PdaAsnSvc.SaveAppointLocate(model.PalletNo, model.LocatNo, _userManager.UserId);
                return Ok(new HttpReturnModel{ Success = "0", Message = "成功指定储位" });
            }
            catch (Exception e)
            {
                return Ok(new HttpReturnModel { Success = "1", Message = e.Message });
            }
        }
        #endregion
        #region 公用方法
        /// <summary>
@@ -653,7 +757,6 @@
        #endregion
         
        #region 平库入库
        /// <summary>
        /// 平库确认入库
@@ -771,5 +874,58 @@
        #endregion
        #region 线编标签
        /// <summary>
        /// 平库确认入库
        /// </summary>
        /// <param name="model">物料编码;物料名称</param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult GetSkuInfo(GetMaterialsVm model)
        {
            try
            {
                var models = _PdaAsnSvc.GetSkuInfo(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 AddLabels(LabelsVm 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.userId = int.Parse(UserId);
                var models = _PdaAsnSvc.AddLabels(model);
                return Ok(new { code = 0, msg = "箱码生成成功!", data = models });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
    }
}