Merge branch '11'

# Conflicts:
#	WCS.BLL/Services/Service/InstoreService.cs
#	WCS.BLL/Services/Service/OutstoreService.cs
This commit is contained in:
hehaibing-1996
2024-05-28 08:59:32 +08:00
132 changed files with 5024 additions and 541 deletions

View File

@ -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
}
}

View 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; }
}
}

View File

@ -12,7 +12,7 @@ namespace WCS.BLL.DbModels
/// <summary>
/// 用于记录单据生成到哪个序号了
/// </summary>
[SugarTable("document_serial_number")]
[SugarTable("wcs_document_serial_number")]
public class DocumentSerialNumber
{
/// <summary>

View File

@ -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>

View File

@ -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>

View File

@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
///<summary>
///物料基础信息
///</summary>
[SugarTable("mat_base_info")]
[SugarTable("wcs_mat_base_info")]
public partial class MatBaseInfo
{
/// <summary>

View File

@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
///<summary>
///物料信息表
///</summary>
[SugarTable("mat_info")]
[SugarTable("wcs_mat_info")]
public class MatInfo
{
/// <summary>

View File

@ -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>

View File

@ -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>
/// 创建时间

View File

@ -6,7 +6,7 @@ namespace WCS.BLL.DbModels
/// <summary>
/// 出库单据明细表
/// </summary>
[SugarTable("out_order_detail")]
[SugarTable("wcs_out_order_detail")]
public class OutOrderDetail
{
/// <summary>

View File

@ -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>

View File

@ -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>
/// 序号

View File

@ -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)]

View File

@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
/// <summary>
/// 盘点单据
/// </summary>
[SugarTable("stock_taking_order")]
[SugarTable("wcs_stock_taking_order")]
public class StockTakingOrder
{
/// <summary>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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)
{

View File

@ -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);

View File

@ -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();
}
}
}

View 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;
}
}
}
}

View File

@ -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)

View File

@ -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);
}
//后台启动时给所有板子、警示灯发送复位操作 保持状态一致

View File

@ -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();
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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,
};
}
}
}

View File

@ -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>()
}
};
}
}
}
}

View File

@ -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
};
}
}
}

View File

@ -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

View File

@ -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
}
}

View File

@ -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)

View File

@ -26,6 +26,7 @@ namespace WCS.BLL.Services.Service
.FirstOrDefault();
if (warning != null)
{
warning.SolvedUser = request.UserName;
WarningManager.ClearWarning(warning, request.SolveType);
}
//判断一下是否还存在对应报警

View File

@ -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)

View File

@ -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>

View File

@ -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>

View File

@ -49,7 +49,7 @@ namespace WCS.DAL
{
Id = 1,
LoginName = "admin",
Password = "",
Password = "admin123",
RoleIds = new List<int> () { 1 },
IsAdmin = true,
Time = dt,

View File

@ -10,7 +10,7 @@ namespace WCS.DAL.Db.AuthDb
/// <summary>
/// 用户
/// </summary>
[SugarTable("User")]
[SugarTable("wcs_user")]
public class UserBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
@ -37,6 +37,13 @@ namespace WCS.DAL.Db.AuthDb
/// 是否最大权限
/// </summary>
public bool IsAdmin { get; set; }
///// <summary>
///// 是否是工程研发
///// </summary>
//[SugarColumn(ColumnName = "IsGCYF", IsNullable = true, ColumnDescription = "是否是工程研发人员")]
public bool IsGCYF { get; set; } = false;
/// <summary>
/// 创建时间
/// </summary>
@ -52,7 +59,7 @@ namespace WCS.DAL.Db.AuthDb
/// <summary>
/// 角色
/// </summary>
[SugarTable("Role")]
[SugarTable("wcs_role")]
public class RoleBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]

View File

@ -1,6 +1,7 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -21,11 +22,8 @@ namespace WCS.DAL.Db
{
db.Aop.OnError = ex =>
{
//TO DO LOG
//Logs.Write($@"{nameof(db)}{Environment.NewLine}SQL:{ex?.Sql}{Environment.NewLine}Parametres:{JsonConvert.SerializeObject(ex?.Parametres)}{Environment.NewLine}InnerException:{ex?.InnerException?.ToString()}{Environment.NewLine}Exception:{ex?.ToString()}{Environment.NewLine}", LogsType.DbErr);
};
});
/// <summary>
/// 日志数据库
/// </summary>
@ -38,23 +36,7 @@ namespace WCS.DAL.Db
{
db.Aop.OnError = ex =>
{
//TO DO LOG
//Logs.Write($@"{nameof(dbAuth)}{Environment.NewLine}SQL:{ex?.Sql}{Environment.NewLine}Parametres:{JsonConvert.SerializeObject(ex?.Parametres)}{Environment.NewLine}InnerException:{ex?.InnerException?.ToString()}{Environment.NewLine}Exception:{ex?.ToString()}{Environment.NewLine}", LogsType.DbErr);
};
});
public static void InitDb()
{
//#region 初始化业务数据库
////不存在创建数据库,存在不会创建
//db.DbMaintenance.CreateDatabase();
////创建表根据实体类
//db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo));
//#endregion
//#region 初始化日志数据库
//dbLog.DbMaintenance.CreateDatabase();
//#endregion
}
}
}

View File

@ -11,7 +11,6 @@ namespace WCS.Model
public string MatSn { get; set; } = string.Empty;
public string ShelfCode { get; set; } = string.Empty;
public string IpAddress { get; set; } = string.Empty;
public bool IsSingleLightIn { get; set; } = false;
public bool SingleLightIn { get; set; } = false;
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class ApiResult
{
/// <summary>
/// 处理结果 200成功
/// </summary>
public int code { get; set; }
/// <summary>
/// 处理消息
/// </summary>
public string message { get; set; }
}
public class ApiResult<T> : ApiResult
{
/// <summary>
/// 数据
/// </summary>
public T data { get; set; }
}
public class ApiResultMsg
{
/// <summary>
/// 处理结果 200成功
/// </summary>
public int code { get; set; }
/// <summary>
/// 处理消息
/// </summary>
public string msg { get; set; }
}
public class ApiResultMsg<T> : ApiResultMsg
{
/// <summary>
/// 数据
/// </summary>
public T data { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class BunkerOutRequest
{
public string materialBar { get; set; }
/// <summary>
///
/// </summary>
public int outType { get; set; } = 0;
/// <summary>
///
/// </summary>
public string pickBillNumber { get; set; }
/// <summary>
///
/// </summary>
public int qty { get; set; } = 0;
/// <summary>
///
/// </summary>
public int warehouseType { get; set; } = 20;
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class InputStockInRequest
{
public string materialBar { get; set; }
public string shelfCode { get; set; }
public string shelfX { get; set; }
public string shelfY { get; set; }
public string shelfZ { get; set; }
public string inUser { get; set; } = string.Empty;
public string inTime { get; set; }
public int warehouseType { get; set; } = 20;
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class MXMesResponseCommon
{
public int code { get; set; }
public string message { get; set; }
public string msg { get; set; }
public object data { get; set; }
}
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class PickOrderRequest
{
public string orderProdNumber { get; set; }
public string orderWorkNumber { get; set; }
public string pickBillNumber { get; set; }
}
public class PickOrderResponse
{
/// <summary>
///
/// </summary>
public int code { get; set; }
/// <summary>
///
/// </summary>
public string msg { get; set; }
/// <summary>
///
/// </summary>
public List<PickOrder> data { get; set; }
}
public class PickOrder
{
public bool IsSelected { get; set; }
public int id { get; set; }
public string pickBillNumber { get; set; }
public string relationPickNumber { get; set; }
public string orderProdIds { get; set; }
public string orderProdNumbers { get; set; }
public string orderWorkIds { get; set; }
public string orderWorkNumbers { get; set; }
public string dictType { get; set; }
public string dictTypeStr
{
get
{
switch (dictType)
{
case "1":
return "生产领料";
default: return "其他";
}
}
}
public string dictStatus { get; set; }
public string dictStatusStr
{
get
{
switch (dictStatus)
{
case "15":
return "待领料";
case "10":
return "部分领料";
default: return dictStatus.ToString();
}
}
}
public string createdBy { get; set; }
public string createdDt { get; set; }
public string updatedBy { get; set; }
public string updatedDt { get; set; }
}
}

View File

@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class QueryBybarRequest
{
//条码
public string materialBar { get; set; }
}
public class InStoreDto
{
public string materialBar { get; set; }
/// <summary>
///
/// </summary>
public string materialCode { get; set; }
/// <summary>
/// 有源蜂鸣器
/// </summary>
public string materialName { get; set; }
/// <summary>
/// TMB09A03/5X9电压3V
/// </summary>
public string materialSpec { get; set; }
public double materialQty { get; set; }
public string batchNo { get; set; }
}
public class QueryBybarResponse
{
/// <summary>
///
/// </summary>
public int code { get; set; }
/// <summary>
///
/// </summary>
public string message { get; set; }
/// <summary>
///
/// </summary>
public List<InStoreDto> data { get; set; }
}
}

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class RecommendedBarCodeRequest
{
public string pickBillNumber { get; set; }
public string warehouseCode { get; set; } = string.Empty;
public int warehouseType { get; set; } = 10;
}
public class FistPushRecommendedBarCodeRequest : RecommendedBarCodeRequest
{
public string reportSide { get; set; } = null;
}
public class RecommendedBarCodeResponse
{
/// <summary>
///
/// </summary>
public int code { get; set; }
/// <summary>
///
/// </summary>
public string message { get; set; }
/// <summary>
///
/// </summary>
public List<PickOrderDetailGetReturnList> data { get; set; }
}
public class PickOrderDetailGetReturnList
{
public bool IsInstore { get; set; }
public int id { get; set; }
public string materialBar { get; set; }
public string materialId { get; set; }
public string materialCode { get; set; }
public string materialName { get; set; }
public string materialSpec { get; set; }
public string unitOfMeasure { get; set; }
public string batchNo { get; set; }
public double qty { get; set; }
public string warehouseId { get; set; }
public string warehouseCode { get; set; }
public string warehouseName { get; set; }
public string shelfCode { get; set; }
public string shelfX { get; set; }
public string shelfY { get; set; }
public string shelfZ { get; set; }
public string inUser { get; set; }
public string inTime { get; set; }
public string outUser { get; set; }
public string outTime { get; set; }
public string createdBy { get; set; }
public string createdDt { get; set; }
public string updatedBy { get; set; }
public string updatedDt { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MXBackgroundThread
{
public class SelectMaterialBarDto
{
public string materialBar { get; set; }
public string warehouseCode { get; set; }
public string warehouseName { get; set; }
}
public class SelectMaterialBarResponse
{
/// <summary>
///
/// </summary>
public int code { get; set; }
/// <summary>
///
/// </summary>
public string msg { get; set; }
/// <summary>
///
/// </summary>
public SelectMaterialBarDto data { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.MatInventoryDetail
{
public class CompareMatInventoryDetailRequest : RequestBase
{
public List<string> MatSns { get; set; }
public string GroupName { get; set; }
}
}

View File

@ -10,12 +10,10 @@ namespace WCS.Model.ApiModel.MatInventoryDetail
public string MatName { get; set; }
public string MatSpec { get; set; }
public string MatBatch { get; set; }
public string MatSupplier { get; set; }
public string MatCustomer { get; set; }
public int ShelfTypeId { get; set; }
}
}

View File

@ -5,7 +5,7 @@ using System.Text;
namespace WCS.Model.ApiModel.MatInventoryDetail
{
public class MatInventorySummaryModel: INotifyPropertyChanged
public class MatInventorySummaryModel : INotifyPropertyChanged
{
public string MatCode { get; set; }
@ -33,6 +33,9 @@ namespace WCS.Model.ApiModel.MatInventoryDetail
}
}
public string Info { get; set; }
public bool IsSelected
{

View File

@ -13,5 +13,7 @@ namespace WCS.Model
public string OrderSource { get; set; }
public string OrderType { get; set; }
public int ShelfTypeId { get; set; } = 0;
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.OutStore
{
public class OutImportMatModel
{
public string { get; set; }
public string { get; set; }
public string { get; set; }
public int { get; set; }
}
}

View File

@ -17,6 +17,15 @@ namespace WCS.Model
/// </summary>
public string OrderType { get; set; }
/// <summary>
/// 货架类型Id
/// </summary>
public int ShelfTypeId { get; set; } = 0;
/// <summary>
/// 货架类型名称
/// </summary>
public string ShelfTypeName { get; set; } = string.Empty;
public List<MatCodeItemList> ItemList { get; set; }
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.StoreInfo
{
public class DisableOrEnableModuleRequest : RequestBase
{
public int ModuleId { get; set; }
public string ModuleCode { get; set; }
public DisableOrEnableEnum DisableOrEnable { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.StoreInfo
{
public class DisableOrEnableStoreRequest : RequestBase
{
public int StoreId { get; set; }
public string SroreCode { get; set; }
public DisableOrEnableEnum DisableOrEnable { get; set; }
}
public enum DisableOrEnableEnum
{
Disable = 0,
Enable = 1
}
}

View File

@ -24,7 +24,7 @@ namespace WCS.Model.ApiModel.StoreInfo
public string C { get; set; }
public string? Bigshelfcode { get; set; }
public string? BigShelfCode { get; set; }
public bool IsEnable { get; set; }

View File

@ -49,7 +49,7 @@ namespace WCS.Model.ApiModel.StoreInfo
public bool IsBind { get; set; }
public string BindShelfCode { get; set; } = string.Empty;
public string BigShelfCode { get; set; }
public int RowNumber { get; set; }

View File

@ -14,5 +14,9 @@ namespace WCS.Model.ApiModel.User
/// 是否配置为不登陆(如果不登陆 直接获取admin 且不验证密码了)
/// </summary>
public bool IsNoLogin { get; set; } = false;
public string WebSocketIpAddress { get; set; } = string.Empty;
public List<string> GroupNames { get; set; }
}
}

View File

@ -4,7 +4,7 @@ using System.Text;
namespace WCS.Model.WebSocketModel
{
public class SolveWarningRequest
public class SolveWarningRequest : RequestBase
{
public Guid Guid { get; set; }
public SolveTypeEnum SolveType { get; set; }

View File

@ -25,6 +25,12 @@ namespace WCS.Model.WebSocketModel
//恢复正常需要消除的报警guid
public List<Guid> SolvedGuids { get; set; }
/// <summary>
/// 异常处理人
/// </summary>
public string SolvedUser { get; set; }
}
public enum WarningTypeEnum

View File

@ -0,0 +1,83 @@
using Microsoft.AspNetCore.Mvc;
using NPOI.HPSF;
using WCS.BLL.Services.IService;
using WCS.Model;
using WCS.Model.ApiModel;
using WCS.Model.ApiModel.User;
using WCS.Model.WebSocketModel;
namespace WCS.WebApi.Controllers
{
/// <summary>
/// 文件下载
/// </summary>
[ApiController]
[Route("[controller]")]
public class FileDownLoadController : ControllerBase
{
public FileDownLoadController()
{
}
[HttpGet("downloadApp")]
public IActionResult downloadApp(string fileName)
{
// 这里是文件的物理路径,你需要根据实际情况提供
var filePath = Path.Combine(Directory.GetCurrentDirectory(), $"Files/{fileName}");
// 检查文件是否存在
if (!System.IO.File.Exists(filePath))
{
return NotFound();
}
// 获取文件流
var stream = System.IO.File.OpenRead(filePath);
// 设置HTTP响应头使浏览器知道这是一个附件应该下载而不是打开
Response.Headers.Add("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
// 返回文件流作为FileResult
return File(stream, "application/octet-stream", fileName);
}
[HttpGet("getLatestAppName")]
public ResponseCommon<string> getLatestAppName()
{
string directoryPath = Path.Combine(AppContext.BaseDirectory, $"Files");
// 获取目录下的所有文件信息
FileInfo[] files = Directory.GetFiles(directoryPath, "*.APK")
.Select(file => new FileInfo(file))
.ToArray();
if (files == null || files.Length == 0)
{
return new ResponseCommon<string>()
{
Code = 201,
Message = "服务器不存在App安装包"
};
}
//获取最后修改的一个
FileInfo lastModifiedFile = files.OrderByDescending(f => f.LastWriteTime).First();
if (lastModifiedFile != null)
{
return new ResponseCommon<string>()
{
Code = 200,
Data = lastModifiedFile.Name
};
}
else
{
return new ResponseCommon<string>()
{
Code = 201,
Message = "服务器不存在App安装包"
};
}
}
}
}

View File

@ -86,5 +86,13 @@ namespace WCS.WebApi.Controllers
{
return await _matInventoryDetailService.getMatInventorySummary(request);
}
[Route("compareMatInventoryDetail")]
[HttpPost(Name = "compareMatInventoryDetail")]
public async Task<ResponseBase> compareMatInventoryDetail(CompareMatInventoryDetailRequest request)
{
return await _matInventoryDetailService.compareMatInventoryDetail(request);
}
}
}

View File

@ -1,9 +1,11 @@
using Microsoft.AspNetCore.Mvc;
using MiniExcelLibs;
using WCS.BLL.HardWare;
using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.BLL.Services.Service;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.OutStore;
namespace WebApi.Controllers
@ -15,12 +17,54 @@ namespace WebApi.Controllers
private readonly IOutstoreService _outstoreService;
private readonly IGenerateService _generateService;
public OutstoreController(IOutstoreService outstoreService,IGenerateService generateService)
public OutstoreController(IOutstoreService outstoreService, IGenerateService generateService)
{
_outstoreService = outstoreService;
_generateService = generateService;
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>У<EFBFBD><D0A3><EFBFBD>ͱȶ<CDB1>
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("importMat")]
[HttpPost(Name = "importMat")]
public async Task<ResponseBase> importMat([FromForm] IFormFile excelFile, [FromForm] string userName, [FromForm] string deviceType)
{
try
{
//<2F>ļ<EFBFBD>У<EFBFBD><D0A3>
if (excelFile == null || excelFile.Length == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = "<22><><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>:<3A>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD>ݣ<EFBFBD>"
};
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>
using (var stream = new MemoryStream())
{
await excelFile.CopyToAsync(stream);
stream.Position = 0;
var list = MiniExcelLibs.MiniExcel.Query<OutImportMatModel>(stream, "<22><><EFBFBD><EFBFBD><E2B5BC>ģ<EFBFBD><C4A3>", ExcelType.XLSX).ToList();
return await _outstoreService.importMat(list);
}
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 201,
Message = "<22><><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
};
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD><CFB1><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
@ -33,7 +77,7 @@ namespace WebApi.Controllers
try
{
if (string.IsNullOrEmpty(request.OrderNumber))
{
{
request.OrderNumber = await _generateService.generateOutOrderNumber();
}
return await _outstoreService.SysOutOrderByMatCode(request);

View File

@ -52,6 +52,13 @@ namespace WCS.WebApi.Controllers
{
return await _storeInfoService.GetModules(request);
}
[Route("disableOrEnableModule")]
[HttpPost(Name = "disableOrEnableModule")]
public async Task<ResponseBase> disableOrEnableModule(DisableOrEnableModuleRequest request)
{
return await _storeInfoService.disableOrEnableModule(request);
}
#endregion
#region
@ -61,6 +68,13 @@ namespace WCS.WebApi.Controllers
{
return await _storeInfoService.GetStores(request);
}
[Route("disableOrEnableStore")]
[HttpPost(Name = "disableOrEnableStore")]
public async Task<ResponseBase> disableOrEnableStore(DisableOrEnableStoreRequest request)
{
return await _storeInfoService.disableOrEnableStore(request);
}
#endregion
}
}

View File

@ -52,6 +52,8 @@ namespace WCS.WebApi.Controllers
[HttpPost(Name = "userLogin")]
public async Task<ResponseBase> userLogin(UserLoginRequest request)
{
//获取调用设备的Ip地址
request.WebSocketIpAddress = HttpContext?.Connection?.RemoteIpAddress?.ToString();
return await _userService.UserLogin(request);
}
}

View File

@ -7,9 +7,6 @@ using WCS.Model.WebSocketModel;
namespace WCS.WebApi.Controllers
{
/// <summary>
/// 权限/用户界面的接口
/// </summary>
[ApiController]
[Route("[controller]")]
public class WarningController : ControllerBase

View File

@ -20,58 +20,76 @@ namespace WebApi
{
public static void Main(string[] args)
{
WebSoceketManager.InitWebSocket();
DbInit.InitDb();
LocalFile.SaveConfig();
TCPClientManager.InitTcpClient();
ShelfManager.InitShelves();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ƺͰ<C6BA><CDB0><EFBFBD>
//TCPClientManager.InitStatus();
WarningManager.StartWarningMessageThread();
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IInstoreService, InstoreService>();
builder.Services.AddScoped<IOutstoreService, OutstoreService>();
builder.Services.AddScoped<IHomerService, HomerService>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IInterfaceRecordService, InterfaceRecordService>();
builder.Services.AddScoped<IMatBaseInfoService, MatBaseInfoService>();
builder.Services.AddScoped<IMatInventoryDetailService, MatInventoryDetailService>();
builder.Services.AddScoped<IStoreInfoService, StoreInfoService>();
builder.Services.AddScoped<IStockTakingService, StockTakingService>();
builder.Services.AddScoped<ISelfCheckService, SelfCheckService>();
builder.Services.AddScoped<IWarningService, WarningService>();
builder.Services.AddScoped<IInOutRecordService, InOutRecordService>();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA1A2><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ģʽ
builder.Services.AddSingleton<IGenerateService, GenerateService>();
var app = builder.Build();
app.UseMiddleware<RequestResponseLoggingMiddleware>();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
try
{
app.UseSwagger();
app.UseSwaggerUI();
}
//<2F><>ʼ<EFBFBD><CABC>websocket
WebSoceketManager.InitWebSocket();
app.UseAuthorization();
app.MapControllers();
app.Run("http://+:8888");
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
DbInit.InitDb();
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
LocalFile.SaveConfig();
//<2F><>ʼ<EFBFBD><CABC>TCP<43><50><EFBFBD><EFBFBD>
TCPClientManager.InitTcpClient();
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD>Ϣ
ShelfManager.InitShelves();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ط<EFBFBD><D8B7>߳<EFBFBD>
WarningManager.StartWarningMessageThread();
//<2F><>Ѷ<EFBFBD><D1B6>˾<EFBFBD><CBBE>̨<EFBFBD>߳<EFBFBD>
if (LocalFile.Config.IsMx)
{
MXBackgroundThread.InitBackgroundThread();
var str = string.Empty;
//MXBackgroundThread.SendDingDingMsg("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>", new List<string> { "104379" }, ref str);
}
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddScoped<IInstoreService, InstoreService>();
builder.Services.AddScoped<IOutstoreService, OutstoreService>();
builder.Services.AddScoped<IHomerService, HomerService>();
builder.Services.AddScoped<IUserService, UserService>();
builder.Services.AddScoped<IInterfaceRecordService, InterfaceRecordService>();
builder.Services.AddScoped<IMatBaseInfoService, MatBaseInfoService>();
builder.Services.AddScoped<IMatInventoryDetailService, MatInventoryDetailService>();
builder.Services.AddScoped<IStoreInfoService, StoreInfoService>();
builder.Services.AddScoped<IStockTakingService, StockTakingService>();
builder.Services.AddScoped<ISelfCheckService, SelfCheckService>();
builder.Services.AddScoped<IWarningService, WarningService>();
builder.Services.AddScoped<IInOutRecordService, InOutRecordService>();
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBA1A2><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ģʽ
builder.Services.AddSingleton<IGenerateService, GenerateService>();
var app = builder.Build();
app.UseMiddleware<RequestResponseLoggingMiddleware>();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseAuthorization();
app.MapControllers();
app.Run("http://0.0.0.0:8888");//0.0.0.0<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ipv4
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>false</DeleteExistingFiles>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
@ -13,5 +13,11 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<ProjectGuid>118d453b-1693-4c00-8378-20ecbfcf2700</ProjectGuid>
<SelfContained>false</SelfContained>
<PublishSingleFile>false</PublishSingleFile>
</PropertyGroup>
</Project>

View File

@ -18,4 +18,14 @@
<ProjectReference Include="..\WCS.Model\WCS.Model.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Files\" />
</ItemGroup>
<ItemGroup>
<None Update="Files\APP.app">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -13,6 +13,7 @@ using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using WCS.Model;
using WCS.Model.ApiModel.MXBackgroundThread;
namespace .Api
{
@ -282,11 +283,11 @@ namespace 货架标准上位机.Api
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)
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}",LogsType.Api);
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}", LogsType.Api);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = "application/json";
@ -320,5 +321,100 @@ namespace 货架标准上位机.Api
return default(T);
}
}
/// <summary>
/// 调用接口-长延时MX MES接口返回时间偶尔10秒+为保证业务能正常进行所以增加此接口)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="data"></param>
/// <param name="url"></param>
/// <param name="httpMethod"></param>
/// <param name="isSaveLog"></param>
/// <returns></returns>
public static ApiResult<T> MXGetDataFromHttpLongWait<T>(string data, string url, string httpMethod, bool isSaveLog = false)
{
Guid guid = Guid.NewGuid();
try
{
if (isSaveLog)
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = "application/json";
request.Timeout = 20000;
if (!string.IsNullOrEmpty(data))
{
string strContent = data; //参数data
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
{
dataStream.Write(strContent);
dataStream.Close();
}
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd();
if (isSaveLog)
Logs.Write($"【{guid}】请求调用接口结束 返回数据为{retString}");
return JsonConvert.DeserializeObject<ApiResult<T>>(retString);
}
catch (Exception ex)
{
Logs.Write($"【{guid}】请求调用遇到异常 异常信息为{ex.Message}");
return new ApiResult<T>()
{
code = 500,
message = ex.Message,
};
}
}
public static ApiResult<T> MXGetDataFromHttp<T>(string data, string url, string httpMethod, bool isSaveLog = false)
{
Guid guid = Guid.NewGuid();
try
{
if (isSaveLog)
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod;
request.ContentType = "application/json";
request.Timeout = 8000;
if (!string.IsNullOrEmpty(data))
{
string strContent = data; //参数data
using (StreamWriter dataStream = new StreamWriter(request.GetRequestStream()))
{
dataStream.Write(strContent);
dataStream.Close();
}
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8"; //默认编码
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd();
if (isSaveLog)
Logs.Write($"【{guid}】请求调用接口结束 返回数据为{retString}");
return JsonConvert.DeserializeObject<ApiResult<T>>(retString);
}
catch (Exception ex)
{
Logs.Write($"【{guid}】请求调用遇到异常 异常信息为{ex.Message}");
return new ApiResult<T>()
{
code = 500,
message = ex.Message,
};
}
}
}
}

View File

@ -2,7 +2,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:货架标准上位机"
StartupUri="Views/MainWindows/MainWindow1.xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:hc="https://handyorg.github.io/handycontrol">
<Application.Resources>

View File

@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Management.Instrumentation;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
namespace
{
@ -13,5 +15,20 @@ namespace 货架标准上位机
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
if (LocalFile.Config.IsMx)
{
MainWindow = new MXMainWindow();
}
else
{
MainWindow = new MainWindow1();
}
MainWindow.ShowDialog();
}
}
}

Binary file not shown.

View File

@ -19,6 +19,10 @@ namespace 货架标准上位机
/// 货架服务器的Ip和端口号
/// </summary>
public string ApiIpHost { get; set; }
/// <summary>
/// WebSocket服务器的地址
/// </summary>
public string WebSocketUrl { get; set; }
public List<string> GroupName { get; set; }
@ -41,6 +45,26 @@ namespace 货架标准上位机
/// 串口扫码枪延时
/// </summary>
public int ScannerTimeOut { get; set; }
#region
public bool IsMx { get; set; }
/// <summary>
///MX-获取要料单接口地址
/// </summary>
public string GetPickOrderUrl { get; set; }
/// <summary>
///MX-获取要料明细接口地址
/// </summary>
public string RecommendedBarCode { get; set; }
/// <summary>
///MX-首盘发料明细接口地址
/// </summary>
public string FirstSendRecommendedBarCode { get; set; }
/// <summary>
///MX-后续发料明细接口地址
/// </summary>
public string ElectronicSiloPush { get; set; }
#endregion
}
public class JsSysConfig

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net472\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
</PropertyGroup>
</Project>

View File

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

View File

@ -28,6 +28,7 @@ using System.Collections.ObjectModel;
using WCS.BLL.DbModels;
using WCS.Model.ApiModel.MatBaseInfo;
using System.Security.Cryptography;
using Ping9719.WpfEx;
namespace .ViewModel
{
@ -148,6 +149,7 @@ namespace 货架标准上位机.ViewModel
if (Result != null && Result.Code == 200)
{
Logs.Write($"货架{scanner.ShelfCode}已成功退出入库!", LogsType.Scanner);
scanner.IsInstoreMode = false;
scanner.ShelfCode = string.Empty;
scanner.ModulesStr = string.Empty;
}
@ -228,6 +230,7 @@ namespace 货架标准上位机.ViewModel
var Result = ApiHelp.GetDataFromHttp<ResponseBase>(LocalFile.Config.ApiIpHost + "instore/shelfGoOutInStore", body, "POST");
if (Result != null && Result.Code == 200)
{
scanner.IsInstoreMode = false;
scanner.ShelfCode = string.Empty;
scanner.ModulesStr = string.Empty;
@ -259,6 +262,33 @@ namespace 货架标准上位机.ViewModel
if (Result != null && Result.Code == 200)
{
scanner.MatSn = Result.Data.MatSN;
#region
Task.Run(() =>
{
try
{
var body = new QueryByMatSnRequest()
{
MatSn = scanner.MatSn,
ShelfCode = scanner.ShelfCode,
IpAddress = scanner.COM,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<MatInfoModel>>(LocalFile.Config.ApiIpHost + "instore/queryInstoreStatus", body, "POST");
if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
TextBoxLog.AddLog($"物料[{scanner.MatSn}]" + Result.Message, "InstoreLog", DateTime.Now);
scanner.MatSn = string.Empty;
scanner.ScannerDisplayControl.RefreshValues(scanner.ShelfCode, scanner.MatSn);
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
});
#endregion
}
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
{

View File

@ -0,0 +1,305 @@
using HandyControl.Controls;
using HandyControl.Data;
using MiniExcelLibs;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using TouchSocket.Core;
using WCS.Model;
using WCS.Model.ApiModel.OutStore;
using WCS.Model.ApiModel.Stocktaking;
using .Api;
using .ViewModel;
namespace .ViewModel
{
public class MXOutInventoryViewModel : BindableBase
{
public MXOutInventoryViewModel()
{
RefreshOutOrderList();
}
#region Property
private OutOrderModel selectedOutOrder;
public OutOrderModel SelectedOutOrder
{
get { return selectedOutOrder; }
set
{
SetProperty(ref selectedOutOrder, value);
if (selectedOutOrder != null)
{
SelectedOutOrderNumber = selectedOutOrder.OrderNumber;
RefreshDataGridItemSource();
}
else
{
DataGridItemSource?.Clear();
}
}
}
private string selectedOutOrderNumber;
public string SelectedOutOrderNumber
{
get => selectedOutOrderNumber;
set
{
SetProperty(ref selectedOutOrderNumber, value);
}
}
private ObservableCollection<OutOrderModel> outOrderList;
public ObservableCollection<OutOrderModel> OutOrderList
{
get => outOrderList;
set
{
SetProperty(ref outOrderList, value);
}
}
private ObservableCollection<OutOrderMatDetailModel> dataGridItemSource;
public ObservableCollection<OutOrderMatDetailModel> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
RefreshCount();
}
}
//单据总盘数
private int totalPan;
public int TotalPan
{
get => totalPan; set
{
SetProperty(ref totalPan, value);
}
}
private int sendedPan;
public int SendedPan
{
get => sendedPan; set
{
SetProperty(ref sendedPan, value);
}
}
private string orderStatus;
public string OrderStatus
{
get { return orderStatus; }
set
{
SetProperty(ref orderStatus, value);
}
}
public void RefreshCount()
{
Task.Run(() =>
{
SendedPan = dataGridItemSource.Where(t => t.IsSended).Count();
TotalPan = dataGridItemSource.Count();
});
}
#endregion
#region Command
public ICommand BtnOutOrderCommand { get => new DelegateCommand(BtnOutOrder); }
public void BtnOutOrder()
{
var window = new MXOutOrderView();
window.Owner = Application.Current.MainWindow;
window.ShowDialog();
}
public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); }
public void BtnStart()
{
try
{
//判断是否选择单据
if (SelectedOutOrder == null)
{
Growl.Warning("未选择单据!");
return;
}
#region
var body = new GetOutOrderDetailRequest()
{
OrderId = selectedOutOrder.Id,
OrderNumber = selectedOutOrder.OrderNumber,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goInOutstore", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Warning("已成功开始出库!");
RefreshDataGridItemSource();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
#endregion
}
catch (Exception ex)
{
Growl.Error("出现异常:" + ex.Message);
}
finally
{
}
}
public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
public void BtnPause()
{
try
{
//判断是否选择单据
if (SelectedOutOrder == null)
{
Growl.Warning("未选择单据!");
return;
}
#region
var body = new GetOutOrderDetailRequest()
{
OrderId = selectedOutOrder.Id,
OrderNumber = selectedOutOrder.OrderNumber,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goOutOutstore", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Warning("已成功结束出库!");
RefreshDataGridItemSource();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
#endregion
}
catch (Exception ex)
{
Growl.Error("出现异常:" + ex.Message);
}
finally
{
}
}
public void RefreshOutOrderList(string OrderNumber = "")
{
#region
try
{
var body = new GetOutOrderListByStatusRequest()
{
OrderExeStatus = new List<OutOrderExeStatus>() { OutOrderExeStatus., OutOrderExeStatus. }
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<OutOrderModel>>(LocalFile.Config.ApiIpHost + "outstore/getOutOrderListByStatus", body, "POST");
if (Result != null && Result.Code == 200)
{
OutOrderList = new ObservableCollection<OutOrderModel>(Result.Data.Lists);
if (!string.IsNullOrEmpty(OrderNumber))
{
SelectedOutOrder = OutOrderList.Where(t => t.OrderNumber == OrderNumber).FirstOrDefault();
}
}
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
Growl.Warning(Result.Message);
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
#endregion
}
public void RefreshDataGridItemSource()
{
if (SelectedOutOrder == null)
{
//选择的单据为空无法进行查询
return;
}
#region
Task.Run(() =>
{
var body = new GetOutOrderDetailRequest()
{
OrderId = selectedOutOrder.Id,
OrderNumber = selectedOutOrder.OrderNumber,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<OutOrderMatDetailModel>>>(LocalFile.Config.ApiIpHost + "outStore/getOutOrderMatDetail", body, "POST");
if (Result != null && Result.Code == 200)
{
if (Result.Data.Count > 0)
{
DataGridItemSource = new ObservableCollection<OutOrderMatDetailModel>(Result.Data);
OrderStatus = Result.Message;
}
else
{
App.Current.Dispatcher.Invoke(() =>
{
DataGridItemSource?.Clear();
});
Growl.Warning("该单据未查询到发料明细!");
}
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
});
#endregion
}
#endregion
}
}

View File

@ -0,0 +1,216 @@
using HandyControl.Controls;
using HandyControl.Data;
using MiniExcelLibs;
using Newtonsoft.Json;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using TouchSocket.Core;
using System.Windows.Markup;
using System.Security.Policy;
using WCS.Model.ApiModel.MXBackgroundThread;
using ;
using WCS.Model.ApiModel.MatInventoryDetail;
using .Api;
using System.Runtime.CompilerServices;
using WCS.Model;
namespace .ViewModel
{
public class MXOutOrderDetailViewViewModel : BindableBase
{
/// <summary>
///
/// </summary>
/// <param name="billNumber"></param>
/// <param name="warehouseCode"></param>
/// <param name="orderProdNumbers"></param>
/// <param name="orderWorkNumbers"></param>
/// <param name="isFirstSend">是否是首盘发料</param>
public MXOutOrderDetailViewViewModel(
string billNumber, string warehouseCode
, string orderProdNumbers, string orderWorkNumbers
, int isFirstSend = 0, string reportSide = null
)
{
BillNumber = billNumber;
OrderProdNumbers = orderProdNumbers;
OrderWorkNumbers = orderWorkNumbers;
WarehouseCode = warehouseCode;
Task.Run(() =>
{
var request = new RecommendedBarCodeRequest()
{
pickBillNumber = billNumber,
warehouseCode = warehouseCode,
warehouseType = 20
};
var requeststr = JsonConvert.SerializeObject(request);
var url = string.Empty;
if (isFirstSend == 0)
{
url = LocalFile.Config.RecommendedBarCode;
}
else if (isFirstSend == 1)
{
request = new FistPushRecommendedBarCodeRequest()
{
pickBillNumber = billNumber,
warehouseCode = warehouseCode,
warehouseType = 20,
reportSide = reportSide,
};
requeststr = JsonConvert.SerializeObject(request);
url = LocalFile.Config.FirstSendRecommendedBarCode;
}
//后续料
else
{
url = LocalFile.Config.ElectronicSiloPush;
}
var result = ApiHelp.MXGetDataFromHttp<List<PickOrderDetailGetReturnList>>(requeststr, url, "POST", true);
if (result != null && result.code == 200 && result.data != null && result.data.Count() > 0)
{
//获取推荐的条码
var matSns = result.data.Select(t => t.materialBar).ToList();
//调用 比对库存数据 获取库存中有的数据
#region
try
{
var body = new CompareMatInventoryDetailRequest()
{
MatSns = matSns,
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<MatInventoryDetailModel>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/compareMatInventoryDetail", body, "POST", true);
//查询到物料信息
if (Result != null && Result.Data != null && Result.Data.Lists != null && Result.Data.Lists.Count != 0)
{
DataGridItemSource = Result.Data.Lists;
}
else if (Result != null && Result.Code == 200 && (Result.Data == null || Result.Data.Lists == null || Result.Data.Lists.Count == 0))
{
MessageBox.Show($"未查询到领料明细!所推荐物料在此货架上不存在,请确认是否在其他货架上!\r\n{string.Join(",\r\n", matSns)}");
DataGridItemSource = null;
}
else
{
MessageBox.Show($"未查询到领料明细!请重试!");
DataGridItemSource = null;
}
}
catch (Exception e)
{
MessageBox.Show($"未查询到领料明细!请重试!");
DataGridItemSource = null;
}
#endregion
}
else if (result != null && result.code == 200 && (result.data == null || result.data.Count == 0))
{
Growl.Warning("未查询到物料明细MES推荐物料明细为空");
DataGridItemSource = null;
}
else
{
Growl.Warning("未查询到领料明细请求MES接口失败");
DataGridItemSource = null;
}
});
}
#region Property
private int selectedCount;
public int SelectedCount
{
get { return selectedCount; }
set { SetProperty(ref selectedCount, value); }
}
private int selectedPan;
public int SelectedPan
{
get { return selectedPan; }
set { SetProperty(ref selectedPan, value); }
}
//发料单号
private string billNumber;
public string BillNumber
{
get { return billNumber; }
set { SetProperty(ref billNumber, value); }
}
//订单号
private string orderProdNumbers;
public string OrderProdNumbers
{
get { return orderProdNumbers; }
set { SetProperty(ref orderProdNumbers, value); }
}
//工单号
private string orderWorkNumbers;
public string OrderWorkNumbers
{
get { return orderWorkNumbers; }
set { SetProperty(ref orderWorkNumbers, value); }
}
//输入的仓库代码
private string warehouseCode;
public string WarehouseCode
{
get { return warehouseCode; }
set
{
SetProperty(ref warehouseCode, value);
}
}
private List<MatInventoryDetailModel> dataGridItemSource;
public List<MatInventoryDetailModel> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
RefreshCount();
}
}
public void RefreshCount()
{
Task.Run(() =>
{
try
{
SelectedCount = dataGridItemSource.Where(t => t.IsSelected == true).Sum(t => t.MatQty);
SelectedPan = dataGridItemSource.Where(t => t.IsSelected == true).Count();
}
catch { }
});
}
#endregion
#region Command
#endregion
}
}

View File

@ -0,0 +1,132 @@
using HandyControl.Controls;
using HandyControl.Data;
using MiniExcelLibs;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using TouchSocket.Core;
using Newtonsoft.Json;
using WCS.Model.ApiModel.MXBackgroundThread;
using .Api;
namespace .ViewModel
{
public class MXOutOrderViewModel : BindableBase
{
public MXOutOrderViewModel()
{
}
#region Property
private string matCode1;
public string MatCode1
{
get { return matCode1; }
set
{
SetProperty(ref matCode1, value);
}
}
private string orderProdNumber;
public string OrderProdNumber
{
get { return orderProdNumber; }
set
{
SetProperty(ref orderProdNumber, value);
}
}
private string orderWorkNumber;
public string OrderWorkNumber
{
get { return orderWorkNumber; }
set
{
SetProperty(ref orderWorkNumber, value);
}
}
private string pickBillNumber;
public string PickBillNumber
{
get { return pickBillNumber; }
set
{
SetProperty(ref pickBillNumber, value);
}
}
private string warehouseCode;
public string WarehouseCode
{
get { return warehouseCode; }
set
{
SetProperty(ref warehouseCode, value);
}
}
private List<PickOrder> dataGridItemSource;
public List<PickOrder> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
}
}
#endregion
#region Command
public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearch); }
public void BtnSearch()
{
Task.Run(() =>
{
var request = new PickOrderRequest()
{
orderProdNumber = OrderProdNumber,
orderWorkNumber = OrderWorkNumber,
pickBillNumber = PickBillNumber
};
var requeststr = JsonConvert.SerializeObject(request);
var result = ApiHelp.MXGetDataFromHttpLongWait<List<PickOrder>>(requeststr, LocalFile.Config.GetPickOrderUrl, "POST");
if (result != null && result.code == 200 && result.data != null && result.data.Count() > 0)
{
DataGridItemSource = result.data;
}
else if (result != null && result.code == 200 && (result.data == null || result.data.Count == 0))
{
result.message = "输入的搜索条件未查询到发料单信息!";
Growl.Warning(result.message);
DataGridItemSource = result.data;
}
else
{
Growl.Warning("调用MES接口超时搜索失败");
}
});
}
#endregion
}
}

View File

@ -227,18 +227,6 @@ namespace 货架标准上位机.ViewModel
//已经选择文件 调用接口进行导入数据
string path = ofd.FileName;
var body = new GetMatBaseInfoRequest()
{
MatCode = MatCode,
MatName = MatName,
MatSpec = MatSpec,
IsEnable = IsEnable,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
PageNumber = CurrentPage,
PageSize = 65535,
};
var result = await ApiHelp.PostImportFileAsync<ResponseCommon<List<string>>>(path, System.Net.Http.HttpMethod.Post,
LocalFile.Config.ApiIpHost + "matBaseInfo/importMatBaseInfo", LocalStatic.CurrentUser, LocalFile.Config.DeviceType);
if (result.Code == 200)

View File

@ -33,14 +33,7 @@ namespace 货架标准上位机.ViewModel
{
public MatInventoryDetailViewModel()
{
//获取物料编码列表
//matCodes = DbHelp.db.Queryable<InventoryDetail>()
// .Select(t => new DataModel()
// {
// MatCode = t.MatCode
// })
// .Distinct()
// .ToList();
}
public void InitMatCode()

View File

@ -19,6 +19,7 @@ using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.User;
using WCS.Model.ApiModel;
using Newtonsoft.Json.Bson;
using System.Windows;
namespace .ViewModel
{
@ -75,7 +76,7 @@ namespace 货架标准上位机.ViewModel
public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); }
public void BtnReset()
{
ModuleCode = string.Empty;
ModuleCode = string.Empty;
ShelfCode = string.Empty;
}
@ -96,9 +97,10 @@ namespace 货架标准上位机.ViewModel
var dia = Dialog.Show(new TextDialog());
try
{
var body = new GetShelvesRequest()
var body = new GetModulesRequest()
{
ShelfCode = ShelfCode,
ModuleCode = ModuleCode,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
PageNumber = CurrentPage,
@ -153,6 +155,97 @@ namespace 货架标准上位机.ViewModel
}
}
}
public ICommand DisableCommand { get => new DelegateCommand<ModuleInfoModel>(Disable); }
public void Disable(ModuleInfoModel module)
{
if (module.IsEnable != true)
{
Growl.Warning("库位未被启用!");
return;
}
var result = HandyControl.Controls.MessageBox.Show("模组禁用会影响正常流程,请确认是否屏蔽?"
, "提示", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
#region
try
{
var body = new DisableOrEnableModuleRequest()
{
ModuleId = module.Id,
ModuleCode = module.ModuleCode,
DisableOrEnable = DisableOrEnableEnum.Disable,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableModule", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success("禁用成功");
BtnSearch();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("操作失败:请重试!");
}
}
catch (Exception ex)
{
Growl.Error("操作失败:" + ex.Message);
}
#endregion
}
else
{
return;
}
}
public ICommand EnableCommand { get => new DelegateCommand<ModuleInfoModel>(Enable); }
public void Enable(ModuleInfoModel module)
{
if (module.IsEnable == true)
{
Growl.Warning("库位未被禁用!");
return;
}
#region
try
{
var body = new DisableOrEnableModuleRequest()
{
ModuleId = module.Id,
ModuleCode = module.ModuleCode,
DisableOrEnable = DisableOrEnableEnum.Enable,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableModule", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success("操作成功!");
BtnSearch();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("操作失败:请重试!");
}
}
catch (Exception ex)
{
Growl.Error("操作失败:" + ex.Message);
}
#endregion
}
#endregion
#region PageOperation

View File

@ -4,10 +4,12 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.Home;
using WCS.Model.ApiModel.MatInventoryDetail;
using .Api;
@ -35,6 +37,71 @@ namespace 货架标准上位机.ViewModels
SetProperty(ref selectedItemSource, value);
}
}
private List<ShelfTypeModel> shelfTypeItems;
public List<ShelfTypeModel> ShelfTypeItems
{
get { return shelfTypeItems; }
set
{
SetProperty(ref shelfTypeItems, value);
}
}
public void InitShelfTypeItems()
{
//调用接口更新!
Task.Run(() =>
{
var body = new RequestBase()
{
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<ShelfTypeModel>>(LocalFile.Config.ApiIpHost + "home/getShelfTypes", body, "POST");
if (Result != null && Result.Data != null && Result.Data.Lists.Count() > 0)
{
ShelfTypeItems = Result.Data.Lists;
SelectedShelfTypeItem = Result.Data.Lists.First();
}
});
}
private ShelfTypeModel selectedShelfTypeItem;
public ShelfTypeModel SelectedShelfTypeItem
{
get { return selectedShelfTypeItem; }
set
{
SetProperty(ref selectedShelfTypeItem, value);
}
}
private int selectedTypeCount = 0;
public int SelectedTypeCount
{
get => selectedTypeCount;
set
{
SetProperty(ref selectedTypeCount, value);
if (selectedTypeCount == 0)
{
ShelfTypeIsEnabled = true;
}
else
{
ShelfTypeIsEnabled = false;
}
}
}
private bool shelfTypeIsEnabled = true;
public bool ShelfTypeIsEnabled
{
get => shelfTypeIsEnabled; set { SetProperty(ref shelfTypeIsEnabled, value); }
}
#endregion
#region Command
@ -44,7 +111,11 @@ namespace 货架标准上位机.ViewModels
public ICommand BtnAddCommand { get => new DelegateCommand(BtnAdd); }
public void BtnAdd()
{
var window = new OutInventoryAddMatView();
if (SelectedShelfTypeItem == null)
{
HandyControl.Controls.MessageBox.Show("请选择货架类型!");
}
var window = new OutInventoryAddMatView(SelectedShelfTypeItem.Id);
window.Owner = Application.Current.MainWindow;
var result = window.ShowDialog();
if (result == true)
@ -52,6 +123,7 @@ namespace 货架标准上位机.ViewModels
if (DataGridItemSource == null)
DataGridItemSource = new ObservableCollection<MatInventorySummaryModel>();
DataGridItemSource.Add(window.inventorySummary);
SelectedTypeCount = DataGridItemSource.Count;
}
else
{
@ -66,11 +138,12 @@ namespace 货架标准上位机.ViewModels
{
DataGridItemSource.Remove(obj);
;
SelectedTypeCount = DataGridItemSource.Count;
}
catch (Exception ex)
{
Growl.Info(ex.Message);
Logs.Write($"删除物料时发生异常", LogsType.Err);
}
}
@ -117,6 +190,8 @@ namespace 货架标准上位机.ViewModels
{
OrderType = "出库",
OrderSource = "WCS前端",
ShelfTypeId = SelectedShelfTypeItem.Id,
ShelfTypeName = SelectedShelfTypeItem.ShelfTypeName,
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
{
MatCode = t.MatCode,

View File

@ -58,6 +58,14 @@ namespace 货架标准上位机.ViewModels
SetProperty(ref matName, value);
}
}
private int shelfTypeId;
public int ShelfTypeId
{
get => shelfTypeId;
set { SetProperty(ref shelfTypeId, value); }
}
#endregion
#region Command
@ -74,6 +82,7 @@ namespace 货架标准上位机.ViewModels
{
MatName = MatName,
MatCode = MatCode,
ShelfTypeId = ShelfTypeId,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<MatInventorySummaryModel>>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/getMatInventorySummary", body, "POST");
if (Result != null && Result.Data != null)

View File

@ -144,6 +144,17 @@ namespace 货架标准上位机.ViewModels
BtnSearch(true);
}
//导入出库
public ICommand BtnImportDocumentCommand { get => new DelegateCommand(BtnImportDocument); }
public void BtnImportDocument()
{
var window = new OutInventoryImportDucumentView();
window.Owner = Application.Current.MainWindow;
var result = window.ShowDialog();
if (result == true)
BtnSearch(true);
}
public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); }
public void BtnOrderDetail()
{

View File

@ -0,0 +1,212 @@
using HandyControl.Controls;
using Ping9719.WpfEx.Mvvm;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Input;
using WCS.BLL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.MatInventoryDetail;
using .Api;
namespace .ViewModels
{
public class OutInventoryImportDucumentViewModel : BindableBase
{
#region Property
private ObservableCollection<MatInventorySummaryModel> dataGridItemSource;
public ObservableCollection<MatInventorySummaryModel> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
}
}
private MatInventorySummaryModel selectedItemSource;
public MatInventorySummaryModel SelectedItemSource
{
get { return selectedItemSource; }
set
{
SetProperty(ref selectedItemSource, value);
}
}
#endregion
#region Command
public ICommand BtnDownloadExcelCommand { get => new DelegateCommand(BtnDownloadExcel); }
public async void BtnDownloadExcel()
{
try
{
#region
Microsoft.Win32.SaveFileDialog sfd = new Microsoft.Win32.SaveFileDialog();
sfd.Filter = ".xlsx文件(*.xlsx)|*.xlsx";
sfd.FileName = "出库导入模板";
sfd.Title = "请选择文件保存地址";
sfd.OverwritePrompt = true;
if (sfd.ShowDialog() != true)
{
return;
}
string path = sfd.FileName;
#endregion
#region
string sourceFile = System.Environment.CurrentDirectory + "\\Excel\\出库单据导入模板.xlsx"; // 源文件路径
string destinationFile = path; // 目标文件路径
try
{
File.Copy(sourceFile, destinationFile, true); // true表示如果目标文件存在则覆盖它
Growl.Success("文件下载成功!");
}
catch (IOException ioEx)
{
Growl.Success("文件下载失败: " + ioEx.Message);
}
catch (Exception ex)
{
Growl.Success("文件下载失败: " + ex.Message);
}
#endregion
}
catch (Exception ex)
{
Growl.Error("导出失败:" + ex.Message);
}
}
public ICommand BtnImportCommand { get => new DelegateCommand(BtnImport); }
public async void BtnImport()
{
try
{
#region
Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
ofd.Title = "选择模板";
ofd.Filter = ".xlsx文件(*.xlsx)|*.xlsx";
ofd.Multiselect = false;
if (ofd.ShowDialog() != true)
{
return;
}
#endregion
//已经选择文件 调用接口进行导入数据
string path = ofd.FileName;
#region
var result = await ApiHelp.PostImportFileAsync<ResponseCommon<List<MatInventorySummaryModel>>>(path, System.Net.Http.HttpMethod.Post,
LocalFile.Config.ApiIpHost + "outstore/importMat", LocalStatic.CurrentUser, LocalFile.Config.DeviceType);
if (result.Code == 200)
{
DataGridItemSource = new ObservableCollection<MatInventorySummaryModel>(result.Data);
}
else
{
if (result != null && !string.IsNullOrEmpty(result.Message))
HandyControl.Controls.MessageBox.Show(result.Message);
else
{
HandyControl.Controls.MessageBox.Show("导入失败,请重试!");
}
}
#endregion
}
catch (Exception ex)
{
Growl.Warning("导入失败:" + ex.Message);
}
}
public ICommand DelCommand { get => new DelegateCommand<MatInventorySummaryModel>(Del); }
public void Del(MatInventorySummaryModel obj)
{
try
{
DataGridItemSource.Remove(obj);
;
}
catch (Exception ex)
{
}
}
// 定义一个事件,当需要关闭窗口时触发
public event Action TrueClose;
public event Action FalseClose;
// 一个方法,当满足某些条件时调用,以触发关闭窗口
protected virtual void OnRequestClose(bool IsTrue)
{
if (IsTrue)
TrueClose?.Invoke();
else
FalseClose?.Invoke();
}
public ICommand GenerateOutOrderCommand { get => new DelegateCommand(GenerateOutOrder); }
public void GenerateOutOrder()
{
//数据校验
if (DataGridItemSource == null || DataGridItemSource.Count == 0)
{
HandyControl.Controls.MessageBox.Show("选择的物料为空无法生成出库单!");
return;
}
foreach (var itemSource in DataGridItemSource)
{
if (itemSource.NeedQty == 0)
{
Growl.Warning("需求数量未填!");
SelectedItemSource = itemSource;
return;
}
}
#region
try
{
var body = new SysOutOrderByMatCodeRequest()
{
OrderType = "出库",
OrderSource = "WCS前端",
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
{
MatCode = t.MatCode,
MatName = t.MatName,
MatBatch = t.MatBatch,
ReqQty = t.NeedQty,
}).ToList(),
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success(Result.Message);
OnRequestClose(true);
}
else if (Result != null)
{
Growl.Warning(Result.Message);
return;
}
}
catch (Exception ex)
{
Growl.Error("加载数据失败:" + ex.Message);
}
finally
{
}
#endregion
}
#endregion
}
}

View File

@ -1,15 +1,26 @@
using HandyControl.Controls;
using HandyControl.Tools.Extension;
using Microsoft.Win32;
using Ping9719.WpfEx.Mvvm;
using QRCoder;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO.Ports;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media.Imaging;
using WCS.Model;
using .Api;
using .Views.Controls;
using static System.Net.WebRequestMethods;
namespace .ViewModel
{
@ -215,5 +226,61 @@ namespace 货架标准上位机.ViewModel
{
}
}
public ICommand AppQRCodeCommand { get => new DelegateCommand(AppQRCode); }
public void AppQRCode()
{
try
{
#region App名称
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "fileDownload/getLatestAppName", null, "GET");
if (Result != null && Result.Code == 200)
{
//拼凑url
var downLoadUrl = LocalFile.Config.ApiIpHost + $"fileDownload/downloadApp?fileName={Result.Data}";
//生成二维码
var qrCodeImage = GenerateQRCode(downLoadUrl);
//展示二维码
Dialog.Show(new ImageDialog(qrCodeImage));
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
#endregion
}
catch
{
}
}
public BitmapImage GenerateQRCode(string data)
{
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode(data, QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.Black, Color.White, true);
// 将System.Drawing.Bitmap转换为System.Windows.Media.Imaging.BitmapImage
using (var memoryStream = new MemoryStream())
{
// 假设Bitmap的Save方法支持Png格式通常是这样
qrCodeImage.Save(memoryStream, ImageFormat.Png);
memoryStream.Position = 0;
var bitmapImage = new BitmapImage();
bitmapImage.BeginInit();
bitmapImage.StreamSource = memoryStream;
bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
bitmapImage.EndInit();
// 返回BitmapImage
return bitmapImage;
}
}
}
}

View File

@ -33,7 +33,7 @@ namespace 货架标准上位机.ViewModel
ClientIp = shelfInfoModel.ClientIp;
GroupName = shelfInfoModel.GroupName;
IsBind = shelfInfoModel.IsBind;
BindShelfCode = shelfInfoModel.BindShelfCode;
BigShelfCode = shelfInfoModel.BigShelfCode;
}
}
@ -51,7 +51,7 @@ namespace 货架标准上位机.ViewModel
ClientIp = ClientIp,
GroupName = GroupName,
IsBind = IsBind,
BindShelfCode = BindShelfCode,
BigShelfCode = BigShelfCode,
};
}
@ -156,13 +156,13 @@ namespace 货架标准上位机.ViewModel
}
}
private string bindShelfCode;
public string BindShelfCode
private string bigShelfCode;
public string BigShelfCode
{
get { return bindShelfCode; }
get { return bigShelfCode; }
set
{
SetProperty(ref bindShelfCode, value);
SetProperty(ref bigShelfCode, value);
}
}
#endregion

View File

@ -19,6 +19,8 @@ using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.User;
using WCS.Model.ApiModel;
using Newtonsoft.Json.Bson;
using System.Windows;
using System.Security.Cryptography;
namespace .ViewModel
{
@ -140,6 +142,94 @@ namespace 货架标准上位机.ViewModel
}
#endregion
}
public ICommand DisableCommand { get => new DelegateCommand<StoreInfoModel>(Disable); }
public void Disable(StoreInfoModel store)
{
var result = HandyControl.Controls.MessageBox.Show("库位屏蔽仅用于临时屏蔽硬件损坏识别的未扫描上架!\r\n" +
"操作时会删除对应库位的数据,需要保证对应库位物料已取出。\r\n" +
"请确认是否进行操作?"
, "提示", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
#region
try
{
var body = new DisableOrEnableStoreRequest()
{
StoreId = store.Id,
SroreCode = store.StoreCode,
DisableOrEnable = DisableOrEnableEnum.Disable,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableStore", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success("禁用成功");
BtnSearch();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("操作失败:请重试!");
}
}
catch (Exception ex)
{
Growl.Error("操作失败:" + ex.Message);
}
#endregion
}
else
{
return;
}
}
public ICommand EnableCommand { get => new DelegateCommand<StoreInfoModel>(Enable); }
public void Enable(StoreInfoModel store)
{
if (store.CurrentMatSn != "禁用")
{
Growl.Warning("库位未被禁用!");
return;
}
#region
try
{
var body = new DisableOrEnableStoreRequest()
{
StoreId = store.Id,
SroreCode = store.StoreCode,
DisableOrEnable = DisableOrEnableEnum.Enable,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "storeInfo/disableOrEnableStore", body, "POST");
if (Result != null && Result.Code == 200)
{
Growl.Success("操作成功!");
BtnSearch();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("操作失败:请重试!");
}
}
catch (Exception ex)
{
Growl.Error("操作失败:" + ex.Message);
}
#endregion
}
#endregion
#region PageOperation

View File

@ -0,0 +1,15 @@
<Border x:Class="货架标准上位机.Views.Controls.ImageDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
CornerRadius="10"
Width="300"
Height="186"
Background="{DynamicResource RegionBrush}">
<hc:SimplePanel>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<Image Name="image1"> </Image>
</StackPanel>
<Button Width="22" Height="22" Command="hc:ControlCommands.Close" Style="{StaticResource ButtonIcon}" Foreground="{DynamicResource PrimaryBrush}" hc:IconElement.Geometry="{StaticResource ErrorGeometry}" Padding="0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0"/>
</hc:SimplePanel>
</Border>

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace .Views.Controls
{
/// <summary>
/// TextDialog.xaml 的交互逻辑
/// </summary>
public partial class ImageDialog
{
public ImageDialog(BitmapImage image)
{
InitializeComponent();
this.image1.Source = image;
}
}
}

View File

@ -1,20 +1,6 @@
using .ViewModel;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace
{

View File

@ -34,7 +34,7 @@
hc:BorderElement.CornerRadius="15"
MinHeight="40"
FontSize="20"
Content="&#xe61b;结束入库"
Content="&#xe61b;结束所有入库"
FontFamily="{StaticResource IconFont}"
Command="{Binding BtnEndCommand}">
</Button>
@ -42,17 +42,33 @@
</Grid>
</Border>
<Border Grid.Row="1" Margin="5,5,5,5" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
<WrapPanel Name="scannersWrapPanel">
</WrapPanel>
</Border>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Margin="5,5,5,5" Grid.Column="0" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
<WrapPanel Name="scannersWrapPanel">
</WrapPanel>
</Border>
<StackPanel Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Margin="5" FontWeight="Bold" FontSize="24" Text="停止入库扫码"></TextBlock>
<Image Margin="5" Width="120" Height="120" Source="/Resources/goOutInstore.png"></Image>
</StackPanel>
<!--<GroupBox Grid.Column="1" Header="停止入库码" Padding="10">-->
<!--<Border Background="{DynamicResource RegionBrush}" CornerRadius="4">-->
<!--</Border>-->
<!--</GroupBox>-->
</Grid>
<Border Grid.Row="2" Margin="5,5,5,5" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<GroupBox Grid.Column="1" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}">
<GroupBox.Header>
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">

View File

@ -36,8 +36,10 @@ namespace 货架标准上位机
t.ScannerDisplayControl = control;
scannersWrapPanel.Children.Add(control);
});
}
//ImageSource = new BitmapImage(new Uri("/Resources/goOutInstore.png"));
}
//public BitmapImage ImageSource { get; set; }
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
DataGrid datagrid = sender as DataGrid;

Some files were not shown because too many files have changed in this diff Show More