From 113f67b1682e3af2499413314bb9603ea0f21f73 Mon Sep 17 00:00:00 2001
From: hlb <894797954@qq.com>
Date: Fri, 10 Nov 2023 14:53:33 +0800
Subject: [PATCH] =?UTF-8?q?=E7=9B=98=E7=82=B9=E4=BB=BB=E5=8A=A1=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E7=9B=98=E7=82=B9=E7=AD=BE=E6=94=B6=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/WmsCheckSignConfig.cs | 77 +++++++++++++++++++
.../Tnb.WarehouseMgr/WmsCheckTaskService.cs | 36 ++++++++-
2 files changed, 109 insertions(+), 4 deletions(-)
create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckSignConfig.cs
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckSignConfig.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckSignConfig.cs
new file mode 100644
index 00000000..3cd97e5b
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckSignConfig.cs
@@ -0,0 +1,77 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.WarehouseMgr.Entities;
+
+///
+/// 盘点签收配置
+///
+[SugarTable("wms_check_sign_config")]
+public partial class WmsCheckSignConfig : BaseEntity
+{
+ public WmsCheckSignConfig()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 仓库ID
+ ///
+ public string? warehouse_id { get; set; }
+
+ ///
+ /// 盘点库位
+ ///
+ public string? location_id { get; set; }
+
+ ///
+ /// 是否启用
+ ///
+ public int? enabled { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 扩展
+ ///
+ public string? extras { get; set; }
+
+ ///
+ /// 时间戳
+ ///
+ public DateTime? timestamp { get; set; }
+
+ ///
+ /// 流程任务Id
+ ///
+ public string? f_flowtaskid { get; set; }
+
+ ///
+ /// 流程引擎Id
+ ///
+ public string? f_flowid { get; set; }
+
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
index 3b02b958..1a5a4593 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
@@ -1,4 +1,5 @@
-using System.Linq.Expressions;
+using System.Linq;
+using System.Linq.Expressions;
using JNPF.Common.Core.Manager;
using JNPF.Common.Dtos.VisualDev;
using JNPF.Common.Extension;
@@ -10,6 +11,7 @@ using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
+using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
@@ -127,9 +129,35 @@ namespace Tnb.WarehouseMgr
//生成预任务信息
if (details.Count > 0 && carryCodes.Count > 0)
{
- string[] locTypes = new[] { ((int)EnumLocationType.出库库位).ToString(), ((int)EnumLocationType.出入库位).ToString() };
- BasLocation[] endLocs = await _db.Queryable().Where(it => it.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && locTypes.Contains(it.is_type)).ToArrayAsync();
- int randomIndex = new Random().Next(0, endLocs.GetUpperBound(0));
+ // 判断当前仓库是否有盘点签收配置
+ var wcsConf = await _db.Queryable().Where(it => it.warehouse_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && it.enabled == 1)
+ .FirstAsync();
+ BasLocation[] endLocs = Array.Empty();
+ int randomIndex = 0;
+ if (wcsConf != null)
+ {
+ if (wcsConf.location_id == null) {
+ throw new AppFriendlyException("盘点签收配置库位为空,请查看配置!", 500);
+ }
+ JArray? jsonArr = null;
+ jsonArr = JArray.Parse(wcsConf.location_id);
+ string?[] locArr = jsonArr.Select(x => x.ToObject()).ToArray();
+ if (locArr != null)
+ {
+ endLocs = await _db.Queryable().Where(it => it.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && locArr.Contains(it.id)).ToArrayAsync();
+ randomIndex = new Random().Next(0, endLocs.GetUpperBound(0));
+ }
+ else {
+ throw new AppFriendlyException("盘点签收配置有误,请查看配置!", 500);
+ }
+
+ }
+ else {
+ string[] locTypes = new[] { ((int)EnumLocationType.出库库位).ToString(), ((int)EnumLocationType.出入库位).ToString() };
+ endLocs = await _db.Queryable().Where(it => it.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && locTypes.Contains(it.is_type)).ToArrayAsync();
+ randomIndex = new Random().Next(0, endLocs.GetUpperBound(0));
+ }
+
List carrys = await _db.Queryable().Where(it => carryCodes.Select(x => x.carry_id).Distinct().Contains(it.id)).ToListAsync();
List curDetails = details.DistinctBy(x => x.carry_id).ToList();
List curCarryCodes = carryCodes.FindAll(x => curDetails.Select(d => d.carry_id).Contains(x.carry_id));