wang.sq@aliyun.com 1 год назад
Родитель
Сommit
15afb8f98d

+ 2 - 1
IMCS_CCS/Entitys/Device.cs

@@ -64,6 +64,7 @@ namespace IMCS.CCS.Entitys
         S7_300,
         FTP,
         FANUC,
-        HEIDEHAIN
+        HEIDEHAIN,
+        KEDE
     }
 }

+ 36 - 0
IMCS_CCS/Model/vo/RequestKeDeData.cs

@@ -0,0 +1,36 @@
+namespace IMCS_CCS.Model.vo
+{
+    public class RequestKeDeData
+    {
+
+        // 服务ip地址
+        public string serverUrl
+        { get; set; }
+
+        // 调用类型 1:数据采集  2:上传程序并设置为主程序 4:删除程序
+        public string type 
+        { get; set; }
+
+        // NC程序源位置,完整地址
+        public string localFilePath 
+        { get; set; }
+
+        // NC程序目标位置,需拼接上文件名
+        public string remoteFilePath
+        { get; set; }
+
+        // 用户名
+        public string userName
+        { get; set; }
+
+        // 密码
+        public string password
+        { get; set; }
+
+        // 端口
+        public string port
+        { get; set; }
+
+
+    }
+}

+ 38 - 4
IMCS_CCS/Service/Impl/HttpRequestService.cs

@@ -57,6 +57,9 @@ namespace IMCS.CCS.Services
 
         private string ecsRootUrlContext;
 
+        // 科德httpserver接口地址
+        private string kedeContext;
+
         public IConfiguration Configuration { get; }
 
         private readonly IApiRequestService _apiRequestService;
@@ -83,6 +86,7 @@ namespace IMCS.CCS.Services
             ftpUserContext = Configuration.GetConnectionString("FTPUser");
             ftpPwdContext = Configuration.GetConnectionString("FTPPwd");
             ecsRootUrlContext = Configuration.GetConnectionString("ecsRootUrlContext");
+            kedeContext = Configuration.GetConnectionString("kedeContext");
         }
 
         /// <summary>
@@ -887,8 +891,10 @@ namespace IMCS.CCS.Services
                                             && x.ProtocolType.Equals(ProtocalTypeEnum.FANUC.ToString())).FirstOrDefault();
                 Device deviceHeidenhain = devices.Where(x => x.Ip.Equals(req.url)
                                             && x.ProtocolType.Equals(ProtocalTypeEnum.HEIDEHAIN.ToString())).FirstOrDefault();
+                Device deviceKeDe = devices.Where(x => x.Ip.Equals(req.url)
+                                            && x.ProtocolType.Equals(ProtocalTypeEnum.KEDE.ToString())).FirstOrDefault();
 
-                if (deviceOpcUa == null && deviceFanuc == null && deviceHeidenhain == null)
+                if (deviceOpcUa == null && deviceFanuc == null && deviceHeidenhain == null && deviceKeDe == null)
                 {
                     Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "设备已离线===>>" + JsonConvert.SerializeObject(req),
                     EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
@@ -931,7 +937,8 @@ namespace IMCS.CCS.Services
                         return responseData;
                     }
 
-                }else if(deviceHeidenhain != null)
+                }
+                else if(deviceHeidenhain != null)
                 { 
                     //海德汉程序上传后,同时写入编号 
                     if (string.IsNullOrEmpty(req.data.fileName))
@@ -1002,8 +1009,35 @@ namespace IMCS.CCS.Services
                         } 
                         //return responseData;
                     }
-                   
-                   
+
+
+                }
+                else if (deviceKeDe != null)
+                {
+                    Console.WriteLine("==============科德机床上传程序并设置此程序为主程序=================");
+                    RequestKeDeData kedeReq = new RequestKeDeData();
+                    kedeReq.serverUrl = deviceKeDe.ServerUrl;
+                    kedeReq.type = "2";
+                    kedeReq.userName = deviceKeDe.UserName;
+                    kedeReq.password = deviceKeDe.Password;
+                    kedeReq.port = deviceKeDe.Port;
+                    kedeReq.localFilePath = req.data.fileName;
+                    kedeReq.remoteFilePath = req.data.remotePath;
+
+                    Console.WriteLine("nc上传请求地址{0},参数{1}", kedeContext, kedeReq);
+
+                    var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, kedeContext, kedeReq, null);
+                    ResponseOpcUaData responseOpcUaData = JsonConvert.DeserializeObject<ResponseOpcUaData>(Result.Message);
+                    if (!Result.IsSuccess || !responseOpcUaData.result)
+                    {
+                        Log.Instance.WriteLogAdd(ActionTypeEnum.UploadFile + "上传异常===>>" + JsonConvert.SerializeObject(req),
+                       EnumHelper.GetDescription(ActionTypeEnum.UploadFile));
+                        responseData.result = "false";
+                        return responseData;
+                    }
+
+
+
                 }
 
                 //插入回调

+ 7 - 6
IMCS_CCS/appsettings.json

@@ -11,21 +11,21 @@
   "TokenValue": "123456",
   "JwtKeyName": "JwtKeyName",
   "JwtSecurityKey": "1CC76841-F25D-4389-89FE-0F9451163CF1",
-  //Json 存储方式 配置
+  //Json 瀛樺偍鏂瑰紡 閰嶇疆
   "DbPath": {
     "Project": "/db/Projects.json",
     "Tasks": "/db/Tasks.json"
   },
-  //是否使用 Redis 存储 1是 0否 默认使用 json 文件
+  //鏄�惁浣跨敤 Redis 瀛樺偍 1鏄� 0鍚� 榛樿�浣跨敤 json 鏂囦欢
   "UseRedis": "0",
-  //Redis 存储方式 配置
+  //Redis 瀛樺偍鏂瑰紡 閰嶇疆
   "RedisDbPath": {
     "Project": "IMCS.CCS:Project",
     "Tasks": "IMCS.CCS:Tasks"
   },
-  //Redis 连接字符串
+  //Redis 杩炴帴瀛楃�涓�
   "RedisConnectionString": "127.0.0.1:6379,password=123456,defaultDatabase=0",
-  //数据连接配置
+  //鏁版嵁杩炴帴閰嶇疆
   "ConnectionStrings": {
     "mysqlContext": "server=localhost;port=3306;database=ccs_yj;uid=root;pwd=adminoyq;CharSet=utf8;Allow Zero Datetime=True",
     "ecsUrlContext": "http://127.0.0.1:9099/api/authority/taskNode/taskNodeCallback",
@@ -38,6 +38,7 @@
     "FTPPwd": "test",
     "fanucUrlContext": "http://localhost:5100/fanuc/",
     "opcuacUrlContext": "http://localhost:8010/opcua/",
-    "hdhUrlContext": "http://localhost:8011/heidenhain/"
+    "hdhUrlContext": "http://localhost:8011/heidenhain/",
+    "kedeContext": "http://localhost:8020/opcua/"
   }
 }