public string Get_work_cycles_no(Zhgd_iot_tower_current zhgd_Iot_Tower_Current) { //大于0.2t就认为触发了工作循环得条件了 if (zhgd_Iot_Tower_Current.weight > 0.2) { if (zhgd_Iot_Tower_Current.is_warning == "Y") { is_work_cycles_warning = "Y"; foreach (string type in zhgd_Iot_Tower_Current.warning_type) { if (!work_cycles_warning_type.Contains(type)) { work_cycles_warning_type.Add(type); } } } if (work_cycles_no != "0") { if (last_height != zhgd_Iot_Tower_Current.height || last_range != zhgd_Iot_Tower_Current.range || last_rotation != zhgd_Iot_Tower_Current.rotation) { is_change_height = true; } last_height = zhgd_Iot_Tower_Current.height; last_range = zhgd_Iot_Tower_Current.range; last_rotation = zhgd_Iot_Tower_Current.rotation; } else { work_cycles_no = DPC_Tool.GetTimeStamp().ToString(); is_change_height = false; last_height = zhgd_Iot_Tower_Current.height; last_range = zhgd_Iot_Tower_Current.range; last_rotation = zhgd_Iot_Tower_Current.rotation; } } //不满足工作循环得条件 else { //不等于0说明这次工作循环该结束了 if (work_cycles_no != "0") { //put运行数据到ES里 Zhgd_iot_tower_working ztw = Zhgd_iot_tower_working.Get_Zhgd_iot_tower_working(zhgd_Iot_Tower_Current); ztw.work_cycles_warning = is_work_cycles_warning; ztw.work_cycles_no = work_cycles_no; ztw.warning_type = work_cycles_warning_type.ToArray(); //异步运行 Tower_operation.Put_work_cycles_event.BeginInvoke(ztw, null, null); //进行初始化操作 work_cycles_no = "0"; is_work_cycles_warning = "N"; is_change_height = false; last_height = 0; last_range = 0; last_rotation = 0; } } return(work_cycles_no); }
/// <summary> /// put塔吊实时数据 /// </summary> /// <param name="zhgd_Iot_Tower_Current"></param> static void Put_tower_current(Zhgd_iot_tower_current zhgd_Iot_Tower_Current) { try { string url = "https://111.56.13.177:52001/zhgd_iot-" + DateTime.Now.ToString("yyyyMMdd") + "/_doc/"; string senddata = JsonConvert.SerializeObject(zhgd_Iot_Tower_Current); Restful.Post(url, senddata); } catch (Exception ex) { ToolAPI.XMLOperation.WriteLogXmlNoTail("塔吊Put_tower_current异常", ex.Message); } }
/// <summary> /// 构造 /// </summary> /// <param name="zhgd_Iot_Tower_Current"></param> //public static Zhgd_iot_tower_working Get_Zhgd_iot_tower_working(Zhgd_iot_tower_current zhgd_Iot_Tower_Current) //{ // Zhgd_iot_tower_working z = new Zhgd_iot_tower_working(); // Zhgd_iot_tower_current zhgd_Iot_Tower_Currenta = z; // zhgd_Iot_Tower_Currenta = zhgd_Iot_Tower_Current; // z.work_cycles_warning = ""; // return z; //} public static Zhgd_iot_tower_working Get_Zhgd_iot_tower_working(Zhgd_iot_tower_current parent) { Zhgd_iot_tower_working child = new Zhgd_iot_tower_working(); var ParentType = typeof(Zhgd_iot_tower_current); var Properties = ParentType.GetProperties(); foreach (var Propertie in Properties) { if (Propertie.CanRead && Propertie.CanWrite) { Propertie.SetValue(child, Propertie.GetValue(parent, null), null); } } return(child); }
/// <summary> /// 进行数据发送 /// </summary> /// <param name="sn">设备序列码</param> /// <returns></returns> public static void Send_tower_Current(Zhgd_iot_tower_current zhgd_Iot_Tower_Current) { try { //获取redis中的项目 string key = "equipment:projectid:" + Equipment_type.塔机 + ":" + zhgd_Iot_Tower_Current.sn; string value = RedisCacheHelper.Get <string>(key); if (value != null) { zhgd_Iot_Tower_Current.create_time = DPC_Tool.GetTimeStamp(); zhgd_Iot_Tower_Current.project_id = value; zhgd_Iot_Tower_Current.equipment_type = Equipment_type.塔机; //这里面应该还有工作运行的判断以及运行序列码得赋值 if (working_state.ContainsKey(zhgd_Iot_Tower_Current.sn)) { zhgd_Iot_Tower_Current.work_cycles_no = working_state[zhgd_Iot_Tower_Current.sn].Get_work_cycles_no(zhgd_Iot_Tower_Current); } else { working_state.Add(zhgd_Iot_Tower_Current.sn, new Zhgd_iot_tower_working_state(zhgd_Iot_Tower_Current.sn)); zhgd_Iot_Tower_Current.work_cycles_no = working_state[zhgd_Iot_Tower_Current.sn].Get_work_cycles_no(zhgd_Iot_Tower_Current); } //先执行rabbitMQ 进行推送 RabbitMQ.producer("Tower_forward", JsonConvert.SerializeObject(zhgd_Iot_Tower_Current)); //执行put方法,把实时数据推走 Put_tower_current(zhgd_Iot_Tower_Current); //进行司机记录推送 Get_equminet_driver(zhgd_Iot_Tower_Current.sn, zhgd_Iot_Tower_Current.driver_id_code); //更新redis DPC.Tower_operation.Update_equminet_last_online_time(zhgd_Iot_Tower_Current.sn, zhgd_Iot_Tower_Current.timestamp); } } catch (Exception ex) { ToolAPI.XMLOperation.WriteLogXmlNoTail("塔吊Get_Zhgd_iot_tower_current异常", ex.Message); } }