提交代码

This commit is contained in:
hehaibing-1996
2024-04-29 08:39:09 +08:00
parent a1199028b3
commit 97888c6978
46 changed files with 2303 additions and 255 deletions

View File

@ -1,4 +1,5 @@
using SqlSugar;
using WCS.Model.ApiModel.OutStore;
namespace WCS.BLL.DbModels
{
@ -24,7 +25,14 @@ namespace WCS.BLL.DbModels
/// 单据状态
/// </summary>
[SugarColumn(ColumnName = "order_status", IsNullable = false, ColumnDescription = "单据状态")]
public OutOrderStatus OrderStatus { get; set; } = OutOrderStatus.;
public OutOrderStatus OrderStatus { get; set; } = OutOrderStatus.;
/// <summary>
/// 单据执行状态: 待发料, 开始发料, 暂停发料, 发料完成
/// </summary>
[SugarColumn(ColumnName = "order_exe_status", IsNullable = true, ColumnDescription = "执行状态:\t待发料\t开始发料\t暂停发料\t发料完成")]
public OutOrderExeStatus OutOrderExeStatus { get; set; } = OutOrderExeStatus.;
/// <summary>
/// 单据来源
@ -41,8 +49,8 @@ namespace WCS.BLL.DbModels
/// <summary>
/// 单据同步类型
/// </summary>
[SugarColumn(ColumnName = "sync_type", Length = 50, IsNullable = true, ColumnDescription = "单据同步类型ByMatCode,ByMatSn")]
public string SyncType { get; set; } = string.Empty;
[SugarColumn(ColumnName = "sync_type",IsNullable = false, ColumnDescription = "单据同步类型ByMatCode,ByMatSn")]
public SyncTypeEnum SyncType { get; set; }
/// <summary>
/// 创建时间
@ -56,13 +64,17 @@ namespace WCS.BLL.DbModels
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
public string CreateUser { get; set; }
}
/// <summary>
/// 用于绑定DataGrid中是否选择
/// </summary>
[SugarColumn(IsIgnore = true)]
public bool IsSelected { get; set; }
public enum OutOrderStatus
{
= 0,
= 1,
= 2
/// <summary>
/// 用于绑定中显示序号
/// </summary>
[SugarColumn(IsIgnore = true)]
public int RowNumber { get; set; }
}
}

View File

@ -32,7 +32,11 @@ namespace WCS.BLL.DbModels
/// </summary>
[SugarColumn(ColumnName = "mat_code", Length = 100, IsNullable = true, ColumnDescription = "物料编号")]
public string MatCode { get; set; }
/// <summary>
/// 物料名称
/// </summary>
[SugarColumn(ColumnName = "mat_name", Length = 150, IsNullable = true, ColumnDescription = "物料名称")]
public string MatName { get; set; }
/// <summary>
/// 物料批次
/// </summary>
@ -45,6 +49,12 @@ namespace WCS.BLL.DbModels
[SugarColumn(ColumnName = "req_qty", IsNullable = false, ColumnDescription = "物料需求数量")]
public int ReqQty { get; set; }
/// <summary>
/// 物料已出库数量
/// </summary>
[SugarColumn(ColumnName = "out_qty", IsNullable = false, DefaultValue = "0", ColumnDescription = "物料已出库数量")]
public int OutQty { get; set; } = 0;
/// <summary>
/// 创建时间
/// </summary>
@ -56,5 +66,11 @@ namespace WCS.BLL.DbModels
/// </summary>
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
public string CreateUser { get; set; }
/// <summary>
/// 用于绑定中显示序号
/// </summary>
[SugarColumn(IsIgnore = true)]
public int RowNumber { get; set; }
}
}

View File

@ -39,7 +39,7 @@ namespace WCS.BLL.DbModels
public int OutOrderDetailId { get; set; }
/// <summary>
/// 库存的ID
/// 库存数据的ID
/// </summary>
[SugarColumn(ColumnName = "inventory_detail_id", IsNullable = true)]
public int InventoryDetailId { get; set; }
@ -126,5 +126,11 @@ namespace WCS.BLL.DbModels
/// </summary>
[SugarColumn(ColumnName = "create_user", Length = 100, IsNullable = true, ColumnDescription = "操作员")]
public string CreateUser { get; set; }
/// <summary>
/// 用于绑定中显示序号
/// </summary>
[SugarColumn(IsIgnore = true)]
public int RowNumber { get; set; }
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.BLL.DbModels;
using WCS.Model;
namespace WCS.BLL.HardWare
@ -75,7 +76,7 @@ namespace WCS.BLL.HardWare
/// <summary>
/// 货架进入出库模式
/// </summary>
public void GoInOutstore();
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder);
/// <summary>
/// 货架退出出库模式

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.BLL.DbModels;
using WCS.Model;
namespace WCS.BLL.HardWare
@ -29,7 +30,7 @@ namespace WCS.BLL.HardWare
throw new NotImplementedException();
}
public void GoInOutstore()
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder)
{
throw new NotImplementedException();
}

View File

@ -12,6 +12,7 @@ using WCS.DAL;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using static System.Formats.Asn1.AsnWriter;
namespace WCS.BLL.HardWare
{
@ -48,7 +49,7 @@ namespace WCS.BLL.HardWare
}
ModulesStr = string.Join(";", Modules.Select(t => t.ModuleCode));
ModuleIds = Modules.Select(t => t.ModuleId).ToList();
ModuleIds = Modules.Select(t => t.BoardId).ToList();
});
////初始化TCPCleint
@ -72,14 +73,14 @@ namespace WCS.BLL.HardWare
// }
// index += (TcpCleint.PreFixLength + TcpCleint.DataLength - 1);//每次循环index会+1 所以这里-1
// //获取板子ID
// var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1];
// var boardIds = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1];
// var lightNumber = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
// //协议处理 判断功能位
// switch (dataTemp[TcpCleint.PreFixLength + 2])
// {
// case 0x01://进入入库模式信号
// GoInInstoreProcess(dataTemp, boardId, lightNumber);
// GoInInstoreProcess(dataTemp, boardIds, lightNumber);
// break;
// case 0x03://正常入库信号
// InStoreReturnProcess(dataTemp);
@ -107,12 +108,22 @@ namespace WCS.BLL.HardWare
public int LightId { get; set; }
public WarningLight WarningLight { get; set; }
/// <summary>
/// 自检异常、未响应对应模式的异常
/// </summary>
public List<string> ExceptionMessages { get; set; } = new List<string>();
/// <summary>
/// 过程中异常 入库过程中异常/出库过程中异常
/// </summary>
public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>();
public string? InstoreIpAddress { get; set; } = string.Empty;
public MatInfoResponse InStoreData { get; set; }
public List<string> CurrentOutStoreMatSNs { get; set; } = new List<string>();
public OutOrder CurrentOutOrder { get; set; }
public string OrderNumber { get; set; }
@ -122,8 +133,15 @@ namespace WCS.BLL.HardWare
#region
public void GoInInstore(string? IPAddress)
{
try
{
if (this.CurentMode == Mode.)
{
InstoreIpAddress = IPAddress;
return;
}
//判断当前模式是否为待机模式
if (this.CurentMode != Mode.)
else if (this.CurentMode != Mode.)
{
return;
}
@ -133,6 +151,7 @@ namespace WCS.BLL.HardWare
}
//清空错误
ExceptionMessages.Clear();
ProcessingExceptions.Clear();
//货架所有模组发送指令进入入库模式
foreach (var module in Modules.Where(t => t.IsEnable).ToList())
{
@ -145,6 +164,16 @@ namespace WCS.BLL.HardWare
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
{
timeSpan = DateTime.Now - beginTime;
//所有板子成功进入入库模式 表示进入入库模式成功,跳出循环
var isExistsNotInstore = Modules.Where(t => t.CurrentMode != Mode.)
.Where(t => t.IsEnable)
.Any();
if (!isExistsNotInstore)
{
break;
}
//接收到第一个异常就不继续循环了
if (ExceptionMessages.Count() > 0)
{
@ -153,11 +182,26 @@ namespace WCS.BLL.HardWare
Thread.Sleep(deficientTime);
//出现异常的未进入入库模式,有红灯进行指引
this.CurentMode = Mode.;
return;
break;
}
//延时处理
//循环延时处理
Thread.Sleep(50);
}
//循环结束后判断当前板子状态
var notInstoreList = Modules.Where(t => t.CurrentMode != Mode.)
.Where(t => t.IsEnable).ToList();
if (notInstoreList.Count > 0)
{
CurentMode = Mode.;
foreach (var item in notInstoreList)
{
ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!");
}
}
//警示灯亮起
WarningLight.BlueLight(TcpCleint);
//绑定当前进入入库PDA/WCS前端的IP
@ -165,10 +209,16 @@ namespace WCS.BLL.HardWare
//返回成功
return;
}
catch (Exception ex)
{
GoOutInstore();
throw ex;
}
}
public void GoOutInstore()
{
//货架是否为入库模式
//当前货架是否为入库模式
if (CurentMode != Mode.)
{
return;
@ -178,20 +228,81 @@ namespace WCS.BLL.HardWare
this.CurentMode = Mode.;
}
//清空错误
ExceptionMessages.Clear();
//货架所有模组发送指令退出入库模式
foreach (var module in Modules.Where(t => t.IsEnable)
//.Where(t => t.CurrentMode == Mode.入库模式)
.ToList())
{
if (module.CurrentMode == Mode.)
module.GoOutInstoreMode(TcpCleint);
}
var timeOut = 3000;
var timeSpan = TimeSpan.FromMilliseconds(0);
var beginTime = DateTime.Now;
while (timeSpan <= TimeSpan.FromMilliseconds(timeOut))
{
timeSpan = DateTime.Now - beginTime;
//所有板子是否成功退出入库模式
var isExistsInstore = Modules.Where(t => t.CurrentMode != Mode.)
.Where(t => t.IsEnable)
.Any();
if (!isExistsInstore)
{
break;
}
//循环延时处理
Thread.Sleep(50);
}
//循环结束后判断当前板子状态
var list = Modules.Where(t => t.CurrentMode != Mode.)
.Where(t => t.IsEnable)
.ToList();
if (list.Count > 0)
{
CurentMode = Mode.;
foreach (var item in list)
{
ExceptionMessages.Add($"模组{item.ModuleCode}未成功退出入库模式!");
}
}
//报警灯熄灭
WarningLight.CloseLight(TcpCleint);
}
public void GoInOutstore()
public void GoInOutstore(List<OutOrderMatDetail> MatDetails, OutOrder outOrder)
{
throw new NotImplementedException();
//第一步:设置货架当前模式
if (CurentMode != Mode.)
{
Modules.ForEach(t => { t.Reset(TcpCleint); });
}
CurentMode = Mode.;
//第二步货架添加需要出的SN 出库的领料单号
//移除货架所有现有待出库的MatSN
CurrentOutStoreMatSNs.Clear();
////添加属于当前货架的物料
CurrentOutStoreMatSNs.AddRange(MatDetails.Select(t => t.MatSN).ToList());
////记录当前出库的发料单
CurrentOutOrder = outOrder;
////第三步:对应的模组进入出库模式
var boardIds = MatDetails.Select(t => t.StoreInfo.BoardId)
.Distinct()
.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)
.ToList();
t.GoInOutStoreMode(TcpCleint, outMatSns);
});
//所有板子亮灯后 亮警示灯
WarningLight.GreenLight(TcpCleint);
}
public void GoInStocktaking()
@ -201,6 +312,15 @@ namespace WCS.BLL.HardWare
public void GoOutOutstore()
{
//找到在出库中的模组
var outingModules = Modules.Where(t => t.CurrentMode == Mode.)
.ToList();
foreach (var module in outingModules)
{
module.GoOutOutStoreMode(TcpCleint);
}
CurrentOutOrder = null;
CurrentOutStoreMatSNs.Clear();
this.CurentMode = Mode.;
}
@ -236,6 +356,7 @@ namespace WCS.BLL.HardWare
#region
public void ProtocolProcess(byte[] data, int boardId, int lightNumber)
{
Logs.Write("协议处理中的数据" + BitConverter.ToString(data) + $"板子id{boardId}");
//协议处理 判断功能位
switch (data[TcpCleint.PreFixLength + 2])
{
@ -248,8 +369,21 @@ namespace WCS.BLL.HardWare
case 0x03://正常入库信号
InStoreReturnProcess(data);
break;
case 0x04://入库模式中异常信号
InStoreExceptionReturnProcess(data, boardId, lightNumber);
break;
case 0x05://进入出库模式返回信号
GoInOutstoreProcess(data, boardId, lightNumber);
break;
case 0x06://退出出库模式返回信号
GoOutOutstoreProcess(data, boardId, lightNumber);
break;
case 0x07://正常出库返回信号
OutstoreReturnProcess(data, boardId, lightNumber);
break;
case 0x13://复位的返回信号
ResetReturnProcess(data, boardId, lightNumber);
break;
default:
;
break;
@ -376,7 +510,7 @@ namespace WCS.BLL.HardWare
//库位未配置、返回数据异常
else
{
//Logs.Write($"[进入入库模式异常]板Id{boardId},库位号{index + 1}找不到对应库位!");
//Logs.Write($"[进入入库模式异常]板Id{boardIds},库位号{index + 1}找不到对应库位!");
}
}
else if (dataTemp[2 * index] == '0')
@ -451,6 +585,9 @@ namespace WCS.BLL.HardWare
}
else
{
var exceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
module.ComfirmErrInstore(TcpCleint);
WarningLight.WaringLightBlueEnd(TcpCleint);
//WaringLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId);
@ -463,7 +600,7 @@ namespace WCS.BLL.HardWare
{
module.ComfirmErrInstore(TcpCleint);
WarningLight.WaringLightBlueEnd(TcpCleint);
//ComfirmErrInstoreByIp(shelfStatus.ClientIp, boardId);
//ComfirmErrInstoreByIp(shelfStatus.ClientIp, boardIds);
//WaringLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId);
//TO DO Logs.Write($"[{guid}]该位置已放置物料!");
return;
@ -549,6 +686,64 @@ namespace WCS.BLL.HardWare
#endregion
}
/// <summary>
/// 入库模式中异常处理
/// </summary>
/// <param name="data"></param>
/// <param name="boardId"></param>
/// <param name="lightNumber"></param>
public void InStoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
{
lightNumber = (int)data[TcpCleint.PreFixLength + 4];
var store = DbHelp.db.Queryable<StoreInfo>()
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
.First();
if (store == null)
{
//TO DO 库位未找到
return;
}
//已放物料丢失了 物料多放了 储位恢复正常
switch (data[TcpCleint.PreFixLength + 3])
{
case 0x00:
{
var exceptionMessage = store.StoreCode + "恢复正常!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
ProcessingExceptions.RemoveAll(t => t.BoardId == boardId);
}
break;
case 0x01:
{
var exceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
ProcessingExceptions.Add(new ProcessingExceptionType()
{
BoardId = boardId,
LightNumber = lightNumber,
ExceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!"
});
}
break;
case 0x02:
{
var exceptionMessage = store.StoreCode + "物料被取出!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
ProcessingExceptions.Add(new ProcessingExceptionType()
{
BoardId = boardId,
LightNumber = lightNumber,
ExceptionMessage = store.StoreCode + "入库过程中物料丢失!"
});
}
break;
default:
break;
}
}
/// <summary>
/// 进入出库模式协议返回
@ -570,7 +765,7 @@ namespace WCS.BLL.HardWare
}
else
{
module.CurrentMode = Mode.;
module.CurrentMode = Mode.;
}
}
//库存物料与实际情况不匹配
@ -584,7 +779,7 @@ namespace WCS.BLL.HardWare
}
else
{
module.CurrentMode = Mode.;
module.CurrentMode = Mode.;
}
//获取当前板所有库位
var storeInfos = DbHelp.db.Queryable<StoreInfo>()
@ -673,7 +868,7 @@ namespace WCS.BLL.HardWare
//库位未配置、返回数据异常
else
{
//Logs.Write($"[进入入库模式异常]板Id{boardId},库位号{index + 1}找不到对应库位!");
//Logs.Write($"[进入入库模式异常]板Id{boardIds},库位号{index + 1}找不到对应库位!");
}
}
else if (dataTemp[2 * index] == '0')
@ -695,6 +890,194 @@ namespace WCS.BLL.HardWare
}
}
}
public void OutstoreReturnProcess(byte[] data, int boardId, int lightNumber)
{
if (CurentMode != Mode.)
{
//TO DO 未在出库模式 要报错
//Logs.Write($"[{guid}]出库错误:该货架模式不是出库模式或盘点模式{storeInfo.ShelfCode}");
return;
}
lightNumber = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
var storeInfo = DbHelp.db.Queryable<StoreInfo>().Where(t => t.BoardId == boardId
&& t.LightNumber == lightNumber)
.First();
if (storeInfo == null)
{
//TO DO 报错
return;
}
var module = this.Modules.Where(t => t.BoardId == boardId)
.FirstOrDefault();
if (module == null)
{
//TO DO 报错
return;
}
//当前库位未记录MatSn
if (string.IsNullOrEmpty(storeInfo.CurrentMatSn))
{
//该库位是需要出库的库位物料被多次取出or给了多个正常出库信号
Logs.Write($"该库位是需要出库的库位物料被反复取出or给了多个正常出库信号,库位{storeInfo.StoreCode}");
//暂不进行处理
return;
}
//不是本次出库需要出的物料
if (!CurrentOutStoreMatSNs.Contains(storeInfo.CurrentMatSn))
{
//Logs.Write($"{storeInfo.CurrentMatSN}不是本次需要出库的物料");
//报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint);
return;
}
//获取当前的库存信息
var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == storeInfo.CurrentMatSn).First();
if (inventoryDetail == null)
{
//Logs.Write($"{storeInfo.CurrentMatSN}库存信息不存在");
//报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint);
return;
}
//获取对应的出库单明细
var orderOrderDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
.Where(t => t.OrderId == CurrentOutOrder.Id)
.Where(t => t.MatSN == inventoryDetail.MatSN)
.ToList();
if (orderOrderDetails == null || orderOrderDetails.Count == 0)
{
//Logs.Write($"{storeInfo.CurrentMatSN},OrderDetail出库明细信息不存在");
//报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint);
return;
}
#region
//当前库位的SN
var matSN = storeInfo.CurrentMatSn;
try
{
DbHelp.db.BeginTran();
//库存明细表 删除
;
//出入库记录表 新增
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.,
};
//库位表 修改
storeInfo.CurrentMatSn = string.Empty;
//发料单明细表 更新为已出库
orderOrderDetails.ForEach(x =>
{
x.IsSended = true;
});
//TO DO 发料需求表增加数量
//保存数据
DbHelp.db.Deleteable(inventoryDetail).ExecuteCommand();
DbHelp.db.Insertable(inOutRecord).ExecuteCommand();
DbHelp.db.Updateable(storeInfo).ExecuteCommand();
DbHelp.db.Updateable(orderOrderDetails).ExecuteCommand();
DbHelp.db.CommitTran();
//报警灯同时亮绿灯并鸣叫一次提示。
WarningLight.SuccessLightGreenEnd(TcpCleint);
//确认本次出库
module.ComfirmOutstore(TcpCleint, data[TcpCleint.PreFixLength + 3]);
//shelfStatus.SetCurrentModeTime = DateTime.Now;
//LocalStatic.IsRefreshOrderDetail = true;
//当前柜子是否还存在未出库的
CurrentOutStoreMatSNs.RemoveAll(t => t == matSN);//删除本次已出的物料SN
var isExsistOut = CurrentOutStoreMatSNs.Any();
if (!isExsistOut)
{
//Logs.Write($"货架[{shelfStatus.ShelfCode}]:不存在待出物料,退出出库模式");
//退出出库模式
GoOutOutstore();
WarningLight.CloseLight(TcpCleint);
var currentPickBillNumber = CurrentOutOrder.OrderNumber;
CurrentOutOrder = null;
Task.Run(() =>
{
//LocalStatic.UpdatOutOrderStatus(currentPickBillNumber);
//给信号通知出库页面更新页面的状态
});
}
}
catch (Exception ex)
{
DbHelp.db.RollbackTran();
//报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint);
}
#endregion
}
/// <summary>
/// 退出出库模式返回信号处理
/// </summary>
/// <param name="data"></param>
public void GoOutOutstoreProcess(byte[] data, int boardId, int lightNumber)
{
var module = this.Modules.Where(t => t.BoardId == boardId && t.CurrentMode == Mode.).FirstOrDefault();
if (module == null)
{
return;
}
else
{
module.CurrentMode = Mode.;
}
}
public void ResetReturnProcess(byte[] data, int boardId, int lightNumber)
{
var module = this.Modules.Where(t => t.BoardId == boardId && t.CurrentMode == Mode.).FirstOrDefault();
if (module == null)
{
return;
}
else
{
module.CurrentMode = Mode.;
}
}
#endregion
}
/// <summary>
/// 过程中异常类型
/// </summary>
public class ProcessingExceptionType
{
public int BoardId { get; set; }
public int LightNumber { get; set; }
public string ExceptionMessage { get; set; }
}
}

View File

@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
@ -32,6 +34,22 @@ namespace WCS.BLL.HardWare
/// 自检模式
/// </summary>
public byte[] CheckModeData = { 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 进入出库模式
/// </summary>
public byte[] GoInOutstoreModeData = { 0x05, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00 };
public byte[] ComfirmOutstoreData = { 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 退出出库模式
/// </summary>
public byte[] GoOutOutstoreModeData = { 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/// <summary>
/// 复位命令
/// </summary>
public byte[] ResetData = { 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
#endregion
public int ModuleId { get; set; }
public string ModuleCode { get; set; }
@ -90,11 +108,24 @@ namespace WCS.BLL.HardWare
}
else
{
//退出对应的模式 回到待机状态 并记录对应的状态日志(这个分支肯定是异常了)
//记录错误日志
//这里应该是状态异常的 正常不会是这种状态
Reset(tcpClient);
}
}
/// <summary>
/// 复位
/// </summary>
/// <param name="tcpClient"></param>
public void Reset(TCPClient tcpClient)
{
tcpClient.Send(tcpClient.GenerateMessage(BoardId, ResetData));
}
/// <summary>
/// 自检
/// </summary>
/// <param name="tcpClient"></param>
public void ShelfCheck(TCPClient tcpClient)
{
if (CurrentMode != Mode.)
@ -122,5 +153,68 @@ namespace WCS.BLL.HardWare
tcpClient.Send(tcpClient.GenerateMessage(BoardId, CheckModeData));
}
/// <summary>
/// 进入出库模式、亮灯
/// </summary>
/// <param name="tcpClient"></param>
public void GoInOutStoreMode(TCPClient tcpClient, List<string> outSns)
{
var storeInfos = DbHelp.db.Queryable<StoreInfo>()
.Where(t => t.BoardId == BoardId)
.OrderBy(t => t.LightNumber)
.ToList();
//计算物料在库的库位
char[] data = "0000000000000000".ToCharArray();
var storeNumber = storeInfos.Count();
foreach (var storeInfo in storeInfos)
{
if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn) && storeInfo.LightNumber > 0 && storeInfo.LightNumber <= storeNumber)
{
data[storeInfo.LightNumber - 1] = '1';
}
}
var dataStr = string.Join("", data.Reverse());
var data1 = dataStr.Substring(8, 8);
var data2 = dataStr.Substring(0, 8);
GoInOutstoreModeData[1] = Convert.ToByte(data1, 2);
GoInOutstoreModeData[2] = Convert.ToByte(data2, 2);
//出库位置亮灯
if (outSns != null && outSns.Count > 0)
{
var outStoreInfos = storeInfos.Where(t => outSns.Contains(t.CurrentMatSn))
.ToList();
char[] outData = "0000000000000000".ToCharArray();
foreach (var storeInfo in outStoreInfos)
{
if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn) && storeInfo.LightNumber > 0 && storeInfo.LightNumber <= storeNumber)
{
outData[storeInfo.LightNumber - 1] = '1';
}
}
var outDataStr = string.Join("", outData.Reverse());
var data3 = outDataStr.Substring(8, 8);
var data4 = outDataStr.Substring(0, 8);
GoInOutstoreModeData[3] = Convert.ToByte(data3, 2);
GoInOutstoreModeData[4] = Convert.ToByte(data4, 2);
}
tcpClient.Send(tcpClient.GenerateMessage(BoardId, GoInOutstoreModeData));
}
public void ComfirmOutstore(TCPClient tcpClient, byte lightNumber)
{
ComfirmOutstoreData[1] = lightNumber;
tcpClient.Send(tcpClient.GenerateMessage(BoardId, ComfirmOutstoreData));
}
/// <summary>
/// 退出出库模式
/// </summary>
/// <param name="tcpClient"></param>
public void GoOutOutStoreMode(TCPClient tcpClient)
{
tcpClient.Send(tcpClient.GenerateMessage(BoardId, GoOutOutstoreModeData));
}
}
}

View File

@ -5,6 +5,7 @@ using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Sockets;
using WCS.BLL.HardWare;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
@ -19,16 +20,18 @@ namespace WCS.BLL.Manager
public static List<TCPClient> TCPClients = new List<TCPClient>();
public static void InitTcpClient()
{
var ips = DbHelp.db.Queryable<ShelfInfo>().Select(t => t.ClientIp).ToList();
var ips = DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode.Contains("A")).Select(t => t.ClientIp).ToList();
foreach (var ip in ips)
{
var tcpCleint = new TCPClient(ip, "192.168.0.154:20003");
var tcpCleint = new TCPClient(ip, "192.168.0.183:20003");
//var tcpCleint = new TCPClient("192.168.0.183:20002", "192.168.0.183:20003");
//配置断线重连
tcpCleint.tcpClient.Received += (client, e) =>
{
var clientIpHost = client.IP + ":" + client.Port;
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
if (TcpCleint == null)
{
@ -47,14 +50,15 @@ namespace WCS.BLL.Manager
if (isEqual)
{
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
Logs.Write($"接受到数据:{BitConverter.ToString(dataTemp)}");
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
{
continue;
}
index += (TcpCleint.PreFixLength + TcpCleint.DataLength - 1);//每次循环index会+1 所以这里-1
//获取板子ID
var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1];
var lightNumber = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1];
var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]);
//报警灯
if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20)
@ -63,7 +67,7 @@ namespace WCS.BLL.Manager
.Where(t => t.LightId == boardId)
.FirstOrDefault();
var smartShelf = shelf as SmartShelf;
smartShelf?.ProtocolProcess(data, boardId, lightNumber);
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
}
//货架类型协议返回
else
@ -73,7 +77,7 @@ namespace WCS.BLL.Manager
.Where(t => t.ModuleIds.Contains(boardId))
.FirstOrDefault();
var smartShelf = shelf as SmartShelf;
smartShelf?.ProtocolProcess(data, boardId, lightNumber);
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Http;
using TouchSocket.Sockets;
namespace WCS.BLL.Manager
{
public static class WebSoceketManager
{
public static HttpService service;
public static void InitWebSocket()
{
service = new HttpService();
service.Setup(new TouchSocketConfig()//加载配置
.SetListenIPHosts(7789)
.ConfigureContainer(a =>
{
a.AddConsoleLogger();
})
.ConfigurePlugins(a =>
{
a.UseWebSocket()//添加WebSocket功能
.SetWSUrl("/ws")//设置url直接可以连接。
.UseAutoPong();//当收到ping报文时自动回应pong
a.Add<WebSocketServicePlugin>();//自定义插件。
}));
service.Start();
service.Logger.Info("服务器已启动");
}
//尝试发送报警信息给前端
public static void TrySendMessage(string IpAddress, string Message)
{
try
{
var clients = service.GetClients().Where(t => t.IP == IpAddress).ToList();
foreach (var client in clients)
{
client.WebSocket.SendAsync(Message);
}
}
catch (Exception ex)
{
}
}
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Http.WebSockets;
namespace WCS.BLL.Manager
{
public class WebSocketServicePlugin : PluginBase, IWebSocketReceivedPlugin
{
private readonly ILog m_logger;
public WebSocketServicePlugin(ILog logger)
{
this.m_logger = logger;
}
public async Task OnWebSocketReceived(IWebSocket client, WSDataFrameEventArgs e)
{
switch (e.DataFrame.Opcode)
{
case WSDataType.Cont:
m_logger.Info($"收到中间数据,长度为:{e.DataFrame.PayloadLength}");
return;
case WSDataType.Text:
m_logger.Info(e.DataFrame.ToText());
if (!client.Client.IsClient)
{
var clients = WebSoceketManager.service.GetClients().ToList();
clients.ForEach(t =>
{
t.WebSocket.Send("我已收到");
});
client.Send("我已收到");
}
return;
case WSDataType.Binary:
if (e.DataFrame.FIN)
{
m_logger.Info($"收到二进制数据,长度为:{e.DataFrame.PayloadLength}");
}
else
{
m_logger.Info($"收到未结束的二进制数据,长度为:{e.DataFrame.PayloadLength}");
}
return;
case WSDataType.Close:
{
m_logger.Info("远程请求断开");
client.Close("断开");
}
return;
case WSDataType.Ping:
client.Pong();
break;
case WSDataType.Pong:
break;
default:
break;
}
await e.InvokeNext();
}
}
}

View File

@ -17,6 +17,8 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request);
public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoInOutstore(GetOutOrderDetailRequest request);
public Task<ResponseBase> GoOutOutstore(GetOutOrderDetailRequest request);

View File

@ -27,5 +27,8 @@ namespace WCS.BLL.Services.IService
/// <param name="request"></param>
/// <returns></returns>
public Task<ResponseCommon<object>> addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request);
public Task<ResponseCommon<object>> GenerateStoreInfo();
}
}

View File

@ -64,6 +64,7 @@ namespace WCS.BLL.Services.Service
Message = $"货架进入入库模式失败:{string.Join(",", shelf.ExceptionMessages)}",
Data = null
};
}
public ResponseBase shelfGoOutInStore(ShelfGoOutInStoreRequest request)
@ -78,15 +79,23 @@ namespace WCS.BLL.Services.Service
Message = $"退出入库模式失败:货架[{request.ShelfCode}]不存在!",
};
}
//TO DO 判断扫码枪 是否被其他扫码枪所占用 如果占用 直接退出入库模式 不发指令
//两个扫码枪互相占用入库会有问题
//判断扫码枪 是否被其他扫码枪所占用 如果占用 直接退出入库模式 不发指令
shelf.GoOutInstore();
if (shelf.ExceptionMessages == null || shelf.ExceptionMessages.Count == 0)
//已退出
return new ResponseCommon()
{
Code = 200,
Message = $"货架[{request.ShelfCode}]已退出入库模式!",
};
else
return new ResponseCommon()
{
Code = 200,
Message = $"货架[{request.ShelfCode}]已退出入库模式!{string.Join(",", shelf.ExceptionMessages)}",
};
}
public async Task<ResponseBase> queryByMatSn(QueryByMatSnRequest request)
@ -120,8 +129,8 @@ namespace WCS.BLL.Services.Service
Message = $"操作失败:物料{inventory.MatSN}已入库,库位为{inventory.StoreCode}",
};
}
#region
//调用接口或者直接查询数据库
#region //调用接口或者直接查询数据库
//调用接口
if (1 != 1)
{

View File

@ -4,11 +4,14 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Sockets;
using WCS.BLL.DbModels;
using WCS.BLL.Manager;
using WCS.BLL.Services.IService;
using WCS.DAL.Db;
using WCS.DAL.DbModels;
using WCS.Model;
using WCS.Model.ApiModel.OutStore;
namespace WCS.BLL.Services.Service
{
@ -55,8 +58,10 @@ namespace WCS.BLL.Services.Service
OrderId = order.Id,
OrderNumber = order.OrderNumber,
MatCode = item.MatCode,
MatName = item.MatName,
MatBatch = item.MatBatch,
ReqQty = item.ReqQty,
OutQty = 0,
CreateUser = request.UserName
};
await DbHelp.db.Insertable(orderDetail).ExecuteCommandAsync();
@ -202,18 +207,31 @@ namespace WCS.BLL.Services.Service
public async Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request)
{
//直接查询
var outOrderList = await DbHelp.db.Queryable<OutOrder>()
var recordsQueryable = DbHelp.db.Queryable<OutOrder>()
.WhereIF(!string.IsNullOrEmpty(request.OrderNumber), t => t.OrderNumber.Contains(request.OrderNumber))
.WhereIF(!string.IsNullOrEmpty(request.OrderSource), t => t.OrderSource.Contains(request.OrderSource))
.WhereIF(!string.IsNullOrEmpty(request.OrderType), t => t.OrderType.Contains(request.OrderType));
var totalCount = await recordsQueryable.CountAsync();
var records = await recordsQueryable
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
.ToListAsync();
//生成序号
for (int i = 0; i < records.Count; i++)
{
records[i].RowNumber = (request.PageNumber - 1) * 10 + i + 1;
}
return new PageQueryResponse<OutOrder>()
{
Code = 200,
Message = "success",
Message = $"success",
Data = new PageQueryResponseData<OutOrder>()
{
Lists = outOrderList,
Count = outOrderList.Count
TotalCount = totalCount,
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
Count = records.Count,
Lists = records.ToList()
}
};
}
@ -235,7 +253,7 @@ namespace WCS.BLL.Services.Service
};
}
}
else if (string.IsNullOrEmpty(request.OrderNumber))
else if (!string.IsNullOrEmpty(request.OrderNumber))
{
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.OrderNumber == request.OrderNumber)
.FirstAsync();
@ -262,29 +280,84 @@ namespace WCS.BLL.Services.Service
var orderDetailTask = DbHelp.db.Queryable<OutOrderDetail>()
.Where(t => t.OrderId == outOrder.Id)
.ToListAsync();
var orderDetail = await orderDetailTask;
//生成序号
for (int i = 0; i < orderDetail.Count; i++)
{
orderDetail[i].RowNumber = i + 1;
}
#endregion
return new ResponseCommon<List<OutOrderDetail>>()
{
Code = 200,
Message = "Success",
Data = orderDetail
};
}
public async Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request)
{
OutOrder outOrder = null;
#region
if (request.OrderId != 0)
{
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.Id == request.OrderId).FirstAsync();
if (outOrder == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"查询失败不存在Id为{request.OrderId}的出库单!",
};
}
}
else if (!string.IsNullOrEmpty(request.OrderNumber))
{
outOrder = await DbHelp.db.Queryable<OutOrder>().Where(t => t.OrderNumber == request.OrderNumber)
.FirstAsync();
if (outOrder == null)
{
return new ResponseCommon()
{
Code = 201,
Message = $"查询失败:不存在单据号为{request.OrderNumber}的出库单!",
};
}
}
else
{
return new ResponseCommon()
{
Code = 201,
Message = $"查询失败:缺少必要参数!",
};
}
#endregion
#region
var orderMatDetailTask = DbHelp.db.Queryable<OutOrderMatDetail>()
.Where(t => t.OrderId == outOrder.Id)
.ToListAsync();
var orderMatDetail = await orderMatDetailTask;
//生成序号
for (int i = 0; i < orderMatDetail.Count; i++)
{
orderMatDetail[i].RowNumber = i + 1;
}
#endregion
var orderDetail = await orderDetailTask;
var orderMatDetail = await orderMatDetailTask;
return new ResponseCommon()
return new ResponseCommon<List<OutOrderMatDetail>>
{
Code = 200,
Message = "Success",
Data = new
{
OrderDetailLists = orderDetail,
OrderMatDetailLists = orderMatDetail,
}
Data = orderMatDetail
};
}
private string GenerateOrderNumber()
{
var orderNumber = "PD" + DateTime.Now.ToString("yyyyMMddHHmmss");
@ -303,26 +376,60 @@ namespace WCS.BLL.Services.Service
return new ResponseCommon()
{
Code = 201,
Message = "不存在对应的出库单据!",
Message = $"不存在对应的出库单据{request.OrderNumber}",
Data = null
};
}
//获取出库单据明细
//TO DO 如果是按物料编码出库 需要计算物料明细保存并进行锁定
//如果是按物料编码出库 需要计算物料明细并进行物料锁定
if (order.SyncType == SyncTypeEnum.ByMatCode)
{
}
//分组 按物料找到对应的货架
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.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 =>
{
var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode)
.Distinct()
.ToList();
shelf.GoInOutstore(matDetails,order);
});
//返回
return new ResponseCommon()
@ -333,17 +440,188 @@ namespace WCS.BLL.Services.Service
};
}
private ResponseBase CaculateOutOrderMatDetails(OutOrder order)
{
try
{
DbHelp.db.BeginTran();
////第一步 删除、解锁 放在上一次结束入库时操作
//var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
// .Where(t => t.OrderId == order.Id)
// .ToList();
//var inventoryIds = outOrderMatDetails.Select(t => t.Id).ToList();
//var inventoryDetails = DbHelp.db.Queryable<InventoryDetail>()
// .Where(t => inventoryIds.Contains(t.Id))
// .ToList();
//inventoryDetails.ForEach(t => { t.IsLocked = false; });
//DbHelp.db.Deleteable(outOrderMatDetails).ExecuteCommand();
//DbHelp.db.Updateable(inventoryDetails).ExecuteCommand();
//第一步 找到需求物料
var outOrderDetails = DbHelp.db.Queryable<OutOrderDetail>()
.Where(t => t.OrderId == order.Id)
.ToList();
if (outOrderDetails == null || outOrderDetails.Count == 0)
{
return new ResponseCommon()
{
Code = 201,
Message = $"计算物料失败,{order.OrderNumber}没有单据明细!"
};
}
//第二步 开始计算物料
List<OutOrderMatDetail> outOrderMatDetails = new List<OutOrderMatDetail>();
foreach (var outOrderDetail in outOrderDetails)
{
//2.1筛选 满足 图号 批次的库存
var matInventoryDetails = DbHelp.db.Queryable<InventoryDetail>()
.Where(t => t.MatCode == outOrderDetail.MatCode)
.WhereIF(!string.IsNullOrEmpty(outOrderDetail.MatBatch), t => t.MatBatch == outOrderDetail.MatBatch)
.OrderBy(t => t.MatBatch)//先进先出
.OrderBy(t => t.MatQty)//零散料先出
.ToList();
//2.2按照搜索出来的库存和当前未出的数量 计算需要出的SN
for (int i = 0; i < matInventoryDetails.Count && outOrderDetail.ReqQty - outOrderDetail.OutQty > 0; i++)
{
if (outOrderDetail.ReqQty - outOrderDetail.OutQty <= matInventoryDetails[i].MatQty)
{
outOrderMatDetails.Add(new OutOrderMatDetail()
{
OrderId = outOrderDetail.Id,
OrderNumber = outOrderDetail.OrderNumber,
OutOrderDetailId = outOrderDetail.Id,
InventoryDetailId = matInventoryDetails[i].Id,
StoreId = matInventoryDetails[i].StoreId,
StoreCode = matInventoryDetails[i].StoreCode,
MatSN = matInventoryDetails[i].MatSN,
MatCode = matInventoryDetails[i].MatCode,
MatName = matInventoryDetails[i].MatName,
MatSpec = matInventoryDetails[i].MatSpec,
MatBatch = matInventoryDetails[i].MatBatch,
MatQty = matInventoryDetails[i].MatQty,
MatSupplier = matInventoryDetails[i].MatSupplier,
MatCustomer = matInventoryDetails[i].MatCustomer,
IsSended = false,
CreateUser = "待定",
});
outOrderDetail.ReqQty = 0;
matInventoryDetails[i].IsLocked = true;
DbHelp.db.Updateable(matInventoryDetails[i]).ExecuteCommand();
}
else
{
outOrderDetail.ReqQty = outOrderDetail.ReqQty - matInventoryDetails[i].MatQty;
outOrderMatDetails.Add(new OutOrderMatDetail()
{
OrderId = outOrderDetail.Id,
OrderNumber = outOrderDetail.OrderNumber,
OutOrderDetailId = outOrderDetail.Id,
InventoryDetailId = matInventoryDetails[i].Id,
StoreId = matInventoryDetails[i].StoreId,
StoreCode = matInventoryDetails[i].StoreCode,
MatSN = matInventoryDetails[i].MatSN,
MatCode = matInventoryDetails[i].MatCode,
MatName = matInventoryDetails[i].MatName,
MatSpec = matInventoryDetails[i].MatSpec,
MatBatch = matInventoryDetails[i].MatBatch,
MatQty = matInventoryDetails[i].MatQty,
MatSupplier = matInventoryDetails[i].MatSupplier,
MatCustomer = matInventoryDetails[i].MatCustomer,
IsSended = false,
CreateUser = "待定",
});
matInventoryDetails[i].IsLocked = true;
DbHelp.db.Updateable(matInventoryDetails[i]).ExecuteCommand();
}
}
}
DbHelp.db.Insertable(outOrderMatDetails).ExecuteCommand();
DbHelp.db.CommitTran();
return new ResponseCommon()
{
Code = 200,
Message = $"Success"
};
}
catch (Exception ex)
{
DbHelp.db.RollbackTran();
return new ResponseCommon()
{
Code = 300,
Message = $"发生异常:{ex.Message}"
};
}
}
private ResponseBase CancelOutOrderMatDetails(OutOrder order)
{
try
{
DbHelp.db.BeginTran();
var outOrderMatDetails = DbHelp.db.Queryable<OutOrderMatDetail>()
.Where(t => t.OrderId == order.Id)
.ToList();
var inventoryIds = outOrderMatDetails.Select(t => t.Id).ToList();
var inventoryDetails = DbHelp.db.Queryable<InventoryDetail>()
.Where(t => inventoryIds.Contains(t.Id))
.ToList();
inventoryDetails.ForEach(t => { t.IsLocked = false; });
DbHelp.db.Deleteable(outOrderMatDetails).ExecuteCommand();
DbHelp.db.Updateable(inventoryDetails).ExecuteCommand();
DbHelp.db.CommitTran();
return new ResponseCommon()
{
Code = 200,
Message = $"Success"
};
}
catch (Exception ex)
{
DbHelp.db.RollbackTran();
return new ResponseCommon()
{
Code = 300,
Message = $"发生异常:{ex.Message}"
};
}
}
public async Task<ResponseBase> GoOutOutstore(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)
{
return new ResponseCommon()
{
Code = 201,
Message = $"不存在对应的出库单据{request.OrderNumber}",
Data = null
};
}
//找到正在出对应出库单的货架
var shelves = ShelfManager.Shelves.Where(t => t.OrderNumber == request.OrderNumber)
.ToList();
//退出出库模式
shelves.ForEach(t =>
{
t.GoOutOutstore();
});
//解锁物料 删除物料明细
CancelOutOrderMatDetails(order);
return new ResponseCommon()
{
Code = 200,

View File

@ -236,5 +236,43 @@ namespace WCS.BLL.Services.Service
return response;
}
}
Task<PageQueryResponse<ShelfInfo>> IStoreInfoService.GetShelves(GetShelvesRequest request)
{
throw new NotImplementedException();
}
Task<ResponseCommon<object>> IStoreInfoService.addOrUpdateShelfInfo(AddShelfInfoRequest<ShelfInfo> request)
{
throw new NotImplementedException();
}
async Task<ResponseCommon<object>> IStoreInfoService.GenerateStoreInfo()
{
var shelfInfo = await DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode == "C04-1").FirstAsync();
var ModuleInfos = await DbHelp.db.Queryable<ModuleInfo>().Where(t => t.ShelfId == shelfInfo.Id).ToListAsync();
ModuleInfos.ForEach(moduleInfo =>
{
for (int i = 1; i <= moduleInfo.LightCount; i++)
{
var storeInfo = new StoreInfo()
{
StoreCode = moduleInfo.ModuleCode + "-" + i.ToString(),
ModuleId = moduleInfo.Id,
ModuleCode = moduleInfo.ModuleCode,
ShelfId = shelfInfo.Id,
ShelfCode = shelfInfo.ShelfCode,
BoardId = moduleInfo.BoardId,
LightNumber = i,
Priority = 1,
CurrentMatSn = string.Empty,
};
DbHelp.db.Insertable(storeInfo).ExecuteCommand();
}
});
return new ResponseCommon<object>() { Message = "111"};
}
}
}

View File

@ -60,7 +60,7 @@ namespace WCS.BLL
//载入配置
tcpClient.Setup(new TouchSocketConfig()
.SetRemoteIPHost(RemoteIPHost)
.SetBindIPHost(BindIPHost)
//.SetBindIPHost(BindIPHost)
.ConfigurePlugins(a =>
{
//配置断线重连
@ -156,19 +156,17 @@ namespace WCS.BLL
}
}
public void ReConnectAsync()
{
tcpClient.TryConnectAsync();
}
public void Send(byte[] message)
{
try
{
var boardId = (message[3] << 8) + message[4];
//记录发送指令 用于通信校验 同Id只校验最后一个指令
////MessageList.AddOrUpdate(boardId, new MessageDto()
////{
//// ID = boardId,
//// Message = message,
////}, (key, oldValue) => oldValue = new MessageDto()
////{
//// ID = boardId,
//// Message = message,
////});
lock (sendLockObject)
{
tcpClient.Send(message);
@ -176,6 +174,19 @@ namespace WCS.BLL
Thread.Sleep(10);
}
}
catch (Exception ex)
{
//因异常断连时(网线已经被断了) 尝试重连一次
if (ex is NotConnectedException)
{
Task.Run(() =>
{
ReConnectAsync();
});
}
throw ex;
}
}
//生成协议明细
public byte[] GenerateMessage(int boardId, byte[] data)

View File

@ -7,7 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="TouchSocket" Version="2.0.0" />
<PackageReference Include="TouchSocket" Version="2.0.3" />
<PackageReference Include="TouchSocket.Http" Version="2.0.3" />
<PackageReference Include="XLParser" Version="1.7.2" />
</ItemGroup>

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace WCS.Model
{
public class GetOutOrderDetailRequest : ResponseBase
public class GetOutOrderDetailRequest : RequestBase
{
public int OrderId { get; set; }
public string OrderNumber { get; set; }

View File

@ -10,10 +10,8 @@ namespace WCS.Model
{
public string OrderNumber { get; set; }
public int OrderStatus { get; set; }
public string OrderSource { get; set; }
//public int PageNumber { get; set; }
//public int PageSize { get; set; }
public string OrderType { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.OutStore
{
public class OutOrderDetailModel
{
public int Id { get; set; }
public int OrderId { get; set; }
public string OrderNumber { get; set; }
public string MatCode { get; set; }
public string MatName { get; set; }
public string MatBatch { get; set; }
public int ReqQty { get; set; }
public int OutQty { get; set; }
public DateTime CreateTime { get; set; }
public string CreateUser { get; set; }
public int RowNumber { get; set; }
}
}

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace WCS.Model.ApiModel.OutStore
{
public class OutOrderMatDetailModel
{
public int Id { get; set; }
public int OrderId { get; set; }
public string OrderNumber { get; set; }
public int OutOrderDetailId { get; set; }
public int InventoryDetailId { get; set; }
#region
public int StoreId { get; set; }
public string StoreCode { get; set; }
#endregion
#region
public string MatSN { get; set; }
public string MatCode { get; set; }
public string MatName { get; set; }
public string MatSpec { get; set; }
public string MatBatch { get; set; }
public int MatQty { get; set; }
public string? MatSupplier { get; set; }
public string? MatCustomer { get; set; }
#endregion
public bool IsSended { get; set; } = false;
public DateTime CreateTime { get; set; }
public string CreateUser { get; set; }
public int RowNumber { get; set; }
}
}

View File

@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
namespace WCS.Model.ApiModel.OutStore
{
public class OutOrderModel : INotifyPropertyChanged
{
public int Id { get; set; }
public string OrderNumber { get; set; }
public OutOrderStatus OrderStatus { get; set; }
public OutOrderExeStatus OutOrderExeStatus { get; set; }
public string OrderSource { get; set; }
public string OrderType { get; set; }
public SyncTypeEnum SyncType { get; set; }
public DateTime CreateTime { get; set; }
public string CreateUser { get; set; }
public bool IsSelected
{
get { return isSelected; }
set
{
isSelected = value;
OnPropertyChanged(nameof(IsSelected));
}
}
public bool isSelected;
public int RowNumber { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public enum OutOrderStatus
{
= 0,
= 1,
= 2
}
public enum OutOrderExeStatus
{
= 0,
= 1,
= 2,
= 3
}
public enum SyncTypeEnum
{
ByMatCode = 0,
ByMatSn = 1
}
}

View File

@ -23,6 +23,7 @@ namespace WCS.Model
public class MatCodeItemList
{
public string MatCode { get; set; }
public string MatName { get; set; }
public string MatBatch { get; set; }
public int ReqQty { get; set; }
}

View File

@ -113,6 +113,30 @@ namespace WebApi.Controllers
}
}
/// <summary>
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><E2B5A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("getOutOrderMatDetail")]
[HttpPost(Name = "getOutOrderMatDetail")]
public async Task<ResponseBase> getOutOrderMatDetail(GetOutOrderDetailRequest request)
{
try
{
return await _outstoreService.GetOutOrderMatDetail(request);
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 300,
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
};
}
}
/// <summary>
/// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݺſ<DDBA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
/// </summary>
@ -147,7 +171,7 @@ namespace WebApi.Controllers
{
try
{
return await _outstoreService.GetOutOrderDetail(request);
return await _outstoreService.GoOutOutstore(request);
}
catch (Exception ex)
{

View File

@ -35,5 +35,11 @@ namespace WCS.WebApi.Controllers
{
return await _storeInfoService.addOrUpdateShelfInfo(request);
}
[HttpPost("GenerateStoreInfo")]
public async Task<ResponseCommon<object>> GenerateStoreInfo()
{
return await _storeInfoService.GenerateStoreInfo();
}
}
}

View File

@ -18,7 +18,7 @@ namespace WebApi
public static void Main(string[] args)
{
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 });
@ -28,6 +28,8 @@ namespace WebApi
TCPClientManager.InitTcpClient();
var builder = WebApplication.CreateBuilder(args);
//// <20><><EFBFBD><EFBFBD>Kestrel
//builder.WebHost.ConfigureKestrel((context, options) =>

View File

@ -11,7 +11,6 @@
<PackageReference Include="MiniExcel" Version="1.31.3" />
<PackageReference Include="NPOI" Version="2.7.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="TouchSocket" Version="2.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -10,6 +10,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.BLL", "..\WCS.BLL\WCS.BLL.csproj", "{A6B0DB70-BE92-487C-BA6B-56441B676C85}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "货架标准上位机", "..\货架标准上位机\货架标准上位机.csproj", "{A24FAA0F-8483-4741-BFE7-EC2C56C811A6}"
ProjectSection(ProjectDependencies) = postProject
{118D453B-1693-4C00-8378-20ECBFCF2700} = {118D453B-1693-4C00-8378-20ECBFCF2700}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WCS.Model", "..\WCS.Model\WCS.Model.csproj", "{7CE9AF07-3538-46C3-BBF0-A039BDE15AAF}"
EndProject

View File

@ -140,6 +140,7 @@ namespace 货架标准上位机.ViewModel
{
scanner.ShelfCode = string.Empty;
scanner.ModulesStr = string.Empty;
}
}
catch (Exception ex)
@ -201,7 +202,7 @@ namespace 货架标准上位机.ViewModel
{
scanner.MatSn = Result.Data.MatSN;
}
else if(Result != null && !string.IsNullOrEmpty(Result.Message))
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
Growl.Warning(Result.Message);
}
@ -237,6 +238,7 @@ namespace 货架标准上位机.ViewModel
t.MatSn = string.Empty;
t.ScannerDisplayControl.RefreshValues(t.ShelfCode, t.MatSn);
Growl.Success(Result.Message);
}
}
else

View File

@ -11,6 +11,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Markup;
@ -25,6 +26,18 @@ namespace 货架标准上位机.ViewModel
/// </summary>
public string Title { get => title; set { SetProperty(ref title, value); } }
private bool goToOutVentoryView;
public bool GoToOutVentoryView
{
get { return goToOutVentoryView; }
set
{
SetProperty(ref goToOutVentoryView, value);
}
}
#region _MainWindow2
//隐藏式选项卡的高度
public double TabItemHeight { get; set; } = 0;
@ -72,6 +85,10 @@ namespace 货架标准上位机.ViewModel
{
ScannerManager.InitScanners();
}),
new Tuple<string, string, Action>("初始化WebSocket连接..", "初始化WebSocket连接失败请联系管理员", () =>
{
WebSocket.InitWebSocket();
}),
};
MainLoadWindow.TaskSleepTime = 200;
@ -88,7 +105,7 @@ namespace 货架标准上位机.ViewModel
});
////不登录,直接使用最高权限
//不登录,直接使用最高权限
//{
// UserLoginView.NotLogin();
// return true;

View File

@ -124,7 +124,6 @@ namespace 货架标准上位机.ViewModel
CurrentPage = 1;
return;
}
#region
//var dia = Dialog.Show(new TextDialog());
try
@ -159,8 +158,6 @@ namespace 货架标准上位机.ViewModel
//dia.Close();
}
#endregion
}
/// <summary>

View File

@ -116,8 +116,9 @@ namespace 货架标准上位机.ViewModels
ItemList = DataGridItemSource.Select(t => new MatCodeItemList()
{
MatCode = t.MatCode,
MatName = t.MatName,
MatBatch = t.MatBatch,
ReqQty = t.NeedQty
ReqQty = t.NeedQty,
}).ToList(),
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser

View File

@ -0,0 +1,378 @@
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 .Api;
namespace .ViewModels
{
public class OutInventoryDocumentViewModel : BindableBase
{
public OutInventoryDocumentViewModel()
{
BtnSearch();
}
#region Properties界面绑定的实体
private ObservableCollection<OutOrderModel> dataGridItemSource;
public ObservableCollection<OutOrderModel> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
}
}
public OutOrderModel selectedataGridItem;
public OutOrderModel 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 GetOutOrderListRequest()
{
OrderNumber = OrderNumber,
OrderType = OrderType,
OrderSource = OrderSource,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
PageNumber = CurrentPage,
PageSize = 10,
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<OutOrderModel>>(LocalFile.Config.ApiIpHost + "outStore/GetOutOrderList", body, "POST");
if (Result != null && Result.Data != null && Result.Data.Lists != null)
{
DataGridItemSource = new ObservableCollection<OutOrderModel>(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()
{
}
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.OrderNumber,
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.OrderNumber,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<OutOrderMatDetailModel>>>(LocalFile.Config.ApiIpHost + "outStore/getOutOrderMatDetail", body, "POST");
if (Result != null && Result.Code == 200)
{
if (Result.Data.Count > 0)
{
//打开窗体
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()
{
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.OrderNumber,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
};
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goInOutstore", body, "POST");
if (Result != null && Result.Code == 200)
{
//成功后直接跳转
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()
{
}
#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
}
}

View File

@ -39,7 +39,7 @@
<GroupBox.Header>
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">
<TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center">报警</TextBlock>
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextErrCommand}">&#xeb45; 清除</Button>
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextErrCommand}">&#xe652; 清除</Button>
</Grid>
</GroupBox.Header>
<TextBox Style="{StaticResource TextBoxExtend.Multi}" IsReadOnly="True" Margin="-1" Text="{Binding TextErr}" Foreground="Tomato" hc:InfoElement.Placeholder="没有报警信息"></TextBox>
@ -49,10 +49,10 @@
<GroupBox.Header>
<Grid Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type GroupBox}}}">
<TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center">日志</TextBlock>
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextInfoCommand}">&#xe62c; 清空</Button>
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextInfoCommand}">&#xe652; 清空</Button>
</Grid>
</GroupBox.Header>
<pi:TextBoxLog Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
<pi:TextBoxLog Token="123" Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
</GroupBox>
</Grid>
</Border>

View File

@ -13,7 +13,8 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="10*"></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
<RowDefinition Height="5*"></RowDefinition>
</Grid.RowDefinitions>
<Border Grid.Row="0" Margin="0" Background="AliceBlue" CornerRadius="0" Padding="0" MouseUp="Border_MouseUp">
@ -26,113 +27,51 @@
<StackPanel Grid.Column="1" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
<Button Style="{StaticResource ButtonDanger}" Margin="10" hc:BorderElement.CornerRadius="15"
MinHeight="40" FontSize="20" Content="&#xe61b;结束入库" FontFamily="{StaticResource IconFont}"
<Button
Style="{StaticResource ButtonDanger}"
Margin="10"
PreviewKeyDown="Button_PreviewKeyDown"
hc:BorderElement.CornerRadius="15"
MinHeight="40"
FontSize="20"
Content="&#xe61b;结束入库"
FontFamily="{StaticResource IconFont}"
Command="{Binding BtnEndCommand}">
</Button>
</StackPanel>
</Grid>
</Border>
<Border Grid.Row="1" Margin="1" Background="AliceBlue" Padding="0">
<Border Grid.Row="1" Margin="5,5,5,5" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
<WrapPanel Name="scannersWrapPanel">
</WrapPanel>
<!--<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="8*"></RowDefinition>
<RowDefinition Height="8*"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="1.2*"></RowDefinition>
<RowDefinition Height="1.2*"></RowDefinition>
</Grid.RowDefinitions>
</Border>
<Border Grid.Row="2" Margin="5,5,5,5" BorderThickness="1" Background="White" BorderBrush="DodgerBlue" CornerRadius="3">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="2*"></ColumnDefinition>
<ColumnDefinition Width="3*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0"
Text="最小包装条码:" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="3"
Text="{Binding MatSN}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left"
></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="0"
Text="物料编码:" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Grid.Row="1" Grid.Column="1"
Text="{Binding MatCode}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left"
></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="0"
Text="物料名称:" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Grid.Row="2" Grid.Column="1"
Text="{Binding MatName}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left"
></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="0"
Text="物料规格:" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="3"
Text="{Binding MatSpec}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left"
>
</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="0"
Text="物料批次:" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Right">
</TextBlock>
<TextBlock Grid.Row="4" Grid.Column="1"
Text="{Binding MatBatch}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left">
</TextBlock>
<TextBlock Grid.Row="5" Grid.Column="0"
Text="物料数量:" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Grid.Row="5" Grid.Column="1"
Text="{Binding MatQty}" FontSize="20"
VerticalAlignment="Center" HorizontalAlignment="Left"></TextBlock>
<TextBlock Grid.Row="4" Grid.Column="2"
Text="当前入库货架:" FontSize="20" FontWeight="Bold"
VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<TextBlock Grid.Row="4" Grid.Column="3" Grid.RowSpan="2"
Text="{Binding ShelfCode}" FontSize="5" FontWeight="Bold"
VerticalAlignment="Center" HorizontalAlignment="Left">
</TextBlock>
<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>
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextInfoCommand}">&#xe652; 清空</Button>
</Grid>
</GroupBox.Header>
<pi:TextBoxLog Token="InstoreWarning" Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
</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}}}">
<TextBlock Margin="5,0" HorizontalAlignment="Left" VerticalAlignment="Center">入库日志信息</TextBlock>
<Button HorizontalAlignment="Right" Height="25" Margin="10,0" Padding="10,0" FontFamily="{StaticResource IconFont}" Command="{Binding ClearTextInfoCommand}">&#xe652; 清空</Button>
</Grid>
</GroupBox.Header>
<pi:TextBoxLog Token="InstoreLog" Style="{StaticResource TextBoxExtend.Multi}" Margin="-1" hc:InfoElement.Placeholder="没有日志信息" Foreground="CornflowerBlue"></pi:TextBoxLog>
</GroupBox>
</Grid>
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
ItemsSource="{Binding DataGridItemSource}"
RowHeight="39" Margin="5"
AutoGenerateColumns="False" FontSize="18" CanUserSortColumns="False">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料名称" Binding="{Binding MatName}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料规格" Binding="{Binding MatSpec}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="批次" Binding="{Binding MatBatch}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="数量" Binding="{Binding MatQty}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="入库位置" Binding="{Binding StoreCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="入库人" Binding="{Binding InstoreUser}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="入库时间" Binding="{Binding InstoreTime ,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="最小包装条码" Binding="{Binding MatSN}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>-->
</Border>
</Grid>

View File

@ -65,5 +65,13 @@ namespace 货架标准上位机
{
}
private void Button_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Space)
{
e.Handled = true; // 阻止空格键触发按钮点击事件
}
}
}
}

View File

@ -87,9 +87,6 @@
</hc:TransitioningContentControl>
</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">
@ -103,6 +100,17 @@
</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="&#xe67d;" FontSize="20" FontFamily="{StaticResource IconFont}"></TextBlock>
<TextBlock Margin="10,0,0,0" FontSize="16">出库单据</TextBlock>
</StackPanel>
</TabItem.Header>
<hc:TransitioningContentControl TransitionMode="Fade">
<View:OutInventoryDocumentView/>
</hc:TransitioningContentControl>
</TabItem>
<TabItem IsSelected="{Binding GoToOutVentoryView}" 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="&#xe67d;" FontSize="20" FontFamily="{StaticResource IconFont}"></TextBlock>

View File

@ -0,0 +1,48 @@
<hc:Window x:Class="货架标准上位机.OutInventoryDocumentDetailView"
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"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
Height="500" Width="800" WindowStyle="None" BorderThickness="0" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
<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>
<TextBlock FontSize="24" Name="Title" Text="单 据 明 细" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Margin="-5,-1" Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" HorizontalAlignment="Right" VerticalAlignment="Top" Click="closeClick"/>
<Grid Margin="5,0" Grid.Row="1" >
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
ItemsSource="{Binding DataGridItemSource}"
RowHeight="39"
AutoGenerateColumns="False" Name="dg1" FontSize="13">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="序号" Binding="{Binding RowNumber}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="单据编号" Binding="{Binding OrderNumber}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料名称" Binding="{Binding MatName}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料批次" Binding="{Binding MatBatch}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="需求数量" Binding="{Binding ReqQty}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="已出库数量" Binding="{Binding OutQty}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<StackPanel Margin="5" x:Name="spacingPanel" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Margin="5" Content="确认" FontSize="18" Click="closeClick"/>
</StackPanel>
</Grid>
</Border>
</hc:Window>

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
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.ApiModel.OutStore;
using static System.Net.Mime.MediaTypeNames;
namespace
{
public partial class OutInventoryDocumentDetailView : HandyControl.Controls.Window
{
public OutInventoryDocumentDetailView(List<OutOrderDetailModel> _matBaseInfo = null)
{
InitializeComponent();
if (_matBaseInfo != null)
{
dg1.ItemsSource = _matBaseInfo;
}
}
private void closeClick(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
DataGrid datagrid = sender as DataGrid;
datagrid.UnselectAllCells();
}
}
}

View File

@ -0,0 +1,51 @@
<hc:Window x:Class="货架标准上位机.OutInventoryDocumentMatDetailView"
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"
mc:Ignorable="d"
xmlns:hc="https://handyorg.github.io/handycontrol"
Height="500" Width="800" WindowStyle="None" BorderThickness="0" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
<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>
<TextBlock FontSize="24" Name="Title" Text="发 料 明 细" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<Button Margin="-5,-1" Visibility="{Binding IsClose,Converter={StaticResource Boolean2VisibilityConverter}}" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource CloseGeometry}" HorizontalAlignment="Right" VerticalAlignment="Top" Click="closeClick"/>
<Grid Margin="5,0" Grid.Row="1" >
<DataGrid Grid.Row="1" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
ItemsSource="{Binding DataGridItemSource}"
RowHeight="39"
AutoGenerateColumns="False" Name="dg1" FontSize="13">
<DataGrid.Columns>
<DataGridTextColumn IsReadOnly="True" Header="序号" Binding="{Binding RowNumber}"></DataGridTextColumn>
<DataGridTextColumn Header="库位" MaxWidth="120" Binding="{Binding StoreCode}"></DataGridTextColumn>
<DataGridTextColumn Header="物料编码" MaxWidth="150" Binding="{Binding MatCode}"></DataGridTextColumn>
<DataGridTextColumn Header="物料名称" MaxWidth="150" Binding="{Binding MatName}"></DataGridTextColumn>
<DataGridTextColumn Header="数量" Binding="{Binding MatQty}"></DataGridTextColumn>
<DataGridTextColumn Header="物料规格" MaxWidth="150" Binding="{Binding MatSpec}"></DataGridTextColumn>
<DataGridTextColumn Header="物料批次" MaxWidth="150" Binding="{Binding MatBatch}"></DataGridTextColumn>
<DataGridTextColumn Header="物料SN" MaxWidth="150" Binding="{Binding MatSN}"></DataGridTextColumn>
<DataGridTextColumn Header="是否已发" MaxWidth="100" Binding="{Binding IsSended}"></DataGridTextColumn>
<DataGridTextColumn Header="操作人" MaxWidth="150" Binding="{Binding OpUser}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
<StackPanel Margin="5" x:Name="spacingPanel" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
<Button Margin="5" Content="确认" FontSize="18" Click="closeClick"/>
</StackPanel>
</Grid>
</Border>
</hc:Window>

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
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 WCS.Model.ApiModel.OutStore;
namespace
{
public partial class OutInventoryDocumentMatDetailView : HandyControl.Controls.Window
{
public OutInventoryDocumentMatDetailView(List<OutOrderMatDetailModel> _matBaseInfo = null)
{
InitializeComponent();
if (_matBaseInfo != null )
{
dg1.ItemsSource= _matBaseInfo;
}
}
private void closeClick(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
this.Close();
}
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
DataGrid datagrid = sender as DataGrid;
datagrid.UnselectAllCells();
}
}
}

View File

@ -0,0 +1,181 @@
<pi:UserControlBase
xmlns:pi="https://github.com/ping9719/wpfex"
x:Class="货架标准上位机.OutInventoryDocumentView"
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="&#xe8b9; 搜索" 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="&#xe652; 重置" 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="&#xe6e2;单据明细" FontFamily="{StaticResource IconFont}" Background="#bccbb0" Foreground="White">
</Button>
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnOrderMatDetailCommand}"
Content="&#xe6e2;发料明细" FontFamily="{StaticResource IconFont}" Background="#bccbb0" Foreground="White">
</Button>
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnStartCommand}"
Content="&#xec61;开始发料" FontFamily="{StaticResource IconFont}" Background="CadetBlue" Foreground="White">
</Button>
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnPauseCommand}"
Content="&#xe67e;暂停发料" 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 OrderNumber}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="单据来源" Binding="{Binding OrderSource}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="单据类型" Binding="{Binding OrderType}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="单据状态" Binding="{Binding OrderStatus}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="单据同步类型" Binding="{Binding SyncType}"></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>

View 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 OutInventoryDocumentView : UserControlBase
{
public OutInventoryDocumentViewModel viewModel = new OutInventoryDocumentViewModel();
public OutInventoryDocumentView()
{
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) + "...";
}
}
}
}
}

View File

@ -132,9 +132,9 @@ namespace 货架标准上位机
{
var body = new GetUsersRequest()
{
UserName = "未登录",
UserName = "admin",
DeviceType = "WCS前端",
Info = "admin",
Info = "123",
};
var Result = ApiHelp.Post<ResponseCommon<List<UserModel>>>([LocalFile.Config.ApiIpHost, "user/getUsers"], body).Result;
if (Result != null && Result.Data.Any())
@ -144,9 +144,9 @@ namespace 货架标准上位机
var bodyRole = new GetUsersRequest()
{
UserName = "未登录",
UserName = "admin",
DeviceType = "WCS前端",
Info = string.Empty,
Info = "123",
};
var ResultRole = ApiHelp.Post<ResponseCommon<List<RoleModel>>>([LocalFile.Config.ApiIpHost, "user/getRoles"], body).Result;

View File

@ -0,0 +1,100 @@
using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TouchSocket.Core;
using TouchSocket.Http.WebSockets;
using TouchSocket.Sockets;
namespace
{
public static class WebSocket
{
public static void InitWebSocket()
{
var client = new WebSocketClient();
client.Setup(new TouchSocketConfig()
.SetRemoteIPHost("ws://127.0.0.1:7789/ws")
.ConfigureContainer(a =>
{
a.AddConsoleLogger();
})
.ConfigurePlugins(a =>
{
a.Add<WebSocketClientPlugin>();
//配置心跳
a.UseWebSocketHeartbeat()//使用心跳插件
.SetTick(TimeSpan.FromSeconds(5));//每5秒ping一次。
//配置断线重连
a.UseReconnection(-1, true, 1000);//-1表示一直重连
}));
client.Connect();
}
}
public class WebSocketClientPlugin : PluginBase, IWebSocketReceivedPlugin
{
private readonly ILog m_logger;
public WebSocketClientPlugin(ILog logger)
{
this.m_logger = logger;
}
public async Task OnWebSocketReceived(IWebSocket client, WSDataFrameEventArgs e)
{
switch (e.DataFrame.Opcode)
{
case WSDataType.Cont:
m_logger.Info($"收到中间数据,长度为:{e.DataFrame.PayloadLength}");
return;
case WSDataType.Text:
m_logger.Info(e.DataFrame.ToText());
if (!client.Client.IsClient)
{
client.Send("我已收到");
}
//返回的报警信息 出入库盘点等日志信息
else
{
TextBoxLog.AddLog(e.DataFrame.ToText(), "123", DateTime.Now);
//Growl.Error(e.DataFrame.ToText());
}
return;
case WSDataType.Binary:
if (e.DataFrame.FIN)
{
m_logger.Info($"收到二进制数据,长度为:{e.DataFrame.PayloadLength}");
}
else
{
m_logger.Info($"收到未结束的二进制数据,长度为:{e.DataFrame.PayloadLength}");
}
return;
case WSDataType.Close:
{
m_logger.Info("远程请求断开");
client.Close("断开");
}
return;
case WSDataType.Ping:
client.Pong();
break;
case WSDataType.Pong:
break;
default:
break;
}
await e.InvokeNext();
}
}
}

View File

@ -54,6 +54,7 @@
<PackageReference Include="SqlSugar" Version="5.1.4.149" />
<PackageReference Include="SqlSugar.MySqlConnector" Version="5.1.3.42" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
<PackageReference Include="TouchSocket.Http" Version="2.0.3" />
<PackageReference Include="TouchSocket.SerialPorts" Version="2.0.2" />
</ItemGroup>