|
@@ -28,11 +28,15 @@ using Flurl.Util;
|
|
|
using HslCommunication.Enthernet;
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
+using StackExchange.Redis;
|
|
|
+using IMCS.CCS.Common.Redis;
|
|
|
|
|
|
namespace IMCS.CCS.Services
|
|
|
{
|
|
|
public class HttpRequestService : IHttpRequestService
|
|
|
{
|
|
|
+ private readonly IRedisService _redisService;
|
|
|
+
|
|
|
private readonly IDeviceService _deviceService;
|
|
|
|
|
|
private readonly ITaskCallbackService _taskCallbackService;
|
|
@@ -67,12 +71,17 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
private static Dictionary<string, string> ipDict = new Dictionary<string, string>();
|
|
|
|
|
|
- public HttpRequestService(IDeviceService deviceService, ITaskCallbackService taskCallbackService,
|
|
|
+ private static List<string> jList = new List<string>();
|
|
|
+
|
|
|
+ private static Dictionary<string, string> jIp = new Dictionary<string, string>();
|
|
|
+
|
|
|
+ public HttpRequestService(IRedisService redisService, IDeviceService deviceService, ITaskCallbackService taskCallbackService,
|
|
|
ICcsActionService ccsActionService, ICcsTagValueService ccsTagValueService,
|
|
|
IEquipmentMonitorService equipmentMonitorService, ICcsActionAddressService ccsActionAddressService,
|
|
|
IApiRequestService apiRequestService, ITaskJobService taskJobService,
|
|
|
IConfiguration configuration)
|
|
|
{
|
|
|
+ _redisService = redisService;
|
|
|
_deviceService = deviceService;
|
|
|
_taskCallbackService = taskCallbackService;
|
|
|
_ccsActionService = ccsActionService;
|
|
@@ -116,6 +125,20 @@ namespace IMCS.CCS.Services
|
|
|
ipDict.Add("10.161.30.246", "DB1.118");
|
|
|
ipDict.Add("10.161.30.247", "DB1.120");
|
|
|
}
|
|
|
+ if (jList.Count == 0)
|
|
|
+ {
|
|
|
+ jList.Add("1");
|
|
|
+ jList.Add("2");
|
|
|
+ jList.Add("3");
|
|
|
+ }
|
|
|
+ if (jIp.Count == 0)
|
|
|
+ {
|
|
|
+ Console.WriteLine("jIp:" + jIp.Count);
|
|
|
+ jIp.Add("1","10.161.30.245");
|
|
|
+ jIp.Add("2","10.161.30.246");
|
|
|
+ jIp.Add("3","10.161.30.247");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -549,6 +572,41 @@ namespace IMCS.CCS.Services
|
|
|
await _taskCallbackService.CreateOrUpdateAndCache(taskCallbackData);
|
|
|
Log.Instance.WriteLogAdd(EnumHelper.GetDescription(ActionTypeEnum.RobotAction) + "操作成功===>>" + JsonConvert.SerializeObject(req)
|
|
|
, EnumHelper.GetDescription(ActionTypeEnum.RobotAction));
|
|
|
+
|
|
|
+ //try catch 包起来不影响正常流程
|
|
|
+ try
|
|
|
+ {
|
|
|
+ //下发任务成功后,查询千机质检结果
|
|
|
+ //如果源目标为是机床,才去查询
|
|
|
+ if (jList.Contains(req.data.location))
|
|
|
+ {
|
|
|
+ RequestOpcUaData deviceReq = new RequestOpcUaData();
|
|
|
+ deviceReq.ServerUrl = "opc.tcp://" + jIp[req.data.location] + ":4840";
|
|
|
+ deviceReq.UserName = "OpcUaClient";
|
|
|
+ deviceReq.Password = "12345678";
|
|
|
+ deviceReq.Type = OpcUaActionTypeEnum.Collect.ToString();
|
|
|
+ deviceReq.Ip = jIp[req.data.location];
|
|
|
+ deviceReq.check = "1";
|
|
|
+ var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Post, mazakUrlContext, deviceReq, null);
|
|
|
+ ResponseOpcUaData responseOpcUaData = JsonConvert.DeserializeObject<ResponseOpcUaData>(Result.Message);
|
|
|
+ if (!Result.IsSuccess || !responseOpcUaData.result)
|
|
|
+ {
|
|
|
+ if (responseOpcUaData.values != null)
|
|
|
+ {
|
|
|
+ await _redisService.Database.StringSetAsync("QJ:" + req.taskNodeId, responseOpcUaData.values[0]);
|
|
|
+ }
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.RobotAction + "查询千机质检结果===>>" + JsonConvert.SerializeObject(responseOpcUaData),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.RobotAction));
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(Exception e)
|
|
|
+ {
|
|
|
+ Log.Instance.WriteLogAdd(ActionTypeEnum.RobotAction + "查询千机质检结果异常===>>" + e.StackTrace + JsonConvert.SerializeObject(req),
|
|
|
+ EnumHelper.GetDescription(ActionTypeEnum.RobotAction));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return responseData;
|
|
|
}
|
|
|
catch (Exception ex)
|