This commit is contained in:
qianjiawei
2024-03-14 17:28:33 +08:00
parent f37ad2bfa3
commit 501a39dda5
6 changed files with 359 additions and 26 deletions

View File

@@ -131,8 +131,14 @@ namespace Tnb.ProductionMgr
getdic.Add("SSX-011-002", new string[] { "YTCS", "AllowAgvFullIn_CS02", "Code_CS02" });
getdic.Add("SSX-011-004", new string[] { "YTCS", "AllowCtuFullOut_CS04", "Code_CS04" });
getdic.Add("SSX-011-008", new string[] { "东面提升机输送线", "入库输送线8允许出箱", "入库输送线7条码" });
getdic.Add("SSX-111-011", new string[] { "东面提升机输送线", "下升降机11允许出箱", "下升降机11条码" });
getdic.Add("SSX-111-012", new string[] { "东面提升机输送线", "下升降机12允许出箱", "下升降机12条码" });
getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03", "" });
getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01", "" });
foreach (var key in getdic.Keys)
{
try
@@ -143,6 +149,8 @@ namespace Tnb.ProductionMgr
JObject? res = JsonConvert.DeserializeObject<JObject>(data);
bool result = res != null && res["Value"] != null ? res.Value<bool>("Value") : false;
if (result)
{
if (!string.IsNullOrEmpty(strs[2]))
{
string codedata = _redisData.GetHash(strs[0], strs[2]).Result;
JObject? coderes = JsonConvert.DeserializeObject<JObject>(codedata);
@@ -162,6 +170,22 @@ namespace Tnb.ProductionMgr
Ctu.Dispose();
}
}
else {
var DistaskH = _repository.AsSugarClient().Queryable<WmsDistaskH>().Where(p => p.startlocation_code == key && p.status == WmsWareHouseConst.TASK_BILL_STATUS_YXD_ID && string.IsNullOrEmpty(p.extras)).First();
if (DistaskH != null)
{
dynamic reqBody = new ExpandoObject();
reqBody.taskCode = DistaskH.bill_code;
reqBody.slotCode = key;
reqBody.containerCode = DistaskH.carry_code;
CancellationTokenSource Ctu = new();
dynamic respBody = HttpClientHelper.PostStreamAsync("http://192.168.11.104:1880/wcs/notify/cargo", reqBody, Ctu.Token).Result;
DistaskH.extras = respBody;
_repository.AsSugarClient().Updateable(DistaskH).ExecuteCommand();
Ctu.Dispose();
}
}
}
}
catch (Exception)
{
@@ -235,6 +259,7 @@ namespace Tnb.ProductionMgr
private void SSXcode(object state)
{
Dictionary<string, string[]> dic = new Dictionary<string, string[]>();
//有问题
dic.Add("东面提升机输送线", new string[] { "下升降机判断请求", "下升降机判断条码", "下升降机判断完毕", "下升降机判断结果" });
Dictionary<string, int> putdic = new Dictionary<string, int>();
putdic.Add("SSX-111-011", 11);
@@ -260,7 +285,7 @@ namespace Tnb.ProductionMgr
{
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strs[0],
["DevName"] = key,
["token"] = _eleCtlCfg.token,
["TagName"] = strs[3],
["Value"] = putdic.Keys.Contains(DistaskH.startlocation_code) ? putdic.Where(p => p.Key == DistaskH.startlocation_code).First().Value.ToString() : "13",
@@ -268,7 +293,26 @@ namespace Tnb.ProductionMgr
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2).Wait();
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = strs[0],
["DevName"] = key,
["token"] = _eleCtlCfg.token,
["TagName"] = strs[2],
["Value"] = "true",
};
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand).Wait();
}
else
{
Dictionary<string, string> dicCommand2 = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = key,
["token"] = _eleCtlCfg.token,
["TagName"] = strs[3],
["Value"] = "13",
};
HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand2).Wait();
Dictionary<string, string> dicCommand = new(StringComparer.OrdinalIgnoreCase)
{
["DevName"] = key,
["token"] = _eleCtlCfg.token,
["TagName"] = strs[2],
["Value"] = "true",

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tnb.WarehouseMgr.Entities.Dto
{
public class LocationOutput
{
public string location_code { get; set; }
public int type { get; set; }
public int layers { get; set; }
public string carry_code { get; set; }
public string material_code { get; set; }
public decimal num { get; set; }
}
public class ZsjOutput
{
public string? device_code { get; set; }
public string? device_state { get; set; }
public string? temp1 { get; set; }
public string? temp3 { get; set; }
public string? temp5 { get; set; }
public string? zsspeed { get; set; }
public string? sjspeed { get; set; }
public string? cxtime { get; set; }
}
}

View File

@@ -76,5 +76,6 @@ namespace Tnb.WarehouseMgr.Interfaces
Task<List<WmsPointH>> PathAlgorithmsEle(string pStartId, string pEndId, int ele);
Task SsxControl(WmsDistaskH disTask, string action);
Func<string, int, Task> AddUnExecuteTask { get; set; }
Task<bool> Check(string code, string action);
}
}

View File

@@ -96,10 +96,18 @@ namespace Tnb.WarehouseMgr
var dis = _db.Queryable<WmsDistaskH>().Where(P => P.bill_code == input.taskCode).First();
if (dis.area_code == "ZSCJ001")
{
var flag = await _wareHouseService.Check(dis.startlocation_code, "LOAD");
if (flag)
{
await _wareHouseService.SsxControl(dis, "LOAD");
return await ToApiResult(HttpStatusCode.OK, "成功");
}
else
{
return await ToApiResult(HttpStatusCode.InternalServerError, "失败");
}
}
/*var whereExp = Expressionable.Create<WmsElevatorH, WmsElevatorD, WmsDistaskH>()
.And((a, b, c) => c.bill_code == input.taskCode)
.And((a, b, c) => a.enabled == 1)
@@ -189,10 +197,18 @@ namespace Tnb.WarehouseMgr
Logger.Information($"当前放货,任务编号:{input.taskCode}");
var dis = _db.Queryable<WmsDistaskH>().Where(P => P.bill_code == input.taskCode).First();
if (dis.area_code == "ZSCJ001")
{
var flag = await _wareHouseService.Check(dis.startlocation_code, "UNLOAD");
if (flag)
{
await _wareHouseService.SsxControl(dis, "UNLOAD");
return await ToApiResult(HttpStatusCode.OK, "成功");
}
else
{
return await ToApiResult(HttpStatusCode.InternalServerError, "失败");
}
}
try
{
/*var whereExp = Expressionable.Create<WmsElevatorH, WmsElevatorD, WmsDistaskH>()

View File

@@ -5,11 +5,15 @@ using JNPF.FriendlyException;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDev;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.Common.Redis;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto;
namespace Tnb.WarehouseMgr
{
@@ -21,11 +25,13 @@ namespace Tnb.WarehouseMgr
{
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
public LocationDefinitionService(ISqlSugarRepository<BasLocation> repository, IUserManager userManager)
private readonly RedisData _redisData;
public LocationDefinitionService(ISqlSugarRepository<BasLocation> repository, IUserManager userManager, RedisData redisData)
{
_db = repository.AsSugarClient();
_userManager = userManager;
OverideFuncs.ImportDataAsync = DataImport;
_redisData=redisData;
}
private async Task<dynamic> DataImport(VisualDevImportDataInput input)
@@ -162,5 +168,168 @@ namespace Tnb.WarehouseMgr
return result;
}
[HttpPost]
[AllowAnonymous]
public async Task<dynamic> GetYCLlocation()
{
List<List<LocationOutput>> LocationOutputss=new List<List<LocationOutput>>();
var list =await _db.Queryable<BasLocation>().Where(p=> p.wh_id == "1" && p.region_id== "26125793924133"&& p.is_type == "0" && p.location_code.Length==9).OrderBy(p=>p.location_code).ToListAsync();
var carrys=await _db.Queryable<WmsCarryH>().ToListAsync();
var carrycodes=await _db.Queryable<WmsCarryCode>().ToListAsync();
var lastdata=string.Empty;
List<LocationOutput> LocationOutputs = new List<LocationOutput>();
foreach (var data in list)
{
if (!string.IsNullOrEmpty(lastdata)&& data.location_code.Substring(4,1)!= lastdata.Substring(4, 1))
{
LocationOutputss.Add(LocationOutputs);
LocationOutputs = new List<LocationOutput>();
}
LocationOutput locationOutput = new LocationOutput();
locationOutput.location_code = data.location_code;
locationOutput.layers = data.layers;
locationOutput.type = 0;
if (carrys.Where(p => p.location_id == data.id).Any())
{
var carry= carrys.Where(p => p.location_id == data.id).First();
locationOutput.carry_code = carry.carry_code;
locationOutput.type = 1;
if (carrycodes.Where(p => p.carry_id == carry.id).Any())
{
var carrycode = carrycodes.Where(p => p.carry_id == carry.id).First();
locationOutput.type = 2;
locationOutput.material_code = carrycode.material_code;
locationOutput.num = carrycode.codeqty;
}
}
lastdata = data.location_code;
LocationOutputs.Add(locationOutput);
}
return LocationOutputss;
}
[HttpPost]
[AllowAnonymous]
public async Task<dynamic> GetCTUlocation()
{
List<List<LocationOutput>> LocationOutputss = new List<List<LocationOutput>>();
var list = await _db.Queryable<BasLocation>().Where(p => p.wh_id == "2" && p.region_id == "27010227520021" && p.is_type == "0" && p.location_code.Length == 13).OrderBy(p =>new { p.loc_column, p.location_code } ).ToListAsync();
var carrys = await _db.Queryable<WmsCarryH>().ToListAsync();
var carrycodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
int loc_column = 0;
List<LocationOutput> LocationOutputs = new List<LocationOutput>();
foreach (var data in list)
{
if (loc_column!=0&& data.loc_column!=loc_column)
{
LocationOutputss.Add(LocationOutputs);
LocationOutputs = new List<LocationOutput>();
}
LocationOutput locationOutput = new LocationOutput();
locationOutput.location_code = data.location_code;
locationOutput.layers = data.layers;
locationOutput.type = 0;
if (carrys.Where(p => p.location_id == data.id).Any())
{
var carry = carrys.Where(p => p.location_id == data.id).First();
locationOutput.carry_code = carry.carry_code;
locationOutput.type = 1;
if (carrycodes.Where(p => p.carry_id == carry.id).Any())
{
var carrycode = carrycodes.Where(p => p.carry_id == carry.id).First();
locationOutput.type = 2;
locationOutput.material_code = carrycode.material_code;
locationOutput.num = carrycode.codeqty;
}
}
loc_column = data.loc_column;
LocationOutputs.Add(locationOutput);
}
return LocationOutputss;
}
[HttpPost]
[AllowAnonymous]
public async Task<dynamic> GetCPlocation()
{
List<List<LocationOutput>> LocationOutputss = new List<List<LocationOutput>>();
var list = await _db.Queryable<BasLocation>().Where(p => p.wh_id == "26103372441637" && p.region_id == "28598002137877" && p.is_type == "0" && p.location_code.Length == 9).OrderBy(p => p.location_code).ToListAsync();
var carrys = await _db.Queryable<WmsCarryH>().ToListAsync();
var carrycodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
var lastdata = string.Empty;
List<LocationOutput> LocationOutputs = new List<LocationOutput>();
foreach (var data in list)
{
if (!string.IsNullOrEmpty(lastdata) && data.location_code.Substring(3, 3) != lastdata.Substring(3, 3))
{
LocationOutputss.Add(LocationOutputs);
LocationOutputs = new List<LocationOutput>();
}
LocationOutput locationOutput = new LocationOutput();
locationOutput.location_code = data.location_code;
locationOutput.layers = data.layers;
locationOutput.type = 0;
if (carrys.Where(p => p.location_id == data.id).Any())
{
var carry = carrys.Where(p => p.location_id == data.id).First();
locationOutput.carry_code = carry.carry_code;
locationOutput.type = 1;
if (carrycodes.Where(p => p.carry_id == carry.id).Any())
{
var carrycode = carrycodes.Where(p => p.carry_id == carry.id).First();
locationOutput.type = 2;
locationOutput.material_code = carrycode.material_code;
locationOutput.num = carrycode.codeqty;
}
}
lastdata = data.location_code;
LocationOutputs.Add(locationOutput);
}
return LocationOutputss;
}
[HttpPost]
[AllowAnonymous]
public async Task<dynamic> GetZSJData()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("device_state", "事件");
dic.Add("temp1", "前部[゚C]");
dic.Add("temp3", "后部1[゚C]");
dic.Add("temp5", "落下口[゚C]");
dic.Add("zsspeed", "V1[mm/s]");
dic.Add("sjspeed", "V2[mm/s]");
dic.Add("cxtime", "周期时间[s]");
var keys = _redisData.GetAllKeys().Where(p => p.Contains("TYSC-ZSJ")).ToList();
List<ZsjOutput> datas = new List<ZsjOutput>();
foreach (var key in keys)
{
var data = datas.Where(p => p.device_code == key.Substring(0, 12)).FirstOrDefault();
if (data != null)
{
foreach (var d in dic)
{
bool flag = await _redisData.HashExist(key, d.Value);
if (flag)
data.GetType().GetProperty(d.Key)!.SetValue(data,_redisData.GetHash(key, d.Value).Result);
}
}
else
{
ZsjOutput zsjOutput = new ZsjOutput();
zsjOutput.device_code = key.Substring(0, 12);
foreach (var d in dic)
{
bool flag = await _redisData.HashExist(key, d.Value);
if (flag)
zsjOutput.GetType().GetProperty(d.Key)!.SetValue(zsjOutput, _redisData.GetHash(key, d.Value).Result);
}
datas.Add(zsjOutput);
}
}
return datas;
}
}
}

View File

@@ -250,10 +250,13 @@ namespace Tnb.WarehouseMgr
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
putdic.Add("SSX-011-006", new string[] { "YTCS", "AllowEmptyIn_CS06" });
putdic.Add("SSX-021-007", new string[] { "东面提升机输送线", "出库输送线7允许入箱" });
putdic.Add("SSX-121-009", new string[] { "东面提升机输送线", "上升降机9允许入箱" });
putdic.Add("SSX-121-010", new string[] { "东面提升机输送线", "上升降机10允许入箱" });
putdic.Add("SSX-021-003", new string[] { "YTCS", "AllowCtuEmptyIn_CS03" });
putdic.Add("SSX-021-001", new string[] { "YTCS", "AllowCtuEmptyIn_CS01" });
putdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvFullIn_CS04", });
putdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvFullIn_CS02", });
var strs = new string[] { };
if (!putdic.ContainsKey(input.targetName))
@@ -277,27 +280,98 @@ namespace Tnb.WarehouseMgr
/// </summary>
/// <returns></returns>
public async Task<bool> Check(string code, string action)
{
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2允许入空箱", });
getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2允许取满箱" });
putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3允许入空箱", });
getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3允许取满箱" });
putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4允许入空箱", });
getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4允许取满箱" });
putdic.Add("ZS-C04-1", new string[] { "hxjC", "A5允许入空箱", });
getdic.Add("ZS-C04-2", new string[] { "hxjC", "A5允许取满箱" });
putdic.Add("ZS-C05-1", new string[] { "hxjC", "A6允许入空箱", });
getdic.Add("ZS-C05-2", new string[] { "hxjC", "A6允许取满箱" });
putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7允许入空箱", });
getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7允许取满箱" });
var strs = new string[] { };
if (action == "LOAD")//取货
{
if (!getdic.ContainsKey(code))
return false;
strs = getdic.Where(p => p.Key == code).First().Value;
bool flag = _redisData.HashExist(strs[0], strs[1]).Result;
if (!flag)
{
return false;
}
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)
return false;
return true;
}
else if (action == "UNLOAD")//放货
{
if (!putdic.ContainsKey(code))
return false;
strs = putdic.Where(p => p.Key == code).First().Value;
bool flag = _redisData.HashExist(strs[0], strs[1]).Result;
if (!flag)
{
return false;
}
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)
return false;
return true;
}
return false;
}
public async Task SsxControl(WmsDistaskH disTask, string action)
{
Dictionary<string, string[]> putdic = new Dictionary<string, string[]>();
Dictionary<string, string[]> getdic = new Dictionary<string, string[]>();
getdic.Add("SSX-021-005", new string[] { "YTCS", "FullOut_CS05Done", "true" });
getdic.Add("SSX-111-011", new string[] { "东面提升机输送线", "下升降机11出箱完毕", "true" });
getdic.Add("SSX-111-012", new string[] { "东面提升机输送线", "下升降机12出箱完毕", "true" });
getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AgvEmptyOut_CS03Done", "true" });
getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AgvEmptyOut_CS01Done", "true" });
getdic.Add("SSX-011-008", new string[] { "东面提升机输送线", "入库输送线8出箱完毕", "true" });
getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2AGV允许入满箱", "true" });
getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3AGV允许入满箱", "true" });
getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4AGV允许入满箱", "true" });
getdic.Add("ZS-C04-2", new string[] { "hxjC", "A5AGV允许入满箱", "true" });
getdic.Add("ZS-C05-2", new string[] { "hxjC", "A6AGV允许入满箱", "true" });
getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7AGV允许入满箱", "true" });
putdic.Add("SSX-021-007", new string[] { "东面提升机输送线", "出库输送线7入箱完毕", "true" });
putdic.Add("SSX-011-006", new string[] { "YTCS", "EmptyIn_CS06Done", "true" });
putdic.Add("SSX-021-003", new string[] { "YTCS", "AgvFullIn_CS03Done", "true" });
putdic.Add("SSX-021-001", new string[] { "YTCS", "CtuEmptyIn_CS01Done", "true" });
putdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AgvFullIn_CS04Done", "true" });
putdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AgvFullIn_CS02Done", "true" });
putdic.Add("SSX-121-009", new string[] { "东面提升机输送线", "上升降机9入箱完毕", "true" });
putdic.Add("SSX-121-010", new string[] { "东面提升机输送线", "上升降机10入箱完毕", "true" });
putdic.Add("YCLCKBGW", new string[] { "CP8", "PutDoneEmptyBox", "true" });
putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2AGV允许出空箱", "true" });
putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3AGV允许出空箱", "true" });
putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4AGV允许出空箱", "true" });
putdic.Add("ZS-C04-1", new string[] { "hxjC", "A5AGV允许出空箱", "true" });
putdic.Add("ZS-C05-1", new string[] { "hxjC", "A6AGV允许出空箱", "true" });
putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7AGV允许出空箱", "true" });
if (action == "LOAD")//取货
{
if (getdic.Keys.Contains(disTask.startlocation_code))