|
|
@@ -39,6 +39,8 @@ namespace IMCS.CCS.Services
|
|
|
|
|
|
private readonly ITaskJobService _taskJobService;
|
|
|
|
|
|
+ private readonly IDictionaryService _dictionaryService;
|
|
|
+
|
|
|
private int SLEEP_TIME = 1000;
|
|
|
|
|
|
string LocalPath = "D:\\PROG";
|
|
|
@@ -67,7 +69,7 @@ namespace IMCS.CCS.Services
|
|
|
public HttpRequestService(IDeviceService deviceService, ITaskCallbackService taskCallbackService,
|
|
|
ICcsActionService ccsActionService, ICcsTagValueService ccsTagValueService,
|
|
|
IEquipmentMonitorService equipmentMonitorService, ICcsActionAddressService ccsActionAddressService,
|
|
|
- IApiRequestService apiRequestService, ITaskJobService taskJobService,
|
|
|
+ IApiRequestService apiRequestService, ITaskJobService taskJobService, IDictionaryService dictionaryService,
|
|
|
IConfiguration configuration)
|
|
|
{
|
|
|
_deviceService = deviceService;
|
|
|
@@ -78,6 +80,7 @@ namespace IMCS.CCS.Services
|
|
|
_ccsActionAddressService = ccsActionAddressService;
|
|
|
_apiRequestService = apiRequestService;
|
|
|
_taskJobService = taskJobService;
|
|
|
+ _dictionaryService = dictionaryService;
|
|
|
Configuration = configuration;
|
|
|
fanucUrlContext = Configuration.GetConnectionString("fanucUrlContext");
|
|
|
opcuacUrlContext = Configuration.GetConnectionString("opcuacUrlContext");
|
|
|
@@ -2799,6 +2802,102 @@ namespace IMCS.CCS.Services
|
|
|
}
|
|
|
|
|
|
|
|
|
+ public async Task<List<ProductionStatus>> GetLineWarn(RequestData<Object> req)
|
|
|
+ {
|
|
|
+ List<ProductionStatus> list = new List<ProductionStatus>();
|
|
|
+ List<CcsTagValue> tagValues = new List<CcsTagValue>();
|
|
|
+ List<Dictionary> dictList = new List<Dictionary>();
|
|
|
+ CcsTagValue tagQuery = new CcsTagValue();
|
|
|
+ tagQuery.ProtocolType = "S7_1500";
|
|
|
+ tagQuery.Description = "PLC报警内容";
|
|
|
+ tagValues = _ccsTagValueService.GetList(tagQuery);
|
|
|
+ tagValues = tagValues.Where(x => x.TagValue != "0").ToList();
|
|
|
+ foreach(CcsTagValue tagValue in tagValues)
|
|
|
+ {
|
|
|
+ Dictionary ccsDictionary = new Dictionary();
|
|
|
+ ccsDictionary.Type = tagValue.Ip;
|
|
|
+ ccsDictionary.Code = tagValue.TagValue.Trim();
|
|
|
+ dictList = await _dictionaryService.GetList(ccsDictionary);
|
|
|
+ Dictionary dicObj = dictList.Where(x => x.state).FirstOrDefault();
|
|
|
+
|
|
|
+ ProductionStatus productionStatus = new ProductionStatus();
|
|
|
+ productionStatus.ip = tagValue.Ip;
|
|
|
+ productionStatus.onlineStatus = "3";
|
|
|
+ productionStatus.alarmState = true;
|
|
|
+ productionStatus.alertMsg = dicObj.Description;
|
|
|
+ list.Add(productionStatus);
|
|
|
+ }
|
|
|
+ //判断指定报警设备的错误信息
|
|
|
+ if (!String.IsNullOrEmpty(req.url))
|
|
|
+ {
|
|
|
+ String[] ips = req.url.Split(",");
|
|
|
+ List<EquipmentMonitor> equipmentMonitors = new List<EquipmentMonitor>();
|
|
|
+ equipmentMonitors = await _equipmentMonitorService.GetList();
|
|
|
+ equipmentMonitors = equipmentMonitors.Where(x => ips.Contains(x.IP)).ToList();
|
|
|
+ if (equipmentMonitors.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (EquipmentMonitor alarmEquipment in equipmentMonitors)
|
|
|
+ {
|
|
|
+ List<Device> deviceList = _deviceService.GetDeviceList();
|
|
|
+ Device onlineDevice = deviceList.Where(x => x.Ip == alarmEquipment.IP).FirstOrDefault();
|
|
|
+ if (alarmEquipment != null && alarmEquipment.Type == "HEIDEHAIN")
|
|
|
+ {
|
|
|
+ RequestHeidhData hdhReq = new RequestHeidhData();
|
|
|
+ hdhReq.ServerUrl = onlineDevice.ServerUrl;
|
|
|
+ hdhReq.MachineName = onlineDevice.UserName;
|
|
|
+ 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("无报警"))
|
|
|
+ {
|
|
|
+ ProductionStatus productionStatus = new ProductionStatus();
|
|
|
+ productionStatus.id = alarmEquipment.Id.ToString();
|
|
|
+ productionStatus.ip = onlineDevice.Ip;
|
|
|
+ productionStatus.alertMsg = responseData.errorsInfo;
|
|
|
+ productionStatus.alarmState = true;//报警
|
|
|
+ productionStatus.onlineStatus = "1";
|
|
|
+ list.Add(productionStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (alarmEquipment != null && alarmEquipment.Type == "FANUC")
|
|
|
+ {
|
|
|
+ string Url = fanucUrlContext + "?ip=" + onlineDevice.Ip + "&port=" + onlineDevice.Port;
|
|
|
+ //调用发那科接口
|
|
|
+ var Result = await _apiRequestService.RequestAsync(RequsetModeEnum.Get, Url + "&fun=AlmInfo", null, null);
|
|
|
+ if (Result.IsSuccess)
|
|
|
+ {
|
|
|
+ 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("无报警"))
|
|
|
+ {
|
|
|
+ ProductionStatus productionStatus = new ProductionStatus();
|
|
|
+ productionStatus.id = alarmEquipment.Id.ToString();
|
|
|
+ productionStatus.ip = onlineDevice.Ip;
|
|
|
+ productionStatus.alertMsg = string.Join(",", msgs.ToArray());
|
|
|
+ productionStatus.alarmState = true;//报警
|
|
|
+ productionStatus.onlineStatus = "1";
|
|
|
+ list.Add(productionStatus);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//移动取放 条件限制
|
|
|
private async Task<bool> robotActionCondition(string ip ,string isAllowFlag,string currentAction)
|
|
|
{
|