From 757bdf8cb9261d328fa67e7bf213c06bdb96f405 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 17 Jul 2024 14:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E5=AE=9A=E7=82=B9=E9=85=8D?= =?UTF-8?q?=E9=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/TimeWorkService.cs | 148 +++++++++++++++++- 1 file changed, 144 insertions(+), 4 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index c407d322..51079787 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -247,6 +247,132 @@ namespace Tnb.ProductionMgr return msg; } + // [HttpGet] + // [AllowAnonymous] + // public async Task FixedPointDelivery() + // { + // string state = await _redisData.TryGetValueByKeyField("YTCS", "State"); + // if ("OK" != state) + // { + // Log.Error($"TCS没开机"); + // return "YTCS没开机"; + // } + // string stateHxja = await _redisData.TryGetValueByKeyField("hxjA", "State"); + // string stateHxjc = await _redisData.TryGetValueByKeyField("hxjC", "State"); + // List hxjList = new List(); + // if ("OK" == stateHxja) + // { + // hxjList.Add("hxjA"); + // } + // if ("OK" == stateHxjc) + // { + // hxjList.Add("hxjC"); + // } + // + // if (hxjList.IsEmpty()) + // { + // Log.Error($"hxjA,hxjC不正常"); + // return "hxjA,hxjC不正常"; + // } + // string msg = ""; + // 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(); + // + // int? cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); + // int? cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); + // + // 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) + // { + // EqpDaq eqpDaq = eqpDaqs.FirstOrDefault(x => x.equip_id==equipment.id); + // if (eqpDaq == null) + // { + // Log.Error($"{equipment.name}没配置允许入空箱"); + // continue; + // } + // if (!hxjList.Contains(eqpDaq.equip_code)) + // { + // Log.Error($"{eqpDaq.equip_code}状态不正常"); + // continue; + // } + // if (string.IsNullOrEmpty(equipment.upmat_location_id)) + // { + // Log.Error($"{equipment.name}未配置上料库位"); + // continue; + // } + // if (await _db.Queryable().AnyAsync(x => + // x.endlocation_id == equipment.upmat_location_id && + // x.biz_type == WmsWareHouseConst.BIZTYPE_WMSDELIVERY_ID && + // (x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID + // || x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_YXF_ID + // || x.status == WmsWareHouseConst.PRETASK_BILL_STATUS_START_ID + // ) + // )) + // { + // 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"); + // Log.Information($"机台号{eqpDaq.equip_code},标签名{eqpDaq.label_name}redis的值为{value.ToString()}"); + // + // if (value==true && !valueFlag) + // { + // bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); + // bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); + // string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; + // if (cs01==true && cs03==true) + // { + // string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; + // if (string.IsNullOrEmpty(last_fixed_point_delivery)) + // { + // startLocationCode = "ZSSSXCTU01"; + // } + // else + // { + // startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); + // } + // } + // 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)}"); + // Result result = await _wareHouseService.CommonCreatePretask(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(result.code == HttpStatusCode.OK) + // { + // msg += $"{equipment.name}注塑定点配送成功,"; + // Log.Information($"【FixedPointDelivery】{equipment.name}注塑定点配送成功"); + // _redisData.Set($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag", true, TimeSpan.FromMinutes(20)); + // _redisData.Set($"last_fixed_point_delivery", startLocationCode); + // } + // else + // { + // msg += $"{equipment.name}注塑定点配送失败:{result.msg},"; + // Log.Error($"【FixedPointDelivery】{equipment.name}注塑定点配送失败:{result.msg}"); + // } + // + // } + // } + // + // return msg; + // } + [HttpGet] [AllowAnonymous] public async Task FixedPointDelivery() @@ -280,8 +406,8 @@ namespace Tnb.ProductionMgr .Where((x, y) => x.code == "ZSJ") .Select((x, y) => y).ToListAsync(); - int? cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); - int? cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); + int cs01Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS01"); + int cs03Count = await _redisData.TryGetValueByKeyField("YTCS", "EmptyNo_CS03"); 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(); @@ -324,8 +450,9 @@ namespace Tnb.ProductionMgr { bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); - string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; - if (cs01==true && cs03==true) + string startLocationCode = ""; + + if (cs01==true && cs03==true && cs01Count>0 && cs03Count>0) { string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; if (string.IsNullOrEmpty(last_fixed_point_delivery)) @@ -337,6 +464,19 @@ namespace Tnb.ProductionMgr startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); } } + else + { + if (cs01==true && cs01Count > 0) + { + startLocationCode = "ZSSSXCTU01"; + cs01Count--; + }else if (cs03==true && cs03Count > 0) + { + startLocationCode = "ZSSSXCTU02"; + cs03Count--; + } + } + if (startLocationCode.IsEmpty()) { Log.Error($"输送线无空载具");