shgx_tz_mom/U8Server/Controllers/WMentryWarehousing_productController.cs

244 lines
7.6 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
namespace WebApi.Controllers.mes.wms
{
/// <summary>
/// 入库模块
/// </summary>
[Route("/mes/wm/entrywarehouse")]
public class WMentryWarehousing_productController : BaseController
{
private readonly IWMentryWarehousing_productService wm_entryWarehousing_productService;
public WMentryWarehousing_productController(IWMentryWarehousing_productService wm_entryWarehousing_productService)
{
this.wm_entryWarehousing_productService = wm_entryWarehousing_productService;
}
/// <summary>
/// 1. 判断是否为库位码
/// </summary>
/// <returns></returns>
[HttpGet("is_production_location")]
[Log(Title = "判断是否为库位码")]
public IActionResult IsProductionLocation(string production_location_code = "")
{
if (string.IsNullOrEmpty(production_location_code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
// 查询 wm_info 表根据库位码查询在表中是否存在true false
bool state = this.wm_entryWarehousing_productService.IsProductionLoacation(production_location_code);
return ToResponse(new ApiResult(200, "success", state));
}
/// <summary>
/// 2. 判断是否为成品库箱子码
/// </summary>
/// <returns></returns>
[HttpGet("is_production_package")]
[Log(Title = "判断是否为成品库箱子码")]
public IActionResult IsProductionPackage(string package_code = "")
{
if (string.IsNullOrEmpty(package_code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
int state = this.wm_entryWarehousing_productService.isProductionPackage(package_code);
string msg = null;
if (state == 0)
msg = "外箱标签码不存在";
else if (state == 1)
msg = "success";
else if (state == 2)
msg = "误扫码,不是外箱标签码";
return ToResponse(new ApiResult(200, msg, state));
}
/// <summary>
/// 3.判断是否为满箱
/// </summary>
/// <returns></returns>
[HttpGet("is_full_package")]
[Log(Title = "判断是否为满箱")]
public IActionResult IsFullPackage(string package_code = "")
{
if (string.IsNullOrEmpty(package_code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
bool state = this.wm_entryWarehousing_productService.isFullPackage(package_code);
string msg = null;
if (state)
{
msg = "满箱";
}
else
{
msg = "零头箱";
}
return ToResponse(new ApiResult(200, msg, state));
}
/// <summary>
/// 4.入库
/// </summary>
/// <param name="wmgoodsDto"></param>
/// <returns></returns>
[HttpPost("into_product_warehouse")]
[Log(Title = "入库")]
public IActionResult IntoProductwarehouse([FromBody] WmgoodsDto wmgoodsDto)
{
try
{
if (wmgoodsDto == null)
{
return ToResponse(new ApiResult(200, "传入参数为空", false));
}
string msg = "";
string createName = HttpContext.GetName();
int num = this.wm_entryWarehousing_productService.IntoProductwarehouse(wmgoodsDto, createName);
if (num == 0)
{
msg = "入库数为0";
}
else if (num >= 1)
{
msg = "成功入库" + num + "箱";
}
return ToResponse(new ApiResult(200, msg, num));
}
catch (Exception e)
{
return ToResponse(new ApiResult(500, e.Message, e.Message));
}
}
/// <summary>
/// 获取库位已经存在箱子
/// </summary>
/// <param name="locationcode"></param>
/// <returns></returns>
[HttpGet("packagelist")]
[Log(Title = "获取库位已经存在箱子")]
public IActionResult Getpackagelist(string locationcode)
{
if (string.IsNullOrEmpty(locationcode))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
string msg = null;
List<WmGoodsNowProduction> productionList = this.wm_entryWarehousing_productService.Getpackagelist(locationcode);
return ToResponse(new ApiResult(200, msg, productionList));
}
/// <summary>
/// 解析外标签码
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
[HttpGet("resolution_package")]
public IActionResult ResolutionPackage(string code = "")
{
try
{
if (string.IsNullOrEmpty(code))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
ResultionPackageCodeDto data = this.wm_entryWarehousing_productService.ResolutionPackage(code);
if (data == null)
{
return ToResponse(new ApiResult(500, "外标签解析异常", data));
}
return ToResponse(new ApiResult(200, "success", data));
}
catch (Exception ex)
{
return ToResponse(new ApiResult(500, ex.Message, "外标签解析异常"));
}
;
}
/// <summary>
/// 7 判断箱子是否存在成品库仓库里
/// </summary>
/// <param name="PatchCode"></param>
/// <returns></returns>
[HttpGet("is_existed_warehouse")]
public IActionResult IsExistedWarehouse(string originalCode = "")
{
if (string.IsNullOrEmpty(originalCode))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
string msg = null;
bool data = this.wm_entryWarehousing_productService.IsExistedWarehouse(originalCode);
if (data)
{
msg = "存在";
}
else
{
msg = "不存在";
}
return ToResponse(new ApiResult(200, msg, data));
}
/// <summary>
/// all.判断标签扫描结果是否可入库(综合结果判断)
/// </summary>
/// <returns></returns>
[HttpGet("checkWarehousing")]
[Log(Title = "判断标签扫描结果是否可入库")]
public IActionResult CheckWarehousing(string production_packcode = "", string location = "",
bool isStrict = false)
{
string msg = this.wm_entryWarehousing_productService.checkWarehousing(production_packcode, location, isStrict);
if ("ok".Equals(msg))
{
// 可入库
return ToResponse(new ApiResult(200, msg, true));
}
else
{
// 不可入库
return ToResponse(new ApiResult(200, msg, false));
}
}
}
}