添加报警窗口
出库流程调试、优化
This commit is contained in:
@ -12,5 +12,7 @@ namespace WCS.BLL.Config
|
||||
public class JsConfig
|
||||
{
|
||||
public List<string> ModuleCodePatterns { get; set; }
|
||||
|
||||
public bool IsSameMatCodeOut { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
|
||||
namespace WCS.BLL.DbModels
|
||||
{
|
||||
@ -61,12 +62,4 @@ namespace WCS.BLL.DbModels
|
||||
public bool IsSelected { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public enum StocktakingOrderStatus
|
||||
{
|
||||
未盘点 = 0,
|
||||
部分盘点 = 1,
|
||||
盘点完成 = 2,
|
||||
已提交 = 3
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ namespace WCS.BLL.HardWare
|
||||
/// </summary>
|
||||
public interface IShelfBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 货架是否处于报警中
|
||||
/// </summary>
|
||||
public bool IsWarning { get; set; }
|
||||
/// <summary>
|
||||
/// 货架ID 数据库中那个
|
||||
/// </summary>
|
||||
@ -39,7 +43,7 @@ namespace WCS.BLL.HardWare
|
||||
/// <summary>
|
||||
/// 货架当前模式
|
||||
/// </summary>
|
||||
public Mode CurentMode { get; set; }
|
||||
public Mode CurrentMode { get; set; }
|
||||
|
||||
public MatInfoResponse InStoreData { get; set; }
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace WCS.BLL.HardWare
|
||||
data[5] = (byte)lightBuzzerStatus;
|
||||
|
||||
//Only For Debug
|
||||
data[5] = (byte)LightBuzzerStatus.关闭;
|
||||
//data[5] = (byte)LightBuzzerStatus.关闭;
|
||||
|
||||
data[4] = time;//灯短亮一次的时间
|
||||
data[6] = time;//蜂鸣器持续鸣叫的时间
|
||||
|
@ -14,7 +14,7 @@ namespace WCS.BLL.HardWare
|
||||
public string ShelfCode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public int RowCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public int ColumnCounts { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public Mode CurentMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public Mode CurrentMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string ModulesStr { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
public string GroupName { get; set; }
|
||||
public MatInfoResponse InStoreData { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
@ -24,6 +24,7 @@ namespace WCS.BLL.HardWare
|
||||
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 void GoInInstore(string IPAdress)
|
||||
{
|
||||
|
@ -6,12 +6,14 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.WebSocketModel;
|
||||
using static System.Formats.Asn1.AsnWriter;
|
||||
|
||||
namespace WCS.BLL.HardWare
|
||||
@ -27,7 +29,7 @@ namespace WCS.BLL.HardWare
|
||||
ShelfCode = shelfInfo.ShelfCode;
|
||||
RowCounts = shelfInfo.Rowcounts;
|
||||
ColumnCounts = shelfInfo.Columncounts;
|
||||
CurentMode = shelfInfo.CurrentMode;
|
||||
CurrentMode = shelfInfo.CurrentMode;
|
||||
ClientIp = shelfInfo.ClientIp;
|
||||
LightId = shelfInfo.LightId;
|
||||
WarningLight = new WarningLight() { LightId = shelfInfo.LightId };
|
||||
@ -96,18 +98,39 @@ namespace WCS.BLL.HardWare
|
||||
//TcpCleint.Connect();
|
||||
}
|
||||
|
||||
|
||||
public int ShelfId { get; set; }
|
||||
public string ShelfCode { get; set; }
|
||||
public int RowCounts { get; set; }
|
||||
public int ColumnCounts { get; set; }
|
||||
public Mode CurentMode { get; set; }
|
||||
public Mode CurrentMode { get; set; }
|
||||
public string ModulesStr { get; set; }//当前货架所有模组的Str
|
||||
public string GroupName { get; set; }
|
||||
public List<SmartShelfModule> Modules { get; set; } = new List<SmartShelfModule>();
|
||||
public TCPClient TcpCleint { get { return TCPClientManager.GetTCPClientByIPHost(ClientIp); } }
|
||||
|
||||
public int LightId { get; set; }
|
||||
public bool IsWarning { get; set; } = false;
|
||||
public WarningLight WarningLight { get; set; }
|
||||
public void ClearWarning()
|
||||
{
|
||||
if (this.CurrentMode == Mode.入库模式)
|
||||
{
|
||||
WarningLight.BlueLight(TcpCleint);
|
||||
}
|
||||
else if (this.CurrentMode == Mode.出库模式)
|
||||
{
|
||||
WarningLight.GreenLight(TcpCleint);
|
||||
}
|
||||
else if (this.CurrentMode == Mode.盘点模式)
|
||||
{
|
||||
WarningLight.GreenLight(TcpCleint);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningLight.CloseLight(TcpCleint);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 自检异常、未响应对应模式的异常
|
||||
/// </summary>
|
||||
@ -136,19 +159,19 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.CurentMode == Mode.入库模式)
|
||||
if (this.CurrentMode == Mode.入库模式)
|
||||
{
|
||||
CurrentCom = IPAddress;
|
||||
return;
|
||||
}
|
||||
//判断当前模式是否为待机模式
|
||||
else if (this.CurentMode != Mode.待机模式)
|
||||
else if (this.CurrentMode != Mode.待机模式)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurentMode = Mode.入库模式;
|
||||
this.CurrentMode = Mode.入库模式;
|
||||
}
|
||||
//清空错误
|
||||
ExceptionMessages.Clear();
|
||||
@ -200,10 +223,15 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!");
|
||||
}
|
||||
//通信校验
|
||||
|
||||
IsWarning = true;
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
}
|
||||
|
||||
//警示灯亮起
|
||||
WarningLight.BlueLight(TcpCleint);
|
||||
//没有报警才亮蓝灯
|
||||
if(!IsWarning)
|
||||
WarningLight.BlueLight(TcpCleint);
|
||||
//绑定当前进入入库PDA/WCS前端的IP
|
||||
CurrentCom = IPAddress;
|
||||
//返回成功
|
||||
@ -219,13 +247,13 @@ namespace WCS.BLL.HardWare
|
||||
public void GoOutInstore()
|
||||
{
|
||||
//当前货架是否为入库模式
|
||||
if (CurentMode != Mode.入库模式)
|
||||
if (CurrentMode != Mode.入库模式)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.CurentMode = Mode.待机模式;
|
||||
this.CurrentMode = Mode.待机模式;
|
||||
}
|
||||
|
||||
//清空错误
|
||||
@ -262,7 +290,7 @@ namespace WCS.BLL.HardWare
|
||||
.ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
CurentMode = Mode.待机模式;
|
||||
CurrentMode = Mode.待机模式;
|
||||
foreach (var item in list)
|
||||
{
|
||||
ExceptionMessages.Add($"模组{item.ModuleCode}未成功退出入库模式!");
|
||||
@ -275,11 +303,11 @@ namespace WCS.BLL.HardWare
|
||||
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder)
|
||||
{
|
||||
//第一步:设置货架当前模式
|
||||
if (CurentMode != Mode.待机模式)
|
||||
if (CurrentMode != Mode.待机模式)
|
||||
{
|
||||
Modules.ForEach(t => { t.Reset(TcpCleint); });
|
||||
}
|
||||
CurentMode = Mode.出库模式;
|
||||
CurrentMode = Mode.出库模式;
|
||||
|
||||
//第二步:货架添加需要出的SN 出库的领料单号
|
||||
//移除货架所有现有待出库的MatSN
|
||||
@ -292,12 +320,13 @@ namespace WCS.BLL.HardWare
|
||||
////第三步:对应的模组进入出库模式
|
||||
var boardIds = MatDetails.Select(t => t.StoreInfo.BoardId)
|
||||
.Distinct()
|
||||
.OrderBy(t => t)
|
||||
.ToList();
|
||||
var outModules = Modules.Where(t => boardIds.Contains(t.BoardId)).ToList();
|
||||
outModules.ForEach(t =>
|
||||
{
|
||||
var outMatSns = MatDetails.Where(t => t.StoreInfo.ModuleId == t.Id)
|
||||
.Select(t => t.MatSN)
|
||||
var outMatSns = MatDetails.Where(mat => mat.StoreInfo.BoardId == t.BoardId)
|
||||
.Select(mat => mat.MatSN)
|
||||
.ToList();
|
||||
t.GoInOutStoreMode(TcpCleint, outMatSns);
|
||||
});
|
||||
@ -307,7 +336,7 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
public void GoInStocktaking()
|
||||
{
|
||||
this.CurentMode = Mode.盘点模式;
|
||||
this.CurrentMode = Mode.盘点模式;
|
||||
}
|
||||
|
||||
public void GoOutOutstore()
|
||||
@ -319,14 +348,14 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
module.GoOutOutStoreMode(TcpCleint);
|
||||
}
|
||||
CurrentOutOrder = null;
|
||||
CurrentOutStoreMatSNs.Clear();
|
||||
this.CurentMode = Mode.待机模式;
|
||||
WarningLight.CloseLight(TcpCleint);
|
||||
this.CurrentMode = Mode.待机模式;
|
||||
}
|
||||
|
||||
public void GoOutStocktaking()
|
||||
{
|
||||
this.CurentMode = Mode.待机模式;
|
||||
this.CurrentMode = Mode.待机模式;
|
||||
}
|
||||
|
||||
void IShelfBase.Reset()
|
||||
@ -407,7 +436,6 @@ namespace WCS.BLL.HardWare
|
||||
.FirstOrDefault();
|
||||
if (module == null)
|
||||
{
|
||||
//TO DO 报错
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -421,7 +449,6 @@ namespace WCS.BLL.HardWare
|
||||
var module = this.Modules.Where(t => t.BoardId == boardId).FirstOrDefault();
|
||||
if (module == null)
|
||||
{
|
||||
//TO DO 报错
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -467,47 +494,63 @@ namespace WCS.BLL.HardWare
|
||||
ExceptionMessages.Add($"{storeInfo.StoreCode}物料{storeInfo.CurrentMatSn}丢失,库存数据已删除,请重新扫码后入库");
|
||||
#endregion
|
||||
|
||||
#region 【后台】丢失的数据处理
|
||||
Task.Run(() =>
|
||||
//#region 【后台】丢失的数据处理
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// DbHelp.db.BeginTran();
|
||||
// //库位表字段清空
|
||||
// storeInfo.CurrentMatSn = string.Empty;
|
||||
// DbHelp.db.Updateable(storeInfo).ExecuteCommand();
|
||||
|
||||
// //库存表记录删除、插入出入记录
|
||||
// var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.StoreId == storeInfo.Id).First();
|
||||
// if (inventoryDetail != null)
|
||||
// {
|
||||
// var inOutRecord = new InOutRecord()
|
||||
// {
|
||||
// StoreCode = storeInfo.StoreCode,
|
||||
// StoreId = storeInfo.Id,
|
||||
// StoreInfo = storeInfo,
|
||||
|
||||
// MatSN = inventoryDetail.MatSN,
|
||||
// MatCode = inventoryDetail.MatCode,
|
||||
// MatName = inventoryDetail.MatName,
|
||||
// MatBatch = inventoryDetail.MatBatch,
|
||||
// MatQty = inventoryDetail.MatQty,
|
||||
// MatSpec = inventoryDetail.MatSpec,
|
||||
// MatCustomer = inventoryDetail.MatCustomer,
|
||||
// MatSupplier = inventoryDetail.MatSupplier,
|
||||
|
||||
// Direction = DirectionEnum.丢失,
|
||||
// };
|
||||
// DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
// DbHelp.db.Deleteable(inventoryDetail).ExecuteCommand();
|
||||
// }
|
||||
// DbHelp.db.CommitTran();
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// DbHelp.db.RollbackTran();
|
||||
// }
|
||||
//});
|
||||
//#endregion
|
||||
#region 不处理、WebSocket通知前台
|
||||
var exceptionMessage = storeInfo.StoreCode + $"进入入库自检发现物料{storeInfo.CurrentMatSn}丢失,请确认是否删除?";
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
try
|
||||
{
|
||||
DbHelp.db.BeginTran();
|
||||
//库位表字段清空
|
||||
storeInfo.CurrentMatSn = string.Empty;
|
||||
DbHelp.db.Updateable(storeInfo).ExecuteCommand();
|
||||
|
||||
//库存表记录删除、插入出入记录
|
||||
var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.StoreId == storeInfo.Id).First();
|
||||
if (inventoryDetail != null)
|
||||
{
|
||||
var inOutRecord = new InOutRecord()
|
||||
{
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
MatSN = inventoryDetail.MatSN,
|
||||
MatCode = inventoryDetail.MatCode,
|
||||
MatName = inventoryDetail.MatName,
|
||||
MatBatch = inventoryDetail.MatBatch,
|
||||
MatQty = inventoryDetail.MatQty,
|
||||
MatSpec = inventoryDetail.MatSpec,
|
||||
MatCustomer = inventoryDetail.MatCustomer,
|
||||
MatSupplier = inventoryDetail.MatSupplier,
|
||||
|
||||
Direction = DirectionEnum.丢失,
|
||||
};
|
||||
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
DbHelp.db.Deleteable(inventoryDetail).ExecuteCommand();
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
}
|
||||
});
|
||||
WarningType = WarningTypeEnum.入库自检丢失,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
ModuleId = module.ModuleId,
|
||||
ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
#endregion
|
||||
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
@ -526,6 +569,24 @@ namespace WCS.BLL.HardWare
|
||||
#region 缓存记录异常信息
|
||||
ExceptionMessages.Add($"库位{storeInfo.StoreCode}:存在物料未扫描上架");
|
||||
#endregion
|
||||
|
||||
#region 不处理、WebSocket通知前台
|
||||
var exceptionMessage = $"进入入库自检发现库位{storeInfo.StoreCode}存在物料未扫描上架,请拿下后点击【确认】消除报警";
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.入库自检未扫描上架,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
ModuleId = module.ModuleId,
|
||||
ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
#endregion
|
||||
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
}
|
||||
else
|
||||
@ -596,7 +657,20 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
Logs.Write("协议处理5.5");
|
||||
var exceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.入库中未扫描上架,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
ModuleId = module.ModuleId,
|
||||
ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!",
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
Logs.Write("协议处理5.4");
|
||||
module.ComfirmErrInstore(TcpCleint);
|
||||
WarningLight.WaringLightAlwaysRed(TcpCleint);
|
||||
@ -608,8 +682,6 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
module.ComfirmErrInstore(TcpCleint);
|
||||
WarningLight.WaringLightBlueEnd(TcpCleint);
|
||||
//ComfirmErrInstoreByIp(shelfStatus.ClientIp, boardIds);
|
||||
//WaringLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId);
|
||||
//TO DO Logs.Write($"[{guid}]该位置已放置物料!");
|
||||
return;
|
||||
}
|
||||
@ -703,11 +775,11 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
Logs.Write("协议处理5.1");
|
||||
lightNumber = (int)data[TcpCleint.PreFixLength + 4];
|
||||
var store = DbHelp.db.Queryable<StoreInfo>()
|
||||
var storeInfo = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
|
||||
.First();
|
||||
Logs.Write("协议处理5.2");
|
||||
if (store == null)
|
||||
if (storeInfo == null)
|
||||
{
|
||||
//TO DO 库位未找到
|
||||
return;
|
||||
@ -718,9 +790,30 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = store.StoreCode + "恢复正常!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warnings = WarningManager.Warnings.Where(t => t.IsWarning = true)
|
||||
.Where(t => t.ShelfId == ShelfId && t.StoreId == storeInfo.Id)
|
||||
.ToList();
|
||||
|
||||
var exceptionMessage = storeInfo.StoreCode + "恢复正常!";
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
WarningType = WarningTypeEnum.恢复正常,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
//自动消除本地缓存的报警
|
||||
warnings.ForEach(warning =>
|
||||
{
|
||||
WarningManager.ClearWarning(warning, SolveTypeEnum.忽略);
|
||||
});
|
||||
|
||||
ProcessingExceptions.RemoveAll(t => t.BoardId == boardId);
|
||||
Logs.Write("协议处理5.5");
|
||||
}
|
||||
@ -728,13 +821,27 @@ namespace WCS.BLL.HardWare
|
||||
case 0x01:
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var exceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.入库中未扫描上架,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
//ModuleId = module.ModuleId,
|
||||
//ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!"
|
||||
ExceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!"
|
||||
});
|
||||
Logs.Write("协议处理5.5");
|
||||
}
|
||||
@ -742,13 +849,27 @@ namespace WCS.BLL.HardWare
|
||||
case 0x02:
|
||||
{
|
||||
Logs.Write("协议处理5.4");
|
||||
var exceptionMessage = store.StoreCode + "物料被取出!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.入库中异常取出,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
//ModuleId = module.ModuleId,
|
||||
//ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "入库过程中物料丢失!"
|
||||
ExceptionMessage = storeInfo.StoreCode + "入库过程中物料丢失!"
|
||||
});
|
||||
Logs.Write("协议处理5.5");
|
||||
}
|
||||
@ -906,7 +1027,7 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
public void OutstoreReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
if (CurentMode != Mode.出库模式)
|
||||
if (CurrentMode != Mode.出库模式)
|
||||
{
|
||||
//TO DO 未在出库模式 要报错
|
||||
Logs.Write($"出库错误:{ShelfCode}该货架模式不是出库模式或盘点模式!");
|
||||
@ -1016,16 +1137,23 @@ namespace WCS.BLL.HardWare
|
||||
|
||||
//确认本次出库
|
||||
module.ComfirmOutstore(TcpCleint, data[TcpCleint.PreFixLength + 3]);
|
||||
|
||||
//通知前台刷新
|
||||
Task.Run(() =>
|
||||
{
|
||||
//给信号通知出库页面更新页面的状态
|
||||
var messageMode = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
ClientIp = "127.0.0.1",
|
||||
WarningType = WarningTypeEnum.通知刷新出库
|
||||
};
|
||||
WarningManager.SendWarning(messageMode);
|
||||
});
|
||||
|
||||
//当前柜子是否还存在未出库的
|
||||
CurrentOutStoreMatSNs.RemoveAll(t => t == matSN);//删除本次已出的物料SN
|
||||
|
||||
|
||||
var isExsistOut = CurrentOutStoreMatSNs.Any();
|
||||
|
||||
//本批次出库已完成
|
||||
if (!isExsistOut)
|
||||
{
|
||||
@ -1033,8 +1161,97 @@ namespace WCS.BLL.HardWare
|
||||
GoOutOutstore();
|
||||
WarningLight.CloseLight(TcpCleint);
|
||||
var currentPickBillNumber = CurrentOutOrder.OrderNumber;
|
||||
//OrderNumber = string.Empty;
|
||||
CurrentOutOrder = null;
|
||||
}
|
||||
|
||||
//看是否是分批次出库的情况 分批次亮灯
|
||||
if (LocalFile.Config.IsSameMatCodeOut)
|
||||
{
|
||||
#region 触发下一批次的精准发料
|
||||
//查一下是否是当前发料单最后一个货架(在出库模式 同一个发料单下)
|
||||
var isLastShelf = ShelfManager.Shelves
|
||||
.Where(t => t.OrderNumber == OrderNumber)
|
||||
.Where(t => t.CurrentMode == Mode.出库模式)
|
||||
.Any();
|
||||
if (!isLastShelf)
|
||||
{
|
||||
Logs.Write($"发料单{OrderNumber},最后一个出库货架,触发精准发料机制!查询是否还存在待出库物料");
|
||||
var outOrder = DbHelp.db.Queryable<OutOrder>()
|
||||
.Where(t => t.OrderNumber == OrderNumber)
|
||||
.First();
|
||||
if (outOrder != null)
|
||||
{
|
||||
var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == outOrder.Id)
|
||||
.Where(t => t.IsSended == false)
|
||||
.Includes(t => t.StoreInfo)
|
||||
.ToList();
|
||||
|
||||
if (outOrderMatDetails != null && outOrderMatDetails.Count > 0)
|
||||
{
|
||||
//存在待出库 然后之前又没亮灯的情况 => 精准发料分批次亮灯
|
||||
Logs.Write($"发料单{OrderNumber},还有物料未出!");
|
||||
var outOrderDetailCount = outOrderMatDetails.GroupBy(t => t.MatCode)
|
||||
.Select(o => new { count = o.Count(), bb = o })
|
||||
.Where(o => o.count >= 2)
|
||||
.OrderByDescending(o => o.count)
|
||||
.ToList();
|
||||
//相同物料存在盘数超过2的情况,亮下一个盘数多的物料
|
||||
if (outOrderDetailCount.Count > 0)
|
||||
{
|
||||
var matCode = outOrderDetailCount.First().bb.Key;
|
||||
outOrderMatDetails = outOrderMatDetails.Where(t => t.MatCode == matCode)
|
||||
.ToList();
|
||||
Logs.Write($"发料单{OrderNumber},本次亮灯物料{matCode}!");
|
||||
}
|
||||
//相同物料不存在盘数超过n的情况,剩余物料全部亮灯
|
||||
else
|
||||
{
|
||||
//剩余物料全出
|
||||
Logs.Write($"发料单{OrderNumber},剩余物料灯全亮!");
|
||||
}
|
||||
|
||||
var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var shelfs = ShelfManager.Shelves.Where(t => shelfIds.Contains(t.ShelfId)).ToList(); ;
|
||||
|
||||
var otherModeShelfs = shelfs.Where(t => t.CurrentMode != HardWare.Mode.待机模式).ToList();
|
||||
if (otherModeShelfs != null && otherModeShelfs.Count > 0)
|
||||
{
|
||||
otherModeShelfs.ForEach(t =>
|
||||
{
|
||||
t.Reset();
|
||||
});
|
||||
Thread.Sleep(1000);
|
||||
}
|
||||
//对应的货架对应位置 进入出库模式 亮灯
|
||||
shelfs.ForEach(shelf =>
|
||||
{
|
||||
var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode)
|
||||
|
||||
.Distinct()
|
||||
.ToList();
|
||||
shelf.GoInOutstore(matDetails, outOrder);
|
||||
shelf.OrderNumber = outOrder.OrderNumber;
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"发料单{OrderNumber},当前物料已发完!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logs.Write($"发料单{OrderNumber},OutOrder为null,肯定是有问题");
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -1071,10 +1288,10 @@ namespace WCS.BLL.HardWare
|
||||
public void OutstoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
|
||||
{
|
||||
lightNumber = (int)data[TcpCleint.PreFixLength + 4];
|
||||
var store = DbHelp.db.Queryable<StoreInfo>()
|
||||
var storeInfo = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
|
||||
.First();
|
||||
if (store == null)
|
||||
if (storeInfo == null)
|
||||
{
|
||||
//TO DO 库位未找到
|
||||
return;
|
||||
@ -1084,32 +1301,82 @@ namespace WCS.BLL.HardWare
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
var exceptionMessage = store.StoreCode + "恢复正常!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
//对应的异常
|
||||
var warnings = WarningManager.Warnings.Where(t => t.IsWarning = true)
|
||||
.Where(t => t.ShelfId == ShelfId && t.StoreId == storeInfo.Id)
|
||||
.ToList();
|
||||
|
||||
var exceptionMessage = storeInfo.StoreCode + "恢复正常!";
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
IsWarning = false,
|
||||
WarningType = WarningTypeEnum.恢复正常,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1",
|
||||
SolvedGuids = warnings.Select(t => t.Guid).ToList(),
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
//自动消除本地缓存的报警
|
||||
warnings.ForEach(warning =>
|
||||
{
|
||||
WarningManager.ClearWarning(warning, SolveTypeEnum.忽略);
|
||||
});
|
||||
ProcessingExceptions.RemoveAll(t => t.BoardId == boardId);
|
||||
}
|
||||
break;
|
||||
case 0x01:
|
||||
{
|
||||
var exceptionMessage = store.StoreCode + "出库过程中存在物料上架!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var exceptionMessage = storeInfo.StoreCode + "出库过程中存在物料上架!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.出库中未扫描上架,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
//ModuleId = module.ModuleId,
|
||||
//ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "出库过程中存在物料上架!"
|
||||
ExceptionMessage = storeInfo.StoreCode + "出库过程中存在物料上架!"
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 0x02:
|
||||
{
|
||||
var exceptionMessage = store.StoreCode + "物料被取出!";
|
||||
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var exceptionMessage = storeInfo.StoreCode + "物料被取出!";
|
||||
//WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
|
||||
var warningModel = new WebSocketMessageModel()
|
||||
{
|
||||
WarningType = WarningTypeEnum.出库中丢失,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
//ModuleId = module.ModuleId,
|
||||
//ModuleCode = module.ModuleCode,
|
||||
ShelfCode = ShelfCode,
|
||||
ShelfId = ShelfId,
|
||||
WarningMessage = exceptionMessage,
|
||||
ClientIp = "127.0.0.1"
|
||||
};
|
||||
WarningManager.SendWarning(warningModel);
|
||||
|
||||
ProcessingExceptions.Add(new ProcessingExceptionType()
|
||||
{
|
||||
BoardId = boardId,
|
||||
LightNumber = lightNumber,
|
||||
ExceptionMessage = store.StoreCode + "出库过程中物料被异常取出!"
|
||||
ExceptionMessage = storeInfo.StoreCode + "出库过程中物料被异常取出!"
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
@ -57,6 +57,8 @@ namespace WCS.BLL.HardWare
|
||||
public bool IsEnable { get; set; }
|
||||
public Mode CurrentMode { get; set; }
|
||||
|
||||
public List<string> CurrentOutSns { get; set; }
|
||||
|
||||
public void SetCurrentMode()
|
||||
{
|
||||
|
||||
@ -160,6 +162,7 @@ namespace WCS.BLL.HardWare
|
||||
/// <param name="tcpClient"></param>
|
||||
public void GoInOutStoreMode(TCPClient tcpClient, List<string> outSns)
|
||||
{
|
||||
CurrentOutSns = outSns;
|
||||
var storeInfos = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.BoardId == BoardId)
|
||||
.OrderBy(t => t.LightNumber)
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@ -24,11 +25,7 @@ namespace WCS.BLL.Manager
|
||||
foreach (var ip in ips)
|
||||
{
|
||||
var tcpCleint = new TCPClient(ip, "192.168.9.183:20003");
|
||||
|
||||
|
||||
//var tcpCleint = new TCPClient("192.168.0.183:20002", "192.168.0.183:20003");
|
||||
//配置断线重连
|
||||
|
||||
tcpCleint.tcpClient.Received += (client, e) =>
|
||||
{
|
||||
|
||||
@ -108,6 +105,30 @@ namespace WCS.BLL.Manager
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitStatus()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
Thread.Sleep(1000);
|
||||
//给所有板子发复位
|
||||
TCPClients.ForEach(tcpClient =>
|
||||
{
|
||||
//板子复位
|
||||
new SmartShelfModule() { BoardId = 2047 }.Reset(tcpClient);
|
||||
//报警灯复位
|
||||
new WarningLight().CloseLight(tcpClient);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logs.Write($"启动时复位异常,{ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
public static TCPClient GetTCPClientByIPHost(string IpHost)
|
||||
{
|
||||
return TCPClients.Where(t => t.RemoteIPHost == IpHost).FirstOrDefault();
|
||||
|
239
WCS.BLL/Manager/WarningManager.cs
Normal file
239
WCS.BLL/Manager/WarningManager.cs
Normal file
@ -0,0 +1,239 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.OscarClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.HardWare;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
/// <summary>
|
||||
/// 报警信息
|
||||
/// </summary>
|
||||
public static class WarningManager
|
||||
{
|
||||
public static object flag = new object();
|
||||
public static void StartWarningMessageThread()
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
var noReceivedWarningMessage = Warnings.Where(t => t.ClientIsReceived == false && t.LastSendTime < DateTime.Now.AddSeconds(-5))
|
||||
.ToList();
|
||||
foreach (var warning in noReceivedWarningMessage)
|
||||
{
|
||||
WebSoceketManager.TrySendMessage(warning.ClientIp, JsonConvert.SerializeObject(warning));
|
||||
warning.LastSendTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
});
|
||||
}
|
||||
public static List<WebSocketMessageModel> Warnings { get; set; } = new List<WebSocketMessageModel>();
|
||||
public static void SendWarning(WebSocketMessageModel warning)
|
||||
{
|
||||
lock (flag)
|
||||
{
|
||||
Warnings.Add(warning);
|
||||
WebSoceketManager.TrySendMessage(warning.ClientIp, JsonConvert.SerializeObject(warning));
|
||||
warning.LastSendTime = DateTime.Now;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void ClearWarning(WebSocketMessageModel warning, SolveTypeEnum solveType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shelfIsWarning = true;
|
||||
var warningInManager = Warnings.Where(t => t.Guid == warning.Guid).FirstOrDefault();
|
||||
if (warningInManager != null)
|
||||
{
|
||||
if (solveType == SolveTypeEnum.处理)
|
||||
{
|
||||
//TODO 对应报警处理对应的数据
|
||||
switch (warningInManager.WarningType)
|
||||
{
|
||||
case WarningTypeEnum.入库自检丢失:
|
||||
SolveLoss(warningInManager);
|
||||
break;
|
||||
case WarningTypeEnum.入库自检未扫描上架:
|
||||
SolveNoScan(warningInManager);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//消除报警缓存信息
|
||||
lock (flag)
|
||||
{
|
||||
Warnings.Remove(warningInManager);
|
||||
}
|
||||
}
|
||||
|
||||
//货架是否还存在报警信息
|
||||
shelfIsWarning = Warnings.Where(t => t.ShelfId == warning.ShelfId)
|
||||
.Any();
|
||||
|
||||
//对应货架如果不存在报警信息了 指示灯回到对应的状态
|
||||
if (!shelfIsWarning)
|
||||
{
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfId == warning.ShelfId)
|
||||
.FirstOrDefault();
|
||||
if (shelf != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
smartShelf?.ClearWarning();
|
||||
smartShelf.IsWarning = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 重新发指令进入对应模式
|
||||
GoInRightMode(warning);
|
||||
#endregion
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logs.Write($"消除报警信息失败:发生异常" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RemoveMessage(WebSocketMessageModel warning)
|
||||
{
|
||||
var warningInManager = Warnings.Where(t => t.Guid == warning.Guid).FirstOrDefault();
|
||||
lock (flag)
|
||||
{
|
||||
Warnings.Remove(warningInManager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 报警消除的处理
|
||||
public static void SolveNoScan(WebSocketMessageModel warning)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void SolveLoss(WebSocketMessageModel warning)
|
||||
{
|
||||
#region 【后台】丢失的数据处理
|
||||
|
||||
try
|
||||
{
|
||||
//获取库位
|
||||
var storeInfo = DbHelp.db.Queryable<StoreInfo>()
|
||||
.Where(t => t.Id == warning.StoreId)
|
||||
.First();
|
||||
if (storeInfo != null)
|
||||
{
|
||||
DbHelp.db.BeginTran();
|
||||
//库位表字段清空
|
||||
storeInfo.CurrentMatSn = string.Empty;
|
||||
DbHelp.db.Updateable(storeInfo).ExecuteCommand();
|
||||
|
||||
//库存表记录删除、插入出入记录
|
||||
var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.StoreId == storeInfo.Id).First();
|
||||
if (inventoryDetail != null)
|
||||
{
|
||||
var inOutRecord = new InOutRecord()
|
||||
{
|
||||
StoreCode = storeInfo.StoreCode,
|
||||
StoreId = storeInfo.Id,
|
||||
StoreInfo = storeInfo,
|
||||
|
||||
MatSN = inventoryDetail.MatSN,
|
||||
MatCode = inventoryDetail.MatCode,
|
||||
MatName = inventoryDetail.MatName,
|
||||
MatBatch = inventoryDetail.MatBatch,
|
||||
MatQty = inventoryDetail.MatQty,
|
||||
MatSpec = inventoryDetail.MatSpec,
|
||||
MatCustomer = inventoryDetail.MatCustomer,
|
||||
MatSupplier = inventoryDetail.MatSupplier,
|
||||
|
||||
Direction = DirectionEnum.丢失,
|
||||
};
|
||||
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
|
||||
DbHelp.db.Deleteable(inventoryDetail).ExecuteCommand();
|
||||
}
|
||||
DbHelp.db.CommitTran();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DbHelp.db.RollbackTran();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public static void GoInRightMode(WebSocketMessageModel warning)
|
||||
{
|
||||
try
|
||||
{
|
||||
//模组还存在其他异常 暂时不进入对应模式
|
||||
var moduleOtherError = WarningManager.Warnings.Where(t => t.ShelfId == warning.ShelfId && t.ModuleId == warning.ModuleId).Any();
|
||||
if (moduleOtherError)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var shelf = ShelfManager.Shelves.Where(t => t.ShelfId == warning.ShelfId)
|
||||
.FirstOrDefault();
|
||||
if (shelf != null)
|
||||
{
|
||||
var smartShelf = shelf as SmartShelf;
|
||||
if (smartShelf != null)
|
||||
{
|
||||
var module = smartShelf.Modules.Where(t => t.ModuleId == warning.ModuleId).FirstOrDefault();
|
||||
if (module != null)
|
||||
{
|
||||
switch (smartShelf.CurrentMode)
|
||||
{
|
||||
case Mode.入库模式:
|
||||
module.GoInInstoreMode(smartShelf.TcpCleint);
|
||||
smartShelf.WarningLight.BlueLight(smartShelf.TcpCleint);
|
||||
break;
|
||||
case Mode.出库模式:
|
||||
module.GoInOutStoreMode(smartShelf.TcpCleint, module.CurrentOutSns);
|
||||
smartShelf.WarningLight.GreenLight(smartShelf.TcpCleint);
|
||||
break;
|
||||
case Mode.待机模式:
|
||||
module.Reset(smartShelf.TcpCleint);
|
||||
smartShelf.WarningLight.CloseLight(smartShelf.TcpCleint);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logs.Write("重置模组状态异常" + e.Message);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -12,6 +12,8 @@ namespace WCS.BLL.Manager
|
||||
public static class WebSoceketManager
|
||||
{
|
||||
public static HttpService service;
|
||||
|
||||
public static object flag = new object();
|
||||
public static void InitWebSocket()
|
||||
{
|
||||
service = new HttpService();
|
||||
@ -40,7 +42,10 @@ namespace WCS.BLL.Manager
|
||||
var clients = service.GetClients().Where(t => t.IP == IpAddress).ToList();
|
||||
foreach (var client in clients)
|
||||
{
|
||||
client.WebSocket.SendAsync(Message);
|
||||
lock (client)
|
||||
{
|
||||
client.WebSocket.Send(Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,10 +1,13 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Http.WebSockets;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace WCS.BLL.Manager
|
||||
{
|
||||
@ -30,12 +33,30 @@ namespace WCS.BLL.Manager
|
||||
|
||||
if (!client.Client.IsClient)
|
||||
{
|
||||
var clients = WebSoceketManager.service.GetClients().ToList();
|
||||
clients.ForEach(t =>
|
||||
try
|
||||
{
|
||||
t.WebSocket.Send("我已收到");
|
||||
});
|
||||
client.Send("我已收到");
|
||||
var message = e.DataFrame.ToText();
|
||||
var warning = JsonConvert.DeserializeObject<WebSocketMessageModel>(message);
|
||||
if (warning.IsWarning == false)
|
||||
{
|
||||
WarningManager.RemoveMessage(warning);
|
||||
return;
|
||||
}
|
||||
if (warning != null)
|
||||
{
|
||||
//收到这个表示客户端已成功收到消息并提示给前端 避免一直发
|
||||
var warningInManager = WarningManager.Warnings.Where(t => t.Guid == warning.Guid).FirstOrDefault();
|
||||
if (warningInManager != null)
|
||||
{
|
||||
|
||||
warningInManager.ClientIsReceived = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
|
18
WCS.BLL/Services/IService/IWarningService.cs
Normal file
18
WCS.BLL/Services/IService/IWarningService.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WCS.Model;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace WCS.BLL.Services.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理、查询报警使用的服务
|
||||
/// </summary>
|
||||
public interface IWarningService
|
||||
{
|
||||
public Task<ResponseCommon<object>> SolveWarning(SolveWarningRequest request);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Runtime;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@ -10,9 +11,12 @@ 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.Model;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using static Dm.net.buffer.ByteArrayBuffer;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
@ -63,7 +67,7 @@ namespace WCS.BLL.Services.Service
|
||||
//已找到模组对应货架
|
||||
shelf.GoInInstore(request.IpAdress);
|
||||
|
||||
if (shelf.CurentMode == Mode.入库模式)
|
||||
if (shelf.CurrentMode == Mode.入库模式)
|
||||
//成功进入入库模式
|
||||
return new ShelfGoInInstoreResponse()
|
||||
{
|
||||
@ -129,12 +133,12 @@ namespace WCS.BLL.Services.Service
|
||||
};
|
||||
}
|
||||
//判断当前是否是入库模式
|
||||
if (shelf.CurentMode != Mode.入库模式)
|
||||
if (shelf.CurrentMode != Mode.入库模式)
|
||||
{
|
||||
return new ResponseCommon<MatInfo>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurentMode}",
|
||||
Message = $"操作失败:货架[{request.ShelfCode}]不在入库模式!\r\n当前为{shelf.CurrentMode}",
|
||||
};
|
||||
}
|
||||
//判断物料是否已入库
|
||||
@ -149,9 +153,92 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
#region 获取物料数据 //调用接口或者直接查询数据库
|
||||
//TODO做成配置 调用接口
|
||||
if (1 != 1)
|
||||
if (1 == 1)
|
||||
{
|
||||
#region 调用Mes接口获取物料信息
|
||||
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");
|
||||
var Result = new ResponseCommon<List<queryByBarResponse>>()
|
||||
{
|
||||
Code = 200,
|
||||
Data = new List<queryByBarResponse>() {new queryByBarResponse()
|
||||
{
|
||||
materialBar = request.MatSn,
|
||||
materialCode = "111222",
|
||||
materialName = "电阻",
|
||||
materialQty = 1000,
|
||||
}
|
||||
}
|
||||
};
|
||||
//查询到物料信息
|
||||
if (Result != null && Result.Code == 200 && Result.Data != null && Result.Data.Count > 0)
|
||||
{
|
||||
var data = Result.Data.First();
|
||||
shelf.InStoreData = new MatInfoResponse()
|
||||
{
|
||||
materialBar = data.materialBar,
|
||||
materialCode = data.materialCode,
|
||||
materialName = data.materialName,
|
||||
materialQty = data.materialQty,
|
||||
materialSpec = data.materialSpec,
|
||||
batchNo = data.batchNo,
|
||||
supplier = "",
|
||||
customer = data.materialBar,
|
||||
|
||||
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系统中未获取到物料信息
|
||||
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
|
||||
@ -207,12 +294,12 @@ namespace WCS.BLL.Services.Service
|
||||
}
|
||||
|
||||
//判断当前是否是入库模式
|
||||
if (shelf.CurentMode != Mode.入库模式)
|
||||
if (shelf.CurrentMode != Mode.入库模式)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"货架[{request.ShelfCode}]已退出入库模式!\r\n当前为{shelf.CurentMode}",
|
||||
Message = $"货架[{request.ShelfCode}]已退出入库模式!\r\n当前为{shelf.CurrentMode}",
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
@ -403,78 +404,112 @@ namespace WCS.BLL.Services.Service
|
||||
|
||||
public async Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request)
|
||||
{
|
||||
//获取出库单
|
||||
var order = await DbHelp.db.Queryable<OutOrder>()
|
||||
.WhereIF(request.OrderId != 0, t => t.Id == request.OrderId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber == request.OrderNumber)
|
||||
.FirstAsync();
|
||||
if (order == null)
|
||||
try
|
||||
{
|
||||
return new ResponseCommon()
|
||||
//获取出库单
|
||||
var order = await DbHelp.db.Queryable<OutOrder>()
|
||||
.WhereIF(request.OrderId != 0, t => t.Id == request.OrderId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber == request.OrderNumber)
|
||||
.FirstAsync();
|
||||
if (order == null)
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"不存在对应的出库单据{request.OrderNumber}!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
|
||||
//如果是按物料编码出库 需要计算物料明细、并进行物料锁定
|
||||
if (order.SyncType == SyncTypeEnum.ByMatCode)
|
||||
{
|
||||
var result = CaculateOutOrderMatDetails(order);
|
||||
if (result.Code != 200)
|
||||
{
|
||||
return result;
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"不存在对应的出库单据{request.OrderNumber}!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//获取需要出库的物料明细
|
||||
var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == order.Id)
|
||||
.Where(t => t.IsSended == false)
|
||||
.Includes(t => t.StoreInfo)
|
||||
.ToList();
|
||||
if (outOrderMatDetails == null || outOrderMatDetails.Count == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
//如果是按物料编码出库 需要计算物料明细、并进行物料锁定
|
||||
if (order.SyncType == SyncTypeEnum.ByMatCode)
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"出库单据{request.OrderNumber}物料已全部出库!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
//按货架分组 按物料找到对应的货架
|
||||
var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
|
||||
.Distinct()
|
||||
var result = CaculateOutOrderMatDetails(order);
|
||||
if (result.Code != 200)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//获取需要出库的物料明细
|
||||
var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
|
||||
.Where(t => t.OrderId == order.Id)
|
||||
.Where(t => t.IsSended == false)
|
||||
.Includes(t => t.StoreInfo)
|
||||
.ToList();
|
||||
if (outOrderMatDetails == null || outOrderMatDetails.Count == 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"出库单据{request.OrderNumber}物料已全部出库!",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
//按货架分组 按物料找到对应的货架
|
||||
var shelfIds = outOrderMatDetails.Select(t => t.StoreInfo.ShelfId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var shelfs = ShelfManager.Shelves.Where(t => shelfIds.Contains(t.ShelfId)).ToList(); ;
|
||||
|
||||
var outherModeShelfs = shelfs.Where(t => t.CurrentMode != HardWare.Mode.待机模式).Select(t => t.ShelfCode).ToList();
|
||||
if (outherModeShelfs != null && outherModeShelfs.Count > 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"进入出库模式失败:货架{string.Join("", outherModeShelfs)}不在待机模式",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
//看是否是分批次出库的情况 分批次亮灯
|
||||
if (LocalFile.Config.IsSameMatCodeOut)
|
||||
{
|
||||
var outOrderDetailCount = outOrderMatDetails.GroupBy(t => t.MatCode)
|
||||
.Select(o => new { count = o.Count(), bb = o })
|
||||
.Where(o => o.count >= 2)
|
||||
.OrderByDescending(o => o.count)
|
||||
.ToList();
|
||||
var shelfs = ShelfManager.Shelves.Where(t => shelfIds.Contains(t.ShelfId)).ToList(); ;
|
||||
//相同物料存在盘数超过2的情况,亮下一个盘数多的物料
|
||||
if (outOrderDetailCount.Count > 0)
|
||||
{
|
||||
var matCode = outOrderDetailCount.First().bb.Key;
|
||||
outOrderMatDetails = outOrderMatDetails.Where(t => t.MatCode == matCode)
|
||||
.ToList();
|
||||
Logs.Write($"发料单{order.OrderNumber},本次亮灯物料{matCode}!");
|
||||
}
|
||||
//相同物料不存在盘数超过n的情况,剩余物料全部亮灯
|
||||
else
|
||||
{
|
||||
//剩余物料全出
|
||||
Logs.Write($"发料单{order.OrderNumber},剩余物料灯全亮!");
|
||||
}
|
||||
}
|
||||
|
||||
var outherModeShelfs = shelfs.Where(t => t.CurentMode != HardWare.Mode.待机模式).Select(t => t.ShelfCode).ToList();
|
||||
if (outherModeShelfs != null && outherModeShelfs.Count > 0)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 201,
|
||||
Message = $"进入出库模式失败:货架{string.Join("", outherModeShelfs)}不在待机模式",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
//对应的货架对应位置 进入出库模式 亮灯
|
||||
shelfs.ForEach(shelf =>
|
||||
//对应的货架对应位置 进入出库模式 亮灯
|
||||
shelfs.ForEach(shelf =>
|
||||
{
|
||||
var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode)
|
||||
|
||||
.Distinct()
|
||||
.ToList();
|
||||
shelf.GoInOutstore(matDetails, order);
|
||||
shelf.OrderNumber = order.OrderNumber;
|
||||
});
|
||||
|
||||
//返回
|
||||
return new ResponseCommon()
|
||||
//返回
|
||||
return new ResponseCommon()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Data = null
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Code = 200,
|
||||
Message = "Success",
|
||||
Data = null
|
||||
};
|
||||
await GoInOutstore(request);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private ResponseBase CaculateOutOrderMatDetails(OutOrder order)
|
||||
@ -657,7 +692,8 @@ namespace WCS.BLL.Services.Service
|
||||
});
|
||||
|
||||
//解锁物料 删除物料明细
|
||||
CancelOutOrderMatDetails(order);
|
||||
if (order.SyncType == SyncTypeEnum.ByMatCode)
|
||||
CancelOutOrderMatDetails(order);
|
||||
|
||||
return new ResponseCommon()
|
||||
{
|
||||
|
@ -312,21 +312,22 @@ namespace WCS.BLL.Services.Service
|
||||
{
|
||||
|
||||
var recordsQueryable = DbHelp.db.Queryable<StockTakingOrder>()
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StocktakingOrderNumber), t => t.StocktakingOrderNumber.Contains(request.StocktakingOrderNumber));
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StocktakingOrderNumber), t => t.StocktakingOrderNumber.Contains(request.StocktakingOrderNumber))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StocktakingOrderSource), t => t.StocktakingOrderSource!=null && t.StocktakingOrderSource.Contains(request.StocktakingOrderSource));
|
||||
|
||||
switch (request.StocktakingOrderStatus)
|
||||
{
|
||||
case Model.ApiModel.Stocktaking.StocktakingOrderStatus.未盘点:
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == DbModels.StocktakingOrderStatus.未盘点);
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == StocktakingOrderStatus.未盘点);
|
||||
break;
|
||||
case Model.ApiModel.Stocktaking.StocktakingOrderStatus.部分盘点:
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == DbModels.StocktakingOrderStatus.部分盘点);
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == StocktakingOrderStatus.部分盘点);
|
||||
break;
|
||||
case Model.ApiModel.Stocktaking.StocktakingOrderStatus.已提交:
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == DbModels.StocktakingOrderStatus.已提交);
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == StocktakingOrderStatus.已提交);
|
||||
break;
|
||||
case Model.ApiModel.Stocktaking.StocktakingOrderStatus.盘点完成:
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == DbModels.StocktakingOrderStatus.盘点完成);
|
||||
recordsQueryable = recordsQueryable.Where(t => t.StocktakingOrderStatus == StocktakingOrderStatus.盘点完成);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -530,7 +531,7 @@ namespace WCS.BLL.Services.Service
|
||||
#endregion
|
||||
|
||||
#region 查询当前盘点盘已启动的货架
|
||||
var shelfs = ShelfManager.Shelves.Where(t => t.CurentMode == HardWare.Mode.盘点模式 && t.OrderNumber == order.StocktakingOrderNumber).ToList();
|
||||
var shelfs = ShelfManager.Shelves.Where(t => t.CurrentMode == HardWare.Mode.盘点模式 && t.OrderNumber == order.StocktakingOrderNumber).ToList();
|
||||
shelfs.ForEach(t =>
|
||||
{
|
||||
t.GoOutStocktaking();
|
||||
@ -674,7 +675,7 @@ namespace WCS.BLL.Services.Service
|
||||
#endregion
|
||||
|
||||
#region 判断单据状态
|
||||
if (order.StocktakingOrderStatus != DbModels.StocktakingOrderStatus.已提交)
|
||||
if (order.StocktakingOrderStatus != StocktakingOrderStatus.已提交)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
@ -682,7 +683,7 @@ namespace WCS.BLL.Services.Service
|
||||
Message = $"单据已提交,请勿重复提交!",
|
||||
};
|
||||
}
|
||||
else if (order.StocktakingOrderStatus != DbModels.StocktakingOrderStatus.盘点完成)
|
||||
else if (order.StocktakingOrderStatus != StocktakingOrderStatus.盘点完成)
|
||||
{
|
||||
return new ResponseCommon()
|
||||
{
|
||||
|
51
WCS.BLL/Services/Service/WarningService.cs
Normal file
51
WCS.BLL/Services/Service/WarningService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.Db.AuthDb;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class WarningService : IWarningService
|
||||
{
|
||||
public async Task<ResponseCommon<object>> SolveWarning(SolveWarningRequest request)
|
||||
{
|
||||
//获取对应的报警
|
||||
var warning = WarningManager.Warnings
|
||||
.Where(t => t.Guid == request.Guid)
|
||||
.FirstOrDefault();
|
||||
if (warning != null)
|
||||
{
|
||||
WarningManager.ClearWarning(warning, request.SolveType);
|
||||
}
|
||||
//判断一下是否还存在对应报警
|
||||
warning = WarningManager.Warnings
|
||||
.Where(t => t.Guid == request.Guid)
|
||||
.FirstOrDefault();
|
||||
if (warning == null)
|
||||
return new ResponseCommon<object>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = "报警解除成功!"
|
||||
};
|
||||
else
|
||||
{
|
||||
return new ResponseCommon<object>()
|
||||
{
|
||||
Code = 201,
|
||||
Message = "报警解除失败!请重试!"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -3,15 +3,18 @@ using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
using WCS.BLL.Tool.Api.Models;
|
||||
using WCS.BLL;
|
||||
using WCS.Model;
|
||||
|
||||
namespace WCS.BLL.Tool.Api
|
||||
namespace WCS.BLL.Tool
|
||||
{
|
||||
public static class ApiHelp
|
||||
{
|
||||
@ -19,57 +22,57 @@ namespace WCS.BLL.Tool.Api
|
||||
static ApiHelp()
|
||||
{
|
||||
httpClient = new HttpClient();
|
||||
httpClient.Timeout = TimeSpan.FromSeconds(5);
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "Chrome/95.0.4638.69 Safari/537.36");
|
||||
//ServicePointManager.Expect100Continue = false;
|
||||
httpClient.Timeout = TimeSpan.FromSeconds(10);
|
||||
httpClient.DefaultRequestHeaders.Add("UserModel-Agent", "Chrome/95.0.4638.69 Safari/537.36");
|
||||
ServicePointManager.Expect100Continue = false;
|
||||
}
|
||||
|
||||
public static ApiResult Get(string uri, object? query = null, object? body = null)
|
||||
public static async Task<ResponseBase> Get(string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send(HttpMethod.Get, uri, query, body);
|
||||
return await Send(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Get(IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
public static async Task<ResponseBase> Get(IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send(HttpMethod.Get, uri, query, body);
|
||||
return await Send(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Get<T>(string uri, object? query = null, object? body = null)
|
||||
public static async Task<T> Get<T>(string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Get, uri, query, body);
|
||||
return await Send<T>(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Get<T>(IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
public static async Task<T> Get<T>(IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Get, uri, query, body);
|
||||
return await Send<T>(HttpMethod.Get, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Post(string uri, object? body = null, object? query = null)
|
||||
public static async Task<ResponseBase> Post(string uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send(HttpMethod.Post, uri, query, body);
|
||||
return await Send(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Post(IEnumerable<object> uri, object? body = null, object? query = null)
|
||||
public static async Task<ResponseBase> Post(IEnumerable<object> uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send(HttpMethod.Post, uri, query, body);
|
||||
return await Send(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Post<T>(string uri, object? body = null, object? query = null)
|
||||
public static async Task<T> Post<T>(string uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Post, uri, query, body);
|
||||
return await Send<T>(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Post<T>(IEnumerable<object> uri, object? body = null, object? query = null)
|
||||
public static async Task<T> Post<T>(IEnumerable<object> uri, object? body = null, object? query = null)
|
||||
{
|
||||
return Send<T>(HttpMethod.Post, uri, query, body);
|
||||
return await Send<T>(HttpMethod.Post, uri, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Send(HttpMethod method, string uri, object? query = null, object? body = null)
|
||||
public static async Task<ResponseBase> Send(HttpMethod method, string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send(method, new string[] { uri }, query, body);
|
||||
return await Send(method, new string[] { uri }, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult Send(HttpMethod method, IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
public static async Task<ResponseBase> Send(HttpMethod method, IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, "".AppendPathSegments(uri).SetQueryParams(query));
|
||||
|
||||
@ -79,35 +82,44 @@ namespace WCS.BLL.Tool.Api
|
||||
httpRequestMessage.Content = content;
|
||||
}
|
||||
|
||||
var re = httpClient.SendAsync(httpRequestMessage).Result;
|
||||
var re = await httpClient.SendAsync(httpRequestMessage);
|
||||
if (!re.IsSuccessStatusCode)
|
||||
return new ApiResult() { Code = ((int)re.StatusCode).ToString() };
|
||||
return new ResponseBase() { Code = (int)re.StatusCode };
|
||||
|
||||
var con = re.Content.ReadAsStringAsync().Result;
|
||||
return JsonConvert.DeserializeObject<ApiResult>(con) ?? new ApiResult();
|
||||
var con = await re.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<ResponseBase>(con) ?? new ResponseBase();
|
||||
}
|
||||
|
||||
public static ApiResult<T> Send<T>(HttpMethod method, string uri, object? query = null, object? body = null)
|
||||
public static async Task<T> Send<T>(HttpMethod method, string uri, object? query = null, object? body = null)
|
||||
{
|
||||
return Send<T>(method, new string[] { uri }, query, body);
|
||||
return await Send<T>(method, new string[] { uri }, query, body);
|
||||
}
|
||||
|
||||
public static ApiResult<T> Send<T>(HttpMethod method, IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
public static async Task<T> Send<T>(HttpMethod method, IEnumerable<object> uri, object? query = null, object? body = null)
|
||||
{
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, "".AppendPathSegments(uri).SetQueryParams(query));
|
||||
|
||||
if (body != null)
|
||||
try
|
||||
{
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
httpRequestMessage.Content = content;
|
||||
var url = "".AppendPathSegments(uri).SetQueryParams(query);
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, url);
|
||||
|
||||
if (body != null)
|
||||
{
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
httpRequestMessage.Content = content;
|
||||
}
|
||||
|
||||
var re = await httpClient.SendAsync(httpRequestMessage);
|
||||
if (!re.IsSuccessStatusCode)
|
||||
return default(T);
|
||||
|
||||
var con = await re.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<T>(con) ?? default(T); ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
var re = httpClient.SendAsync(httpRequestMessage).Result;
|
||||
if (!re.IsSuccessStatusCode)
|
||||
return new ApiResult<T>() { Code = ((int)re.StatusCode).ToString() };
|
||||
|
||||
var con = re.Content.ReadAsStringAsync().Result;
|
||||
return JsonConvert.DeserializeObject<ApiResult<T>>(con) ?? new ApiResult<T>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -118,17 +130,18 @@ namespace WCS.BLL.Tool.Api
|
||||
/// <returns>地址</returns>
|
||||
public static string AppendPathSegments(this string url, IEnumerable<object> segments)
|
||||
{
|
||||
string urlStr = url;
|
||||
string urlStr = url.Trim();
|
||||
foreach (var segment in segments)
|
||||
{
|
||||
var val = segment?.ToString();
|
||||
var val = segment?.ToString()?.Trim() ?? "";
|
||||
if (string.IsNullOrWhiteSpace(val))
|
||||
continue;
|
||||
|
||||
if (urlStr.EndsWith("/"))
|
||||
urlStr = urlStr.Substring(0, urlStr.Length - 1);
|
||||
|
||||
urlStr += val!.StartsWith("/") ? val : $"/{val}";
|
||||
if (val.Length > 0)
|
||||
urlStr += string.IsNullOrEmpty(urlStr) || val.StartsWith("/") ? val : $"/{val}";
|
||||
}
|
||||
return urlStr;
|
||||
}
|
||||
@ -178,5 +191,126 @@ namespace WCS.BLL.Tool.Api
|
||||
|
||||
return urlStr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post方式下载Excel文件
|
||||
/// </summary>
|
||||
/// <param name="localFilePath">文件保存的路径</param>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="requestUrl"></param>
|
||||
/// <param name="body"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task PostDownloadFileAsync(string localFilePath, HttpMethod method, string requestUrl, object? body = null)
|
||||
{
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, requestUrl);
|
||||
if (body != null)
|
||||
{
|
||||
var content = new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json");
|
||||
httpRequestMessage.Content = content;
|
||||
}
|
||||
using (var response = await httpClient.SendAsync(httpRequestMessage))
|
||||
{
|
||||
response.EnsureSuccessStatusCode(); // 确保请求成功
|
||||
|
||||
// 获取内容头中的文件名(如果需要的话)
|
||||
//var contentDisposition = ContentDispositionHeaderValue.Parse(response.Content.Headers.ContentDisposition.ToString());
|
||||
//string filename = contentDisposition.FileName.Trim('"'); // 去除引号
|
||||
var filename = string.Empty;
|
||||
// 如果提供的本地文件路径没有文件名,则使用从响应头中获取的文件名
|
||||
if (Path.GetFileName(localFilePath) == string.Empty)
|
||||
{
|
||||
localFilePath = Path.Combine(Path.GetDirectoryName(localFilePath), filename);
|
||||
}
|
||||
// 写入文件
|
||||
using (var fileStream = new FileStream(localFilePath, FileMode.Create, FileAccess.Write, FileShare.None, bufferSize: 4096, useAsync: true))
|
||||
{
|
||||
await response.Content.CopyToAsync(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Post方式导入Excel文件
|
||||
/// </summary>
|
||||
/// <param name="localFilePath">文件保存的路径</param>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="requestUrl"></param>
|
||||
/// <param name="body"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<T> PostImportFileAsync<T>(string localFilePath, HttpMethod method, string requestUrl, string userName, string deviceType)
|
||||
{
|
||||
HttpRequestMessage httpRequestMessage = new HttpRequestMessage(method, requestUrl);
|
||||
|
||||
using (var content = new MultipartFormDataContent())
|
||||
{
|
||||
var fileContent = new StreamContent(new FileStream(localFilePath, FileMode.Open, FileAccess.Read));
|
||||
fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("multipart/form-data");
|
||||
content.Add(fileContent, "excelFile", Path.GetFileName(localFilePath));
|
||||
|
||||
var userNameContent = new StringContent(userName);
|
||||
userNameContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("multipart/form-data");
|
||||
content.Add(userNameContent, "userName");
|
||||
|
||||
var deviceTypeContent = new StringContent(deviceType);
|
||||
deviceTypeContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("multipart/form-data");
|
||||
content.Add(deviceTypeContent, "deviceType");
|
||||
|
||||
httpRequestMessage.Content = content;
|
||||
using (var response = await httpClient.SendAsync(httpRequestMessage))
|
||||
{
|
||||
response.EnsureSuccessStatusCode(); // 确保请求成功
|
||||
var filename = string.Empty;
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return default(T);
|
||||
|
||||
var con = await response.Content.ReadAsStringAsync();
|
||||
return JsonConvert.DeserializeObject<T>(con) ?? default(T); ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static T GetDataFromHttp<T>(string url, object dataObj, string httpMethod, bool isSaveLog = false)
|
||||
{
|
||||
Guid guid = Guid.NewGuid();
|
||||
var data = 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 = 10000;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
29
WCS.BLL/Tool/Api/ApiModel/queryByBarResponse.cs
Normal file
29
WCS.BLL/Tool/Api/ApiModel/queryByBarResponse.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Tool.Api.ApiModel
|
||||
{
|
||||
public class queryByBarResponse
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WCS.BLL.Tool.Api.Models
|
||||
{
|
||||
public class ApiResult
|
||||
{
|
||||
public string Code { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class ApiResult<T> : ApiResult
|
||||
{
|
||||
public T Data { get; set; }
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ namespace WCS.BLL
|
||||
/// 数据库错误
|
||||
/// </summary>
|
||||
DbErr,
|
||||
Api
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -7,15 +7,9 @@ namespace WCS.Model.ApiModel.Stocktaking
|
||||
public class GetStockTakingOrdersRequest : PageQueryRequestBase
|
||||
{
|
||||
public string StocktakingOrderNumber { get; set; }
|
||||
public string StocktakingOrderSource { get; set; }
|
||||
public string StocktakingOrderType { get; set; }
|
||||
|
||||
public StocktakingOrderStatus? StocktakingOrderStatus { get; set; }
|
||||
}
|
||||
|
||||
public enum StocktakingOrderStatus
|
||||
{
|
||||
未盘点 = 0,
|
||||
部分盘点 = 1,
|
||||
盘点完成 = 2,
|
||||
已提交 = 3
|
||||
}
|
||||
}
|
||||
|
50
WCS.Model/ApiModel/Stocktaking/StockTakingOrderModel.cs
Normal file
50
WCS.Model/ApiModel/Stocktaking/StockTakingOrderModel.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.Stocktaking
|
||||
{
|
||||
public class StockTakingOrderModel : INotifyPropertyChanged
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string StocktakingOrderNumber { get; set; }
|
||||
|
||||
public StocktakingOrderStatus StocktakingOrderStatus { get; set; } = StocktakingOrderStatus.未盘点;
|
||||
|
||||
public string? StocktakingOrderSource { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; } = DateTime.Now;
|
||||
|
||||
public string CreateUser { get; set; }
|
||||
|
||||
public int RowNumber { get; set; }
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return isSelected; }
|
||||
set
|
||||
{
|
||||
isSelected = value;
|
||||
OnPropertyChanged(nameof(IsSelected));
|
||||
}
|
||||
}
|
||||
public bool isSelected;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
public enum StocktakingOrderStatus
|
||||
{
|
||||
未盘点 = 0,
|
||||
部分盘点 = 1,
|
||||
盘点完成 = 2,
|
||||
已提交 = 3
|
||||
}
|
||||
|
||||
}
|
18
WCS.Model/WebSocketModel/SolveWarningRequesr.cs
Normal file
18
WCS.Model/WebSocketModel/SolveWarningRequesr.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.WebSocketModel
|
||||
{
|
||||
public class SolveWarningRequest
|
||||
{
|
||||
public Guid Guid { get; set; }
|
||||
public SolveTypeEnum SolveType { get; set; }
|
||||
}
|
||||
|
||||
public enum SolveTypeEnum
|
||||
{
|
||||
处理 = 0,
|
||||
忽略 = 1,
|
||||
}
|
||||
}
|
47
WCS.Model/WebSocketModel/WebSocketMessageModel.cs
Normal file
47
WCS.Model/WebSocketModel/WebSocketMessageModel.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.WebSocketModel
|
||||
{
|
||||
public class WebSocketMessageModel
|
||||
{
|
||||
public bool IsWarning { get; set; } = true;
|
||||
public Guid Guid { get; set; } = Guid.NewGuid();
|
||||
public WarningTypeEnum WarningType { get; set; }
|
||||
public int StoreId { get; set; }
|
||||
public string StoreCode { get; set; }
|
||||
public int ModuleId { get; set; }
|
||||
public string ModuleCode { get; set; }
|
||||
public int ShelfId { get; set; }
|
||||
public string ShelfCode { get; set; }
|
||||
public string WarningMessage { get; set; }
|
||||
/// <summary>
|
||||
/// 发送到前端的地址
|
||||
/// </summary>
|
||||
public string ClientIp { get; set; }
|
||||
public DateTime LastSendTime { get; set; }
|
||||
public bool ClientIsReceived { get; set; }
|
||||
|
||||
//恢复正常需要消除的报警guid
|
||||
public List<Guid> SolvedGuids { get; set; }
|
||||
}
|
||||
|
||||
public enum WarningTypeEnum
|
||||
{
|
||||
进入入库未响应 = 0,
|
||||
入库自检丢失 = 1,
|
||||
入库自检未扫描上架 = 2,
|
||||
入库中异常取出 = 3,
|
||||
入库中未扫描上架 = 4,
|
||||
退出入库未响应 = 5,
|
||||
进入出库未响应 = 6,
|
||||
出库自检丢失 = 7,
|
||||
出库自检未扫描上架 = 8,
|
||||
出库中丢失 = 9,
|
||||
出库中未扫描上架 = 10,
|
||||
退出出库未响应 = 11,
|
||||
恢复正常 = 50,
|
||||
通知刷新出库 = 51,
|
||||
}
|
||||
}
|
@ -77,7 +77,7 @@ namespace WCS.WebApi.Controllers
|
||||
{
|
||||
ShelfId = t.ShelfId,
|
||||
ShelfCode = t.ShelfCode,
|
||||
CurentMode = (int)t.CurentMode,
|
||||
CurentMode = (int)t.CurrentMode,
|
||||
ModulesStr = t.ModulesStr,
|
||||
GroupName = t.GroupName
|
||||
}).ToList(),
|
||||
|
@ -178,7 +178,7 @@ namespace WebApi.Controllers
|
||||
return new ResponseBase()
|
||||
{
|
||||
Code = 300,
|
||||
Message = "<22><>ѯʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
|
||||
Message = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽʧ<EFBFBD>ܣ<EFBFBD>" + ex.Message,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
31
WCS.WebApi/Controllers/WarningController.cs
Normal file
31
WCS.WebApi/Controllers/WarningController.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
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 WarningController : ControllerBase
|
||||
{
|
||||
public IWarningService _warningService { get; set; }
|
||||
|
||||
public WarningController(IWarningService warningService)
|
||||
{
|
||||
_warningService = warningService;
|
||||
}
|
||||
|
||||
[Route("solveWarning")]
|
||||
[HttpPost(Name = "solveWarning")]
|
||||
public async Task<ResponseBase> SolveWarning(SolveWarningRequest request)
|
||||
{
|
||||
return await _warningService.SolveWarning(request);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,34 +21,22 @@ namespace WebApi
|
||||
{
|
||||
|
||||
WebSoceketManager.InitWebSocket();
|
||||
//LocalStatic.wCSTcpCleint = new WCS.BLL.TCPClient("127.0.0.1:20002");
|
||||
//LocalStatic.wCSTcpCleint.Send(new byte[] { 0x08, 0x00, 0x00, 0x11, 0x12, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
|
||||
|
||||
DbInit.InitDb();
|
||||
|
||||
LocalFile.SaveConfig();
|
||||
|
||||
ShelfManager.InitShelves();
|
||||
|
||||
TCPClientManager.InitTcpClient();
|
||||
|
||||
ShelfManager.InitShelves();
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ƺͰ<C6BA><CDB0><EFBFBD>
|
||||
TCPClientManager.InitStatus();
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
//// <20><><EFBFBD><EFBFBD>Kestrel
|
||||
//builder.WebHost.ConfigureKestrel((context, options) =>
|
||||
//{
|
||||
// // <20><><EFBFBD>ü<EFBFBD><C3BC><EFBFBD><EFBFBD>˿<EFBFBD>
|
||||
// options.Listen(IPAddress.Any, 8888); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP<49><50>ַ<EFBFBD><D6B7>5001<30>˿<EFBFBD>
|
||||
WarningManager.StartWarningMessageThread();
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// options.Limits.MaxRequestBodySize = 10 * 1024 * 1024; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>СΪ10MB
|
||||
// options.Limits.MaxConcurrentConnections = 1000; // <20><><EFBFBD><EFBFBD><F3B2A2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// options.Limits.MinRequestBodyDataRate = new MinDataRate(bytesPerSecond: 100, gracePeriod: TimeSpan.FromSeconds(10)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>SSL/TLS<4C><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӵ<EFBFBD><D3B4><EFBFBD>
|
||||
// // <20><><EFBFBD><EFBFBD>: options.Listen(IPAddress.Any, 5000, listenOptions => { listenOptions.UseHttps("path_to_certificate.pfx", "certificate_password"); });
|
||||
//});
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
@ -65,6 +53,7 @@ namespace WebApi
|
||||
builder.Services.AddScoped<IStoreInfoService, StoreInfoService>();
|
||||
builder.Services.AddScoped<IStockTakingService, StockTakingService>();
|
||||
builder.Services.AddScoped<ISelfCheckService, SelfCheckService>();
|
||||
builder.Services.AddScoped<IWarningService, WarningService>();
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>롢<EFBFBD><EBA1A2><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD><C3B5><EFBFBD>ģʽ
|
||||
builder.Services.AddSingleton<IGenerateService, GenerateService>();
|
||||
|
||||
|
@ -37,6 +37,16 @@ namespace 货架标准上位机.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
private bool goToStockTakingView;
|
||||
public bool GoToStockTakingView
|
||||
{
|
||||
get { return goToStockTakingView; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref goToStockTakingView, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region 专用_MainWindow2
|
||||
//隐藏式选项卡的高度
|
||||
|
@ -290,7 +290,7 @@ namespace 货架标准上位机.ViewModel
|
||||
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
PageNumber = CurrentPage,
|
||||
PageNumber = 1,
|
||||
PageSize = 10000,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<MatInventoryDetailModel>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/getMatInventoryDetail", body, "POST");
|
||||
|
@ -266,6 +266,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
//判断是否勾选数据
|
||||
var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
@ -273,6 +274,7 @@ namespace 货架标准上位机.ViewModels
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口开始出库
|
||||
@ -288,6 +290,9 @@ namespace 货架标准上位机.ViewModels
|
||||
{
|
||||
//成功后直接跳转
|
||||
MainWindow1.viewModel.GoToOutVentoryView = true;
|
||||
//刷新出库单列表
|
||||
OutVentoryView.viewModel.RefreshOutOrderList(selectedOutOrder.OrderNumber);
|
||||
|
||||
Growl.Success("已跳转到物料出库页面!");
|
||||
}
|
||||
else if (Result != null)
|
||||
|
@ -31,27 +31,6 @@ namespace 货架标准上位机.ViewModel
|
||||
{
|
||||
public OutInventoryViewModel()
|
||||
{
|
||||
//线程 更新当前选择的订单的状态
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// while (true)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// Thread.Sleep(1000);
|
||||
// //if (LocalStatic.IsRefreshOrderDetail)
|
||||
// //{
|
||||
// // LocalStatic.IsRefreshOrderDetail = false;
|
||||
// // SelectedPickBillNumberChanged();
|
||||
// //}
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// //Logs.Write("更新订单状态异常!!");
|
||||
// }
|
||||
// }
|
||||
//});
|
||||
|
||||
RefreshOutOrderList();
|
||||
}
|
||||
|
||||
@ -242,7 +221,7 @@ namespace 货架标准上位机.ViewModel
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshOutOrderList()
|
||||
public void RefreshOutOrderList(string OrderNumber = "")
|
||||
{
|
||||
#region 调用接口获取发料单
|
||||
try
|
||||
@ -255,6 +234,10 @@ namespace 货架标准上位机.ViewModel
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
OutOrderList = new ObservableCollection<OutOrderModel>(Result.Data.Lists);
|
||||
if (!string.IsNullOrEmpty(OrderNumber))
|
||||
{
|
||||
SelectedOutOrder = OutOrderList.Where(t => t.OrderNumber == OrderNumber).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||
{
|
||||
|
384
货架标准上位机/ViewModels/StocktakingDocumentViewModel.cs
Normal file
384
货架标准上位机/ViewModels/StocktakingDocumentViewModel.cs
Normal file
@ -0,0 +1,384 @@
|
||||
using HandyControl.Controls;
|
||||
using Ping9719.WpfEx.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.MatBaseInfo;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
using WCS.Model.ApiModel.Stocktaking;
|
||||
using 货架标准上位机.Api;
|
||||
|
||||
namespace 货架标准上位机.ViewModels
|
||||
{
|
||||
public class StocktakingDocumentViewModel : BindableBase
|
||||
{
|
||||
public StocktakingDocumentViewModel()
|
||||
{
|
||||
BtnSearch();
|
||||
}
|
||||
|
||||
#region Properties界面绑定的实体
|
||||
private ObservableCollection<StockTakingOrderModel> dataGridItemSource;
|
||||
public ObservableCollection<StockTakingOrderModel> DataGridItemSource
|
||||
{
|
||||
get { return dataGridItemSource; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref dataGridItemSource, value);
|
||||
}
|
||||
}
|
||||
|
||||
public StockTakingOrderModel selectedataGridItem;
|
||||
public StockTakingOrderModel SelectedataGridItem
|
||||
{
|
||||
get { return selectedataGridItem; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref selectedataGridItem, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string orderNumber;
|
||||
public string OrderNumber
|
||||
{
|
||||
get { return orderNumber; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref orderNumber, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string orderType;
|
||||
public string OrderType
|
||||
{
|
||||
get { return orderType; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref orderType, value);
|
||||
}
|
||||
}
|
||||
|
||||
private string orderSource;
|
||||
public string OrderSource
|
||||
{
|
||||
get { return orderSource; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref orderSource, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Command
|
||||
public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearchReset); }
|
||||
public void BtnSearchReset()
|
||||
{
|
||||
BtnSearch(true);
|
||||
}
|
||||
public void BtnSearch(bool IsPageReset = true)
|
||||
{
|
||||
if (CurrentPage == 0 || IsPageReset)
|
||||
{
|
||||
CurrentPage = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
#region 调用接口获取数据
|
||||
try
|
||||
{
|
||||
var body = new GetStockTakingOrdersRequest()
|
||||
{
|
||||
StocktakingOrderNumber = OrderNumber,
|
||||
StocktakingOrderType = OrderType,
|
||||
StocktakingOrderSource = OrderSource,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
PageNumber = CurrentPage,
|
||||
PageSize = 10,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<StockTakingOrderModel>>(LocalFile.Config.ApiIpHost + "stockTaking/getStockTakingOrders", body, "POST");
|
||||
if (Result != null && Result.Data != null && Result.Data.Lists != null)
|
||||
{
|
||||
DataGridItemSource = new ObservableCollection<StockTakingOrderModel>(Result.Data.Lists);
|
||||
MaxPage = Result.Data.MaxPage;
|
||||
TotalCount = Result.Data.TotalCount;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("加载数据失败:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); }
|
||||
public void BtnReset()
|
||||
{
|
||||
OrderNumber = string.Empty;
|
||||
OrderType = string.Empty;
|
||||
OrderSource = string.Empty;
|
||||
}
|
||||
|
||||
//public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); }
|
||||
//public void BtnDelete()
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); }
|
||||
public void BtnOrderDetail()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
}
|
||||
|
||||
//判断是否勾选数据
|
||||
var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
.FirstOrDefault();
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
}
|
||||
|
||||
#region 调用接口获取数据
|
||||
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
{
|
||||
OrderId = selectedOutOrder.Id,
|
||||
OrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<OutOrderDetailModel>>>(LocalFile.Config.ApiIpHost + "outStore/getOutOrderDetail", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
if (Result.Data.Count > 0)
|
||||
{
|
||||
//打开窗体
|
||||
var window = new OutInventoryDocumentDetailView(Result.Data);
|
||||
window.Owner = Application.Current.MainWindow;
|
||||
window.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("该单据没有单据明细!");
|
||||
}
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ICommand BtnOrderMatDetailCommand { get => new DelegateCommand(BtnOrderMatDetail); }
|
||||
public void BtnOrderMatDetail()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DataGridItemSource == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
}
|
||||
|
||||
//判断是否勾选数据
|
||||
var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
.FirstOrDefault();
|
||||
if (selectedOutOrder == null)
|
||||
{
|
||||
Growl.Warning("未勾选数据!");
|
||||
}
|
||||
#region 调用接口获取数据
|
||||
var body = new GetOutOrderDetailRequest()
|
||||
{
|
||||
OrderId = selectedOutOrder.Id,
|
||||
OrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<OutOrderMatDetailModel>>>(LocalFile.Config.ApiIpHost + "outStore/getOutOrderMatDetail", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
if (Result.Data.Count > 0)
|
||||
{
|
||||
//打开窗体
|
||||
var window = new OutInventoryDocumentMatDetailView(Result.Data);
|
||||
window.Owner = Application.Current.MainWindow;
|
||||
window.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("该单据没有发料明细!");
|
||||
}
|
||||
}
|
||||
else if (Result != null)
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
Growl.Warning("调用接口失败!");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Error("出现异常:" + ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//开始入库 如果成功就直接跳转出库界面
|
||||
public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); }
|
||||
public void BtnStart()
|
||||
{
|
||||
WarningManager.AddWarning(new WCS.Model.WebSocketModel.WebSocketMessageModel());
|
||||
//try
|
||||
//{
|
||||
// if (DataGridItemSource == null)
|
||||
// {
|
||||
// Growl.Warning("未勾选数据!");
|
||||
// return;
|
||||
// }
|
||||
// //判断是否勾选数据
|
||||
// var selectedOutOrder = DataGridItemSource.Where(t => t.IsSelected)
|
||||
// .FirstOrDefault();
|
||||
// if (selectedOutOrder == null)
|
||||
// {
|
||||
// Growl.Warning("未勾选数据!");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// #region 调用接口开始盘点
|
||||
// var body = new GetOutOrderDetailRequest()
|
||||
// {
|
||||
// OrderId = selectedOutOrder.Id,
|
||||
// OrderNumber = selectedOutOrder.StocktakingOrderNumber,
|
||||
// UserName = LocalStatic.CurrentUser,
|
||||
// DeviceType = LocalFile.Config.DeviceType,
|
||||
// };
|
||||
// var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goInOutstore", body, "POST");
|
||||
// if (Result != null && Result.Code == 200)
|
||||
// {
|
||||
// //成功后直接跳转
|
||||
// MainWindow1.viewModel.GoToOutVentoryView = true;
|
||||
// Growl.Success("已跳转到物料出库页面!");
|
||||
// }
|
||||
// else if (Result != null)
|
||||
// {
|
||||
// Growl.Warning(Result.Message);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Growl.Warning("调用接口失败!");
|
||||
// }
|
||||
// #endregion
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// Growl.Error("出现异常:" + ex.Message);
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
//}
|
||||
}
|
||||
|
||||
public ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
|
||||
public void BtnPause()
|
||||
{
|
||||
WarningManager.RemoveWarning(Guid.NewGuid());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PageOperation 分页操作
|
||||
private int currentPage;
|
||||
public int CurrentPage
|
||||
{
|
||||
get { return currentPage; }
|
||||
set
|
||||
{
|
||||
SetProperty(ref currentPage, value);
|
||||
BtnSearch(false);
|
||||
}
|
||||
}
|
||||
|
||||
private int maxPage;
|
||||
public int MaxPage
|
||||
{
|
||||
get { return maxPage; }
|
||||
set { SetProperty(ref maxPage, value); }
|
||||
}
|
||||
|
||||
//总数量
|
||||
private int totalCount;
|
||||
public int TotalCount
|
||||
{
|
||||
get { return totalCount; }
|
||||
set { SetProperty(ref totalCount, value); }
|
||||
}
|
||||
|
||||
public ICommand BtnFirstPageCommand { get => new DelegateCommand(BtnFirstPage); }
|
||||
public void BtnFirstPage()
|
||||
{
|
||||
CurrentPage = 1;
|
||||
}
|
||||
|
||||
public ICommand BtnPrePageCommand { get => new DelegateCommand(BtnPrePage); }
|
||||
public void BtnPrePage()
|
||||
{
|
||||
if (CurrentPage > 1)
|
||||
{
|
||||
CurrentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand BtnNextPageCommand { get => new DelegateCommand(BtnNextPage); }
|
||||
public void BtnNextPage()
|
||||
{
|
||||
if (CurrentPage < MaxPage)
|
||||
{
|
||||
CurrentPage++;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand BtnLastPageCommand { get => new DelegateCommand(BtnLastPage); }
|
||||
public void BtnLastPage()
|
||||
{
|
||||
if (CurrentPage != MaxPage)
|
||||
{
|
||||
CurrentPage = MaxPage;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -50,10 +50,10 @@
|
||||
<Border Grid.Row="2" Margin="5,5,5,5" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"></ColumnDefinition>
|
||||
<!--<ColumnDefinition Width="2*"></ColumnDefinition>-->
|
||||
<ColumnDefinition Width="3*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<GroupBox Grid.Column="0" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}" Margin="0,5,5,5" >
|
||||
<!--<GroupBox Grid.Column="0" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}" Margin="0,5,5,5" >
|
||||
<GroupBox.Header>
|
||||
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">
|
||||
<TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center">入库报警信息</TextBlock>
|
||||
@ -61,7 +61,7 @@
|
||||
</Grid>
|
||||
</GroupBox.Header>
|
||||
<pi:TextBoxLog Token="InstoreWarning" Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
|
||||
</GroupBox>
|
||||
</GroupBox>-->
|
||||
<GroupBox Grid.Column="1" Background="White" Padding="0" Style="{StaticResource GroupBoxTab}" Margin="0,5,5,5" >
|
||||
<GroupBox.Header>
|
||||
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">
|
||||
|
@ -123,6 +123,18 @@
|
||||
</TabItem>
|
||||
|
||||
<TabItem Padding="10,10,40,10" Visibility="{Binding Auth,Source={x:Static local:UserInfoView.viewModel},ConverterParameter={x:Static local:AuthEnum.查询},Converter={StaticResource AuthVisConverter}}">
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="" FontSize="20" FontFamily="{StaticResource IconFont}"></TextBlock>
|
||||
<TextBlock Margin="10,0,0,0" FontSize="16">盘点单据</TextBlock>
|
||||
</StackPanel>
|
||||
</TabItem.Header>
|
||||
<hc:TransitioningContentControl TransitionMode="Fade">
|
||||
<View:StocktakingDocumentView/>
|
||||
</hc:TransitioningContentControl>
|
||||
</TabItem>
|
||||
|
||||
<TabItem IsSelected="{Binding GoToStockTakingView}" Padding="10,10,40,10" Visibility="{Binding Auth,Source={x:Static local:UserInfoView.viewModel},ConverterParameter={x:Static local:AuthEnum.查询},Converter={StaticResource AuthVisConverter}}">
|
||||
<TabItem.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="" FontSize="20" FontFamily="{StaticResource IconFont}"></TextBlock>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="7*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" Margin="5 5 5 0" Background="AliceBlue" CornerRadius="5" Padding="0">
|
||||
<Border Grid.Row="0" Margin="2" Background="AliceBlue" CornerRadius="5" Padding="0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
@ -73,7 +73,7 @@
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Margin="5" Background="AliceBlue" CornerRadius="5" Padding="0">
|
||||
<Border Grid.Row="1" Margin="2" Background="AliceBlue" CornerRadius="5" Padding="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.8*"></RowDefinition>
|
||||
|
@ -88,7 +88,7 @@
|
||||
<RowDefinition Height="1*"></RowDefinition>
|
||||
<RowDefinition Height="12*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="发料单列表" FontWeight="DemiBold" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"></TextBlock>
|
||||
<TextBlock Text="发料单列表" MouseDown="TextBlock_MouseDown" FontWeight="DemiBold" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"></TextBlock>
|
||||
<Border CornerRadius="3" Margin="1" Grid.Row="1" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5">
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible">
|
||||
<ListView FontSize="18" ItemsSource="{Binding OutOrderList}" SelectedItem="{Binding SelectedOutOrder,Mode=TwoWay}" PreviewMouseWheel="ListView_PreviewMouseWheel">
|
||||
|
@ -60,5 +60,10 @@ namespace 货架标准上位机
|
||||
parent.RaiseEvent(eventArg);
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
viewModel.RefreshOutOrderList(viewModel.SelectedOutOrderNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
175
货架标准上位机/Views/StocktakingDocumentView.xaml
Normal file
175
货架标准上位机/Views/StocktakingDocumentView.xaml
Normal file
@ -0,0 +1,175 @@
|
||||
<pi:UserControlBase
|
||||
xmlns:pi="https://github.com/ping9719/wpfex"
|
||||
x:Class="货架标准上位机.StocktakingDocumentView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="737" d:DesignWidth="1192">
|
||||
<Border Margin="0" Background="LightGray" CornerRadius="3" Padding="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="7*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Border Grid.Row="0" Margin="5 5 5 0" Background="AliceBlue" CornerRadius="5" Padding="0">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1.5*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1.5*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="0.2*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Column="0"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Text="盘点单据编号:" FontSize="18" ></TextBlock>
|
||||
<TextBox Grid.Column="1" Text="{Binding OrderNumber}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
FontSize="18" MinWidth="120" ></TextBox>
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Text="盘点单据类型:" FontSize="18" ></TextBlock>
|
||||
<TextBox Grid.Column="3" Text="{Binding OrderType}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
FontSize="18" MinWidth="120" ></TextBox>
|
||||
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Text="盘点单据来源:" FontSize="18" ></TextBlock>
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding OrderSource}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
FontSize="18" MinWidth="120" ></TextBox>
|
||||
|
||||
|
||||
<!--<TextBlock Grid.Row="2" Grid.Column="2"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Right"
|
||||
Text="单据状态:" FontSize="18" ></TextBlock>
|
||||
<TextBox Grid.Row="1" Grid.Column="3" Text="{Binding OrderNumber}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Left"
|
||||
FontSize="18" MinWidth="120" ></TextBox>-->
|
||||
|
||||
<Button Style="{StaticResource ButtonSuccess}"
|
||||
Command="{Binding BtnSearchCommand}"
|
||||
hc:BorderElement.CornerRadius="15"
|
||||
Grid.Column="6" MinHeight="40" FontSize="18" Content=" 搜索" FontFamily="{StaticResource IconFont}" Margin="0,0,0,-10" >
|
||||
</Button>
|
||||
<Button Style="{StaticResource ButtonWarning}"
|
||||
Command="{Binding BtnResetCommand}"
|
||||
hc:BorderElement.CornerRadius="15"
|
||||
Grid.Column="7" MinHeight="40" FontSize="18" Content=" 重置" FontFamily="{StaticResource IconFont}" Margin="0,0,0,-10" >
|
||||
</Button>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Grid.Row="1" Margin="5" Background="AliceBlue" CornerRadius="5" Padding="0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="0.8*"></RowDefinition>
|
||||
<RowDefinition Height="8*"></RowDefinition>
|
||||
<RowDefinition Height="0.8*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnOrderDetailCommand}"
|
||||
Content="单据明细" FontFamily="{StaticResource IconFont}" Background="#bccbb0" Foreground="White">
|
||||
</Button>
|
||||
|
||||
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnStartCommand}"
|
||||
Content="开始盘点" FontFamily="{StaticResource IconFont}" Background="CadetBlue" Foreground="White">
|
||||
</Button>
|
||||
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnPauseCommand}"
|
||||
Content="暂停盘点" FontFamily="{StaticResource IconFont}" Background="CadetBlue" Foreground="White">
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
|
||||
SelectedItem="{Binding SelectedataGridItem}"
|
||||
ItemsSource="{Binding DataGridItemSource}"
|
||||
Name="dg"
|
||||
RowHeight="39"
|
||||
AutoGenerateColumns="False" FontSize="13">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn CanUserResize="False">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox Width="30" Height="30" IsHitTestVisible="False" IsChecked="{Binding IsSelected , UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="序号" Binding="{Binding RowNumber}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="盘点单据编号" Binding="{Binding StocktakingOrderNumber}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="盘点单据来源" Binding="{Binding StocktakingOrderSource}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="盘点单据状态" Binding="{Binding StocktakingOrderStatus}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="创建时间" Binding="{Binding CreateTime}"></DataGridTextColumn>
|
||||
<DataGridTextColumn IsReadOnly="True" Header="创建人" Binding="{Binding CreateUser}"></DataGridTextColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Border CornerRadius="3" Background="Transparent" VerticalAlignment="Center" >
|
||||
<Grid HorizontalAlignment="Stretch" Margin="0" VerticalAlignment="Top" Width="Auto" MinHeight="26">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="5*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<TextBlock FontSize="14" Text="共"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="{Binding TotalCount ,FallbackValue=0}"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="条记录 "></TextBlock>
|
||||
<TextBlock FontSize="14" Text="第"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="{Binding CurrentPage,FallbackValue=0}"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="/"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="{Binding MaxPage,FallbackValue=0}"></TextBlock>
|
||||
<TextBlock FontSize="14" Text="页"></TextBlock>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Column="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions >
|
||||
<RowDefinition Height="30"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="0" Name="btnFirst" Content="首页" Foreground="Black" FontSize="14"
|
||||
Command="{Binding BtnFirstPageCommand}"/>
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="1" Name="btnPrev" Content="上一页" FontSize="14"
|
||||
Command="{Binding BtnPrePageCommand}"/>
|
||||
<TextBox BorderBrush="Transparent" Grid.Column="2" FontSize="14" MinWidth="50" HorizontalAlignment="Center" VerticalAlignment="Center" Cursor="IBeam" IsEnabled="False"
|
||||
Text ="{Binding CurrentPage}" TextAlignment="Center"/>
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="3" Name="btnNext" Content="下一页" FontSize="14"
|
||||
Command="{Binding BtnNextPageCommand}"/>
|
||||
<Button BorderBrush="Transparent" Background="Transparent" Grid.Column="4" Name="btnLast" Content="末页" FontSize="14"
|
||||
Command="{Binding BtnLastPageCommand}"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
</pi:UserControlBase>
|
66
货架标准上位机/Views/StocktakingDocumentView.xaml.cs
Normal file
66
货架标准上位机/Views/StocktakingDocumentView.xaml.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using Ping9719.WpfEx;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using 货架标准上位机.ViewModels;
|
||||
using DataGrid = System.Windows.Controls.DataGrid;
|
||||
|
||||
namespace 货架标准上位机
|
||||
{
|
||||
/// <summary>
|
||||
/// InInventoryView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class StocktakingDocumentView : UserControlBase
|
||||
{
|
||||
public StocktakingDocumentViewModel viewModel = new StocktakingDocumentViewModel();
|
||||
public StocktakingDocumentView()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.DataContext = viewModel;
|
||||
}
|
||||
|
||||
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (viewModel.SelectedataGridItem != null)
|
||||
{
|
||||
viewModel.SelectedataGridItem.IsSelected = !viewModel.SelectedataGridItem.IsSelected;
|
||||
this.dg.UnselectAllCells();//取消选中 避免手动点击check选项时反选失败 和重新点击该项时反选失败
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
|
||||
{
|
||||
if (e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Pager)
|
||||
{
|
||||
if (e.Item.Cells[1].Text.Length > 20)
|
||||
{
|
||||
e.Item.Cells[1].Text = e.Item.Cells[1].Text.Substring(0, 20) + "...";
|
||||
}
|
||||
if (e.Item.Cells[2].Text.Length > 20)
|
||||
{
|
||||
e.Item.Cells[2].Text = e.Item.Cells[2].Text.Substring(0, 20) + "...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
42
货架标准上位机/Views/Windows/WarningWindow.xaml
Normal file
42
货架标准上位机/Views/Windows/WarningWindow.xaml
Normal file
@ -0,0 +1,42 @@
|
||||
<hc:Window x:Class="货架标准上位机.WarningWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:货架标准上位机"
|
||||
mc:Ignorable="d"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
Height="300" Width="520" WindowStyle="None" BorderThickness="0" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="0.95">
|
||||
<hc:Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource ButtonDefault}">
|
||||
<Setter Property="Padding" Value="25,0"></Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</hc:Window.Resources>
|
||||
<Border BorderBrush="Gray" Background="WhiteSmoke" CornerRadius="5" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="auto"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid VerticalAlignment="Top">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="auto"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid PreviewMouseLeftButtonDown="previewMouseLeftButtonDown" Background="Transparent">
|
||||
|
||||
</Grid>
|
||||
<TextBlock Margin="5,0" Text="报警" FontSize="15" Foreground="Red" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left"/>
|
||||
<!--<Button Grid.Column="1" Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityHiddenConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" Click="closeClick"/>-->
|
||||
</Grid>
|
||||
<TextBlock Margin="5,0" Grid.Row="1" Text="{Binding Content, FallbackValue=我是内容}" Foreground="Red" FontSize="18" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
<hc:UniformSpacingPanel x:Name="spacingPanel" Grid.Row="2" Margin="5,0,5,10" Spacing="10" Width="auto" ChildWrapping="Wrap" HorizontalAlignment="Center">
|
||||
<Button Content="确认"/>
|
||||
<Button Content="忽略"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</hc:Window>
|
154
货架标准上位机/Views/Windows/WarningWindow.xaml.cs
Normal file
154
货架标准上位机/Views/Windows/WarningWindow.xaml.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using 货架标准上位机.ViewModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Media;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using WCS.Model.WebSocketModel;
|
||||
using HandyControl.Controls;
|
||||
using WCS.Model;
|
||||
using 货架标准上位机.Api;
|
||||
using TouchSocket.Core;
|
||||
using Window = HandyControl.Controls.Window;
|
||||
|
||||
namespace 货架标准上位机
|
||||
{
|
||||
/// <summary>
|
||||
/// 提示框
|
||||
/// </summary>
|
||||
public partial class WarningWindow : HandyControl.Controls.Window
|
||||
{
|
||||
public WebSocketMessageModel warning { get; set; }
|
||||
public WarningWindow(WebSocketMessageModel _warning)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.Topmost = true; // 设置窗口始终在最上方
|
||||
this.WindowStyle = WindowStyle.None; // 可选,移除窗口的标准边框
|
||||
warning = _warning;
|
||||
}
|
||||
|
||||
private void closeClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//this.Close();
|
||||
WarningManager.RemoveWarning(warning.Guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, string.Empty, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, string title, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, title, new string[] { "确认", "忽略" }, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="buttons">按钮内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, IEnumerable<string> buttons, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
return Show(content, string.Empty, buttons, _warning, isVisCloseBut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示提示框
|
||||
/// </summary>
|
||||
/// <param name="content">内容</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="buttons">按钮内容</param>
|
||||
/// <param name="isVisCloseBut">界面右上角是否显示关闭按钮</param>
|
||||
/// <returns>点击的按钮文本</returns>
|
||||
public static WarningWindow Show(string content, string title, IEnumerable<string> buttons, WebSocketMessageModel _warning, bool isVisCloseBut = true, Window owner = null)
|
||||
{
|
||||
WarningWindow WaningWindow;
|
||||
string clikename = string.Empty;
|
||||
WaningWindow = new WarningWindow(_warning);
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
WaningWindow = new WarningWindow(_warning);
|
||||
WaningWindow.DataContext = new { Title = title, Content = content, IsClose = isVisCloseBut };
|
||||
WaningWindow.spacingPanel.Children.Clear();
|
||||
|
||||
foreach (var item in buttons)
|
||||
{
|
||||
Button button = new Button()
|
||||
{
|
||||
Content = item,
|
||||
};
|
||||
button.Click += (s, e) =>
|
||||
{
|
||||
clikename = ((Button)s).Content.ToString();
|
||||
Logs.Write($"用户{LocalStatic.CurrentUser}在处理异常报警{_warning.Guid}时点击了" + clikename);
|
||||
#region 调用接口处理异常/消除报警
|
||||
try
|
||||
{
|
||||
var body = new SolveWarningRequest()
|
||||
{
|
||||
Guid = _warning.Guid,
|
||||
SolveType = clikename == "确认" ? SolveTypeEnum.处理 : SolveTypeEnum.忽略,
|
||||
};
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<object>>(LocalFile.Config.ApiIpHost + "warning/solveWarning", body, "POST");
|
||||
if (Result != null && Result.Code == 200)
|
||||
{
|
||||
//消除异常或已不存在该异常
|
||||
WaningWindow.Close();
|
||||
}
|
||||
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
|
||||
{
|
||||
Growl.Warning(Result.Message);
|
||||
}
|
||||
else if (Result == null)
|
||||
{
|
||||
Growl.Warning("调用后台接口失败!");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Growl.Warning(ex.Message);
|
||||
}
|
||||
#endregion
|
||||
};
|
||||
|
||||
WaningWindow.spacingPanel.Children.Add(button);
|
||||
}
|
||||
|
||||
WaningWindow.Owner = owner == null ? System.Windows.Application.Current.MainWindow : owner;
|
||||
WaningWindow.Show();
|
||||
}));
|
||||
return WaningWindow;
|
||||
}
|
||||
|
||||
private void previewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
}
|
58
货架标准上位机/WarningManager.cs
Normal file
58
货架标准上位机/WarningManager.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using HandyControl.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using WCS.Model.ApiModel.User;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model;
|
||||
using WCS.Model.WebSocketModel;
|
||||
using 货架标准上位机.ViewModel;
|
||||
|
||||
namespace 货架标准上位机
|
||||
{
|
||||
public static class WarningManager
|
||||
{
|
||||
public static List<WarningWindow> warnings = new List<WarningWindow>();
|
||||
|
||||
public static object flag = new object();
|
||||
|
||||
public static void AddWarning(WebSocketMessageModel warningModel)
|
||||
{
|
||||
lock (flag)
|
||||
{
|
||||
warnings.Add(WarningWindow.Show(warningModel.WarningMessage, "报警信息", warningModel));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void RemoveWarning(Guid guid)
|
||||
{
|
||||
lock(flag)
|
||||
{
|
||||
try
|
||||
{
|
||||
var warning = warnings.Where(t => t.warning.Guid == guid).First();
|
||||
Application.Current.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
warning?.Close();
|
||||
warnings.Remove(warning);
|
||||
}));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void InitWarning()
|
||||
{
|
||||
//TODO 调用接口获取当前IP前端已接收未进行处理的异常,避免因前端重启造成异常无法处理
|
||||
#region 调用接口
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +1,16 @@
|
||||
using HandyControl.Controls;
|
||||
using Newtonsoft.Json;
|
||||
using Ping9719.WpfEx;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Http.WebSockets;
|
||||
using TouchSocket.Sockets;
|
||||
using WCS.Model.WebSocketModel;
|
||||
|
||||
namespace 货架标准上位机
|
||||
{
|
||||
@ -61,7 +64,52 @@ namespace 货架标准上位机
|
||||
//返回的报警信息 出入库盘点等日志信息
|
||||
else
|
||||
{
|
||||
TextBoxLog.AddLog(e.DataFrame.ToText(), "InstoreLog", DateTime.Now);
|
||||
try
|
||||
{
|
||||
var message = e.DataFrame.ToText();
|
||||
var warning = JsonConvert.DeserializeObject<WebSocketMessageModel>(message);
|
||||
if (warning != null)
|
||||
{
|
||||
//通知类的
|
||||
if (warning.IsWarning == false)
|
||||
{
|
||||
switch (warning.WarningType)
|
||||
{
|
||||
case WarningTypeEnum.通知刷新出库:
|
||||
OutVentoryView.viewModel.RefreshDataGridItemSource();
|
||||
client.Send(e.DataFrame.ToText());
|
||||
break;
|
||||
case WarningTypeEnum.恢复正常:
|
||||
var SolvedGuids = warning.SolvedGuids;
|
||||
SolvedGuids.ForEach(guid =>
|
||||
{
|
||||
WarningManager.RemoveWarning(guid);
|
||||
});
|
||||
TextBoxLog.AddLog(warning.WarningMessage, "InstoreLog", DateTime.Now);
|
||||
client.Send(e.DataFrame.ToText());
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
WarningManager.AddWarning(warning);
|
||||
TextBoxLog.AddLog(warning.WarningMessage, "InstoreLog", DateTime.Now);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
client.Send(e.DataFrame.ToText());
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
|
||||
|
Reference in New Issue
Block a user