bug
This commit is contained in:
@@ -7,11 +7,13 @@ using JNPF.Common.Cache;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetTaste;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Qiniu.Util;
|
||||
using SqlSugar;
|
||||
using Tnb.Common.Extension;
|
||||
using Tnb.Common.Redis;
|
||||
using Tnb.Common.Utils;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
@@ -19,6 +21,7 @@ using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Entities.Enums;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Configs;
|
||||
using Tnb.WarehouseMgr.Entities.Consts;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
|
||||
@@ -34,6 +37,7 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IPrdInstockService _prdInstockService;
|
||||
private readonly ISqlSugarRepository<RedisReadConfig> _repository;
|
||||
private readonly IWmsPDAScanInStockService _wmsPDAScanInStock;
|
||||
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
|
||||
public RedisBackGround(RedisData redisData, IPrdInstockService prdInstockService, ISqlSugarRepository<RedisReadConfig> repository, IWmsPDAScanInStockService wmsPDAScanInStock)
|
||||
{
|
||||
_redisData = redisData;
|
||||
@@ -136,6 +140,7 @@ namespace Tnb.ProductionMgr
|
||||
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
|
||||
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
|
||||
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
|
||||
coderesult = coderesult.Replace("\r", "");
|
||||
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.carry_code == coderesult && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID).First();
|
||||
if (DistaskH != null)
|
||||
{
|
||||
@@ -158,19 +163,47 @@ namespace Tnb.ProductionMgr
|
||||
//扫码入库
|
||||
private void ScanInStock(object state)
|
||||
{
|
||||
var carry_code = "TestLX0001";//从数采读取载具
|
||||
WmsCarryH? carry = _repository.AsSugarClient().Queryable<WmsCarryH>().Single(it => it.carry_code == carry_code);
|
||||
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
||||
getdic.Add("BGWRKYCL02", new string[] { "CP8", "AllowGetFullBox1", "code1", "PutDoneEmptyBox","false" });
|
||||
foreach (var key in getdic.Keys)
|
||||
{
|
||||
try
|
||||
{
|
||||
var strs = getdic.Where(p => p.Key == key).First().Value;
|
||||
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)
|
||||
{
|
||||
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
["DevName"] = strs[0],
|
||||
["token"] = _eleCtlCfg.token,
|
||||
["TagName"] = strs[3],
|
||||
["Value"] = strs[4],
|
||||
};
|
||||
HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand).Wait();
|
||||
|
||||
|
||||
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
|
||||
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
|
||||
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
|
||||
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_DZX_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID || p.status == WmsWareHouseConst.TASK_BILL_STATUS_RUNING_ID)).Any())
|
||||
continue;
|
||||
var WmsCarryCode = _repository.AsSugarClient().Queryable<WmsCarryCode>().Single(it => it.carry_id == carry.id);
|
||||
|
||||
if (WmsCarryCode != null)
|
||||
{
|
||||
VisualDevModelDataCrInput input = new VisualDevModelDataCrInput();
|
||||
input.data = new Dictionary<string, object>();
|
||||
input.data.Add("barcode", carry_code);
|
||||
input.data.Add("barcode", coderesult);
|
||||
input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量
|
||||
input.data.Add("material_code", WmsCarryCode.material_code);
|
||||
input.data.Add("extras", carry.location_code!);//location_code
|
||||
input.data.Add("warehouse_id", WmsCarryCode.warehouse_id!);
|
||||
input.data.Add("extras", key);//location_code
|
||||
input.data.Add("warehouse_id", "1");//TEST
|
||||
input.data.Add("bill_code", "");//采购收货单号
|
||||
input.data.Add("code_batch", WmsCarryCode.code_batch!);//批次
|
||||
input.data.Add("material_specification", WmsCarryCode.material_specification!);//规格型号
|
||||
@@ -180,6 +213,17 @@ namespace Tnb.ProductionMgr
|
||||
_wmsPDAScanInStock.ScanInStockByRedis(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -187,12 +231,13 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
Readtimer?.Dispose();
|
||||
CheckGettimer?.Dispose();
|
||||
Scantimer?.Dispose();
|
||||
}
|
||||
public Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
// Readtimer = new Timer(GetRedisData, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
|
||||
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
|
||||
// Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(300));
|
||||
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
|
||||
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
|
||||
@@ -273,35 +273,13 @@ namespace Tnb.WarehouseMgr
|
||||
/// 判断CTU是否可以取货
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[AllowAnonymous]
|
||||
public async Task<dynamic> CheckGet()
|
||||
{
|
||||
try
|
||||
{
|
||||
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
||||
getdic.Add("SSX-021-005", new string[] { "YTCS", "AllowFullOut_CS05", "LiftCode" });
|
||||
|
||||
var strs = getdic.First().Value;
|
||||
string data = await _redisData.GetHash(strs[0], strs[1]);
|
||||
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
|
||||
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
|
||||
if (result)
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task Test()
|
||||
{
|
||||
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
|
||||
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
|
||||
string coderesult = coderes != null && coderes["Value"] != null ? coderes.Value<string>("Value")! : "";
|
||||
return new { flag =true, code = coderesult };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new { flag = false, code = "" };
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new AppFriendlyException($"接口请求异常", 500);
|
||||
}
|
||||
var a = _db.Queryable<WmsDistaskH>().Where(p => p.id == "31900194166806").First();
|
||||
await SsxControl(a, "UNLOAD");
|
||||
}
|
||||
public async Task SsxControl(WmsDistaskH disTask, string action)
|
||||
{
|
||||
@@ -309,6 +287,7 @@ namespace Tnb.WarehouseMgr
|
||||
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
|
||||
getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" });
|
||||
putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" });
|
||||
putdic.Add("YCLCKBGW", new string[] { "CP8", "PutDoneEmptyBox", "true" });
|
||||
if (action == "LOAD")//取货
|
||||
{
|
||||
if (getdic.Keys.Contains(disTask.startlocation_code))
|
||||
@@ -321,7 +300,8 @@ namespace Tnb.WarehouseMgr
|
||||
["TagName"] = strarr[1],
|
||||
["Value"] = strarr[2],
|
||||
};
|
||||
var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand);
|
||||
Logger.Information($"SsxControlLOAD:{dicCommand}");
|
||||
var str= await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand);
|
||||
Logger.Information($"SsxControlLOAD:{str}");
|
||||
}
|
||||
}
|
||||
@@ -337,7 +317,8 @@ namespace Tnb.WarehouseMgr
|
||||
["TagName"] = strarr[1],
|
||||
["Value"] = strarr[2],
|
||||
};
|
||||
var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, pars: dicCommand);
|
||||
Logger.Information($"SsxControlUNLOAD:{dicCommand}");
|
||||
var str = await HttpClientHelper.GetAsync(_eleCtlCfg.WriteTagUrl, new Dictionary<string, string>(), dicCommand);
|
||||
Logger.Information($"SsxControlUNLOAD:{str}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public class Startup : AppStartup
|
||||
services.AddOverideVisualDev();
|
||||
|
||||
//定时任务
|
||||
SnowflakeIdHelper.InitYitIdWorker();
|
||||
|
||||
services.AddHostedService<TimedTaskBackgroundService>();
|
||||
services.AddSingleton<BackgroundService, TimedTaskBackgroundService>(sp => new TimedTaskBackgroundService());
|
||||
@@ -112,7 +113,6 @@ public class Startup : AppStartup
|
||||
endpoints.MapControllerRoute(name: "default", pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
|
||||
SnowflakeIdHelper.InitYitIdWorker();
|
||||
|
||||
bool isStartTimeJob = App.GetConfig<bool>("IsStartTimeJob");
|
||||
if (isStartTimeJob)
|
||||
|
||||
Reference in New Issue
Block a user