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 { /// /// 入库模块 /// [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")] [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)); } /// /// 2. 判断是否为成品库箱子码 /// /// [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)); } /// /// 3.判断是否为满箱 /// /// [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)); } /// /// 4.入库 /// /// /// [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)); } } /// /// 获取库位已经存在箱子 /// /// /// [HttpGet("packagelist")] [Log(Title = "获取库位已经存在箱子")] 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)); } /// /// 解析外标签码 /// /// /// [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, "外标签解析异常")); } ; } /// /// 7 判断箱子是否存在成品库仓库里 /// /// /// [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)); } /// /// all.判断标签扫描结果是否可入库(综合结果判断) /// /// [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)); } } } }