提交库存
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@ -6,10 +7,12 @@ using WCS.BLL.Config;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.DbModels.Task;
|
||||
using WCS.BLL.Manager;
|
||||
using WCS.BLL.Tool;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel.InOutRecord;
|
||||
using WCS.Model.ApiModel.MKYBackgroundThread;
|
||||
using WCS.Model.ApiModel.OutStore;
|
||||
using WCS.Model.WebSocketModel;
|
||||
using static WCS.BLL.HardWare.WarningLight;
|
||||
@ -64,13 +67,20 @@ namespace WCS.BLL.HardWare
|
||||
Logs.Write($"[test]{ShelfCode}");
|
||||
try
|
||||
{
|
||||
Logs.Write($"[test]{ShelfCode}1");
|
||||
if (TcpCleint == null)
|
||||
{
|
||||
await Task.Delay(2000);
|
||||
continue;
|
||||
}
|
||||
Logs.Write($"[test]{ShelfCode}2");
|
||||
//未完成首次连接时 暂不发送
|
||||
if (TcpCleint.IsFirstConnected == false)
|
||||
{
|
||||
await Task.Delay(2000);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logs.Write($"[test]{ShelfCode}3");
|
||||
//查询属于本货架的任务
|
||||
var currentShelfTasks = DbHelp.db.Queryable<CurrentTask>()
|
||||
.Where(t => t.ShelfId == this.ShelfId)
|
||||
@ -85,9 +95,11 @@ namespace WCS.BLL.HardWare
|
||||
{ t.IsNeedRefresh = true; }
|
||||
});
|
||||
|
||||
Logs.Write($"[test]{ShelfCode}4");
|
||||
//查询是否有需要刷新的
|
||||
var needRefreshModules = MXL4Modules.Where(t => t.IsNeedRefresh)
|
||||
.ToList();
|
||||
Logs.Write($"[test]{ShelfCode}5");
|
||||
foreach (var module in needRefreshModules)
|
||||
{
|
||||
try
|
||||
@ -96,9 +108,11 @@ namespace WCS.BLL.HardWare
|
||||
var currentTasks = currentShelfTasks.Where(t => t.ModuleId == module.ModuleId)
|
||||
.OrderBy(t => t.CreateTime)
|
||||
.ToList();
|
||||
Logs.Write($"[test]{ShelfCode}5.1");
|
||||
//入库、出库、盘点等任务
|
||||
if (currentTasks != null && currentTasks.Count > 0)
|
||||
{
|
||||
Logs.Write($"[test]{ShelfCode}5.2");
|
||||
var firstTask = currentTasks.First();
|
||||
var taskMode = currentTasks.First().TaskMode;
|
||||
#region 处理模组的模式 没有Continue
|
||||
@ -188,9 +202,11 @@ namespace WCS.BLL.HardWare
|
||||
//不存在入库、出库、盘点等任务 应该变成待机
|
||||
else
|
||||
{
|
||||
Logs.Write($"[test]{ShelfCode}5.3");
|
||||
//退出对应模式到待机模式! 后续持续刷新数据!
|
||||
if (module.CurrentMode != TaskModeEnum.待机模式)
|
||||
{
|
||||
Logs.Write($"[test]{ShelfCode}5.4");
|
||||
// 退出对应模式
|
||||
switch (module.CurrentMode)
|
||||
{
|
||||
@ -209,14 +225,80 @@ namespace WCS.BLL.HardWare
|
||||
continue;
|
||||
}
|
||||
|
||||
Logs.Write($"[test]{ShelfCode}5.5");
|
||||
//向上层系统获取数据
|
||||
|
||||
var stockQueryUrl = @"http://10.41.235.10:18989/ztwcs/stockQuery";
|
||||
var dataBody = new StockQueryRequest();
|
||||
dataBody.storeCodes.Add(module.ModuleCode);
|
||||
Logs.Write("111", LogsType.StartBoot);
|
||||
var result = ApiHelp.GetDataFromHttp<StockQueryResponse>(stockQueryUrl, dataBody, "POST", true);
|
||||
if (result == null)
|
||||
{
|
||||
Logs.Write("2222", LogsType.StartBoot);
|
||||
continue;
|
||||
}
|
||||
//获取成功 有数据 绑定对应数据
|
||||
if (result.code == 200)
|
||||
{
|
||||
|
||||
var jsonString = result.data;
|
||||
Logs.Write($"3333{jsonString}", LogsType.StartBoot);
|
||||
if (!string.IsNullOrEmpty(jsonString))
|
||||
{
|
||||
Logs.Write($"44", LogsType.StartBoot);
|
||||
// 去除所有双引号前面的反斜杠
|
||||
jsonString = Regex.Replace(jsonString, @"\\(.)", "$1"); ;
|
||||
var data = JsonConvert.DeserializeObject<List<StockQueryResponseDataItem>>(jsonString);
|
||||
if (data != null && data.Count > 0)
|
||||
{
|
||||
//硬件只能显示7个 只保留前7个
|
||||
if (data.Count > 7)
|
||||
{
|
||||
data = data.Take(7).ToList();
|
||||
}
|
||||
|
||||
int taskid = 1;
|
||||
foreach (var item in data)
|
||||
{
|
||||
module.SendTaskId(taskid++, TcpCleint);
|
||||
module.SendMatCode(item.material_code, TcpCleint);
|
||||
module.SendMatName(item.material_name, TcpCleint);
|
||||
module.SendMatSpec("-", TcpCleint);
|
||||
module.SendMatBatch(item.batch_no, TcpCleint);
|
||||
module.SendMatQty((int)item.qty, TcpCleint);
|
||||
}
|
||||
module.IsNeedRefresh = false;
|
||||
continue;
|
||||
}
|
||||
//库存里面无数据
|
||||
else
|
||||
{
|
||||
Logs.Write($"6666", LogsType.StartBoot);
|
||||
//获取成功 无数据
|
||||
module.StandbyNoInfoDisplay(TcpCleint);
|
||||
module.IsNeedRefresh = false;//未获取到库存数据 回没有库位显示信息给硬件
|
||||
//获取失败 跳过此次循环后继续获取
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Logs.Write($"6666", LogsType.StartBoot);
|
||||
//获取成功 无数据
|
||||
module.StandbyNoInfoDisplay(TcpCleint);
|
||||
module.IsNeedRefresh = false;//未获取到库存数据 回没有库位显示信息给硬件
|
||||
//获取失败 跳过此次循环后继续获取
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
//获取成功 无数据
|
||||
module.StandbyNoInfoDisplay(TcpCleint);
|
||||
module.IsNeedRefresh = false;//未获取到库存数据 回没有库位显示信息给硬件
|
||||
//获取失败 跳过此次循环后继续获取
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -226,6 +308,23 @@ namespace WCS.BLL.HardWare
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//刷新报警灯
|
||||
if (needRefreshModules != null && needRefreshModules.Count > 0)
|
||||
{
|
||||
var isShelfHaveTask = DbHelp.db.Queryable<CurrentTask>()
|
||||
.Where(t => t.ShelfId == this.ShelfId)
|
||||
.Where(t => t.IsSended == true)
|
||||
.Any();
|
||||
if (isShelfHaveTask)
|
||||
{
|
||||
WarningLight.GreenLight(TcpCleint);
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningLight.CloseLight(TcpCleint);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -618,7 +717,7 @@ namespace WCS.BLL.HardWare
|
||||
MatBatch = task.MatBatch,
|
||||
MatSN = task.MatSN,
|
||||
CreateTime = task.CreateTime,
|
||||
Qty= task.Qty,
|
||||
Qty = task.Qty,
|
||||
FinishQty = finishQty,
|
||||
FinishTime = DateTime.Now,
|
||||
};
|
||||
|
@ -326,7 +326,7 @@ namespace WCS.BLL.Tool
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = httpMethod;
|
||||
request.ContentType = "application/json";
|
||||
request.Timeout = 3000;
|
||||
request.Timeout = 5000;
|
||||
|
||||
if (!string.IsNullOrEmpty(data))
|
||||
{
|
||||
|
11
WCS.Model/ApiModel/MKYBackgroundThread/StockQueryRequest.cs
Normal file
11
WCS.Model/ApiModel/MKYBackgroundThread/StockQueryRequest.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MKYBackgroundThread
|
||||
{
|
||||
public class StockQueryRequest
|
||||
{
|
||||
public List<string> storeCodes { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
31
WCS.Model/ApiModel/MKYBackgroundThread/StockQueryResponse.cs
Normal file
31
WCS.Model/ApiModel/MKYBackgroundThread/StockQueryResponse.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace WCS.Model.ApiModel.MKYBackgroundThread
|
||||
{
|
||||
/// <summary>
|
||||
/// 库存查询返回实体
|
||||
/// </summary>
|
||||
public class StockQueryResponse
|
||||
{
|
||||
public int code { get; set; }
|
||||
|
||||
public string data { get; set; }
|
||||
|
||||
public string message { get; set; }
|
||||
}
|
||||
|
||||
public class StockQueryResponseDataItem
|
||||
{
|
||||
public string batch_no { get; set; } = "-";
|
||||
|
||||
public string location_code { get; set; } = "-";
|
||||
|
||||
public decimal qty { get; set; } = 0;
|
||||
|
||||
public string material_name { get; set; } = "-";
|
||||
|
||||
public string material_code { get; set; } = "-";
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user