| | |
| | | CommonStackerCrane commonStackerCrane = (CommonStackerCrane)context.JobDetail.JobDataMap.Get("JobParams"); |
| | | if (commonStackerCrane != null) |
| | | { |
| | | //EqptRun(commonStackerCrane); |
| | | //EqptAlive(commonStackerCrane); |
| | | //EqptStatus(commonStackerCrane); |
| | | //Console.Out.WriteLine(commonStackerCrane.DeviceName); |
| | | if (!commonStackerCrane.IsEventSubscribed) |
| | | { |
| | |
| | | { |
| | | CommonConveyorLine conveyorLine = (CommonConveyorLine)device; |
| | | //if (conveyorLine.IsOccupied(router.ChildPosi))//出库站台未被占用 |
| | | //{ |
| | | return task; |
| | | //} |
| | | { |
| | | return task; |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | return stackerCraneTaskCommand; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设备与MOM系统对接,设备上线 |
| | | /// </summary> |
| | | /// <param name="commonStackerCrane"></param> |
| | | public async void EqptRun(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | if (!commonStackerCrane.StackerOnline) |
| | | { |
| | | RequestEqptRunDto request = new RequestEqptRunDto() |
| | | { |
| | | EmployeeNo = "T00001", |
| | | EquipmentCode = commonStackerCrane.DeviceCode, |
| | | RequestTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | Software = commonStackerCrane.DeviceName, |
| | | Password = "12345", |
| | | EquipmentModel = "1" |
| | | }; |
| | | var respone = await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptRun", request.ToJsonString()); |
| | | if (respone != null) |
| | | { |
| | | var result = JsonConvert.DeserializeObject<ResponseEqptRunDto>(respone); |
| | | if (result != null && result.Success) |
| | | { |
| | | var process = _processRepository.QueryData(x => x.EquipmentName == commonStackerCrane.DeviceCode).FirstOrDefault(); |
| | | if (process == null) |
| | | { |
| | | ResponeRunDto runDto = JsonConvert.DeserializeObject<ResponeRunDto>(respone); |
| | | process = new Dt_EquipmentProcess() |
| | | { |
| | | EquipmentName = commonStackerCrane.DeviceCode, |
| | | EquipmentType = new string(commonStackerCrane.DeviceName.TakeWhile(c => !char.IsDigit(c)).ToArray()), |
| | | WipOrderNo = runDto.WipOrderNo, |
| | | ProductDesc = runDto.ProductDesc, |
| | | ProcessValue = JsonConvert.SerializeObject(result) |
| | | }; |
| | | var isResult = await _processRepository.AddDataAsync(process) > 0; |
| | | } |
| | | else |
| | | { |
| | | process.ProcessValue = JsonConvert.SerializeObject(result); |
| | | var isResult = await _processRepository.UpdateDataAsync(process); |
| | | } |
| | | commonStackerCrane.StackerOnline = true; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设备心跳 |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设备状态 |
| | | /// </summary> |
| | | /// <param name="commonStackerCrane"></param> |
| | | public async void EqptStatus(CommonStackerCrane commonStackerCrane) |
| | | { |
| | | string code = string.Empty; |
| | | RequestAlertDto requestAlert = new RequestAlertDto() |
| | | { |
| | | EmployeeNo = "T00001", |
| | | EquipmentCode = commonStackerCrane.DeviceCode, |
| | | RequestTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | Software = commonStackerCrane.DeviceName, |
| | | AlertInfo = new List<AlertInfoDto>() |
| | | }; |
| | | switch (commonStackerCrane.Status) |
| | | { |
| | | case DeviceStatus.Idle: |
| | | code = "Waiting"; |
| | | break; |
| | | |
| | | case DeviceStatus.Working: |
| | | code = "Running"; |
| | | break; |
| | | |
| | | case DeviceStatus.Fault: |
| | | code = "Alerting"; |
| | | var alert = new AlertInfoDto() |
| | | { |
| | | AlertCode = "1001", |
| | | AlertDescription = commonStackerCrane.StackerCraneStatusDes, |
| | | AlertReset = "1" |
| | | }; |
| | | requestAlert.AlertInfo.Add(alert); |
| | | |
| | | await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptAlive", requestAlert.ToJsonString()); |
| | | |
| | | break; |
| | | |
| | | case DeviceStatus.Unkonw: |
| | | code = "Down"; |
| | | break; |
| | | |
| | | case DeviceStatus.Offline: |
| | | code = "Maintenance"; |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | if (code != "Alerting") |
| | | { |
| | | requestAlert.AlertInfo = new List<AlertInfoDto>(); |
| | | var alert = new AlertInfoDto() |
| | | { |
| | | AlertCode = "1001", |
| | | AlertDescription = commonStackerCrane.StackerCraneStatusDes, |
| | | AlertReset = "0" |
| | | }; |
| | | var S= await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptAlive", requestAlert.ToJsonString()); |
| | | WriteInfo("EqptAlive", S); |
| | | } |
| | | RequestEqptStatusDto requestEqptStatus = new RequestEqptStatusDto() |
| | | { |
| | | EmployeeNo = "T00001", |
| | | EquipmentCode = "ECH001-B", |
| | | RequestTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | SessionId = Guid.NewGuid().ToString(), |
| | | Software = commonStackerCrane.DeviceName, |
| | | ChangeTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), |
| | | Description = commonStackerCrane.StackerCraneStatusDes, |
| | | LocationID = "NA", |
| | | ReasonCode = "123", |
| | | StatusCode = code |
| | | }; |
| | | var respone = await HttpHelper.PostAsync("http://ts-momapp01:12020/api/MachineIntegration/EqptStatus", requestEqptStatus.ToJsonString()); |
| | | WriteInfo("EqptStatus", respone); |
| | | } |
| | | } |
| | | } |