using Infrastructure.Extensions;
using JinianNet.JNTemplate;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Tokens;
using ZR.Admin.WebApi.Extensions;
using ZR.Model.Dto;
using ZR.Model.MES.qu;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Service.mes.wms.IService;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ZR.Admin.WebApi.Controllers.mes.wms
{
///
/// 入库模块
///
[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;
}
///
/// 1. 判断是否为库位码
///
///
[HttpGet("is_production_location")]
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));
}
///
/// 2. 判断是否为成品库箱子码
///
///
[HttpGet("is_production_package")]
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));
}
///
/// 3.判断是否为满箱
///
///
[HttpGet("is_full_package")]
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 = state ? "满箱" : "不满箱";
return ToResponse(new ApiResult(200, msg, true));
}
///
/// 4.入库
///
///
///
[HttpPost("into_product_warehouse")]
public IActionResult IntoProductwarehouse([FromBody] WmgoodsDto wmgoodsDto)
{
if(wmgoodsDto == null)
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
string msg = "";
bool data = false;
string createName=HttpContext.GetName();
int status=this.wm_entryWarehousing_productService.IntoProductwarehouse(wmgoodsDto, createName);
if(status == 0)
{
msg = "数据插入异常";
data = false;
}
else if(status == 1)
{
msg = "success";
data = true;
}
return ToResponse(new ApiResult(200, msg, data));
}
///
/// 获取库位已经存在箱子
///
///
///
[HttpGet("packagelist")]
public IActionResult Getpackagelist(string locationcode)
{
if(string.IsNullOrEmpty(locationcode))
{
return ToResponse(new ApiResult(200, "传入为空", false));
}
string msg = null;
List productionList= this.wm_entryWarehousing_productService.Getpackagelist(locationcode);
return ToResponse(new ApiResult(200, msg, productionList));
}
}
}