Pārlūkot izejas kodu

CCS功能处理

oyq28 3 nedēļas atpakaļ
vecāks
revīzija
20d8407a84

+ 1 - 1
IMCS_CCS/Controllers/JobTasksController.cs

@@ -151,7 +151,7 @@ namespace IMCS.CCS.Controllers
         [HttpPost("RemoveRedis")]
         public void RemoveRedis()
         {
-            //_taskJobService.removeRedis();
+            _taskJobService.removeRedis();
         }
     }
 }

+ 6 - 0
IMCS_CCS/IMCS.CCS.xml

@@ -1804,6 +1804,12 @@
             </summary>
             <returns></returns>
         </member>
+        <member name="M:IMCS.CCS.Service.ITaskJobService.removeRedis">
+            <summary>
+            删除redis
+            </summary> 
+            <returns></returns>
+        </member>
         <member name="T:IMCS.CCS.Service.ITaskService">
             <summary>
             任务 Job 服务

+ 2 - 0
IMCS_CCS/Model/vo/ResponseECSData.cs

@@ -15,6 +15,8 @@ namespace IMCS.CCS.Models.vo
 
         public string concurrency { get; set; } = "false";
 
+        public string isUpload { get; set; } = "false";
+
         public string data { get; set; } 
         public ResponseECSData(string taskID,string taskNodeID)
         {

+ 1 - 1
IMCS_CCS/Service/ITaskJobService.cs

@@ -88,7 +88,7 @@ namespace IMCS.CCS.Service
         /// 删除redis
         /// </summary> 
         /// <returns></returns>
-        //void removeRedis();
+        void removeRedis();
 
     }
 }

+ 2 - 2
IMCS_CCS/Service/Impl/HttpRequestService.cs

@@ -879,7 +879,7 @@ namespace IMCS.CCS.Services
         public async Task<ResponseECSData> UploadFile(RequestData<UploadFileData> req)
         {
             ResponseECSData responseData = new ResponseECSData(req.taskId, req.taskNodeId);
-
+            responseData.isUpload = "true";
             try
             {
                 List<Device> devices = _deviceService.GetDeviceList();
@@ -1081,7 +1081,7 @@ namespace IMCS.CCS.Services
         public async Task<ResponseECSData> PreUploadFile(RequestData<UploadFileData> req)
         {
             ResponseECSData responseData = new ResponseECSData(req.taskId, req.taskNodeId);
-
+            responseData.isUpload = "true";
             try
             {
                 List<Device> devices = _deviceService.GetDeviceList();

+ 56 - 9
IMCS_CCS/Service/Impl/TaskJobService.cs

@@ -52,6 +52,8 @@ namespace IMCS.CCS.Service.Impl
 
         private string hdhUrlContext;
 
+        private string kedeUrlContext;
+
         private Dictionary<String, int> syncStatusMap = new Dictionary<String, int>();
 
         private Dictionary<String, String> jcAddressDict = new Dictionary<String, String>();
@@ -100,7 +102,9 @@ namespace IMCS.CCS.Service.Impl
             fanucUrlContext = Configuration.GetConnectionString("fanucUrlContext");
             opcuacUrlContext = Configuration.GetConnectionString("opcuacUrlContext");
             hdhUrlContext = Configuration.GetConnectionString("hdhUrlContext");
+            kedeUrlContext = Configuration.GetConnectionString("kedeUrlContext");
             ecsRootUrlContext = Configuration.GetConnectionString("ecsRootUrlContext");
+            
             syncStatusMap.Add("离线", 0);
             syncStatusMap.Add("空闲", 1);
             syncStatusMap.Add("生产中", 2);
@@ -121,6 +125,13 @@ namespace IMCS.CCS.Service.Impl
             jcIpDict.Add("192.168.11.166", "192.168.11.150");
             jcIpDict.Add("192.168.11.167", "192.168.11.150");
             jcIpDict.Add("192.168.11.168", "192.168.11.150");
+            //翼片
+            jcIpDict.Add("192.168.11.39", "192.168.11.33");
+            jcIpDict.Add("192.168.11.41", "192.168.11.33");
+            jcIpDict.Add("192.168.11.43", "192.168.11.33");
+            //中舱
+            jcIpDict.Add("192.168.11.29", "192.168.11.21");
+            jcIpDict.Add("192.168.11.27", "192.168.11.21");            
 
             //框体机床对应加工状态
             jcAddressDict.Add("192.168.11.186", "DB200.402");
@@ -130,11 +141,21 @@ namespace IMCS.CCS.Service.Impl
             jcAddressDict.Add("192.168.11.190", "DB200.410");
             jcAddressDict.Add("192.168.11.191", "DB200.412");
             jcAddressDict.Add("192.168.11.192", "DB200.414");
+
             //舱体机床对应加工状态
             jcAddressDict.Add("192.168.11.164", "DB200.292"); //恒轮
             jcAddressDict.Add("192.168.11.166", "DB200.296");
             jcAddressDict.Add("192.168.11.167", "DB200.298");
-            jcAddressDict.Add("192.168.11.168", "DB200.300"); 
+            jcAddressDict.Add("192.168.11.168", "DB200.300");
+
+            //翼片机床对应加工状态
+            jcAddressDict.Add("192.168.11.39", "DB200.338"); 
+            jcAddressDict.Add("192.168.11.41", "DB200.340");
+            jcAddressDict.Add("192.168.11.43", "DB200.342");            
+
+            //中舱机床对应加工状态
+            jcAddressDict.Add("192.168.11.29", "DB200.322"); 
+            jcAddressDict.Add("192.168.11.27", "DB200.320");           
         }
 
         /// <summary>
@@ -1488,7 +1509,7 @@ namespace IMCS.CCS.Service.Impl
                 foreach (Device onlineDevice in onlineDeviceList)
                  {
                     
-                    EquipmentMonitor alarmEquipment = equipmentMonitors.Where(x => x.IP == onlineDevice.Ip && x.Type == onlineDevice.ProtocolType).FirstOrDefault(); 
+                    EquipmentMonitor alarmEquipment = equipmentMonitors.Where(x => x.IP == onlineDevice.Ip && x.Type == onlineDevice.ProtocolType).FirstOrDefault();
 
                     if (alarmEquipment != null && alarmEquipment.Type == "HEIDEHAIN")
                     {
@@ -1499,7 +1520,7 @@ namespace IMCS.CCS.Service.Impl
                         hdhReq.Type = OpcUaActionTypeEnum.Connect.ToString();
                         var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, hdhUrlContext, hdhReq, null);
                         if (Result.IsSuccess)
-                        { 
+                        {
                             ResponseHeidhData responseData = JsonConvert.DeserializeObject<ResponseHeidhData>(Result.Message);
                             if (!string.IsNullOrEmpty(responseData.errorsInfo) && !Result.Message.Contains("无报警"))
                             {
@@ -1521,14 +1542,14 @@ namespace IMCS.CCS.Service.Impl
                         var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Get, Url + "&fun=AlmInfo", null, null);
                         if (Result.IsSuccess)
                         {
-                            
+
                             //ResponseFanucData fncReq = new ResponseFanucData();
                             List<AlmInfo> AlmMsg = JsonConvert.DeserializeObject<List<AlmInfo>>(Result.Message);
                             //List<AlmInfo> AlmMsg = fncReq.AlmMsg;                                   
                             if (AlmMsg != null && AlmMsg.Count > 0)
                             {
                                 var msgs = from o in AlmMsg select o.msg;
-                                if(msgs != null && !Result.Message.Contains("无报警"))
+                                if (msgs != null && !Result.Message.Contains("无报警"))
                                 {
                                     ProductionStatus productionStatus = new ProductionStatus();
                                     productionStatus.id = alarmEquipment.Id.ToString();
@@ -1538,19 +1559,19 @@ namespace IMCS.CCS.Service.Impl
                                     productionStatus.onlineStatus = "1";
                                     productionStatusList.Add(productionStatus);
                                 }
-                                
+
                             }
                         }
 
                     }
-                    else if(alarmEquipment != null && onlineDevice.ProtocolType == "S7_1500")
+                    else if (alarmEquipment != null && onlineDevice.ProtocolType == "S7_1500")
                     {
                         //缓存取PLCagvalue 值
                         List<CcsTagValue> tagValues = new List<CcsTagValue>();
                         string tag_value_redis_key = imcs_redis_key + onlineDevice.Ip + ":" + onlineDevice.ProtocolType;
                         var tagData = await _redisService.Database.StringGetAsync(tag_value_redis_key);
                         if (tagData.IsNullOrEmpty)
-                        { 
+                        {
                             CcsTagValue tagQuery = new CcsTagValue();
                             tagQuery.ProtocolType = onlineDevice.ProtocolType;
                             tagQuery.Ip = onlineDevice.Ip;
@@ -1566,7 +1587,10 @@ namespace IMCS.CCS.Service.Impl
                             tagValues = JsonConvert.DeserializeObject<List<CcsTagValue>>(tagData);
                         }
                         //获取机械手报警信息
-                        CcsTagValue plcWarnValue = tagValues.Where(x => x.Ip == alarmEquipment.IP && x.Address == "DB200.34").FirstOrDefault();
+                        //判断报警信息是否是今天
+                        CcsTagValue plcWarnValue = tagValues.Where(x => (x.Ip == alarmEquipment.IP && x.Address == "DB200.34" && x.Ip != "192.168.11.21" && x.Ip != "192.168.11.33" && x.UpdateTime.Date == DateTime.Today)
+                             || (x.Ip == alarmEquipment.IP && (x.Ip == "192.168.11.21" || x.Ip == "192.168.11.33") && x.Address == "DB200.22" && x.UpdateTime.Date == DateTime.Today)
+                            ).FirstOrDefault();
                         if (plcWarnValue != null && plcWarnValue.TagValue != "0")
                         { 
                             //从字典中查询具体描述
@@ -1783,5 +1807,28 @@ namespace IMCS.CCS.Service.Impl
             }
             return deviceList;
         }
+
+        /*
+        public async Task<string> SyncPlcHeartBeat()
+        {
+            CcsTagValue tagQuery = new CcsTagValue();
+            string name = Enum.GetName(typeof(ProtocalTypeEnum), ProtocalTypeEnum.S7_1500);
+            tagQuery.ProtocolType = name;
+            tagQuery.Description = "上位机心跳信号";
+            List<CcsTagValue> tagValues = _ccsTagValueService.GetList(tagQuery);
+            if (tagValues != null && tagValues.Count > 0)
+            {
+                for(CcsTagValue ccsTagValue : tagValues)
+                {
+                    //ccsTagValue.TagValue = ccsTagValue.TagValue;
+
+                }
+                //await _ccsTagValueService.Update(tagValues);
+                //await _redisService.Database.StringSetAsync(tag_value_redis_key, JsonConvert.SerializeObject(tagValues));
+            }
+            return null;
+
+        } */
     }
+
 }