示例#1
0
 /// <summary>
 /// 进行数据发送
 /// </summary>
 /// <param name="sn">设备序列码</param>
 /// <returns></returns>
 public static void Send_discharge_Current(Zhgd_iot_discharge_current zhgd_Iot_discharge_Current)
 {
     try
     {
         //获取redis中的项目
         string key   = "equipment:projectid:" + Equipment_type.卸料平台 + ":" + zhgd_Iot_discharge_Current.sn;
         string value = RedisCacheHelper.Get <string>(key);
         if (value != null)
         {
             zhgd_Iot_discharge_Current.create_time    = DPC_Tool.GetTimeStamp();
             zhgd_Iot_discharge_Current.project_id     = value;
             zhgd_Iot_discharge_Current.equipment_type = Equipment_type.卸料平台;
             //这里面应该还有工作运行的判断以及运行序列码得赋值
             if (working_state.ContainsKey(zhgd_Iot_discharge_Current.sn))
             {
                 zhgd_Iot_discharge_Current.work_cycles_no = working_state[zhgd_Iot_discharge_Current.sn].Get_work_cycles_no(zhgd_Iot_discharge_Current);
             }
             else
             {
                 working_state.Add(zhgd_Iot_discharge_Current.sn, new Zhgd_iot_discharge_working_state(zhgd_Iot_discharge_Current.sn));
                 zhgd_Iot_discharge_Current.work_cycles_no = working_state[zhgd_Iot_discharge_Current.sn].Get_work_cycles_no(zhgd_Iot_discharge_Current);
             }
             //先执行rabbitMQ 进行推送
             RabbitMQ.producer("Discharge_forward", JsonConvert.SerializeObject(zhgd_Iot_discharge_Current));
             //执行put方法,把实时数据推走
             Put_discharge_current(zhgd_Iot_discharge_Current);
             //更新redis
             DPC.Discharge_operation.Update_equminet_last_online_time(zhgd_Iot_discharge_Current.sn, zhgd_Iot_discharge_Current.timestamp);
         }
     }
     catch (Exception ex)
     {
         ToolAPI.XMLOperation.WriteLogXmlNoTail("卸料Send_discharge_Current异常", ex.Message);
     }
 }
        public static void Update_equminet_driver(string sn, string driver_code)
        {
            string key   = "equipment:driver:" + Equipment_type.升降机 + ":" + sn;
            string value = driver_code + "&" + DateTime.Now.ToString();

            RedisCacheHelper.Add(key, value);
        }
示例#3
0
        /// <summary>
        /// 进行数据发送
        /// </summary>
        /// <returns></returns>
        public static void Send_personnel_records(Zhgd_iot_personnel_records zhgd_Iot_Personnel_Records)
        {
            try
            {
                //获取redis中的项目
                string key = "equipment:projectid:" + Equipment_type.人员管理 + ":" + zhgd_Iot_Personnel_Records.project_code;
                string value = RedisCacheHelper.Get<string>(key);
                if (value != null)
                {
                    zhgd_Iot_Personnel_Records.create_time = DPC_Tool.GetTimeStamp();
                    zhgd_Iot_Personnel_Records.project_id = value;
                    zhgd_Iot_Personnel_Records.equipment_type = Equipment_type.人员管理;

                    //先执行rabbitMQ 进行推送
                    RabbitMQ.producer("Personnel_forward", JsonConvert.SerializeObject(zhgd_Iot_Personnel_Records));

                    //执行put方法,把实时数据推走
                    Put_Send_personnel_records(zhgd_Iot_Personnel_Records);
                }
            }
            catch (Exception ex)
            {
                ToolAPI.XMLOperation.WriteLogXmlNoTail("人员管理Send_personnel_records异常", ex.Message);
            }
        }
示例#4
0
 static void Sync_equipment_project_func()
 {
     try
     {
         DbHelperSQL dbNet;
         var connectionString = ToolAPI.INIOperate.IniReadValue("netSqlGroup", "connectionString", Application.StartupPath + "\\Config.ini");
         string[] connectionStringtearm = connectionString.Split('&');
         if (connectionStringtearm != null && connectionStringtearm.Length == 5)
             dbNet = new DbHelperSQL(string.Format("Data Source={0};Port={1};Database={2};User={3};Password={4}", connectionStringtearm[0], connectionStringtearm[1], connectionStringtearm[2], connectionStringtearm[3], connectionStringtearm[4]), DbProviderType.MySql);
         else
             dbNet = new DbHelperSQL(string.Format("Data Source={0};Port={1};Database={2};User={3};Password={4}", "172.24.108.167", "3306", "gd_db_v2", "wisdom_root", "JIwLi5j40SY#o1Et"), DbProviderType.MySql);
         Dictionary<string, string> Equipment_project_temp = new Dictionary<string, string>();
         string sql = "select project_code,project_id from biz_project";
         DataTable dt = dbNet.ExecuteDataTable(sql, null);
         if (dt != null && dt.Rows.Count > 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 string project_personnel_id = dr["project_code"].ToString();
                 string project_id = dr["project_id"].ToString();
                 //存入redis中
                 string key = "equipment:projectid:" + Equipment_type.人员管理 + ":" + project_personnel_id;
                 TimeSpan timeSpan = new TimeSpan(0, 0, 300);
                 RedisCacheHelper.Add(key, project_id, timeSpan);
             }
         }
     }
     catch (Exception ex)
     {
         ToolAPI.XMLOperation.WriteLogXmlNoTail("人员管理Sync_equipment_project异常", ex.Message);
     }
 }
        /// <summary>
        /// 进行数据发送
        /// </summary>
        /// <param name="sn">设备序列码</param>
        /// <returns></returns>
        public static void Send_dust_noise_Current(Zhgd_iot_dust_noise_current zhgd_Iot_dust_noise_Current)
        {
            try
            {
                //获取redis中的项目
                string key   = "equipment:projectid:" + Equipment_type.扬尘噪音 + ":" + zhgd_Iot_dust_noise_Current.sn;
                string value = RedisCacheHelper.Get <string>(key);
                if (value != null)
                {
                    string[] item = value.Split('&');
                    zhgd_Iot_dust_noise_Current.create_time    = DPC_Tool.GetTimeStamp();
                    zhgd_Iot_dust_noise_Current.project_id     = item[0];
                    zhgd_Iot_dust_noise_Current.equipment_type = Equipment_type.扬尘噪音;
                    //报警判断
                    zhgd_Iot_dust_noise_Current.is_warning = "N";
                    List <string> vs = new List <string>();
                    if (zhgd_Iot_dust_noise_Current.pm2_5 > double.Parse(item[1]))
                    {
                        vs.Add(Warning_type.PM2_5报警);
                        zhgd_Iot_dust_noise_Current.is_warning = "Y";
                    }
                    if (zhgd_Iot_dust_noise_Current.pm10 > double.Parse(item[2]))
                    {
                        vs.Add(Warning_type.PM10报警);
                        zhgd_Iot_dust_noise_Current.is_warning = "Y";
                    }
                    if (zhgd_Iot_dust_noise_Current.noise > double.Parse(item[3]))
                    {
                        vs.Add(Warning_type.噪音告警);
                        zhgd_Iot_dust_noise_Current.is_warning = "Y";
                    }
                    zhgd_Iot_dust_noise_Current.warning_type = vs.ToArray();
                    //进行AQI计算
                    zhgd_Iot_dust_noise_Current.aqi = Get_aqi(zhgd_Iot_dust_noise_Current.pm2_5);

                    //先执行rabbitMQ 进行推送
                    RabbitMQ.producer("Dust_noise_forward", JsonConvert.SerializeObject(zhgd_Iot_dust_noise_Current));
                    //执行put方法,把实时数据推走
                    Put_dust_noise_current(zhgd_Iot_dust_noise_Current);
                    //更新在线时间
                    Update_equminet_last_online_time(zhgd_Iot_dust_noise_Current.sn, zhgd_Iot_dust_noise_Current.timestamp);
                }
            }
            catch (Exception ex)
            {
                ToolAPI.XMLOperation.WriteLogXmlNoTail("扬尘噪音Send_dust_noise_Current异常", ex.Message);
            }
        }
 static void Sync_equipment_project_func()
 {
     try
     {
         DbHelperSQL dbNet;
         var         connectionString      = ToolAPI.INIOperate.IniReadValue("netSqlGroup", "connectionString", Application.StartupPath + "\\Config.ini");
         string[]    connectionStringtearm = connectionString.Split('&');
         if (connectionStringtearm != null && connectionStringtearm.Length == 5)
         {
             dbNet = new DbHelperSQL(string.Format("Data Source={0};Port={1};Database={2};User={3};Password={4}", connectionStringtearm[0], connectionStringtearm[1], connectionStringtearm[2], connectionStringtearm[3], connectionStringtearm[4]), DbProviderType.MySql);
         }
         else
         {
             dbNet = new DbHelperSQL(string.Format("Data Source={0};Port={1};Database={2};User={3};Password={4}", "172.24.108.167", "3306", "gd_db_v2", "wisdom_root", "JIwLi5j40SY#o1Et"), DbProviderType.MySql);
         }
         Dictionary <string, string> Equipment_project_temp = new Dictionary <string, string>();
         string    sql = "select bpe.equipment_sn,bpe.project_id,bwn.pm25_warn_value,bwn.pm10_warn_value,bwn.noise_warn_value from biz_warn_config_dust_noise as bwn,biz_project_equipment as bpe where bwn.equipment_id = bpe.equipment_id and bpe.equipment_type='" + Equipment_type.扬尘噪音 + "'";
         DataTable dt  = dbNet.ExecuteDataTable(sql, null);
         if (dt != null && dt.Rows.Count > 0)
         {
             foreach (DataRow dr in dt.Rows)
             {
                 string equipment_sn     = dr["equipment_sn"].ToString();
                 string project_id       = dr["project_id"].ToString();
                 string pm25_warn_value  = dr["pm25_warn_value"].ToString();
                 string pm10_warn_value  = dr["pm10_warn_value"].ToString();
                 string noise_warn_value = dr["noise_warn_value"].ToString();
                 string value            = project_id + "&" + pm25_warn_value + "&" + pm10_warn_value + "&" + noise_warn_value;
                 //存入redis中
                 string   key      = "equipment:projectid:" + Equipment_type.扬尘噪音 + ":" + equipment_sn;
                 TimeSpan timeSpan = new TimeSpan(0, 0, 300);
                 RedisCacheHelper.Add(key, value, timeSpan);
             }
         }
     }
     catch (Exception ex)
     {
         ToolAPI.XMLOperation.WriteLogXmlNoTail("扬尘噪音Sync_equipment_project异常", ex.Message);
     }
 }
        public static void Get_equminet_driver(string sn, string driver_code)
        {
            string key   = "equipment:driver:" + Equipment_type.升降机 + ":" + sn;
            string value = RedisCacheHelper.Get <string>(key);

            if (value == null)
            {
                Update_driver_attendance_asyn.BeginInvoke(sn, driver_code, DateTime.Now.ToString(), null, null);
                Update_equminet_driver(sn, driver_code);
            }
            else
            {
                string[] code_time = value.Split('&');
                if (code_time.Length > 1)
                {
                    if (code_time[0] != driver_code)
                    {
                        Update_driver_attendance_asyn.BeginInvoke(sn, driver_code, DateTime.Now.ToString(), null, null);
                        Update_equminet_driver(sn, driver_code);
                    }
                    else
                    {
                        DateTime dateTime = DateTime.Parse(code_time[1]);
                        if ((DateTime.Now - dateTime).TotalHours > 4)
                        {
                            Update_driver_attendance_asyn.BeginInvoke(sn, driver_code, DateTime.Now.ToString(), null, null);
                            Update_equminet_driver(sn, driver_code);
                        }
                    }
                }
                else
                {
                    Update_driver_attendance_asyn.BeginInvoke(sn, driver_code, DateTime.Now.ToString(), null, null);
                    Update_equminet_driver(sn, driver_code);
                }
            }
        }
示例#8
0
        public static void Update_equminet_last_online_time(string sn, long time)
        {
            string key = "equipment:online_time:" + Equipment_type.卸料平台 + ":" + sn;

            RedisCacheHelper.Add(key, time);
        }