diff --git a/Directory.Build.props b/Directory.Build.props index c5ae6e0e..cb062056 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,8 +9,8 @@ - none - false + full + true \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs b/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs index 1cdf43ef..47de788a 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisDataService.cs @@ -70,7 +70,7 @@ namespace Tnb.ProductionMgr { ["DevName"] = device, ["token"] = _eleCtlCfg.token, - ["TagName"] = eqpDaq1.label_point, + ["TagName"] = eqpDaq1.label_name, ["Value"] = "true", }; Log.Information($"确认称重参数:{JsonConvert.SerializeObject(dicCommand)}"); @@ -82,12 +82,12 @@ namespace Tnb.ProductionMgr throw Oops.Bah("未在数据采集中设置当前重量标签点"); } - bool flag = await _redisData.HashExist(device, eqpDaq2.label_point); + bool flag = await _redisData.HashExist(device, eqpDaq2.label_name); if (!flag) { - throw Oops.Bah("没有找到" + device + "----" + eqpDaq2.label_point + "的数据"); + throw Oops.Bah("没有找到" + device + "----" + eqpDaq2.label_name + "的数据"); } - string data = await _redisData.GetHash(device, eqpDaq2.label_point); + string data = await _redisData.GetHash(device, eqpDaq2.label_name); JObject? res = JsonConvert.DeserializeObject(data); @@ -105,7 +105,7 @@ namespace Tnb.ProductionMgr { ["DevName"] = device, ["token"] = _eleCtlCfg.token, - ["TagName"] = eqpDaq3.label_point, + ["TagName"] = eqpDaq3.label_name, ["Value"] = "true", }; Log.Information($"称重完成参数:{JsonConvert.SerializeObject(dicCommand2)}"); diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 73330d23..808089ca 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -35,6 +35,7 @@ namespace Tnb.ProductionMgr public class TimeWorkService : IDynamicApiController, ITransient { private readonly ISqlSugarRepository _repository; + private readonly ISqlSugarClient _db; private readonly IOrganizeService _organizeService; private readonly IBillRullService _billRullService; private readonly RedisData _redisData; @@ -50,6 +51,7 @@ namespace Tnb.ProductionMgr { _redisData = redisData; _repository = repository; + _db = repository.AsSugarClient(); _organizeService = organizeService; _billRullService = billRullService; _wmsEmptyOutstockService = wmsEmptyOutstockService; @@ -216,50 +218,59 @@ namespace Tnb.ProductionMgr public async Task FixedPointDelivery() { string msg = ""; - bool? value = await _redisData.TryGetValueByKeyField("hxjC", "A2允许入空箱"); - bool valueFlag = _redisData.Get("hxjC_A2允许入空箱_flag"); - if (value==true && !valueFlag) + List equipments = await _db.Queryable() + .InnerJoin((x, y) => x.id == y.equip_type_id) + .Where((x, y) => x.code == "ZSJ") + .Select((x, y) => y).ToListAsync(); + + List eqpIds = equipments.Select(x => x.id).ToList(); + List eqpDaqs = await _db.Queryable().Where(x => eqpIds.Contains(x.equip_id) && x.label_name.Contains("允许入空箱")).ToListAsync(); + BasFactoryConfig config = await _db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN); + foreach (var equipment in equipments) { - bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS01"); - bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS03"); - string startLocationCode = cs01==false ? "ZSSSXCTU01" : cs03==false ? "ZSSSXCTU02" : ""; - if (startLocationCode.IsEmpty()) + EqpDaq eqpDaq = eqpDaqs.First(x => x.equip_id == equipment.id); + if (eqpDaq == null) { - Log.Error($"输送线无空载具"); - return "输送线无空载具"; + Log.Error($"{equipment.name}没配置允许入空箱"); + continue; } + bool? value = await _redisData.TryGetValueByKeyField(eqpDaq.equip_code, eqpDaq.label_name); + bool valueFlag = _redisData.Get($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag"); - var db = _repository.AsSugarClient(); - BasLocation startLocation = await db.Queryable().Where(x=>x.location_code==startLocationCode).FirstAsync(); - EqpEquipment equipment = await db.Queryable().Where(x=>x.code=="TYZS001").FirstAsync(); - if (equipment == null) + if (value==true && !valueFlag) { - Log.Error($"未找到设备编号为TYZS001的设备"); - return "未找到设备编号为TYZS001的设备"; - + bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS01"); + bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "CallCtuEmptyIn_CS03"); + string startLocationCode = cs01==false ? "ZSSSXCTU01" : cs03==false ? "ZSSSXCTU02" : ""; + if (startLocationCode.IsEmpty()) + { + Log.Error($"输送线无空载具"); + return "输送线无空载具"; + } + + BasLocation startLocation = await _db.Queryable().Where(x=>x.location_code==startLocationCode).FirstAsync(); + CommonCreatePretaskInput postData = new CommonCreatePretaskInput(); + postData.startlocation_id = startLocation.id; + postData.endlocation_id = equipment.upmat_location_id; + postData.biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID; + postData.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; + Log.Information($"【FixedPointDelivery】注塑定点配送,参数:{JsonConvert.SerializeObject(postData)}"); + string sendResult = HttpUtils.RequestPost($"{config.value}/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); + // string sendResult = HttpUtils.RequestPost($"http://localhost:9232/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); + AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); + if(authResponse.code == 200 && authResponse.data.ObjToBool()) + { + msg += $"{equipment.name}注塑定点配送成功,"; + Log.Information($"【FixedPointDelivery】{equipment.name}注塑定点配送成功"); + _redisData.Set($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag", true, TimeSpan.FromMinutes(20)); + } + else + { + msg += $"{equipment.name}注塑定点配送失败:{authResponse.msg},"; + Log.Error($"【FixedPointDelivery】{equipment.name}注塑定点配送失败:{authResponse.msg}"); + } + } - CommonCreatePretaskInput postData = new CommonCreatePretaskInput(); - postData.startlocation_id = startLocation.id; - postData.endlocation_id = equipment.as_location_id; - postData.biz_type = WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID; - postData.task_type = WmsWareHouseConst.WMS_PRETASK_OUTSTOCK_TYPE_ID; - Log.Information($"【FixedPointDelivery】注塑定点配送,参数:{JsonConvert.SerializeObject(postData)}"); - BasFactoryConfig config = await db.Queryable().FirstAsync(x => x.enabled == 1 && x.key == FactoryConfigConst.DOMAIN); - string sendResult = HttpUtils.RequestPost($"{config.value}/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); - // string sendResult = HttpUtils.RequestPost($"http://localhost:9232/api/wms/ware-house/common-create-pretask", JsonConvert.SerializeObject(postData), null); - AuthResponse authResponse = JsonConvert.DeserializeObject(sendResult); - if(authResponse.code == 200 && authResponse.data.ObjToBool()) - { - msg = "注塑定点配送成功"; - Log.Information("【FixedPointDelivery】注塑定点配送成功"); - _redisData.Set("hxjC_A2允许入空箱_flag", true, TimeSpan.FromMinutes(20)); - } - else - { - msg = $"注塑定点配送失败:{authResponse.msg}"; - Log.Error($"【FixedPointDelivery】注塑定点配送失败:{authResponse.msg}"); - } - } return msg; diff --git a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj index d9debf8f..fd26adc3 100644 --- a/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj +++ b/ProductionMgr/Tnb.ProductionMgr/Tnb.ProductionMgr.csproj @@ -6,9 +6,6 @@ enable True Debug;Release;tianyi - full - true - false