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 盘点
///
/// 获取盘点单据列表
///
/// PalletNo:托盘号
///
[HttpPost]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetStockCheckNoList(PdaCrVm model)
{
return await _pdaCrSvc.GetStockCheckNoList(model.PalletNo);
}
///
/// 获取盘点明细物料批次信息
///
/// CrNo:盘点单、PalletNo:托盘号
///
[HttpPost]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetStockCheckDetailList(PdaCrVm model)
{
return await _pdaCrSvc.GetStockCheckDetailList(model.CrNo, model.PalletNo);
}
///
/// 获取要盘点的箱码信息
///
///
///
[HttpPost]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetStockCheckLogList(PdaCrVm model)
{
return await _pdaCrSvc.GetStockCheckLogList(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo, model.isContinue);
}
///
/// 盘点库存
///
///
///
[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 库存查询
///
/// pda库存查询
///
/// 储位编号
/// 托盘号
/// 物料名称
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetStockQueryList(string locatNo, string palletNo)
{
return await _pdaCrSvc.GetStockQueryList(locatNo, palletNo);
}
#endregion
#region 托盘变更
///
/// 根据托盘号获取箱码和箱内数量
///
/// 托盘号
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetDataDetailList(string palletNo)
{
return await _pdaCrSvc.GetDataDetailList(palletNo);
}
///
/// 根据箱码获取物料、批次、数量等信息
///
/// 托盘号
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task GetBoxInfoByBox(string boxNo)
{
return await _pdaCrSvc.GetBoxInfoByBox(boxNo);
}
///
/// 解绑原托盘绑定新托盘
///
///
///
[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转运
///
/// 获取托盘所在储位地址
///
///
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task GetPalletLocatNo(string palletNo)
{
return await _pdaCrSvc.GetPalletLocatNo(palletNo);
}
///
/// 获取托盘所在楼层所有区域
///
///
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetStorageArea(string palletNo)
{
return await _pdaCrSvc.GetStorageArea(palletNo);
}
///
/// 获取托盘所在楼层所有区域
///
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetRunSoNoticeList()
{
return await _pdaCrSvc.GetRunSoNoticeList();
}
///
/// 根据托盘号获取托盘上物料信息
///
///
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetSkuInfoByPalletNo(string palletNo)
{
return await _pdaCrSvc.GetSkuInfoByPalletNo(palletNo);
}
///
/// 根据出库单号获取分配的托盘信息
///
///
///
[HttpGet]
[ServiceFilter(typeof(ApiResponseActionFilter))]
public async Task> GetPalletNoListBySoNo(string soNo)
{
return await _pdaCrSvc.GetPalletNoListBySoNo(soNo);
}
///
/// agv转运呼叫小车
///
///
///
[HttpPost]
[ServiceFilter(typeof(ApiResponseActionFilter))]
[UnitOfWork]
public async Task AgvTransport(PdaAgvTransportVm model)
{
await _pdaCrSvc.AgvTransport(model.PalletNo, model.AreaNo, model.Ruku, _userManager.UserId);
}
///
/// agv转运呼叫小车取货
///
///
///
[HttpPost]
[ServiceFilter(typeof(ApiResponseActionFilter))]
[UnitOfWork]
public async Task AgvTransport2(PdaAgvTransportVm model)
{
await _pdaCrSvc.AgvTransport2(model.SoNo, model.PalletNo, model.AreaNo, _userManager.UserId);
}
#endregion
#region 零箱解绑
///
/// 零箱解绑
///
///
///
[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 拆箱贴标
///
/// 拆箱贴标
///
///
///
[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
}
}