Merge branch '11'
# Conflicts: # WCS.BLL/Services/Service/InstoreService.cs # WCS.BLL/Services/Service/OutstoreService.cs
This commit is contained in:
@ -18,6 +18,18 @@ namespace WCS.BLL.Config
|
||||
/// </summary>
|
||||
public bool IsSameMatCodeOut { get; set; }
|
||||
/// <summary>
|
||||
/// 数据-数据库路径
|
||||
/// </summary>
|
||||
public string DataDbPath { get; set; }
|
||||
/// <summary>
|
||||
/// 日志-数据库路径
|
||||
/// </summary>
|
||||
public string LogDbPath { get; set; }
|
||||
/// <summary>
|
||||
/// 权限-数据库路径
|
||||
/// </summary>
|
||||
public string AuthDbPath { get; set; }
|
||||
/// <summary>
|
||||
/// 是否接入WMS系统
|
||||
/// </summary>
|
||||
public bool IsAccessWMS { get; set; }
|
||||
@ -25,5 +37,25 @@ namespace WCS.BLL.Config
|
||||
/// WMS系统
|
||||
/// </summary>
|
||||
public string? WMSUrl { get; set; }
|
||||
|
||||
#region 盟讯公司后台配置
|
||||
public bool IsMx { get; set; }
|
||||
/// <summary>
|
||||
/// 回传Mes入库/移库
|
||||
/// </summary>
|
||||
public string InputStockInStr { get; set; }
|
||||
/// <summary>
|
||||
/// 回传Mes出库
|
||||
/// </summary>
|
||||
public string BunkerOutStr { get; set; }
|
||||
/// <summary>
|
||||
/// 通过条码查询物料信息接口
|
||||
/// </summary>
|
||||
public string QueryBybar { get; set; }
|
||||
/// <summary>
|
||||
/// 后台配置的组别
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
19
WCS.BLL/DbModels/DingDingSendUser.cs
Normal file
19
WCS.BLL/DbModels/DingDingSendUser.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
[SugarTable("ding_ding_send_user")]
|
||||
public class DingDingSendUser
|
||||
{
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "user_name", Length = 50, IsNullable = true, ColumnDescription = "创建人")]
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 用于记录单据生成到哪个序号了
|
||||
/// </summary>
|
||||
[SugarTable("document_serial_number")]
|
||||
[SugarTable("wcs_document_serial_number")]
|
||||
public class DocumentSerialNumber
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,7 +12,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出入库记录
|
||||
/// </summary>
|
||||
[SugarTable("in_out_record")]
|
||||
[SugarTable("wcs_in_out_record")]
|
||||
public class InOutRecord
|
||||
{
|
||||
/// <summary>
|
||||
@ -115,6 +115,33 @@ namespace WCS.BLL.DbModels
|
||||
[SugarColumn(ColumnName = "operate_user", Length = 100, IsNullable = true, ColumnDescription = "创建人")]
|
||||
public string OperateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Row 行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "R", Length = 10, IsNullable = true, ColumnDescription = "库位 行")]
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
/// Column 列
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "C", Length = 10, IsNullable = true, ColumnDescription = "库位 列")]
|
||||
public string C { get; set; }
|
||||
/// <summary>
|
||||
/// Column 位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Wei", Length = 10, IsNullable = true, ColumnDescription = "库位 位 第几个库位灯")]
|
||||
public string Wei { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 库存明细表
|
||||
/// </summary>
|
||||
[SugarTable("inventory_detail")]
|
||||
[SugarTable("wcs_inventory_detail")]
|
||||
public class InventoryDetail
|
||||
{
|
||||
/// <summary>
|
||||
@ -102,7 +102,38 @@ namespace WCS.BLL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_locked", IsNullable = false, ColumnDescription = "物料是否已被锁定")]
|
||||
public bool IsLocked { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "big_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Row 行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "R", Length = 10, IsNullable = true, ColumnDescription = "库位 行")]
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
/// Column 列
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "C", Length = 10, IsNullable = true, ColumnDescription = "库位 列")]
|
||||
public string C { get; set; }
|
||||
/// <summary>
|
||||
/// Column 位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Wei", Length = 10, IsNullable = true, ColumnDescription = "库位 位 第几个库位灯")]
|
||||
public string Wei { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WarehouseCode 仓库代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "WarehouseCode", Length = 10, IsNullable = true, ColumnDescription = "仓库代码")]
|
||||
public string WarehouseCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
///<summary>
|
||||
///物料基础信息
|
||||
///</summary>
|
||||
[SugarTable("mat_base_info")]
|
||||
[SugarTable("wcs_mat_base_info")]
|
||||
public partial class MatBaseInfo
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
///<summary>
|
||||
///物料信息表
|
||||
///</summary>
|
||||
[SugarTable("mat_info")]
|
||||
[SugarTable("wcs_mat_info")]
|
||||
public class MatInfo
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.DAL.DbModels
|
||||
///<summary>
|
||||
///模组信息表
|
||||
///</summary>
|
||||
[SugarTable("module_info")]
|
||||
[SugarTable("wcs_module_info")]
|
||||
public class ModuleInfo
|
||||
{
|
||||
|
||||
@ -27,6 +27,12 @@ namespace WCS.DAL.DbModels
|
||||
[SugarColumn(ColumnName = "module_code", Length = 50, IsNullable = false, ColumnDescription = "模组编码")]
|
||||
public string ModuleCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false,DefaultValue ="0", ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架Id
|
||||
/// </summary>
|
||||
@ -56,7 +62,11 @@ namespace WCS.DAL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "client_ip", Length = 50, IsNullable = false, ColumnDescription = "货架对应Can模块的Ip")]
|
||||
public string CleintIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// R 行
|
||||
/// </summary>
|
||||
|
@ -6,7 +6,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库单据
|
||||
/// </summary>
|
||||
[SugarTable("out_order")]
|
||||
[SugarTable("wcs_out_order")]
|
||||
public class OutOrder
|
||||
{
|
||||
/// <summary>
|
||||
@ -49,15 +49,25 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 单据同步类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "sync_type",IsNullable = false, ColumnDescription = "单据同步类型:ByMatCode,ByMatSn")]
|
||||
[SugarColumn(ColumnName = "sync_type", IsNullable = false, ColumnDescription = "单据同步类型:ByMatCode,ByMatSn")]
|
||||
public SyncTypeEnum SyncType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_name", Length = 50, IsNullable = false, ColumnDescription = "货架类型名称")]
|
||||
public string ShelfTypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, DefaultValue = "0", ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 单据货架类型 : 单灯单据还是货架单据
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type", IsNullable = false, ColumnDescription = "货架类型 是信息化货架还是智能货架")]
|
||||
public ShelfTypeEnum ShelfType { get; set; }
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
|
@ -6,7 +6,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库单据明细表
|
||||
/// </summary>
|
||||
[SugarTable("out_order_detail")]
|
||||
[SugarTable("wcs_out_order_detail")]
|
||||
public class OutOrderDetail
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库物料明细(库存数据加锁后缓存对应的数据并记录状态)
|
||||
/// </summary>
|
||||
[SugarTable("out_order_mat_detail")]
|
||||
[SugarTable("wcs_out_order_mat_detail")]
|
||||
public class OutOrderMatDetail
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -8,7 +8,7 @@ using WCS.BLL.HardWare;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
[SugarTable("shelf_info")]
|
||||
[SugarTable("wcs_shelf_info")]
|
||||
public class ShelfInfo
|
||||
{
|
||||
|
||||
@ -83,7 +83,7 @@ namespace WCS.DAL.DbModels
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BindShelfCode { get; set; } = string.Empty;
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 货架类型
|
||||
/// </summary>
|
||||
[SugarTable("shelf_type")]
|
||||
[SugarTable("wcs_shelf_type")]
|
||||
public class ShelfTypeInfo
|
||||
{
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 盘点单据
|
||||
/// </summary>
|
||||
[SugarTable("stock_taking_order")]
|
||||
[SugarTable("wcs_stock_taking_order")]
|
||||
public class StockTakingOrder
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 盘点单据物料明细
|
||||
/// </summary>
|
||||
[SugarTable("stock_taking_order_matdetail")]
|
||||
[SugarTable("wcs_stock_taking_order_matdetail")]
|
||||
public class StockTakingOrderMatDetail
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
[SugarTable("store_info")]
|
||||
[SugarTable("wcs_store_info")]
|
||||
public partial class StoreInfo
|
||||
{
|
||||
/// <summary>
|
||||
@ -21,12 +21,16 @@ namespace WCS.DAL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "store_code", Length = 50, IsNullable = false, ColumnDescription = "库位编码")]
|
||||
public string StoreCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, DefaultValue = "0", ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; }
|
||||
/// <summary>
|
||||
/// 模组Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "module_id", IsNullable = false, ColumnDescription = "模组Id")]
|
||||
public int ModuleId { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模组编号
|
||||
@ -88,6 +92,33 @@ namespace WCS.DAL.DbModels
|
||||
[SugarColumn(ColumnName = "offset_voltage", IsNullable = true, ColumnDescription = "电压偏移值")]
|
||||
public decimal OffsetVoltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Row 行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "R", Length = 10, IsNullable = true, ColumnDescription = "库位 行")]
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
/// Column 列
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "C", Length = 10, IsNullable = true, ColumnDescription = "库位 列")]
|
||||
public string C { get; set; }
|
||||
/// <summary>
|
||||
/// Column 位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Wei", Length = 10, IsNullable = true, ColumnDescription = "库位 位 第几个库位灯")]
|
||||
public string Wei { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 系统接口日志记录
|
||||
/// </summary>
|
||||
[SugarTable("system_api_log_record")]
|
||||
[SugarTable("wcs_system_api_log_record")]
|
||||
public class SystemApiLogRecord
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -39,6 +39,7 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
public int LightId { get; set; }
|
||||
public List<int> ModuleIds { get; set; }
|
||||
public List<SmartShelfModule> Modules { get; set; }
|
||||
public string ClientIp { get; set; }
|
||||
/// <summary>
|
||||
/// 货架当前模式
|
||||
@ -57,6 +58,8 @@ namespace WCS.BLL.HardWare
|
||||
/// 货架组别
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
|
||||
public string WebSocketIpAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 模组
|
||||
/// </summary>
|
||||
|
@ -25,6 +25,8 @@ namespace WCS.BLL.HardWare
|
||||
public string ClientIp { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public List<string> ExceptionMessages { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public bool IsWarning { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string WebSocketIpAddress { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public List<SmartShelfModule> Modules { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
|
||||
{
|
||||
|
@ -104,6 +104,9 @@ namespace WCS.BLL.HardWare
|
||||
public List<int> ModuleIds { get; set; }
|
||||
public string ClientIp { get; set; }
|
||||
|
||||
//websocket通知的前端的IP地址
|
||||
public string WebSocketIpAddress { get; set; } = "127.0.0.2";
|
||||
|
||||
#region 协议处理
|
||||
public void GoInInstore(string? IPAddress)
|
||||
{
|
||||
@ -186,7 +189,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
@ -267,13 +270,13 @@ namespace WCS.BLL.HardWare
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = true,
|
||||
WarningType = WarningTypeEnum.进入入库未响应,
|
||||
WarningType = WarningTypeEnum.退出入库未响应,
|
||||
StoreId = 0,
|
||||
StoreCode = "",
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
}
|
||||
@ -354,7 +357,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
}
|
||||
@ -411,7 +414,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
}
|
||||
@ -503,7 +506,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
}
|
||||
@ -536,7 +539,7 @@ namespace WCS.BLL.HardWare
|
||||
var messageMode = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
WarningType = WarningTypeEnum.通知刷新盘点
|
||||
};
|
||||
WarningManager.SendWarning(messageMode);
|
||||
@ -590,7 +593,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
}
|
||||
@ -797,7 +800,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
#endregion
|
||||
@ -831,7 +834,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
#endregion
|
||||
@ -916,7 +919,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!",
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
@ -946,6 +949,12 @@ namespace WCS.BLL.HardWare
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
|
||||
R = storeInfo.R,
|
||||
C = storeInfo.C,
|
||||
Wei = storeInfo.Wei,
|
||||
BigShelfCode = storeInfo.BigShelfCode,
|
||||
GroupName = storeInfo.GroupName,
|
||||
|
||||
MatSN = this.InStoreData.materialBar,
|
||||
MatCode = this.InStoreData.materialCode,
|
||||
MatName = this.InStoreData.materialName,
|
||||
@ -966,6 +975,12 @@ namespace WCS.BLL.HardWare
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
R = storeInfo.R,
|
||||
C = storeInfo.C,
|
||||
Wei = storeInfo.Wei,
|
||||
BigShelfCode = storeInfo.BigShelfCode,
|
||||
GroupName = storeInfo.GroupName,
|
||||
|
||||
MatSN = this.InStoreData.materialBar,
|
||||
MatCode = this.InStoreData.materialCode,
|
||||
MatName = this.InStoreData.materialName,
|
||||
@ -1051,7 +1066,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
@ -1079,7 +1094,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
@ -1096,7 +1111,6 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.入库中异常取出,
|
||||
@ -1107,7 +1121,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
@ -1213,7 +1227,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
#endregion
|
||||
@ -1247,7 +1261,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
#endregion
|
||||
@ -1342,6 +1356,12 @@ namespace WCS.BLL.HardWare
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
R = storeInfo.R,
|
||||
C = storeInfo.C,
|
||||
Wei = storeInfo.Wei,
|
||||
BigShelfCode = storeInfo.BigShelfCode,
|
||||
GroupName = storeInfo.GroupName,
|
||||
|
||||
MatSN = inventoryDetail.MatSN,
|
||||
MatCode = inventoryDetail.MatCode,
|
||||
MatName = inventoryDetail.MatName,
|
||||
@ -1350,6 +1370,7 @@ namespace WCS.BLL.HardWare
|
||||
MatSpec = inventoryDetail.MatSpec,
|
||||
MatCustomer = inventoryDetail.MatCustomer,
|
||||
MatSupplier = inventoryDetail.MatSupplier,
|
||||
OrderNumber = orderMatDetails.OrderNumber,
|
||||
|
||||
Direction = DirectionEnum.出库,
|
||||
};
|
||||
@ -1402,7 +1423,7 @@ namespace WCS.BLL.HardWare
|
||||
var messageMode = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
WarningType = WarningTypeEnum.通知刷新出库
|
||||
};
|
||||
WarningManager.SendWarning(messageMode);
|
||||
@ -1625,7 +1646,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
ClientIp = WebSocketIpAddress,
|
||||
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
@ -1640,7 +1661,6 @@ namespace WCS.BLL.HardWare
|
||||
case 0x01:
|
||||
{
|
||||
var exceptionMessage = storeInfo.StoreCode + "出库过程中存在物料上架!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.出库中未扫描上架,
|
||||
@ -1651,7 +1671,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress,
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
@ -1666,7 +1686,6 @@ namespace WCS.BLL.HardWare
|
||||
case 0x02:
|
||||
{
|
||||
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.出库中丢失,
|
||||
@ -1677,7 +1696,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
ClientIp = WebSocketIpAddress
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.DAL.DbModels;
|
||||
@ -14,6 +18,51 @@ namespace WCS.BLL.Manager
|
||||
{
|
||||
public static void InitDb()
|
||||
{
|
||||
Logs.Write("【初始化数据库】开始", LogsType.StartBoot);
|
||||
//初始化数据库对象
|
||||
if (LocalFile.Config.IsMx)
|
||||
{
|
||||
DbHelp.db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = LocalFile.Config.DataDbPath,
|
||||
DbType = DbType.SqlServer,//[Sqlite]安装[System.Data.SQLite];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
};
|
||||
});
|
||||
|
||||
DbHelp.dbLog = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = LocalFile.Config.LogDbPath,
|
||||
DbType = DbType.SqlServer,//[Sqlite]安装[System.Data.SQLite];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
};
|
||||
});
|
||||
|
||||
AuthDbHelp.db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = LocalFile.Config.AuthDbPath,
|
||||
DbType = DbType.SqlServer,//[Sqlite]安装[System.Data.SQLite];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
DbHelp.db.DbMaintenance.CreateDatabase();
|
||||
DbHelp.dbLog.DbMaintenance.CreateDatabase();
|
||||
|
||||
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
||||
@ -43,6 +92,25 @@ namespace WCS.BLL.Manager
|
||||
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
|
||||
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
|
||||
}
|
||||
//初始化货架类型
|
||||
if (!DbHelp.db.Queryable<ShelfTypeInfo>().Any())
|
||||
{
|
||||
var smartShelf = new ShelfTypeInfo()
|
||||
{
|
||||
ShelfTypeName = "智能货架"
|
||||
};
|
||||
var singleLight = new ShelfTypeInfo()
|
||||
{
|
||||
ShelfTypeName = "信息化货架"
|
||||
};
|
||||
DbHelp.db.Insertable(smartShelf).ExecuteCommand();
|
||||
DbHelp.db.Insertable(singleLight).ExecuteCommand();
|
||||
}
|
||||
|
||||
Logs.Write("【初始化数据库】结束", LogsType.StartBoot);
|
||||
|
||||
//初始化权限数据库
|
||||
AuthDbHelp.InitDb();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
255
WCS.BLL/Manager/MXBackgroundThread.cs
Normal file
255
WCS.BLL/Manager/MXBackgroundThread.cs
Normal file
@ -0,0 +1,255 @@
|
||||
using SqlSugar;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MXBackgroundThread;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
//盟讯公司后台方法
|
||||
public static class MXBackgroundThread
|
||||
{
|
||||
public static void InitBackgroundThread()
|
||||
{
|
||||
#region 定时任务:回传Mes入库出库
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//每5秒同步一次
|
||||
Thread.Sleep(5000);
|
||||
try
|
||||
{
|
||||
var records = DbHelp.db.Queryable<InOutRecord>()
|
||||
.Where(t => t.OperateTime > DateTime.Now.AddDays(-3)) //只查询回传三天内数据
|
||||
.Where(t => t.IsUpload == false)
|
||||
.Includes(t => t.StoreInfo)
|
||||
.OrderBy(t => t.Id)
|
||||
.ToList();
|
||||
//入库记录上传
|
||||
var inventoryDetails = records.Where(t => t.Direction == DirectionEnum.入库)
|
||||
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.GroupName == LocalFile.Config.GroupName)
|
||||
.ToList();
|
||||
if (inventoryDetails != null && inventoryDetails.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < inventoryDetails.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
//请求WMS上传入库记录
|
||||
var data = new InputStockInRequest
|
||||
{
|
||||
materialBar = inventoryDetails[i].MatSN,
|
||||
shelfCode = inventoryDetails[i].BigShelfCode,
|
||||
shelfX = "R" + inventoryDetails[i].R,
|
||||
shelfY = "C" + inventoryDetails[i].C,
|
||||
shelfZ = inventoryDetails[i].Wei,
|
||||
inUser = inventoryDetails[i].OperateUser,
|
||||
inTime = inventoryDetails[i].OperateTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
};
|
||||
Guid guid = Guid.NewGuid();
|
||||
var result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.InputStockInStr, data, "POST", true);
|
||||
if (result != null && (result.Code == 200))
|
||||
{
|
||||
//上传成功 更改上传状态
|
||||
inventoryDetails[i].IsUpload = true;
|
||||
DbHelp.db.Updateable(inventoryDetails[i]).ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
|
||||
//出库记录上传
|
||||
var outRecord = records.Where(t => t.Direction == DirectionEnum.出库)
|
||||
.Where(t => !string.IsNullOrEmpty(t.OrderNumber))
|
||||
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.GroupName == LocalFile.Config.GroupName)
|
||||
.ToList();
|
||||
if (outRecord != null && outRecord.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < outRecord.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var retString = string.Empty;
|
||||
|
||||
var data = new BunkerOutRequest()
|
||||
{
|
||||
materialBar = outRecord[i].MatSN,
|
||||
outType = 0,
|
||||
pickBillNumber = outRecord[i].OrderNumber,
|
||||
qty = outRecord[i].MatQty,
|
||||
};
|
||||
var result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.BunkerOutStr, data, "POST", true);
|
||||
//请求成功
|
||||
if (result != null && result.Code == 200)
|
||||
{
|
||||
//上传成功 更改上传状态
|
||||
outRecord[i].IsUpload = true;
|
||||
DbHelp.db.Updateable(outRecord[i]).ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
Thread.Sleep(200);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write("【定时任务】上传异常:" + ex.Message);
|
||||
}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
|
||||
#region 定时任务:超时退出 出库、入库、盘点模式
|
||||
|
||||
#endregion
|
||||
|
||||
#region 定时任务:海康未扫物料码的物料更新数据
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//间隔20秒同步一次
|
||||
Thread.Sleep(20000);
|
||||
try
|
||||
{
|
||||
var inventoryDetails = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.MatName == "暂时未知")
|
||||
.Where(t => t.InstoreTime > DateTime.Now.AddDays(-3))
|
||||
.ToList();
|
||||
if (inventoryDetails != null && inventoryDetails.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < inventoryDetails.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
//请求WMS获取物料的信息
|
||||
var request = new QueryBybarRequest()
|
||||
{
|
||||
materialBar = inventoryDetails[i].MatSN
|
||||
};
|
||||
var result = ApiHelp.GetDataFromHttp<QueryBybarResponse>(LocalFile.Config.QueryBybar, request, "POST", true);
|
||||
if (result != null && (result.code == 200) && result.data != null && result.data.Count() > 0)
|
||||
{
|
||||
//查询成功 更改数值
|
||||
var instoreDto = result.data.FirstOrDefault();
|
||||
inventoryDetails[i].MatCode = instoreDto.materialCode;
|
||||
inventoryDetails[i].MatName = instoreDto.materialName;
|
||||
inventoryDetails[i].MatBatch = instoreDto.batchNo;
|
||||
inventoryDetails[i].MatSpec = instoreDto.materialSpec;
|
||||
inventoryDetails[i].MatQty = (int)instoreDto.materialQty;
|
||||
DbHelp.db.Updateable(inventoryDetails[i]).ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write("【定时任务】更新海康物料信息异常:" + ex.Message);
|
||||
}
|
||||
|
||||
Thread.Sleep(3000);
|
||||
try
|
||||
{
|
||||
var inventoryDetails = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.WarehouseCode == null)
|
||||
.Where(t => t.InstoreTime > DateTime.Now.AddDays(-30))
|
||||
.ToList();
|
||||
if (inventoryDetails != null && inventoryDetails.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < inventoryDetails.Count; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var url = $"http://192.168.2.23:9213/integrate/hkwsInventoryDetail/selectMaterialBar?materialBar={inventoryDetails[i].MatSN}";
|
||||
var result = ApiHelp.GetDataFromHttp<SelectMaterialBarResponse>(url, null, "POST", false);
|
||||
if (result != null && result.code == 200 && result.data != null && !string.IsNullOrEmpty(result.data.warehouseCode))
|
||||
{
|
||||
//查询成功 更改数值
|
||||
inventoryDetails[i].WarehouseCode = result.data.warehouseCode;
|
||||
DbHelp.db.Updateable(inventoryDetails[i]).ExecuteCommand();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write("【定时任务】更新仓库代码异常:" + ex.Message);
|
||||
}
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
|
||||
#region 定时任务:紧机复原和监测警示灯关灯机制
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送钉钉消息
|
||||
/// </summary>
|
||||
/// <param name="msg">发送的消息内容</param>
|
||||
/// <param name="errMsg">错误信息</param>
|
||||
/// <param name="idList">工号列表</param>
|
||||
/// <returns></returns>
|
||||
public static bool SendDingDingMsg(string msg, List<string> idList, ref string errMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 获取所有工程研发人员
|
||||
var list = AuthDbHelp.db.Queryable<UserBase>().Where(t => t.IsGCYF)
|
||||
.Select(t => t.LoginName)
|
||||
.ToList();
|
||||
#endregion
|
||||
string ids = string.Join(",", list);
|
||||
string url = "http://192.168.2.23:9213/integrate/cmccMonitor/rateAlertByCMCC?" + $"context={msg}&messageType=软件管理平台&username={ids}";
|
||||
#region 调用接口请求发送钉钉消息
|
||||
var Result = ApiHelp.GetDataFromHttp<MXMesResponseCommon>(url, null, "GET");
|
||||
if (Result != null && Result.code != 200)
|
||||
{
|
||||
errMsg = Result.msg;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endregion
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errMsg = "接口调用失败";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.DAL.Db;
|
||||
@ -20,11 +21,18 @@ namespace WCS.BLL.Manager
|
||||
|
||||
public static void InitShelves()
|
||||
{
|
||||
var shelvesInDb = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||
Logs.Write("【InitShelves】开始", LogsType.StartBoot);
|
||||
|
||||
var shelvesInDbQueryable = DbHelp.db.Queryable<ShelfInfo>();
|
||||
if (LocalFile.Config.IsMx)
|
||||
shelvesInDbQueryable = shelvesInDbQueryable.Where(t => t.GroupName == LocalFile.Config.GroupName);
|
||||
var shelvesInDb = shelvesInDbQueryable.ToList();
|
||||
foreach (var shelfInDb in shelvesInDb)
|
||||
{
|
||||
Shelves.Add(InitShelf(shelfInDb));
|
||||
}
|
||||
|
||||
Logs.Write("【InitShelves】结束", LogsType.StartBoot);
|
||||
}
|
||||
|
||||
public static IShelfBase InitShelf(ShelfInfo shelfInDb)
|
||||
|
@ -22,107 +22,94 @@ namespace WCS.BLL.Manager
|
||||
public static List<TCPClient> TCPClients = new List<TCPClient>();
|
||||
public static void InitTcpClient()
|
||||
{
|
||||
Logs.Write("【InitTcpClient】开始", LogsType.StartBoot);
|
||||
|
||||
var ips = DbHelp.db.Queryable<ShelfInfo>()
|
||||
//.Where(t => t.ShelfCode.Contains("C"))
|
||||
.Select(t => t.ClientIp)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
foreach (var ip in ips)
|
||||
{
|
||||
var tcpCleint = new TCPClient(ip, "");
|
||||
//配置断线重连
|
||||
tcpCleint.tcpClient.Received += (client, e) =>
|
||||
Task.Run(() =>
|
||||
{
|
||||
var clientIpHost = client.IP + ":" + client.Port;
|
||||
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
||||
if (TcpCleint == null)
|
||||
var tcpCleint = new TCPClient(ip, "");
|
||||
//配置断线重连
|
||||
tcpCleint.tcpClient.Received += (client, e) =>
|
||||
{
|
||||
//TO DO
|
||||
return EasyTask.CompletedTask;
|
||||
}
|
||||
|
||||
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
|
||||
e.ByteBlock.Clear();
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - TcpCleint.PreFixLength; index++)
|
||||
{
|
||||
//协议拆包 通过前缀校验是否为完整数据包
|
||||
var prefixInData = data.Skip(index).Take(TcpCleint.PreFixLength);
|
||||
var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix);
|
||||
if (isEqual)
|
||||
var clientIpHost = client.IP + ":" + client.Port;
|
||||
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
||||
if (TcpCleint == null)
|
||||
{
|
||||
Logs.Write("协议处理1!");
|
||||
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
|
||||
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
|
||||
{
|
||||
continue;
|
||||
}
|
||||
index += (TcpCleint.PreFixLength + TcpCleint.DataLength - 1);//每次循环index会+1 所以这里-1
|
||||
//获取板子ID
|
||||
var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1];
|
||||
var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]);
|
||||
|
||||
Logs.Write("协议处理2!");
|
||||
//报警灯
|
||||
if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20)
|
||||
{
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ClientIp == clientIpHost)
|
||||
.Where(t => t.LightId == boardId)
|
||||
.FirstOrDefault();
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
||||
}
|
||||
//!= 0x20 货架类型协议返回
|
||||
else
|
||||
{
|
||||
Logs.Write("协议处理3!");
|
||||
var shelf = ShelfManager.Shelves
|
||||
.Where(t => t.ClientIp == clientIpHost)
|
||||
.Where(t => t.ModuleIds.Contains(boardId))
|
||||
.FirstOrDefault();
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
||||
|
||||
}
|
||||
|
||||
//协议处理 判断功能位
|
||||
//switch (dataTemp[TcpCleint.PreFixLength + 2])
|
||||
//{
|
||||
// case 0x20://进入入库模式信号
|
||||
// //GoInInstoreProcess(dataTemp, boardId, lightNumber);
|
||||
// break;
|
||||
// case 0x03://正常入库信号
|
||||
// //InStoreReturnProcess(dataTemp);
|
||||
// break;
|
||||
// default:
|
||||
// ;
|
||||
// break;
|
||||
//}
|
||||
return EasyTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
Logs.Write("协议处理完毕!");
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
//配置首次连接后复位操作
|
||||
tcpCleint.tcpClient.Connected += (client, e) =>
|
||||
{
|
||||
var clientIpHost = client.IP + ":" + client.Port;
|
||||
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
||||
if (TcpCleint == null)
|
||||
{
|
||||
return EasyTask.CompletedTask;
|
||||
}
|
||||
//首次连接
|
||||
if (TcpCleint.IsFirstConnected == false)
|
||||
{
|
||||
InitStatus(TcpCleint);
|
||||
TcpCleint.IsFirstConnected = true;
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
TCPClients.Add(tcpCleint);
|
||||
tcpCleint.Connect();
|
||||
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
|
||||
Logs.Write($"【接收】{BitConverter.ToString(data)}",LogsType.Instructions);
|
||||
e.ByteBlock.Clear();
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - TcpCleint.PreFixLength; index++)
|
||||
{
|
||||
//协议拆包 通过前缀校验是否为完整数据包
|
||||
var prefixInData = data.Skip(index).Take(TcpCleint.PreFixLength);
|
||||
var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix);
|
||||
if (isEqual)
|
||||
{
|
||||
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
|
||||
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Logs.Write($"【处理单条指令 开始】{BitConverter.ToString(dataTemp)}", LogsType.Instructions);
|
||||
index += (TcpCleint.PreFixLength + TcpCleint.DataLength - 1);//每次循环index会+1 所以这里-1
|
||||
//获取板子ID
|
||||
var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1];
|
||||
var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]);
|
||||
//报警灯
|
||||
if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20)
|
||||
{
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ClientIp == clientIpHost)
|
||||
.Where(t => t.LightId == boardId)
|
||||
.FirstOrDefault();
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
||||
}
|
||||
//!= 0x20 货架类型协议返回
|
||||
else
|
||||
{
|
||||
var shelf = ShelfManager.Shelves
|
||||
.Where(t => t.ClientIp == clientIpHost)
|
||||
.Where(t => t.ModuleIds.Contains(boardId))
|
||||
.FirstOrDefault();
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
|
||||
}
|
||||
Logs.Write($"【处理单条指令 结束】{BitConverter.ToString(dataTemp)}", LogsType.Instructions);
|
||||
}
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
//配置首次连接后复位操作
|
||||
tcpCleint.tcpClient.Connected += (client, e) =>
|
||||
{
|
||||
var clientIpHost = client.IP + ":" + client.Port;
|
||||
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
|
||||
if (TcpCleint == null)
|
||||
{
|
||||
return EasyTask.CompletedTask;
|
||||
}
|
||||
//首次连接
|
||||
if (TcpCleint.IsFirstConnected == false)
|
||||
{
|
||||
Logs.Write($"【InitTcpClient】{clientIpHost}完成首次连接", LogsType.StartBoot);
|
||||
InitStatus(TcpCleint);
|
||||
TcpCleint.IsFirstConnected = true;
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
TCPClients.Add(tcpCleint);
|
||||
tcpCleint.Connect();
|
||||
});
|
||||
}
|
||||
|
||||
//启动线程监听所有TCP是否已经完成首次连接
|
||||
@ -146,6 +133,7 @@ namespace WCS.BLL.Manager
|
||||
}
|
||||
}
|
||||
});
|
||||
Logs.Write("【InitTcpClient】完成后台继续连接", LogsType.StartBoot);
|
||||
}
|
||||
|
||||
//后台启动时给所有板子、警示灯发送复位操作 保持状态一致
|
||||
|
@ -88,7 +88,6 @@ namespace WCS.BLL.Manager
|
||||
//货架是否还存在报警信息
|
||||
shelfIsWarning = Warnings.Where(t => t.ShelfId == warning.ShelfId)
|
||||
.Any();
|
||||
|
||||
//对应货架如果不存在报警信息了 指示灯回到对应的状态
|
||||
if (!shelfIsWarning)
|
||||
{
|
||||
@ -139,7 +138,6 @@ namespace WCS.BLL.Manager
|
||||
public static void SolveLoss(WebSocketMessageModel warning)
|
||||
{
|
||||
#region 【后台】丢失的数据处理
|
||||
|
||||
try
|
||||
{
|
||||
//获取库位
|
||||
@ -164,6 +162,12 @@ namespace WCS.BLL.Manager
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
R = storeInfo.R,
|
||||
C = storeInfo.C,
|
||||
Wei = storeInfo.Wei,
|
||||
BigShelfCode = storeInfo.BigShelfCode,
|
||||
GroupName = storeInfo.GroupName,
|
||||
|
||||
MatSN = inventoryDetail.MatSN,
|
||||
MatCode = inventoryDetail.MatCode,
|
||||
MatName = inventoryDetail.MatName,
|
||||
@ -174,9 +178,29 @@ namespace WCS.BLL.Manager
|
||||
MatSupplier = inventoryDetail.MatSupplier,
|
||||
|
||||
Direction = DirectionEnum.丢失,
|
||||
OperateUser = warning.SolvedUser,
|
||||
};
|
||||
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
DbHelp.db.Deleteable(inventoryDetail).ExecuteCommand();
|
||||
|
||||
#region 如果是出库 删除正在出库缓存的数据
|
||||
if (warning.WarningType == WarningTypeEnum.出库自检丢失)
|
||||
{
|
||||
//清掉需要出库的缓存
|
||||
var shelf = ShelfManager.Shelves
|
||||
.Where(t => t.ShelfId == warning.ShelfId)
|
||||
.FirstOrDefault();
|
||||
if (shelf != null)
|
||||
{
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
if (smartShelf != null)
|
||||
{
|
||||
smartShelf.CurrentOutStoreMatSNs.RemoveAll(t => t == inventoryDetail.MatSN);
|
||||
//TODO 如何保证丢失的继续进行
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
}
|
||||
|
@ -16,6 +16,8 @@ namespace WCS.BLL.Manager
|
||||
public static object flag = new object();
|
||||
public static void InitWebSocket()
|
||||
{
|
||||
Console.WriteLine("【启动WebSocket】开始");
|
||||
Logs.Write("【启动WebSocket】开始", LogsType.StartBoot);
|
||||
service = new HttpService();
|
||||
service.Setup(new TouchSocketConfig()//加载配置
|
||||
.SetListenIPHosts(7789)
|
||||
@ -30,11 +32,19 @@ namespace WCS.BLL.Manager
|
||||
.UseAutoPong();//当收到ping报文时自动回应pong
|
||||
a.Add<WebSocketServicePlugin>();//自定义插件。
|
||||
}));
|
||||
|
||||
//客户端成功连接
|
||||
service.Connected = (client, e) =>
|
||||
{
|
||||
Logs.Write("[WebSocket]" + client.GetIPPort() + "成功连接!", LogsType.StartBoot);
|
||||
Console.WriteLine("[WebSocket]" + client.GetIPPort() +"成功连接!");
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
service.Start();
|
||||
service.Logger.Info("服务器已启动");
|
||||
Console.WriteLine("【启动WebSocket】结束");
|
||||
Logs.Write("【启动WebSocket】结束", LogsType.StartBoot);
|
||||
}
|
||||
//尝试发送报警信息给前端
|
||||
|
||||
//发送报警信息给前端
|
||||
public static void TrySendMessage(string IpAddress, string Message)
|
||||
{
|
||||
try
|
||||
|
@ -15,5 +15,7 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<PageQueryResponse<InventoryDetail>> exportMatInventoryDetail(GetMatInventoryDetailRequest request);
|
||||
|
||||
public Task<ResponseCommon<List<MatInventorySummaryModel>>> getMatInventorySummary(GetMatInventorySummaryRequest request);
|
||||
|
||||
public Task<PageQueryResponse<InventoryDetail>> compareMatInventoryDetail(CompareMatInventoryDetailRequest request);
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IOutstoreService
|
||||
{
|
||||
public Task<ResponseCommon<List<MatInventorySummaryModel>>> importMat(List<OutImportMatModel> list);
|
||||
public Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request);
|
||||
|
||||
public Task<ResponseBase> SysOutOrderByMatSn(SysOutOrderByMatSnRequest request);
|
||||
@ -22,7 +24,7 @@ namespace WCS.BLL.Services.IService
|
||||
|
||||
public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
|
||||
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request);
|
||||
|
||||
|
@ -32,19 +32,33 @@ namespace WCS.BLL.Services.IService
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询货架列表
|
||||
/// 查询模组列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<PageQueryResponse<ModuleInfo>> GetModules(GetModulesRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 禁用或启用模组
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<ResponseCommon> disableOrEnableModule(DisableOrEnableModuleRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询货架列表
|
||||
/// 查询库位列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<PageQueryResponse<StoreInfo>> GetStores(GetStoresRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 禁用或启用库位
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public Task<ResponseCommon> disableOrEnableStore(DisableOrEnableStoreRequest request);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MXBackgroundThread;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
@ -130,7 +131,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
|
||||
IShelfBase shelf = null;
|
||||
if (!request.IsSingleLightIn)
|
||||
if (!request.SingleLightIn)
|
||||
{
|
||||
//获取货架
|
||||
shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
@ -164,13 +165,13 @@ namespace WCS.BLL.Services.Service
|
||||
{
|
||||
materialBar = request.MatSn
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<queryByBarResponse>>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST");
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<queryByBarResponse>>>("http://192.168.2.23:9213/integrate/instock/queryBybar", body, "POST", true);
|
||||
|
||||
//查询到物料信息
|
||||
if (Result != null && Result.Code == 200 && Result.Data != null && Result.Data.Count > 0)
|
||||
{
|
||||
var data = Result.Data.First();
|
||||
if (!request.IsSingleLightIn && shelf != null)
|
||||
if (!request.SingleLightIn && shelf != null)
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = data.materialBar,
|
||||
@ -180,7 +181,7 @@ namespace WCS.BLL.Services.Service
|
||||
materialSpec = data.materialSpec,
|
||||
batchNo = data.batchNo,
|
||||
supplier = "",
|
||||
customer = data.materialBar,
|
||||
customer = "",
|
||||
|
||||
InstoreUser = request.UserName
|
||||
};
|
||||
@ -207,6 +208,47 @@ namespace WCS.BLL.Services.Service
|
||||
else if (Result != null && Result.Code == 200 && Result.Data == null)
|
||||
{
|
||||
//Mes系统中未获取到物料信息
|
||||
|
||||
//简单校验看是否满足海康物料
|
||||
//海康物料 只扫了外箱码 未扫条码
|
||||
if ((request.MatSn.Length == 54 || request.MatSn.Length == 56) && !request.MatSn.Contains("\\") && !request.MatSn.Contains("/"))
|
||||
{
|
||||
|
||||
if (!request.SingleLightIn && shelf != null)
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = request.MatSn,
|
||||
materialCode = "暂时未知",
|
||||
materialName = "暂时未知",
|
||||
materialQty = 0,
|
||||
materialSpec = "暂时未知",
|
||||
batchNo = "暂时未知",
|
||||
supplier = "",
|
||||
customer = "",
|
||||
|
||||
InstoreUser = request.UserName
|
||||
};
|
||||
|
||||
var matInfo = new MatInfo()
|
||||
{
|
||||
MatSn = request.MatSn,
|
||||
MatCode = "暂时未知",
|
||||
MatName = "暂时未知",
|
||||
MatBatch = "暂时未知",
|
||||
MatQty = 0,
|
||||
MatSpec = "暂时未知",
|
||||
MatSupplier = "",
|
||||
MatCustomer = "",
|
||||
};
|
||||
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Data = matInfo,
|
||||
Message = "success"
|
||||
};
|
||||
}
|
||||
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
@ -239,7 +281,7 @@ namespace WCS.BLL.Services.Service
|
||||
if (matInfo != null)
|
||||
{
|
||||
//TODO 改成wcs的实体
|
||||
if (!request.IsSingleLightIn && shelf != null)
|
||||
if (!request.SingleLightIn && shelf != null)
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = matInfo.MatSn,
|
||||
@ -468,7 +510,7 @@ namespace WCS.BLL.Services.Service
|
||||
//data1[5] = 0x03;
|
||||
//data1[6] = 0x02;
|
||||
//data1[7] = 0x02;
|
||||
//byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, true);
|
||||
//byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, false);
|
||||
byte[] senddata1 = Tool.Helper.InstoreWarnLight(warnLightID);
|
||||
tCPClient.Send(senddata1); //报警灯短亮一次
|
||||
|
||||
@ -491,7 +533,7 @@ namespace WCS.BLL.Services.Service
|
||||
Message = $"入库成功!",
|
||||
Data = rcs.Data,
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL.Db;
|
||||
@ -128,16 +129,16 @@ namespace WCS.BLL.Services.Service
|
||||
var inventortyDetails = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), t => t.MatBatch.Contains(request.MatBatch))
|
||||
.Where(t => t.StoreInfo.ShelfTypeId == request.ShelfTypeId)
|
||||
.GroupBy(t => t.MatCode)
|
||||
.GroupBy(t => t.MatBatch)
|
||||
.Select(t => new MatInventorySummaryModel
|
||||
{
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatBatch = t.MatBatch,
|
||||
MatSpec = t.MatSpec,
|
||||
MatCustomer = t.MatCustomer,
|
||||
MatSupplier = t.MatSupplier,
|
||||
MatBatch = t.MatBatch,
|
||||
TotalQty = SqlFunc.AggregateSum(t.MatQty)
|
||||
})
|
||||
.ToListAsync();
|
||||
@ -149,5 +150,48 @@ namespace WCS.BLL.Services.Service
|
||||
Data = inventortyDetails
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<InventoryDetail>> compareMatInventoryDetail(CompareMatInventoryDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//查询 本分组中 是否含有所传SN的物料
|
||||
var recordsQueryable = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => request.MatSns.Contains(t.MatSN))
|
||||
.OrderBy(t => t.MatCode)
|
||||
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.StoreInfo.GroupName == LocalFile.Config.GroupName);
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable.ToListAsync();
|
||||
//生成序号 选中
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = i + 1;
|
||||
records[i].IsSelected = true;
|
||||
}
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
Lists = new List<InventoryDetail>()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Sockets;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using SqlSugar;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
@ -15,6 +9,7 @@ using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
@ -24,6 +19,53 @@ namespace WCS.BLL.Services.Service
|
||||
public OutstoreService()
|
||||
{
|
||||
|
||||
}
|
||||
public async Task<ResponseCommon<List<MatInventorySummaryModel>>> importMat(List<OutImportMatModel> list)
|
||||
{
|
||||
//数据校验
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
return new ResponseCommon<List<MatInventorySummaryModel>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:导入文件中没有内容!"
|
||||
};
|
||||
}
|
||||
//需求数量
|
||||
var errorCount = list.Where(t => t.需求数量 <= 0).ToList();
|
||||
if (errorCount != null && errorCount.Count > 0)
|
||||
{
|
||||
return new ResponseCommon<List<MatInventorySummaryModel>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:需求数量需要大于0!"
|
||||
};
|
||||
}
|
||||
//每一个物料进行搜索库存
|
||||
var returnList = new List<MatInventorySummaryModel>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var inventoryCount = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.MatCode == item.物料编码)
|
||||
.Where(t => t.MatBatch == item.物料批次)
|
||||
.Where(t => t.IsLocked == false)
|
||||
.SumAsync(t => t.MatQty);
|
||||
var info = inventoryCount < item.需求数量 ? "库存数量小于需求数量" : string.Empty;
|
||||
returnList.Add(new MatInventorySummaryModel()
|
||||
{
|
||||
MatCode = item.物料编码,
|
||||
MatName = item.物料名称,
|
||||
MatBatch = item.物料批次,
|
||||
NeedQty = item.需求数量,
|
||||
TotalQty = inventoryCount,
|
||||
Info = info
|
||||
});
|
||||
}
|
||||
return new ResponseCommon<List<MatInventorySummaryModel>>()
|
||||
{
|
||||
Code = 200,
|
||||
Data = returnList
|
||||
};
|
||||
}
|
||||
public async Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request)
|
||||
{
|
||||
@ -36,6 +78,24 @@ namespace WCS.BLL.Services.Service
|
||||
Message = "出库单据同步失败:缺少需要出库的物料类型!"
|
||||
};
|
||||
}
|
||||
//补齐货架类型名称
|
||||
if (string.IsNullOrEmpty(request.ShelfTypeName))
|
||||
{
|
||||
var shelfType = await DbHelp.db.Queryable<ShelfTypeInfo>()
|
||||
.Where(t => t.Id == request.ShelfTypeId)
|
||||
.FirstAsync();
|
||||
if (shelfType == null)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"出库单据同步失败:缺少必要参数!ShelfTypeId"
|
||||
};
|
||||
}
|
||||
else
|
||||
request.ShelfTypeName = shelfType.ShelfTypeName;
|
||||
}
|
||||
|
||||
//保存数据
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
try
|
||||
@ -45,6 +105,8 @@ namespace WCS.BLL.Services.Service
|
||||
OrderNumber = request.OrderNumber,
|
||||
OrderSource = request.OrderSource,
|
||||
OrderType = request.OrderType,
|
||||
ShelfTypeId = request.ShelfTypeId,
|
||||
ShelfTypeName = request.ShelfTypeName,
|
||||
SyncType = SyncTypeEnum.ByMatCode,
|
||||
CreateUser = request.UserName,
|
||||
};
|
||||
@ -95,103 +157,262 @@ namespace WCS.BLL.Services.Service
|
||||
Message = "出库单据同步失败:缺少物料明细!"
|
||||
};
|
||||
}
|
||||
//库存有无校验 & 库存已锁校验
|
||||
try
|
||||
//标准版逻辑-库存有无校验 & 库存已锁校验
|
||||
if (!LocalFile.Config.IsMx)
|
||||
{
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
var inventoryDetails = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => request.SnList.Contains(t.MatSN))
|
||||
.TranLock(DbLockType.Wait)
|
||||
.ToListAsync();
|
||||
if (inventoryDetails.Count < request.SnList.Count)//库存的物料少于需求的物料数量
|
||||
try
|
||||
{
|
||||
var existsSns = inventoryDetails.Select(t => t.MatSN).ToList();
|
||||
request.SnList.RemoveAll(t => existsSns.Contains(t));
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
//返回提示哪些物料库存不存在
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
var inventoryDetails = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => request.SnList.Contains(t.MatSN))
|
||||
.TranLock(DbLockType.Wait)
|
||||
.ToListAsync();
|
||||
if (inventoryDetails.Count < request.SnList.Count)//库存的物料少于需求的物料数量
|
||||
{
|
||||
var existsSns = inventoryDetails.Select(t => t.MatSN).ToList();
|
||||
request.SnList.RemoveAll(t => existsSns.Contains(t));
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
//返回提示哪些物料库存不存在
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "出库单据同步失败:存在物料不在库存中!",
|
||||
Data = request.SnList
|
||||
|
||||
};
|
||||
}
|
||||
else if (inventoryDetails.Where(t => t.IsLocked).Any())
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
//返回提示哪些物料库存已被锁定
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "出库单据同步失败:存在物料被锁定!",
|
||||
Data = inventoryDetails.Where(t => t.IsLocked).Select(t => t.MatSN).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
#region 保存数据
|
||||
|
||||
//锁库存
|
||||
inventoryDetails.ForEach(t =>
|
||||
{
|
||||
t.IsLocked = true;
|
||||
});
|
||||
var lockTask = DbHelp.db.Updateable(inventoryDetails).ExecuteCommandAsync();
|
||||
|
||||
//保存数据
|
||||
var order = new OutOrder()
|
||||
{
|
||||
OrderNumber = request.OrderNumber,
|
||||
OrderSource = request.OrderSource,
|
||||
OrderType = request.OrderType,
|
||||
SyncType = SyncTypeEnum.ByMatSn,
|
||||
CreateUser = request.UserName,
|
||||
};
|
||||
order.Id = await DbHelp.db.Insertable(order).ExecuteReturnIdentityAsync();
|
||||
|
||||
//通过库存数据保存出库物料明细表
|
||||
var matDetailTasks = inventoryDetails.Select(async t =>
|
||||
{
|
||||
var orderMatDetail = new OutOrderMatDetail()
|
||||
{
|
||||
OrderId = order.Id,
|
||||
OrderNumber = order.OrderNumber,
|
||||
InventoryDetailId = t.Id,
|
||||
StoreId = t.StoreId,
|
||||
StoreCode = t.StoreCode,
|
||||
MatSN = t.MatSN,
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatSpec = t.MatSpec,
|
||||
MatBatch = t.MatBatch,
|
||||
MatQty = t.MatQty,
|
||||
MatSupplier = t.MatSupplier,
|
||||
MatCustomer = t.MatCustomer,
|
||||
CreateUser = request.UserName
|
||||
};
|
||||
await DbHelp.db.Insertable(orderMatDetail).ExecuteCommandAsync();
|
||||
}).ToList();
|
||||
|
||||
await lockTask;
|
||||
await Task.WhenAll(matDetailTasks);
|
||||
|
||||
await DbHelp.db.CommitTranAsync();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "出库单据同步失败:存在物料不在库存中!",
|
||||
Data = request.SnList
|
||||
|
||||
Code = 200,
|
||||
Message = $"出库单据同步成功!\r\n出库单据号为{request.OrderNumber}",
|
||||
Data = order.Id
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
else if (inventoryDetails.Where(t => t.IsLocked).Any())
|
||||
catch (Exception ex)
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
//返回提示哪些物料库存已被锁定
|
||||
return new ResponseCommon()
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "出库单据同步失败:存在物料被锁定!",
|
||||
Data = inventoryDetails.Where(t => t.IsLocked).Select(t => t.MatSN).ToList()
|
||||
Message = $"出库单据同步失败:{ex.Message}"
|
||||
};
|
||||
}
|
||||
|
||||
#region 保存数据
|
||||
|
||||
//锁库存
|
||||
inventoryDetails.ForEach(t =>
|
||||
{
|
||||
t.IsLocked = true;
|
||||
});
|
||||
var lockTask = DbHelp.db.Updateable(inventoryDetails).ExecuteCommandAsync();
|
||||
|
||||
//保存数据
|
||||
var order = new OutOrder()
|
||||
{
|
||||
OrderNumber = request.OrderNumber,
|
||||
OrderSource = request.OrderSource,
|
||||
OrderType = request.OrderType,
|
||||
SyncType = SyncTypeEnum.ByMatSn,
|
||||
CreateUser = request.UserName,
|
||||
};
|
||||
order.Id = await DbHelp.db.Insertable(order).ExecuteReturnIdentityAsync();
|
||||
|
||||
//通过库存数据保存出库物料明细表
|
||||
var matDetailTasks = inventoryDetails.Select(async t =>
|
||||
{
|
||||
var orderMatDetail = new OutOrderMatDetail()
|
||||
{
|
||||
OrderId = order.Id,
|
||||
OrderNumber = order.OrderNumber,
|
||||
InventoryDetailId = t.Id,
|
||||
StoreId = t.StoreId,
|
||||
StoreCode = t.StoreCode,
|
||||
MatSN = t.MatSN,
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatSpec = t.MatSpec,
|
||||
MatBatch = t.MatBatch,
|
||||
MatQty = t.MatQty,
|
||||
MatSupplier = t.MatSupplier,
|
||||
MatCustomer = t.MatCustomer,
|
||||
CreateUser = request.UserName
|
||||
};
|
||||
await DbHelp.db.Insertable(orderMatDetail).ExecuteCommandAsync();
|
||||
}).ToList();
|
||||
|
||||
await lockTask;
|
||||
await Task.WhenAll(matDetailTasks);
|
||||
|
||||
await DbHelp.db.CommitTranAsync();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"出库单据同步成功!\r\n出库单据号为{request.OrderNumber}",
|
||||
Data = order.Id
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
//盟讯公司逻辑 不锁库存 直接保存数据/清除未发送的
|
||||
else
|
||||
{
|
||||
await DbHelp.db.RollbackTranAsync();
|
||||
return new ResponseBase()
|
||||
try
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"出库单据同步失败:{ex.Message}"
|
||||
};
|
||||
DbHelp.db.BeginTran();
|
||||
//1. 获取库存物料明细
|
||||
var inventoryDetails = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => request.SnList.Contains(t.MatSN))
|
||||
.ToListAsync();
|
||||
if (inventoryDetails == null || inventoryDetails.Count == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "保存出库单失败!请重试!",
|
||||
Data = request.SnList
|
||||
};
|
||||
}
|
||||
//2. 先获取对应单号是否已经保存
|
||||
var outOrder = DbHelp.db.Queryable<OutOrder>()
|
||||
.Where(t => t.OrderNumber == request.OrderNumber)
|
||||
.Where(t => t.GroupName == LocalFile.Config.GroupName)
|
||||
.First();
|
||||
//数据库中没有才添加
|
||||
if (outOrder == null)
|
||||
{
|
||||
//OutOrder
|
||||
outOrder = new OutOrder()
|
||||
{
|
||||
OrderNumber = request.OrderNumber,
|
||||
OutOrderExeStatus = OutOrderExeStatus.开始发料,
|
||||
OrderSource = "WCS前端",
|
||||
SyncType = SyncTypeEnum.ByMatSn,
|
||||
ShelfTypeName = "智能货架",
|
||||
ShelfTypeId = 0,
|
||||
GroupName = LocalFile.Config.GroupName,
|
||||
};
|
||||
outOrder.Id = await DbHelp.db.Insertable(outOrder).ExecuteReturnIdentityAsync();
|
||||
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.OrderNumber == request.OrderNumber)
|
||||
.Where(t => t.Id == outOrder.Id)
|
||||
.FirstAsync();
|
||||
//保存单据失败了
|
||||
if (outOrder == null)
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "保存出库单失败!保存Order失败!",
|
||||
Data = request.SnList
|
||||
};
|
||||
|
||||
//出库物料明细
|
||||
foreach (var item in inventoryDetails)
|
||||
{
|
||||
var orderMatDetail = new OutOrderMatDetail()
|
||||
{
|
||||
OrderId = outOrder.Id,
|
||||
OrderNumber = outOrder.OrderNumber,
|
||||
InventoryDetailId = item.Id,
|
||||
StoreId = item.StoreId,
|
||||
StoreCode = item.StoreCode,
|
||||
MatSN = item.MatSN,
|
||||
MatCode = item.MatCode,
|
||||
MatName = item.MatName,
|
||||
MatSpec = item.MatSpec,
|
||||
MatBatch = item.MatBatch,
|
||||
MatQty = item.MatQty,
|
||||
MatSupplier = item.MatSupplier,
|
||||
MatCustomer = item.MatCustomer,
|
||||
CreateUser = request.UserName
|
||||
};
|
||||
await DbHelp.db.Insertable(orderMatDetail).ExecuteCommandAsync();
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
}
|
||||
//数据库已有该Order
|
||||
else
|
||||
{
|
||||
outOrder.CreateTime = DateTime.Now;
|
||||
DbHelp.db.Updateable(outOrder).ExecuteCommand();
|
||||
//删除未出库的
|
||||
var outOrderDetails = DbHelp.db.Deleteable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.Where(t => t.IsSended == false)
|
||||
.ExecuteCommand();
|
||||
//当前已出库的 //已出库的也不在库存中了 应该查询不到了
|
||||
//避免影响效率 就不查重了
|
||||
foreach (var item in inventoryDetails)
|
||||
{
|
||||
var orderMatDetail = new OutOrderMatDetail()
|
||||
{
|
||||
OrderId = outOrder.Id,
|
||||
OrderNumber = outOrder.OrderNumber,
|
||||
InventoryDetailId = item.Id,
|
||||
StoreId = item.StoreId,
|
||||
StoreCode = item.StoreCode,
|
||||
MatSN = item.MatSN,
|
||||
MatCode = item.MatCode,
|
||||
MatName = item.MatName,
|
||||
MatSpec = item.MatSpec,
|
||||
MatBatch = item.MatBatch,
|
||||
MatQty = item.MatQty,
|
||||
MatSupplier = item.MatSupplier,
|
||||
MatCustomer = item.MatCustomer,
|
||||
CreateUser = request.UserName
|
||||
};
|
||||
await DbHelp.db.Insertable(orderMatDetail).ExecuteCommandAsync();
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
|
||||
//更新订单状态
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (outOrder != null)
|
||||
{
|
||||
#region 物料明细表是否已发完
|
||||
var orderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.ToList();
|
||||
var isExistNoSendMat = orderMatDetails.Where(t => t.IsSended == false)
|
||||
.Any();
|
||||
if (isExistNoSendMat)
|
||||
{
|
||||
outOrder.OrderStatus = OutOrderStatus.部分发料;
|
||||
}
|
||||
else
|
||||
{
|
||||
outOrder.OrderStatus = OutOrderStatus.全部发料;
|
||||
outOrder.OutOrderExeStatus = OutOrderExeStatus.发料完成;
|
||||
}
|
||||
#endregion
|
||||
DbHelp.db.Updateable(outOrder).ExecuteCommand();
|
||||
}
|
||||
});
|
||||
}
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"Success",
|
||||
Data = request.SnList
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
Logs.Write($"同步出库单据发生异常{ex.Message}", LogsType.Info);
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"保存出库单失败!{ex.Message}!",
|
||||
Data = request.SnList
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -202,7 +423,8 @@ namespace WCS.BLL.Services.Service
|
||||
var recordsQueryable = DbHelp.db.Queryable<OutOrder>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber.Contains(request.OrderNumber))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderSource), t => t.OrderSource.Contains(request.OrderSource))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderType), t => t.OrderType.Contains(request.OrderType));
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderType), t => t.OrderType.Contains(request.OrderType))
|
||||
.WhereIF(request.ShelfTypeId != 0, t => t.ShelfTypeId == request.ShelfTypeId);
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
@ -713,7 +935,8 @@ namespace WCS.BLL.Services.Service
|
||||
.Where(t => t.MatCode == outOrderDetail.MatCode)
|
||||
.WhereIF(!string.IsNullOrEmpty(outOrderDetail.MatBatch), t => t.MatBatch == outOrderDetail.MatBatch)
|
||||
.Where(t => t.IsLocked == false)//未锁定的物料
|
||||
.OrderBy(t => t.MatBatch)//先进先出
|
||||
.Where(t => t.StoreInfo.ShelfTypeId == order.ShelfTypeId)
|
||||
.OrderBy(t => t.MatBatch)//按批次先进先出
|
||||
//(t => t.MatQty)//零散料先出
|
||||
.ToList();
|
||||
|
||||
@ -866,6 +1089,10 @@ namespace WCS.BLL.Services.Service
|
||||
DbHelp.db.Updateable(order).ExecuteCommand();
|
||||
}
|
||||
|
||||
//解锁物料 删除物料明细
|
||||
if (order.SyncType == SyncTypeEnum.ByMatCode)
|
||||
CancelOutOrderMatDetails(order);
|
||||
|
||||
//找到正在出对应出库单的货架
|
||||
var shelves = ShelfManager.Shelves.Where(t => t.OrderNumber == request.OrderNumber)
|
||||
.Where(t => t.CurrentMode == HardWare.Mode.出库模式)
|
||||
@ -881,15 +1108,15 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
//退出出库模式
|
||||
shelves.ForEach(t =>
|
||||
{
|
||||
t.GoOutOutstore();
|
||||
});
|
||||
|
||||
//解锁物料 删除物料明细
|
||||
if (order.SyncType == SyncTypeEnum.ByMatCode)
|
||||
CancelOutOrderMatDetails(order);
|
||||
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
@ -1061,11 +1288,11 @@ namespace WCS.BLL.Services.Service
|
||||
ior.OperateUser = request.userName;
|
||||
ior.OperateTime = DateTime.Now;
|
||||
//保存出库记录
|
||||
int count= DbHelp.db.Insertable(ior).ExecuteCommand();
|
||||
int count = DbHelp.db.Insertable(ior).ExecuteCommand();
|
||||
//删除库存
|
||||
DbHelp.db.Deleteable<InventoryDetail>().Where(it => it.MatSN == request.MatSn).ExecuteCommand();
|
||||
//更新需求表
|
||||
List<OutOrderDetail> odd = DbHelp.db.Queryable<OutOrderDetail>().Where(it => it.OrderNumber == request.orderNumber).Where(it=>it.MatCode==request.MatCode).ToList();
|
||||
List<OutOrderDetail> odd = DbHelp.db.Queryable<OutOrderDetail>().Where(it => it.OrderNumber == request.orderNumber).Where(it => it.MatCode == request.MatCode).ToList();
|
||||
odd[0].OutQty += request.Qty;
|
||||
DbHelp.db.Updateable(odd[0]).ExecuteCommand();
|
||||
|
||||
@ -1076,5 +1303,7 @@ namespace WCS.BLL.Services.Service
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -941,6 +941,12 @@ namespace WCS.BLL.Services.Service
|
||||
StoreCode = inventoryDetail.StoreCode,
|
||||
StoreId = inventoryDetail.StoreId,
|
||||
|
||||
R = inventoryDetail.R,
|
||||
C = inventoryDetail.C,
|
||||
Wei = inventoryDetail.Wei,
|
||||
BigShelfCode = inventoryDetail.BigShelfCode,
|
||||
GroupName = inventoryDetail.GroupName,
|
||||
|
||||
MatSN = inventoryDetail.MatSN,
|
||||
MatCode = inventoryDetail.MatCode,
|
||||
MatName = inventoryDetail.MatName,
|
||||
@ -949,6 +955,7 @@ namespace WCS.BLL.Services.Service
|
||||
MatSpec = inventoryDetail.MatSpec,
|
||||
MatCustomer = inventoryDetail.MatCustomer,
|
||||
MatSupplier = inventoryDetail.MatSupplier,
|
||||
OrderNumber = stockTakingOrderMatDetail.StocktakingOrderNumber,
|
||||
|
||||
Direction = DirectionEnum.盘点,
|
||||
OperateUser = request.UserName
|
||||
|
@ -5,13 +5,17 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
@ -106,7 +110,7 @@ namespace WCS.BLL.Services.Service
|
||||
shelfnfo.ClientIp = request.ShelfInfo.ClientIp;
|
||||
shelfnfo.GroupName = request.ShelfInfo.GroupName;
|
||||
shelfnfo.IsBind = request.ShelfInfo.IsBind;
|
||||
shelfnfo.BindShelfCode = request.ShelfInfo.BindShelfCode;
|
||||
shelfnfo.BigShelfCode = request.ShelfInfo.BigShelfCode;
|
||||
|
||||
var rowNum = await DbHelp.db.Updateable(shelfnfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
@ -153,7 +157,7 @@ namespace WCS.BLL.Services.Service
|
||||
ClientIp = request.ShelfInfo.ClientIp,
|
||||
GroupName = request.ShelfInfo.GroupName,
|
||||
IsBind = request.ShelfInfo.IsBind,
|
||||
BindShelfCode = request.ShelfInfo.BindShelfCode,
|
||||
BigShelfCode = request.ShelfInfo.BigShelfCode,
|
||||
};
|
||||
var rowNum = await DbHelp.db.Insertable(newShelfInfo).ExecuteCommandAsync();
|
||||
if (rowNum == 0)
|
||||
@ -242,29 +246,36 @@ namespace WCS.BLL.Services.Service
|
||||
/// <returns></returns>
|
||||
public async Task<ResponseCommon<object>> GenerateStoreInfo()
|
||||
{
|
||||
var shelfInfo = await DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode == "C04-1").FirstAsync();
|
||||
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == shelfInfo.Id).ToListAsync();
|
||||
ModuleInfos.ForEach(moduleInfo =>
|
||||
var shelfInfos = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||
foreach (var shelfInfo in shelfInfos)
|
||||
{
|
||||
for (int i = 1; i <= moduleInfo.LightCount; i++)
|
||||
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == shelfInfo.Id).ToListAsync();
|
||||
ModuleInfos.ForEach(moduleInfo =>
|
||||
{
|
||||
var storeInfo = new StoreInfo()
|
||||
for (int i = 1; i <= moduleInfo.LightCount; i++)
|
||||
{
|
||||
StoreCode = moduleInfo.ModuleCode + "-" + i.ToString(),
|
||||
ModuleId = moduleInfo.Id,
|
||||
ModuleCode = moduleInfo.ModuleCode,
|
||||
ShelfId = shelfInfo.Id,
|
||||
ShelfCode = shelfInfo.ShelfCode,
|
||||
BoardId = moduleInfo.BoardId,
|
||||
LightNumber = i,
|
||||
Priority = 1,
|
||||
CurrentMatSn = string.Empty,
|
||||
};
|
||||
DbHelp.db.Insertable(storeInfo).ExecuteCommand();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
var storeInfo = new StoreInfo()
|
||||
{
|
||||
StoreCode = moduleInfo.ModuleCode + "-" + i.ToString(),
|
||||
ShelfTypeId = 1,
|
||||
ModuleId = moduleInfo.Id,
|
||||
ModuleCode = moduleInfo.ModuleCode,
|
||||
ShelfId = shelfInfo.Id,
|
||||
ShelfCode = shelfInfo.ShelfCode,
|
||||
BoardId = moduleInfo.BoardId,
|
||||
LightNumber = i,
|
||||
Priority = 1,
|
||||
CurrentMatSn = string.Empty,
|
||||
BigShelfCode = moduleInfo.Bigshelfcode,
|
||||
R = moduleInfo.R,
|
||||
C = moduleInfo.C,
|
||||
Wei = i.ToString(),
|
||||
GroupName = moduleInfo.GroupName,
|
||||
};
|
||||
DbHelp.db.Insertable(storeInfo).ExecuteCommand();
|
||||
}
|
||||
});
|
||||
}
|
||||
return new ResponseCommon<object>() { Message = "111" };
|
||||
}
|
||||
|
||||
@ -308,6 +319,84 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用或启用模组
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResponseCommon> disableOrEnableModule(DisableOrEnableModuleRequest request)
|
||||
{
|
||||
//找到库位
|
||||
var moduleInfo = await DbHelp.db.Queryable<ModuleInfo>()
|
||||
.Where(t => t.Id == request.ModuleId)
|
||||
.FirstAsync();
|
||||
//库位不存在
|
||||
if (moduleInfo == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:模组{request.ModuleCode}不存在!"
|
||||
};
|
||||
}
|
||||
try
|
||||
{
|
||||
DbHelp.db.BeginTran();
|
||||
//禁用
|
||||
if (request.DisableOrEnable == DisableOrEnableEnum.Disable)
|
||||
{
|
||||
moduleInfo.IsEnable = false;
|
||||
//盟讯公司发送钉钉消息
|
||||
if (LocalFile.Config.IsMx)
|
||||
{
|
||||
var DingDing = string.Empty;
|
||||
MXBackgroundThread.SendDingDingMsg($"【智能货架】模组{moduleInfo.ModuleCode}被屏蔽", new List<string> { "104379", "103595" }, ref DingDing);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
moduleInfo.IsEnable = true;
|
||||
}
|
||||
DbHelp.db.Updateable(moduleInfo).ExecuteCommand();
|
||||
DbHelp.db.CommitTran();
|
||||
|
||||
#region 更新缓存中的禁用/启动状态
|
||||
try
|
||||
{
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfId == moduleInfo.ShelfId)
|
||||
.FirstOrDefault();
|
||||
if (shelf != null)
|
||||
{
|
||||
|
||||
var moduleInPc = shelf.Modules.Where(t => t.ModuleId == moduleInfo.Id)
|
||||
.First();
|
||||
if (moduleInPc != null)
|
||||
moduleInPc.IsEnable = request.DisableOrEnable == DisableOrEnableEnum.Enable;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"Success"
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:异常{ex.Message}!"
|
||||
};
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 库位管理
|
||||
@ -352,6 +441,99 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon> disableOrEnableStore(DisableOrEnableStoreRequest request)
|
||||
{
|
||||
//找到库位
|
||||
var storeInfo = await DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.Id == request.StoreId)
|
||||
.FirstAsync();
|
||||
//库位不存在
|
||||
if (storeInfo == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:库位{request.SroreCode}不存在!"
|
||||
};
|
||||
}
|
||||
try
|
||||
{
|
||||
DbHelp.db.BeginTran();
|
||||
//禁用需要删除当前库存数据
|
||||
if (request.DisableOrEnable == DisableOrEnableEnum.Disable)
|
||||
{
|
||||
|
||||
//盟讯公司发送钉钉消息
|
||||
if (LocalFile.Config.IsMx)
|
||||
{
|
||||
var DingDing = string.Empty;
|
||||
MXBackgroundThread.SendDingDingMsg($"【智能货架】库位{storeInfo.StoreCode}被屏蔽", new List<string> { "104379", "103595" }, ref DingDing);
|
||||
}
|
||||
|
||||
//库位
|
||||
storeInfo.CurrentMatSn = "禁用";
|
||||
//库存数据处理
|
||||
var inventorys = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.StoreId == storeInfo.Id)
|
||||
.ToList();
|
||||
if (inventorys != null && inventorys.Count > 0)
|
||||
{
|
||||
//删除并进行出入库记录
|
||||
foreach (var inventory in inventorys)
|
||||
{
|
||||
var inOutRecord = new InOutRecord()
|
||||
{
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
R = storeInfo.R,
|
||||
C = storeInfo.C,
|
||||
Wei = storeInfo.Wei,
|
||||
BigShelfCode = storeInfo.BigShelfCode,
|
||||
GroupName = storeInfo.GroupName,
|
||||
|
||||
MatSN = inventory.MatSN,
|
||||
MatCode = inventory.MatCode,
|
||||
MatName = inventory.MatName,
|
||||
MatSpec = inventory.MatSpec,
|
||||
MatBatch = inventory.MatBatch,
|
||||
MatQty = inventory.MatQty,
|
||||
MatCustomer = inventory.MatCustomer,
|
||||
MatSupplier = inventory.MatSupplier,
|
||||
|
||||
OperateUser = request.UserName + "(禁用库位)",
|
||||
Direction = DirectionEnum.丢失,
|
||||
};
|
||||
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
DbHelp.db.Deleteable(inventory).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
storeInfo.CurrentMatSn = string.Empty;
|
||||
}
|
||||
DbHelp.db.Updateable(storeInfo).ExecuteCommand();
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"Success"
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:异常{ex.Message}!"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
@ -440,13 +441,23 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
//返回字串不返回密码
|
||||
user.Password = "***";
|
||||
|
||||
var response = new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = user
|
||||
};
|
||||
//登录成功
|
||||
if (request.DeviceType == "WCS前端" && request.GroupNames != null)
|
||||
{
|
||||
var shelves = ShelfManager.Shelves.Where(t => request.GroupNames.Contains(t.GroupName))
|
||||
.ToList();
|
||||
foreach (var shelf in shelves)
|
||||
{
|
||||
shelf.WebSocketIpAddress = request.WebSocketIpAddress;
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -26,6 +26,7 @@ namespace WCS.BLL.Services.Service
|
||||
.FirstOrDefault();
|
||||
if (warning != null)
|
||||
{
|
||||
warning.SolvedUser = request.UserName;
|
||||
WarningManager.ClearWarning(warning, request.SolveType);
|
||||
}
|
||||
//判断一下是否还存在对应报警
|
||||
|
@ -274,7 +274,7 @@ namespace WCS.BLL.Tool
|
||||
public static T GetDataFromHttp<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
var data = JsonConvert.SerializeObject(dataObj);
|
||||
var data = dataObj == null ? string.Empty : JsonConvert.SerializeObject(dataObj);
|
||||
try
|
||||
{
|
||||
if (isSaveLog)
|
||||
|
@ -22,18 +22,21 @@ namespace WCS.BLL
|
||||
/// </summary>
|
||||
Info,
|
||||
/// <summary>
|
||||
/// 警告
|
||||
/// 启动信息
|
||||
/// </summary>
|
||||
Warning,
|
||||
StartBoot,
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// 调用外部Api的接口
|
||||
/// </summary>
|
||||
Err,
|
||||
Api,
|
||||
/// <summary>
|
||||
/// 数据库错误
|
||||
/// 指令发送接收
|
||||
/// </summary>
|
||||
DbErr,
|
||||
Api
|
||||
Instructions,
|
||||
/// <summary>
|
||||
/// 指令重发
|
||||
/// </summary>
|
||||
InstructionResend
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -115,16 +118,6 @@ namespace WCS.BLL
|
||||
Write($"{contentTitle} {JsonConvert.SerializeObject(content)}", type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="ex">错误</param>
|
||||
/// <returns>是否写入成功</returns>
|
||||
public static void Write(Exception ex, LogsType type = LogsType.Err)
|
||||
{
|
||||
Write(ex.ToString(), type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除日志
|
||||
/// </summary>
|
||||
|
@ -79,36 +79,38 @@ namespace WCS.BLL
|
||||
tcpClient.Received += (client, e) =>
|
||||
{
|
||||
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
|
||||
Logs.Write($"校验发送接收,收到数据" + BitConverter.ToString(data));
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - PreFixLength; index++)
|
||||
Task.Run(() =>
|
||||
{
|
||||
//协议拆包 通过前缀校验是否为完整数据包
|
||||
var prefixInData = data.Skip(index).Take(PreFixLength);
|
||||
var isEqual = prefixInData.SequenceEqual(Prefix);
|
||||
if (isEqual)
|
||||
Logs.Write($"【校验发送接收 开始】" + BitConverter.ToString(data), LogsType.InstructionResend);
|
||||
var len = data.Length;
|
||||
for (int index = 0; index < data.Length - PreFixLength; index++)
|
||||
{
|
||||
var dataTemp = data.Skip(index).Take(PreFixLength + DataLength).ToArray();
|
||||
if (dataTemp.Length < PreFixLength + DataLength)//拆包后不满足一条指令的长度
|
||||
//协议拆包 通过前缀校验是否为完整数据包
|
||||
var prefixInData = data.Skip(index).Take(PreFixLength);
|
||||
var isEqual = prefixInData.SequenceEqual(Prefix);
|
||||
if (isEqual)
|
||||
{
|
||||
continue;
|
||||
var dataTemp = data.Skip(index).Take(PreFixLength + DataLength).ToArray();
|
||||
if (dataTemp.Length < PreFixLength + DataLength)//拆包后不满足一条指令的长度
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//获取返回指令的板子ID
|
||||
var boardId = (dataTemp[PreFixLength + 0] << 8) + dataTemp[PreFixLength + 1];
|
||||
//查询当前板子是否有待验证的指令
|
||||
var message = new MessageDto();
|
||||
MessageList.TryGetValue(boardId, out message);
|
||||
//功能位校验 功能位相同视为已响应指令 删除对应的指令
|
||||
if (message?.Message[PreFixLength + 2] == dataTemp[PreFixLength + 2])
|
||||
{
|
||||
MessageList.TryRemove(boardId, out message);
|
||||
}
|
||||
index += (PreFixLength + DataLength - 2);//每次循环index会+1 所以这里-1
|
||||
}
|
||||
//获取返回指令的板子ID
|
||||
var boardId = (data[PreFixLength + 0] << 8) + data[PreFixLength + 1];
|
||||
//查询当前板子是否有待验证的指令
|
||||
var message = new MessageDto();
|
||||
MessageList.TryGetValue(boardId, out message);
|
||||
//功能位校验 功能位相同视为已响应指令 删除对应的指令
|
||||
if (message?.Message[PreFixLength + 2] == dataTemp[PreFixLength + 2])
|
||||
{
|
||||
MessageList.TryRemove(boardId, out message);
|
||||
}
|
||||
index += (PreFixLength + DataLength - 1);//每次循环index会+1 所以这里-1
|
||||
}
|
||||
}
|
||||
Logs.Write($"校验发送接收处理完毕" + BitConverter.ToString(data));
|
||||
Logs.Write($"【校验发送接收 结束】" + BitConverter.ToString(data), LogsType.InstructionResend);
|
||||
});
|
||||
return null;
|
||||
|
||||
};
|
||||
|
||||
tcpClient.Connected += (client, e) =>
|
||||
@ -131,27 +133,25 @@ namespace WCS.BLL
|
||||
try
|
||||
{
|
||||
//TODO如果指令已发两次 则取消重发
|
||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
||||
await Task.Delay(100);
|
||||
if (MessageList.Count > 0)
|
||||
{
|
||||
var failedMessage = MessageList.Where(t => t.Value.SendTimes >= 2).ToList();
|
||||
var failedMessage = MessageList.Where(t => t.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
|
||||
.ToList();
|
||||
foreach (var message in failedMessage)
|
||||
{
|
||||
Logs.Write(BitConverter.ToString(message.Value.Message) +
|
||||
"指令未响应");
|
||||
Logs.Write("【指令重发】" + BitConverter.ToString(message.Value.Message) + "指令超时1s未响应", LogsType.InstructionResend);
|
||||
}
|
||||
MessageList.RemoveWhen(t => t.Value.SendTimes >= 3);
|
||||
|
||||
Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
|
||||
MessageList.RemoveWhen(t => t.Value.SendTimes >= 2);
|
||||
foreach (var item in MessageList)
|
||||
{
|
||||
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
|
||||
{
|
||||
tcpClient.Send(item.Value.Message);
|
||||
|
||||
Send(item.Value.Message);
|
||||
item.Value.SendTimes++;
|
||||
item.Value.LastSendTime = DateTime.Now;
|
||||
await Task.Delay(10);
|
||||
Logs.Write("【指令重发】" + BitConverter.ToString(item.Value.Message) + "已进行重发", LogsType.InstructionResend);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -173,18 +173,30 @@ namespace WCS.BLL
|
||||
}
|
||||
|
||||
|
||||
public void Send(byte[] message)
|
||||
public void Send(byte[] message, bool IsReSend = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var boardId = (message[3] << 8) + message[4];
|
||||
|
||||
if (boardId != 2047 && IsReSend == false)
|
||||
{
|
||||
MessageList.TryAdd(boardId, new MessageDto()
|
||||
{
|
||||
ID = boardId,
|
||||
Message = message,
|
||||
SendTimes = 1
|
||||
});
|
||||
}
|
||||
|
||||
lock (sendLockObject)
|
||||
{
|
||||
tcpClient.Send(message);
|
||||
//TODO MessageList.AddOrUpdate(new Mes)
|
||||
//发送自带10ms间隔
|
||||
Thread.Sleep(10);
|
||||
//发送自带8ms间隔
|
||||
Thread.Sleep(8);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -226,18 +238,14 @@ namespace WCS.BLL
|
||||
public class MessageDto
|
||||
{
|
||||
public int ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后一次发送时间
|
||||
/// </summary>
|
||||
public DateTime LastSendTime { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 发送内容
|
||||
/// </summary>
|
||||
public byte[] Message { get; set; }
|
||||
|
||||
public bool IsWating { get; set; }
|
||||
/// <summary>
|
||||
/// 发送次数
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user