From febcd0c73b51b17f484ff9a9a189b1f85130c2f7 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期二, 17 三月 2026 13:52:06 +0800
Subject: [PATCH] 更新自动门,新增切卷卷绕缓存架
---
wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs | 324 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 322 insertions(+), 2 deletions(-)
diff --git a/wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs b/wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs
index e0a83cf..78278e6 100644
--- a/wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs
+++ b/wcs-server-hbf/WIDESEA_WCS/Jobs/RGV/AluminumCaseJob.cs
@@ -21,6 +21,12 @@
using HslCommunication;
using SqlSugar;
using WIDESEA_Core.Extensions;
+using static System.Collections.Specialized.BitVector32;
+using WIDESEA_WCS.WCSClient.Modbus;
+using static FreeSql.Internal.GlobalFilter;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using System.Reflection.Metadata;
+using Dm;
namespace WIDESEA_WCS
{
@@ -32,6 +38,7 @@
{
FreeDB freeDB = new FreeDB();
static List<HCJCenterEqDB> centerEqDBList;
+ static List<HCJCenterEqDB> centerJRDBList;
private static object createTaskObj = new object();
public Task Execute(IJobExecutionContext context)
{
@@ -54,8 +61,321 @@
client.Connect();
return;
}
- //閾濆3缂撳瓨鏋朵笟鍔′綔涓�
- LKHCJdispatch();
+ if (client.PLCName.Contains("閾濆3"))
+ {
+ //閾濆3缂撳瓨鏋朵笟鍔′綔涓�
+ LKHCJdispatch();
+ }
+ else
+ {
+ //鍗风粫缂撳瓨鏋朵笟鍔′綔涓�
+ JRHCJdispatch();
+ }
+
+ }
+ /// <summary>
+ /// 鍗风粫缂撳瓨鏋朵笟鍔′綔涓�
+ /// </summary>
+ private void JRHCJdispatch()
+ {
+
+ //閾濆3缂撳瓨鏋舵惉杩�
+ PLCClient pLCClientJR = WCSService.Clients.Find(V => V.PLCName==PLCConst.PLCNameJR);
+ if (pLCClientJR != null)
+ {
+ string tsjJson = File.ReadAllText(AppContext.BaseDirectory + "/Config/鍗风粫缂撳瓨鏋�.json", Encoding.UTF8);
+ centerJRDBList = JsonConvert.DeserializeObject<List<HCJCenterEqDB>>(tsjJson);
+ if (centerJRDBList == null)
+ {
+ return;
+ }
+ PLCClient agvzzplc = WCSService.Clients.Find(v => v.PLCName == "缁勮AGV璋冨害");
+ UpdateJRHCJ(pLCClientJR);
+ #region 鍗风粫鍙枡
+ List<base_ware_location> locations = freeDB.Select<base_ware_location>()
+ .Where(x => (x.tpgd == 0 && x.gd1 == 0 && x.gd2 == 0 && x.gd3 == 0 && x.gd4 == 0 && x.status == 1 && x.task == 2 && x.logic_layer == "1" && x.location_state == "LocationState_Empty") && (x.upper_code.Contains("QJHCJ10") || x.upper_code.Contains("QJHCJ11")))
+ .ToList();
+ foreach (var item in locations)
+ {
+ if (item.geartype == "鏆傛棤")
+ {
+ WriteLog.GetLog().Write($"{item.upper_code}{item.geartype}---{DateTime.Now}", $"鍗风粫涓婃枡璇锋眰澶辫触");
+ continue;
+ }
+ List<base_routing_table> routing_table = freeDB.Select<base_routing_table>()
+ .Where(v => v.route_end == item.upper_code).ToList();
+ if (routing_table.Count > 0)//鏃犳枡鎵嶈兘鐢熸垚浠诲姟&& location_QJ.tpgd==0
+ {
+ List<string> route_begans = routing_table.Select(x => x.route_began).ToList();
+ base_ware_location ware_Location = freeDB.Select<base_ware_location>()
+ .Where(d => route_begans.Contains(d.upper_code) && d.location_state == "LocationState_Stored" && d.logic_col == 1 && d.tpgd == 1 && d.status == 1 && d.task == 2 && d.geartype == item.geartype).OrderBy(d => d.update_time).First();
+ if (ware_Location != null)
+ {
+ base_ware_location jkloction = ware_Location;
+ #region 璁板綍涓婃枡璇锋眰淇″彿
+ WriteLog.GetLog().Write($"{item.upper_code}涓婃枡璇锋眰---{DateTime.Now}", $"鍗风粫涓婃枡璇锋眰");
+ #endregion
+ //鍐嶆鍒ゆ柇鏄惁鏈変换鍔″瓨鍦�
+ dt_agvtask agvtaskOld = freeDB.Select<dt_agvtask>().Where(x => x.agv_toaddress == item.upper_code).First();
+ if (agvtaskOld != null && item.task == 2)
+ {
+ item.logic_col = 1;//璁剧疆鑹搧鐗╂枡
+ item.task = 1;//璁剧疆浠诲姟鐢熸垚1
+ var locationOffOld1 = freeDB.Update(item).UpdateColumns(t => new
+ {
+ t.logic_col,
+ t.task
+ }).ExecuteAffrows();
+ continue;
+ }
+ dt_agvtask agvtask = new dt_agvtask()
+ {
+ agv_id = Guid.NewGuid(),
+ agv_tasknum = "KH-" + IdenxManager.GetTaskNo(),
+ agv_fromaddress = jkloction.upper_code,
+ agv_toaddress = item.upper_code,
+ agv_code = "缁勮AGV璋冨害",
+ agv_remark = "鍒囧嵎涓婃枡鍛煎彨",
+ agv_taskstate = AGVTaskStateEnum.Create.ToString(),
+ agv_tasktype = AGVTaskTypeEnum.TaskType_Outbound.ToString(),
+ agv_worktype = 1,//宸ヤ綔绫诲瀷
+ agv_materielid = "",
+ agv_qty = 1,
+ agv_createtime = DateTime.Now,
+ agv_grade = 0,//浠诲姟浼樺厛绾�
+ agv_userid = "WCS",
+ agv_barcode = ""
+ };
+ item.logic_col = 1;//璁剧疆鑹搧鐗╂枡
+ item.task = 1;//璁剧疆浠诲姟鐢熸垚1
+ var locationOff1 = freeDB.Update(item).UpdateColumns(t => new
+ {
+ t.logic_col,
+ t.task
+ }).ExecuteAffrows();
+ jkloction.logic_col = 1;//璁剧疆鑹搧鐗╂枡
+ jkloction.task = 1;//璁剧疆浠诲姟鐢熸垚1
+ var locationOff2 = freeDB.Update(jkloction).UpdateColumns(t => new
+ {
+ t.logic_col,
+ t.task
+ }).ExecuteAffrows();
+ freeDB.Add(agvtask);
+ }
+ else
+ {
+ WriteLog.GetLog().Write($"{item.upper_code}鏈壘鍒版弧瓒抽�佸線鍒囧嵎鐨勬瀬搴撴枡---{DateTime.Now}", $"鍗风粫涓婃枡璇锋眰澶辫触");
+ }
+ }
+ }
+ #endregion
+ }
+ }
+ private void UpdateJRHCJ(PLCClient client)
+ {
+ ModbusTcpNet ModbusPLCClient = client.ModbusPLCClient.ModbusTcpNetClient;
+ var stationList = centerJRDBList.FirstOrDefault(t => client.PLCName.Contains(t.HCJCenterName));
+ foreach (var item in stationList.stationInfos)
+ {
+ base_ware_location location = freeDB.Select<base_ware_location>()
+ .Where(x => x.upper_code == item.HCJCode)
+ .First();
+ ////Console.WriteLine($"{station.stationCode}------{DateTime.Now}");
+ if (location == null)
+ {
+ continue;
+ }
+ string wlgd1DB = item.RPLCDB[0];//鐗╂枡鍏夌數1鐘舵�佷俊鍙风偣浣�
+ string wlgd2DB = item.RPLCDB[1];//鐗╂枡鍏夌數2鐘舵�佷俊鍙风偣浣�
+ string wlgd3DB = item.RPLCDB[2];//鐗╂枡鍏夌數3鐘舵�佷俊鍙风偣浣�
+ string wlgd4DB = item.RPLCDB[3];//鐗╂枡鍏夌數4鐘舵�佷俊鍙风偣浣�
+ string tpgdDB = item.RPLCDB[4];//鎵樼洏鍏夌數鐘舵�佷俊鍙风偣浣�
+ string buttonDB = item.RPLCDB[5];//鎸夐挳鐘舵�佷俊鍙风偣浣�
+
+ ////纭鎸夐挳(缁胯壊)
+ OperateResult<bool> R_TBR_XT1 = ModbusPLCClient.ReadBool(buttonDB);
+ OperateResult<bool> R_TBR_XT2 = ModbusPLCClient.ReadBool(buttonDB);
+ WriteLog.GetLog().Write($"{item.HCJName}缂撳瓨鏋�,杩炴帴{R_TBR_XT1.IsSuccess}{R_TBR_XT2.IsSuccess}", "鍗风粫缂撳瓨鏋�");
+ if (!R_TBR_XT1.IsSuccess && !R_TBR_XT2.IsSuccess)
+ {
+ //Console.WriteLine($"-{ModbusPLCClient.IpAddress}---{station.stationCode}----{ButtonEnsureDB}--------false--{R_TBR_XT.Message}----------------");
+ location.location_state = LocationStateEnum.LocationState_Close.ToString();
+ location.tpgd = -1;
+ location.update_time = DateTime.Now;
+ location.wireless_time = DateTime.Now;
+ var locationOff = freeDB.Update(location).UpdateColumns(t => new
+ {
+ t.location_state,
+ t.tpgd,
+ t.update_time,
+ t.wireless_time
+ }).ExecuteAffrows();
+ continue;
+ }
+ OperateResult<bool> ButtonEnsure1 = ModbusPLCClient.ReadBool(buttonDB);
+ OperateResult<bool> ButtonEnsure2 = ModbusPLCClient.ReadBool(buttonDB);
+ //鎵樼洏鍏夌數鐘舵��
+ OperateResult<bool> tpgdstate1 = ModbusPLCClient.ReadBool(tpgdDB);
+ OperateResult<bool> tpgdstate2 = ModbusPLCClient.ReadBool(tpgdDB);
+ //鐗╂枡鍏夌數1鐘舵��
+ OperateResult<bool> wlgd1state1 = ModbusPLCClient.ReadBool(wlgd1DB);
+ OperateResult<bool> wlgd1state2 = ModbusPLCClient.ReadBool(wlgd1DB);
+ //鐗╂枡鍏夌數2鐘舵��
+ OperateResult<bool> wlgd2state1 = ModbusPLCClient.ReadBool(wlgd2DB);
+ OperateResult<bool> wlgd2state2 = ModbusPLCClient.ReadBool(wlgd2DB);
+ //鐗╂枡鍏夌數3鐘舵��
+ OperateResult<bool> wlgd3state1 = ModbusPLCClient.ReadBool(wlgd3DB);
+ OperateResult<bool> wlgd3state2 = ModbusPLCClient.ReadBool(wlgd3DB);
+ //鐗╂枡鍏夌數4鐘舵��
+ OperateResult<bool> wlgd4state1 = ModbusPLCClient.ReadBool(wlgd4DB);
+ OperateResult<bool> wlgd4state2 = ModbusPLCClient.ReadBool(wlgd4DB);
+ //鏍规嵁璇诲埌鐨凱LC淇℃伅锛岃疆璇㈡洿鏂版暟鎹簱淇℃伅
+ location.update_time = DateTime.Now;
+ location.wireless_time = DateTime.Now;
+ if (ButtonEnsure1.IsSuccess)
+ {
+ location.logic_layer = ButtonEnsure1.Content ? "1" : "0";
+ }
+ if (ButtonEnsure2.IsSuccess)
+ {
+ location.logic_layer = ButtonEnsure2.Content ? "1" : "0";
+ }
+ if (tpgdstate1.IsSuccess)
+ {
+ location.tpgd = !tpgdstate1.Content ? 1 : 0;
+ }
+ if (tpgdstate2.IsSuccess)
+ {
+ location.tpgd = !tpgdstate2.Content ? 1 : 0;
+ }
+ #region 鐗╂枡鍏夌數1
+ if (wlgd1state1.IsSuccess)
+ {
+ location.gd1 = !wlgd1state1.Content ? 1 : 0; ;
+ }
+ if (wlgd1state2.IsSuccess)
+ {
+ location.gd1 = !wlgd1state2.Content ? 1 : 0; ;
+ }
+ #endregion
+ #region 鐗╂枡鍏夌數2
+ if (wlgd2state1.IsSuccess)
+ {
+ location.gd2 = !wlgd2state1.Content ? 1 : 0; ;
+ }
+ if (wlgd2state2.IsSuccess)
+ {
+ location.gd2 = !wlgd2state2.Content ? 1 : 0; ;
+ }
+ #endregion
+ #region 鐗╂枡鍏夌數3
+ if (wlgd3state1.IsSuccess)
+ {
+ location.gd3 = !wlgd3state1.Content ? 1 : 0; ;
+ }
+ if (wlgd3state2.IsSuccess)
+ {
+ location.gd3 = !wlgd3state2.Content ? 1 : 0; ;
+ }
+ #endregion
+ #region 鐗╂枡鍏夌數4
+ if (wlgd4state1.IsSuccess)
+ {
+ location.gd4 = !wlgd4state1.Content ? 1 : 0; ;
+ }
+ if (wlgd4state2.IsSuccess)
+ {
+ location.gd4 = !wlgd4state2.Content ? 1 : 0; ;
+ }
+ #endregion
+ string LampYellowDB = item.WPLCDB[0];//榛勭伅淇″彿鐐逛綅
+ string LampGreenDB = item.WPLCDB[1];//缁跨伅淇″彿鐐逛綅
+ string LampRedDB = item.WPLCDB[2];//绾㈢伅淇″彿鐐逛綅
+
+ //璐ф灦瀛樺湪浠诲姟浠诲姟鏃�
+ if (location.tpgd == 1)
+ {
+ location.location_state = LocationStateEnum.LocationState_Stored.ToString();
+ OperateResult<bool> Yellow1 = ModbusPLCClient.ReadBool(LampYellowDB);
+ OperateResult<bool> Yellow2 = ModbusPLCClient.ReadBool(LampYellowDB);
+ if (location.logic_col == 2)
+ {
+ ModbusPLCClient.Write(LampRedDB, true); //绾㈢伅
+ ModbusPLCClient.Write(LampRedDB, true); //绾㈢伅
+ }
+ if (location.task == 1 && (Yellow1.Content || Yellow2.Content))
+ {
+ //ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ //ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ ModbusPLCClient.Write(LampYellowDB, false); //榛勭伅
+ ModbusPLCClient.Write(LampYellowDB, false); //榛勭伅
+ }
+ else if(location.task == 1 && (!Yellow1.Content || !Yellow2.Content))
+ {
+ //ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ //ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ ModbusPLCClient.Write(LampYellowDB, true); //榛勭伅
+ ModbusPLCClient.Write(LampYellowDB, true); //榛勭伅
+ }
+ else
+ {
+ ModbusPLCClient.Write(LampYellowDB, true); //榛勭伅
+ ModbusPLCClient.Write(LampYellowDB, true); //榛勭伅
+ ModbusPLCClient.Write(LampGreenDB, false); //缁跨伅
+ ModbusPLCClient.Write(LampGreenDB, false); //缁跨伅
+ ModbusPLCClient.Write(LampRedDB, false); //绾㈢伅
+ ModbusPLCClient.Write(LampRedDB, false); //绾㈢伅
+ }
+ }
+ else
+ {
+ location.location_state = LocationStateEnum.LocationState_Empty.ToString();
+ OperateResult<bool> Yellow1 = ModbusPLCClient.ReadBool(LampYellowDB);
+ OperateResult<bool> Yellow2 = ModbusPLCClient.ReadBool(LampYellowDB);
+ if (location.logic_col == 2)
+ {
+ ModbusPLCClient.Write(LampRedDB, true); //绾㈢伅
+ ModbusPLCClient.Write(LampRedDB, true); //绾㈢伅
+ }
+
+ if (location.task == 1 && (Yellow1.Content || Yellow2.Content))
+ {
+ ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ ModbusPLCClient.Write(LampYellowDB, false); //榛勭伅
+ ModbusPLCClient.Write(LampYellowDB, false); //榛勭伅
+ }
+ else if (location.task == 1 && (!Yellow1.Content || !Yellow2.Content))
+ {
+ ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ ModbusPLCClient.Write(LampGreenDB, true); //缁跨伅
+ ModbusPLCClient.Write(LampYellowDB, true); //榛勭伅
+ ModbusPLCClient.Write(LampYellowDB, true); //榛勭伅
+ }
+ else
+ {
+ ModbusPLCClient.Write(LampYellowDB, false); //榛勭伅
+ ModbusPLCClient.Write(LampYellowDB, false); //榛勭伅
+ ModbusPLCClient.Write(LampGreenDB, false); //缁跨伅
+ ModbusPLCClient.Write(LampGreenDB, false); //缁跨伅
+ ModbusPLCClient.Write(LampRedDB, false); //绾㈢伅
+ ModbusPLCClient.Write(LampRedDB, false); //绾㈢伅
+ }
+ }
+
+ var executeAffrows = freeDB.Update(location).UpdateColumns(t => new
+ {
+ t.location_state,
+ t.logic_layer,
+ t.update_time,
+ t.wireless_time,
+ t.tpgd,
+ t.gd1,
+ t.gd2,
+ t.gd3,
+ t.gd4
+ }).ExecuteAffrows();
+ }
}
private void LKHCJdispatch()
{
--
Gitblit v1.9.3