原材料仓人工扫码入库
This commit is contained in:
@@ -121,6 +121,10 @@ public class ModuleConsts
|
||||
/// </summary>
|
||||
public const string MODULE_WMSCARRYREPLACE_ID = "26188532491557";//26188532491557
|
||||
/// <summary>
|
||||
/// 模块标识-人工扫码入库记录 todo
|
||||
/// </summary>
|
||||
public const string MODULE_WmsArtificialInstock_ID = "MODULE_WmsArtificialInstock_ID";
|
||||
/// <summary>
|
||||
/// 模块标识-出入库流水记录 todo
|
||||
/// </summary>
|
||||
public const string MODULE_WMSOUTINSTOCKDETAIL_ID = "MODULE_WMSOUTINSTOCKDETAIL_ID";
|
||||
|
||||
@@ -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 ArtificialInstockInput
|
||||
{
|
||||
public string? org { get; set; } = WmsWareHouseConst.AdministratorOrgId;
|
||||
public string? create_id { get; set; }
|
||||
public string? carry_code { get; set; }
|
||||
public string? startlocation_code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities.Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 人工扫码入库记录
|
||||
/// </summary>
|
||||
[SugarTable("wms_artificial_instock")]
|
||||
public partial class WmsArtificialInstock : BaseEntity<string>
|
||||
{
|
||||
public WmsArtificialInstock()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 入库仓库id
|
||||
/// </summary>
|
||||
public string? warehouse_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; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -4,12 +4,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Interfaces
|
||||
{
|
||||
public interface IWmsPDAScanInStockService
|
||||
{
|
||||
Task<dynamic> ScanInStock(VisualDevModelDataCrInput input);
|
||||
Task<dynamic> ScanInStockByRedis(VisualDevModelDataCrInput input);
|
||||
Task<dynamic> ScanInStockByRedis(VisualDevModelDataCrInput input, ISqlSugarClient dbConn = null);
|
||||
}
|
||||
}
|
||||
|
||||
159
WarehouseMgr/Tnb.WarehouseMgr/WmsArtificialInstockService.cs
Normal file
159
WarehouseMgr/Tnb.WarehouseMgr/WmsArtificialInstockService.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||
using Tnb.WarehouseMgr.Entities.Entity;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 人工扫码入库记录
|
||||
/// </summary>
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WmsArtificialInstock_ID)]
|
||||
public class WmsArtificialInstockService : BaseWareHouseService
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IBillRullService _billRullService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
|
||||
public WmsArtificialInstockService(
|
||||
ISqlSugarRepository<WmsCarryH> repository,
|
||||
IUserManager userManager,
|
||||
IBillRullService billRullService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IWmsPDAScanInStockService wmsPDAScanInStock)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
_billRullService = billRullService;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_wmsPDAScanInStock = wmsPDAScanInStock;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 人工扫码入库
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost]
|
||||
public async Task ArtificialInstock(ArtificialInstockInput input)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
BasLocation startlocationn = await _db.Queryable<BasLocation>().Where(r => r.location_code == input.startlocation_code).FirstAsync();
|
||||
if (startlocationn == null)
|
||||
{
|
||||
throw new AppFriendlyException($"【ArtificialInstock】库位{input.startlocation_code}不存在", 500);
|
||||
}
|
||||
if (startlocationn.is_lock == 1)
|
||||
{
|
||||
throw new AppFriendlyException($"【ArtificialInstock】库位{input.startlocation_code}已锁定", 500);
|
||||
}
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).FirstAsync();
|
||||
if (wmsCarryH == null)
|
||||
{
|
||||
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}不存在", 500);
|
||||
}
|
||||
if (wmsCarryH.is_lock == 1)
|
||||
{
|
||||
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}已锁定", 500);
|
||||
}
|
||||
if (wmsCarryH.carry_status != "1")
|
||||
{
|
||||
throw new AppFriendlyException($"【ArtificialInstock】载具{input.carry_code}未绑定物料", 500);
|
||||
}
|
||||
|
||||
BasLocation carrryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == wmsCarryH.location_id).FirstAsync();
|
||||
if (carrryLoc != null && carrryLoc.is_type == "0")
|
||||
{
|
||||
throw new Exception($"托盘{wmsCarryH.carry_code}在存储库位中,不能绑定!");
|
||||
}
|
||||
|
||||
switch (startlocationn.wh_id)
|
||||
{
|
||||
case WmsWareHouseConst.WAREHOUSE_YCL_ID:
|
||||
{
|
||||
var WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == wmsCarryH.id).OrderByDescending(it => it.id).First();
|
||||
|
||||
if (WmsCarryCode != null)
|
||||
{
|
||||
VisualDevModelDataCrInput input2 = new VisualDevModelDataCrInput();
|
||||
input2.data = new Dictionary<string, object>();
|
||||
input2.data.Add("barcode", input.carry_code);
|
||||
input2.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
|
||||
input2.data.Add("material_code", WmsCarryCode.material_code);
|
||||
input2.data.Add("extras", input.startlocation_code);//location_code
|
||||
input2.data.Add("warehouse_id", "1");//TEST
|
||||
input2.data.Add("bill_code", "");//采购收货单号
|
||||
input2.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
|
||||
input2.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
|
||||
input2.data.Add("container_no", WmsCarryCode.container_no!);//箱号
|
||||
input2.data.Add("material_id", WmsCarryCode.material_id);
|
||||
input2.data.Add("物料条码", WmsCarryCode.barcode);
|
||||
input2.data.Add("id", null);
|
||||
_wmsPDAScanInStock.ScanInStockByRedis(input2, _db).Wait();
|
||||
|
||||
WmsArtificialInstock wmsArtificialInstock = new WmsArtificialInstock();
|
||||
wmsArtificialInstock.carry_id = wmsCarryH.id;
|
||||
wmsArtificialInstock.carry_code = wmsCarryH.carry_code;
|
||||
wmsArtificialInstock.org_id = input.org;
|
||||
wmsArtificialInstock.create_id = input.create_id;
|
||||
wmsArtificialInstock.create_time = DateTime.Now;
|
||||
wmsArtificialInstock.location_id = startlocationn.id;
|
||||
wmsArtificialInstock.location_code = startlocationn.location_code;
|
||||
wmsArtificialInstock.warehouse_id = startlocationn.wh_id;
|
||||
await _db.Insertable(wmsArtificialInstock).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AppFriendlyException($"【ArtificialInstock】载具 {input.carry_code} 未绑定物料条码!", 500);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError($"【ArtificialInstock】 {ex.Message}");
|
||||
Logger.LogError($"【ArtificialInstock】 {ex.StackTrace}");
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw new AppFriendlyException($"【ArtificialInstock】人工扫码入库失败 {ex.Message}", 500);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -350,8 +350,11 @@ namespace Tnb.WarehouseMgr
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
public async Task<dynamic> ScanInStockByRedis(VisualDevModelDataCrInput input)
|
||||
public async Task<dynamic> ScanInStockByRedis(VisualDevModelDataCrInput input, ISqlSugarClient dbConn = null)
|
||||
{
|
||||
var db = _dbScanInStockByRedis;
|
||||
if (dbConn != null)
|
||||
db = dbConn;
|
||||
Logger.LogInformation($"【ScanInStockByRedis】执行入库 {JsonConvert.SerializeObject(input)}");
|
||||
try
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"AgvRequestUrls": {
|
||||
"CreateTaskChainUrl": "http://192.168.11.104:1880/api/task-chain/create",
|
||||
"CreateTaskChainUrl": "http://10.147.19.104:5013/api/task-chain/create",
|
||||
"CancelTaskChainUrl": "http://192.168.11.104:1880/api/task-chain/cancel"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user