From 5666f0262e1b6254fb667595fd0affc8039593c9 Mon Sep 17 00:00:00 2001
From: majian <780924089@qq.com>
Date: Thu, 18 Jul 2024 12:31:05 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E8=BD=AC=E5=BA=93=E5=8D=95=E5=90=8C?=
=?UTF-8?q?=E6=AD=A5=E8=B0=83=E6=95=B4=20=E5=BA=93=E5=AD=98=E6=8A=A5?=
=?UTF-8?q?=E8=A1=A8=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/WmsCarryStockReportH.cs | 80 +++++++-------
.../Tnb.WarehouseMgr/ErpToWmsService.cs | 17 ++-
.../Tnb.WarehouseMgr/WareHouseService.cs | 4 +-
.../WmsCarryStockReportService.cs | 101 +++++++++---------
.../Configurations/ConnectionStrings.json | 9 +-
5 files changed, 114 insertions(+), 97 deletions(-)
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryStockReportH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryStockReportH.cs
index d3a98f88..62690e32 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryStockReportH.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCarryStockReportH.cs
@@ -9,7 +9,7 @@ namespace Tnb.WarehouseMgr.Entities;
///
public partial class WmsCarryStockReport
{
- public int 序号 { get; set; }
+ public int index { get; set; }
/////
///// 所属组织
/////
@@ -23,22 +23,22 @@ public partial class WmsCarryStockReport
///
/// 载具编码
///
- public string? 载具编码 { get; set; }
+ public string? carry_code { get; set; }
///
/// 载具名称
///
- public string? 载具名称 { get; set; }
+ public string? carry_name { get; set; }
///
/// 子载具编码
///
- public string? 子载具编码 { get; set; }
+ public string? membercarry_code { get; set; }
///
/// 子载具名称
///
- public string? 子载具名称 { get; set; }
+ public string? membercarry_name { get; set; }
///
/// 物料ID
@@ -48,77 +48,77 @@ public partial class WmsCarryStockReport
///
/// 物料编码
///
- public string? 物料编码 { get; set; }
+ public string? material_code { get; set; }
///
/// 物料名称
///
- public string? 物料名称 { get; set; }
+ public string? material_name { get; set; }
///
/// 仓库名称
///
- public string? 仓库名称 { get; set; }
+ public string? warehouse_name { get; set; }
///
/// 库位编码
///
- public string? 库位编码 { get; set; }
+ public string? location_code { get; set; }
///
/// 库位名称
///
- public string? 库位名称 { get; set; }
+ public string? location_name { get; set; }
///
/// 载具状态
///
- public string? 载具状态 { get; set; }
+ public string? carry_status { get; set; }
///
/// 库位状态
///
- public string? 库位状态 { get; set; }
+ public string? location_status { get; set; }
///
/// 载具类型
///
- public string? 载具类型 { get; set; }
+ public string? carry_type { get; set; }
///
/// 入库时间
///
- public string? 入库时间 { get; set; }
+ public string? instock_time { get; set; }
///
/// 条码
///
- public string? 条码 { get; set; }
+ public string? barcode { get; set; }
///
/// 批次
///
- public string? 批次 { get; set; }
+ public string? code_batch { get; set; }
///
/// 数量
///
- public decimal? 数量 { get; set; }
+ public decimal? qty { get; set; }
///
/// 单位
///
- public string? 单位 { get; set; }
+ public string? unit { get; set; }
///
/// 操作用户
///
- public string? 操作用户 { get; set; }
+ public string? creator { get; set; }
///
/// 绑定时间
///
- public string? 绑定时间 { get; set; }
+ public string? bind_time { get; set; }
}
@@ -127,7 +127,7 @@ public partial class WmsCarryStockReport
///
public partial class WmsCarryStockReportH
{
- public int 序号 { get; set; }
+ public int index { get; set; }
/////
///// 所属组织
/////
@@ -141,47 +141,47 @@ public partial class WmsCarryStockReportH
///
/// 载具编码
///
- public string? 载具编码 { get; set; }
+ public string? carry_code { get; set; }
///
/// 载具名称
///
- public string? 载具名称 { get; set; }
+ public string? carry_name { get; set; }
///
/// 仓库名称
///
- public string? 仓库名称 { get; set; }
+ public string? warehouse_name { get; set; }
///
/// 库位编码
///
- public string? 库位编码 { get; set; }
+ public string? location_code { get; set; }
///
/// 库位名称
///
- public string? 库位名称 { get; set; }
+ public string? location_name { get; set; }
///
/// 载具状态
///
- public string? 载具状态 { get; set; }
+ public string? carry_status { get; set; }
///
/// 库位状态
///
- public string? 库位状态 { get; set; }
+ public string? location_status { get; set; }
///
/// 载具类型
///
- public string? 载具类型 { get; set; }
+ public string? carry_type { get; set; }
///
/// 入库时间
///
- public string? 入库时间 { get; set; }
+ public string? instock_time { get; set; }
public List Details { get; set; }
}
@@ -192,7 +192,7 @@ public partial class WmsCarryStockReportH
///
public partial class WmsCarryStockReportCode
{
- public int 序号 { get; set; }
+ public int index { get; set; }
/////
///// 载具ID
/////
@@ -201,12 +201,12 @@ public partial class WmsCarryStockReportCode
///
/// 载具编码
///
- public string? 载具编码 { get; set; }
+ public string? carry_code { get; set; }
///
/// 载具名称
///
- public string? 载具名称 { get; set; }
+ public string? carry_name { get; set; }
/////
///// 物料ID
@@ -216,32 +216,32 @@ public partial class WmsCarryStockReportCode
///
/// 物料编号
///
- public string? 物料编号 { get; set; }
+ public string? material_code { get; set; }
///
/// 物料名称
///
- public string? 物料名称 { get; set; }
+ public string? material_name { get; set; }
///
/// 条码编号
///
- public string? 条码 { get; set; }
+ public string? barcode { get; set; }
///
/// 批次
///
- public string? 批次 { get; set; }
+ public string? code_batch { get; set; }
///
/// 条码数量
///
- public decimal? 数量 { get; set; }
+ public decimal? qty { get; set; }
///
/// 单位
///
- public string? 单位 { get; set; }
+ public string? unit { get; set; }
/////
///// 操作用户
@@ -251,7 +251,7 @@ public partial class WmsCarryStockReportCode
///
/// 绑定时间
///
- public string? 绑定时间 { get; set; }
+ public string? bind_time { get; set; }
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
index 4bd3e117..8cce4593 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs
@@ -4,6 +4,7 @@ using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
+using JNPF.Systems.Entitys.System;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components.Forms;
@@ -13,6 +14,7 @@ using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using Tnb.BasicData.Entities;
+using Tnb.ProductionMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto.ErpInputs;
@@ -511,7 +513,6 @@ namespace Tnb.WarehouseMgr
WmsMaterialTransferD wmsMaterialTransferD = new WmsMaterialTransferD();
wmsMaterialTransferD.lineno = detail.lineno;
wmsMaterialTransferD.material_code = detail.material_code;
- wmsMaterialTransferD.unit_code = detail.unit_code;
wmsMaterialTransferD.code_batch = detail.code_batch;
wmsMaterialTransferD.station_code = detail.station_code;
wmsMaterialTransferD.qty = detail.qty;
@@ -526,8 +527,20 @@ namespace Tnb.WarehouseMgr
{
wmsMaterialTransferD.material_id = material.id;
wmsMaterialTransferD.material_specification = material.material_specification;
- wmsMaterialTransferD.unit_id = detail.unit_code;
}
+
+ var erpExtendField = await db.Queryable().InnerJoin((a, b) => a.table_id == b.Id).Where((a, b) => a.cunitid == detail.unit_code).Select((a, b) => b).FirstAsync();
+ if (erpExtendField != null)
+ {
+ wmsMaterialTransferD.unit_id = erpExtendField.Id;
+ wmsMaterialTransferD.unit_code = erpExtendField.EnCode;
+ }
+ else
+ {
+ _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体明细中单位{detail.unit_code}在wms系统中未找到!");
+ throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500);
+ }
+
wmsMaterialTransferDs.Add(wmsMaterialTransferD);
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index bc958835..18d1fe56 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -669,12 +669,12 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("点位" + input.targetName + "不存在", 500);
}
string data = await _redisData.GetHash(strs[0], strs[1]);
- Logger.Information("联核请求CheckPut接口查询X2Server数据:" + data);
+ Logger.Information("wcs请求CheckPut接口查询X2Server数据:" + data);
JObject? res = JsonConvert.DeserializeObject(data);
bool result = res != null && res["Value"] != null ? res.Value("Value") : false;
if (!result)
throw new AppFriendlyException("点位" + input.targetName + "不可放", 500);
- Logger.Information("联核请求CheckPut接口结果:CTU可放货" + data);
+ Logger.Information("wcs请求CheckPut接口结果:CTU可放货" + data);
}
///
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs
index 25b04da4..ff4e2079 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryStockReportService.cs
@@ -34,10 +34,7 @@ namespace Tnb.WarehouseMgr
_userManager = userManager;
}
- ///
- /// 转库单
- ///
- [HttpPost, NonUnify, AllowAnonymous]
+ [HttpPost]
public async Task CarryStock(CarryStockInput input)
{
var warehouse_id = "";
@@ -66,25 +63,25 @@ namespace Tnb.WarehouseMgr
.OrderByDescending((a, b, c, d, e, f) => b.carry_code)
.Select((a, b, c, d, e, f) => new WmsCarryStockReport
{
- 仓库名称 = c.whname,
+ warehouse_name = c.whname,
carry_id = b.id,
- 载具编码 = string.IsNullOrEmpty(b.carry_code) ? "空托盘堆垛" : b.carry_code,
- 载具名称 = string.IsNullOrEmpty(b.carry_code) ? "空托盘堆垛" : b.carry_name,
- 载具状态 = b.is_lock == 1 ? "锁定" : "未锁定",
- 载具类型 = d.carrystd_name,
- 库位编码 = a.location_code,
- 库位名称 = a.location_name,
- 库位状态 = b.is_lock == 1 ? "锁定" : "未锁定",
- 入库时间 = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
- 条码 = e.barcode,
- 批次 = e.code_batch,
- 数量 = e.codeqty,
+ carry_code = string.IsNullOrEmpty(b.carry_code) ? "空托盘堆垛" : b.carry_code,
+ carry_name = string.IsNullOrEmpty(b.carry_code) ? "空托盘堆垛" : b.carry_name,
+ carry_status = b.is_lock == 1 ? "锁定" : "未锁定",
+ carry_type = d.carrystd_name,
+ location_code = a.location_code,
+ location_name = a.location_name,
+ location_status = b.is_lock == 1 ? "锁定" : "未锁定",
+ instock_time = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
+ barcode = e.barcode,
+ code_batch = e.code_batch,
+ qty = e.codeqty,
material_id = e.material_id,
- 物料编码 = e.material_code,
- 物料名称 = f.name,
- 单位 = e.unit_id,
- 操作用户 = e.create_id,
- 绑定时间 = e.create_time != null ? e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
+ material_code = e.material_code,
+ material_name = f.name,
+ unit = e.unit_id,
+ creator = e.create_id,
+ bind_time = e.create_time != null ? e.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
})
.ToListAsync();
@@ -104,27 +101,27 @@ namespace Tnb.WarehouseMgr
.WhereIF(!string.IsNullOrEmpty(material_id), (a, b, c, d, e, f, g) => g.id == material_id)
.Select((a, b, c, d, e, f, g, h) => new WmsCarryStockReport
{
- 仓库名称 = c.whname,
+ warehouse_name = c.whname,
carry_id = b.id,
- 载具编码 = b.carry_code,
- 载具名称 = b.carry_name,
- 子载具编码 = h.carry_code,
- 子载具名称 = h.carry_name,
- 载具状态 = b.is_lock == 1 ? "锁定" : "未锁定",
- 载具类型 = d.carrystd_name,
- 库位编码 = a.location_code,
- 库位名称 = a.location_name,
- 库位状态 = b.is_lock == 1 ? "锁定" : "未锁定",
- 入库时间 = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
- 条码 = f.barcode,
- 批次 = f.code_batch,
- 数量 = f.codeqty,
+ carry_code = b.carry_code,
+ carry_name = b.carry_name,
+ membercarry_code = h.carry_code,
+ membercarry_name = h.carry_name,
+ carry_status = b.is_lock == 1 ? "锁定" : "未锁定",
+ carry_type = d.carrystd_name,
+ location_code = a.location_code,
+ location_name = a.location_name,
+ location_status = b.is_lock == 1 ? "锁定" : "未锁定",
+ instock_time = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
+ barcode = f.barcode,
+ code_batch = f.code_batch,
+ qty = f.codeqty,
material_id = f.material_id,
- 物料编码 = f.material_code,
- 物料名称 = g.name,
- 单位 = f.unit_id,
- 操作用户 = f.create_id,
- 绑定时间 = f.create_time != null ? f.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
+ material_code = f.material_code,
+ material_name = g.name,
+ unit = f.unit_id,
+ creator = f.create_id,
+ bind_time = f.create_time != null ? f.create_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
})
.ToListAsync();
@@ -138,7 +135,7 @@ namespace Tnb.WarehouseMgr
_ = storeMap.TryGetValue(itGroup.Key, out WmsCarryStockReport? report);
WmsCarryStockReportH stockReport = report.Adapt();
- if (report.载具编码 != "空托盘堆垛")
+ if (report.carry_code != "空托盘堆垛")
{
List curCarryCodes = items.FindAll(x => x.carry_id == itGroup.Key.carry_id);
@@ -148,19 +145,19 @@ namespace Tnb.WarehouseMgr
{
index++;
WmsCarryStockReportCode wmsCarryStockReportCode = new();
- wmsCarryStockReportCode.序号 = index;
+ wmsCarryStockReportCode.index = index;
//wmsCarryStockReportCode.carry_id = x.carry_id;
- wmsCarryStockReportCode.载具编码 = !string.IsNullOrEmpty(x.子载具编码) ? x.子载具编码 : x.载具编码;
- wmsCarryStockReportCode.载具名称 = !string.IsNullOrEmpty(x.子载具名称) ? x.子载具名称 : x.载具名称;
+ wmsCarryStockReportCode.carry_code = !string.IsNullOrEmpty(x.membercarry_code) ? x.membercarry_code : x.carry_code;
+ wmsCarryStockReportCode.carry_name = !string.IsNullOrEmpty(x.membercarry_name) ? x.membercarry_name : x.carry_name;
//wmsCarryStockReportCode.material_id = x.material_id;
- wmsCarryStockReportCode.物料编号 = x.物料编码;
- wmsCarryStockReportCode.物料名称 = x.物料编码;
- wmsCarryStockReportCode.条码 = x.条码;
- wmsCarryStockReportCode.批次 = x.批次;
- wmsCarryStockReportCode.数量 = x.数量;
- wmsCarryStockReportCode.单位 = x.单位;
+ wmsCarryStockReportCode.material_code = x.material_code;
+ wmsCarryStockReportCode.material_name = x.material_name;
+ wmsCarryStockReportCode.barcode = x.barcode;
+ wmsCarryStockReportCode.code_batch = x.code_batch;
+ wmsCarryStockReportCode.qty = x.qty;
+ wmsCarryStockReportCode.unit = x.unit;
//wmsCarryStockReportCode.创建用户 = x.操作用户;
- wmsCarryStockReportCode.绑定时间 = x.绑定时间;
+ wmsCarryStockReportCode.bind_time = x.bind_time;
wmsCarryStockReportCodes.Add(wmsCarryStockReportCode);
});
@@ -176,7 +173,7 @@ namespace Tnb.WarehouseMgr
int rowIndex = 0;
List pages = result.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
- pages.ForEach(page => { rowIndex++; page.序号 = rowIndex; });
+ pages.ForEach(page => { rowIndex++; page.index = rowIndex; });
SqlSugarPagedList pagedList = new()
{
diff --git a/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json b/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json
index 5314dd45..30252d9a 100644
--- a/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json
+++ b/apihost/Tnb.API.Entry/Configurations/ConnectionStrings.json
@@ -20,8 +20,15 @@
//Oracle
//"DefaultConnection": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST={0})(PORT={1}))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME={2})));User Id={3};Password={4}"
//PostgreSQL
- "DefaultConnection": "server={0};port={1};database={2};uid={3};pwd={4};pooling=true;KeepAlive=60;ConnectionLifetime=300;MaxPoolSize=320;"
+ "DefaultConnection": "server={0};port={1};database={2};uid={3};pwd={4};pooling=true;KeepAlive=60;ConnectionLifetime=300;MaxPoolSize=320;",
//MySql
//"DefaultConnection": "server={0};port={1};database={2};uid={3};pwd={4};sslmode=none;pooling=true;charset=utf8mb4;allowLoadLocalInfile=true;allowPublicKeyRetrieval=true"
+ "ConfigList": [
+ {
+ "ServiceName": "erpdb",
+ "dbType": "Oracle",
+ "connectionStr": "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.11)(PORT=1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME=orcl)));User Id=BIP0201;Password=BIP0201"
+ }
+ ]
}
}
\ No newline at end of file
From 991297623903c7a90bc61583580c767961e32967 Mon Sep 17 00:00:00 2001
From: majian <780924089@qq.com>
Date: Thu, 18 Jul 2024 23:54:39 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E9=9A=8F=E6=96=99=E6=9E=B6=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E6=96=99=E7=AE=B1=E4=BD=8D=E7=BD=AE=EF=BC=8C=E4=B8=8B?=
=?UTF-8?q?=E4=BB=BB=E5=8A=A1=E9=A1=BA=E5=BA=8F=E5=8F=98=E6=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Tnb.ProductionMgr/RedisBackGround.cs | 52 +-
.../Tnb.WarehouseMgr/WareHouseService.cs | 6785 +++++++++--------
.../Tnb.WarehouseMgr/WmsDistaskService.cs | 4 +-
.../WmsMaterialTransferService.cs | 4 +-
system/Tnb.Systems/Common/TestService.cs | 1 +
5 files changed, 3442 insertions(+), 3404 deletions(-)
diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs
index 98b5d8ee..2ee09157 100644
--- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs
@@ -553,6 +553,15 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerBGWCarrySupplement.LogInformation($"【BGWCarrySupplementtimer】 没有未锁定且已占用且库位中没有记录托盘的数据");
continue;
}
+
+ WmsPretaskH wmsPretaskH = db_BGWCarrySupplementtimer.Queryable().Where(r => r.endlocation_code == endLocation.location_code
+ && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
+ if (wmsPretaskH != null)
+ {
+ LoggerBGWCarrySupplement.LogWarning($"【BGWCarrySupplementtimer】存在未完成的预任务{wmsPretaskH.bill_code} 不能送托盘!");
+ continue;
+ }
+
BasLocation startLocation = wmsLoc.First();
//锁定起点库位
@@ -1171,7 +1180,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
BasLocation startLocation = rackStartLocations.First();
- List wmsCarryHs = db_Floor2timer送空托到上升降区.Queryable().Where(r => r.location_id == startLocation.id).ToList();
+ List wmsCarryHs = db_Floor2timer送空托到上升降区.Queryable().Where(r => r.location_id == startLocation.id
+ && r.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID).ToList();
if (wmsCarryHs.Count == 0)
{
LoggerFloor2RackDelivery.LogError($"【送空托到上升降区】 起点{startLocation.id} {startLocation.location_code}上找不到料架");
@@ -1346,7 +1356,8 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
BasLocation startLocation = rackStartLocations.First();
- List wmsCarryHs = db_Floor2timer送满托到下升降区.Queryable().Where(r => r.location_id == startLocation.id).ToList();
+ List wmsCarryHs = db_Floor2timer送满托到下升降区.Queryable().Where(r => r.location_id == startLocation.id
+ && r.carrystd_id == WmsWareHouseConst.CARRY_LJSTD_ID).ToList();
if (wmsCarryHs.Count == 0)
{
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 起点{startLocation.id} {startLocation.location_code}上找不到料架");
@@ -1358,7 +1369,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
LoggerFloor2RackDelivery.LogError($"【送满托到下升降区】 起点{startLocation.id} {startLocation.location_code}上存在多个料架");
continue;
}
-
+
WmsPretaskH wmsPretaskH = db_Floor2timer送满托到下升降区.Queryable().Where(r => r.endlocation_code == wmsMechanicalArmH.location_code
&& r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First();
if (wmsPretaskH != null)
@@ -1748,22 +1759,31 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
async void ElevatorTaskExceptionHandle(object args)
{
- List wmsDistaskHs = db_ElevatorTaskExceptionHandle.Queryable()
- .Where(r => r.startlocation_code.Contains("DT") && r.endlocation_code.Contains("DT") && r.act_start_date == null && r.act_end_date == null).ToList();
-
- LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】检查到需要恢复的电梯任务{wmsDistaskHs.Count}条 {string.Join(',', wmsDistaskHs.Select(x => x.bill_code))}");
- foreach (WmsDistaskH wmsDistaskH in wmsDistaskHs)
+ try
{
- ElevagorInfoQuery q = new() { endlocation_id = wmsDistaskH.endlocation_id, taskCode = wmsDistaskH.bill_code };
+ List wmsDistaskHs = db_ElevatorTaskExceptionHandle.Queryable()
+ .Where(r => r.startlocation_code.Contains("DT") && r.endlocation_code.Contains("DT") && r.act_start_date == null && r.act_end_date == null).ToList();
- LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯参数 {JsonConvert.SerializeObject(q)}");
- var e = await _wareHouseService.FindElevatorFromPars(q);
- LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
- if (e == null)
- continue;
- wmsDistaskH.device_id = e.device_id;
- await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskH);
+ LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】检查到需要恢复的电梯任务{wmsDistaskHs.Count}条 {string.Join(',', wmsDistaskHs.Select(x => x.bill_code))}");
+ foreach (WmsDistaskH wmsDistaskH in wmsDistaskHs)
+ {
+ ElevagorInfoQuery q = new() { endlocation_id = wmsDistaskH.endlocation_id, taskCode = wmsDistaskH.bill_code };
+
+ LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯参数 {JsonConvert.SerializeObject(q)}");
+ var e = await _wareHouseService.FindElevatorFromPars(q);
+ LoggerElevatorTask.Information($"【ElevatorTaskExceptionHandle】执行电梯任务时 根据任务单号获取电梯结果 {JsonConvert.SerializeObject(e)}");
+ if (e == null)
+ continue;
+ wmsDistaskH.device_id = e.device_id;
+ await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskH);
+ }
}
+ catch(Exception ex)
+ {
+ LoggerFloor2RackDelivery.LogError($"【ElevatorTaskExceptionHandle】{ex.Message}");
+ LoggerFloor2RackDelivery.LogError($"【ElevatorTaskExceptionHandle】{ex.StackTrace}");
+ }
+
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index 18d1fe56..4a265303 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -1,3401 +1,3418 @@
-using System;
-using System.Diagnostics;
-using System.Dynamic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Net;
-using System.Security.Policy;
-using System.Text;
-using System.Threading.Tasks;
-using Aop.Api.Domain;
-using Aspose.Cells;
-using JNPF;
-using JNPF.Common.Contracts;
-using JNPF.Common.Core.Manager;
-using JNPF.Common.Dtos.VisualDev;
-using JNPF.Common.Enums;
-using JNPF.Common.Extension;
-using JNPF.Common.Manager;
-using JNPF.Common.Security;
-using JNPF.FriendlyException;
-using JNPF.Systems.Entitys.System;
-using JNPF.Systems.Interfaces.System;
-using JNPF.VisualDev.Entitys;
-using JNPF.VisualDev.Interfaces;
-using Mapster;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.Rendering;
-using Microsoft.CodeAnalysis;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.Logging;
-using NetTaste;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using NPOI.OpenXmlFormats.Dml;
-using NPOI.SS.Formula.Functions;
-using Org.BouncyCastle.Crypto;
-using SqlSugar;
-using Tnb.BasicData.Entities;
-using Tnb.Common.Extension;
-using Tnb.Common.Redis;
-using Tnb.Common.Utils;
-using Tnb.ProductionMgr.Entities;
-using Tnb.ProductionMgr.Entities.Entity;
-using Tnb.QcMgr.Entities;
-using Tnb.WarehouseMgr.Entities;
-using Tnb.WarehouseMgr.Entities.Configs;
-using Tnb.WarehouseMgr.Entities.Consts;
-using Tnb.WarehouseMgr.Entities.Dto;
-using Tnb.WarehouseMgr.Entities.Dto.Inputs;
-using Tnb.WarehouseMgr.Entities.Dto.Outputs;
-using Tnb.WarehouseMgr.Entities.Dto.Queries;
-using Tnb.WarehouseMgr.Entities.Entity;
-using Tnb.WarehouseMgr.Entities.Enums;
-using Tnb.WarehouseMgr.Interfaces;
-using static NPOI.HSSF.Util.HSSFColor;
-using Tnb.BasicData;
-
-namespace Tnb.WarehouseMgr
-{
- ///
- /// 库房业务类(出入库)
- ///
- public class WareHouseService : DevServBase, IWareHouseService
- {
- private readonly ISqlSugarClient _db;
- private readonly IDictionaryDataService _dictionaryDataService;
- private readonly IBillRullService _billRullService;
- private readonly IUserManager _userManager;
- private readonly ICacheManager _cacheManager;
- private readonly IElevatorControlService _elevatorControlService;
- private readonly IWmsCarryBindService _wmsCarryBindService;
- private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
- private static readonly Dictionary _elevatorAgvCtlStatusMap = new(StringComparer.OrdinalIgnoreCase);
- private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build();
- private static Dictionary locMap = new Dictionary(StringComparer.OrdinalIgnoreCase);
- private readonly IConfiguration _configuration;
- private readonly StackExRedisHelper _redisData;
- private readonly IVisualDevService _visualDevService;
- private readonly IRunService _runService;
-
- public static SemaphoreSlim s_floor2CreatePretask = new(1);
- public static SemaphoreSlim s_taskCommonCreatePretask = new(1);
- public static SemaphoreSlim s_taskGenPreTask = new(1);
- public static SemaphoreSlim s_GenTaskExecute = new(1);
-
- public Func AddUnExecuteTask { get; set; }
-
-
- public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, StackExRedisHelper redisData,
- IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,
- IWmsCarryBindService wmsCarryBindService,
- IWmsCarryUnbindService wmsCarryUnbindService,
- IRunService runService,
- IVisualDevService visualDevService
- //IConfiguration configuration
- ) : base(repository.AsSugarClient())
- {
- _db = repository.AsSugarClient();
- _dictionaryDataService = dictionaryDataService;
- _billRullService = billRullService;
- _userManager = userManager;
- _cacheManager = cacheManager;
- _elevatorControlService = elevatorControlService;
- _redisData = redisData;
- _wmsCarryBindService = wmsCarryBindService;
- _wmsCarryUnbindService = wmsCarryUnbindService;
- _runService = runService;
- _visualDevService = visualDevService;
- //_configuration = configuration;
-
- }
-
- ///
- /// 根据载具Id带出库位、仓库信息
- ///
- /// 载具id
- ///
- /// returns:
- ///
{
- ///
carry_id:载具Id
- ///
carry_name:载具名称
- ///
location_id:库位Id
- ///
location_name:库位名称
- ///
warehouse_id:库房Id
- ///
warehouse_name:库房名称
- ///
}
- ///
- [HttpGet]
- public async Task GetLocationAndWorkHouseByCarryId([FromRoute] string carryId)
- {
- var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id)
- .LeftJoin((a, b, c) => b.wh_id == c.id)
- .Where(a => a.id == carryId)
- .Select((a, b, c) => new
- {
- carry_id = a.id,
- a.carry_name,
- location_id = b.id,
-
- b.location_name,
- warehouse_id = c.id,
- warehouse_name = c.whname,
- })
- .ToListAsync();
- return items ?? Enumerable.Empty();
- }
- ///
- /// 库房业务,入库、出库申请新增修改功能
- ///
- ///
- ///
- [HttpPost]
- public async Task ApplyFor(InOutStockApplyforUpInput input)
- {
- if (input == null)
- {
- throw new ArgumentNullException(nameof(input));
- }
-
- async Task _updateLocalFunc(InOutStockApplyforUpInput input)
- where TStockD : BaseEntity, new()
- where TStockCode : BaseEntity, IInOutStockCode, new()
- {
- TStockD instockD = input.Adapt();
- global::System.Collections.Generic.List? stockCodes = input.InstockCodes?.Adapt>();
- if (stockCodes?.Count > 0)
- {
- stockCodes.ForEach(x =>
- {
- if (x.id.IsNullOrWhiteSpace())
- {
- x.id = SnowflakeIdHelper.NextId();
- }
- x.bill_d_id = instockD.id;
- });
- }
- return await Update(instockD, stockCodes!);
- }
-
- bool isOk = input.inoutStockType switch
- {
- EnumInOutStockType.In => await _updateLocalFunc(input),
- EnumInOutStockType.Out => await _updateLocalFunc(input),
- _ => throw new ArgumentOutOfRangeException(nameof(input.inoutStockType), $"Not expected EnumInOutStockType value: {input.inoutStockType}"),
- };
- if (!isOk)
- {
- throw Oops.Oh(ErrorCode.COM1001);
- }
- }
- ///
- /// 根据明细Id获取出入库明细信息
- ///
- ///
- [HttpGet]
- public async Task GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input)
- {
- dynamic? result = input.inoutStockType switch
- {
- EnumInOutStockType.In => await FetchInOutStockCodesById(input.bill_d_id),
- EnumInOutStockType.Out => await FetchInOutStockCodesById(input.bill_d_id),
- _ => throw new NotImplementedException(),
- };
- return result ?? Enumerable.Empty();
- }
- ///
- /// 入库策略
- ///
- ///
- [HttpGet]
- public async Task> InStockStrategy([FromQuery] InStockStrategyQuery input)
- {
- List items = new();
- try
- {
- WmsInstockPolicies policy = await _db.CopyNew().Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用的策略", 500);
- }
-
- Expression> whereExp = Expressionable.Create()
- .And(it => it.wh_id == input.warehouse_id)
- .And(it => it.is_lock == 0)
- .And(it => it.is_type == ((int)EnumLocationType.存储库位).ToString())
- .And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
- .ToExpression();
- items = await _db.CopyNew().Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
- }
- catch (Exception)
- {
- throw;
- }
- return items.Take(input.Size).ToList();
- }
- ///
- /// 入库策略
- ///
- ///
- [HttpGet]
- public async Task> InStockStrategyBCK([FromQuery] InStockStrategyQuery input)
- {
- List items = new();
- try
- {
- WmsInstockPolicies policy = await _db.CopyNew().Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用的策略", 500);
- }
-
- Expression> whereExp = Expressionable.Create()
- .And(it => it.wh_id == input.warehouse_id)
- .And(it => it.is_lock == 0)
- .And(it => it.is_type == ((int)EnumLocationType.分拣库位).ToString())
- .And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
- .ToExpression();
- items = await _db.CopyNew().Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
- }
- catch (Exception)
- {
- throw;
- }
- return items.Take(input.Size).ToList();
- }
-
- ///
- /// 包材库2楼入库策略
- ///
- ///
- [HttpGet]
- public async Task> BCKF2InStockStrategy([FromQuery] InStockStrategyQuery input)
- {
- List items = new();
- try
- {
- WmsInstockPolicies policy = await _db.CopyNew().Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用的策略", 500);
- }
-
- Expression> whereExp = Expressionable.Create()
- .And(it => it.wh_id == input.warehouse_id)
- .And(it => it.is_lock == 0)
- .And(it => it.is_type == ((int)EnumLocationType.出入库位).ToString())
- .And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
- .ToExpression();
- items = await _db.CopyNew().Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
- }
- catch (Exception)
- {
- throw;
- }
- return items.Take(input.Size).ToList();
- }
-
-
- ///
- /// 是否为一楼出库工位
- ///
- ///
- ///
- public string[] GetFloor1OutstockLocation()
- {
- return new string[23] { "30018211902485", "34355463261205", "34355450098709", "34355446145813"
- , "34355443336981", "34355440377365", "34355436327189", "34355432397077", "34355428852501", "34355424568341"
- , "34355421064213", "34355416966165", "34355407509269", "34355402216469", "34355397484565", "34355394965013"
- , "34355391740181", "34355387110933", "34355383562005", "34355377989397", "34355374481173", "34355369617173"
- , "30018211902485"};
- }
-
- ///
- /// 是否为二楼包材出库工位
- ///
- ///
- ///
- public string[] GetFloor2BCOutstockLocation()
- {
- return new string[1] { "30018211902485" };
- }
-
- ///
- /// 是否为供料三工位库位
- ///
- ///
- ///
- public string[] GetFloor1GLSGWOutstockLocation()
- {
- return new string[5] { WmsWareHouseConst.Floor1GLSGWOutstockStation1 , WmsWareHouseConst.Floor1GLSGWOutstockStation2
- , WmsWareHouseConst.Floor1GLSGWOutstockStation3, WmsWareHouseConst.Floor1GLSGWOutstockStation4, WmsWareHouseConst.Floor1GLSGWOutstockStation5 };
- }
-
- ///
- /// 是否为外协三工位库位
- ///
- ///
- ///
- public string[] GetFloor1WXSGWOutstockLocation()
- {
- return new string[3] { WmsWareHouseConst.Floor1WXSGWOutstockStation1 , WmsWareHouseConst.Floor1WXSGWOutstockStation2
- , WmsWareHouseConst.Floor1WXSGWOutstockStation3 };
- }
-
- ///
- /// 出库策略-销售出库下发
- ///
- ///
- [HttpGet]
- public async Task>> OutStockStrategy_saleRelease([FromQuery] OutStockStrategyQuery input)
- {
- Expressionable whereExprable = Expressionable.Create()
- .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
- .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
- .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
- .And((a, b, c) => a.out_status == "0")
- .And((a, b, c) => c.wh_id == input.warehouse_id)
- .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
- .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
- .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
- .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
- .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
- Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
- ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
- : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
- _ = whereExprable.And(carryStatusFilterExp);
- Expression> whereExpr = whereExprable.ToExpression();
-
- SqlSugarClient cyDb = _db.CopyNew();
-
-
- List> items = cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
- .LeftJoin((a, b, c) => a.location_id == c.id)
- .Where(whereExpr)
- //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
- .OrderBy("a.location_code,layers,loc_line,loc_column")
- .Select((a, b, c) => new
- {
- WmsCarryH = a,
- WmsCarryCode = b,
- BasLocation = c,
- codeqty = b.codeqty
- }).ToList().Select(r =>
- {
- // 如果可出库数量已经扣减完
- if (input.qty <= 0)
- {
- return new Tuple("", r.WmsCarryH, r.WmsCarryCode, r.BasLocation);
- }
-
- // 扣减可出库数量
- input.qty = input.qty - r.codeqty;
-
- // 出库数量与托盘上的数量不一致需要进行分拣
- if (input.qty < 0)
- {
- r.WmsCarryCode.codeqty = input.qty + r.codeqty;
- return new Tuple("分拣任务", r.WmsCarryH, r.WmsCarryCode, r.BasLocation);
- }
- else
- {
- // 正常预任务出库
- return new Tuple("预任务", r.WmsCarryH, r.WmsCarryCode, r.BasLocation);
- }
- }).Where(r => r.Item1 != "").ToList();
- return items;
- }
-
- public async Task> OutStockStrategy([FromQuery] OutStockStrategyQuery input)
- {
- Expressionable whereExprable = Expressionable.Create()
- .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
- .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
- .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
- .And((a, b, c) => a.out_status == "0")
- .And((a, b, c) => c.wh_id == input.warehouse_id)
- .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
- .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
- .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
- .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
- .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
- Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
- ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
- : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
- _ = whereExprable.And(carryStatusFilterExp);
- Expression> whereExpr = whereExprable.ToExpression();
-
- SqlSugarClient cyDb = _db.CopyNew();
- WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用策略", 500);
- }
-
- List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
- .LeftJoin((a, b, c) => a.location_id == c.id)
- .Where(whereExpr)
- //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
- .OrderBy(policy.policy)
-
- .Select()
- .ToListAsync();
- return input.Size > 0 ? items.Take(input.Size).ToList() : items;
- }
-
- ///
- /// 原材料仓出库策略
- ///
- ///
- ///
- ///
- public async Task> OutStockStrategyYCL([FromQuery] OutStockStrategyQuery input)
- {
- Expressionable whereExprable = Expressionable.Create()
- .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
- .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
- .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
- .And((a, b, c) => a.out_status == "0")
- .And((a, b, c) => c.wh_id == input.warehouse_id)
- .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
- .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
- .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
- .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
- .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
- Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
- ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
- : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
- _ = whereExprable.And(carryStatusFilterExp);
- Expression> whereExpr = whereExprable.ToExpression();
-
- SqlSugarClient cyDb = _db.CopyNew();
- WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用策略", 500);
- }
-
- List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
- .LeftJoin((a, b, c) => a.location_id == c.id)
- .Where(whereExpr)
- //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
- .OrderBy(policy.policy)
-
- .Select()
- .ToListAsync();
-
- items = items.Distinct().ToList();
- return input.Size > 0 ? items.Take(input.Size).ToList() : items;
- }
-
- ///
- /// 缓存仓出库策略
- ///
- ///
- ///
- ///
- public async Task> OutStockStrategyHCC([FromQuery] OutStockStrategyQuery input)
- {
- Expressionable whereExprable = Expressionable.Create()
- .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
- .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
- .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
- .And((a, b, c) => a.out_status == "0")
- .And((a, b, c) => c.wh_id == input.warehouse_id)
- .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
- .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
- .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
- .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
- .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
- Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
- ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
- : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
- _ = whereExprable.And(carryStatusFilterExp);
- Expression> whereExpr = whereExprable.ToExpression();
-
- SqlSugarClient cyDb = _db.CopyNew();
- WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用策略", 500);
- }
-
- List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
- .LeftJoin((a, b, c) => a.location_id == c.id)
- .Where(whereExpr)
- //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
- .OrderBy(policy.policy)
-
- .Select()
- .ToListAsync();
-
-
- items = items.Distinct().ToList();
- return input.Size > 0 ? items.Take(input.Size).ToList() : items;
- }
-
- ///
- /// 1->2出库策略
- ///
- ///
- ///
- ///
- public async Task>> OutStockStrategyZCC2Floor2([FromQuery] OutStockStrategyZCC2Floor2Query input)
- {
- Expressionable whereExprable = Expressionable.Create()
- .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
- .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
- .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
- .And((a, b, c) => a.out_status == "0")
- .And((a, b, c) => c.wh_id == input.warehouse_id)
- .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
- .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
- .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
- .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
- .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
- Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
- ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
- : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
- _ = whereExprable.And(carryStatusFilterExp);
- Expression> whereExpr = whereExprable.ToExpression();
-
- SqlSugarClient cyDb = _db.CopyNew();
- WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
- if (policy == null)
- {
- throw new AppFriendlyException("没有可用策略", 500);
- }
-
- #region 只解决少数情况(比如只有60 59 60 60四个料箱,下发180,要取60 60 60) 其它情况不考虑
-
- var itemsASC = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
- .LeftJoin((a, b, c) => a.location_id == c.id)
- .Where(whereExpr)
- //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
- //.OrderBy(policy.policy)
- .OrderBy("codeqty desc,a.location_code,layers,loc_line,loc_column")
-
- .Select((a, b) => new { wmsCarryH = a, wmsCarryCode = b })
- .ToListAsync();
- //items = itemsASC.Count < itemsDESC.Count ? itemsASC : itemsDESC;
-
- itemsASC = itemsASC.Distinct().ToList();
-
+using System;
+using System.Diagnostics;
+using System.Dynamic;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Net;
+using System.Security.Policy;
+using System.Text;
+using System.Threading.Tasks;
+using Aop.Api.Domain;
+using Aspose.Cells;
+using JNPF;
+using JNPF.Common.Contracts;
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
+using JNPF.Common.Enums;
+using JNPF.Common.Extension;
+using JNPF.Common.Manager;
+using JNPF.Common.Security;
+using JNPF.FriendlyException;
+using JNPF.Systems.Entitys.System;
+using JNPF.Systems.Interfaces.System;
+using JNPF.VisualDev.Entitys;
+using JNPF.VisualDev.Interfaces;
+using Mapster;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Rendering;
+using Microsoft.CodeAnalysis;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using NetTaste;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using NPOI.OpenXmlFormats.Dml;
+using NPOI.SS.Formula.Functions;
+using Org.BouncyCastle.Crypto;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.Common.Extension;
+using Tnb.Common.Redis;
+using Tnb.Common.Utils;
+using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Entities.Entity;
+using Tnb.QcMgr.Entities;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Entities.Configs;
+using Tnb.WarehouseMgr.Entities.Consts;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
+using Tnb.WarehouseMgr.Entities.Dto.Outputs;
+using Tnb.WarehouseMgr.Entities.Dto.Queries;
+using Tnb.WarehouseMgr.Entities.Entity;
+using Tnb.WarehouseMgr.Entities.Enums;
+using Tnb.WarehouseMgr.Interfaces;
+using static NPOI.HSSF.Util.HSSFColor;
+using Tnb.BasicData;
+using System.Reflection;
+
+namespace Tnb.WarehouseMgr
+{
+ ///
+ /// 库房业务类(出入库)
+ ///
+ public class WareHouseService : DevServBase, IWareHouseService
+ {
+ private readonly ISqlSugarClient _db;
+ private readonly IDictionaryDataService _dictionaryDataService;
+ private readonly IBillRullService _billRullService;
+ private readonly IUserManager _userManager;
+ private readonly ICacheManager _cacheManager;
+ private readonly IElevatorControlService _elevatorControlService;
+ private readonly IWmsCarryBindService _wmsCarryBindService;
+ private readonly IWmsCarryUnbindService _wmsCarryUnbindService;
+ private static readonly Dictionary _elevatorAgvCtlStatusMap = new(StringComparer.OrdinalIgnoreCase);
+ private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build();
+ private static Dictionary locMap = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ private readonly IConfiguration _configuration;
+ private readonly StackExRedisHelper _redisData;
+ private readonly IVisualDevService _visualDevService;
+ private readonly IRunService _runService;
+
+ public static SemaphoreSlim s_floor2CreatePretask = new(1);
+ public static SemaphoreSlim s_taskCommonCreatePretask = new(1);
+ public static SemaphoreSlim s_taskGenPreTask = new(1);
+ public static SemaphoreSlim s_GenTaskExecute = new(1);
+
+ public Func AddUnExecuteTask { get; set; }
+
+
+ public WareHouseService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, StackExRedisHelper redisData,
+ IBillRullService billRullService, IUserManager userManager, ICacheManager cacheManager, IElevatorControlService elevatorControlService,
+ IWmsCarryBindService wmsCarryBindService,
+ IWmsCarryUnbindService wmsCarryUnbindService,
+ IRunService runService,
+ IVisualDevService visualDevService
+ //IConfiguration configuration
+ ) : base(repository.AsSugarClient())
+ {
+ _db = repository.AsSugarClient();
+ _dictionaryDataService = dictionaryDataService;
+ _billRullService = billRullService;
+ _userManager = userManager;
+ _cacheManager = cacheManager;
+ _elevatorControlService = elevatorControlService;
+ _redisData = redisData;
+ _wmsCarryBindService = wmsCarryBindService;
+ _wmsCarryUnbindService = wmsCarryUnbindService;
+ _runService = runService;
+ _visualDevService = visualDevService;
+ //_configuration = configuration;
+
+ }
+
+ ///
+ /// 根据载具Id带出库位、仓库信息
+ ///
+ /// 载具id
+ ///
+ /// returns:
+ ///
{
+ ///
carry_id:载具Id
+ ///
carry_name:载具名称
+ ///
location_id:库位Id
+ ///
location_name:库位名称
+ ///
warehouse_id:库房Id
+ ///
warehouse_name:库房名称
+ ///
}
+ ///
+ [HttpGet]
+ public async Task GetLocationAndWorkHouseByCarryId([FromRoute] string carryId)
+ {
+ var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id)
+ .LeftJoin((a, b, c) => b.wh_id == c.id)
+ .Where(a => a.id == carryId)
+ .Select((a, b, c) => new
+ {
+ carry_id = a.id,
+ a.carry_name,
+ location_id = b.id,
+
+ b.location_name,
+ warehouse_id = c.id,
+ warehouse_name = c.whname,
+ })
+ .ToListAsync();
+ return items ?? Enumerable.Empty();
+ }
+ ///
+ /// 库房业务,入库、出库申请新增修改功能
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task ApplyFor(InOutStockApplyforUpInput input)
+ {
+ if (input == null)
+ {
+ throw new ArgumentNullException(nameof(input));
+ }
+
+ async Task _updateLocalFunc(InOutStockApplyforUpInput input)
+ where TStockD : BaseEntity, new()
+ where TStockCode : BaseEntity, IInOutStockCode, new()
+ {
+ TStockD instockD = input.Adapt();
+ global::System.Collections.Generic.List? stockCodes = input.InstockCodes?.Adapt>();
+ if (stockCodes?.Count > 0)
+ {
+ stockCodes.ForEach(x =>
+ {
+ if (x.id.IsNullOrWhiteSpace())
+ {
+ x.id = SnowflakeIdHelper.NextId();
+ }
+ x.bill_d_id = instockD.id;
+ });
+ }
+ return await Update(instockD, stockCodes!);
+ }
+
+ bool isOk = input.inoutStockType switch
+ {
+ EnumInOutStockType.In => await _updateLocalFunc(input),
+ EnumInOutStockType.Out => await _updateLocalFunc(input),
+ _ => throw new ArgumentOutOfRangeException(nameof(input.inoutStockType), $"Not expected EnumInOutStockType value: {input.inoutStockType}"),
+ };
+ if (!isOk)
+ {
+ throw Oops.Oh(ErrorCode.COM1001);
+ }
+ }
+ ///
+ /// 根据明细Id获取出入库明细信息
+ ///
+ ///
+ [HttpGet]
+ public async Task GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input)
+ {
+ dynamic? result = input.inoutStockType switch
+ {
+ EnumInOutStockType.In => await FetchInOutStockCodesById(input.bill_d_id),
+ EnumInOutStockType.Out => await FetchInOutStockCodesById(input.bill_d_id),
+ _ => throw new NotImplementedException(),
+ };
+ return result ?? Enumerable.Empty();
+ }
+ ///
+ /// 入库策略
+ ///
+ ///
+ [HttpGet]
+ public async Task> InStockStrategy([FromQuery] InStockStrategyQuery input)
+ {
+ List items = new();
+ try
+ {
+ WmsInstockPolicies policy = await _db.CopyNew().Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用的策略", 500);
+ }
+
+ Expression> whereExp = Expressionable.Create()
+ .And(it => it.wh_id == input.warehouse_id)
+ .And(it => it.is_lock == 0)
+ .And(it => it.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
+ .ToExpression();
+ items = await _db.CopyNew().Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ return items.Take(input.Size).ToList();
+ }
+ ///
+ /// 入库策略
+ ///
+ ///
+ [HttpGet]
+ public async Task> InStockStrategyBCK([FromQuery] InStockStrategyQuery input)
+ {
+ List items = new();
+ try
+ {
+ WmsInstockPolicies policy = await _db.CopyNew().Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用的策略", 500);
+ }
+
+ Expression> whereExp = Expressionable.Create()
+ .And(it => it.wh_id == input.warehouse_id)
+ .And(it => it.is_lock == 0)
+ .And(it => it.is_type == ((int)EnumLocationType.分拣库位).ToString())
+ .And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
+ .ToExpression();
+ items = await _db.CopyNew().Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ return items.Take(input.Size).ToList();
+ }
+
+ ///
+ /// 包材库2楼入库策略
+ ///
+ ///
+ [HttpGet]
+ public async Task> BCKF2InStockStrategy([FromQuery] InStockStrategyQuery input)
+ {
+ List items = new();
+ try
+ {
+ WmsInstockPolicies policy = await _db.CopyNew().Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用的策略", 500);
+ }
+
+ Expression> whereExp = Expressionable.Create()
+ .And(it => it.wh_id == input.warehouse_id)
+ .And(it => it.is_lock == 0)
+ .And(it => it.is_type == ((int)EnumLocationType.出入库位).ToString())
+ .And(it => it.is_use == ((int)EnumCarryStatus.空闲).ToString())
+ .ToExpression();
+ items = await _db.CopyNew().Queryable().Where(whereExp).OrderBy(policy.policy).ToListAsync();
+ }
+ catch (Exception)
+ {
+ throw;
+ }
+ return items.Take(input.Size).ToList();
+ }
+
+
+ ///
+ /// 是否为一楼出库工位
+ ///
+ ///
+ ///
+ public string[] GetFloor1OutstockLocation()
+ {
+ return new string[23] { "30018211902485", "34355463261205", "34355450098709", "34355446145813"
+ , "34355443336981", "34355440377365", "34355436327189", "34355432397077", "34355428852501", "34355424568341"
+ , "34355421064213", "34355416966165", "34355407509269", "34355402216469", "34355397484565", "34355394965013"
+ , "34355391740181", "34355387110933", "34355383562005", "34355377989397", "34355374481173", "34355369617173"
+ , "30018211902485"};
+ }
+
+ ///
+ /// 是否为二楼包材出库工位
+ ///
+ ///
+ ///
+ public string[] GetFloor2BCOutstockLocation()
+ {
+ return new string[1] { "30018211902485" };
+ }
+
+ ///
+ /// 是否为供料三工位库位
+ ///
+ ///
+ ///
+ public string[] GetFloor1GLSGWOutstockLocation()
+ {
+ return new string[5] { WmsWareHouseConst.Floor1GLSGWOutstockStation1 , WmsWareHouseConst.Floor1GLSGWOutstockStation2
+ , WmsWareHouseConst.Floor1GLSGWOutstockStation3, WmsWareHouseConst.Floor1GLSGWOutstockStation4, WmsWareHouseConst.Floor1GLSGWOutstockStation5 };
+ }
+
+ ///
+ /// 是否为外协三工位库位
+ ///
+ ///
+ ///
+ public string[] GetFloor1WXSGWOutstockLocation()
+ {
+ return new string[3] { WmsWareHouseConst.Floor1WXSGWOutstockStation1 , WmsWareHouseConst.Floor1WXSGWOutstockStation2
+ , WmsWareHouseConst.Floor1WXSGWOutstockStation3 };
+ }
+
+ ///
+ /// 出库策略-销售出库下发
+ ///
+ ///
+ [HttpGet]
+ public async Task>> OutStockStrategy_saleRelease([FromQuery] OutStockStrategyQuery input)
+ {
+ Expressionable whereExprable = Expressionable.Create()
+ .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
+ .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
+ .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And((a, b, c) => a.out_status == "0")
+ .And((a, b, c) => c.wh_id == input.warehouse_id)
+ .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
+ .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
+ .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
+ .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
+ .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
+ Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
+ ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
+ : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
+ _ = whereExprable.And(carryStatusFilterExp);
+ Expression> whereExpr = whereExprable.ToExpression();
+
+ SqlSugarClient cyDb = _db.CopyNew();
+
+
+ List> items = cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
+ .LeftJoin((a, b, c) => a.location_id == c.id)
+ .Where(whereExpr)
+ //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
+ .OrderBy("a.location_code,layers,loc_line,loc_column")
+ .Select((a, b, c) => new
+ {
+ WmsCarryH = a,
+ WmsCarryCode = b,
+ BasLocation = c,
+ codeqty = b.codeqty
+ }).ToList().Select(r =>
+ {
+ // 如果可出库数量已经扣减完
+ if (input.qty <= 0)
+ {
+ return new Tuple("", r.WmsCarryH, r.WmsCarryCode, r.BasLocation);
+ }
+
+ // 扣减可出库数量
+ input.qty = input.qty - r.codeqty;
+
+ // 出库数量与托盘上的数量不一致需要进行分拣
+ if (input.qty < 0)
+ {
+ r.WmsCarryCode.codeqty = input.qty + r.codeqty;
+ return new Tuple("分拣任务", r.WmsCarryH, r.WmsCarryCode, r.BasLocation);
+ }
+ else
+ {
+ // 正常预任务出库
+ return new Tuple("预任务", r.WmsCarryH, r.WmsCarryCode, r.BasLocation);
+ }
+ }).Where(r => r.Item1 != "").ToList();
+ return items;
+ }
+
+ public async Task> OutStockStrategy([FromQuery] OutStockStrategyQuery input)
+ {
+ Expressionable whereExprable = Expressionable.Create()
+ .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
+ .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
+ .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And((a, b, c) => a.out_status == "0")
+ .And((a, b, c) => c.wh_id == input.warehouse_id)
+ .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
+ .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
+ .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
+ .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
+ .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
+ Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
+ ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
+ : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
+ _ = whereExprable.And(carryStatusFilterExp);
+ Expression> whereExpr = whereExprable.ToExpression();
+
+ SqlSugarClient cyDb = _db.CopyNew();
+ WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用策略", 500);
+ }
+
+ List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
+ .LeftJoin((a, b, c) => a.location_id == c.id)
+ .Where(whereExpr)
+ //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
+ .OrderBy(policy.policy)
+
+ .Select()
+ .ToListAsync();
+ return input.Size > 0 ? items.Take(input.Size).ToList() : items;
+ }
+
+ ///
+ /// 原材料仓出库策略
+ ///
+ ///
+ ///
+ ///
+ public async Task> OutStockStrategyYCL([FromQuery] OutStockStrategyQuery input)
+ {
+ Expressionable whereExprable = Expressionable.Create()
+ .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
+ .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
+ .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And((a, b, c) => a.out_status == "0")
+ .And((a, b, c) => c.wh_id == input.warehouse_id)
+ .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
+ .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
+ .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
+ .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
+ .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
+ Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
+ ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
+ : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
+ _ = whereExprable.And(carryStatusFilterExp);
+ Expression> whereExpr = whereExprable.ToExpression();
+
+ SqlSugarClient cyDb = _db.CopyNew();
+ WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用策略", 500);
+ }
+
+ List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
+ .LeftJoin((a, b, c) => a.location_id == c.id)
+ .Where(whereExpr)
+ //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
+ .OrderBy(policy.policy)
+
+ .Select()
+ .ToListAsync();
+
+ items = items.Distinct().ToList();
+ return input.Size > 0 ? items.Take(input.Size).ToList() : items;
+ }
+
+ ///
+ /// 缓存仓出库策略
+ ///
+ ///
+ ///
+ ///
+ public async Task> OutStockStrategyHCC([FromQuery] OutStockStrategyQuery input)
+ {
+ Expressionable whereExprable = Expressionable.Create()
+ .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
+ .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
+ .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And((a, b, c) => a.out_status == "0")
+ .And((a, b, c) => c.wh_id == input.warehouse_id)
+ .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
+ .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
+ .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
+ .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
+ .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
+ Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
+ ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
+ : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
+ _ = whereExprable.And(carryStatusFilterExp);
+ Expression> whereExpr = whereExprable.ToExpression();
+
+ SqlSugarClient cyDb = _db.CopyNew();
+ WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用策略", 500);
+ }
+
+ List items = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
+ .LeftJoin((a, b, c) => a.location_id == c.id)
+ .Where(whereExpr)
+ //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
+ .OrderBy(policy.policy)
+
+ .Select()
+ .ToListAsync();
+
+
+ items = items.Distinct().ToList();
+ return input.Size > 0 ? items.Take(input.Size).ToList() : items;
+ }
+
+ ///
+ /// 1->2出库策略
+ ///
+ ///
+ ///
+ ///
+ public async Task>> OutStockStrategyZCC2Floor2([FromQuery] OutStockStrategyZCC2Floor2Query input)
+ {
+ Expressionable whereExprable = Expressionable.Create()
+ .And((a, b, c) => a.is_lock == 0 && c.is_lock == 0)
+ .And((a, b, c) => !string.IsNullOrEmpty(a.location_id))
+ .And((a, b, c) => c.is_type == ((int)EnumLocationType.存储库位).ToString())
+ .And((a, b, c) => a.out_status == "0")
+ .And((a, b, c) => c.wh_id == input.warehouse_id)
+ .AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id)
+ .AndIF(!string.IsNullOrEmpty(input.code_batch), (a, b, c) => b.code_batch == input.code_batch)
+ .AndIF(!string.IsNullOrEmpty(input.material_specification), (a, b, c) => b.material_specification == input.material_specification)
+ .AndIF(!string.IsNullOrEmpty(input.container_no), (a, b, c) => b.container_no == input.container_no)
+ .AndIF(!string.IsNullOrEmpty(input.carrystd_id), (a, b, c) => a.carrystd_id == input.carrystd_id);
+ Expression> carryStatusFilterExp = !input.material_id.IsNullOrWhiteSpace()
+ ? (a, b, c) => a.carry_status == ((int)EnumCarryStatus.占用).ToString()
+ : (a, b, c) => a.carry_status == ((int)EnumCarryStatus.空闲).ToString();
+ _ = whereExprable.And(carryStatusFilterExp);
+ Expression> whereExpr = whereExprable.ToExpression();
+
+ SqlSugarClient cyDb = _db.CopyNew();
+ WmsInstockPolicies policy = await cyDb.Queryable().Where(it => it.status == 1).FirstAsync();
+ if (policy == null)
+ {
+ throw new AppFriendlyException("没有可用策略", 500);
+ }
+
+ #region 只解决少数情况(比如只有60 59 60 60四个料箱,下发180,要取60 60 60) 其它情况不考虑
+
+ var itemsASC = await cyDb.Queryable().LeftJoin((a, b) => a.id == b.carry_id)
+ .LeftJoin((a, b, c) => a.location_id == c.id)
+ .Where(whereExpr)
+ //.OrderByIF((a,b,c)=>SqlFunc.IsNullOrEmpty())
+ //.OrderBy(policy.policy)
+ .OrderBy("codeqty desc,a.location_code,layers,loc_line,loc_column")
+
+ .Select((a, b) => new { wmsCarryH = a, wmsCarryCode = b })
+ .ToListAsync();
+ //items = itemsASC.Count < itemsDESC.Count ? itemsASC : itemsDESC;
+
+ itemsASC = itemsASC.Distinct().ToList();
+
List>? carrys = new List>();
- for (int i = 0; i < itemsASC.Count; i++)
- {
- WmsCarryH wmsCarryH = itemsASC[i].wmsCarryH;
- WmsCarryCode wmsCarryCode = itemsASC[i].wmsCarryCode;
+ // 6个下发一条任务链
+ int move_num = 6;
int endlocation_index = 0;
string[] endlocations = new string[2] { "32609229889045", "32609238573589" };
+ BasLocation endlocation_ssx = null;
- if (input.needOut <= 0)
- {
- break;
+ for (int i = 0; i < itemsASC.Count; i++)
+ {
+ WmsCarryH wmsCarryH = itemsASC[i].wmsCarryH;
+ WmsCarryCode wmsCarryCode = itemsASC[i].wmsCarryCode;
+
+ if (input.needOut <= 0)
+ {
+ break;
}
-
- // 查找是否有一个料箱可以正好满足剩余需求数量(目前只做这个额外判断,其它情形不考虑)
- bool isFind = false;
- for (int j = i + 1; j < itemsASC.Count; j++)
+ // 每6个重新获取一次终点
+ if (i % move_num == 0)
{
- WmsCarryCode _wmsCarryCode = itemsASC[j].wmsCarryCode;
- if (_wmsCarryCode.codeqty == input.needOut)
- {
- input.needOut -= _wmsCarryCode.codeqty;
- WmsCarryH _wmsCarryH = itemsASC[j].wmsCarryH;
+ endlocation_ssx = await _db.Queryable().Where(r => endlocations.Contains(r.id)).OrderBy("is_lock, task_nums, location_code").FirstAsync();
+ }
+
+ // 查找是否有一个料箱可以正好满足剩余需求数量(目前只做这个额外判断,其它情形不考虑)
+ bool isFind = false;
+ for (int j = i + 1; j < itemsASC.Count; j++)
+ {
+ WmsCarryCode _wmsCarryCode = itemsASC[j].wmsCarryCode;
+ if (_wmsCarryCode.codeqty == input.needOut)
+ {
+ input.needOut -= _wmsCarryCode.codeqty;
+ WmsCarryH _wmsCarryH = itemsASC[j].wmsCarryH;
+
+ await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => endlocation_ssx.id == it.id).ExecuteCommandAsync();
+
+ carrys.Add(new Tuple(_wmsCarryH, _wmsCarryCode.codeqty, endlocation_ssx));
+
+ isFind = true;
+ break;
+ }
+
+ }
+ if (isFind)
+ break;
+
+ // 目前只支持一个料箱只有一个物料
+ input.needOut -= wmsCarryCode.codeqty;
+
+ await _db.Updateable().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => endlocation_ssx.id == it.id).ExecuteCommandAsync();
+
+ carrys.Add(new Tuple(wmsCarryH, wmsCarryCode.codeqty, endlocation_ssx));
+ }
+ #endregion
+
+ if (input.needOut > 0)
+ {
+ throw new AppFriendlyException($"物料{input.material_code}没有足够的库存!,缺失数量为{input.needOut}", 500);
+ }
+
+
+ return carrys;
+ }
+
+ ///
+ /// 判断CTU是否可以放货
+ ///
+ ///
+ [HttpPost]
+ [AllowAnonymous]
+ public async Task CheckPut(CheckPutInput input)
+ {
+ Logger.Information("联核请求CheckPut接口传入参数为:" + JsonConvert.SerializeObject(input));
+
+ Dictionary putdic = new Dictionary();
+
+ putdic.Add("SSX-011-006", new string[] { "YTCS", "AllowEmptyIn_CS06" });
+ putdic.Add("SSX-021-007", new string[] { "东面提升机输送线", "出库输送线7允许入箱" });
+ putdic.Add("SSX-121-009", new string[] { "东面提升机输送线", "上升降机9允许入箱" });
+ putdic.Add("SSX-121-010", new string[] { "东面提升机输送线", "上升降机10允许入箱" });
+ putdic.Add("SSX-021-003", new string[] { "YTCS", "AllowCtuEmptyIn_CS03" });
+ putdic.Add("SSX-021-001", new string[] { "YTCS", "AllowCtuEmptyIn_CS01" });
+ putdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowCtuFullOut_CS04", });
+ putdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowCtuFullOut_CS02", });
+ var strs = new string[] { };
+
+ if (!putdic.ContainsKey(input.targetName))
+ throw new AppFriendlyException("点位" + input.targetName + "不存在", 500);
+ strs = putdic.Where(p => p.Key == input.targetName).First().Value;
+
+ bool flag = await _redisData.HashExists(strs[0], strs[1]);
+ if (!flag)
+ {
+ throw new AppFriendlyException("点位" + input.targetName + "不存在", 500);
+ }
+ string data = await _redisData.GetHash(strs[0], strs[1]);
+ Logger.Information("wcs请求CheckPut接口查询X2Server数据:" + data);
+ JObject? res = JsonConvert.DeserializeObject(data);
+ bool result = res != null && res["Value"] != null ? res.Value("Value") : false;
+ if (!result)
+ throw new AppFriendlyException("点位" + input.targetName + "不可放", 500);
+ Logger.Information("wcs请求CheckPut接口结果:CTU可放货" + data);
+ }
+
+ ///
+ /// 判断CTU是否可以取货
+ ///
+ ///
+
+ public async Task Check(string code, string action)
+ {
+ Logger.Information($"【Check】 判断KIVA是否可以{action} {code}");
+ Dictionary putdic = new Dictionary();
+ Dictionary getdic = new Dictionary();
+
+ putdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvFullIn_CS04", });
+ putdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvFullIn_CS02", });
+ getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01" });
+ getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03" });
+
+ #region 注塑车间点位
+ putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2允许入空箱", });
+ getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2允许取满箱" });
+
+ putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3允许入空箱", });
+ getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3允许取满箱" });
+
+ putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4允许入空箱", });
+ getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4允许取满箱" });
+
+ putdic.Add("ZS-C04-1", new string[] { "hxjC", "A5允许入空箱", });
+ getdic.Add("ZS-C04-2", new string[] { "hxjC", "A5允许取满箱" });
+
+ putdic.Add("ZS-C05-1", new string[] { "hxjC", "A6允许入空箱", });
+ getdic.Add("ZS-C05-2", new string[] { "hxjC", "A6允许取满箱" });
+
+ putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7允许入空箱", });
+ getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7允许取满箱" });
+
+ putdic.Add("ZS-C07-1", new string[] { "hxjC", "A8允许入空箱", });
+ getdic.Add("ZS-C07-2", new string[] { "hxjC", "A8允许取满箱" });
+
+ putdic.Add("ZS-C08-1", new string[] { "hxjC", "A9允许入空箱", });
+ getdic.Add("ZS-C08-2", new string[] { "hxjC", "A9允许取满箱" });
+
+ putdic.Add("ZS-C09-1", new string[] { "hxjC", "A10允许入空箱", });
+ getdic.Add("ZS-C09-2", new string[] { "hxjC", "A10允许取满箱" });
+
+ putdic.Add("ZS-C10-1", new string[] { "hxjC", "A11允许入空箱", });
+ getdic.Add("ZS-C10-2", new string[] { "hxjC", "A11允许取满箱" });
+
+ putdic.Add("ZS-C11-1", new string[] { "hxjC", "A12允许入空箱", });
+ getdic.Add("ZS-C11-2", new string[] { "hxjC", "A12允许取满箱" });
+
+ putdic.Add("ZS-C12-1", new string[] { "hxjC", "A13允许入空箱", });
+ getdic.Add("ZS-C12-2", new string[] { "hxjC", "A13允许取满箱" });
+
+ putdic.Add("ZS-C13-1", new string[] { "hxjC", "A14允许入空箱", });
+ getdic.Add("ZS-C13-2", new string[] { "hxjC", "A14允许取满箱" });
+
+ putdic.Add("ZS-C14-1", new string[] { "hxjC", "A1允许入空箱", });
+ getdic.Add("ZS-C14-2", new string[] { "hxjC", "A1允许取满箱" });
+
+
+ putdic.Add("ZS-A01-1", new string[] { "hxjA", "A3允许入空箱", });
+ getdic.Add("ZS-A01-2", new string[] { "hxjA", "A3允许取满箱" });
+
+ putdic.Add("ZS-A02-1", new string[] { "hxjA", "A4允许入空箱", });
+ getdic.Add("ZS-A02-2", new string[] { "hxjA", "A4允许取满箱" });
+
+ putdic.Add("ZS-A03-1", new string[] { "hxjA", "A5允许入空箱", });
+ getdic.Add("ZS-A03-2", new string[] { "hxjA", "A5允许取满箱" });
+
+ putdic.Add("ZS-A04-1", new string[] { "hxjA", "A6允许入空箱", });
+ getdic.Add("ZS-A04-2", new string[] { "hxjA", "A6允许取满箱" });
+
+ putdic.Add("ZS-A05-1", new string[] { "hxjA", "A7允许入空箱", });
+ getdic.Add("ZS-A05-2", new string[] { "hxjA", "A7允许取满箱" });
+
+ putdic.Add("ZS-A06-1", new string[] { "hxjA", "A8允许入空箱", });
+ getdic.Add("ZS-A06-2", new string[] { "hxjA", "A8允许取满箱" });
+
+ putdic.Add("ZS-A07-1", new string[] { "hxjA", "A9允许入空箱", });
+ getdic.Add("ZS-A07-2", new string[] { "hxjA", "A9允许取满箱" });
+
+ putdic.Add("ZS-A08-1", new string[] { "hxjA", "A10允许入空箱", });
+ getdic.Add("ZS-A08-2", new string[] { "hxjA", "A10允许取满箱" });
+
+ putdic.Add("ZS-A09-1", new string[] { "hxjA", "A11允许入空箱", });
+ getdic.Add("ZS-A09-2", new string[] { "hxjA", "A11允许取满箱" });
+
+ putdic.Add("ZS-A10-1", new string[] { "hxjA", "A12允许入空箱", });
+ getdic.Add("ZS-A10-2", new string[] { "hxjA", "A12允许取满箱" });
+
+ putdic.Add("ZS-A11-1", new string[] { "hxjA", "A13允许入空箱", });
+ getdic.Add("ZS-A11-2", new string[] { "hxjA", "A13允许取满箱" });
+
+ putdic.Add("ZS-A12-1", new string[] { "hxjA", "A14允许入空箱", });
+ getdic.Add("ZS-A12-2", new string[] { "hxjA", "A14允许取满箱" });
+ #endregion
+
+ var strs = new string[] { };
+
+ if (action == "LOAD")//取货
+ {
+ if (!getdic.ContainsKey(code))
+ {
+ return false;
+ }
+ strs = getdic.Where(p => p.Key == code).First().Value;
+
+ bool flag = await _redisData.HashExists(strs[0], strs[1]);
+ Logger.Information($"【Check】{action} 判断KIVA是否可以取货(信号是否存在) 获取{code}的标签{strs[1]}是否存在 结果为:{flag} ");
+ if (!flag)
+ {
+ throw new Exception($"【Check】{action} 判断KIVA是否可以取货(信号是否存在) 获取{code}的标签{strs[1]}是否存在 结果为:{flag} ");
+ }
+ string data = _redisData.GetHash(strs[0], strs[1]).Result;
+ JObject? res = JsonConvert.DeserializeObject(data);
+ bool result = res != null && res["Value"] != null ? res.Value("Value") : false;
+ Logger.Information($"【Check】{action} 判断KIVA是否可以取货(信号是否允许) 获取{code}的标签{strs[1]}信号值 结果为:{result} ");
+ if (!result)
+ {
+ throw new Exception($"【Check】{action} 判断KIVA是否可以取货(信号是否允许) 获取{code}的标签{strs[1]}信号值 结果为:{result} ");
+ }
+ return true;
+ }
+ else if (action == "UNLOAD")//放货
+ {
+ if (!putdic.ContainsKey(code))
+ return false;
+ strs = putdic.Where(p => p.Key == code).First().Value;
+
+ bool flag = await _redisData.HashExists(strs[0], strs[1]);
+ Logger.Information($"【Check】 判断CTU是否可以放货(信号是否存在) 获取{code}的标签{strs[1]}是否存在 结果为:{flag} ");
+ if (!flag)
+ {
+ throw new Exception($"【Check】 判断CTU是否可以放货(信号是否存在) 获取{code}的标签{strs[1]}是否存在 结果为:{flag} ");
+ }
+ string data = _redisData.GetHash(strs[0], strs[1]).Result;
+ JObject? res = JsonConvert.DeserializeObject(data);
+ bool result = res != null && res["Value"] != null ? res.Value("Value") : false;
+ Logger.Information($"【Check】 判断CTU是否可以放货(信号是否允许) 获取{code}的标签{strs[1]}信号值 结果为:{result}");
+ if (!result)
+ {
+ throw new Exception($"【Check】 判断CTU是否可以放货(信号是否允许) 获取{code}的标签{strs[1]}信号值 结果为:{result} ");
+ }
+ return true;
+ }
+ return false;
+ }
+ public async Task SsxControl(WmsDistaskH disTask, string action)
+ {
+ Logger.Information($"输送线控制SsxControl传入参数: {JsonConvert.SerializeObject(disTask)} {action}");
+
+ Dictionary putdic = new Dictionary();
+ Dictionary getdic = new Dictionary();
+ getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" });
+ getdic.Add("SSX-111-011", new string[] { "东面提升机输送线", "下升降机11出箱完毕", "true" });
+ getdic.Add("SSX-111-012", new string[] { "东面提升机输送线", "下升降机12出箱完毕", "true" });
+ getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "右输送线上层允许出箱3", "true" });
+ getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "左输送线上层允许出箱1", "true" });
+ getdic.Add("SSX-011-008", new string[] { "东面提升机输送线", "入库输送线8出箱完毕", "true" });
+ getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2AGV允许入满箱", "true" });
+ getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3AGV允许入满箱", "true" });
+ getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4AGV允许入满箱", "true" });
+ getdic.Add("ZS-C04-2", new string[] { "hxjC", "A5AGV允许入满箱", "true" });
+ getdic.Add("ZS-C05-2", new string[] { "hxjC", "A6AGV允许入满箱", "true" });
+ getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7AGV允许入满箱", "true" });
+ getdic.Add("ZS-C07-2", new string[] { "hxjC", "A8AGV允许入满箱", "true" });
+ getdic.Add("ZS-C08-2", new string[] { "hxjC", "A9AGV允许入满箱", "true" });
+ getdic.Add("ZS-C09-2", new string[] { "hxjC", "A10AGV允许入满箱", "true" });
+ getdic.Add("ZS-C10-2", new string[] { "hxjC", "A11AGV允许入满箱", "true" });
+ getdic.Add("ZS-C11-2", new string[] { "hxjC", "A12AGV允许入满箱", "true" });
+ getdic.Add("ZS-C12-2", new string[] { "hxjC", "A13AGV允许入满箱", "true" });
+ getdic.Add("ZS-C13-2", new string[] { "hxjC", "A14AGV允许入满箱", "true" });
+ getdic.Add("ZS-C14-2", new string[] { "hxjC", "A1AGV允许入满箱", "true" });
+
+ getdic.Add("ZS-A01-2", new string[] { "hxjA", "A3AGV允许入满箱", "true" });
+ getdic.Add("ZS-A02-2", new string[] { "hxjA", "A4AGV允许入满箱", "true" });
+ getdic.Add("ZS-A03-2", new string[] { "hxjA", "A5AGV允许入满箱", "true" });
+ getdic.Add("ZS-A04-2", new string[] { "hxjA", "A6AGV允许入满箱", "true" });
+ getdic.Add("ZS-A05-2", new string[] { "hxjA", "A7AGV允许入满箱", "true" });
+ getdic.Add("ZS-A06-2", new string[] { "hxjA", "A8AGV允许入满箱", "true" });
+ getdic.Add("ZS-A07-2", new string[] { "hxjA", "A9AGV允许入满箱", "true" });
+ getdic.Add("ZS-A08-2", new string[] { "hxjA", "A10AGV允许入满箱", "true" });
+ getdic.Add("ZS-A09-2", new string[] { "hxjA", "A11AGV允许入满箱", "true" });
+ getdic.Add("ZS-A10-2", new string[] { "hxjA", "A12AGV允许入满箱", "true" });
+ getdic.Add("ZS-A11-2", new string[] { "hxjA", "A13AGV允许入满箱", "true" });
+ getdic.Add("ZS-A12-2", new string[] { "hxjA", "A14AGV允许入满箱", "true" });
+
+
+
+ putdic.Add("SSX-021-007", new string[] { "东面提升机输送线", "出库输送线7入箱完毕", "true" });
+ putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" });
+ putdic.Add("SSX-021-003", new string[] { "YTCS", "AgvFullIn_CS03Done", "true" });
+ putdic.Add("SSX-021-001", new string[] { "YTCS", "CtuEmptyIn_CS01Done", "true" });
+ putdic.Add("ZSSSXCTU02", new string[] { "YTCS", "右输送线下层允许入箱4", "true" });
+ putdic.Add("ZSSSXCTU01", new string[] { "YTCS", "左输送线下层允许入箱2", "true" });
+ putdic.Add("SSX-121-009", new string[] { "东面提升机输送线", "上升降机9入箱完毕", "true" });
+ putdic.Add("SSX-121-010", new string[] { "东面提升机输送线", "上升降机10入箱完毕", "true" });
+ putdic.Add("YCLCKBGW", new string[] { "CP8", "PutDoneEmptyBox", "true" });
+ putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2AGV允许出空箱", "true" });
+ putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3AGV允许出空箱", "true" });
+ putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4AGV允许出空箱", "true" });
+ putdic.Add("ZS-C04-1", new string[] { "hxjC", "A5AGV允许出空箱", "true" });
+ putdic.Add("ZS-C05-1", new string[] { "hxjC", "A6AGV允许出空箱", "true" });
+ putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7AGV允许出空箱", "true" });
+ putdic.Add("ZS-C07-1", new string[] { "hxjC", "A8AGV允许出空箱", "true" });
+ putdic.Add("ZS-C08-1", new string[] { "hxjC", "A9AGV允许出空箱", "true" });
+ putdic.Add("ZS-C09-1", new string[] { "hxjC", "A10AGV允许出空箱", "true" });
+ putdic.Add("ZS-C10-1", new string[] { "hxjC", "A11AGV允许出空箱", "true" });
+ putdic.Add("ZS-C11-1", new string[] { "hxjC", "A12AGV允许出空箱", "true" });
+ putdic.Add("ZS-C12-1", new string[] { "hxjC", "A13AGV允许出空箱", "true" });
+ putdic.Add("ZS-C13-1", new string[] { "hxjC", "A14AGV允许出空箱", "true" });
+ putdic.Add("ZS-C14-1", new string[] { "hxjC", "A1AGV允许出空箱", "true" });
+
+ putdic.Add("ZS-A01-1", new string[] { "hxjA", "A3AGV允许出空箱", "true" });
+ putdic.Add("ZS-A02-1", new string[] { "hxjA", "A4AGV允许出空箱", "true" });
+ putdic.Add("ZS-A03-1", new string[] { "hxjA", "A5AGV允许出空箱", "true" });
+ putdic.Add("ZS-A04-1", new string[] { "hxjA", "A6AGV允许出空箱", "true" });
+ putdic.Add("ZS-A05-1", new string[] { "hxjA", "A7AGV允许出空箱", "true" });
+ putdic.Add("ZS-A06-1", new string[] { "hxjA", "A8AGV允许出空箱", "true" });
+ putdic.Add("ZS-A07-1", new string[] { "hxjA", "A9AGV允许出空箱", "true" });
+ putdic.Add("ZS-A08-1", new string[] { "hxjA", "A10AGV允许出空箱", "true" });
+ putdic.Add("ZS-A09-1", new string[] { "hxjA", "A11AGV允许出空箱", "true" });
+ putdic.Add("ZS-A10-1", new string[] { "hxjA", "A12AGV允许出空箱", "true" });
+ putdic.Add("ZS-A11-1", new string[] { "hxjA", "A13AGV允许出空箱", "true" });
+ putdic.Add("ZS-A12-1", new string[] { "hxjA", "A14AGV允许出空箱", "true" });
+
+ if (action == "LOAD")//取货
+ {
+ if (getdic.Keys.Contains(disTask.startlocation_code))
+ {
+ var strarr = getdic.Where(p => p.Key == disTask.startlocation_code).First().Value;
+ Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase)
+ {
+ ["DevName"] = strarr[0],
+ ["token"] = _eleCtlCfg.token,
+ ["TagName"] = strarr[1],
+ ["Value"] = strarr[2],
+ };
+ Logger.Information($"SsxControlLOAD:{JsonConvert.SerializeObject(dicCommand)}");
+ var str = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
+ Logger.Information($"SsxControlLOAD:{str}");
+ }
+ }
+ else if (action == "UNLOAD")//放货
+ {
+ if (putdic.Keys.Contains(disTask.endlocation_code))
+ {
+ var strarr = putdic.Where(p => p.Key == disTask.endlocation_code).First().Value;
+ Dictionary dicCommand = new(StringComparer.OrdinalIgnoreCase)
+ {
+ ["DevName"] = strarr[0],
+ ["token"] = _eleCtlCfg.token,
+ ["TagName"] = strarr[1],
+ ["Value"] = strarr[2],
+ };
+ Logger.Information($"SsxControlUNLOAD:{JsonConvert.SerializeObject(dicCommand)}");
+ var str = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
+ Logger.Information($"SsxControlUNLOAD:{str}");
+ }
+ }
+
+ }
+
+ ///
+ /// 二楼机械臂
+ ///
+ ///
+ public async Task Floor2MechanicalConfirm(WmsDistaskH disTask, string action)
+ {
+ List rackAreaPointsUp = new List();
+ List rackAreaPointsDown = new List();
+ // 二楼上升降区料架区点位
+ rackAreaPointsUp.Add("AS01");
+ rackAreaPointsUp.Add("AS02");
+ // 二楼下升降区料架区点位
+ rackAreaPointsDown.Add("AX01");
+ rackAreaPointsDown.Add("AX02");
+
+ try {
+ List basLocations = _db.Queryable().Where(r => (r.location_code == disTask.endlocation_code || r.location_code == disTask.startlocation_code)
+ && r.wh_id != "33780009364245").ToList();
+
+ // 暂存仓内任务
+ if (disTask.area_code == "E" && basLocations.Count() == 0)
+ {
+ await _db.Ado.BeginTranAsync();
+ Logger.Information($"【二楼机械臂Floor2MechanicalComplete】收到到货确认信号 传入参数: {disTask.bill_code} {action}");
+
+ if (action == "UNLOAD")
+ {
+ // 去料架区放货
+ if (rackAreaPointsUp.Contains(disTask.endlocation_code) || rackAreaPointsDown.Contains(disTask.endlocation_code))
+ {
+ ISugarQueryable WmsMechanicalArmHs = _db.Queryable