Merge branch 'master' of https://gitee.com/cquni-wcs/wcs
# Conflicts: # WCS.BLL/Tool/Helper.cs # WCS.WebApi/Program.cs
This commit is contained in:
@ -18,6 +18,18 @@ namespace WCS.BLL.Config
|
||||
/// </summary>
|
||||
public bool IsSameMatCodeOut { get; set; }
|
||||
/// <summary>
|
||||
/// 数据-数据库路径
|
||||
/// </summary>
|
||||
public string DataDbPath { get; set; }
|
||||
/// <summary>
|
||||
/// 日志-数据库路径
|
||||
/// </summary>
|
||||
public string LogDbPath { get; set; }
|
||||
/// <summary>
|
||||
/// 权限-数据库路径
|
||||
/// </summary>
|
||||
public string AuthDbPath { get; set; }
|
||||
/// <summary>
|
||||
/// 是否接入WMS系统
|
||||
/// </summary>
|
||||
public bool IsAccessWMS { get; set; }
|
||||
@ -25,5 +37,26 @@ namespace WCS.BLL.Config
|
||||
/// WMS系统
|
||||
/// </summary>
|
||||
public string? WMSUrl { get; set; }
|
||||
|
||||
public bool IsResetDBOrTable { 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
|
||||
}
|
||||
}
|
||||
|
16
WCS.BLL/Config/LocalStatic.cs
Normal file
16
WCS.BLL/Config/LocalStatic.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Config
|
||||
{
|
||||
public static class LocalStatic
|
||||
{
|
||||
/// <summary>
|
||||
/// 0x02绿色 0x04蓝色
|
||||
/// </summary>
|
||||
public static byte CurrentOutStoreColor = 0x02;
|
||||
}
|
||||
}
|
19
WCS.BLL/DbModels/DingDingSendUser.cs
Normal file
19
WCS.BLL/DbModels/DingDingSendUser.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
[SugarTable("ding_ding_send_user")]
|
||||
public class DingDingSendUser
|
||||
{
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "user_name", Length = 50, IsNullable = true, ColumnDescription = "创建人")]
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 用于记录单据生成到哪个序号了
|
||||
/// </summary>
|
||||
[SugarTable("document_serial_number")]
|
||||
[SugarTable("wcs_document_serial_number")]
|
||||
public class DocumentSerialNumber
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -12,7 +12,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出入库记录
|
||||
/// </summary>
|
||||
[SugarTable("in_out_record")]
|
||||
[SugarTable("wcs_in_out_record")]
|
||||
public class InOutRecord
|
||||
{
|
||||
/// <summary>
|
||||
@ -115,6 +115,33 @@ namespace WCS.BLL.DbModels
|
||||
[SugarColumn(ColumnName = "operate_user", Length = 100, IsNullable = true, ColumnDescription = "创建人")]
|
||||
public string OperateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Row 行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "R", Length = 10, IsNullable = true, ColumnDescription = "库位 行")]
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
/// Column 列
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "C", Length = 10, IsNullable = true, ColumnDescription = "库位 列")]
|
||||
public string C { get; set; }
|
||||
/// <summary>
|
||||
/// Column 位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Wei", Length = 10, IsNullable = true, ColumnDescription = "库位 位 第几个库位灯")]
|
||||
public string Wei { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 库存明细表
|
||||
/// </summary>
|
||||
[SugarTable("inventory_detail")]
|
||||
[SugarTable("wcs_inventory_detail")]
|
||||
public class InventoryDetail
|
||||
{
|
||||
/// <summary>
|
||||
@ -102,7 +102,38 @@ namespace WCS.BLL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_locked", IsNullable = false, ColumnDescription = "物料是否已被锁定")]
|
||||
public bool IsLocked { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "big_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Row 行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "R", Length = 10, IsNullable = true, ColumnDescription = "库位 行")]
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
/// Column 列
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "C", Length = 10, IsNullable = true, ColumnDescription = "库位 列")]
|
||||
public string C { get; set; }
|
||||
/// <summary>
|
||||
/// Column 位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Wei", Length = 10, IsNullable = true, ColumnDescription = "库位 位 第几个库位灯")]
|
||||
public string Wei { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// WarehouseCode 仓库代码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "WarehouseCode", Length = 10, IsNullable = true, ColumnDescription = "仓库代码")]
|
||||
public string WarehouseCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
///<summary>
|
||||
///物料基础信息
|
||||
///</summary>
|
||||
[SugarTable("mat_base_info")]
|
||||
[SugarTable("wcs_mat_base_info")]
|
||||
public partial class MatBaseInfo
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
///<summary>
|
||||
///物料信息表
|
||||
///</summary>
|
||||
[SugarTable("mat_info")]
|
||||
[SugarTable("wcs_mat_info")]
|
||||
public class MatInfo
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.DAL.DbModels
|
||||
///<summary>
|
||||
///模组信息表
|
||||
///</summary>
|
||||
[SugarTable("module_info")]
|
||||
[SugarTable("wcs_module_info")]
|
||||
public class ModuleInfo
|
||||
{
|
||||
|
||||
@ -27,6 +27,12 @@ namespace WCS.DAL.DbModels
|
||||
[SugarColumn(ColumnName = "module_code", Length = 50, IsNullable = false, ColumnDescription = "模组编码")]
|
||||
public string ModuleCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false,DefaultValue ="0", ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架Id
|
||||
/// </summary>
|
||||
@ -56,7 +62,11 @@ namespace WCS.DAL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "client_ip", Length = 50, IsNullable = false, ColumnDescription = "货架对应Can模块的Ip")]
|
||||
public string CleintIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// R 行
|
||||
/// </summary>
|
||||
|
@ -20,7 +20,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库单据号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "order_number", Length = 50, IsNullable = false, ColumnDescription = "出库单据号")]
|
||||
[SugarColumn(ColumnName = "order_number", Length = 50, IsNullable = true, ColumnDescription = "出库单据号")]
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -6,7 +6,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库单据
|
||||
/// </summary>
|
||||
[SugarTable("out_order")]
|
||||
[SugarTable("wcs_out_order")]
|
||||
public class OutOrder
|
||||
{
|
||||
/// <summary>
|
||||
@ -49,15 +49,25 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 单据同步类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "sync_type",IsNullable = false, ColumnDescription = "单据同步类型:ByMatCode,ByMatSn")]
|
||||
[SugarColumn(ColumnName = "sync_type", IsNullable = false, ColumnDescription = "单据同步类型:ByMatCode,ByMatSn")]
|
||||
public SyncTypeEnum SyncType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型名称
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_name", Length = 50, IsNullable = false, ColumnDescription = "货架类型名称")]
|
||||
public string ShelfTypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, DefaultValue = "0", ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 单据货架类型 : 单灯单据还是货架单据
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type", IsNullable = false, ColumnDescription = "货架类型 是信息化货架还是智能货架")]
|
||||
public ShelfTypeEnum ShelfType { get; set; }
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
@ -71,6 +81,12 @@ namespace WCS.BLL.DbModels
|
||||
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
|
||||
public string CreateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是盟讯公司盘点生成的出库单
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_MXPD", IsNullable = true, ColumnDescription = "是否是盟讯公司盘点生成的出库单")]
|
||||
public bool? IsMXPD { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 用于绑定DataGrid中是否选择
|
||||
/// </summary>
|
||||
@ -82,6 +98,12 @@ namespace WCS.BLL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回当前是否正在进行出库
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool IsOuting { get; set; } = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库单据明细表
|
||||
/// </summary>
|
||||
[SugarTable("out_order_detail")]
|
||||
[SugarTable("wcs_out_order_detail")]
|
||||
public class OutOrderDetail
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 出库物料明细(库存数据加锁后缓存对应的数据并记录状态)
|
||||
/// </summary>
|
||||
[SugarTable("out_order_mat_detail")]
|
||||
[SugarTable("wcs_out_order_mat_detail")]
|
||||
public class OutOrderMatDetail
|
||||
{
|
||||
/// <summary>
|
||||
@ -127,6 +127,12 @@ namespace WCS.BLL.DbModels
|
||||
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
|
||||
public string CreateUser { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是盟讯公司盘点生成的出库单
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "is_MXPD", IsNullable = true, ColumnDescription = "是否是盟讯公司盘点生成的出库单")]
|
||||
public bool? IsMXPD { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 用于绑定中显示序号
|
||||
/// </summary>
|
||||
|
@ -8,7 +8,7 @@ using WCS.BLL.HardWare;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
[SugarTable("shelf_info")]
|
||||
[SugarTable("wcs_shelf_info")]
|
||||
public class ShelfInfo
|
||||
{
|
||||
|
||||
@ -42,6 +42,12 @@ namespace WCS.DAL.DbModels
|
||||
[SugarColumn(ColumnName = "current_mode", IsNullable = false, ColumnDescription = "货架当前状态")]
|
||||
public Mode CurrentMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架设置当前模式的时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "set_current_mode_time", IsNullable = true, ColumnDescription = "设置货架当前模式的时间")]
|
||||
public DateTime SetCurrentModeTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架行数
|
||||
/// </summary>
|
||||
@ -83,7 +89,7 @@ namespace WCS.DAL.DbModels
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BindShelfCode { get; set; } = string.Empty;
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 货架类型
|
||||
/// </summary>
|
||||
[SugarTable("shelf_type")]
|
||||
[SugarTable("wcs_shelf_type")]
|
||||
public class ShelfTypeInfo
|
||||
{
|
||||
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsNullable = false, IsIdentity = true)]
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 盘点单据
|
||||
/// </summary>
|
||||
[SugarTable("stock_taking_order")]
|
||||
[SugarTable("wcs_stock_taking_order")]
|
||||
public class StockTakingOrder
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -11,7 +11,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 盘点单据物料明细
|
||||
/// </summary>
|
||||
[SugarTable("stock_taking_order_matdetail")]
|
||||
[SugarTable("wcs_stock_taking_order_matdetail")]
|
||||
public class StockTakingOrderMatDetail
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.DAL.DbModels
|
||||
{
|
||||
[SugarTable("store_info")]
|
||||
[SugarTable("wcs_store_info")]
|
||||
public partial class StoreInfo
|
||||
{
|
||||
/// <summary>
|
||||
@ -21,12 +21,16 @@ namespace WCS.DAL.DbModels
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "store_code", Length = 50, IsNullable = false, ColumnDescription = "库位编码")]
|
||||
public string StoreCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架类型Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "shelf_type_id", IsNullable = false, DefaultValue = "0", ColumnDescription = "货架类型Id")]
|
||||
public int ShelfTypeId { get; set; }
|
||||
/// <summary>
|
||||
/// 模组Id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "module_id", IsNullable = false, ColumnDescription = "模组Id")]
|
||||
public int ModuleId { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模组编号
|
||||
@ -88,6 +92,33 @@ namespace WCS.DAL.DbModels
|
||||
[SugarColumn(ColumnName = "offset_voltage", IsNullable = true, ColumnDescription = "电压偏移值")]
|
||||
public decimal OffsetVoltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 串联绑定后的大货架编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Bind_shelf_code", IsNullable = true, ColumnDescription = "串联绑定后的大货架编码")]
|
||||
public string? BigShelfCode { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Row 行
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "R", Length = 10, IsNullable = true, ColumnDescription = "库位 行")]
|
||||
public string R { get; set; }
|
||||
/// <summary>
|
||||
/// Column 列
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "C", Length = 10, IsNullable = true, ColumnDescription = "库位 列")]
|
||||
public string C { get; set; }
|
||||
/// <summary>
|
||||
/// Column 位
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "Wei", Length = 10, IsNullable = true, ColumnDescription = "库位 位 第几个库位灯")]
|
||||
public string Wei { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "group_name", Length = 50, IsNullable = false, DefaultValue = "0", ColumnDescription = "货架的组别、区域(区分单个软件管哪些货架的,前端的配置文件配置一个组别,查询时只显示当前组别的货架)")]
|
||||
public string GroupName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
|
@ -10,7 +10,7 @@ namespace WCS.BLL.DbModels
|
||||
/// <summary>
|
||||
/// 系统接口日志记录
|
||||
/// </summary>
|
||||
[SugarTable("system_api_log_record")]
|
||||
[SugarTable("wcs_system_api_log_record")]
|
||||
public class SystemApiLogRecord
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model;
|
||||
using static WCS.BLL.HardWare.WarningLight;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
@ -38,12 +39,18 @@ namespace WCS.BLL.HardWare
|
||||
public int ColumnCounts { get; set; }
|
||||
|
||||
public int LightId { get; set; }
|
||||
public LightColorEnum LightColor { get; set; }
|
||||
public List<int> ModuleIds { get; set; }
|
||||
public List<SmartShelfModule> Modules { get; set; }
|
||||
public string ClientIp { get; set; }
|
||||
/// <summary>
|
||||
/// 货架当前模式
|
||||
/// </summary>
|
||||
public Mode CurrentMode { get; set; }
|
||||
/// <summary>
|
||||
/// 设置到当前模式的时间
|
||||
/// </summary>
|
||||
public DateTime SetCurrentModeTime { get; set; }
|
||||
|
||||
public MatInfoResponse InStoreData { get; set; }
|
||||
|
||||
@ -57,6 +64,8 @@ namespace WCS.BLL.HardWare
|
||||
/// 货架组别
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
|
||||
public string WebSocketIpAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 模组
|
||||
/// </summary>
|
||||
@ -65,7 +74,7 @@ namespace WCS.BLL.HardWare
|
||||
/// <summary>
|
||||
/// 设置货架模式
|
||||
/// </summary>
|
||||
public void SetCurrentMode();
|
||||
public void SetCurrentMode(Mode mode);
|
||||
|
||||
/// <summary>
|
||||
/// 货架进入入库模式
|
||||
@ -96,7 +105,7 @@ namespace WCS.BLL.HardWare
|
||||
/// <summary>
|
||||
/// 货架单个确认盘点
|
||||
/// </summary>
|
||||
public bool ConfirmStocktakingSingle(int BoardId,int LightNumber);
|
||||
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber);
|
||||
|
||||
/// <summary>
|
||||
/// 货架退出盘点模式
|
||||
|
@ -15,6 +15,8 @@ namespace WCS.BLL.HardWare
|
||||
红色 = 0x01,
|
||||
绿色 = 0x02,
|
||||
蓝色 = 0x03,
|
||||
//关闭仅用于后台暂存和判断使用 不用于协议
|
||||
关闭 = 0x11,
|
||||
}
|
||||
public enum LightModeEnum
|
||||
{
|
||||
|
@ -5,6 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.Model;
|
||||
using static WCS.BLL.HardWare.WarningLight;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
{
|
||||
@ -21,10 +22,14 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
public string OrderNumber { get; set; }
|
||||
public int LightId { get; set; }
|
||||
public LightColorEnum LightColor { get; set; }
|
||||
public List<int> ModuleIds { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
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 DateTime SetCurrentModeTime { get; set; }
|
||||
|
||||
public bool ConfirmStocktakingSingle(int BoardId, int LightNumber)
|
||||
{
|
||||
@ -34,58 +39,58 @@ namespace WCS.BLL.HardWare
|
||||
public void GoInInstore(string IPAdress)
|
||||
{
|
||||
//找到对应的灯 亮灯
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void GoInStocktaking()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void GoInStocktaking(List<StockTakingOrderMatDetail> MatDetails, StockTakingOrder outOrder)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void GoOutInstore()
|
||||
{
|
||||
//找到已亮灯的 灭灯
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void GoOutOutstore()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void GoOutStocktaking()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return;
|
||||
}
|
||||
|
||||
public void SetCurrentMode()
|
||||
public void SetCurrentMode(Mode mode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void ShelfCheck()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
public void Warning()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
|
||||
@ -65,11 +66,22 @@ namespace WCS.BLL.HardWare
|
||||
/// </summary>
|
||||
public byte[] GoOutStockTakingModeData = { 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 复位命令
|
||||
/// </summary>
|
||||
public byte[] ResetData = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 查询当前电压值
|
||||
/// </summary>
|
||||
public byte[] VoltageSingleData = { 0x17, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 电压偏移值
|
||||
/// </summary>
|
||||
public byte[] OffsetSingleData = { 0x18, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
/// <summary>
|
||||
/// 电压标准值
|
||||
/// </summary>
|
||||
public byte[] StandardSingleData = { 0x19, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
#endregion
|
||||
public int ModuleId { get; set; }
|
||||
public string ModuleCode { get; set; }
|
||||
@ -185,6 +197,7 @@ namespace WCS.BLL.HardWare
|
||||
/// <param name="tcpClient"></param>
|
||||
public void GoInOutStoreMode(TCPClient tcpClient, List<string> outSns)
|
||||
{
|
||||
Logs.Write($"模组{ModuleCode},本次亮灯物料{string.Join(",",outSns)}", LogsType.Outstore);
|
||||
CurrentOutSns = outSns;
|
||||
var storeInfos = DbHelp.db.Queryable<StoreInfo>().Where(t => t.ModuleId == ModuleId)
|
||||
.Where(t => t.BoardId == BoardId)
|
||||
@ -224,6 +237,15 @@ namespace WCS.BLL.HardWare
|
||||
var data4 = outDataStr.Substring(0, 8);
|
||||
GoInOutstoreModeData[3] = Convert.ToByte(data3, 2);
|
||||
GoInOutstoreModeData[4] = Convert.ToByte(data4, 2);
|
||||
|
||||
if (LocalFile.Config.IsSameMatCodeOut)
|
||||
{
|
||||
GoInOutstoreModeData[5] = LocalStatic.CurrentOutStoreColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
GoInOutstoreModeData[5] = 0x02;
|
||||
}
|
||||
}
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, GoInOutstoreModeData));
|
||||
}
|
||||
@ -370,5 +392,21 @@ namespace WCS.BLL.HardWare
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, ComfirmOutstoreData));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询电压值
|
||||
/// </summary>
|
||||
/// <param name="tcpClient"></param>
|
||||
public void QueryVoltage(TCPClient tcpClient)
|
||||
{
|
||||
Thread.Sleep(10);
|
||||
Task.Run(() =>
|
||||
{
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, VoltageSingleData));
|
||||
Thread.Sleep(50);
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, StandardSingleData));
|
||||
Thread.Sleep(50);
|
||||
tcpClient.Send(tcpClient.GenerateMessage(BoardId, OffsetSingleData));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,35 +18,113 @@ namespace WCS.BLL.Manager
|
||||
{
|
||||
public static void InitDb()
|
||||
{
|
||||
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
||||
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)
|
||||
, typeof(DocumentSerialNumber)
|
||||
);
|
||||
|
||||
DbHelp.dbLog.CodeFirst.InitTables(typeof(SystemApiLogRecord));
|
||||
|
||||
//初始化单据序列号数据
|
||||
if (!DbHelp.db.Queryable<DocumentSerialNumber>().Any())
|
||||
Logs.Write("【初始化数据库】开始", LogsType.StartBoot);
|
||||
//初始化数据库对象
|
||||
if (LocalFile.Config.IsMx)
|
||||
{
|
||||
var outDocumentSerialNumber = new DocumentSerialNumber()
|
||||
DbHelp.db = new SqlSugarScope(new ConnectionConfig()
|
||||
{
|
||||
DocumentType = DocumentTypeEnum.出库单据,
|
||||
UpdateDate = DateTime.Now,
|
||||
CurrentSerialNumber = 0
|
||||
};
|
||||
|
||||
var stockTakingDocumentSerialNumber = new DocumentSerialNumber()
|
||||
ConnectionString = LocalFile.Config.DataDbPath,
|
||||
DbType = DbType.SqlServer,//[Sqlite]安装[System.Data.SQLite];
|
||||
IsAutoCloseConnection = true
|
||||
}, db =>
|
||||
{
|
||||
DocumentType = DocumentTypeEnum.盘点单据,
|
||||
UpdateDate = DateTime.Now,
|
||||
CurrentSerialNumber = 0
|
||||
};
|
||||
db.Aop.OnError = ex =>
|
||||
{
|
||||
};
|
||||
});
|
||||
|
||||
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
|
||||
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
|
||||
//sqlserver保存接口日志时因为每个字段要限制长度,当接口返回内容长度过长会报错
|
||||
//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 =>
|
||||
{
|
||||
};
|
||||
});
|
||||
Logs.Write("【初始化数据库】MX", LogsType.StartBoot);
|
||||
}
|
||||
//手动修改后台配置后再进行CodeFirst 数据库的生成、表的生成
|
||||
if (LocalFile.Config.IsResetDBOrTable)
|
||||
{
|
||||
#region 建库建表 只在表有变动时运行
|
||||
DbHelp.db.DbMaintenance.CreateDatabase();
|
||||
DbHelp.dbLog.DbMaintenance.CreateDatabase();
|
||||
Logs.Write("【初始化数据库】创建数据库", LogsType.StartBoot);
|
||||
|
||||
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
||||
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
||||
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
||||
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)
|
||||
, typeof(DocumentSerialNumber),typeof(OrderLight)
|
||||
);
|
||||
Logs.Write("【初始化数据库】db建表", LogsType.StartBoot);
|
||||
|
||||
DbHelp.dbLog.CodeFirst.InitTables(typeof(SystemApiLogRecord));
|
||||
Logs.Write("【初始化数据库】logdb建表", LogsType.StartBoot);
|
||||
|
||||
//初始化单据序列号数据
|
||||
if (!DbHelp.db.Queryable<DocumentSerialNumber>().Any())
|
||||
{
|
||||
var outDocumentSerialNumber = new DocumentSerialNumber()
|
||||
{
|
||||
DocumentType = DocumentTypeEnum.出库单据,
|
||||
UpdateDate = DateTime.Now,
|
||||
CurrentSerialNumber = 0
|
||||
};
|
||||
|
||||
var stockTakingDocumentSerialNumber = new DocumentSerialNumber()
|
||||
{
|
||||
DocumentType = DocumentTypeEnum.盘点单据,
|
||||
UpdateDate = DateTime.Now,
|
||||
CurrentSerialNumber = 0
|
||||
};
|
||||
|
||||
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
|
||||
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
|
||||
}
|
||||
Logs.Write("【初始化数据库】DocumentSerialNumber", LogsType.StartBoot);
|
||||
|
||||
//初始化货架类型
|
||||
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();
|
||||
#endregion
|
||||
|
||||
LocalFile.Config.IsResetDBOrTable = false;
|
||||
LocalFile.SaveConfig();
|
||||
}
|
||||
Logs.Write("【初始化数据库】结束", LogsType.StartBoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
361
WCS.BLL/Manager/MXBackgroundThread.cs
Normal file
361
WCS.BLL/Manager/MXBackgroundThread.cs
Normal file
@ -0,0 +1,361 @@
|
||||
using SqlSugar;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.DAL.DbModels;
|
||||
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 定时任务:超时退出 出库、入库、盘点模式
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//每10s一次
|
||||
Thread.Sleep(10000);
|
||||
try
|
||||
{
|
||||
#region 入库模式
|
||||
var inStoreShelf = ShelfManager.Shelves.Where(t => t.CurrentMode == Mode.入库模式)
|
||||
.Where(t => DateTime.Now - t.SetCurrentModeTime >= TimeSpan.FromMinutes(3))
|
||||
.ToList();
|
||||
foreach (var shelf in inStoreShelf)
|
||||
{
|
||||
shelf.GoOutInstore();
|
||||
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时(3min)未退出入库模式,系统后台自动退出!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 出库模式
|
||||
//出库超过n分钟自动进入待机模式
|
||||
var outStoreShelf = ShelfManager.Shelves.Where(t => t.CurrentMode == Mode.出库模式)
|
||||
.Where(t => DateTime.Now - t.SetCurrentModeTime >= TimeSpan.FromMinutes(5))
|
||||
.ToList();
|
||||
foreach (var shelf in outStoreShelf)
|
||||
{
|
||||
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时(5min)未退出出库模式,系统后台自动退出!出库单[{shelf.OrderNumber}]");
|
||||
shelf.GoOutOutstore();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 盘点模式
|
||||
var stockTakingShelf = ShelfManager.Shelves.Where(t => t.CurrentMode == Mode.盘点模式)
|
||||
.Where(t => DateTime.Now - t.SetCurrentModeTime >= TimeSpan.FromMinutes(5))
|
||||
.ToList();
|
||||
foreach (var shelf in stockTakingShelf)
|
||||
{
|
||||
Logs.Write($"【定时任务:定时退出模式】货架【{shelf.ShelfCode}】超时(5min)未退出盘点模式,系统后台自动退出!盘点单[{shelf.OrderNumber}]");
|
||||
shelf.GoOutStocktaking();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logs.Write("【定时任务:定时退出模式】" + e.Message, LogsType.Info);
|
||||
}
|
||||
}
|
||||
});
|
||||
#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 定时任务:监测警示灯关灯机制
|
||||
//判断灯颜色和模式是否对应
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//间隔5秒查询一次
|
||||
Thread.Sleep(5000);
|
||||
try
|
||||
{
|
||||
//待机模式未关灯
|
||||
var shelves = ShelfManager.Shelves.Where(t => t.CurrentMode == Mode.待机模式 && t.LightColor != WarningLight.LightColorEnum.关闭)
|
||||
.Where(t => t.SetCurrentModeTime < DateTime.Now.AddSeconds(-5))
|
||||
.ToList();
|
||||
foreach (var shelf in shelves)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (shelf is SmartShelf)
|
||||
{
|
||||
var smartShelf = (SmartShelf)shelf;
|
||||
smartShelf?.WarningLight.CloseLight(smartShelf.TcpCleint);
|
||||
Logs.Write($"【定时任务】:监测警示灯关灯机制,关【{shelf.ShelfCode}】灯发送指令成功!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"【定时任务】:监测警示灯关灯机制,关【{shelf.ShelfCode}】灯发生异常" + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
//出库模式未亮灯
|
||||
var outShelves = ShelfManager.Shelves.Where(t => t.CurrentMode == Mode.出库模式 && t.LightColor == WarningLight.LightColorEnum.关闭)
|
||||
.Where(t => t.SetCurrentModeTime < DateTime.Now.AddSeconds(-5))
|
||||
.ToList();
|
||||
foreach (var shelf in outShelves)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (shelf is SmartShelf)
|
||||
{
|
||||
var smartShelf = (SmartShelf)shelf;
|
||||
smartShelf?.WarningLight.GreenLight(smartShelf.TcpCleint);
|
||||
Logs.Write($"【定时任务】:监测警示灯关灯机制,出库开灯【{shelf.ShelfCode}】发送指令成功!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"【定时任务】:监测警示灯关灯机制,出库开灯【{shelf.ShelfCode}】发生异常" + ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write("【定时任务】:监测警示灯关灯机制发生异常" + ex.Message);
|
||||
}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送钉钉消息
|
||||
/// </summary>
|
||||
/// <param name="msg">发送的消息内容</param>
|
||||
/// <param name="errMsg">错误信息</param>
|
||||
/// <param name="idList">工号列表</param>
|
||||
/// <returns></returns>
|
||||
public static bool SendDingDingMsg(string msg, List<string> idList, ref string errMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 获取所有工程研发人员
|
||||
var list = AuthDbHelp.db.Queryable<UserBase>().Where(t => t.IsGCYF)
|
||||
.Select(t => t.LoginName)
|
||||
.ToList();
|
||||
#endregion
|
||||
string ids = string.Join(",", list);
|
||||
string url = "http://192.168.2.23:9213/integrate/cmccMonitor/rateAlertByCMCC?" + $"context={msg}&messageType=软件管理平台&username={ids}";
|
||||
#region 调用接口请求发送钉钉消息
|
||||
var Result = ApiHelp.GetDataFromHttp<MXMesResponseCommon>(url, null, "GET");
|
||||
if (Result != null && Result.code != 200)
|
||||
{
|
||||
errMsg = Result.msg;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#endregion
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
errMsg = "接口调用失败";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.DAL.Db;
|
||||
@ -20,11 +21,18 @@ namespace WCS.BLL.Manager
|
||||
|
||||
public static void InitShelves()
|
||||
{
|
||||
var shelvesInDb = DbHelp.db.Queryable<ShelfInfo>().ToList();
|
||||
Logs.Write("【InitShelves】开始", LogsType.StartBoot);
|
||||
|
||||
var shelvesInDbQueryable = DbHelp.db.Queryable<ShelfInfo>();
|
||||
if (LocalFile.Config.IsMx)
|
||||
shelvesInDbQueryable = shelvesInDbQueryable.Where(t => t.GroupName == LocalFile.Config.GroupName);
|
||||
var shelvesInDb = shelvesInDbQueryable.ToList();
|
||||
foreach (var shelfInDb in shelvesInDb)
|
||||
{
|
||||
Shelves.Add(InitShelf(shelfInDb));
|
||||
}
|
||||
|
||||
Logs.Write("【InitShelves】结束", LogsType.StartBoot);
|
||||
}
|
||||
|
||||
public static IShelfBase InitShelf(ShelfInfo shelfInDb)
|
||||
|
@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
@ -22,107 +23,95 @@ 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"))
|
||||
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName),t => t.GroupName == LocalFile.Config.GroupName)
|
||||
.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?.WarningLightProcess(dataTemp, boardId, lightNumber);
|
||||
}
|
||||
//!= 0x20 货架类型协议返回
|
||||
else
|
||||
{
|
||||
var shelf = ShelfManager.Shelves
|
||||
.Where(t => t.ClientIp == clientIpHost)
|
||||
.Where(t => t.ModuleIds != null && 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);
|
||||
Console.WriteLine($"【InitTcpClient】{clientIpHost}完成首次连接");
|
||||
InitStatus(TcpCleint);
|
||||
TcpCleint.IsFirstConnected = true;
|
||||
}
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
|
||||
TCPClients.Add(tcpCleint);
|
||||
tcpCleint.Connect();
|
||||
});
|
||||
}
|
||||
|
||||
//启动线程监听所有TCP是否已经完成首次连接
|
||||
@ -130,22 +119,31 @@ namespace WCS.BLL.Manager
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
Thread.Sleep(1000);
|
||||
var noFirstConnectedClients = TCPClientManager.TCPClients.Where(t => t.IsFirstConnected == false)
|
||||
.ToList();
|
||||
if (noFirstConnectedClients.Count == 0)
|
||||
try
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
noFirstConnectedClients.ForEach(t =>
|
||||
Thread.Sleep(1000);
|
||||
var noFirstConnectedClients = TCPClientManager.TCPClients.Where(t => t.IsFirstConnected == false)
|
||||
.ToList();
|
||||
if (noFirstConnectedClients.Count == 0)
|
||||
{
|
||||
t.ReConnectAsync();
|
||||
});
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"存在tcp未完成首次连接,继续重连!");
|
||||
noFirstConnectedClients.ForEach(t =>
|
||||
{
|
||||
t.ReConnectAsync();
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
Logs.Write("【InitTcpClient】完成 后台继续连接", LogsType.StartBoot);
|
||||
}
|
||||
|
||||
//后台启动时给所有板子、警示灯发送复位操作 保持状态一致
|
||||
|
@ -75,8 +75,15 @@ namespace WCS.BLL.Manager
|
||||
case WarningTypeEnum.出库自检丢失:
|
||||
SolveLoss(warningInManager);
|
||||
break;
|
||||
case WarningTypeEnum.自检丢失:
|
||||
SolveLoss(warningInManager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (solveType == SolveTypeEnum.忽略)
|
||||
{
|
||||
//不发指令了
|
||||
}
|
||||
|
||||
//消除报警缓存信息
|
||||
lock (flag)
|
||||
@ -88,7 +95,6 @@ namespace WCS.BLL.Manager
|
||||
//货架是否还存在报警信息
|
||||
shelfIsWarning = Warnings.Where(t => t.ShelfId == warning.ShelfId)
|
||||
.Any();
|
||||
|
||||
//对应货架如果不存在报警信息了 指示灯回到对应的状态
|
||||
if (!shelfIsWarning)
|
||||
{
|
||||
@ -139,7 +145,6 @@ namespace WCS.BLL.Manager
|
||||
public static void SolveLoss(WebSocketMessageModel warning)
|
||||
{
|
||||
#region 【后台】丢失的数据处理
|
||||
|
||||
try
|
||||
{
|
||||
//获取库位
|
||||
@ -164,6 +169,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 +185,45 @@ 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.出库自检丢失)
|
||||
{
|
||||
Logs.Write($"【出库自检】发现物料{inventoryDetail.MatSN}丢失,用户点击【处理】,删除数据",LogsType.Outstore);
|
||||
//清掉需要出库的缓存
|
||||
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);
|
||||
Logs.Write($"【出库自检】发现物料{inventoryDetail.MatSN}丢失,已删除货架缓存,剩余物料为{string.Join(",", smartShelf.CurrentOutStoreMatSNs)}", LogsType.Outstore);
|
||||
|
||||
//删除模组上缓存的那一条数据
|
||||
var module = smartShelf.Modules.Where(t => t.ModuleId == warning.ModuleId).FirstOrDefault();
|
||||
if (module != null) {
|
||||
module.CurrentOutSns.RemoveAll(t => t == inventoryDetail.MatSN);
|
||||
Logs.Write($"【出库自检】发现物料{inventoryDetail.MatSN}丢失,已删除模组缓存,剩余物料为{string.Join(",", module.CurrentOutSns)}", LogsType.Outstore);
|
||||
}
|
||||
//删除已丢失的出库明细数据
|
||||
var outOrderMatDetail = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == smartShelf.CurrentOutOrder.Id)
|
||||
.Where(t => t.MatSN == inventoryDetail.MatSN && t.IsSended == false)
|
||||
.ToList();
|
||||
Logs.Write($"【出库自检】发现物料{inventoryDetail.MatSN}丢失,删除出库物料明细数据{outOrderMatDetail.Count}条!");
|
||||
DbHelp.db.Deleteable(outOrderMatDetail).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
}
|
||||
@ -217,8 +264,9 @@ namespace WCS.BLL.Manager
|
||||
smartShelf.WarningLight.BlueLight(smartShelf.TcpCleint);
|
||||
break;
|
||||
case Mode.出库模式:
|
||||
module.GoInOutStoreMode(smartShelf.TcpCleint, module.CurrentOutSns);
|
||||
smartShelf.WarningLight.GreenLight(smartShelf.TcpCleint);
|
||||
//module.GoInOutStoreMode(smartShelf.TcpCleint, module.CurrentOutSns);
|
||||
//smartShelf.WarningLight.GreenLight(smartShelf.TcpCleint);
|
||||
smartShelf.GoInOutstoreByWebSocket(module.ModuleId);
|
||||
break;
|
||||
case Mode.待机模式:
|
||||
module.Reset(smartShelf.TcpCleint);
|
||||
|
@ -16,6 +16,8 @@ namespace WCS.BLL.Manager
|
||||
public static object flag = new object();
|
||||
public static void InitWebSocket()
|
||||
{
|
||||
Console.WriteLine("【启动WebSocket】开始");
|
||||
Logs.Write("【启动WebSocket】开始", LogsType.StartBoot);
|
||||
service = new HttpService();
|
||||
service.Setup(new TouchSocketConfig()//加载配置
|
||||
.SetListenIPHosts(7789)
|
||||
@ -30,11 +32,19 @@ namespace WCS.BLL.Manager
|
||||
.UseAutoPong();//当收到ping报文时自动回应pong
|
||||
a.Add<WebSocketServicePlugin>();//自定义插件。
|
||||
}));
|
||||
|
||||
//客户端成功连接
|
||||
service.Connected = (client, e) =>
|
||||
{
|
||||
Logs.Write("[WebSocket]" + client.GetIPPort() + "成功连接!", LogsType.StartBoot);
|
||||
Console.WriteLine("[WebSocket]" + client.GetIPPort() +"成功连接!");
|
||||
return EasyTask.CompletedTask;
|
||||
};
|
||||
service.Start();
|
||||
service.Logger.Info("服务器已启动");
|
||||
Console.WriteLine("【启动WebSocket】结束");
|
||||
Logs.Write("【启动WebSocket】结束", LogsType.StartBoot);
|
||||
}
|
||||
//尝试发送报警信息给前端
|
||||
|
||||
//发送报警信息给前端
|
||||
public static void TrySendMessage(string IpAddress, string Message)
|
||||
{
|
||||
try
|
||||
|
@ -15,5 +15,7 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<string> generateStockTakingNumber();
|
||||
|
||||
public Task<string> generateOutOrderNumber();
|
||||
|
||||
public Task<string> generateMXPDOutOrderNumber();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,6 @@ namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IHomerService
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,7 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<PageQueryResponse<InventoryDetail>> exportMatInventoryDetail(GetMatInventoryDetailRequest request);
|
||||
|
||||
public Task<ResponseCommon<List<MatInventorySummaryModel>>> getMatInventorySummary(GetMatInventorySummaryRequest request);
|
||||
|
||||
public Task<PageQueryResponse<InventoryDetail>> compareMatInventoryDetail(CompareMatInventoryDetailRequest request);
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,14 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
public interface IOutstoreService
|
||||
{
|
||||
public Task<ResponseCommon<List<MatInventorySummaryModel>>> importMat(List<OutImportMatModel> list);
|
||||
public Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request);
|
||||
|
||||
public Task<ResponseBase> SysOutOrderByMatSn(SysOutOrderByMatSnRequest request);
|
||||
@ -19,10 +21,11 @@ namespace WCS.BLL.Services.IService
|
||||
public Task<ResponseBase> GetOutOrderListByStatus(GetOutOrderListByStatusRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request);
|
||||
public Task<ResponseBase> GetOutOrderDetailSingleLight(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
|
||||
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
|
||||
|
||||
public Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request);
|
||||
|
||||
|
@ -12,5 +12,7 @@ namespace WCS.BLL.Services.IService
|
||||
public interface ISelfCheckService
|
||||
{
|
||||
public Task<ResponseBase> StartSelfCheckByShelfCode(StartSelfCheckByShelfCodeRequest request);
|
||||
|
||||
public Task<ResponseBase> StartSelfCheckByGroupName(List<string> GroupNames);
|
||||
}
|
||||
}
|
||||
|
@ -32,19 +32,40 @@ 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<ResponseCommon> queryModuleVoltage(QueryModuleVoltageRequest 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +134,15 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> generateMXPDOutOrderNumber()
|
||||
{
|
||||
lock (stockTakingFlag)
|
||||
{
|
||||
var serialNumber = GetSerialNumber(DocumentTypeEnum.出库单据);
|
||||
return "PDOUT" + DateTime.Now.ToString("yyyyMMdd") + serialNumber.ToString().PadLeft(4, '0');
|
||||
}
|
||||
}
|
||||
|
||||
public int GetSerialNumber(DocumentTypeEnum documentType)
|
||||
{
|
||||
var documentSerialNumber = DbHelp.db.Queryable<DocumentSerialNumber>()
|
||||
|
@ -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();
|
||||
@ -151,6 +152,8 @@ namespace WCS.BLL.Services.Service
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurrentMode}",
|
||||
};
|
||||
}
|
||||
//物料在入库模式,更新时间 避免被后台线程关闭
|
||||
shelf.SetCurrentModeTime = DateTime.Now;
|
||||
}
|
||||
|
||||
#region 获取物料数据 //调用接口或者直接查询数据库
|
||||
@ -164,13 +167,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 +183,7 @@ namespace WCS.BLL.Services.Service
|
||||
materialSpec = data.materialSpec,
|
||||
batchNo = data.batchNo,
|
||||
supplier = "",
|
||||
customer = data.materialBar,
|
||||
customer = "",
|
||||
|
||||
InstoreUser = request.UserName
|
||||
};
|
||||
@ -207,6 +210,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 +283,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 +512,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 +535,7 @@ namespace WCS.BLL.Services.Service
|
||||
Message = $"入库成功!",
|
||||
Data = rcs.Data,
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
552
WCS.BLL/Services/Service/InstoreService.cs.orig
Normal file
552
WCS.BLL/Services/Service/InstoreService.cs.orig
Normal file
@ -0,0 +1,552 @@
|
||||
using OracleInternal.SqlAndPlsqlParser.LocalParsing;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.BLL.Tool.Api.ApiModel;
|
||||
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
|
||||
{
|
||||
public class InstoreService : IInstoreService
|
||||
{
|
||||
public InstoreService() { }
|
||||
|
||||
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request)
|
||||
{
|
||||
//校验货架编码规则
|
||||
//取配置文件中得货架编码规则
|
||||
bool isValid = false;
|
||||
var patterns = LocalFile.Config.ModuleCodePatterns;
|
||||
if (patterns != null && patterns.Count > 0)
|
||||
{
|
||||
foreach (var pattern in patterns)
|
||||
{
|
||||
isValid = Regex.IsMatch(request.ModuleCode, pattern);
|
||||
//匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
|
||||
if (isValid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//如果配置文件缺失 使用默认正则进行匹配
|
||||
else
|
||||
{
|
||||
isValid = Regex.IsMatch(request.ModuleCode, LocalFile.DefaultModuleCodePattern);
|
||||
}
|
||||
|
||||
if (!isValid)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 202,
|
||||
Message = $"模组编码{request.ModuleCode}不满足模组编码规则!",
|
||||
};
|
||||
}
|
||||
//找到模组对应的货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ModulesStr.Contains(request.ModuleCode)).FirstOrDefault();
|
||||
if (shelf == null)//未找到
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "未找到模组对应的货架",
|
||||
};
|
||||
}
|
||||
//已找到模组对应货架
|
||||
shelf.GoInInstore(request.IpAdress);
|
||||
|
||||
if (shelf.CurrentMode == Mode.入库模式)
|
||||
//成功进入入库模式
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"货架进入入库模式成功!{string.Join(",", shelf.ExceptionMessages)}",
|
||||
Data = new ShelfGoInInstoreDto()
|
||||
{
|
||||
ShelfCode = shelf.ShelfCode,
|
||||
ModulesStr = shelf.ModulesStr,
|
||||
}
|
||||
};
|
||||
else
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架进入入库模式失败:{string.Join(",", shelf.ExceptionMessages)}",
|
||||
Data = null
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public ResponseBase shelfGoOutInStore(ShelfGoOutInStoreRequest request)
|
||||
{
|
||||
//获取货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
if (shelf == null)//货架不存在
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"退出入库模式失败:货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
|
||||
//判断扫码枪 是否被其他扫码枪所占用 如果占用 直接退出入库模式 不发指令
|
||||
shelf.GoOutInstore();
|
||||
|
||||
if (shelf.ExceptionMessages == null || shelf.ExceptionMessages.Count == 0)
|
||||
//已退出
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"货架[{request.ShelfCode}]已退出入库模式!",
|
||||
};
|
||||
else
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"货架[{request.ShelfCode}]已退出入库模式!{string.Join(",", shelf.ExceptionMessages)}",
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> queryByMatSn(QueryByMatSnRequest request)
|
||||
{
|
||||
//判断物料是否已入库
|
||||
var inventory = await DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == request.MatSn).FirstAsync();
|
||||
if (inventory != null)
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:物料{inventory.MatSN}已入库!库位为{inventory.StoreCode}",
|
||||
};
|
||||
}
|
||||
|
||||
IShelfBase shelf = null;
|
||||
if (!request.SingleLightIn)
|
||||
{
|
||||
//获取货架
|
||||
shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
if (shelf == null)//货架不存在
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
//判断当前是否是入库模式
|
||||
if (shelf.CurrentMode != Mode.入库模式)
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurrentMode}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取物料数据 //调用接口或者直接查询数据库
|
||||
// 调用接口
|
||||
if (LocalFile.Config.IsAccessWMS)
|
||||
{
|
||||
#region 调用WMS接口获取物料信息
|
||||
try
|
||||
{
|
||||
var body = new
|
||||
{
|
||||
materialBar = request.MatSn
|
||||
};
|
||||
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.SingleLightIn && shelf != null)
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = data.materialBar,
|
||||
materialCode = data.materialCode,
|
||||
materialName = data.materialName,
|
||||
materialQty = data.materialQty,
|
||||
materialSpec = data.materialSpec,
|
||||
batchNo = data.batchNo,
|
||||
supplier = "",
|
||||
customer = "",
|
||||
|
||||
InstoreUser = request.UserName
|
||||
};
|
||||
|
||||
var matInfo = new MatInfo()
|
||||
{
|
||||
MatSn = data.materialBar,
|
||||
MatCode = data.materialCode,
|
||||
MatName = data.materialName,
|
||||
MatBatch = data.batchNo,
|
||||
MatQty = (int)data.materialQty,
|
||||
MatSpec = data.materialSpec,
|
||||
MatSupplier = "",
|
||||
MatCustomer = "",
|
||||
};
|
||||
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Data = matInfo,
|
||||
Message = "success"
|
||||
};
|
||||
}
|
||||
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,
|
||||
Message = $"操作失败:调用Mes接口未获取到物料信息!",
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:调用Mes接口失败!",
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:调用Mes接口发生异常{e.Message}",
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
//查询数据库是否存在这个物料
|
||||
else
|
||||
{
|
||||
var matInfo = await DbHelp.db.Queryable<MatInfo>().Where(t => t.MatSn == request.MatSn).FirstAsync();
|
||||
if (matInfo != null)
|
||||
{
|
||||
//TODO 改成wcs的实体
|
||||
if (!request.SingleLightIn && shelf != null)
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = matInfo.MatSn,
|
||||
materialCode = matInfo.MatCode,
|
||||
materialName = matInfo.MatName,
|
||||
materialQty = matInfo.MatQty,
|
||||
materialSpec = matInfo.MatSpec,
|
||||
batchNo = matInfo.MatBatch,
|
||||
supplier = matInfo.MatSupplier,
|
||||
customer = matInfo.MatCustomer,
|
||||
|
||||
InstoreUser = request.UserName
|
||||
};
|
||||
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Data = matInfo,
|
||||
Message = "success"
|
||||
};
|
||||
}
|
||||
else
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Data = null,
|
||||
Message = $"不存在物料{request.MatSn}"
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单灯出库时查询物料信息 这里返回库存的数据
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResponseBase> queryByMatSnOut(QueryByMatSnRequest request)
|
||||
{
|
||||
//判断物料是否已入库
|
||||
var inventory = await DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == request.MatSn).FirstAsync();
|
||||
if (inventory == null)
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:物料不在库存内,无法进行出库!",
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"Success",
|
||||
Data = new MatInfo()
|
||||
{
|
||||
MatSn = inventory.MatSN,
|
||||
MatCode = inventory.MatCode,
|
||||
MatName = inventory.MatName,
|
||||
MatBatch = inventory.MatBatch,
|
||||
MatQty = inventory.MatQty,
|
||||
MatSpec = inventory.MatSpec,
|
||||
MatSupplier = inventory.MatSupplier,
|
||||
MatCustomer = inventory.MatCustomer,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> queryInstoreStatus(QueryByMatSnRequest request)
|
||||
{
|
||||
//获取货架
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
if (shelf == null)//货架不存在
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
|
||||
//判断当前是否是入库模式
|
||||
if (shelf.CurrentMode != Mode.入库模式)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架[{request.ShelfCode}]已退出入库模式!\r\n当前为{shelf.CurrentMode}",
|
||||
};
|
||||
}
|
||||
|
||||
//TODO 配置这个时间相当于需要入库扫码后需要等待的时间
|
||||
var timeOut = 5000;
|
||||
var timeSpan = TimeSpan.FromMilliseconds(0);
|
||||
var beginTime = DateTime.Now;
|
||||
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
|
||||
{
|
||||
timeSpan = DateTime.Now - beginTime;
|
||||
//已入库当前扫码的物料时 查询数据库
|
||||
if (shelf.InStoreData == null || (shelf.InStoreData as object) == null)
|
||||
{
|
||||
await Task.Delay(50);
|
||||
var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.MatSN == request.MatSn)
|
||||
.First();
|
||||
if (inventoryDetail != null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"入库成功!物料已放入库位{inventoryDetail.StoreCode}",
|
||||
Data = new
|
||||
{
|
||||
StoreCode = inventoryDetail.StoreCode,
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
//延时处理
|
||||
Thread.Sleep(50);
|
||||
}
|
||||
//超时未成功入库
|
||||
shelf.InStoreData = null;
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"超时未入库!请重新扫码后入库!",
|
||||
Data = new
|
||||
{
|
||||
StoreCode = string.Empty,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> queryInstoreStatusSingle(QueryByMatSnRequestSingle request)
|
||||
{
|
||||
//获取货架
|
||||
//var shelf = ShelfManager.Shelves.Where(t => t.ShelfCode == request.ShelfCode).FirstOrDefault();
|
||||
//if (shelf == null)//货架不存在
|
||||
//{
|
||||
// return new ResponseCommon()
|
||||
// {
|
||||
// Code = 201,
|
||||
// Message = $"货架[{request.ShelfCode}]不存在!",
|
||||
// };
|
||||
//}
|
||||
List<ModuleInfo> MI = DbHelp.db.Queryable<ModuleInfo>().Where(it => it.ModuleCode == request.ShelfCode).ToList();
|
||||
if (MI.Count == 0)
|
||||
{
|
||||
return new ResponseCommonSingle()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架[{request.ShelfCode}]不存在!",
|
||||
};
|
||||
}
|
||||
ResponseCommonSingle rcs = new ResponseCommonSingle();
|
||||
rcs.Data = new List<Detail>();
|
||||
|
||||
string sendIP = MI[0].CleintIp; //单灯IP
|
||||
int PCBId = MI[0].BoardId; //单灯PCB板ID
|
||||
|
||||
List<StoreInfo> SI = DbHelp.db.Queryable<StoreInfo>().Where(it => it.ModuleCode == request.ShelfCode).ToList();
|
||||
|
||||
List<ShelfInfo> si = DbHelp.db.Queryable<ShelfInfo>().Where(it => it.ShelfCode == MI[0].ShelfCode).ToList();
|
||||
int warnLightID = si[0].LightId;
|
||||
|
||||
foreach (QueryByMatSnRequestSingle.MatSnListDetail matSnListDetail in request.MatSnList)
|
||||
{
|
||||
Detail detail = new Detail();
|
||||
try
|
||||
{
|
||||
InventoryDetail inventoryDetail = new InventoryDetail();
|
||||
inventoryDetail.MatSN = matSnListDetail.MatSn;
|
||||
inventoryDetail.MatCode = matSnListDetail.MatCode;
|
||||
inventoryDetail.MatName = matSnListDetail.MatName;
|
||||
inventoryDetail.MatSpec = matSnListDetail.MatSpec;
|
||||
inventoryDetail.MatBatch = matSnListDetail.MatBatch;
|
||||
inventoryDetail.MatQty = matSnListDetail.MatQty;
|
||||
inventoryDetail.MatCustomer = matSnListDetail.MatCustomer;
|
||||
inventoryDetail.MatSupplier = matSnListDetail.MatSupplier;
|
||||
inventoryDetail.StoreCode = request.ShelfCode;
|
||||
inventoryDetail.StoreId = SI[0].Id;
|
||||
|
||||
int count = DbHelp.db.Insertable(inventoryDetail).ExecuteCommand();
|
||||
|
||||
InOutRecord ior = new InOutRecord();
|
||||
ior.MatSN = matSnListDetail.MatSn;
|
||||
ior.MatCode = matSnListDetail.MatCode;
|
||||
ior.MatName = matSnListDetail.MatName;
|
||||
ior.MatSpec = matSnListDetail.MatSpec;
|
||||
ior.MatBatch = matSnListDetail.MatBatch;
|
||||
ior.MatQty = matSnListDetail.MatQty;
|
||||
ior.MatCustomer = matSnListDetail.MatCustomer;
|
||||
ior.MatSupplier = matSnListDetail.MatSupplier;
|
||||
ior.StoreCode = request.ShelfCode;
|
||||
ior.StoreId = SI[0].Id;
|
||||
ior.Direction = DirectionEnum.入库;
|
||||
ior.OperateTime = DateTime.Now;
|
||||
ior.OperateUser = request.UserName;
|
||||
int count1 = DbHelp.db.Insertable(ior).ExecuteCommand();
|
||||
|
||||
detail.matsn = matSnListDetail.MatSn;
|
||||
detail.result = "入库成功";
|
||||
rcs.Data.Add(detail);
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
detail.matsn = matSnListDetail.MatSn;
|
||||
detail.result = "入库失败";
|
||||
detail.reason = ee.Message;
|
||||
rcs.Data.Add(detail);
|
||||
}
|
||||
}
|
||||
//亮灯
|
||||
TCPClient tCPClient = TCPClientManager.GetTCPClientByIPHost(sendIP);
|
||||
<<<<<<< HEAD
|
||||
//byte[] data1 = new byte[8];
|
||||
//data1[0] = 0xff;
|
||||
//data1[1] = 0x02;
|
||||
//data1[2] = 0x00;
|
||||
//data1[3] = 0x0a;
|
||||
//data1[4] = (byte)warnLightID;
|
||||
//data1[5] = 0x03;
|
||||
//data1[6] = 0x02;
|
||||
//data1[7] = 0x02;
|
||||
//byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, true);
|
||||
byte[] senddata1 = Tool.Helper.InstoreWarnLight(warnLightID);
|
||||
=======
|
||||
byte[] data1 = new byte[8];
|
||||
data1[0] = 0xff;
|
||||
data1[1] = 0x02;
|
||||
data1[2] = 0x00;
|
||||
data1[3] = 0x0a;
|
||||
data1[4] = (byte)warnLightID;
|
||||
data1[5] = 0x03;
|
||||
data1[6] = 0x02;
|
||||
data1[7] = 0x02;
|
||||
byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, false);
|
||||
>>>>>>> 11
|
||||
tCPClient.Send(senddata1); //报警灯短亮一次
|
||||
|
||||
//byte[] data2 = new byte[8];
|
||||
//data2[0] = 0xff;
|
||||
//data2[1] = 0x01;
|
||||
//data2[2] = 0x00;
|
||||
//data2[3] = 0x0a;
|
||||
//data2[4] = 0x01;
|
||||
//data2[5] = (byte)PCBId;
|
||||
//data2[6] = 0x03;
|
||||
//data2[7] = 0x02;
|
||||
//byte[] senddata2 = Tool.Helper.Crc16(data2, data2.Length, true);
|
||||
byte[] senddata2 = Tool.Helper.InstoreLight(PCBId);
|
||||
tCPClient.Send(senddata2); //库位灯短亮一次
|
||||
|
||||
return new ResponseCommonSingle()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"入库成功!",
|
||||
Data = rcs.Data,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL.Db;
|
||||
@ -128,16 +129,16 @@ namespace WCS.BLL.Services.Service
|
||||
var inventortyDetails = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), t => t.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), t => t.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), t => t.MatBatch.Contains(request.MatBatch))
|
||||
.Where(t => t.StoreInfo.ShelfTypeId == request.ShelfTypeId)
|
||||
.GroupBy(t => t.MatCode)
|
||||
.GroupBy(t => t.MatBatch)
|
||||
.Select(t => new MatInventorySummaryModel
|
||||
{
|
||||
MatCode = t.MatCode,
|
||||
MatName = t.MatName,
|
||||
MatBatch = t.MatBatch,
|
||||
MatSpec = t.MatSpec,
|
||||
MatCustomer = t.MatCustomer,
|
||||
MatSupplier = t.MatSupplier,
|
||||
MatBatch = t.MatBatch,
|
||||
TotalQty = SqlFunc.AggregateSum(t.MatQty)
|
||||
})
|
||||
.ToListAsync();
|
||||
@ -149,5 +150,48 @@ namespace WCS.BLL.Services.Service
|
||||
Data = inventortyDetails
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<InventoryDetail>> compareMatInventoryDetail(CompareMatInventoryDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
//查询 本分组中 是否含有所传SN的物料
|
||||
var recordsQueryable = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => request.MatSns.Contains(t.MatSN))
|
||||
.OrderBy(t => t.MatCode)
|
||||
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.StoreInfo.GroupName == LocalFile.Config.GroupName);
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable.ToListAsync();
|
||||
//生成序号 选中
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = i + 1;
|
||||
records[i].IsSelected = true;
|
||||
}
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
Lists = new List<InventoryDetail>()
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,5 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Sockets;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using SqlSugar;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
@ -15,6 +9,7 @@ using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
@ -24,6 +19,53 @@ namespace WCS.BLL.Services.Service
|
||||
public OutstoreService()
|
||||
{
|
||||
|
||||
}
|
||||
public async Task<ResponseCommon<List<MatInventorySummaryModel>>> importMat(List<OutImportMatModel> list)
|
||||
{
|
||||
//数据校验
|
||||
if (list == null || list.Count == 0)
|
||||
{
|
||||
return new ResponseCommon<List<MatInventorySummaryModel>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:导入文件中没有内容!"
|
||||
};
|
||||
}
|
||||
//需求数量
|
||||
var errorCount = list.Where(t => t.需求数量 <= 0).ToList();
|
||||
if (errorCount != null && errorCount.Count > 0)
|
||||
{
|
||||
return new ResponseCommon<List<MatInventorySummaryModel>>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "导入失败:需求数量需要大于0!"
|
||||
};
|
||||
}
|
||||
//每一个物料进行搜索库存
|
||||
var returnList = new List<MatInventorySummaryModel>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var inventoryCount = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.MatCode == item.物料编码)
|
||||
.Where(t => t.MatBatch == item.物料批次)
|
||||
.Where(t => t.IsLocked == false)
|
||||
.SumAsync(t => t.MatQty);
|
||||
var info = inventoryCount < item.需求数量 ? "库存数量小于需求数量" : string.Empty;
|
||||
returnList.Add(new MatInventorySummaryModel()
|
||||
{
|
||||
MatCode = item.物料编码,
|
||||
MatName = item.物料名称,
|
||||
MatBatch = item.物料批次,
|
||||
NeedQty = item.需求数量,
|
||||
TotalQty = inventoryCount,
|
||||
Info = info
|
||||
});
|
||||
}
|
||||
return new ResponseCommon<List<MatInventorySummaryModel>>()
|
||||
{
|
||||
Code = 200,
|
||||
Data = returnList
|
||||
};
|
||||
}
|
||||
public async Task<ResponseBase> SysOutOrderByMatCode(SysOutOrderByMatCodeRequest request)
|
||||
{
|
||||
@ -36,6 +78,24 @@ namespace WCS.BLL.Services.Service
|
||||
Message = "出库单据同步失败:缺少需要出库的物料类型!"
|
||||
};
|
||||
}
|
||||
//补齐货架类型名称
|
||||
if (string.IsNullOrEmpty(request.ShelfTypeName))
|
||||
{
|
||||
var shelfType = await DbHelp.db.Queryable<ShelfTypeInfo>()
|
||||
.Where(t => t.Id == request.ShelfTypeId)
|
||||
.FirstAsync();
|
||||
if (shelfType == null)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"出库单据同步失败:缺少必要参数!ShelfTypeId"
|
||||
};
|
||||
}
|
||||
else
|
||||
request.ShelfTypeName = shelfType.ShelfTypeName;
|
||||
}
|
||||
|
||||
//保存数据
|
||||
await DbHelp.db.BeginTranAsync();
|
||||
try
|
||||
@ -45,6 +105,8 @@ namespace WCS.BLL.Services.Service
|
||||
OrderNumber = request.OrderNumber,
|
||||
OrderSource = request.OrderSource,
|
||||
OrderType = request.OrderType,
|
||||
ShelfTypeId = request.ShelfTypeId,
|
||||
ShelfTypeName = request.ShelfTypeName,
|
||||
SyncType = SyncTypeEnum.ByMatCode,
|
||||
CreateUser = request.UserName,
|
||||
};
|
||||
@ -69,6 +131,7 @@ namespace WCS.BLL.Services.Service
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"出库单据同步成功!\r\n出库单据号为{request.OrderNumber}",
|
||||
Data = request.OrderNumber
|
||||
}; ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -95,103 +158,266 @@ 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,
|
||||
OrderType = request.OrderType,
|
||||
OutOrderExeStatus = OutOrderExeStatus.开始发料,
|
||||
OrderSource = "WCS前端",
|
||||
SyncType = SyncTypeEnum.ByMatSn,
|
||||
ShelfTypeName = "智能货架",
|
||||
ShelfTypeId = 0,
|
||||
GroupName = LocalFile.Config.GroupName,
|
||||
IsMXPD = request.IsMXPD,
|
||||
};
|
||||
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,
|
||||
IsMXPD = request.IsMXPD,
|
||||
};
|
||||
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,
|
||||
IsMXPD = request.IsMXPD,
|
||||
};
|
||||
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 = outOrder.OrderNumber,
|
||||
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 +428,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
|
||||
@ -244,23 +471,33 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
//直接查询
|
||||
var recordsQueryable = DbHelp.db.Queryable<OutOrder>().Where(t => request.OrderExeStatus.Contains(t.OutOrderExeStatus));
|
||||
var recordsQueryable = DbHelp.db.Queryable<OutOrder>()
|
||||
.Where(t => request.OrderExeStatus.Contains(t.OutOrderExeStatus))
|
||||
.WhereIF(request.IsMXPD != null, t => t.IsMXPD == request.IsMXPD)
|
||||
.WhereIF(LocalFile.Config.IsMx, t => t.CreateTime > DateTime.Now.AddDays(-3))
|
||||
.WhereIF(!string.IsNullOrEmpty(LocalFile.Config.GroupName), t => t.GroupName == LocalFile.Config.GroupName);
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.OrderByDescending(t => t.CreateTime)
|
||||
//.Take(request.PageSize)
|
||||
.ToListAsync();
|
||||
|
||||
//获取后台当前正在进行出库的订单 将出库状态反馈给前端
|
||||
var outingOrderNumbers = ShelfManager.Shelves
|
||||
.Where(t => t.CurrentMode == HardWare.Mode.出库模式).Select(t => t.OrderNumber)
|
||||
.ToList();
|
||||
foreach (var record in records)
|
||||
{
|
||||
if (outingOrderNumbers.Contains(record.OrderNumber))
|
||||
record.IsOuting = true;
|
||||
}
|
||||
|
||||
return new PageQueryResponse<OutOrder>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<OutOrder>()
|
||||
{
|
||||
//TotalCount = totalCount,
|
||||
//MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
//Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
@ -325,6 +562,74 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单灯查询物料明细 PDA要求返回数据种data需要增加一层details
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<ResponseBase> GetOutOrderDetailSingleLight(GetOutOrderDetailRequest request)
|
||||
{
|
||||
OutOrder outOrder = null;
|
||||
|
||||
#region 查询出库单
|
||||
if (request.OrderId != 0)
|
||||
{
|
||||
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.Id == request.OrderId).FirstAsync();
|
||||
if (outOrder == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"查询失败:不存在Id为{request.OrderId}的出库单!",
|
||||
};
|
||||
}
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(request.OrderNumber))
|
||||
{
|
||||
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.OrderNumber == request.OrderNumber)
|
||||
.FirstAsync();
|
||||
if (outOrder == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"查询失败:不存在出库单据号为{request.OrderNumber}的出库单!",
|
||||
};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"查询失败:缺少必要参数!",
|
||||
};
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询出库单明细
|
||||
var orderDetailTask = DbHelp.db.Queryable<OutOrderDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.ToListAsync();
|
||||
var orderDetail = await orderDetailTask;
|
||||
//生成序号
|
||||
for (int i = 0; i < orderDetail.Count; i++)
|
||||
{
|
||||
orderDetail[i].RowNumber = i + 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
return new ResponseCommonModify<OutOrderDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Data = new ResponseCommonDataDetail<OutOrderDetail>
|
||||
{
|
||||
Details = orderDetail
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request)
|
||||
{
|
||||
OutOrder outOrder = null;
|
||||
@ -432,7 +737,7 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
|
||||
if (request.IsStart)//&& order.OutOrderExeStatus != OutOrderExeStatus.发料完成
|
||||
if (request.IsStart)
|
||||
{
|
||||
order.OutOrderExeStatus = OutOrderExeStatus.开始发料;
|
||||
DbHelp.db.Updateable(order).ExecuteCommand();
|
||||
@ -457,6 +762,9 @@ namespace WCS.BLL.Services.Service
|
||||
//看是否是分批次出库的情况 分批次亮灯
|
||||
if (LocalFile.Config.IsSameMatCodeOut)
|
||||
{
|
||||
//最先亮的颜色为绿色
|
||||
LocalStatic.CurrentOutStoreColor = 0x02;
|
||||
|
||||
var outOrderDetailCount = outOrderMatDetails.GroupBy(t => t.MatCode)
|
||||
.Select(o => new { count = o.Count(), bb = o })
|
||||
.Where(o => o.count >= 2)
|
||||
@ -468,14 +776,22 @@ namespace WCS.BLL.Services.Service
|
||||
var matCode = outOrderDetailCount.First().bb.Key;
|
||||
outOrderMatDetails = outOrderMatDetails.Where(t => t.MatCode == matCode)
|
||||
.ToList();
|
||||
Logs.Write($"出库单{order.OrderNumber},本次亮灯物料{matCode}!");
|
||||
Logs.Write($"出库单{order.OrderNumber},本次亮灯物料{matCode}!", LogsType.Outstore);
|
||||
|
||||
//分批次亮灯再计算一次出哪些货架 以免亮大灯不亮小灯
|
||||
shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
shelfs = ShelfManager.Shelves.Where(t => shelfIds.Contains(t.ShelfId)).ToList();
|
||||
}
|
||||
//相同物料不存在盘数超过n的情况,剩余物料全部亮灯
|
||||
else
|
||||
{
|
||||
//剩余物料全出
|
||||
Logs.Write($"出库单{order.OrderNumber},剩余物料灯全亮!");
|
||||
Logs.Write($"出库单{order.OrderNumber},剩余物料灯全亮!", LogsType.Outstore);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//对应的货架对应位置 进入出库模式 亮灯
|
||||
@ -486,6 +802,7 @@ namespace WCS.BLL.Services.Service
|
||||
.ToList();
|
||||
shelf.GoInOutstore(matDetails, order);
|
||||
shelf.OrderNumber = order.OrderNumber;
|
||||
Logs.Write($"出库单{order.OrderNumber},货架{shelf.ShelfCode}进入入库模式!", LogsType.Outstore);
|
||||
});
|
||||
|
||||
//返回
|
||||
@ -498,6 +815,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"本次发料发生异常!{ex.Message}", LogsType.Outstore);
|
||||
await GoOutOutstore(request);
|
||||
throw ex;
|
||||
}
|
||||
@ -608,7 +926,7 @@ namespace WCS.BLL.Services.Service
|
||||
Dictionary<string, List<int>> dict = new Dictionary<string, List<int>>();
|
||||
foreach (OutOrderMatDetail oomd in outOrderMatDetails)
|
||||
{
|
||||
List<ModuleInfo> mi= DbHelp.db.Queryable<ModuleInfo>().Where(it => it.ModuleCode == oomd.StoreCode).ToList();
|
||||
List<ModuleInfo> mi = DbHelp.db.Queryable<ModuleInfo>().Where(it => it.ModuleCode == oomd.StoreCode).ToList();
|
||||
if (mi.Count != 0)
|
||||
{
|
||||
if (!StoreCode.Contains(oomd.StoreCode))
|
||||
@ -640,7 +958,7 @@ namespace WCS.BLL.Services.Service
|
||||
{
|
||||
string sendIP = v.Key;
|
||||
TCPClient tCPClient = TCPClientManager.GetTCPClientByIPHost(sendIP);
|
||||
byte[] lightOn = Helper.OutstoreLight(v.Value, LightColor,1);
|
||||
byte[] lightOn = Helper.OutstoreLight(v.Value, LightColor, 1);
|
||||
tCPClient.Send(lightOn);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -660,12 +978,12 @@ namespace WCS.BLL.Services.Service
|
||||
foreach (string shelfcode in WarnLightShelfCode)
|
||||
{
|
||||
List<ShelfInfo> si = DbHelp.db.Queryable<ShelfInfo>().Where(it => it.ShelfCode == shelfcode).ToList();
|
||||
if (si.Count != 0)
|
||||
if (si.Count != 0)
|
||||
{
|
||||
for (int i = 0; i < si.Count; i++)
|
||||
{
|
||||
TCPClient tCPClient = TCPClientManager.GetTCPClientByIPHost(si[i].ClientIp);
|
||||
byte[] warnlightOn = Helper.OutstoreWarnLight(si[i].LightId,LightColor,1,0);
|
||||
byte[] warnlightOn = Helper.OutstoreWarnLight(si[i].LightId, LightColor, 1, 0);
|
||||
tCPClient.Send(warnlightOn);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -675,7 +993,7 @@ namespace WCS.BLL.Services.Service
|
||||
return new OutResponseCommonSingle()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Message = LightColor,
|
||||
Data = orcs.Data
|
||||
};
|
||||
}
|
||||
@ -713,7 +1031,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 +1185,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.出库模式)
|
||||
@ -887,10 +1210,6 @@ namespace WCS.BLL.Services.Service
|
||||
t.GoOutOutstore();
|
||||
});
|
||||
|
||||
//解锁物料 删除物料明细
|
||||
if (order.SyncType == SyncTypeEnum.ByMatCode)
|
||||
CancelOutOrderMatDetails(order);
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
@ -963,7 +1282,7 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
Logs.Write("查询出库单据:"+request.OrderNumber+"对应库位灯颜色失败,"+ ee.Message);
|
||||
Logs.Write("查询出库单据:" + request.OrderNumber + "对应库位灯颜色失败," + ee.Message);
|
||||
}
|
||||
Dictionary<string, List<int>> dict = new Dictionary<string, List<int>>();
|
||||
foreach (OutOrderMatDetail oomd in outOrderMatDetails)
|
||||
@ -1000,7 +1319,7 @@ namespace WCS.BLL.Services.Service
|
||||
{
|
||||
string sendIP = v.Key;
|
||||
TCPClient tCPClient = TCPClientManager.GetTCPClientByIPHost(sendIP);
|
||||
byte[] lightOn = Helper.OutstoreLight(v.Value, LightColor,0);
|
||||
byte[] lightOn = Helper.OutstoreLight(v.Value, LightColor, 0);
|
||||
tCPClient.Send(lightOn);
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
@ -1045,46 +1364,92 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
public async Task<ResponseBase> SingleLightConfirmOutstore(OutOrderMatDetailModelSingle request)
|
||||
{
|
||||
InOutRecord ior = new InOutRecord();
|
||||
List<InventoryDetail> id = DbHelp.db.Queryable<InventoryDetail>().Where(it => it.MatSN == request.MatSn).ToList();
|
||||
if (id.Count == 0)
|
||||
try
|
||||
{
|
||||
//单据校验
|
||||
var order = await DbHelp.db.Queryable<OutOrder>()
|
||||
.Where(it => it.Id == request.OrderId)
|
||||
.Where(it => it.OrderNumber == request.OrderNumber)
|
||||
.FirstAsync();
|
||||
if (order == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"系统不存在单据[{request.OrderNumber}]!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
//物料校验
|
||||
var invetoryDetail = await DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(it => it.Id == request.MatId)
|
||||
.Where(it => it.MatSN == request.MatSn)
|
||||
.FirstAsync();
|
||||
|
||||
if (invetoryDetail == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"库存中不存在物料[{request.MatSn}]!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
//物料需求明细校验
|
||||
var outOrderDetail = await DbHelp.db.Queryable<OutOrderDetail>().Where(it => it.OrderNumber == request.OrderNumber)
|
||||
.Where(it => it.MatCode == invetoryDetail.MatCode)
|
||||
.FirstAsync();
|
||||
if (outOrderDetail == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"单据[{request.OrderNumber}]需求不包含物料[{invetoryDetail.MatCode}]!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
var inOutRecord = new InOutRecord();
|
||||
inOutRecord.StoreId = invetoryDetail.StoreId;
|
||||
inOutRecord.StoreCode = invetoryDetail.StoreCode;
|
||||
inOutRecord.MatSN = invetoryDetail.MatSN;
|
||||
inOutRecord.MatCode = invetoryDetail.MatCode;
|
||||
inOutRecord.MatName = invetoryDetail.MatName;
|
||||
inOutRecord.MatSpec = invetoryDetail.MatSpec;
|
||||
inOutRecord.MatBatch = invetoryDetail.MatBatch;
|
||||
inOutRecord.MatQty = invetoryDetail.MatQty;
|
||||
inOutRecord.MatSupplier = invetoryDetail.MatSupplier;
|
||||
inOutRecord.MatCustomer = invetoryDetail.MatCustomer;
|
||||
inOutRecord.OrderNumber = order.OrderNumber;
|
||||
inOutRecord.Direction = DirectionEnum.出库;
|
||||
inOutRecord.OperateUser = request.UserName;
|
||||
inOutRecord.OperateTime = DateTime.Now;
|
||||
//保存出库记录
|
||||
int count = DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
//删除库存
|
||||
DbHelp.db.Deleteable<InventoryDetail>().Where(it => it.MatSN == request.MatSn).ExecuteCommand();
|
||||
//更新需求表
|
||||
outOrderDetail.OutQty += invetoryDetail.MatQty;
|
||||
DbHelp.db.Updateable(outOrderDetail).ExecuteCommand();
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"此SN不在库存中{request.MatSn}!",
|
||||
Code = 200,
|
||||
Message = $"出库成功",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
ior.StoreId = id[0].StoreId;
|
||||
ior.StoreCode = id[0].StoreCode;
|
||||
ior.MatSN = request.MatSn;
|
||||
ior.MatCode = request.MatCode;
|
||||
ior.MatName = request.MatName;
|
||||
ior.MatSpec = request.MatSpec;
|
||||
ior.MatBatch = request.MatBatch;
|
||||
ior.MatQty = request.Qty;
|
||||
ior.MatSupplier = request.MatSupplier;
|
||||
ior.MatCustomer = request.MatCustomer;
|
||||
ior.OrderNumber = request.orderNumber;
|
||||
ior.Direction = DirectionEnum.出库;
|
||||
ior.OperateUser = request.userName;
|
||||
ior.OperateTime = DateTime.Now;
|
||||
//保存出库记录
|
||||
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();
|
||||
odd[0].OutQty += request.Qty;
|
||||
DbHelp.db.Updateable(odd[0]).ExecuteCommand();
|
||||
|
||||
return new ResponseCommon()
|
||||
catch (Exception ex)
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"出库成功",
|
||||
Data = null
|
||||
};
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"出库发生异常!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
1311
WCS.BLL/Services/Service/OutstoreService.cs.orig
Normal file
1311
WCS.BLL/Services/Service/OutstoreService.cs.orig
Normal file
File diff suppressed because it is too large
Load Diff
@ -7,6 +7,7 @@ using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.SelfCheck;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
@ -42,5 +43,76 @@ namespace WCS.BLL.Services.Service
|
||||
Message = $"货架{string.Join(",", request.ShelfCodes)}已开始自检!",
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ResponseBase> StartSelfCheckByGroupName(List<string> GroupNames)
|
||||
{
|
||||
if (GroupNames == null || GroupNames.Count == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"参数为空!",
|
||||
};
|
||||
}
|
||||
//获取货架
|
||||
var shelfs = ShelfManager.Shelves
|
||||
.Where(t => GroupNames.Contains(t.GroupName))
|
||||
.ToList();
|
||||
var cleintIps = shelfs.Select(t => t.ClientIp).Distinct().ToList();
|
||||
|
||||
foreach (var ip in cleintIps)
|
||||
{
|
||||
var currentIdShelfs = shelfs.Where(t => t.ClientIp == ip)
|
||||
.ToList();
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach(var shelf in currentIdShelfs)
|
||||
{
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
ClientIsReceived = true,
|
||||
WarningType = WarningTypeEnum.通知自检进度,
|
||||
StoreId = 0,
|
||||
StoreCode = "",
|
||||
ShelfCode = shelf.ShelfCode,
|
||||
ShelfId = shelf.ShelfId,
|
||||
ClientIp = shelf.WebSocketIpAddress,
|
||||
WarningMessage = $"货架【{shelf.ShelfCode}】开始自检"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
});
|
||||
|
||||
shelf.ShelfCheck();
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
ClientIsReceived = true,
|
||||
WarningType = WarningTypeEnum.通知自检进度,
|
||||
StoreId = 0,
|
||||
StoreCode = "",
|
||||
ShelfCode = shelf.ShelfCode,
|
||||
ShelfId = shelf.ShelfId,
|
||||
ClientIp = shelf.WebSocketIpAddress,
|
||||
WarningMessage = $"货架【{shelf.ShelfCode}】已完成自检"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
});
|
||||
Thread.Sleep(10);
|
||||
}
|
||||
});
|
||||
}
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"已成功开始自检!",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -788,10 +788,21 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
shelf.ConfirmStocktakingSingle(stockTakingMatDetail.StoreInfo.BoardId, stockTakingMatDetail.StoreInfo.LightNumber);
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
DbHelp.db.CommitTran();
|
||||
|
||||
//更新时间 避免被自动退出
|
||||
Task.Run(() =>
|
||||
{
|
||||
var shelves = ShelfManager.Shelves.Where(t => t.CurrentMode == HardWare.Mode.盘点模式 && t.OrderNumber == request.StocktakingOrderNumber)
|
||||
.ToList();
|
||||
foreach (var shelf in shelves)
|
||||
{
|
||||
shelf.SetCurrentModeTime = DateTime.Now;
|
||||
}
|
||||
});
|
||||
#region 更新Order状态
|
||||
Task.Run(() =>
|
||||
{
|
||||
@ -941,6 +952,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 +966,7 @@ namespace WCS.BLL.Services.Service
|
||||
MatSpec = inventoryDetail.MatSpec,
|
||||
MatCustomer = inventoryDetail.MatCustomer,
|
||||
MatSupplier = inventoryDetail.MatSupplier,
|
||||
OrderNumber = stockTakingOrderMatDetail.StocktakingOrderNumber,
|
||||
|
||||
Direction = DirectionEnum.盘点,
|
||||
OperateUser = request.UserName
|
||||
|
@ -5,13 +5,17 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.StoreInfo;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
@ -50,7 +54,6 @@ namespace WCS.BLL.Services.Service
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -106,7 +109,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 +156,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 +245,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 +318,131 @@ 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}!"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 发送指令获取模组的电压值
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<ResponseCommon> queryModuleVoltage(QueryModuleVoltageRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var modules = await DbHelp.db.Queryable<ModuleInfo>().Where(t => request.MouduleIds.Contains(t.Id)).ToListAsync();
|
||||
var isSend = false;
|
||||
foreach (var module in modules)
|
||||
{
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfId == module.ShelfId).FirstOrDefault();
|
||||
if (shelf != null && shelf is SmartShelf)
|
||||
{
|
||||
var smartShelf = (SmartShelf)shelf;
|
||||
smartShelf.QueryVoltage(module.Id);
|
||||
isSend = true;
|
||||
}
|
||||
}
|
||||
if (isSend)
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success"
|
||||
};
|
||||
else
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "操作失败:未找到对应模组"
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "操作失败:" + ex.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 库位管理
|
||||
@ -352,6 +487,100 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseCommon> disableOrEnableStore(DisableOrEnableStoreRequest request)
|
||||
{
|
||||
//找到库位
|
||||
var storeInfo = await DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.Id == request.StoreId)
|
||||
.FirstAsync();
|
||||
//库位不存在
|
||||
if (storeInfo == null)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:库位{request.SroreCode}不存在!"
|
||||
};
|
||||
}
|
||||
try
|
||||
{
|
||||
DbHelp.db.BeginTran();
|
||||
//禁用需要删除当前库存数据
|
||||
if (request.DisableOrEnable == DisableOrEnableEnum.Disable)
|
||||
{
|
||||
|
||||
//盟讯公司发送钉钉消息
|
||||
if (LocalFile.Config.IsMx)
|
||||
{
|
||||
var DingDing = string.Empty;
|
||||
MXBackgroundThread.SendDingDingMsg($"【智能货架】库位{storeInfo.StoreCode}被屏蔽", new List<string> { "104379", "103595" }, ref DingDing);
|
||||
}
|
||||
|
||||
//库位
|
||||
storeInfo.CurrentMatSn = "禁用";
|
||||
//库存数据处理
|
||||
var inventorys = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.Where(t => t.StoreId == storeInfo.Id)
|
||||
.ToList();
|
||||
if (inventorys != null && inventorys.Count > 0)
|
||||
{
|
||||
//删除并进行出入库记录
|
||||
foreach (var inventory in inventorys)
|
||||
{
|
||||
var inOutRecord = new InOutRecord()
|
||||
{
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
R = storeInfo.R,
|
||||
C = storeInfo.C,
|
||||
Wei = storeInfo.Wei,
|
||||
BigShelfCode = storeInfo.BigShelfCode,
|
||||
GroupName = storeInfo.GroupName,
|
||||
|
||||
MatSN = inventory.MatSN,
|
||||
MatCode = inventory.MatCode,
|
||||
MatName = inventory.MatName,
|
||||
MatSpec = inventory.MatSpec,
|
||||
MatBatch = inventory.MatBatch,
|
||||
MatQty = inventory.MatQty,
|
||||
MatCustomer = inventory.MatCustomer,
|
||||
MatSupplier = inventory.MatSupplier,
|
||||
|
||||
OperateUser = request.UserName + "(禁用库位)",
|
||||
Direction = DirectionEnum.丢失,
|
||||
};
|
||||
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
DbHelp.db.Deleteable(inventory).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
storeInfo.CurrentMatSn = string.Empty;
|
||||
}
|
||||
DbHelp.db.Updateable(storeInfo).ExecuteCommand();
|
||||
DbHelp.db.CommitTran();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"Success"
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:异常{ex.Message}!"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,16 @@ 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.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MXBackgroundThread;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
@ -393,15 +398,67 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
else//登录模式需要校验密码
|
||||
{
|
||||
user = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.Where(t => t.LoginName == request.UserName)
|
||||
.FirstAsync();
|
||||
#region 盟讯公司登录接入系统接口
|
||||
if (LocalFile.Config.IsMx)
|
||||
{
|
||||
#region 调用接口 接入盟讯公司登录
|
||||
try
|
||||
{
|
||||
var body = new
|
||||
{
|
||||
uername = request.UserName,
|
||||
password = request.PassWord,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttpShortTime<MXResponse>("http://192.168.2.23:9213/integrate/login/queryGenerLogin", body, "POST", true);
|
||||
//账号密码验证成功
|
||||
if (Result != null && Result.code == 200)
|
||||
{
|
||||
//判断系统中是否有对应用户
|
||||
user = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.Where(t => t.LoginName == request.UserName)
|
||||
.FirstAsync();
|
||||
//Mes登录成功后wcs这边也添加一个用户
|
||||
if (user == null)
|
||||
{
|
||||
user = new UserBase()
|
||||
{
|
||||
LoginName = request.UserName,
|
||||
Password = request.PassWord,
|
||||
RoleIds = new List<int>() { 2 },
|
||||
IsAdmin = false,
|
||||
Time = DateTime.Now,
|
||||
};
|
||||
await AuthDbHelp.db.Insertable(user).ExecuteCommandAsync();
|
||||
}
|
||||
else if (user.Password != request.PassWord)
|
||||
{
|
||||
user.Password = request.PassWord;
|
||||
await AuthDbHelp.db.Updateable(user).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
//账号密码验证失败
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
if (user == null)
|
||||
user = await AuthDbHelp.db.Queryable<UserBase>()
|
||||
.Where(t => t.LoginName == request.UserName)
|
||||
.FirstAsync();
|
||||
if (user == null)
|
||||
{
|
||||
return new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"登录失败:用户名[{request.UserName}]不存在!",
|
||||
Message = $"登录失败:用户名[{request.UserName}]不存在或密码输入错误!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
@ -440,13 +497,23 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
//返回字串不返回密码
|
||||
user.Password = "***";
|
||||
|
||||
var response = new ResponseCommon<UserBase>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = user
|
||||
};
|
||||
//登录成功
|
||||
if (request.DeviceType == "WCS前端" && request.GroupNames != null)
|
||||
{
|
||||
var shelves = ShelfManager.Shelves.Where(t => request.GroupNames.Contains(t.GroupName))
|
||||
.ToList();
|
||||
foreach (var shelf in shelves)
|
||||
{
|
||||
shelf.WebSocketIpAddress = request.WebSocketIpAddress;
|
||||
}
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -26,6 +26,7 @@ namespace WCS.BLL.Services.Service
|
||||
.FirstOrDefault();
|
||||
if (warning != null)
|
||||
{
|
||||
warning.SolvedUser = request.UserName;
|
||||
WarningManager.ClearWarning(warning, request.SolveType);
|
||||
}
|
||||
//判断一下是否还存在对应报警
|
||||
|
@ -274,7 +274,7 @@ namespace WCS.BLL.Tool
|
||||
public static T GetDataFromHttp<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
var data = JsonConvert.SerializeObject(dataObj);
|
||||
var data = dataObj == null ? string.Empty : JsonConvert.SerializeObject(dataObj);
|
||||
try
|
||||
{
|
||||
if (isSaveLog)
|
||||
@ -312,5 +312,47 @@ namespace WCS.BLL.Tool
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
public static T GetDataFromHttpShortTime<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
var data = dataObj == null ? string.Empty : JsonConvert.SerializeObject(dataObj);
|
||||
try
|
||||
{
|
||||
if (isSaveLog)
|
||||
Logs.Write($"【{guid}】开始请求调用接口 url:{url} 请求方式:{httpMethod} 数据:{data}", LogsType.Api);
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = httpMethod;
|
||||
request.ContentType = "application/json";
|
||||
request.Timeout = 2000;
|
||||
|
||||
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}", LogsType.Api);
|
||||
return JsonConvert.DeserializeObject<T>(retString);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"【{guid}】请求调用遇到异常 异常信息为{ex.Message}");
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
53
WCS.BLL/Tool/DependencyExtensions.cs
Normal file
53
WCS.BLL/Tool/DependencyExtensions.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace WCS.BLL.Tool
|
||||
{
|
||||
/// <summary>
|
||||
/// 一个心跳计数器扩展。
|
||||
/// </summary>
|
||||
internal static class DependencyExtensions
|
||||
{
|
||||
public static readonly DependencyProperty<Timer> HeartbeatTimerProperty =
|
||||
DependencyProperty<Timer>.Register("HeartbeatTimer", null);
|
||||
|
||||
public static bool Ping<TClient>(this TClient client) where TClient : ITcpClientBase
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = new byte[] { 0x05, 0x00, 0x00, 0x06, 0x78, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00 };
|
||||
client.Send(data);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"【{client.IP}:{client.Port}】发送心跳中发现异常:" + ex.Message, LogsType.Info);
|
||||
if (ex is NotConnectedException)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool Pong<TClient>(this TClient client) where TClient : ITcpClientBase
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Send(new MyRequestInfo() { DataType = DataType.Pong }.PackageAsBytes());
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
client.Logger.Exception(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
67
WCS.BLL/Tool/HeartbeatAndReceivePlugin.cs
Normal file
67
WCS.BLL/Tool/HeartbeatAndReceivePlugin.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
|
||||
namespace WCS.BLL.Tool
|
||||
{
|
||||
internal class HeartbeatAndReceivePlugin : PluginBase, ITcpConnectedPlugin<ITcpClientBase>, ITcpDisconnectedPlugin<ITcpClientBase>, ITcpReceivedPlugin<ITcpClientBase>
|
||||
{
|
||||
private readonly int m_timeTick;
|
||||
private readonly ILog logger;
|
||||
|
||||
[DependencyInject("20000")]
|
||||
public HeartbeatAndReceivePlugin(int timeTick, ILog logger)
|
||||
{
|
||||
this.m_timeTick = 20000;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public async Task OnTcpConnected(ITcpClientBase client, ConnectedEventArgs e)
|
||||
{
|
||||
if (client is ISocketClient)
|
||||
{
|
||||
return;//此处可判断,如果为服务器,则不用使用心跳。
|
||||
}
|
||||
|
||||
if (client.GetValue(DependencyExtensions.HeartbeatTimerProperty) is Timer timer)
|
||||
{
|
||||
timer.Dispose();
|
||||
}
|
||||
|
||||
client.SetValue(DependencyExtensions.HeartbeatTimerProperty, new Timer((o) =>
|
||||
{
|
||||
client.Ping();
|
||||
}, null, 0, this.m_timeTick));
|
||||
await e.InvokeNext();
|
||||
}
|
||||
|
||||
public async Task OnTcpDisconnected(ITcpClientBase client, DisconnectEventArgs e)
|
||||
{
|
||||
if (client.GetValue(DependencyExtensions.HeartbeatTimerProperty) is Timer timer)
|
||||
{
|
||||
timer.Dispose();
|
||||
client.SetValue(DependencyExtensions.HeartbeatTimerProperty, null);
|
||||
}
|
||||
|
||||
await e.InvokeNext();
|
||||
}
|
||||
|
||||
public async Task OnTcpReceived(ITcpClientBase client, ReceivedDataEventArgs e)
|
||||
{
|
||||
if (e.RequestInfo is MyRequestInfo myRequest)
|
||||
{
|
||||
this.logger.Info(myRequest.ToString());
|
||||
if (myRequest.DataType == DataType.Ping)
|
||||
{
|
||||
client.Pong();
|
||||
}
|
||||
}
|
||||
await e.InvokeNext();
|
||||
}
|
||||
}
|
||||
}
|
@ -83,6 +83,30 @@ namespace WCS.BLL.Tool
|
||||
return data.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] Query()
|
||||
{
|
||||
byte[] data2 = new byte[4];
|
||||
data2[0] = 0xff;
|
||||
data2[1] = 0x03;
|
||||
data2[2] = 0x00;
|
||||
data2[3] = 0x06;
|
||||
byte[] senddata2 = Tool.Helper.Crc16(data2, data2.Length, true);
|
||||
return senddata2;
|
||||
}
|
||||
|
||||
public static byte[] SetId()
|
||||
{
|
||||
byte[] data2 = new byte[6];
|
||||
data2[0] = 0xff;
|
||||
data2[1] = 0x04;
|
||||
data2[2] = 0x00;
|
||||
data2[3] = 0x08;
|
||||
data2[4] = 0x03;
|
||||
data2[5] = 0x01;
|
||||
byte[] senddata2 = Tool.Helper.Crc16(data2, data2.Length, true);
|
||||
return senddata2;
|
||||
}
|
||||
|
||||
//出库库位灯亮灯
|
||||
public static byte[] OutstoreLight(List<int> board_id, string lightcolor,int status)
|
||||
{
|
||||
@ -200,11 +224,15 @@ namespace WCS.BLL.Tool
|
||||
//入库警示灯短亮(绿色),蜂鸣器鸣叫一次
|
||||
public static byte[] InstoreWarnLight(int lightid)
|
||||
{
|
||||
byte[] data1 = new byte[8];
|
||||
byte[] data1 = new byte[8 + 3 * 6];
|
||||
data1[0] = 0xff;
|
||||
data1[1] = 0x02;
|
||||
data1[2] = 0x00;
|
||||
data1[3] = 0x0a;
|
||||
data1[4] = (byte)lightid;
|
||||
data1[5] = 0x03;
|
||||
data1[6] = 0x02;
|
||||
for (int i = 0; i < 7; i++)
|
||||
{
|
||||
data1[4 + i * 3] = (byte)(lightid + i);
|
||||
@ -214,7 +242,8 @@ namespace WCS.BLL.Tool
|
||||
//data1[4] = (byte)lightid;
|
||||
//data1[5] = 0x03;
|
||||
//data1[6] = 0x02;
|
||||
data1[7] = 0x02;
|
||||
//data1[7] = 0x02;
|
||||
data1[7] = 0x00;
|
||||
byte[] senddata1 = Tool.Helper.Crc16(data1, data1.Length, true);
|
||||
return senddata1;
|
||||
}
|
||||
|
@ -22,18 +22,25 @@ namespace WCS.BLL
|
||||
/// </summary>
|
||||
Info,
|
||||
/// <summary>
|
||||
/// 警告
|
||||
/// 启动信息
|
||||
/// </summary>
|
||||
Warning,
|
||||
StartBoot,
|
||||
/// <summary>
|
||||
/// 错误
|
||||
/// 调用外部Api的接口
|
||||
/// </summary>
|
||||
Err,
|
||||
Api,
|
||||
/// <summary>
|
||||
/// 数据库错误
|
||||
/// 指令发送接收
|
||||
/// </summary>
|
||||
DbErr,
|
||||
Api
|
||||
Instructions,
|
||||
/// <summary>
|
||||
/// 指令重发
|
||||
/// </summary>
|
||||
InstructionResend,
|
||||
/// <summary>
|
||||
/// 出库流程日志
|
||||
/// </summary>
|
||||
Outstore,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -115,16 +122,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>
|
||||
|
85
WCS.BLL/Tool/MyFixedHeaderDataHandlingAdapter .cs
Normal file
85
WCS.BLL/Tool/MyFixedHeaderDataHandlingAdapter .cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
|
||||
namespace WCS.BLL.Tool
|
||||
{
|
||||
|
||||
internal class MyFixedHeaderDataHandlingAdapter : CustomFixedHeaderDataHandlingAdapter<MyRequestInfo>
|
||||
{
|
||||
public override int HeaderLength => 3;
|
||||
|
||||
public override bool CanSendRequestInfo => false;
|
||||
|
||||
protected override MyRequestInfo GetInstance()
|
||||
{
|
||||
return new MyRequestInfo();
|
||||
}
|
||||
|
||||
protected override void PreviewSend(IRequestInfo requestInfo)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
internal class MyRequestInfo : IFixedHeaderRequestInfo
|
||||
{
|
||||
public DataType DataType { get; set; }
|
||||
public byte[] Data { get; set; }
|
||||
|
||||
public int BodyLength { get; private set; }
|
||||
|
||||
public bool OnParsingBody(byte[] body)
|
||||
{
|
||||
if (body.Length == this.BodyLength)
|
||||
{
|
||||
this.Data = body;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool OnParsingHeader(byte[] header)
|
||||
{
|
||||
if (header.Length == 3)
|
||||
{
|
||||
this.BodyLength = TouchSocketBitConverter.Default.ToUInt16(header, 0) - 1;
|
||||
this.DataType = (DataType)header[2];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Package(ByteBlock byteBlock)
|
||||
{
|
||||
byteBlock.Write((ushort)((this.Data == null ? 0 : this.Data.Length) + 1));
|
||||
byteBlock.Write((byte)this.DataType);
|
||||
if (this.Data != null)
|
||||
{
|
||||
byteBlock.Write(this.Data);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] PackageAsBytes()
|
||||
{
|
||||
using var byteBlock = new ByteBlock();
|
||||
this.Package(byteBlock);
|
||||
return byteBlock.ToArray();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"数据类型={this.DataType},数据={(this.Data == null ? "null" : Encoding.UTF8.GetString(this.Data))}";
|
||||
}
|
||||
}
|
||||
|
||||
internal enum DataType : byte
|
||||
{
|
||||
Ping,
|
||||
Pong,
|
||||
Data
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System.Text;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.Tool;
|
||||
|
||||
|
||||
namespace WCS.BLL
|
||||
@ -68,6 +69,7 @@ namespace WCS.BLL
|
||||
{
|
||||
//配置断线重连
|
||||
a.UseReconnection(-1, true, 1000);
|
||||
a.Add<HeartbeatAndReceivePlugin>();
|
||||
})
|
||||
.ConfigureContainer(a =>
|
||||
{
|
||||
@ -79,36 +81,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 +135,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,22 +175,36 @@ 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);
|
||||
Task.Run(() =>
|
||||
{
|
||||
Logs.Write($"【发送】{BitConverter.ToString(message)}", LogsType.Instructions);
|
||||
});
|
||||
//发送自带8ms间隔
|
||||
Thread.Sleep(8);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//因异常断连时(网线已经被断了) 尝试重连一次
|
||||
//因异常断连时(网线已经被断了) 手动重连一次
|
||||
if (ex is NotConnectedException)
|
||||
{
|
||||
Task.Run(() =>
|
||||
@ -226,18 +242,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>
|
||||
|
@ -49,7 +49,7 @@ namespace WCS.DAL
|
||||
{
|
||||
Id = 1,
|
||||
LoginName = "admin",
|
||||
Password = "",
|
||||
Password = "admin123",
|
||||
RoleIds = new List<int> () { 1 },
|
||||
IsAdmin = true,
|
||||
Time = dt,
|
||||
|
@ -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)]
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,10 @@ namespace WCS.Model
|
||||
{
|
||||
public class GetShelfStatusResponse : ResponseBase
|
||||
{
|
||||
public List<Shelf> Data { get; set; }
|
||||
public List<ShelfModel> Data { get; set; }
|
||||
}
|
||||
|
||||
public class Shelf
|
||||
public class ShelfModel
|
||||
{
|
||||
public int ShelfId { get; set; }
|
||||
|
||||
@ -33,5 +33,9 @@ namespace WCS.Model
|
||||
/// 货架组别
|
||||
/// </summary>
|
||||
public string GroupName { get; set; }
|
||||
/// <summary>
|
||||
/// 单据号
|
||||
/// </summary>
|
||||
public string OrderNumber { get; set; }
|
||||
}
|
||||
}
|
||||
|
15
WCS.Model/ApiModel/Home/ResetShelfStatusRequest.cs
Normal file
15
WCS.Model/ApiModel/Home/ResetShelfStatusRequest.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.Home
|
||||
{
|
||||
public class ResetShelfStatusRequest : RequestBase
|
||||
{
|
||||
public List<int> SelfIds { get; set; }
|
||||
|
||||
public bool IsResetAll { get; set; }
|
||||
|
||||
public List<string> GroupNames { get; set; }
|
||||
}
|
||||
}
|
@ -40,5 +40,6 @@ namespace WCS.Model.ApiModel.InOutRecord
|
||||
出库 = 1,
|
||||
丢失 = 2,
|
||||
盘点 = 3,
|
||||
盘点下架 = 4,
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
51
WCS.Model/ApiModel/MXBackgroundThread/ApiResult.cs
Normal file
51
WCS.Model/ApiModel/MXBackgroundThread/ApiResult.cs
Normal 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; }
|
||||
}
|
||||
}
|
27
WCS.Model/ApiModel/MXBackgroundThread/BunkerOutRequest.cs
Normal file
27
WCS.Model/ApiModel/MXBackgroundThread/BunkerOutRequest.cs
Normal 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;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MXBackgroundThread
|
||||
{
|
||||
public class ElectronicSiloPushRequest
|
||||
{
|
||||
public string materialCode { get; set; }
|
||||
public string warehouseCode { get; set; }
|
||||
}
|
||||
|
||||
public class ElectronicSiloPushDto
|
||||
{
|
||||
public string materialBar { get; set; }
|
||||
}
|
||||
}
|
25
WCS.Model/ApiModel/MXBackgroundThread/InputStockInRequest.cs
Normal file
25
WCS.Model/ApiModel/MXBackgroundThread/InputStockInRequest.cs
Normal 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;
|
||||
}
|
||||
}
|
14
WCS.Model/ApiModel/MXBackgroundThread/MXMesResponseCommon.cs
Normal file
14
WCS.Model/ApiModel/MXBackgroundThread/MXMesResponseCommon.cs
Normal 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; }
|
||||
}
|
||||
}
|
72
WCS.Model/ApiModel/MXBackgroundThread/PickOrderRequest.cs
Normal file
72
WCS.Model/ApiModel/MXBackgroundThread/PickOrderRequest.cs
Normal 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; }
|
||||
}
|
||||
}
|
49
WCS.Model/ApiModel/MXBackgroundThread/QueryByBar.cs
Normal file
49
WCS.Model/ApiModel/MXBackgroundThread/QueryByBar.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
13
WCS.Model/ApiModel/MXBackgroundThread/mesLoginRequest.cs
Normal file
13
WCS.Model/ApiModel/MXBackgroundThread/mesLoginRequest.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MXBackgroundThread
|
||||
{
|
||||
public class MXResponse
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string msg { get; set; }
|
||||
public object data { get; set; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
||||
}
|
||||
}
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.OutStore
|
||||
{
|
||||
public class ResponseCommonModify<T>:ResponseCommon
|
||||
{
|
||||
public ResponseCommonDataDetail<T> Data { get; set; }
|
||||
}
|
||||
|
||||
public class ResponseCommonDataDetail<T>
|
||||
{
|
||||
public List<T> Details { get; set; }
|
||||
}
|
||||
}
|
@ -10,5 +10,7 @@ namespace WCS.Model
|
||||
public class GetOutOrderListByStatusRequest : PageQueryRequestBase
|
||||
{
|
||||
public List<OutOrderExeStatus> OrderExeStatus { get; set; }
|
||||
|
||||
public bool? IsMXPD { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ namespace WCS.Model
|
||||
public string OrderSource { get; set; }
|
||||
|
||||
public string OrderType { get; set; }
|
||||
|
||||
public int ShelfTypeId { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
14
WCS.Model/ApiModel/OutStore/OutImportMatModel.cs
Normal file
14
WCS.Model/ApiModel/OutStore/OutImportMatModel.cs
Normal 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; }
|
||||
}
|
||||
}
|
@ -4,19 +4,12 @@ using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.OutStore
|
||||
{
|
||||
public class OutOrderMatDetailModelSingle
|
||||
public class OutOrderMatDetailModelSingle:RequestBase
|
||||
{
|
||||
public int orderId { get; set; }
|
||||
public string orderNumber { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
public int MatId { get; set; }
|
||||
public string MatSn { get; set; }
|
||||
public string MatCode { get; set; }
|
||||
public string MatName { get; set; }
|
||||
public string MatSpec { get; set; }
|
||||
public string MatBatch { get; set; }
|
||||
public int MatQty { get; set; }
|
||||
public string MatCustomer { get; set; }
|
||||
public string MatSupplier { get; set; }
|
||||
public int Qty { get; set; }
|
||||
public string userName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ namespace WCS.Model.ApiModel.OutStore
|
||||
}
|
||||
public bool isSelected;
|
||||
public int RowNumber { get; set; }
|
||||
public bool IsOuting { get; set; }
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
|
@ -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; }
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,11 @@ namespace WCS.Model
|
||||
/// </summary>
|
||||
public string OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否是盟讯公司盘点生成的出库单
|
||||
/// </summary>
|
||||
public bool IsMXPD { get; set; } = false;
|
||||
|
||||
public List<string> SnList { get; set; }
|
||||
}
|
||||
}
|
||||
|
15
WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs
Normal file
15
WCS.Model/ApiModel/StoreInfo/DisableOrEnableModuleRequest.cs
Normal 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; }
|
||||
}
|
||||
}
|
22
WCS.Model/ApiModel/StoreInfo/DisableOrEnableStoreRequest.cs
Normal file
22
WCS.Model/ApiModel/StoreInfo/DisableOrEnableStoreRequest.cs
Normal 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
|
||||
}
|
||||
|
||||
}
|
@ -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; }
|
||||
|
||||
|
11
WCS.Model/ApiModel/StoreInfo/QueryModuleVoltageRequest.cs
Normal file
11
WCS.Model/ApiModel/StoreInfo/QueryModuleVoltageRequest.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.StoreInfo
|
||||
{
|
||||
public class QueryModuleVoltageRequest : RequestBase
|
||||
{
|
||||
public List<int> MouduleIds { get; set; }
|
||||
}
|
||||
}
|
@ -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; }
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
|
@ -21,10 +21,20 @@ namespace WCS.Model.WebSocketModel
|
||||
/// </summary>
|
||||
public string ClientIp { get; set; }
|
||||
public DateTime LastSendTime { get; set; }
|
||||
/// <summary>
|
||||
/// 消息创建时间 跟消息时效性有关
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
public bool ClientIsReceived { get; set; }
|
||||
|
||||
//恢复正常需要消除的报警guid
|
||||
public List<Guid> SolvedGuids { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异常处理人
|
||||
/// </summary>
|
||||
public string SolvedUser { get; set; }
|
||||
}
|
||||
|
||||
public enum WarningTypeEnum
|
||||
@ -46,9 +56,17 @@ namespace WCS.Model.WebSocketModel
|
||||
进入盘点未响应 = 12,
|
||||
确认盘点未响应 = 13,
|
||||
退出盘点未响应 = 14,
|
||||
|
||||
自检丢失 = 15,
|
||||
自检未扫描上架 = 16,
|
||||
|
||||
//通知类
|
||||
恢复正常 = 50,
|
||||
通知刷新出库 = 51,
|
||||
通知刷新盘点 = 52,
|
||||
通知刷新盟讯盘点 = 53,
|
||||
通知前台结束入库 = 54,
|
||||
通知刷新出库单列表 = 55,
|
||||
通知自检进度 = 56,
|
||||
}
|
||||
}
|
||||
|
83
WCS.WebApi/Controllers/FileDownLoadController.cs
Normal file
83
WCS.WebApi/Controllers/FileDownLoadController.cs
Normal 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安装包"
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Services.Service;
|
||||
@ -18,10 +19,12 @@ namespace WCS.WebApi.Controllers
|
||||
public class HomeController : ControllerBase
|
||||
{
|
||||
public IHomerService _homerService { get; set; }
|
||||
public ISelfCheckService _selfCheckService { get; set; }
|
||||
|
||||
public HomeController(IHomerService homerService)
|
||||
public HomeController(IHomerService homerService, ISelfCheckService selfCheckService)
|
||||
{
|
||||
_homerService = homerService;
|
||||
_selfCheckService = selfCheckService;
|
||||
}
|
||||
|
||||
[Route("getShelfTypes")]
|
||||
@ -73,21 +76,104 @@ namespace WCS.WebApi.Controllers
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
Data = shelfs.Select(t => new Shelf
|
||||
Data = shelfs.Select(t => new ShelfModel
|
||||
{
|
||||
ShelfId = t.ShelfId,
|
||||
ShelfCode = t.ShelfCode,
|
||||
CurentMode = (int)t.CurrentMode,
|
||||
ModulesStr = t.ModulesStr,
|
||||
GroupName = t.GroupName
|
||||
GroupName = t.GroupName,
|
||||
OrderNumber = t.OrderNumber,
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "获取失败:" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Route("shelfCheckAll")]
|
||||
[HttpPost(Name = "shelfCheckAll")]
|
||||
public async Task<ResponseBase> shelfCheckAll(GetShelfStatusRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _selfCheckService.StartSelfCheckByGroupName(request.GroupNames);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "操作失败:" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置货架的状态 使其回到待机模式
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[Route("resetShelfStatus")]
|
||||
[HttpPost(Name = "resetShelfStatus")]
|
||||
public async Task<ResponseBase> resetShelfStatus(ResetShelfStatusRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (request.IsResetAll == false && (request.SelfIds == null || request.SelfIds.Count == 0))
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "复位失败:请选择需要复位的货架!",
|
||||
};
|
||||
}
|
||||
if (request.IsResetAll == true && (request.GroupNames == null || request.GroupNames.Count == 0))
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "复位失败:请选择需要复位的货架区域!",
|
||||
};
|
||||
}
|
||||
var shelfs = new List<IShelfBase>();
|
||||
if (request.IsResetAll == false)
|
||||
shelfs = ShelfManager.Shelves
|
||||
.Where(t => request.SelfIds.Contains(t.ShelfId))
|
||||
.Where(t => t.CurrentMode != Mode.待机模式)
|
||||
.ToList();
|
||||
else
|
||||
shelfs = ShelfManager.Shelves
|
||||
.Where(t => request.GroupNames.Contains(t.GroupName))
|
||||
.Where(t => t.CurrentMode != Mode.待机模式)
|
||||
.ToList();
|
||||
foreach (var shelf in shelfs)
|
||||
{
|
||||
shelf.Reset();
|
||||
}
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "success",
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 300,
|
||||
Message = ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WebApi.Controllers
|
||||
@ -141,9 +142,12 @@ namespace WebApi.Controllers
|
||||
//TODO:<3A><><EFBFBD><EFBFBD> <20><><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD>ύ<EFBFBD><E1BDBB><EFBFBD><EFBFBD>
|
||||
try
|
||||
{
|
||||
var aa = Helper.Query();
|
||||
var bb = Helper.SetId();
|
||||
return await _instoreService.queryInstoreStatusSingle(request);
|
||||
//ShelfManager.
|
||||
//
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
@ -62,7 +106,12 @@ namespace WebApi.Controllers
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.OrderNumber))
|
||||
{
|
||||
request.OrderNumber = await _generateService.generateOutOrderNumber();
|
||||
if (request.IsMXPD)
|
||||
{
|
||||
request.OrderNumber = await _generateService.generateMXPDOutOrderNumber();
|
||||
}
|
||||
else
|
||||
request.OrderNumber = await _generateService.generateOutOrderNumber();
|
||||
}
|
||||
return await _outstoreService.SysOutOrderByMatSn(request);
|
||||
}
|
||||
@ -146,6 +195,25 @@ namespace WebApi.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
[Route("getOutOrderDetailSingleLight")]
|
||||
[HttpPost(Name = "getOutOrderDetailSingleLight")]
|
||||
public async Task<ResponseBase> getOutOrderDetailSingleLight(GetOutOrderDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _outstoreService.GetOutOrderDetailSingleLight(request);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ⵥ<EFBFBD><E2B5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ
|
||||
/// </summary>
|
||||
|
@ -72,28 +72,45 @@ namespace WCS.WebApi.Controllers
|
||||
|
||||
finally
|
||||
{
|
||||
var guid = Guid.NewGuid();
|
||||
//TO DO如何将记日志的 和不记日志的分开 解耦
|
||||
if (!context.Request.Path.ToString().Contains("getInterfaceRecord"))
|
||||
{
|
||||
try
|
||||
{
|
||||
Logs.Write($"[记录接口日志]{guid},开始记录{context.Request.Path.ToString()}", LogsType.Api);
|
||||
var logRecord = new SystemApiLogRecord()
|
||||
{
|
||||
DeviceIp = context?.Connection?.RemoteIpAddress?.ToString(),
|
||||
RequestUrl = context.Request.Path,
|
||||
RequestUrl = context.Request?.Path.ToString(),
|
||||
RequestBody = requestBody,
|
||||
QueryString = context.Request.QueryString.ToString(),
|
||||
QueryString = context.Request?.QueryString.ToString(),
|
||||
IsResponse = true,
|
||||
ResponseJson = responseBody,
|
||||
RequestTime = requestTime,
|
||||
ResponseTime = DateTime.Now,
|
||||
ExecutionTime = stopwatch.ElapsedMilliseconds
|
||||
};
|
||||
await DbHelp.dbLog.Insertable(logRecord).ExecuteCommandAsync();
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
DbHelp.dbLog.Insertable(logRecord).ExecuteCommand();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"[记录接口日志]{guid}保存数据失败!发生异常:" + ex.Message, LogsType.Api);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//TO DO txt记录失败的日志和响应实体
|
||||
Logs.Write($"[记录接口日志]{guid}失败!发生异常:" + e.Message, LogsType.Api);
|
||||
}
|
||||
}
|
||||
else
|
||||
Logs.Write($"[记录接口日志]{guid},不记录getInterfaceRecord", LogsType.Api);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,20 @@ 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);
|
||||
}
|
||||
|
||||
[Route("queryModuleVoltage")]
|
||||
[HttpPost(Name = "queryModuleVoltage")]
|
||||
public async Task<ResponseBase> queryModuleVoltage(QueryModuleVoltageRequest request)
|
||||
{
|
||||
return await _storeInfoService.queryModuleVoltage(request);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 库位管理
|
||||
@ -61,6 +75,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
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,6 @@ using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace WCS.WebApi.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限/用户界面的接口
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WarningController : ControllerBase
|
||||
@ -27,5 +24,7 @@ namespace WCS.WebApi.Controllers
|
||||
{
|
||||
return await _warningService.SolveWarning(request);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
using WCS.BLL;
|
||||
|
||||
namespace WCS.WebApi
|
||||
{
|
||||
public static class LocalStatic
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user