diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
index 0dc16b62..bec5a1b3 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs
@@ -261,5 +261,9 @@
/// 组织Id(天益4厂)
///
public const string AdministratorOrgId = "25193668006933";
+ ///
+ /// 盘点任务计算状态-未结算
+ ///
+ public const string CLOSINGSTATUS_WJS_ID = "27674058079509";
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs
new file mode 100644
index 00000000..bc7f2dd2
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Entities.Dto.Outputs
+{
+ ///
+ /// 盘点任务明细输出类
+ ///
+ public class CheckTaskDetailOutput
+ {
+ ///
+ /// 物料编号
+ ///
+ public string material_code { get; set; }
+ ///
+ /// 批次
+ ///
+ public string code_batch { get; set; }
+ ///
+ /// 库位编号
+ ///
+ public string location_code { get; set; }
+ ///
+ ///载具编号
+ ///
+ public string carry_code { get; set; }
+ ///
+ /// 理论库存数量
+ ///
+ public decimal? pr_qty { get; set; }
+ ///
+ /// 结算状态
+ ///
+ public string closing_status { get; set; }
+ ///
+ /// 已盘点数量
+ ///
+ public decimal? qty { get; set; }
+
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs
new file mode 100644
index 00000000..62cb8db6
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.DirectoryServices.Protocols;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tnb.WarehouseMgr.Entities.Enums;
+
+namespace Tnb.WarehouseMgr.Entities.Dto.Queries
+{
+ ///
+ /// 根据盘点类型获取任务明细查询参数
+ ///
+ public class CheckDetailQuery
+ {
+ ///
+ /// 仓库Id
+ ///
+ public string warehouse_id { get; set; }
+ ///
+ /// 盘点类型
+ ///
+ public EnumCheckType CheckType { get; set; }
+ ///
+ /// 物料Id
+ ///
+ public string material_id { get; set; }
+ ///
+ /// 区域ID列表
+ ///
+ public List regionIds { get; set; }
+ }
+}
+
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs
index ba095aa0..4d93f685 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs
@@ -103,5 +103,12 @@ public partial class WmsCheckstockH : BaseEntity
/// 流程引擎Id
///
public string? f_flowid { get; set; }
-
+ ///
+ /// 物料ID
+ ///
+ public string? material_id { get; set; }
+ ///
+ /// 区域ID
+ ///
+ public string area_id { get; set; }
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index b31742e3..bfc3d27c 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -252,7 +252,7 @@ namespace Tnb.WarehouseMgr
//获取所有未下发的预任务申请
List preTasks = await db.Queryable().InnerJoin((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id)
.InnerJoin((a, b, c) => a.area_id == c.id)
- .InnerJoin((a, b, c, d) => a.endlocation_id == d.id && d.is_use == "0" && d.is_lock == 0)
+ .InnerJoin((a, b, c, d) => a.endlocation_id == d.id && d.is_use == "0" )
.Where(a => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID && !string.IsNullOrWhiteSpace(a.startlocation_id))
.OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code })
.Select((a, b, c, d) => new WmsPretaskH
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
index 1a5a4593..59ba69b9 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
@@ -11,12 +11,15 @@ using JNPF.VisualDev;
using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces;
using Mapster;
+using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Outputs;
+using Tnb.WarehouseMgr.Entities.Dto.Queries;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
@@ -34,6 +37,8 @@ namespace Tnb.WarehouseMgr
private readonly IVisualDevService _visualDevService;
private readonly IRunService _runService;
private readonly IBillRullService _billRullService;
+ private static Dictionary _carryMap = new();
+
public WmsCheckTaskService(
ISqlSugarRepository repository,
IWareHouseService wareHouseService,
@@ -122,6 +127,7 @@ namespace Tnb.WarehouseMgr
_ = await _db.Insertable(details).ExecuteCommandAsync();
break;
case EnumCheckType.物料盘点:
+
break;
case EnumCheckType.批次盘点:
break;
@@ -129,14 +135,15 @@ namespace Tnb.WarehouseMgr
//生成预任务信息
if (details.Count > 0 && carryCodes.Count > 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) {
+ if (wcsConf.location_id == null)
+ {
throw new AppFriendlyException("盘点签收配置库位为空,请查看配置!", 500);
}
JArray? jsonArr = null;
@@ -147,17 +154,19 @@ namespace Tnb.WarehouseMgr
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 {
+ else
+ {
throw new AppFriendlyException("盘点签收配置有误,请查看配置!", 500);
}
-
+
}
- else {
+ 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();
+ 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));
@@ -266,5 +275,60 @@ namespace Tnb.WarehouseMgr
{
return _db.Queryable().InnerJoin(joinExp).Where(whereExp).Select().ToListAsync();
}
+ ///
+ /// 根据盘点类型获取任务明细
+ ///
+ ///
+ ///
{
+ ///
warehouse_id:仓库ID
+ ///
CheckType:盘点类型 0 全库盘点、1 物料盘点 2 区域盘点
+ ///
material_id:物料ID
+ ///
regionIds: 区域ID列表
+ ///
}
+ ///
+ ///
+ [HttpGet]
+ public async Task GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input)
+ {
+ if(_carryMap.Count == 0)
+ {
+ _carryMap = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.carry_code);
+ }
+
+ var filterExpable = Expressionable.Create()
+ .And((a, b, c) => a.wh_id == input.warehouse_id)
+ .And((a, b, c) => a.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And((a, b, c) => c.is_lock == 0);
+
+ switch (input.CheckType)
+ {
+ case EnumCheckType.物料盘点:
+ filterExpable.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id);
+ break;
+ case EnumCheckType.批次盘点:
+ filterExpable.AndIF(input.regionIds?.Count> 0, (a, b, c) => input.regionIds.Contains(a.region_id));
+ break;
+ }
+ var carryCodes = await _db.Queryable().InnerJoin((a, b) => a.id == b.location_id)
+ .InnerJoin((a, b, c) => b.carry_id == c.id)
+ .Where(filterExpable.ToExpression())
+ .Select()
+ .ToListAsync();
+ //var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty();
+ //var checkStockDs = await _db.Queryable().Where(it => carryIds.Contains(it.carry_id)).ToListAsync();
+
+ List outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new CheckTaskDetailOutput
+ {
+ material_code = x.Key.material_code,
+ code_batch = x.Key.code_batch,
+ location_code = x.Key.location_code,
+ carry_code = _carryMap[x.Key.carry_id]?.ToString() ?? string.Empty,
+ pr_qty = x.Sum(d => d.codeqty),
+ closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID,
+ qty = 0,
+ })
+ .ToList();
+ return outputs;
+ }
}
}
diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs
index 3dbfefd2..1efe0fb4 100644
--- a/apihost/Tnb.API.Entry/Startup.cs
+++ b/apihost/Tnb.API.Entry/Startup.cs
@@ -57,7 +57,7 @@ public class Startup : AppStartup
//定时任务
services.AddHostedService();
- services.AddHostedService();
+ //services.AddHostedService();
}