提交代码

This commit is contained in:
hehaibing-1996
2024-05-03 11:04:59 +08:00
parent 97888c6978
commit d283924ae1
48 changed files with 802 additions and 509 deletions

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WCS.BLL.Config
{
/// <summary>
/// json配置文件
/// </summary>
public class JsConfig
{
public List<string> ModuleCodePatterns { get; set; }
}
}

View File

@ -11,17 +11,15 @@ namespace WCS.BLL.Config
/// <summary> /// <summary>
/// 本地文件 /// 本地文件
/// </summary> /// </summary>
public class LocalFile public static class LocalFile
{ {
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
/// <summary> /// <summary>
/// 程序运行名称BaseUi.exe /// 程序运行名称BaseUi.exe
/// </summary> /// </summary>
public static readonly string AppName = AppDomain.CurrentDomain.FriendlyName; public static readonly string AppName = AppDomain.CurrentDomain.FriendlyName;
/// <summary> /// <summary>
/// 程序运行目录
/// </summary>
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;
/// <summary>
/// 数据目录 /// 数据目录
/// </summary> /// </summary>
public static readonly string DataDir = Path.Combine(AppDir, "data"); public static readonly string DataDir = Path.Combine(AppDir, "data");
@ -30,76 +28,72 @@ namespace WCS.BLL.Config
/// </summary> /// </summary>
public static readonly string LogDir = Path.Combine(AppDir, "logs"); public static readonly string LogDir = Path.Combine(AppDir, "logs");
/// <summary> /// <summary>
/// 运行主程序
/// </summary>
public static readonly string AppPath = Path.Combine(AppDir, AppDomain.CurrentDomain.FriendlyName);
/// <summary>
/// 配置文件路径 /// 配置文件路径
/// </summary> /// </summary>
public static readonly string ConfigPath = Path.Combine(DataDir, "jsconfig.json"); public static readonly string ConfigPath = Path.Combine(DataDir, "jsconfig.json");
/// <summary> /// <summary>
/// 货架模组编码正则表达式 /// 货架模组编码正则表达式
/// </summary> /// </summary>
public static readonly string ModuleCodePattern = "^[ABCD][0-9]{1,2}-R[0-9]{1,2}C[0-9]{1,2}$"; public static readonly string DefaultModuleCodePattern = "^[ABCD][0-9]{1,2}-R[0-9]{1,2}C[0-9]{1,2}$";
static object lockConfig = new object(); static object lockConfig = new object();
//static JsConfig config; static JsConfig config;
///// <summary> /// <summary>
///// 配置信息 /// 配置信息
///// </summary> /// </summary>
//public static JsConfig Config public static JsConfig Config
//{ {
// get get
// { {
// if (config != null) if (config != null)
// return config; return config;
// else else
// { {
// try try
// { {
// if (File.Exists(ConfigPath)) if (File.Exists(ConfigPath))
// lock (lockConfig) lock (lockConfig)
// config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8)); config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
// else else
// config = null; config = null;
// } }
// catch (Exception) catch (Exception)
// { {
// config = null; config = null;
// } }
// } }
// return config ?? new JsConfig(); return config ?? new JsConfig();
// } }
//} }
///// <summary> /// <summary>
///// 刷新配置信息。将本地的配置信息重新加载到内存中 /// 刷新配置信息。将本地的配置信息重新加载到内存中
///// </summary> /// </summary>
//public static void UpdateConfig() public static void UpdateConfig()
//{ {
// if (File.Exists(ConfigPath)) if (File.Exists(ConfigPath))
// lock (lockConfig) lock (lockConfig)
// config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8)); config = JsonConvert.DeserializeObject<JsConfig>(File.ReadAllText(ConfigPath, Encoding.UTF8));
// else else
// config = null; config = null;
//} }
///// <summary> /// <summary>
///// 保存配置信息。将内存中的配置信息保存到本地 /// 保存配置信息。将内存中的配置信息保存到本地
///// </summary> /// </summary>
//public static void SaveConfig() public static void SaveConfig()
//{ {
// try try
// { {
// lock (lockConfig) lock (lockConfig)
// File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(Config, Formatting.Indented), Encoding.UTF8); File.WriteAllText(ConfigPath, JsonConvert.SerializeObject(Config, Formatting.Indented), Encoding.UTF8);
// } }
// catch (Exception ex) catch (Exception ex)
// { {
// UpdateConfig(); UpdateConfig();
// throw ex; throw ex;
// } }
//} }
} }
} }

View File

@ -116,7 +116,8 @@ namespace WCS.BLL.HardWare
/// 过程中异常 入库过程中异常/出库过程中异常 /// 过程中异常 入库过程中异常/出库过程中异常
/// </summary> /// </summary>
public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>(); public List<ProcessingExceptionType> ProcessingExceptions { get; set; } = new List<ProcessingExceptionType>();
public string? InstoreIpAddress { get; set; } = string.Empty; public string? CurrentCom { get; set; } = string.Empty;
//TODO 退出入库清除
public MatInfoResponse InStoreData { get; set; } public MatInfoResponse InStoreData { get; set; }
@ -137,7 +138,7 @@ namespace WCS.BLL.HardWare
{ {
if (this.CurentMode == Mode.) if (this.CurentMode == Mode.)
{ {
InstoreIpAddress = IPAddress; CurrentCom = IPAddress;
return; return;
} }
//判断当前模式是否为待机模式 //判断当前模式是否为待机模式
@ -181,7 +182,6 @@ namespace WCS.BLL.HardWare
if (deficientTime > 0) if (deficientTime > 0)
Thread.Sleep(deficientTime); Thread.Sleep(deficientTime);
//出现异常的未进入入库模式,有红灯进行指引 //出现异常的未进入入库模式,有红灯进行指引
this.CurentMode = Mode.;
break; break;
} }
@ -195,7 +195,7 @@ namespace WCS.BLL.HardWare
if (notInstoreList.Count > 0) if (notInstoreList.Count > 0)
{ {
CurentMode = Mode.;
foreach (var item in notInstoreList) foreach (var item in notInstoreList)
{ {
ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!"); ExceptionMessages.Add($"模组{item.ModuleCode}未进入入库模式!");
@ -205,7 +205,7 @@ namespace WCS.BLL.HardWare
//警示灯亮起 //警示灯亮起
WarningLight.BlueLight(TcpCleint); WarningLight.BlueLight(TcpCleint);
//绑定当前进入入库PDA/WCS前端的IP //绑定当前进入入库PDA/WCS前端的IP
InstoreIpAddress = IPAddress; CurrentCom = IPAddress;
//返回成功 //返回成功
return; return;
} }
@ -356,7 +356,7 @@ namespace WCS.BLL.HardWare
#region #region
public void ProtocolProcess(byte[] data, int boardId, int lightNumber) public void ProtocolProcess(byte[] data, int boardId, int lightNumber)
{ {
Logs.Write("协议处理中的数据" + BitConverter.ToString(data) + $"板子id{boardId}"); Logs.Write("协议处理4");
//协议处理 判断功能位 //协议处理 判断功能位
switch (data[TcpCleint.PreFixLength + 2]) switch (data[TcpCleint.PreFixLength + 2])
{ {
@ -381,13 +381,18 @@ namespace WCS.BLL.HardWare
case 0x07://正常出库返回信号 case 0x07://正常出库返回信号
OutstoreReturnProcess(data, boardId, lightNumber); OutstoreReturnProcess(data, boardId, lightNumber);
break; break;
case 0x08://出库模式中异常信号
OutstoreExceptionReturnProcess(data, boardId, lightNumber);
break;
case 0x13://复位的返回信号 case 0x13://复位的返回信号
ResetReturnProcess(data, boardId, lightNumber); ResetReturnProcess(data, boardId, lightNumber);
break; break;
default: default:
; ;
break; break;
} }
Logs.Write("协议处理5");
} }
/// <summary> /// <summary>
/// 进入入库模式返回信号处理 /// 进入入库模式返回信号处理
@ -510,7 +515,7 @@ namespace WCS.BLL.HardWare
//库位未配置、返回数据异常 //库位未配置、返回数据异常
else else
{ {
//Logs.Write($"[进入入库模式异常]板Id{boardIds},库位号{index + 1}找不到对应库位!"); Logs.Write($"[进入入库模式异常]板Id{boardId},库位号{index + 1}找不到对应库位!");
} }
} }
else if (dataTemp[2 * index] == '0') else if (dataTemp[2 * index] == '0')
@ -556,22 +561,26 @@ namespace WCS.BLL.HardWare
/// <param name="data"></param> /// <param name="data"></param>
public void InStoreReturnProcess(byte[] data) public void InStoreReturnProcess(byte[] data)
{ {
Logs.Write("协议处理5.1");
var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1]; var boardId = (data[TcpCleint.PreFixLength + 0] << 8) + data[TcpCleint.PreFixLength + 1];
var number = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]); var number = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
var storeInfo = DbHelp.db.Queryable<StoreInfo>().Where(t => t.BoardId == boardId var storeInfo = DbHelp.db.Queryable<StoreInfo>().Where(t => t.BoardId == boardId
&& t.LightNumber == number).First(); && t.LightNumber == number).First();
Logs.Write("协议处理5.2");
if (storeInfo == null) if (storeInfo == null)
{ {
//TO DO 报错 //TODO 报错
return; return;
} }
Logs.Write("协议处理5.3");
var module = this.Modules.Where(t => t.BoardId == boardId) var module = this.Modules.Where(t => t.BoardId == boardId)
.FirstOrDefault(); .FirstOrDefault();
if (module == null) if (module == null)
{ {
//TO DO 报错 //TODO 报错
return; return;
} }
Logs.Write("协议处理5.4");
#region #region
//物料未扫码 //物料未扫码
if (this.InStoreData == null) if (this.InStoreData == null)
@ -580,18 +589,17 @@ namespace WCS.BLL.HardWare
if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn)) if (!string.IsNullOrEmpty(storeInfo.CurrentMatSn))
{ {
module.ComfirmInstore(TcpCleint); module.ComfirmInstore(TcpCleint);
//TO DO Logs.Write($"[{guid}]CAN给了多次正常入库信号防止硬件异常返回了确认入库"); Logs.Write($"CAN给了多次正常入库信号防止硬件异常返回了确认入库");
return; return;
} }
else else
{ {
Logs.Write("协议处理5.5");
var exceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!"; var exceptionMessage = storeInfo.StoreCode + "入库过程中存在物料未扫描上架!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage); WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
Logs.Write("协议处理5.4");
module.ComfirmErrInstore(TcpCleint); module.ComfirmErrInstore(TcpCleint);
WarningLight.WaringLightBlueEnd(TcpCleint); WarningLight.WaringLightAlwaysRed(TcpCleint);
//WaringLightBlueEnd(shelfStatus.ClientIp, shelfStatus.LightId);
//TO DO Logs.Write($"[{guid}]当前物料信息不存在,请取出后重新扫码进行入库!");
return; return;
} }
} }
@ -664,7 +672,6 @@ namespace WCS.BLL.HardWare
this.InStoreData = null; this.InStoreData = null;
//实际入库位置亮灯1S报警灯同时进行亮绿灯并鸣叫一次提示。 //实际入库位置亮灯1S报警灯同时进行亮绿灯并鸣叫一次提示。
Thread.Sleep(20);
Task.Run(() => Task.Run(() =>
{ {
//确认入库硬件入库位置亮灯1秒 //确认入库硬件入库位置亮灯1秒
@ -694,50 +701,56 @@ namespace WCS.BLL.HardWare
/// <param name="lightNumber"></param> /// <param name="lightNumber"></param>
public void InStoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber) public void InStoreExceptionReturnProcess(byte[] data, int boardId, int lightNumber)
{ {
Logs.Write("协议处理5.1");
lightNumber = (int)data[TcpCleint.PreFixLength + 4]; lightNumber = (int)data[TcpCleint.PreFixLength + 4];
var store = DbHelp.db.Queryable<StoreInfo>() var store = DbHelp.db.Queryable<StoreInfo>()
.Where(t => t.BoardId == boardId && t.LightNumber == lightNumber) .Where(t => t.BoardId == boardId && t.LightNumber == lightNumber)
.First(); .First();
Logs.Write("协议处理5.2");
if (store == null) if (store == null)
{ {
//TO DO 库位未找到 //TO DO 库位未找到
return; return;
} }
Logs.Write("协议处理5.3");
//已放物料丢失了 物料多放了 储位恢复正常 //已放物料丢失了 物料多放了 储位恢复正常
switch (data[TcpCleint.PreFixLength + 3]) switch (data[TcpCleint.PreFixLength + 3])
{ {
case 0x00: case 0x00:
{ {
Logs.Write("协议处理5.4");
var exceptionMessage = store.StoreCode + "恢复正常!"; var exceptionMessage = store.StoreCode + "恢复正常!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage); WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
ProcessingExceptions.RemoveAll(t => t.BoardId == boardId); ProcessingExceptions.RemoveAll(t => t.BoardId == boardId);
Logs.Write("协议处理5.5");
} }
break; break;
case 0x01: case 0x01:
{ {
Logs.Write("协议处理5.4");
var exceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!"; var exceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage); WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
ProcessingExceptions.Add(new ProcessingExceptionType() ProcessingExceptions.Add(new ProcessingExceptionType()
{ {
BoardId = boardId, BoardId = boardId,
LightNumber = lightNumber, LightNumber = lightNumber,
ExceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!" ExceptionMessage = store.StoreCode + "入库过程中存在物料未扫描上架!"
}); });
Logs.Write("协议处理5.5");
} }
break; break;
case 0x02: case 0x02:
{ {
Logs.Write("协议处理5.4");
var exceptionMessage = store.StoreCode + "物料被取出!"; var exceptionMessage = store.StoreCode + "物料被取出!";
WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage); WebSoceketManager.TrySendMessage("127.0.0.1", exceptionMessage);
ProcessingExceptions.Add(new ProcessingExceptionType() ProcessingExceptions.Add(new ProcessingExceptionType()
{ {
BoardId = boardId, BoardId = boardId,
LightNumber = lightNumber, LightNumber = lightNumber,
ExceptionMessage = store.StoreCode + "入库过程中物料丢失!" ExceptionMessage = store.StoreCode + "入库过程中物料丢失!"
}); });
Logs.Write("协议处理5.5");
} }
break; break;
default: default:
@ -896,7 +909,7 @@ namespace WCS.BLL.HardWare
if (CurentMode != Mode.) if (CurentMode != Mode.)
{ {
//TO DO 未在出库模式 要报错 //TO DO 未在出库模式 要报错
//Logs.Write($"[{guid}]出库错误:该货架模式不是出库模式或盘点模式{storeInfo.ShelfCode}"); Logs.Write($"出库错误:{ShelfCode}该货架模式不是出库模式或盘点模式!");
return; return;
} }
lightNumber = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]); lightNumber = Convert.ToInt32(data[TcpCleint.PreFixLength + 3]);
@ -927,7 +940,7 @@ namespace WCS.BLL.HardWare
//不是本次出库需要出的物料 //不是本次出库需要出的物料
if (!CurrentOutStoreMatSNs.Contains(storeInfo.CurrentMatSn)) if (!CurrentOutStoreMatSNs.Contains(storeInfo.CurrentMatSn))
{ {
//Logs.Write($"{storeInfo.CurrentMatSN}不是本次需要出库的物料"); Logs.Write($"{storeInfo.CurrentMatSn}不是本次需要出库的物料");
//报警灯报警 //报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint); WarningLight.WaringLightAlwaysRed(TcpCleint);
return; return;
@ -937,7 +950,7 @@ namespace WCS.BLL.HardWare
var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == storeInfo.CurrentMatSn).First(); var inventoryDetail = DbHelp.db.Queryable<InventoryDetail>().Where(t => t.MatSN == storeInfo.CurrentMatSn).First();
if (inventoryDetail == null) if (inventoryDetail == null)
{ {
//Logs.Write($"{storeInfo.CurrentMatSN}库存信息不存在"); Logs.Write($"{storeInfo.CurrentMatSn}库存信息不存在");
//报警灯报警 //报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint); WarningLight.WaringLightAlwaysRed(TcpCleint);
return; return;
@ -949,7 +962,7 @@ namespace WCS.BLL.HardWare
.ToList(); .ToList();
if (orderOrderDetails == null || orderOrderDetails.Count == 0) if (orderOrderDetails == null || orderOrderDetails.Count == 0)
{ {
//Logs.Write($"{storeInfo.CurrentMatSN},OrderDetail出库明细信息不存在"); Logs.Write($"{storeInfo.CurrentMatSn},OrderDetail出库明细信息不存在");
//报警灯报警 //报警灯报警
WarningLight.WaringLightAlwaysRed(TcpCleint); WarningLight.WaringLightAlwaysRed(TcpCleint);
return; return;
@ -1003,27 +1016,24 @@ namespace WCS.BLL.HardWare
//确认本次出库 //确认本次出库
module.ComfirmOutstore(TcpCleint, data[TcpCleint.PreFixLength + 3]); module.ComfirmOutstore(TcpCleint, data[TcpCleint.PreFixLength + 3]);
//shelfStatus.SetCurrentModeTime = DateTime.Now; Task.Run(() =>
//LocalStatic.IsRefreshOrderDetail = true; {
//给信号通知出库页面更新页面的状态
});
//当前柜子是否还存在未出库的 //当前柜子是否还存在未出库的
CurrentOutStoreMatSNs.RemoveAll(t => t == matSN);//删除本次已出的物料SN CurrentOutStoreMatSNs.RemoveAll(t => t == matSN);//删除本次已出的物料SN
var isExsistOut = CurrentOutStoreMatSNs.Any(); var isExsistOut = CurrentOutStoreMatSNs.Any();
//本批次出库已完成
if (!isExsistOut) if (!isExsistOut)
{ {
//Logs.Write($"货架[{shelfStatus.ShelfCode}]:不存在待出物料,退出出库模式");
//退出出库模式 //退出出库模式
GoOutOutstore(); GoOutOutstore();
WarningLight.CloseLight(TcpCleint); WarningLight.CloseLight(TcpCleint);
var currentPickBillNumber = CurrentOutOrder.OrderNumber; var currentPickBillNumber = CurrentOutOrder.OrderNumber;
CurrentOutOrder = null; CurrentOutOrder = null;
Task.Run(() =>
{
//LocalStatic.UpdatOutOrderStatus(currentPickBillNumber);
//给信号通知出库页面更新页面的状态
});
} }
} }
catch (Exception ex) catch (Exception ex)
@ -1052,6 +1062,63 @@ namespace WCS.BLL.HardWare
} }
} }
/// <summary>
/// 出库模式中异常处理
/// </summary>
/// <param name="data"></param>
/// <param name="boardId"></param>
/// <param name="lightNumber"></param>
public void OutstoreExceptionReturnProcess(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;
}
}
public void ResetReturnProcess(byte[] data, int boardId, int lightNumber) public void ResetReturnProcess(byte[] data, int boardId, int lightNumber)
{ {
var module = this.Modules.Where(t => t.BoardId == boardId && t.CurrentMode == Mode.).FirstOrDefault(); var module = this.Modules.Where(t => t.BoardId == boardId && t.CurrentMode == Mode.).FirstOrDefault();
@ -1065,7 +1132,6 @@ namespace WCS.BLL.HardWare
} }
} }
#endregion #endregion
} }

View File

@ -20,10 +20,10 @@ namespace WCS.BLL.Manager
public static List<TCPClient> TCPClients = new List<TCPClient>(); public static List<TCPClient> TCPClients = new List<TCPClient>();
public static void InitTcpClient() public static void InitTcpClient()
{ {
var ips = DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode.Contains("A")).Select(t => t.ClientIp).ToList(); var ips = DbHelp.db.Queryable<ShelfInfo>().Where(t => t.ShelfCode.Contains("C")).Select(t => t.ClientIp).ToList();
foreach (var ip in ips) foreach (var ip in ips)
{ {
var tcpCleint = new TCPClient(ip, "192.168.0.183:20003"); var tcpCleint = new TCPClient(ip, "192.168.9.183:20003");
//var tcpCleint = new TCPClient("192.168.0.183:20002", "192.168.0.183:20003"); //var tcpCleint = new TCPClient("192.168.0.183:20002", "192.168.0.183:20003");
@ -31,6 +31,7 @@ namespace WCS.BLL.Manager
tcpCleint.tcpClient.Received += (client, e) => tcpCleint.tcpClient.Received += (client, e) =>
{ {
var clientIpHost = client.IP + ":" + client.Port; var clientIpHost = client.IP + ":" + client.Port;
var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost); var TcpCleint = TCPClientManager.GetTCPClientByIPHost(clientIpHost);
if (TcpCleint == null) if (TcpCleint == null)
@ -49,8 +50,8 @@ namespace WCS.BLL.Manager
var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix); var isEqual = prefixInData.SequenceEqual(TcpCleint.Prefix);
if (isEqual) if (isEqual)
{ {
Logs.Write("协议处理1");
var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray(); var dataTemp = data.Skip(index).Take(TcpCleint.PreFixLength + TcpCleint.DataLength).ToArray();
Logs.Write($"接受到数据:{BitConverter.ToString(dataTemp)}");
if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度 if (dataTemp.Length < TcpCleint.PreFixLength + TcpCleint.DataLength)//拆包后不满足一条指令的长度
{ {
continue; continue;
@ -60,6 +61,7 @@ namespace WCS.BLL.Manager
var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1]; var boardId = (dataTemp[TcpCleint.PreFixLength + 0] << 8) + dataTemp[TcpCleint.PreFixLength + 1];
var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]); var lightNumber = Convert.ToInt32(dataTemp[TcpCleint.PreFixLength + 3]);
Logs.Write("协议处理2");
//报警灯 //报警灯
if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20) if (dataTemp[TcpCleint.PreFixLength + 2] == 0x20)
{ {
@ -69,9 +71,10 @@ namespace WCS.BLL.Manager
var smartShelf = shelf as SmartShelf; var smartShelf = shelf as SmartShelf;
smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber); smartShelf?.ProtocolProcess(dataTemp, boardId, lightNumber);
} }
//货架类型协议返回 //!= 0x20 货架类型协议返回
else else
{ {
Logs.Write("协议处理3");
var shelf = ShelfManager.Shelves var shelf = ShelfManager.Shelves
.Where(t => t.ClientIp == clientIpHost) .Where(t => t.ClientIp == clientIpHost)
.Where(t => t.ModuleIds.Contains(boardId)) .Where(t => t.ModuleIds.Contains(boardId))
@ -96,6 +99,7 @@ namespace WCS.BLL.Manager
//} //}
} }
} }
Logs.Write("协议处理完毕!");
return EasyTask.CompletedTask; return EasyTask.CompletedTask;
}; };

View File

@ -1,6 +1,5 @@
 
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.DAL.AuthDbModel;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatBaseInfo;

View File

@ -1,6 +1,5 @@
 
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.DAL.AuthDbModel;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.User; using WCS.Model.ApiModel.User;

View File

@ -1,6 +1,5 @@
 
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.DAL.AuthDbModel;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatBaseInfo;

View File

@ -1,6 +1,5 @@
 
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.DAL.AuthDbModel;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.MatInventoryDetail; using WCS.Model.ApiModel.MatInventoryDetail;

View File

@ -15,6 +15,8 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request); public Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request);
public Task<ResponseBase> GetOutOrderListByStatus(GetOutOrderListByStatusRequest request);
public Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request); public Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request);
public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request); public Task<ResponseBase> GetOutOrderMatDetail(GetOutOrderDetailRequest request);

View File

@ -27,7 +27,7 @@ namespace WCS.BLL.Services.IService
public Task<ResponseBase> queryMatInfoInStocktakingOrder(QueryMatInfoInStocktakingOrderRequest request); public Task<ResponseBase> queryMatInfoInStocktakingOrder(QueryMatInfoInStocktakingOrderRequest request);
public Task<ResponseBase> comfirmStocktakingOrder(ComfirmStocktakingOrderRequest request); public Task<ResponseBase> confirmStocktakingOrder(ConfirmStocktakingOrderRequest request);
public Task<ResponseBase> commitStockTakingOrder(GetStockTakingOrderMatDetailRequest request); public Task<ResponseBase> commitStockTakingOrder(GetStockTakingOrderMatDetailRequest request);
} }

View File

@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WCS.DAL.AuthDbModel;
using WCS.Model.ApiModel.User; using WCS.Model.ApiModel.User;
using WCS.Model; using WCS.Model;
using WCS.DAL.DbModels; using WCS.DAL.DbModels;

View File

@ -1,5 +1,4 @@
 using WCS.DAL.Db.AuthDb;
using WCS.DAL.AuthDbModel;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.User; using WCS.Model.ApiModel.User;

View File

@ -11,7 +11,6 @@ using TouchSocket.Core;
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.DAL; using WCS.DAL;
using WCS.DAL.AuthDbModel;
using WCS.DAL.Db; using WCS.DAL.Db;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;

View File

@ -23,7 +23,25 @@ namespace WCS.BLL.Services.Service
public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request) public ResponseBase shelfGoInInStore(ShelfGoInInstoreRequest request)
{ {
//校验货架编码规则 //校验货架编码规则
bool isValid = Regex.IsMatch(request.ModuleCode, LocalFile.ModuleCodePattern); //取配置文件中得货架编码规则
bool isValid = false;
var patterns = LocalFile.Config.ModuleCodePatterns;
if (patterns != null && patterns.Count > 0)
{
foreach (var pattern in patterns)
{
isValid = Regex.IsMatch(request.ModuleCode, pattern);
//匹配到第一个符合条件的货架码 就直接退出循环 认为匹配成功
if (isValid)
break;
}
}
//如果配置文件缺失 使用默认正则进行匹配
else
{
isValid = Regex.IsMatch(request.ModuleCode, LocalFile.DefaultModuleCodePattern);
}
if (!isValid) if (!isValid)
{ {
return new ResponseBase() return new ResponseBase()
@ -50,7 +68,7 @@ namespace WCS.BLL.Services.Service
return new ShelfGoInInstoreResponse() return new ShelfGoInInstoreResponse()
{ {
Code = 200, Code = 200,
Message = "货架进入入库模式成功!", Message = $"货架进入入库模式成功!{string.Join(",", shelf.ExceptionMessages)}",
Data = new ShelfGoInInstoreDto() Data = new ShelfGoInInstoreDto()
{ {
ShelfCode = shelf.ShelfCode, ShelfCode = shelf.ShelfCode,
@ -130,7 +148,7 @@ namespace WCS.BLL.Services.Service
}; };
} }
#region //调用接口或者直接查询数据库 #region //调用接口或者直接查询数据库
//调用接口 //TODO做成配置 调用接口
if (1 != 1) if (1 != 1)
{ {
@ -141,7 +159,7 @@ namespace WCS.BLL.Services.Service
var matInfo = await DbHelp.db.Queryable<MatInfo>().Where(t => t.MatSn == request.MatSn).FirstAsync(); var matInfo = await DbHelp.db.Queryable<MatInfo>().Where(t => t.MatSn == request.MatSn).FirstAsync();
if (matInfo != null) if (matInfo != null)
{ {
//TODO 改成wcs的实体
shelf.InStoreData = new MatInfoResponse() shelf.InStoreData = new MatInfoResponse()
{ {
materialBar = matInfo.MatSn, materialBar = matInfo.MatSn,
@ -198,7 +216,7 @@ namespace WCS.BLL.Services.Service
}; };
} }
//这个时间相当于需要入库扫码后需要等待的时间 //TODO 配置这个时间相当于需要入库扫码后需要等待的时间
var timeOut = 5000; var timeOut = 5000;
var timeSpan = TimeSpan.FromMilliseconds(0); var timeSpan = TimeSpan.FromMilliseconds(0);
var beginTime = DateTime.Now; var beginTime = DateTime.Now;

View File

@ -9,7 +9,6 @@ using TouchSocket.Core;
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.DAL; using WCS.DAL;
using WCS.DAL.AuthDbModel;
using WCS.DAL.Db; using WCS.DAL.Db;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;

View File

@ -10,7 +10,6 @@ using TouchSocket.Core;
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.DAL; using WCS.DAL;
using WCS.DAL.AuthDbModel;
using WCS.DAL.Db; using WCS.DAL.Db;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;

View File

@ -8,8 +8,6 @@ using System.Threading.Tasks;
using TouchSocket.Core; using TouchSocket.Core;
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.DAL;
using WCS.DAL.AuthDbModel;
using WCS.DAL.Db; using WCS.DAL.Db;
using WCS.DAL.DbModels; using WCS.DAL.DbModels;
using WCS.Model; using WCS.Model;

View File

@ -204,6 +204,7 @@ namespace WCS.BLL.Services.Service
} }
public async Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request) public async Task<ResponseBase> GetOutOrderList(GetOutOrderListRequest request)
{ {
//直接查询 //直接查询
@ -236,6 +237,43 @@ namespace WCS.BLL.Services.Service
}; };
} }
public async Task<ResponseBase> GetOutOrderListByStatus(GetOutOrderListByStatusRequest request)
{
if (request.OrderExeStatus == null || request.OrderExeStatus.Count == 0)
{
//不传入状态不显示
return new PageQueryResponse<OutOrder>()
{
Code = 200,
Message = $"success",
Data = new PageQueryResponseData<OutOrder>()
{
Lists = new List<OutOrder>()
}
};
}
//直接查询
var recordsQueryable = DbHelp.db.Queryable<OutOrder>();
var totalCount = await recordsQueryable.CountAsync();
var records = await recordsQueryable
.OrderByDescending(t => t.CreateTime)
//.Take(request.PageSize)
.ToListAsync();
return new PageQueryResponse<OutOrder>()
{
Code = 200,
Message = $"success",
Data = new PageQueryResponseData<OutOrder>()
{
//TotalCount = totalCount,
//MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
//Count = records.Count,
Lists = records.ToList()
}
};
}
public async Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request) public async Task<ResponseBase> GetOutOrderDetail(GetOutOrderDetailRequest request)
{ {
OutOrder outOrder = null; OutOrder outOrder = null;
@ -288,7 +326,6 @@ namespace WCS.BLL.Services.Service
} }
#endregion #endregion
return new ResponseCommon<List<OutOrderDetail>>() return new ResponseCommon<List<OutOrderDetail>>()
{ {
Code = 200, Code = 200,
@ -428,7 +465,7 @@ namespace WCS.BLL.Services.Service
var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode) var matDetails = outOrderMatDetails.Where(t => t.StoreInfo.ShelfCode == shelf.ShelfCode)
.Distinct() .Distinct()
.ToList(); .ToList();
shelf.GoInOutstore(matDetails,order); shelf.GoInOutstore(matDetails, order);
}); });
//返回 //返回

View File

@ -606,7 +606,7 @@ namespace WCS.BLL.Services.Service
} }
public async Task<ResponseBase> comfirmStocktakingOrder(ComfirmStocktakingOrderRequest request) public async Task<ResponseBase> confirmStocktakingOrder(ConfirmStocktakingOrderRequest request)
{ {
//获取盘点物料明细 //获取盘点物料明细
var stockTakingMatDetail =await DbHelp.db.Queryable<StockTakingOrderMatDetail>() var stockTakingMatDetail =await DbHelp.db.Queryable<StockTakingOrderMatDetail>()

View File

@ -8,7 +8,6 @@ using TouchSocket.Core;
using WCS.BLL.DbModels; using WCS.BLL.DbModels;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.DAL; using WCS.DAL;
using WCS.DAL.AuthDbModel;
using WCS.DAL.Db; using WCS.DAL.Db;
using WCS.DAL.DbModels; using WCS.DAL.DbModels;
using WCS.Model; using WCS.Model;

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
using TouchSocket.Core; using TouchSocket.Core;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.DAL; using WCS.DAL;
using WCS.DAL.AuthDbModel; using WCS.DAL.Db.AuthDb;
using WCS.Model; using WCS.Model;
using WCS.Model.ApiModel; using WCS.Model.ApiModel;
using WCS.Model.ApiModel.User; using WCS.Model.ApiModel.User;

View File

@ -77,6 +77,7 @@ namespace WCS.BLL
{ {
var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray(); var data = e.ByteBlock.Buffer.Take((int)e.ByteBlock.Length).ToArray();
//e.ByteBlock.Clear(); //e.ByteBlock.Clear();
Logs.Write($"校验发送接收,收到数据" + BitConverter.ToString(data));
var len = data.Length; var len = data.Length;
for (int index = 0; index < data.Length - PreFixLength; index++) for (int index = 0; index < data.Length - PreFixLength; index++)
{ {
@ -103,7 +104,9 @@ namespace WCS.BLL
index += (PreFixLength + DataLength - 1);//每次循环index会+1 所以这里-1 index += (PreFixLength + DataLength - 1);//每次循环index会+1 所以这里-1
} }
} }
Logs.Write($"校验发送接收处理完毕" + BitConverter.ToString(data));
return null; return null;
}; };
tcpClient.Connected += (client, e) => tcpClient.Connected += (client, e) =>
@ -125,15 +128,23 @@ namespace WCS.BLL
{ {
try try
{ {
//TO DO如果指令未回应n次 则取消重发 //TODO如果指令未回应n次 则取消重发
Console.WriteLine(Thread.CurrentThread.ManagedThreadId); Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
await Task.Delay(3000); await Task.Delay(100);
if (MessageList.Count > 0) if (MessageList.Count > 0)
{ {
var failedMessage = MessageList.Where(t => t.Value.SendTimes >= 3).ToList();
foreach (var message in failedMessage)
{
Logs.Write(BitConverter.ToString(message.Value.Message) +
"指令未响应");
}
MessageList.RemoveWhen(t => t.Value.SendTimes >= 3);
Console.WriteLine(Thread.CurrentThread.ManagedThreadId); Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
foreach (var item in MessageList) foreach (var item in MessageList)
{ {
if (item.Value.LastSendTime < DateTime.Now.AddSeconds(3)) if (item.Value.LastSendTime < DateTime.Now.AddSeconds(-1))
{ {
tcpClient.Send(item.Value.Message); tcpClient.Send(item.Value.Message);
item.Value.SendTimes++; item.Value.SendTimes++;
@ -141,6 +152,7 @@ namespace WCS.BLL
await Task.Delay(10); await Task.Delay(10);
} }
} }
} }
} }
catch catch
@ -170,6 +182,7 @@ namespace WCS.BLL
lock (sendLockObject) lock (sendLockObject)
{ {
tcpClient.Send(message); tcpClient.Send(message);
//TODO MessageList.AddOrUpdate(new Mes)
//发送自带10ms间隔 //发送自带10ms间隔
Thread.Sleep(10); Thread.Sleep(10);
} }
@ -225,6 +238,7 @@ namespace WCS.BLL
/// </summary> /// </summary>
public byte[] Message { get; set; } public byte[] Message { get; set; }
public bool IsWating { get; set; }
/// <summary> /// <summary>
/// 发送次数 /// 发送次数
/// </summary> /// </summary>

View File

@ -5,7 +5,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WCS.DAL.AuthDbModel; using WCS.DAL.Db.AuthDb;
namespace WCS.DAL namespace WCS.DAL
{ {
@ -14,9 +14,11 @@ namespace WCS.DAL
/// </summary> /// </summary>
public static class AuthDbHelp public static class AuthDbHelp
{ {
public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig() public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
{ {
ConnectionString = $"Data Source={LocalFile.AuthDbPath};", ConnectionString = $"Data Source={DbPath.AuthDbPath};",
DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite.Core]; DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite.Core];
IsAutoCloseConnection = true IsAutoCloseConnection = true
}, db => }, db =>

View File

@ -5,7 +5,7 @@ using System.Text;
using WCS.DAL.Db; using WCS.DAL.Db;
using WCS.Model; using WCS.Model;
namespace WCS.DAL.AuthDbModel namespace WCS.DAL.Db.AuthDb
{ {
/// <summary> /// <summary>
/// 用户 /// 用户
@ -32,7 +32,7 @@ namespace WCS.DAL.AuthDbModel
/// 角色名称 /// 角色名称
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public List<string> RoleNames { get => (RoleIds == null || !RoleIds.Any()) ? new List<string>() : AuthDbHelp.db.Queryable<RoleBase>().Where(o => RoleIds.Contains(o.Id)).Select(o => o.Name).ToList(); } public List<string> RoleNames { get => RoleIds == null || !RoleIds.Any() ? new List<string>() : AuthDbHelp.db.Queryable<RoleBase>().Where(o => RoleIds.Contains(o.Id)).Select(o => o.Name).ToList(); }
/// <summary> /// <summary>
/// 是否最大权限 /// 是否最大权限
/// </summary> /// </summary>
@ -70,7 +70,7 @@ namespace WCS.DAL.AuthDbModel
/// 认证模块名称 /// 认证模块名称
/// </summary> /// </summary>
[SugarColumn(IsIgnore = true)] [SugarColumn(IsIgnore = true)]
public List<string> AuthNames { get => (Auths == null || !Auths.Any()) ? new List<string>() : EnumHelps.GetEnumDescriptionList(typeof(AuthEnum), true).Where(o => Auths.Contains(o.Item1)).Select(o => o.Item3).ToList(); } public List<string> AuthNames { get => Auths == null || !Auths.Any() ? new List<string>() : EnumHelps.GetEnumDescriptionList(typeof(AuthEnum), true).Where(o => Auths.Contains(o.Item1)).Select(o => o.Item3).ToList(); }
/// <summary> /// <summary>
/// 是否最大权限 /// 是否最大权限
/// </summary> /// </summary>

View File

@ -14,7 +14,7 @@ namespace WCS.DAL.Db
/// </summary> /// </summary>
public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig() public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
{ {
ConnectionString = $"Data Source={LocalFile.DataDbPath};", ConnectionString = $"Data Source={DbPath.DataDbPath};",
DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite]; DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite];
IsAutoCloseConnection = true IsAutoCloseConnection = true
}, db => }, db =>
@ -31,7 +31,7 @@ namespace WCS.DAL.Db
/// </summary> /// </summary>
public static SqlSugarScope dbLog = new SqlSugarScope(new ConnectionConfig() public static SqlSugarScope dbLog = new SqlSugarScope(new ConnectionConfig()
{ {
ConnectionString = $"Data Source={LocalFile.LogDbPath};", ConnectionString = $"Data Source={DbPath.LogDbPath};",
DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite]; DbType = DbType.Sqlite,//[Sqlite]安装[System.Data.SQLite];
IsAutoCloseConnection = true IsAutoCloseConnection = true
}, db => }, db =>

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace WCS.DAL namespace WCS.DAL
{ {
public static class LocalFile public static class DbPath
{ {
public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory; public static readonly string AppDir = AppDomain.CurrentDomain.BaseDirectory;

View File

@ -27,7 +27,15 @@ namespace WCS.Model.ApiModel.MatInventoryDetail
public DateTime InstoreTime { get; set; } = DateTime.Now; public DateTime InstoreTime { get; set; } = DateTime.Now;
public string InstoreUser { get; set; } public string InstoreUser { get; set; }
public bool IsLocked { get; set; } = false; public bool IsLocked { get; set; }
public string IsLockedStr
{
get
{
return IsLocked ? "是" : "否";
}
}
public int RowNumber { get; set; } public int RowNumber { get; set; }
public bool IsSelected { get; set; } public bool IsSelected { get; set; }
} }

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WCS.Model.ApiModel.OutStore;
namespace WCS.Model
{
public class GetOutOrderListByStatusRequest : PageQueryRequestBase
{
public List<OutOrderExeStatus> OrderExeStatus { get; set; }
}
}

View File

@ -40,9 +40,17 @@ namespace WCS.Model.ApiModel.OutStore
public string? MatCustomer { get; set; } public string? MatCustomer { get; set; }
#endregion #endregion
public bool IsSended { get; set; } = false; public bool IsSended { get; set; }
public DateTime CreateTime { get; set; } public string IsSendedStr
{
get
{
return IsSended ? "是" : "否";
}
}
public DateTime CreateTime { get; set; }
public string CreateUser { get; set; } public string CreateUser { get; set; }

View File

@ -4,7 +4,7 @@ using System.Text;
namespace WCS.Model.ApiModel.Stocktaking namespace WCS.Model.ApiModel.Stocktaking
{ {
public class ComfirmStocktakingOrderRequest public class ConfirmStocktakingOrderRequest
{ {
public int Id { get; set; } public int Id { get; set; }
public string StocktakingOrderNumber { get; set; } public string StocktakingOrderNumber { get; set; }

View File

@ -90,6 +90,29 @@ namespace WebApi.Controllers
} }
} }
/// <summary>
/// <20><>״̬<D7B4><CCAC>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><E2B5A5>
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("getOutOrderListByStatus")]
[HttpPost(Name = "getOutOrderListByStatus")]
public async Task<ResponseBase> getOutOrderListByStatus(GetOutOrderListByStatusRequest request)
{
try
{
return await _outstoreService.GetOutOrderListByStatus(request);
}
catch (Exception ex)
{
return new ResponseBase()
{
Code = 300,
Message = "<22><>ѯʧ<D1AF>ܣ<EFBFBD>" + ex.Message,
};
}
}
/// <summary> /// <summary>
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD>ϸ /// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD><EFBFBD><EFBFBD>ϸ
/// </summary> /// </summary>

View File

@ -71,11 +71,11 @@ namespace WCS.WebApi.Controllers
return await _stockTakingService.queryMatInfoInStocktakingOrder(request); return await _stockTakingService.queryMatInfoInStocktakingOrder(request);
} }
[Route("comfirmStocktakingOrder")] [Route("confirmStocktakingOrder")]
[HttpPost(Name = "comfirmStocktakingOrder")] [HttpPost(Name = "confirmStocktakingOrder")]
public async Task<ResponseBase> comfirmStocktakingOrder(ComfirmStocktakingOrderRequest request) public async Task<ResponseBase> confirmStocktakingOrder(ConfirmStocktakingOrderRequest request)
{ {
return await _stockTakingService.comfirmStocktakingOrder(request); return await _stockTakingService.confirmStocktakingOrder(request);
} }
[Route("commitStocktakingOrder")] [Route("commitStocktakingOrder")]

View File

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Server.Kestrel.Core; using Microsoft.AspNetCore.Server.Kestrel.Core;
using System.Configuration;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Net.Sockets; using System.Net.Sockets;
using System.Text; using System.Text;
using WCS.BLL.Config;
using WCS.BLL.Manager; using WCS.BLL.Manager;
using WCS.BLL.Services.IService; using WCS.BLL.Services.IService;
using WCS.BLL.Services.Service; using WCS.BLL.Services.Service;
@ -24,6 +26,8 @@ namespace WebApi
DbInit.InitDb(); DbInit.InitDb();
LocalFile.SaveConfig();
ShelfManager.InitShelves(); ShelfManager.InitShelves();
TCPClientManager.InitTcpClient(); TCPClientManager.InitTcpClient();

View File

@ -278,11 +278,11 @@ namespace 货架标准上位机.Api
try try
{ {
if (isSaveLog) if (isSaveLog)
Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}"); Logs.Write($"【{guid}】开始请求调用接口 url{url} 请求方式:{httpMethod} 数据:{data}",LogsType.Api);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = httpMethod; request.Method = httpMethod;
request.ContentType = "application/json"; request.ContentType = "application/json";
request.Timeout = 100000; request.Timeout = 10000;
if (!string.IsNullOrEmpty(data)) if (!string.IsNullOrEmpty(data))
{ {
@ -303,7 +303,7 @@ namespace 货架标准上位机.Api
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding)); StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string retString = reader.ReadToEnd(); string retString = reader.ReadToEnd();
if (isSaveLog) if (isSaveLog)
Logs.Write($"【{guid}】请求调用接口结束 返回数据为{retString}"); Logs.Write($"【{guid}】请求调用接口结束 返回数据为{retString}", LogsType.Api);
return JsonConvert.DeserializeObject<T>(retString); return JsonConvert.DeserializeObject<T>(retString);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -40,10 +40,6 @@ namespace 货架标准上位机
Scanners.Add(Scanner); Scanners.Add(Scanner);
return EasyTask.CompletedTask; return EasyTask.CompletedTask;
}; };
client.Received = async (c, e) =>
{
;
};
client.Setup(new TouchSocket.Core.TouchSocketConfig() client.Setup(new TouchSocket.Core.TouchSocketConfig()
.SetSerialPortOption(new SerialPortOption() .SetSerialPortOption(new SerialPortOption()
{ {

View File

@ -35,7 +35,11 @@ namespace 货架标准上位机
/// <summary> /// <summary>
/// 扫码枪 /// 扫码枪
/// </summary> /// </summary>
Scanner Scanner,
/// <summary>
/// Api接口调用
/// </summary>
Api
} }
/// <summary> /// <summary>

View File

@ -90,7 +90,7 @@ namespace 货架标准上位机.ViewModel
{ {
ModuleCodeProcess(scanner); ModuleCodeProcess(scanner);
} }
//TO DO 增加正则表达式进行判断是否扫到的是物料码 //TODO 增加正则表达式进行判断是否扫到的是物料码
else else
{ {
MatSnProcess(scanner); MatSnProcess(scanner);
@ -168,6 +168,14 @@ namespace 货架标准上位机.ViewModel
scanner.IsInstoreMode = true; scanner.IsInstoreMode = true;
scanner.ShelfCode = Result.Data.ShelfCode; scanner.ShelfCode = Result.Data.ShelfCode;
scanner.ModulesStr = Result.Data.ModulesStr; scanner.ModulesStr = Result.Data.ModulesStr;
//TODO 清除其他扫码枪的占用
var sacnners = ScannerManager.Scanners
.Where(t => ShelfCode == Result.Data.ShelfCode)
.ToList();
foreach (var item in sacnners)
{
item.ShelfCode = string.Empty;
}
} }
else if (Result != null && !string.IsNullOrEmpty(Result.Message)) else if (Result != null && !string.IsNullOrEmpty(Result.Message))
{ {

View File

@ -24,6 +24,8 @@ using WCS.Model.ApiModel.InterfaceRecord;
using HandyControl.Collections; using HandyControl.Collections;
using WCS.Model.ApiModel.MatBaseInfo; using WCS.Model.ApiModel.MatBaseInfo;
using WCS.Model.ApiModel.MatInventoryDetail; using WCS.Model.ApiModel.MatInventoryDetail;
using HandyControl.Tools.Extension;
using WCS.Model.ApiModel.Stocktaking;
namespace .ViewModel namespace .ViewModel
{ {
@ -39,7 +41,6 @@ namespace 货架标准上位机.ViewModel
// }) // })
// .Distinct() // .Distinct()
// .ToList(); // .ToList();
} }
public void InitMatCode() public void InitMatCode()
@ -270,6 +271,192 @@ namespace 货架标准上位机.ViewModel
Growl.Error("导出失败:" + ex.Message); Growl.Error("导出失败:" + ex.Message);
} }
} }
public ICommand BtnGenerateOutstoreCommand { get => new DelegateCommand(BtnGenerateOutstore); }
public async void BtnGenerateOutstore()
{
try
{
#region SN
try
{
var body = new GetMatInventoryDetailRequest()
{
MatName = MatName,
MatSN = MatSN,
MatBatch = MatBatch,
MatCode = MatCode,
StoreCode = StoreCode,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
PageNumber = CurrentPage,
PageSize = 10000,
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<MatInventoryDetailModel>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/getMatInventoryDetail", body, "POST");
if (Result != null && Result.Data != null && Result.Data.Lists != null)
{
//获取搜索条件返回数据中未锁定的物料
var unLockedMatSns = Result.Data.Lists.Where(t => t.IsLocked == false)
.Select(t => t.MatSN)
.ToList();
if (unLockedMatSns.Count == 0)
{
HandyControl.Controls.MessageBox.Show("根据您的搜索条件不存在可以出库的物料(或物料已全部被锁定)!");
return;
}
//提示 是否生成出库单
var result = HandyControl.Controls.MessageBox.Show($"根据您的搜索条件,共有{unLockedMatSns.Count}盘未锁定的物料,是否生成出库单并锁定物料?", "提示", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
var dia = Dialog.Show(new TextDialog());
try
{
#region
var body1 = new SysOutOrderByMatSnRequest()
{
OrderType = "出库",
OrderSource = "WCS前端-库存数据出库",
SnList = unLockedMatSns,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser
};
var Result1 = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatSn", body1, "POST");
if (Result1 != null && Result1.Code == 200)
{
Growl.Success(Result1.Message);
}
else if (Result1 != null)
{
Growl.Warning(Result1.Message);
}
#endregion
}
catch (Exception ex)
{
Growl.Error("生成出库单据失败:" + ex.Message);
}
finally
{
App.Current.Dispatcher.Invoke(() =>
{
dia.Close();
dia.Collapse();
});
}
}
}
}
catch (Exception ex)
{
Growl.Error("获取数据失败:" + ex.Message);
}
finally
{
}
#endregion
}
catch (Exception ex)
{
Growl.Error("导出失败:" + ex.Message);
}
}
public ICommand BtnGenerateStocktakingCommand { get => new DelegateCommand(BtnGenerateStocktaking); }
public void BtnGenerateStocktaking()
{
try
{
#region SN
try
{
var body = new GetMatInventoryDetailRequest()
{
MatName = MatName,
MatSN = MatSN,
MatBatch = MatBatch,
MatCode = MatCode,
StoreCode = StoreCode,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
PageNumber = CurrentPage,
PageSize = 10000,
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<MatInventoryDetailModel>>(LocalFile.Config.ApiIpHost + "matInventoryDetail/getMatInventoryDetail", body, "POST");
if (Result != null && Result.Data != null && Result.Data.Lists != null)
{
//获取搜索条件返回数据中未锁定的物料
var unLockedMatSns = Result.Data.Lists.Where(t => t.IsLocked == false)
.Select(t => t.MatSN)
.ToList();
if (unLockedMatSns.Count == 0)
{
HandyControl.Controls.MessageBox.Show("根据您的搜索条件不存在可以盘点的物料!");
return;
}
//提示 是否生成出库单
var result = HandyControl.Controls.MessageBox.Show($"根据您的搜索条件,共有{unLockedMatSns.Count}盘未锁定的物料,是否生成盘点单?", "提示", MessageBoxButton.OKCancel);
if (result == MessageBoxResult.OK)
{
var dia = Dialog.Show(new TextDialog());
try
{
#region
var body1 = new SysStockTakingOrderRequest()
{
StocktakingOrderType = "snList",
StocktakingOrderSource = "WCS前端-库存数据",
List = unLockedMatSns,
DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser
};
var Result1 = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "stockTaking/sysStockTakingOrder", body1, "POST");
if (Result1 != null && Result1.Code == 200)
{
Growl.Success(Result1.Message);
}
else if (Result1 != null)
{
Growl.Warning(Result1.Message);
}
#endregion
}
catch (Exception ex)
{
Growl.Error("生成盘点单据失败:" + ex.Message);
}
finally
{
App.Current.Dispatcher.Invoke(() =>
{
dia.Close();
dia.Collapse();
});
}
}
}
}
catch (Exception ex)
{
Growl.Error("获取数据失败:" + ex.Message);
}
finally
{
}
#endregion
}
catch (Exception ex)
{
Growl.Error("导出失败:" + ex.Message);
}
}
#endregion #endregion
#region PageOperation #region PageOperation

View File

@ -122,28 +122,28 @@ namespace 货架标准上位机.ViewModels
}).ToList(), }).ToList(),
DeviceType = LocalFile.Config.DeviceType, DeviceType = LocalFile.Config.DeviceType,
UserName = LocalStatic.CurrentUser UserName = LocalStatic.CurrentUser
}; };
var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST"); var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outstore/sysOutOrderByMatCode", body, "POST");
if (Result != null && Result.Code == 200) if (Result != null && Result.Code == 200)
{ {
Growl.Success(Result.Message); Growl.Success(Result.Message);
OnRequestClose(); OnRequestClose();
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
} }
else if (Result != null)
{
Growl.Warning(Result.Message);
}
}
catch (Exception ex) catch (Exception ex)
{ {
Growl.Error("加载数据失败:" + ex.Message); Growl.Error("加载数据失败:" + ex.Message);
} }
finally finally
{ {
}
#endregion
} }
#endregion
} }
#endregion
} }
#endregion
}
} }

View File

@ -123,14 +123,16 @@ namespace 货架标准上位机.ViewModels
public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); } public ICommand BtnResetCommand { get => new DelegateCommand(BtnReset); }
public void BtnReset() public void BtnReset()
{ {
OrderNumber = string.Empty;
OrderType = string.Empty;
OrderSource = string.Empty;
} }
public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); } //public ICommand BtnDeleteCommand { get => new DelegateCommand(BtnDelete); }
public void BtnDelete() //public void BtnDelete()
{ //{
} //}
public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); } public ICommand BtnOrderDetailCommand { get => new DelegateCommand(BtnOrderDetail); }
public void BtnOrderDetail() public void BtnOrderDetail()

View File

@ -4,18 +4,25 @@ using MiniExcelLibs;
using Ping9719.WpfEx.Mvvm; using Ping9719.WpfEx.Mvvm;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data.SqlClient; using System.Data.SqlClient;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Net; using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using TouchSocket.Core; using TouchSocket.Core;
using WCS.Model;
using WCS.Model.ApiModel.OutStore;
using WCS.Model.ApiModel.Stocktaking;
using .Api;
using .ViewModel; using .ViewModel;
namespace .ViewModel namespace .ViewModel
@ -44,169 +51,78 @@ namespace 货架标准上位机.ViewModel
// } // }
// } // }
//}); //});
}
public System.Windows.Controls.TextBox textBox { get; set; } RefreshOutOrderList();
}
#region Property #region Property
private string number; private OutOrderModel selectedOutOrder;
public string Number public OutOrderModel SelectedOutOrder
{ {
get { return number; } get { return selectedOutOrder; }
set set
{ {
SetProperty(ref number, value); SetProperty(ref selectedOutOrder, value);
if (selectedOutOrder != null)
{
SelectedOutOrderNumber = selectedOutOrder.OrderNumber;
RefreshDataGridItemSource();
}
else
{
DataGridItemSource?.Clear();
}
} }
} }
private bool isOrderOut; private string selectedOutOrderNumber;
public bool IsOrderOut public string SelectedOutOrderNumber
{ {
get { return isOrderOut; } get => selectedOutOrderNumber;
set set
{ {
SetProperty(ref isOrderOut, value); SetProperty(ref selectedOutOrderNumber, value);
//LocalStatic.IsOrderOut = value;
} }
} }
private string matCode1;
public string MatCode1 private ObservableCollection<OutOrderModel> outOrderList;
public ObservableCollection<OutOrderModel> OutOrderList
{ {
get { return matCode1; } get => outOrderList;
set set
{ {
SetProperty(ref matCode1, value); SetProperty(ref outOrderList, value);
} }
} }
private int matQty1; private ObservableCollection<OutOrderMatDetailModel> dataGridItemSource;
public int MatQty1 public ObservableCollection<OutOrderMatDetailModel> DataGridItemSource
{ {
get { return matQty1; } get { return dataGridItemSource; }
set set
{ {
SetProperty(ref matQty1, value); SetProperty(ref dataGridItemSource, value);
RefreshCount();
} }
} }
private string order_prod_number; //单据总盘数
public string Order_prod_number private int totalPan;
public int TotalPan
{ {
get { return order_prod_number; } get => totalPan; set
set
{ {
SetProperty(ref order_prod_number, value); SetProperty(ref totalPan, value);
} }
} }
private string material_code; private int sendedPan;
public string Material_code public int SendedPan
{ {
get { return material_code; } get => sendedPan; set
set
{ {
SetProperty(ref material_code, value); SetProperty(ref sendedPan, value);
}
}
private string material_name;
public string Material_name
{
get { return material_name; }
set
{
SetProperty(ref material_name, value);
}
}
private string material_spec;
public string Material_spec
{
get { return material_spec; }
set
{
SetProperty(ref material_spec, value);
}
}
private string matCode;
public string MatCode
{
get { return matCode; }
set
{
SetProperty(ref matCode, value);
}
}
private string matName;
public string MatName
{
get { return matName; }
set
{
SetProperty(ref matName, value);
}
}
private string matCode3;
public string MatCode3
{
get { return matCode3; }
set
{
SetProperty(ref matCode3, value);
}
}
private string matName3;
public string MatName3
{
get { return matName3; }
set
{
SetProperty(ref matName3, value);
}
}
private string matSpec3;
public string MatSpec3
{
get { return matSpec3; }
set
{
SetProperty(ref matSpec3, value);
}
}
private string matBatch3;
public string MatBatch3
{
get { return matBatch3; }
set
{
SetProperty(ref matBatch3, value);
}
}
private string selectedPickBillNumber;
public string SelectedPickBillNumber
{
get { return selectedPickBillNumber; }
set
{
SetProperty(ref selectedPickBillNumber, value);
}
}
private string orderProdNumber;
public string OrderProdNumber
{
get { return orderProdNumber; }
set
{
SetProperty(ref orderProdNumber, value);
} }
} }
@ -220,88 +136,17 @@ namespace 货架标准上位机.ViewModel
} }
} }
private List<object> dataGridItemSource;
public List<object> DataGridItemSource
{
get { return dataGridItemSource; }
set
{
SetProperty(ref dataGridItemSource, value);
RefreshCount();
}
}
//领料单号列表
private List<string> pickBillNumberList;
public List<string> PickBillNumberList
{
get { return pickBillNumberList; }
set
{
SetProperty(ref pickBillNumberList, value);
}
}
public void RefreshCount() public void RefreshCount()
{ {
Task.Run(() => Task.Run(() =>
{ {
SendedPan = dataGridItemSource.Where(t => t.IsSended).Count();
TotalPan = dataGridItemSource.Count(); TotalPan = dataGridItemSource.Count();
//SendedPan = dataGridItemSource.Where(t => t.IsSend == true).Count();
//UnSendedPan = dataGridItemSource.Where(t => t.IsSend == false).Count();
}); });
} }
#endregion #endregion
#region Command #region Command
//public ICommand BtnSearchCommand { get => new DelegateCommand(BtnSearch); }
//public void BtnSearch()
//{
// if (string.IsNullOrEmpty(MatCode1))
// {
// Growl.Warning("请输入料号进行筛选!");
// return;
// }
// else if (MatQty1 == 0)
// {
// Growl.Warning("请输入需要的数量!");
// return;
// }
// var inventoryDetails = DbHelp.db.Queryable<InventoryDetail>();
// if (!string.IsNullOrEmpty(MatCode1))
// {
// inventoryDetails = inventoryDetails
// .Where(t => t.MatCode.Contains(MatCode1))
// .Includes(t => t.StoreInfo)
// .OrderBy(t => t.MatQty);
// }
// else
// {
// }
// var inventorys = inventoryDetails.ToList();
// int totalMatQty = 0;
// //List<InventoryDetail> dataSourceTemp = new List<InventoryDetail>();
// foreach (var item in inventorys)
// {
// if (totalMatQty < MatQty1)
// {
// totalMatQty += item.MatQty;
// item.IsSelected = true;
// }
// else
// {
// break;
// }
// }
// DataGridItemSource = inventorys;
//}
public ICommand BtnOutOrderCommand { get => new DelegateCommand(BtnOutOrder); } public ICommand BtnOutOrderCommand { get => new DelegateCommand(BtnOutOrder); }
public void BtnOutOrder() public void BtnOutOrder()
{ {
@ -310,69 +155,164 @@ namespace 货架标准上位机.ViewModel
window.ShowDialog(); window.ShowDialog();
} }
//public ICommand BtnTempOutCommand { get => new DelegateCommand(BtnTempOut); }
//public void BtnTempOut()
//{
// var window = new OutInventoryDocumentDetailView();
// window.ShowDialog();
// if (window.DialogResult == true)
// {
// DataGridItemSource = window.DataGridItemSource;
// }
//}
public ICommand BtnReset3Command { get => new DelegateCommand(BtnReset3); }
public void BtnReset3()
{
MatCode3 = string.Empty;
MatName3 = string.Empty;
MatSpec3 = string.Empty;
MatBatch3 = string.Empty;
}
public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); } public ICommand BtnStartCommand { get => new DelegateCommand(BtnStart); }
public void BtnStart() public void BtnStart()
{ {
return; try
{
//判断是否选择单据
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)
{
Growl.Warning("已成功开始入库!");
}
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 ICommand BtnPauseCommand { get => new DelegateCommand(BtnPause); }
public void BtnPause() public void BtnPause()
{ {
try
{
//判断是否选择单据
if (SelectedOutOrder == null)
{
Growl.Warning("未选择单据!");
}
} #region
#endregion var body = new GetOutOrderDetailRequest()
{
OrderId = selectedOutOrder.Id,
#region PageOperation OrderNumber = selectedOutOrder.OrderNumber,
private int totalPan; UserName = LocalStatic.CurrentUser,
public int TotalPan DeviceType = LocalFile.Config.DeviceType,
{ };
get { return totalPan; } var Result = ApiHelp.GetDataFromHttp<ResponseCommon>(LocalFile.Config.ApiIpHost + "outStore/goOutOutstore", body, "POST");
set { SetProperty(ref totalPan, value); } if (Result != null && Result.Code == 200)
{
Growl.Warning("已成功结束入库!");
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
#endregion
}
catch (Exception ex)
{
Growl.Error("出现异常:" + ex.Message);
}
finally
{
}
} }
private int sendedPan; public void RefreshOutOrderList()
public int SendedPan
{ {
get { return sendedPan; } #region
set { SetProperty(ref sendedPan, value); } try
{
var body = new GetOutOrderListByStatusRequest()
{
OrderExeStatus = new List<OutOrderExeStatus>() { OutOrderExeStatus., OutOrderExeStatus. }
};
var Result = ApiHelp.GetDataFromHttp<PageQueryResponse<OutOrderModel>>(LocalFile.Config.ApiIpHost + "outstore/getOutOrderListByStatus", body, "POST");
if (Result != null && Result.Code == 200)
{
OutOrderList = new ObservableCollection<OutOrderModel>(Result.Data.Lists);
}
else if (Result != null && !string.IsNullOrEmpty(Result.Message))
{
Growl.Warning(Result.Message);
}
}
catch (Exception ex)
{
Growl.Warning(ex.Message);
}
#endregion
} }
private int unSendedPan; public void RefreshDataGridItemSource()
public int UnSendedPan
{ {
get { return unSendedPan; } if (SelectedOutOrder == null)
set { SetProperty(ref unSendedPan, value); } {
} //选择的单据为空无法进行查询
#endregion return;
}
#region
Task.Run(() =>
{
var body = new GetOutOrderDetailRequest()
{
OrderId = selectedOutOrder.Id,
OrderNumber = selectedOutOrder.OrderNumber,
UserName = LocalStatic.CurrentUser,
DeviceType = LocalFile.Config.DeviceType,
#region private method };
public bool GrowlCallBack(bool aaa) var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<OutOrderMatDetailModel>>>(LocalFile.Config.ApiIpHost + "outStore/getOutOrderMatDetail", body, "POST");
{ if (Result != null && Result.Code == 200)
return true; {
if (Result.Data.Count > 0)
{
DataGridItemSource = new ObservableCollection<OutOrderMatDetailModel>(Result.Data);
}
else
{
App.Current.Dispatcher.Invoke(() =>
{
DataGridItemSource?.Clear();
});
Growl.Warning("该单据未查询到发料明细!");
}
}
else if (Result != null)
{
Growl.Warning(Result.Message);
}
else
{
Growl.Warning("调用接口失败!");
}
});
#endregion
} }
#endregion #endregion
} }

View File

@ -108,8 +108,21 @@
Content="&#xe866; 导 出" FontFamily="{StaticResource IconFont}" Content="&#xe866; 导 出" FontFamily="{StaticResource IconFont}"
Style="{StaticResource ButtonWarning}" Background="DarkOrange"> Style="{StaticResource ButtonWarning}" Background="DarkOrange">
</Button> </Button>
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnGenerateOutstoreCommand}"
Content="&#xe67d; 搜索结果出库" FontFamily="{StaticResource IconFont}"
Style="{StaticResource ButtonWarning}" Background="IndianRed">
</Button>
<Button MinHeight="40" FontSize="18" Margin="5" Command="{Binding BtnGenerateStocktakingCommand}"
Content="&#xe65f; 搜索结果盘点" FontFamily="{StaticResource IconFont}"
Style="{StaticResource ButtonWarning}" Background="IndianRed">
</Button>
</StackPanel> </StackPanel>
<DataGrid Grid.Row="1" <DataGrid Grid.Row="1"
SelectedCellsChanged="DataGrid_SelectedCellsChanged" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
ItemsSource="{Binding DataGridItemSource}" ItemsSource="{Binding DataGridItemSource}"
@ -123,9 +136,7 @@
<DataGridTextColumn MaxWidth="100" Header="批次" Binding="{Binding MatBatch}"></DataGridTextColumn> <DataGridTextColumn MaxWidth="100" Header="批次" Binding="{Binding MatBatch}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="数量" Binding="{Binding MatQty}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="数量" Binding="{Binding MatQty}"></DataGridTextColumn>
<DataGridTextColumn Header="库位" Binding="{Binding StoreCode}"></DataGridTextColumn> <DataGridTextColumn Header="库位" Binding="{Binding StoreCode}"></DataGridTextColumn>
<!--<DataGridTextColumn IsReadOnly="True" Header="R" Binding="{Binding R}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="已锁定" Binding="{Binding IsLockedStr}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="C" Binding="{Binding C}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="位" Binding="{Binding Wei}"></DataGridTextColumn>-->
<DataGridTextColumn IsReadOnly="True" Header="入库时间" Binding="{Binding InstoreTime,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="入库时间" Binding="{Binding InstoreTime,StringFormat='yyyy-MM-dd HH:mm:ss'}"></DataGridTextColumn>
<DataGridTextColumn Header="物料SN" Binding="{Binding MatSN}"></DataGridTextColumn> <DataGridTextColumn Header="物料SN" Binding="{Binding MatSN}"></DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>

View File

@ -31,12 +31,12 @@
<Button Style="{StaticResource ButtonSuccess}" hc:BorderElement.CornerRadius="15" <Button Style="{StaticResource ButtonSuccess}" hc:BorderElement.CornerRadius="15"
Grid.Column="3" MinHeight="45" FontSize="28" Content="&#xec61;完整发料" FontFamily="{StaticResource IconFont}" Grid.Column="3" MinHeight="45" FontSize="28" Content="&#xec61;开始发料" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnStartCommand}" Command="{Binding BtnStartCommand}"
> >
</Button> </Button>
<Button Style="{StaticResource ButtonWarning}" hc:BorderElement.CornerRadius="15" <Button Style="{StaticResource ButtonWarning}" hc:BorderElement.CornerRadius="15"
Grid.Column="4" MinHeight="45" FontSize="28" Content="&#xe61b;取消发料" FontFamily="{StaticResource IconFont}" Grid.Column="4" MinHeight="45" FontSize="28" Content="&#xe61b;暂停发料" FontFamily="{StaticResource IconFont}"
Command="{Binding BtnPauseCommand}"> Command="{Binding BtnPauseCommand}">
</Button> </Button>
</Grid> </Grid>
@ -64,7 +64,7 @@
<StackPanel Grid.Column="2" VerticalAlignment="Center" Orientation="Horizontal"> <StackPanel Grid.Column="2" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock FontSize="26" Text="发料单号:"> <TextBlock FontSize="26" Text="发料单号:">
</TextBlock> </TextBlock>
<TextBlock FontSize="26" Text="{Binding SelectedPickBillNumber}"> <TextBlock FontSize="26" Text="{Binding SelectedOutOrderNumber}">
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
</Grid> </Grid>
@ -88,12 +88,21 @@
<RowDefinition Height="1*"></RowDefinition> <RowDefinition Height="1*"></RowDefinition>
<RowDefinition Height="12*"></RowDefinition> <RowDefinition Height="12*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!--<Border CornerRadius="3" Margin="1 1 1 0" Grid.Row="0" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5">-->
<TextBlock Text="发料单列表" FontWeight="DemiBold" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"></TextBlock> <TextBlock Text="发料单列表" FontWeight="DemiBold" FontSize="24" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center"></TextBlock>
<!--</Border>-->
<Border CornerRadius="3" Margin="1" Grid.Row="1" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5"> <Border CornerRadius="3" Margin="1" Grid.Row="1" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5">
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible"> <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible">
<ListView FontSize="18" ItemsSource="{Binding PickBillNumberList}" SelectedItem="{Binding SelectedPickBillNumber}" PreviewMouseWheel="ListView_PreviewMouseWheel"> <ListView FontSize="18" ItemsSource="{Binding OutOrderList}" SelectedItem="{Binding SelectedOutOrder,Mode=TwoWay}" PreviewMouseWheel="ListView_PreviewMouseWheel">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridView.ColumnHeaderContainerStyle>
<Style TargetType="{x:Type GridViewColumnHeader}">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</GridView.ColumnHeaderContainerStyle>
<GridViewColumn DisplayMemberBinding="{Binding OrderNumber}"/>
</GridView>
</ListView.View>
</ListView> </ListView>
</ScrollViewer> </ScrollViewer>
</Border> </Border>
@ -102,18 +111,18 @@
<Border CornerRadius="3" Margin="1" Grid.Row="0" Grid.Column="1" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5"> <Border CornerRadius="3" Margin="1" Grid.Row="0" Grid.Column="1" Background="AliceBlue" BorderBrush="CadetBlue" BorderThickness="1.5">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="1*"></RowDefinition> <!--<RowDefinition Height="1*"></RowDefinition>-->
<RowDefinition Height="12*"></RowDefinition> <RowDefinition Height="12*"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<StackPanel VerticalAlignment="Center" Orientation="Horizontal" > <!--<StackPanel VerticalAlignment="Center" Orientation="Horizontal" >
<TextBlock Text="订单号:" FontSize="24"> <TextBlock FontSize="24">
</TextBlock> </TextBlock>
<TextBlock Text="{Binding OrderProdNumber}" FontSize="24"> <TextBlock Text="{Binding SelectedOutOrderNumber}" FontSize="24">
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>-->
<DataGrid Grid.Row="2" <DataGrid Grid.Row="0"
SelectedCellsChanged="DataGrid_SelectedCellsChanged" SelectedCellsChanged="DataGrid_SelectedCellsChanged"
ItemsSource="{Binding DataGridItemSource}" ItemsSource="{Binding DataGridItemSource}"
RowHeight="40" RowHeight="40"
@ -121,39 +130,22 @@
<DataGrid.Resources> <DataGrid.Resources>
<货架标准上位机:WorkItemBackgroundConverter x:Key="converter"/> <货架标准上位机:WorkItemBackgroundConverter x:Key="converter"/>
</DataGrid.Resources> </DataGrid.Resources>
<DataGrid.RowStyle> <DataGrid.RowStyle>
<Style TargetType="DataGridRow"> <Style TargetType="DataGridRow">
<Setter Property="Background" Value="{Binding Path=IsSend, Converter={StaticResource converter}}"/> <Setter Property="Background" Value="{Binding Path=IsSended, Converter={StaticResource converter}}"/>
</Style> </Style>
</DataGrid.RowStyle> </DataGrid.RowStyle>
<DataGrid.Columns> <DataGrid.Columns>
<!--<DataGridTemplateColumn CanUserResize="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<CheckBox Width="30" Height="30"
Checked="CheckBox_Checked"
Unchecked="CheckBox_Checked"
IsChecked="{Binding IsSelected , UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<CheckBox Width="30" Height="30" Unchecked="allChecked_Unchecked" Checked="allChecked_Checked" Name="allChecked"/>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
</DataGridTemplateColumn>-->
<DataGridTextColumn IsReadOnly="True" Header="序号" Binding="{Binding RowNumber}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="序号" Binding="{Binding RowNumber}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="库位" Binding="{Binding StoreCode}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="库位" Binding="{Binding StoreCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="物料编码" Binding="{Binding MatCode}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="数量" Binding="{Binding MatQty}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="物料名称" Binding="{Binding MatName}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="物料名称" Binding="{Binding MatName}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="数量" Binding="{Binding MatQty}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding MatSpec}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="规格" Binding="{Binding MatSpec}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="批次" Binding="{Binding MatBatch}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="批次" Binding="{Binding MatBatch}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="True" Header="是否已取料" Binding="{Binding IsSendStr}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="True" Header="已取料" Binding="{Binding IsSendedStr}"></DataGridTextColumn>
<DataGridTextColumn IsReadOnly="False" Header="最小包装条码" Binding="{Binding MatSN}"></DataGridTextColumn> <DataGridTextColumn IsReadOnly="False" Header="物料SN" Binding="{Binding MatSN}"></DataGridTextColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>

View File

@ -19,10 +19,11 @@ namespace 货架标准上位机
{ {
public partial class OutVentoryView : UserControlBase public partial class OutVentoryView : UserControlBase
{ {
public static OutInventoryViewModel viewModel = new OutInventoryViewModel();
public OutVentoryView() public OutVentoryView()
{ {
InitializeComponent(); InitializeComponent();
this.DataContext = new OutInventoryViewModel(); this.DataContext = viewModel;
} }
private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e) private void DataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
@ -34,12 +35,7 @@ namespace 货架标准上位机
var index = datagrid.SelectedIndex; var index = datagrid.SelectedIndex;
if (index >= 0) if (index >= 0)
{ {
//if (viewModel.DataGridItemSource != null && viewModel.DataGridItemSource.Count() > index)
//{
// var data = viewModel.DataGridItemSource.ElementAt(index);
// //data.IsSelected = !data.IsSelected;
// viewModel.DataGridItemSource = viewModel.DataGridItemSource.ToList();
//}
} }
datagrid.UnselectAllCells(); datagrid.UnselectAllCells();
} }
@ -49,46 +45,6 @@ namespace 货架标准上位机
} }
} }
private void allChecked_Checked(object sender, RoutedEventArgs e)
{
//var viewMode = this.DataContext as OutInventoryViewModel;
//if (viewMode != null && viewMode.DataGridItemSource != null && viewMode.DataGridItemSource.Count() > 0)
//{
// foreach (var item in viewMode.DataGridItemSource)
// {
// //item.IsSelected = true;
// }
// viewMode.DataGridItemSource = viewMode.DataGridItemSource.ToList();
//}
}
private void allChecked_Unchecked(object sender, RoutedEventArgs e)
{
//var viewMode = this.DataContext as OutInventoryViewModel;
//if (viewMode != null && viewMode.DataGridItemSource != null && viewMode.DataGridItemSource.Count() > 0)
//{
// foreach (var item in viewMode.DataGridItemSource)
// {
// //item.IsSelected = false;
// }
// viewMode.DataGridItemSource = viewMode.DataGridItemSource.ToList();
//}
}
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
//var viewMode = this.DataContext as OutInventoryViewModel;
//viewMode.RefreshCount();
}
private void txtMatQty1_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
if (!Regex.IsMatch(e.Text, "^[0-9]"))
{
e.Handled = true;
}
}
private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e) private void ListView_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
{ {
if (!e.Handled) if (!e.Handled)

View File

@ -74,14 +74,14 @@ namespace 货架标准上位机
}; };
var Result = ApiHelp.GetDataFromHttp<ResponseBase<UserModel>>(LocalFile.Config.ApiIpHost + "user/userLogin", var Result = ApiHelp.GetDataFromHttp<ResponseBase<UserModel>>(LocalFile.Config.ApiIpHost + "user/userLogin",
body, "POST"); body, "POST");
if (Result.Code != 200 || Result.Data == null) if (Result!= null && Result.Code != 200)
{ {
HandyControl.Controls.MessageBox.Warning(Result.Message, "提示"); HandyControl.Controls.MessageBox.Warning(Result.Message, "提示");
return; return;
} }
else else
{ {
viewModel.User = Result.Data; viewModel.User = Result?.Data;
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -56,13 +56,12 @@ namespace 货架标准上位机
m_logger.Info(e.DataFrame.ToText()); m_logger.Info(e.DataFrame.ToText());
if (!client.Client.IsClient) if (!client.Client.IsClient)
{ {
client.Send("已收到"); client.Send("已收到");
} }
//返回的报警信息 出入库盘点等日志信息 //返回的报警信息 出入库盘点等日志信息
else else
{ {
TextBoxLog.AddLog(e.DataFrame.ToText(), "123", DateTime.Now); TextBoxLog.AddLog(e.DataFrame.ToText(), "InstoreLog", DateTime.Now);
//Growl.Error(e.DataFrame.ToText());
} }
return; return;