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 Wms.Tools;
|
using Microsoft.Extensions.Options;
|
|
namespace Wms.Controllers
|
{
|
[Route("api/[controller]/[action]")]
|
[ApiController]
|
[Authorize]
|
public class PdaCrController : ControllerBase
|
{
|
private readonly IPdaCrServer _pdaCrSvc;
|
private readonly ApiUrlConfig _config; //接口交互路径
|
public PdaCrController(IPdaCrServer pdaCrSvc, IOptions<ApiUrlConfig> setting)
|
{
|
_pdaCrSvc = pdaCrSvc;
|
_config = setting.Value;
|
}
|
|
#region 盘点
|
|
/// <summary>
|
/// 获取盘点单据列表
|
/// </summary>
|
/// <param name="model">PalletNo:托盘号</param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult GetStockCheckNoList(PdaCrVm model)
|
{
|
try
|
{
|
var list = _pdaCrSvc.GetStockCheckNoList(model.PalletNo);
|
|
return Ok(new { code = 0, msg = "盘点单信息", data = list });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
/// <summary>
|
/// 获取盘点明细物料批次信息
|
/// </summary>
|
/// <param name="model">CrNo:盘点单、PalletNo:托盘号</param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult GetStockCheckDetailList(PdaCrVm model)
|
{
|
try
|
{
|
var list = _pdaCrSvc.GetStockCheckDetailList(model.CrNo, model.PalletNo);
|
|
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 GetStockCheckLogList(PdaCrVm model)
|
{
|
try
|
{
|
var list = _pdaCrSvc.GetStockCheckLogList(model.CrNo, model.CrDetail, model.PalletNo, model.BoxNo,model.isContinue);
|
|
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 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]
|
public IActionResult GetStockQueryList(string locatNo, string palletNo )
|
{
|
try
|
{
|
List<DataStockDetail> stockList = _pdaCrSvc.GetStockQueryList(locatNo, palletNo);
|
if (stockList.Count==0)
|
{
|
return Ok(new { data = stockList, code = 1, msg = "无数据" });
|
}
|
return Ok(new { data = stockList, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
|
#endregion
|
|
#region 托盘变更
|
|
/// <summary>
|
/// 根据托盘号获取箱码和箱内数量
|
/// </summary>
|
/// <param name="palletNo">托盘号</param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetDataDetailList(string palletNo)
|
{
|
try
|
{
|
var list = _pdaCrSvc.GetDataDetailList(palletNo);
|
if (list.Count == 0)
|
{
|
return Ok(new { data = list, code = 1, msg = "无数据" });
|
}
|
return Ok(new { data = list, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
|
/// <summary>
|
/// 根据箱码获取物料、批次、数量等信息
|
/// </summary>
|
/// <param name="boxNo">托盘号</param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetBoxInfoByBox(string boxNo)
|
{
|
try
|
{
|
var list = _pdaCrSvc.GetBoxInfoByBox(boxNo);
|
if (list == null)
|
{
|
return Ok(new { data = list, code = 1, msg = "无数据" });
|
}
|
return Ok(new { data = list, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
|
/// <summary>
|
/// 解绑原托盘绑定新托盘
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult SaveUnbind(PdaPalletCheckVm 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.SaveUnbind(model.PalletNo, model.BoxNo, model.PalletNoNew, uId);
|
|
return Ok(new { data = "", code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
|
#endregion
|
|
#region AGV转运
|
/// <summary>
|
/// 获取托盘所在储位地址
|
/// </summary>
|
/// <param name="palletNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetPalletLocatNo(string palletNo)
|
{
|
try
|
{
|
string result = _pdaCrSvc.GetPalletLocatNo(palletNo);
|
|
return Ok(new { data = result, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
/// <summary>
|
/// 获取托盘所在楼层所有区域
|
/// </summary>
|
/// <param name="palletNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetStorageArea(string palletNo)
|
{
|
try
|
{
|
List<SysStorageArea> result = _pdaCrSvc.GetStorageArea(palletNo);
|
|
return Ok(new { data = result, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
/// <summary>
|
/// 获取托盘所在楼层所有区域
|
/// </summary>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetRunSoNoticeList()
|
{
|
try
|
{
|
List<string> result = _pdaCrSvc.GetRunSoNoticeList();
|
|
return Ok(new { data = result, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
/// <summary>
|
/// 根据托盘号获取托盘上物料信息
|
/// </summary>
|
/// <param name="palletNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetSkuInfoByPalletNo(string palletNo)
|
{
|
try
|
{
|
List<DataStockDetail> result = _pdaCrSvc.GetSkuInfoByPalletNo(palletNo);
|
|
return Ok(new { data = result, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
/// <summary>
|
/// 根据出库单号获取分配的托盘信息
|
/// </summary>
|
/// <param name="soNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetPalletNoListBySoNo(string soNo)
|
{
|
try
|
{
|
List<string> result = _pdaCrSvc.GetPalletNoListBySoNo(soNo);
|
|
return Ok(new { data = result, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
/// <summary>
|
/// agv转运呼叫小车
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult AgvTransport(PdaAgvTransportVm 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.AgvTransport(model.PalletNo, model.AreaNo, model.Ruku, uId, _config.AgvHost + _config.GenAgvSchedulingTask,_config.WcsHost + _config.HttpInConfirm);
|
|
return Ok(new { data = "", code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
}
|
/// <summary>
|
/// agv转运呼叫小车取货
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult AgvTransport2(PdaAgvTransportVm 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);
|
var str = _pdaCrSvc.AgvTransport2(model.SoNo,model.PalletNo, model.AreaNo,model.Ruku, uId, _config.WcsHost + _config.GenAgvSchedulingTask);
|
var msgStr = "";
|
if (str.Contains("0"))
|
{
|
msgStr += "成功";
|
}
|
if (str.Contains("1"))
|
{
|
msgStr += "部分托盘已有小车等待执行或正在执行的任务";
|
}
|
|
|
return Ok(new { data = "", code = 0, msg = msgStr });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
}
|
|
/// <summary>
|
/// 空托盘入库呼叫小车
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult AgvTransport3(PdaAgvTransNullPalnoModel 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.AgvTransport3(model.PalletNo, model.LocatNo, model.Ruku, uId, _config.AgvHost + _config.GenAgvSchedulingTask, _config.WcsHost + _config.HttpInConfirm);
|
|
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 ArtificialTransport(PdaArtificialTransportVm 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.ArtificialTransport(model.PalletNo, model.LocatNo, model.EndLocatNo, _config.MesHost + _config.MesGetTokenUrl,_config.MesHost+_config.MesBeiLiaoUrl, uId);
|
|
return Ok(new { data = "", code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
}
|
|
#endregion
|
|
#region 箱码查询
|
/// <summary>
|
/// pda箱码查询
|
/// </summary>
|
/// <param name="boxNo">箱码</param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult GetBoxQueryList(string boxNo)
|
{
|
try
|
{
|
DataBoxDto stockList = _pdaCrSvc.GetBoxQueryList(boxNo);
|
if (stockList == null)
|
{
|
return Ok(new { data = stockList, code = 1, msg = "无数据" });
|
}
|
return Ok(new { data = stockList, code = 0, msg = "成功" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { data = "", code = 1, msg = $"异常:{e.Message}" });
|
}
|
|
}
|
#endregion
|
|
}
|
}
|