From e9784e50145a63cdab11e7863b1f7dee637133c9 Mon Sep 17 00:00:00 2001
From: majian <780924089@qq.com>
Date: Thu, 15 Aug 2024 17:17:08 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8E=9F=E6=9D=90=E6=96=99=E4=BB=93=E4=BA=BA?=
=?UTF-8?q?=E5=B7=A5=E6=89=AB=E7=A0=81=E5=85=A5=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Consts/ModuleConsts.cs | 4 +
.../Dto/Inputs/ArtificialInstock.cs | 17 ++
.../Entity/WmsArtificialInstock.cs | 67 ++++++++
.../IWmsPDAScanInStockService.cs | 3 +-
.../WmsArtificialInstockService.cs | 159 ++++++++++++++++++
.../WmsPDAScanInStockService.cs | 5 +-
.../Configurations/AgvRequestCfgUrl.json | 2 +-
7 files changed, 254 insertions(+), 3 deletions(-)
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ArtificialInstock.cs
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsArtificialInstock.cs
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsArtificialInstockService.cs
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs
index a9576987..fd4383b9 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/ModuleConsts.cs
@@ -121,6 +121,10 @@ public class ModuleConsts
///
public const string MODULE_WMSCARRYREPLACE_ID = "26188532491557";//26188532491557
///
+ /// 模块标识-人工扫码入库记录 todo
+ ///
+ public const string MODULE_WmsArtificialInstock_ID = "MODULE_WmsArtificialInstock_ID";
+ ///
/// 模块标识-出入库流水记录 todo
///
public const string MODULE_WMSOUTINSTOCKDETAIL_ID = "MODULE_WMSOUTINSTOCKDETAIL_ID";
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ArtificialInstock.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ArtificialInstock.cs
new file mode 100644
index 00000000..481fbf1d
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/ArtificialInstock.cs
@@ -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; }
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsArtificialInstock.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsArtificialInstock.cs
new file mode 100644
index 00000000..6a5f8af4
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsArtificialInstock.cs
@@ -0,0 +1,67 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.WarehouseMgr.Entities.Entity;
+
+///
+/// 人工扫码入库记录
+///
+[SugarTable("wms_artificial_instock")]
+public partial class WmsArtificialInstock : BaseEntity
+{
+ public WmsArtificialInstock()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 入库仓库id
+ ///
+ public string? warehouse_id { get; set; }
+
+ ///
+ /// 起点库位id
+ ///
+ public string? location_id { get; set; }
+
+ ///
+ /// 起点库位编码
+ ///
+ public string? location_code { get; set; }
+
+ ///
+ /// 载具id
+ ///
+ public string? carry_id { get; set; }
+
+ ///
+ /// 载具编码
+ ///
+ public string? carry_code { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDAScanInStockService.cs
index 9b5fb88d..fb37d78b 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDAScanInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDAScanInStockService.cs
@@ -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 ScanInStock(VisualDevModelDataCrInput input);
- Task ScanInStockByRedis(VisualDevModelDataCrInput input);
+ Task ScanInStockByRedis(VisualDevModelDataCrInput input, ISqlSugarClient dbConn = null);
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsArtificialInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsArtificialInstockService.cs
new file mode 100644
index 00000000..2159b2fd
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsArtificialInstockService.cs
@@ -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
+{
+ ///
+ /// 人工扫码入库记录
+ ///
+ [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 repository,
+ IUserManager userManager,
+ IBillRullService billRullService,
+ IRunService runService,
+ IVisualDevService visualDevService,
+ IWmsPDAScanInStockService wmsPDAScanInStock)
+ {
+ _db = repository.AsSugarClient();
+ _userManager = userManager;
+ _billRullService = billRullService;
+ _runService = runService;
+ _visualDevService = visualDevService;
+ _wmsPDAScanInStock = wmsPDAScanInStock;
+ }
+
+
+ ///
+ /// 人工扫码入库
+ ///
+ ///
+ ///
+ ///
+ ///
+ [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().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().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().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().Where(it => it.carry_id == wmsCarryH.id).OrderByDescending(it => it.id).First();
+
+ if (WmsCarryCode != null)
+ {
+ VisualDevModelDataCrInput input2 = new VisualDevModelDataCrInput();
+ input2.data = new Dictionary();
+ 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);
+ }
+ }
+
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs
index a9d141d3..4b9d9d6e 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs
@@ -350,8 +350,11 @@ namespace Tnb.WarehouseMgr
return Task.FromResult(true);
}
- public async Task ScanInStockByRedis(VisualDevModelDataCrInput input)
+ public async Task ScanInStockByRedis(VisualDevModelDataCrInput input, ISqlSugarClient dbConn = null)
{
+ var db = _dbScanInStockByRedis;
+ if (dbConn != null)
+ db = dbConn;
Logger.LogInformation($"【ScanInStockByRedis】执行入库 {JsonConvert.SerializeObject(input)}");
try
{
diff --git a/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json b/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json
index a15fe34b..697ba175 100644
--- a/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json
+++ b/apihost/Tnb.API.Entry/Configurations/AgvRequestCfgUrl.json
@@ -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"
}
}
\ No newline at end of file