This commit is contained in:
2024-04-11 15:04:11 +08:00
parent 1f909839d6
commit 5f16ca1abe
7 changed files with 77 additions and 15 deletions

View File

@@ -2,6 +2,7 @@
using System.Data;
using System.Dynamic;
using System.Security.Policy;
using System.Text;
using Aop.Api.Domain;
using JNPF;
using JNPF.Common.Cache;
@@ -193,6 +194,34 @@ namespace Tnb.ProductionMgr
}
}
}
private static readonly Dictionary<LogLevel, string> s_logLevelMap = new()
{
[LogLevel.Debug] = "DBG",
[LogLevel.Information] = "INF",
[LogLevel.Warning] = "WRN",
[LogLevel.Error] = "ERR",
};
protected ILogger Logger => LoggerFactory.Create(builder => builder.AddFile($"{AppContext.BaseDirectory}/logs/custom{DateTime.Now:yyyyMMdd}.log", cfgOpts =>
{
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
cfgOpts.MessageFormat = (logMsg) =>
{
var logLevel = s_logLevelMap[logMsg.LogLevel];
var sb = new StringBuilder();
_ = sb.Append($"[{logLevel}] ");
_ = sb.Append($"{logMsg.LogName} ");
_ = sb.Append($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} ");
_ = sb.Append($"#{logMsg.EventId.Id} ");
_ = sb.Append(logMsg.Message + " ");
_ = sb.Append(logMsg.Exception?.ToString());
return sb.ToString();
};
})).CreateLogger(this.GetType());
//扫码入库
private void ScanInStock(object state)
{
@@ -207,9 +236,14 @@ namespace Tnb.ProductionMgr
bool flag = _redisData.HashExist(strs[0], strs[1]).Result;
string data = _redisData.GetHash(strs[0], strs[1]).Result;
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
if (result)
{
Logger.LogInformation($"八工位扫到码发送入库请求:{res}");
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strs[0],
@@ -224,7 +258,7 @@ namespace Tnb.ProductionMgr
WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == coderesult);
if (carry != null)
{
if (_repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID ).Any())
if (_repository.AsSugarClient().Queryable<WmsPretaskH>().Where(p => p.carry_id == carry.id && p.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID ).Any())
continue;
var WmsCarryCode = _repository.AsSugarClient().Queryable<WmsCarryCode>().Single(it => it.carry_id == carry.id);
if (WmsCarryCode != null)