/// <summary> /// put实时数据 /// </summary> /// <param name="zhgd_Iot_Lift_Current"></param> static void Put_lift_current(Zhgd_iot_lift_current zhgd_Iot_Lift_Current) { try { string url = "https://111.56.13.177:52001/zhgd_iot-" + DateTime.Now.ToString("yyyyMMdd") + "/_doc/"; string senddata = JsonConvert.SerializeObject(zhgd_Iot_Lift_Current); Restful.Post(url, senddata); } catch (Exception ex) { ToolAPI.XMLOperation.WriteLogXmlNoTail("升降机Put_lift_current异常", ex.Message); } }
/// <summary> /// 构造 /// </summary> /// <param name="zhgd_Iot_Lift_Current"></param> //public static Zhgd_iot_lift_working Get_Zhgd_iot_lift_working(Zhgd_iot_lift_current zhgd_Iot_Lift_Current) //{ // Zhgd_iot_lift_working z = zhgd_Iot_Lift_Current as Zhgd_iot_lift_working; // return z; //} public static Zhgd_iot_lift_working Get_Zhgd_iot_lift_working(Zhgd_iot_lift_current parent) { Zhgd_iot_lift_working child = new Zhgd_iot_lift_working(); var ParentType = typeof(Zhgd_iot_lift_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); }
public string Get_work_cycles_no(Zhgd_iot_lift_current zhgd_Iot_Lift_Current) { //速度大于0就认为触发了工作循环得条件了 if (zhgd_Iot_Lift_Current.speed > 0) { if (zhgd_Iot_Lift_Current.is_warning == "Y") { is_work_cycles_warning = "Y"; foreach (string type in zhgd_Iot_Lift_Current.warning_type) { if (!work_cycles_warning_type.Contains(type)) { work_cycles_warning_type.Add(type); } } } if (work_cycles_no == "0") { work_cycles_no = DPC_Tool.GetTimeStamp().ToString(); } } //不满足工作循环得条件 else { //不等于0说明这次工作循环该结束了 if (work_cycles_no != "0") { //put运行数据到ES里 Zhgd_iot_lift_working ztw = Zhgd_iot_lift_working.Get_Zhgd_iot_lift_working(zhgd_Iot_Lift_Current); ztw.work_cycles_warning = is_work_cycles_warning; ztw.work_cycles_no = work_cycles_no; ztw.warning_type = work_cycles_warning_type.ToArray(); //异步运行 Lift_operation.Put_work_cycles_event.BeginInvoke(ztw, null, null); //进行初始化操作 work_cycles_no = "0"; is_work_cycles_warning = "N"; } } return(work_cycles_no); }
/// <summary> /// 进行数据发送 /// </summary> /// <param name="sn">设备序列码</param> /// <returns></returns> public static void Send_Lift_Current(Zhgd_iot_lift_current zhgd_Iot_Lift_Current) { try { //获取redis中的项目 string key = "equipment:projectid:" + Equipment_type.升降机 + ":" + zhgd_Iot_Lift_Current.sn; string value = RedisCacheHelper.Get <string>(key); if (value != null) { zhgd_Iot_Lift_Current.create_time = DPC_Tool.GetTimeStamp(); zhgd_Iot_Lift_Current.project_id = value; zhgd_Iot_Lift_Current.equipment_type = Equipment_type.升降机; //这里面应该还有工作运行的判断以及运行序列码得赋值 if (working_state.ContainsKey(zhgd_Iot_Lift_Current.sn)) { zhgd_Iot_Lift_Current.work_cycles_no = working_state[zhgd_Iot_Lift_Current.sn].Get_work_cycles_no(zhgd_Iot_Lift_Current); } else { working_state.Add(zhgd_Iot_Lift_Current.sn, new Zhgd_iot_lift_working_state(zhgd_Iot_Lift_Current.sn)); zhgd_Iot_Lift_Current.work_cycles_no = working_state[zhgd_Iot_Lift_Current.sn].Get_work_cycles_no(zhgd_Iot_Lift_Current); } //先执行rabbitMQ 进行推送 RabbitMQ.producer("Lift_forward", JsonConvert.SerializeObject(zhgd_Iot_Lift_Current)); //执行put方法,把实时数据推走 Put_lift_current(zhgd_Iot_Lift_Current); //进行司机记录推送 Get_equminet_driver(zhgd_Iot_Lift_Current.sn, zhgd_Iot_Lift_Current.driver_id_code); //更新redis DPC.Lift_operation.Update_equminet_last_online_time(zhgd_Iot_Lift_Current.sn, zhgd_Iot_Lift_Current.timestamp); } } catch (Exception ex) { ToolAPI.XMLOperation.WriteLogXmlNoTail("升降机Send_Lift_Current异常", ex.Message); } }