diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs index 9ab4a6c8..d294c392 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WMentryWarehousing_productController.cs @@ -1,10 +1,15 @@ 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 { @@ -18,7 +23,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms private readonly IWMentryWarehousing_productService wm_entryWarehousing_productService; public WMentryWarehousing_productController(IWMentryWarehousing_productService wm_entryWarehousing_productService) { - this.wm_entryWarehousing_productService = wm_entryWarehousing_productService; + this.wm_entryWarehousing_productService = wm_entryWarehousing_productService; } /// @@ -28,7 +33,11 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms [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); @@ -42,7 +51,24 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms [HttpGet("is_production_package")] public IActionResult IsProductionPackage(string package_code = "") { - return ToResponse(new ApiResult(200, "success", true)); + 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)); + } /// @@ -52,8 +78,66 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms [HttpGet("is_full_package")] public IActionResult IsFullPackage(string package_code = "") { - return ToResponse(new ApiResult(200, "success", true)); + + 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)); } } - + } diff --git a/ZR.Admin.WebApi/Controllers/mes/wms/WMlocationInfoController.cs b/ZR.Admin.WebApi/Controllers/mes/wms/WMlocationInfoController.cs index 73062a85..f1bab376 100644 --- a/ZR.Admin.WebApi/Controllers/mes/wms/WMlocationInfoController.cs +++ b/ZR.Admin.WebApi/Controllers/mes/wms/WMlocationInfoController.cs @@ -5,6 +5,7 @@ using Microsoft.IdentityModel.Tokens; using ZR.Model.MES.qu; using ZR.Model.MES.wms; using ZR.Service.mes.wms.IService; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace ZR.Admin.WebApi.Controllers.mes.wms { @@ -13,7 +14,7 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms public class WMlocationInfoController : BaseController { - private readonly IWMlocationInfoService wm_locationInfoService; + private readonly IWMlocationInfoService wm_locationInfoService; public WMlocationInfoController(IWMlocationInfoService wm_locationInfoService) { this.wm_locationInfoService = wm_locationInfoService; @@ -25,11 +26,25 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms /// /// [HttpGet("production_warehouse_info")] - public IActionResult Queryproduction_warehouse_info(string shelf = "", int layer = 0,int pageNum=0,int pageSize=0) + public IActionResult Queryproduction_warehouse_info(string shelf = "", int layer = 0, int pageNum = 0, int pageSize = 0) { (List, int) data = wm_locationInfoService.Getwminfo_product(shelf, layer, pageNum, pageSize); return ToResponse(new ApiResult(200, "success", data)); } + + /// + /// 获取库位信息 + /// + [HttpGet("get_location_info")] + public IActionResult Querylocationinfo(int warehouse_num, string locationcode = "") + { + + WmInfo wmInfo= wm_locationInfoService.Getlocationinfo(warehouse_num, locationcode); + return ToResponse(new ApiResult(200, "success", wmInfo)); + + + + } } } diff --git a/ZR.Model/MES/wms/Dto/WmgoodsDto.cs b/ZR.Model/MES/wms/Dto/WmgoodsDto.cs new file mode 100644 index 00000000..1d46812d --- /dev/null +++ b/ZR.Model/MES/wms/Dto/WmgoodsDto.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ZR.Model.MES.wms.Dto +{ + /// + /// 待入库货物 + /// + public class WmgoodsDto + { + /// + /// 货架 + /// + public string location { set; get; } + /// + /// 箱子列表 + /// + public string[] packagelist { set; get; } + } +} diff --git a/ZR.Model/MES/wms/WmGoodsNowProduction.cs b/ZR.Model/MES/wms/WmGoodsNowProduction.cs new file mode 100644 index 00000000..39421fcc --- /dev/null +++ b/ZR.Model/MES/wms/WmGoodsNowProduction.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SqlSugar; +namespace ZR.Model.MES.wms +{ + /// + /// 成品库当前货物表 + /// + [SugarTable("wm_goods_now_production")] + public class WmGoodsNowProduction + { + /// + /// 雪花id + /// + [SugarColumn(ColumnName = "id", IsPrimaryKey = true)] + public string Id { get; set; } + /// + /// 箱子编号 + /// + [SugarColumn(ColumnName = "package_code")] + public string PackageCode { get; set; } + /// + /// 库位编号 + /// + [SugarColumn(ColumnName = "location_code")] + public string LocationCode { get; set; } + /// + /// 箱子中货物数量(理论) + /// + [SugarColumn(ColumnName = "goods_num_logic")] + public int? GoodsNumLogic { get; set; } + /// + /// 箱子中货物数量(实际) + /// + [SugarColumn(ColumnName = "goods_num_action")] + public int? GoodsNumAction { get; set; } + /// + /// 入库时间 + /// + [SugarColumn(ColumnName = "entry_warehouse_time")] + public DateTime? EntryWarehouseTime { get; set; } + /// + /// 备注 + /// + [SugarColumn(ColumnName = "remark")] + public string Remark { get; set; } + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "UPDATED_BY")] + public string UpdatedBy { get; set; } + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "UPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "CREATED_BY")] + public string CreatedBy { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CREATED_TIME")] + public DateTime? CreatedTime { get; set; } + } +} diff --git a/ZR.Model/MES/wms/WmPackingrecord.cs b/ZR.Model/MES/wms/WmPackingrecord.cs new file mode 100644 index 00000000..fa3bc5b4 --- /dev/null +++ b/ZR.Model/MES/wms/WmPackingrecord.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using SqlSugar; + +namespace ZR.Model.MES.wms +{ + /// + /// 包装记录 + /// + [SugarTable("wm_packingrecord")] + public class WmPackingrecord + { + /// + /// + /// + [SugarColumn(ColumnName = "ID", IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + /// + /// 零件号 + /// + [SugarColumn(ColumnName = "PartNum")] + public string PartNum { get; set; } + /// + /// 设备名称(ID) + /// + [SugarColumn(ColumnName = "Machine")] + public string Machine { get; set; } + /// + /// 产品条码 + /// + [SugarColumn(ColumnName = "ProductCode")] + public string ProductCode { get; set; } + /// + /// 箱条码 + /// + [SugarColumn(ColumnName = "PackingCode")] + public string PackingCode { get; set; } + /// + /// 扫码记录 + /// + [SugarColumn(ColumnName = "ScannerContent")] + public string ScannerContent { get; set; } + /// + /// 工单号 + /// + [SugarColumn(ColumnName = "WorkOrderNum")] + public string WorkOrderNum { get; set; } + /// + /// 备用3 + /// + [SugarColumn(ColumnName = "Standby3")] + public string Standby3 { get; set; } + /// + /// 备用4 + /// + [SugarColumn(ColumnName = "Standby4")] + public string Standby4 { get; set; } + /// + /// 备用5 + /// + [SugarColumn(ColumnName = "Standby5")] + public string Standby5 { get; set; } + /// + /// 指示是否满箱 + /// 默认值: b'0' + /// + [SugarColumn(ColumnName = "BFilled")] + public bool BFilled { get; set; } + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "CreateTime")] + public DateTime? CreateTime { get; set; } + } +} diff --git a/ZR.Service/mes/wms/IService/IWMWarehousingService.cs b/ZR.Service/mes/wms/IService/IWMWarehousingService.cs index 8bef042d..62584d02 100644 --- a/ZR.Service/mes/wms/IService/IWMWarehousingService.cs +++ b/ZR.Service/mes/wms/IService/IWMWarehousingService.cs @@ -6,6 +6,7 @@ using System.Text; using System.Threading.Tasks; using ZR.Model.MES.qc.DTO; using ZR.Model.MES.wms; +using ZR.Model.MES.wms.Dto; namespace ZR.Service.mes.wms.IService { @@ -16,6 +17,18 @@ namespace ZR.Service.mes.wms.IService // 获取库位列表 public bool IsProductionLoacation(string production_location_code); + // 判断是否为成品箱子码 + public int isProductionPackage(string production_packcode); + + //判断箱子是否满 + public bool isFullPackage(string production_packcode); + + // 货物入库 + public int IntoProductwarehouse(WmgoodsDto wmgoods, string createName); + + //获取库位已经存在的货物 + public List Getpackagelist(string location); + } diff --git a/ZR.Service/mes/wms/IService/IWMlocationInfoService.cs b/ZR.Service/mes/wms/IService/IWMlocationInfoService.cs index 1fa833d3..c6a7ae14 100644 --- a/ZR.Service/mes/wms/IService/IWMlocationInfoService.cs +++ b/ZR.Service/mes/wms/IService/IWMlocationInfoService.cs @@ -15,7 +15,7 @@ namespace ZR.Service.mes.wms.IService // 获取成品库信息 public (List,int) Getwminfo_product(string shelf , int layer, int pageNum , int pageSize); - - + // 获取库位信息 + public WmInfo Getlocationinfo(int warehouse_num, string locationcode); } } diff --git a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs index 3ab1952d..baa1f2cb 100644 --- a/ZR.Service/mes/wms/WMentryWarehousing_productService.cs +++ b/ZR.Service/mes/wms/WMentryWarehousing_productService.cs @@ -6,9 +6,11 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using ZR.Model.MES.qu; using ZR.Model.MES.wms; +using ZR.Model.MES.wms.Dto; using ZR.Service.mes.qc.IService; using ZR.Service.mes.wms.IService; @@ -17,6 +19,85 @@ namespace ZR.Service.mes.wms [AppService(ServiceType = typeof(IWMentryWarehousing_productService), ServiceLifetime = LifeTime.Transient)] public class WMentryWarehousing_productService : BaseService, IWMentryWarehousing_productService { + //货物入库 + public int IntoProductwarehouse(WmgoodsDto wmgoods, string createName) + { + List preparegoodsList = new List(); + if (wmgoods.packagelist != null && wmgoods.packagelist.Count() > 0) + { + for (int i = 0; i < wmgoods.packagelist.Count(); i++) + { + WmGoodsNowProduction wmGood = new WmGoodsNowProduction(); + wmGood.Id = SnowFlakeSingle.Instance.NextId().ToString(); + + + wmGood.PackageCode = Getpack_no(wmgoods.packagelist[i]); + wmGood.LocationCode = wmgoods.location; + + string workorder_id = wmgoods.packagelist[i].Substring(3, 9); + + + wmGood.GoodsNumLogic = Context.Queryable() + .Where(it => it.WorkOrderNum == workorder_id) + .Count(); + + wmGood.EntryWarehouseTime = DateTime.Now; + wmGood.CreatedBy = createName; + wmGood.CreatedTime = DateTime.Now; + + + preparegoodsList.Add(wmGood); + + + } + + } + + int result = Context.Insertable(preparegoodsList).ExecuteCommand(); + return result; + } + + //判断箱子是否满 + public bool isFullPackage(string production_packcode) + { + string workorder_id = production_packcode.Substring(3, 9); + string flow_id = production_packcode.Substring(13, 3); + bool isExist = Context.Queryable() + .Where(it => it.WorkOrderNum == workorder_id) + .Where(it => it.PackingCode.EndsWith(flow_id)) + .Where(it => it.BFilled == true).Any(); + return isExist; + } + + /// + /// 判断是否为成品箱子码 + /// + /// + /// + public int isProductionPackage(string production_packcode) + { + Regex r = new Regex("BNW_\\d{9}_\\d{3}"); + //todo 不是箱子 + if (!r.IsMatch(production_packcode)) + { + return 2; + } + string workorder_id = production_packcode.Substring(3, 9); + string flow_id = production_packcode.Substring(13, 3); + bool isExist = Context.Queryable() + .Where(it => it.WorkOrderNum == workorder_id) + .Where(it => it.PackingCode.EndsWith(flow_id)) + .Any(); + if (!isExist) + { + return 0; + } + + + return 1; + + } + bool IWMentryWarehousing_productService.IsProductionLoacation(string production_location_code) { @@ -24,5 +105,35 @@ namespace ZR.Service.mes.wms .Where(it => it.Location.Equals(production_location_code)).Any(); } + /// + /// 获取箱子唯一识别号 + /// + /// + /// + private string Getpack_no(string production_packcode) + { + string workorder_id = production_packcode.Substring(3, 9); + string flow_id = production_packcode.Substring(13, 3); + + WmPackingrecord record = Context.Queryable() + .Where(it => it.WorkOrderNum == workorder_id) + .Where(it => it.PackingCode.EndsWith(flow_id)) + .First(); + + + if (record == null) + { + return null; + } + + return record.ProductCode; + } + + //获取库位已经存在的货物 + public List Getpackagelist(string location) + { + return Context.Queryable().Where(it=>it.LocationCode==location).ToList(); + + } } } diff --git a/ZR.Service/mes/wms/WMlocationInfoService.cs b/ZR.Service/mes/wms/WMlocationInfoService.cs index 9480305f..fa759a8b 100644 --- a/ZR.Service/mes/wms/WMlocationInfoService.cs +++ b/ZR.Service/mes/wms/WMlocationInfoService.cs @@ -16,6 +16,18 @@ namespace ZR.Service.mes.wms [AppService(ServiceType = typeof(IWMlocationInfoService), ServiceLifetime = LifeTime.Transient)] public class WMlocationInfoService : BaseService, IWMlocationInfoService { + /// + /// 查询库位信息 + /// + /// + /// + /// + /// + public WmInfo Getlocationinfo(int warehouse_num, string locationcode) + { + return Context.Queryable().Where(it=>it.WarehouseNum== warehouse_num && it.Location==locationcode).First(); + } + /// /// 获取成品库库位信息 ///