using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Mvc;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Security.Claims;
|
using System.Threading.Tasks;
|
using Microsoft.AspNetCore.Authorization;
|
using Model.ModelVm.PdaVm;
|
using WMS.IBLL.IPdaServer;
|
using WMS.Entity.DataEntity;
|
using WMS.Entity.SysEntity;
|
using Utility;
|
using Model.ModelDto.BllCheckDto;
|
using Model.ModelDto.PdaDto;
|
using Microsoft.AspNetCore.Identity;
|
using System.Security.Cryptography;
|
|
namespace Wms.Controllers
|
{
|
[Route("api/[controller]/[action]")]
|
[ApiController]
|
[Authorize]
|
public class PdaCrController : ControllerBase
|
{
|
private readonly IPdaCrServer _pdaCrSvc;
|
private readonly UserManager _userManager;
|
|
public PdaCrController(IPdaCrServer pdaCrSvc, UserManager userManager)
|
{
|
_pdaCrSvc = pdaCrSvc;
|
_userManager = userManager;
|
}
|
|
#region 盘点
|
|
/// <summary>
|
/// 获取盘点单据列表
|
/// </summary>
|
/// <param name="model">PalletNo:托盘号</param>
|
/// <returns></returns>
|
[HttpPost]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<string>> GetStockCheckNoList(PdaCrVm model)
|
{
|
return await _pdaCrSvc.GetStockCheckNoList(model.PalletNo);
|
}
|
|
/// <summary>
|
/// 获取盘点明细物料批次信息
|
/// </summary>
|
/// <param name="model">CrNo:盘点单、PalletNo:托盘号</param>
|
/// <returns></returns>
|
[HttpPost]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<StockCheckDetailDto>> GetStockCheckDetailList(PdaCrVm model)
|
{
|
return await _pdaCrSvc.GetStockCheckDetailList(model.CrNo, model.PalletNo);
|
}
|
|
/// <summary>
|
/// 获取要盘点的箱码信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<StockCheckLogDto>> GetStockCheckLogList(PdaCrVm model)
|
{
|
return await _pdaCrSvc.GetStockCheckLogList(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo, model.isContinue);
|
}
|
|
/// <summary>
|
/// 盘点库存
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[UnitOfWork]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public IActionResult CrSetCheck(PdaCrVm 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 = "未获取到当前操作人信息" });
|
}
|
|
_pdaCrSvc.CrSetCheck(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo, model.BoxNo3, model.Result, model.Qty, model.isContinue, int.Parse(userId));
|
|
return Ok(new { code = 0, msg = "盘点完成", data = "" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
#endregion
|
|
#region 库存查询
|
|
/// <summary>
|
/// pda库存查询
|
/// </summary>
|
/// <param name="locatNo">储位编号</param>
|
/// <param name="palletNo">托盘号</param>
|
/// <param name="skuName">物料名称</param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<DataStockDetail>> GetStockQueryList(string locatNo, string palletNo)
|
{
|
return await _pdaCrSvc.GetStockQueryList(locatNo, palletNo);
|
}
|
|
#endregion
|
|
#region 托盘变更
|
|
/// <summary>
|
/// 根据托盘号获取箱码和箱内数量
|
/// </summary>
|
/// <param name="palletNo">托盘号</param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<PdaPalletNoCheckDto>> GetDataDetailList(string palletNo)
|
{
|
return await _pdaCrSvc.GetDataDetailList(palletNo);
|
|
}
|
|
/// <summary>
|
/// 根据箱码获取物料、批次、数量等信息
|
/// </summary>
|
/// <param name="boxNo">托盘号</param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<PdaPalletNoCheckDto> GetBoxInfoByBox(string boxNo)
|
{
|
return await _pdaCrSvc.GetBoxInfoByBox(boxNo);
|
}
|
|
/// <summary>
|
/// 解绑原托盘绑定新托盘
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
[UnitOfWork]
|
public async Task SaveUnbind(PdaPalletCheckVm model)
|
{
|
await _pdaCrSvc.SaveUnbind(model.PalletNo, model.BoxNo, model.PalletNoNew, _userManager.UserId);
|
}
|
|
#endregion
|
|
#region AGV转运
|
/// <summary>
|
/// 获取托盘所在储位地址
|
/// </summary>
|
/// <param name="palletNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<string> GetPalletLocatNo(string palletNo)
|
{
|
return await _pdaCrSvc.GetPalletLocatNo(palletNo);
|
}
|
/// <summary>
|
/// 获取托盘所在楼层所有区域
|
/// </summary>
|
/// <param name="palletNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<SysStorageArea>> GetStorageArea(string palletNo)
|
{
|
return await _pdaCrSvc.GetStorageArea(palletNo);
|
}
|
/// <summary>
|
/// 获取托盘所在楼层所有区域
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<string>> GetRunSoNoticeList()
|
{
|
return await _pdaCrSvc.GetRunSoNoticeList();
|
}
|
/// <summary>
|
/// 根据托盘号获取托盘上物料信息
|
/// </summary>
|
/// <param name="palletNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<DataStockDetail>> GetSkuInfoByPalletNo(string palletNo)
|
{
|
return await _pdaCrSvc.GetSkuInfoByPalletNo(palletNo);
|
}
|
/// <summary>
|
/// 根据出库单号获取分配的托盘信息
|
/// </summary>
|
/// <param name="soNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
public async Task<List<string>> GetPalletNoListBySoNo(string soNo)
|
{
|
return await _pdaCrSvc.GetPalletNoListBySoNo(soNo);
|
}
|
/// <summary>
|
/// agv转运呼叫小车
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
[UnitOfWork]
|
public async Task AgvTransport(PdaAgvTransportVm model)
|
{
|
await _pdaCrSvc.AgvTransport(model.PalletNo, model.AreaNo, model.Ruku, _userManager.UserId);
|
}
|
/// <summary>
|
/// agv转运呼叫小车取货
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
[ServiceFilter(typeof(ApiResponseActionFilter))]
|
[UnitOfWork]
|
public async Task AgvTransport2(PdaAgvTransportVm model)
|
{
|
await _pdaCrSvc.AgvTransport2(model.SoNo, model.PalletNo, model.AreaNo, _userManager.UserId);
|
}
|
|
#endregion
|
|
#region 零箱解绑
|
/// <summary>
|
/// 零箱解绑
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult LingxingUnbind(PdaPalletUnBindVm 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 = "未获取到当前操作人信息" });
|
}
|
|
var uId = int.Parse(userId);
|
_pdaCrSvc.LingxingUnbind(model.PalletNo, model.BoxNo, uId);
|
|
return Ok(new { data = "", code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
}
|
#endregion
|
|
#region 拆箱贴标
|
|
/// <summary>
|
/// 拆箱贴标
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult AddLableByDevanning(PdaDevaningVm 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 = "未获取到当前操作人信息" });
|
}
|
|
var uId = int.Parse(userId);
|
_pdaCrSvc.AddLableByDevanning(model.BoxNo, model.DevanQty,uId);
|
|
return Ok(new { data = "", code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
}
|
#endregion
|
|
}
|
}
|