using System;
|
using System.Collections.Generic;
|
using System.Security.Claims;
|
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.Extensions.Options;
|
using Model.ModelVm;
|
using Model.ModelVm.LogVm;
|
using Model.ModelVm.SysVm;
|
using WMS.IBLL.IBllAsnServer;
|
using WMS.IBLL.ILogServer;
|
using WmsApi.Tools;
|
|
namespace WmsApi.Controllers
|
{
|
[Route("api/[controller]/[action]")]
|
[ApiController]
|
[Authorize]
|
public class BllAsnController : ControllerBase
|
{
|
#region 依赖注入
|
private readonly ApiUrlConfig _config; //接口交互路径
|
private readonly IArrivalNoticeServer _arrivalNoticeSvc; // 入库单据Svc
|
private readonly IPalletBindServer _PalletBindSvc; // 托盘绑定Svc
|
private readonly IBllBoxInfoServer _BoxInfoSvc;
|
private readonly ITaskServer _taskSvc; //入库任务Svc
|
private readonly IOperationASNServer _logSvc; //入库库操作日志Svc
|
#endregion
|
|
#region 构造函数
|
public BllAsnController(IOptions<ApiUrlConfig> setting, IArrivalNoticeServer arrivalNoticeSvc, IPalletBindServer palletBindSvc,IBllBoxInfoServer bllBoxInfoSvc, ITaskServer taskSvc,IOperationASNServer logSvc)
|
{
|
_config = setting.Value;
|
_arrivalNoticeSvc = arrivalNoticeSvc;
|
_PalletBindSvc = palletBindSvc;
|
_BoxInfoSvc = bllBoxInfoSvc;
|
_taskSvc = taskSvc;
|
_logSvc = logSvc;
|
}
|
#endregion
|
|
#region 入库单据
|
/// <summary>
|
/// 获取入库单信息
|
/// </summary>
|
/// <param name="model">查询条件</param>
|
/// <returns>入库单信息</returns>
|
[HttpPost]
|
public IActionResult GetArrivalNoticeList(ArrivalNoticeVm model)
|
{
|
try
|
{
|
var models = _arrivalNoticeSvc.GetArrivalNoticeList(model, out int count);
|
|
return Ok(new { code = 0, count, msg = "入库单信息", data = models });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult GetArrivalNotice(ArrivalNoticeVm model)
|
{
|
try
|
{
|
var models = _arrivalNoticeSvc.GetArrivalNoticeList(model, out int count);
|
|
return Ok(new { code = 0, count, msg = "入库单信息", data = models[0] });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult GetArrivalNoticeDetailList(ArrivalNoticeDetailVm model)
|
{
|
try
|
{
|
var models = _arrivalNoticeSvc.GetArrivalNoticeDetailList(model, out int count);
|
|
return Ok(new { code = 0, count, msg = "入库单明细信息", data = models });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult GetMaterialsList(GetMaterialsVm model)
|
{
|
try
|
{
|
var models = _arrivalNoticeSvc.GetMaterialsList(model);
|
|
return Ok(new { code = 0, msg = "物料信息", data = models });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult AddArrivalNotice(ArrivalNoticeVm model)
|
{
|
try
|
{
|
//_=model.AsnDetail[0].InspectNo;
|
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.CreateUser = int.Parse(UserId);
|
string strMesage = _arrivalNoticeSvc.AddArrivalNotice(model);
|
|
if (strMesage == "")
|
{
|
return Ok(new { code = 0, msg = "添加成功" });
|
}
|
if (strMesage.Contains("-1"))
|
{
|
return Ok(new { code = 0, msg = "部分成功" });
|
}
|
else
|
{
|
return Ok(new { code = 1, msg = strMesage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult EditArrivalNotice(ArrivalNoticeVm 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.CreateUser = int.Parse(UserId);
|
string strMesage = _arrivalNoticeSvc.EditArrivalNotice(model);
|
|
if (strMesage == "")
|
{
|
return Ok(new { code = 0, msg = "编辑成功" });
|
}
|
if (strMesage.Contains("-1"))
|
{
|
return Ok(new { code = 0, msg = "部分成功" });
|
}
|
else
|
{
|
return Ok(new { code = 1, msg = strMesage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult DelArrivalNotice(ArrivalNoticeVm 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.CreateUser = int.Parse(UserId);
|
string strMesage = _arrivalNoticeSvc.DelArrivalNotice(model);
|
|
if (strMesage == "")
|
{
|
return Ok(new { code = 0, msg = "删除成功" });
|
}
|
else
|
{
|
return Ok(new { code = 1, msg = strMesage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult DelArrivalNoticeDetail(ArrivalNoticeDetailVm 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.CreateUser = int.Parse(UserId);
|
string strMesage = _arrivalNoticeSvc.DelArrivalNoticeDetail(model);
|
|
if (strMesage == "")
|
{
|
return Ok(new { code = 0, msg = "删除成功" });
|
}
|
else
|
{
|
return Ok(new { code = 1, msg = strMesage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
#endregion
|
|
#region 托盘绑定
|
[HttpPost]
|
public IActionResult GetPalletBindList(PalletBindVm model)
|
{
|
try
|
{
|
var models = _PalletBindSvc.GetPalletBindList(model, out int count);
|
|
return Ok(new { code = 0, count, msg = "托盘绑定信息", data = models });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult GetBoxInfoList(BoxInfoVm model)
|
{
|
try
|
{
|
var models = _PalletBindSvc.GetBoxInfoList(model, out int count);
|
|
return Ok(new { code = 0, count, 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 DelPalletBind(IdVm 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("未获取到用户信息");
|
}
|
_PalletBindSvc.DelPalletBind(model.Id, int.Parse(userId));
|
|
return Ok(new { code = 0, count = 0, msg = "删除成功", data = "" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
/// <summary>
|
/// 删除绑定的箱码信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult DelBindBoxInfo(IdVm 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("未获取到用户信息");
|
}
|
_PalletBindSvc.DelBindBoxInfo(model.Id, int.Parse(userId));
|
|
return Ok(new { code = 0, count = 0, msg = "删除成功", data = "" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
|
#endregion
|
|
#region 指定储位
|
|
/// <summary>
|
/// 指定储位数据源(正常的空储位)
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult GetLocateList(GetOkLocateVm model)
|
{
|
try
|
{
|
var models = _PalletBindSvc.GetLocateList("W01",model.RoadwayNo,model.Row,model.Column,model.Layer,model.LocateNo,model.Page,model.Limit, out int count);
|
|
return Ok(new { code = 0, count, 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 SaveAppointSlot(SaveLocateVm 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("未获取到用户信息");
|
}
|
_PalletBindSvc.SaveAppointSlot(model.BindId,model.LocateId,int.Parse(userId));
|
|
return Ok(new { code = 0, count = 0, msg = "指定储位成功", data = "" });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
#endregion
|
|
#region 物料信息录入
|
[HttpPost]
|
public IActionResult GetBllBoxInfoList(BoxInfoVm model)
|
{
|
try
|
{
|
var models = _BoxInfoSvc.GetBoxInfoList(model, out int count);
|
|
return Ok(new { code = 0, count, msg = "箱支信息", data = models });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult AddBllBoxInfo(BoxInfoVm 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.CreateUser = int.Parse(UserId);
|
string strMesage = _BoxInfoSvc.AddBoxInfo(model);
|
|
if (strMesage == "")
|
{
|
return Ok(new { code = 0, msg = "添加成功" });
|
}
|
else
|
{
|
return Ok(new { code = 1, msg = strMesage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = "添加失败:" + e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult DelBllBoxInfo(BoxInfoVm 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.CreateUser = int.Parse(UserId);
|
string strMesage = _BoxInfoSvc.DelBoxInfo(model);
|
|
if (strMesage == "")
|
{
|
return Ok(new { code = 0, msg = "删除成功" });
|
}
|
else
|
{
|
return Ok(new { code = 1, msg = strMesage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
[HttpPost]
|
public IActionResult ImportBllBoxInfo(BoxInfoVms models)
|
{
|
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("未获取到用户信息");
|
}
|
|
models.CreateUser = int.Parse(UserId);
|
string strMessage = _BoxInfoSvc.ImportBoxInfo(models);
|
|
if (strMessage.Contains("-1"))
|
{
|
return Ok(new { code = 1, msg = strMessage });
|
}
|
else
|
{
|
return Ok(new { code = 0, msg = strMessage });
|
}
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
#endregion
|
|
#region 入库日志
|
|
/// <summary>
|
/// 获取入库任务信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult GetArrivalTaskList(GetTaskVm model)
|
{
|
try
|
{
|
var type = new List<string>() { "0" };
|
var bolls = _taskSvc.GetTaskList(type, model.Type, model.Status, model.TaskNo, model.IsSuccess, model.PalletNo,model.StartTime,model.EndTime, model.Msg, model.Page, model.Limit, out int count);
|
|
return Ok(new { code = 0, count, msg = "入库任务信息", data = bolls });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
/// <summary>
|
/// 取消入库任务
|
/// </summary>
|
/// <param name="taskNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult CancelAsnTask(string taskNo)
|
{
|
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 = "未获取到当前操作人信息" });
|
}
|
_PalletBindSvc.CancelAsnTask(taskNo, int.Parse(userId), _config.WcsHost + _config.FinshComApiUrl);
|
|
return Ok(new { code = 0, msg = "取消任务已完成", data = "" });
|
|
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
/// <summary>
|
/// 完成入库任务
|
/// </summary>
|
/// <param name="taskNo"></param>
|
/// <returns></returns>
|
[HttpGet]
|
public IActionResult FinishAsnTask(string taskNo)
|
{
|
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 = "未获取到当前操作人信息" });
|
}
|
_PalletBindSvc.ArrivalSuccess(taskNo, int.Parse(userId), _config.WcsHost + _config.FinshComApiUrl);
|
|
return Ok(new { code = 0, msg = "成功完成任务", data = "" });
|
|
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
|
#endregion
|
|
#region 操作日志
|
|
/// <summary>
|
/// 获取入库操作日志信息
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
[HttpPost]
|
public IActionResult GetLogOperationAsnList(GetOperationVm model)
|
{
|
try
|
{
|
var bolls = _logSvc.GetLogOperationAsnList(model.MenuName, model.Type, model.Msg, model.StartTime, model.EndTime, model.Page, model.Limit, out int count);
|
|
return Ok(new { code = 0, count, msg = "入库操作日志信息", data = bolls });
|
}
|
catch (Exception e)
|
{
|
return Ok(new { code = 1, msg = e.Message });
|
}
|
}
|
|
#endregion
|
}
|
|
}
|