人工空托盘入库

This commit is contained in:
2024-07-13 22:52:14 +08:00
parent 2dc8f04e4e
commit 724372b20a
5 changed files with 205 additions and 0 deletions

View File

@@ -121,6 +121,10 @@ public class ModuleConsts
/// </summary>
public const string MODULE_WMSCARRYREPLACE_ID = "26188532491557";//26188532491557
/// <summary>
/// 模块标识-人工空载具入库 todo
/// </summary>
public const string MODULE_WMSEMPTYCARRYINSTOCK_ID = "MODULE_WMSEMPTYCARRYINSTOCK_ID";//
/// <summary>
/// 模块标识-齐套分拣
/// </summary>
public const string MODULE_WMSSETSORTING_ID = "26172520979237";

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tnb.WarehouseMgr.Entities.Consts;
namespace Tnb.WarehouseMgr.Entities.Dto.Inputs
{
public class WmsEmptycarryInstockServiceInstockInput
{
public string carry_code { get; set; }
public string location_code { get; set; }
public string org_id { get; set; } = WmsWareHouseConst.AdministratorOrgId;
public string create_id { get; set; } = WmsWareHouseConst.AdministratorUserId;
}
}

View File

@@ -0,0 +1,52 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.WarehouseMgr.Entities.Entity;
/// <summary>
/// 空托盘入库及记录
/// </summary>
[SugarTable("wms_emptycarry_instock_log")]
public partial class WmsEmptycarryInstockLog : BaseEntity<string>
{
public WmsEmptycarryInstockLog()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 创建用户
/// </summary>
public string? create_id { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 所属组织
/// </summary>
public string? org_id { get; set; }
/// <summary>
/// 入库库位id
/// </summary>
public string? location_id { get; set; }
/// <summary>
/// 入库库位编码
/// </summary>
public string? location_code { get; set; }
/// <summary>
/// 载具id
/// </summary>
public string? carry_id { get; set; }
/// <summary>
/// 载具编码
/// </summary>
public string? carry_code { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
namespace Tnb.WarehouseMgr.Interfaces
{
public interface IWmsEmptycarryInstockLogService
{
Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> Instock(WmsEmptycarryInstockServiceInstockInput input);
}
}

View File

@@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.Common.Utils;
using Tnb.QcMgr.Entities.Enums;
using Tnb.QcMgr.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
using Tnb.WarehouseMgr.Interfaces;
using Tnb.QcMgr.Interfaces;
using Tnb.WarehouseMgr.Entities.Consts;
using JNPF.Common.Enums;
using JNPF.FriendlyException;
using Microsoft.Extensions.Logging;
using Tnb.ProductionMgr.Entities;
using Tnb.WarehouseMgr.Entities.Entity;
using Npgsql;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.ProductionMgr.Entities.Dto;
using JNPF.VisualDev;
using System.Runtime.InteropServices;
using Tnb.BasicData.Entities;
namespace Tnb.WarehouseMgr
{
[OverideVisualDev(ModuleConsts.MODULE_WMSEMPTYCARRYINSTOCK_ID)]
public class WmsEmptycarryInstockLogService : BaseWareHouseService,IWmsEmptycarryInstockLogService
{
private readonly ISqlSugarClient _db;
public WmsEmptycarryInstockLogService(ISqlSugarRepository<WmsEmptycarryInstockLog> repository)
{
_db = repository.AsSugarClient();
}
/// <summary>
/// 人工空托盘入库
/// </summary>
/// <param name="input">
///
/// </param>
/// <returns></returns>
[HttpPost]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> Instock(WmsEmptycarryInstockServiceInstockInput input)
{
try
{
if (string.IsNullOrEmpty(input.location_code))
{
throw new Exception("请扫描入库库位");
}
if (string.IsNullOrEmpty(input.carry_code))
{
throw new Exception("请扫描载具");
}
await _db.Ado.BeginTranAsync();
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).FirstAsync();
BasLocation basLocation = await _db.Queryable<BasLocation>().Where(r => r.location_code == input.location_code).FirstAsync();
if (wmsCarryH.is_lock == 1)
{
throw new Exception($"载具{wmsCarryH.carry_code}已锁定");
}
if (wmsCarryH.carry_status == "1")
{
throw new Exception($"载具{wmsCarryH.carry_code}已占用");
}
if (basLocation.is_lock == 1)
{
throw new Exception($"库位{basLocation.location_code}已锁定");
}
if (basLocation.is_use == "1")
{
throw new Exception($"库位{basLocation.location_code}已占用");
}
wmsCarryH.location_id = basLocation.id;
wmsCarryH.location_code = basLocation.location_code;
basLocation.is_use = "1";
await _db.Updateable(wmsCarryH).UpdateColumns(r => new { r.location_id , r.location_code}).ExecuteCommandAsync();
await _db.Updateable(basLocation).UpdateColumns(r => new { r.is_use }).ExecuteCommandAsync();
WmsEmptycarryInstockLog wmsEmptycarryInstockLog = new WmsEmptycarryInstockLog();
wmsEmptycarryInstockLog.carry_id = wmsCarryH.id;
wmsEmptycarryInstockLog.carry_code = wmsCarryH.carry_code;
wmsEmptycarryInstockLog.location_id = basLocation.id;
wmsEmptycarryInstockLog.location_code = basLocation.location_code;
wmsEmptycarryInstockLog.org_id = input.org_id;
wmsEmptycarryInstockLog.create_id =input.create_id ;
wmsEmptycarryInstockLog.create_time = DateTime.Now;
await _db.Insertable(wmsEmptycarryInstockLog).ExecuteCommandAsync();
await _db.Ado.CommitTranAsync();
return await ToApiResult(HttpStatusCode.OK, "成功");
}
catch (Exception ex)
{
Logger.LogInformation("【WmsEmptycarryInstockService-Instock】" + ex.Message);
Logger.LogInformation("【WmsEmptycarryInstockService-Instock】" + ex.StackTrace);
await _db.Ado.RollbackTranAsync();
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
}
}
}
}