入库模块init
This commit is contained in:
@@ -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
|
||||
{
|
||||
@@ -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));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,7 +78,65 @@ 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));
|
||||
}
|
||||
/// <summary>
|
||||
/// 4.入库
|
||||
/// </summary>
|
||||
/// <param name="wmgoodsDto"></param>
|
||||
/// <returns></returns>
|
||||
[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));
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取库位已经存在箱子
|
||||
/// </summary>
|
||||
/// <param name="locationcode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("packagelist")]
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -30,6 +31,20 @@ namespace ZR.Admin.WebApi.Controllers.mes.wms
|
||||
(List<WmInfo>, int) data = wm_locationInfoService.Getwminfo_product(shelf, layer, pageNum, pageSize);
|
||||
return ToResponse(new ApiResult(200, "success", data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取库位信息
|
||||
/// </summary>
|
||||
[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));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
23
ZR.Model/MES/wms/Dto/WmgoodsDto.cs
Normal file
23
ZR.Model/MES/wms/Dto/WmgoodsDto.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 待入库货物
|
||||
/// </summary>
|
||||
public class WmgoodsDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架
|
||||
/// </summary>
|
||||
public string location { set; get; }
|
||||
/// <summary>
|
||||
/// 箱子列表
|
||||
/// </summary>
|
||||
public string[] packagelist { set; get; }
|
||||
}
|
||||
}
|
||||
69
ZR.Model/MES/wms/WmGoodsNowProduction.cs
Normal file
69
ZR.Model/MES/wms/WmGoodsNowProduction.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SqlSugar;
|
||||
namespace ZR.Model.MES.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 成品库当前货物表
|
||||
///</summary>
|
||||
[SugarTable("wm_goods_now_production")]
|
||||
public class WmGoodsNowProduction
|
||||
{
|
||||
/// <summary>
|
||||
/// 雪花id
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true)]
|
||||
public string Id { get; set; }
|
||||
/// <summary>
|
||||
/// 箱子编号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "package_code")]
|
||||
public string PackageCode { get; set; }
|
||||
/// <summary>
|
||||
/// 库位编号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "location_code")]
|
||||
public string LocationCode { get; set; }
|
||||
/// <summary>
|
||||
/// 箱子中货物数量(理论)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "goods_num_logic")]
|
||||
public int? GoodsNumLogic { get; set; }
|
||||
/// <summary>
|
||||
/// 箱子中货物数量(实际)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "goods_num_action")]
|
||||
public int? GoodsNumAction { get; set; }
|
||||
/// <summary>
|
||||
/// 入库时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "entry_warehouse_time")]
|
||||
public DateTime? EntryWarehouseTime { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "remark")]
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "UPDATED_BY")]
|
||||
public string UpdatedBy { get; set; }
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "UPDATED_TIME")]
|
||||
public DateTime? UpdatedTime { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "CREATED_BY")]
|
||||
public string CreatedBy { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "CREATED_TIME")]
|
||||
public DateTime? CreatedTime { get; set; }
|
||||
}
|
||||
}
|
||||
76
ZR.Model/MES/wms/WmPackingrecord.cs
Normal file
76
ZR.Model/MES/wms/WmPackingrecord.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.MES.wms
|
||||
{
|
||||
/// <summary>
|
||||
/// 包装记录
|
||||
///</summary>
|
||||
[SugarTable("wm_packingrecord")]
|
||||
public class WmPackingrecord
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ID", IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 零件号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PartNum")]
|
||||
public string PartNum { get; set; }
|
||||
/// <summary>
|
||||
/// 设备名称(ID)
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Machine")]
|
||||
public string Machine { get; set; }
|
||||
/// <summary>
|
||||
/// 产品条码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ProductCode")]
|
||||
public string ProductCode { get; set; }
|
||||
/// <summary>
|
||||
/// 箱条码
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "PackingCode")]
|
||||
public string PackingCode { get; set; }
|
||||
/// <summary>
|
||||
/// 扫码记录
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "ScannerContent")]
|
||||
public string ScannerContent { get; set; }
|
||||
/// <summary>
|
||||
/// 工单号
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "WorkOrderNum")]
|
||||
public string WorkOrderNum { get; set; }
|
||||
/// <summary>
|
||||
/// 备用3
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Standby3")]
|
||||
public string Standby3 { get; set; }
|
||||
/// <summary>
|
||||
/// 备用4
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Standby4")]
|
||||
public string Standby4 { get; set; }
|
||||
/// <summary>
|
||||
/// 备用5
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "Standby5")]
|
||||
public string Standby5 { get; set; }
|
||||
/// <summary>
|
||||
/// 指示是否满箱
|
||||
/// 默认值: b'0'
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "BFilled")]
|
||||
public bool BFilled { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
///</summary>
|
||||
[SugarColumn(ColumnName = "CreateTime")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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<WmGoodsNowProduction> Getpackagelist(string location);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ZR.Service.mes.wms.IService
|
||||
// 获取成品库信息
|
||||
public (List<WmInfo>,int) Getwminfo_product(string shelf , int layer, int pageNum , int pageSize);
|
||||
|
||||
|
||||
|
||||
// 获取库位信息
|
||||
public WmInfo Getlocationinfo(int warehouse_num, string locationcode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<WmInfo>, IWMentryWarehousing_productService
|
||||
{
|
||||
//货物入库
|
||||
public int IntoProductwarehouse(WmgoodsDto wmgoods, string createName)
|
||||
{
|
||||
List<WmGoodsNowProduction> preparegoodsList = new List<WmGoodsNowProduction>();
|
||||
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<WmPackingrecord>()
|
||||
.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<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == workorder_id)
|
||||
.Where(it => it.PackingCode.EndsWith(flow_id))
|
||||
.Where(it => it.BFilled == true).Any();
|
||||
return isExist;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否为成品箱子码
|
||||
/// </summary>
|
||||
/// <param name="production_packcode"></param>
|
||||
/// <returns></returns>
|
||||
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<WmPackingrecord>()
|
||||
.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();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取箱子唯一识别号
|
||||
/// </summary>
|
||||
/// <param name="production_packcode"></param>
|
||||
/// <returns></returns>
|
||||
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<WmPackingrecord>()
|
||||
.Where(it => it.WorkOrderNum == workorder_id)
|
||||
.Where(it => it.PackingCode.EndsWith(flow_id))
|
||||
.First();
|
||||
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return record.ProductCode;
|
||||
}
|
||||
|
||||
//获取库位已经存在的货物
|
||||
public List<WmGoodsNowProduction> Getpackagelist(string location)
|
||||
{
|
||||
return Context.Queryable<WmGoodsNowProduction>().Where(it=>it.LocationCode==location).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,18 @@ namespace ZR.Service.mes.wms
|
||||
[AppService(ServiceType = typeof(IWMlocationInfoService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class WMlocationInfoService : BaseService<WmInfo>, IWMlocationInfoService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询库位信息
|
||||
/// </summary>
|
||||
/// <param name="warehouse_num"></param>
|
||||
/// <param name="locationcode"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public WmInfo Getlocationinfo(int warehouse_num, string locationcode)
|
||||
{
|
||||
return Context.Queryable<WmInfo>().Where(it=>it.WarehouseNum== warehouse_num && it.Location==locationcode).First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取成品库库位信息
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user