|
@@ -47,8 +47,8 @@ namespace TimedUpload.QuartzJobs
|
|
|
|
|
|
if (channels.Count > 0)
|
|
|
{
|
|
|
- SendZoneMeterUser(channels, properties);
|
|
|
- SendZoneMeterUserHis(channels, properties);
|
|
|
+ SendQualityMeterUser(channels, properties);
|
|
|
+ SendQualityMeterUserHis(channels, properties);
|
|
|
}
|
|
|
|
|
|
foreach (KeyValuePair<string, IConnection> item in connections)
|
|
@@ -63,7 +63,7 @@ namespace TimedUpload.QuartzJobs
|
|
|
/// 水质设备添加
|
|
|
/// </summary>
|
|
|
/// <param name="channel"></param>
|
|
|
- private void SendZoneMeterUser(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
|
|
|
+ private void SendQualityMeterUser(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
|
|
|
{
|
|
|
string changLeWaterQualityId = Constants.changLeWaterQualityId;
|
|
|
log.Info("水质设备基础数据同步任务开始执行.................\r\n");
|
|
@@ -152,87 +152,50 @@ namespace TimedUpload.QuartzJobs
|
|
|
/// 水质设备历史数据
|
|
|
/// </summary>
|
|
|
/// <param name="channel"></param>
|
|
|
- private void SendZoneMeterUserHis(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
|
|
|
+ private void SendQualityMeterUserHis(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
|
|
|
{
|
|
|
string changLeWaterQualityHisId = Constants.changLeWaterQualityHisId;
|
|
|
log.Info("水质设备抄表数据同步任务开始执行.................\r\n");
|
|
|
- String sqlMeter = "SELECT * FROM [设备信息] ORDER BY ID";
|
|
|
- DataTable dtMeter = dbHelper.Fill(sqlMeter);
|
|
|
+ String sqlMeter = "SELECT top 100 * FROM [历史记录_zhsw] WHERE HistoryRecordID > " + changLeWaterQualityHisId + " ORDER BY HistoryRecordID";
|
|
|
+ DataTable dtMeterHis = dbHelper.Fill(sqlMeter);
|
|
|
|
|
|
- for (int i = 0; i < dtMeter.Rows.Count; i++)
|
|
|
+ StringBuilder message = new StringBuilder();
|
|
|
+ for (int j = 0; j < dtMeterHis.Rows.Count; j++)
|
|
|
{
|
|
|
- DataRow drMeter = dtMeter.Rows[i];
|
|
|
- String meterId = drMeter["ID"].ToString();
|
|
|
- String meterCode = drMeter["考核表编码"].ToString();
|
|
|
- String lastTime = "";
|
|
|
-
|
|
|
- int nowYear = DateTime.Now.Year;
|
|
|
-
|
|
|
- //for (int k = lastYear; k <= nowYear; k++)
|
|
|
- //{
|
|
|
- // string tablename = "历史记录_" + ("000000" + meterId).Substring(meterId.Length, 6) + "_" + k;
|
|
|
-
|
|
|
-
|
|
|
- // DataTable dtMeterHis = dbHelper.Fill("");
|
|
|
-
|
|
|
- // StringBuilder message = new StringBuilder();
|
|
|
- // for (int j = 0; j < dtMeterHis.Rows.Count; j++)
|
|
|
- // {
|
|
|
- // message.Clear();
|
|
|
- // try
|
|
|
- // {
|
|
|
- // DataRow drMeterHis = dtMeterHis.Rows[j];
|
|
|
- // String getDateTime = Convert.ToDateTime(drMeterHis["采集时间"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
- // message.Append("{");
|
|
|
- // message.Append("\"meterAssessmentCode\": \"").Append(meterCode).Append("\",");
|
|
|
- // message.Append("\"manufacturerCode\": ").Append(Constants.ManufacturerCode).Append(",");
|
|
|
- // message.Append("\"getDateTime\": \"").Append(getDateTime).Append("\",");
|
|
|
- // if (Convert.DBNull != drMeterHis["净累计流量"])
|
|
|
- // {
|
|
|
- // message.Append("\"netCumulativeFlow\": ").Append(Convert.ToDecimal(drMeterHis["净累计流量"])).Append(",");
|
|
|
- // }
|
|
|
- // if (Convert.DBNull != drMeterHis["正累计流量"])
|
|
|
- // {
|
|
|
- // message.Append("\"positiveCumulativeFlow\": ").Append(Convert.ToDecimal(drMeterHis["正累计流量"])).Append(",");
|
|
|
- // }
|
|
|
- // if (Convert.DBNull != drMeterHis["负累计流量"])
|
|
|
- // {
|
|
|
- // message.Append("\"negativeCumulativeFlow\": ").Append(Convert.ToDecimal(drMeterHis["负累计流量"])).Append(",");
|
|
|
- // }
|
|
|
- // if (Convert.DBNull != drMeterHis["瞬时流量"])
|
|
|
- // {
|
|
|
- // message.Append("\"instantaneousFlow\": ").Append(Convert.ToDecimal(drMeterHis["瞬时流量"])).Append(",");
|
|
|
- // }
|
|
|
- // if (Convert.DBNull != drMeterHis["压力"])
|
|
|
- // {
|
|
|
- // message.Append("\"pressure\": ").Append(Convert.ToDecimal(drMeterHis["压力"])).Append(",");
|
|
|
- // }
|
|
|
- // if (Convert.DBNull != drMeterHis["电池电压"])
|
|
|
- // {
|
|
|
- // message.Append("\"batteryVoltageValue\": ").Append(Convert.ToDecimal(drMeterHis["电池电压"])).Append(",");
|
|
|
- // }
|
|
|
- // message.Append("}");
|
|
|
+ message.Clear();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ DataRow drMeterHis = dtMeterHis.Rows[j];
|
|
|
+ String getDateTime = Convert.ToDateTime(drMeterHis["GetDateTime"]).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String meterCode = "wwkjsz" + drMeterHis["DevId"].ToString();
|
|
|
+ message.Append("{");
|
|
|
+ message.Append("\"meterAssessmentCode\": \"").Append(meterCode).Append("\",");
|
|
|
+ message.Append("\"manufacturerCode\": ").Append(Constants.ManufacturerCode).Append(",");
|
|
|
+ message.Append("\"getDateTime\": \"").Append(getDateTime).Append("\",");
|
|
|
+ if (Convert.DBNull != drMeterHis["Chlorine"])
|
|
|
+ {
|
|
|
+ message.Append("\"chlorine\": ").Append(Convert.ToDecimal(drMeterHis["Chlorine"])).Append(",");
|
|
|
+ }
|
|
|
+ if (Convert.DBNull != drMeterHis["Turbidity"])
|
|
|
+ {
|
|
|
+ message.Append("\"turbidity\": ").Append(Convert.ToDecimal(drMeterHis["Turbidity"])).Append(",");
|
|
|
+ }
|
|
|
+ message.Append("}");
|
|
|
|
|
|
- // foreach (KeyValuePair<string, IModel> item in channels)
|
|
|
- // {
|
|
|
- // string key = item.Key;
|
|
|
- // IModel channel = item.Value;
|
|
|
- // IBasicProperties property = properties[key];
|
|
|
- // channel.BasicPublish("zone.deviceHis", "", property, Encoding.UTF8.GetBytes(message.ToString())); //生产消息
|
|
|
- // }
|
|
|
- // lastTime = getDateTime;
|
|
|
- // }
|
|
|
- // catch (Exception ex)
|
|
|
- // {
|
|
|
- // log.Info("水质设备历史记录同步任务数据推送失败:" + message.ToString() + "\r\n");
|
|
|
- // log.Error(ex.Message + "===========" + ex.StackTrace + "\r\n");
|
|
|
- // }
|
|
|
- // }
|
|
|
- //}
|
|
|
- //if (!"".Equals(lastTime))
|
|
|
- //{
|
|
|
- // uploadHis[meterCode] = lastTime;
|
|
|
- //}
|
|
|
+ foreach (KeyValuePair<string, IModel> item in channels)
|
|
|
+ {
|
|
|
+ string key = item.Key;
|
|
|
+ IModel channel = item.Value;
|
|
|
+ IBasicProperties property = properties[key];
|
|
|
+ channel.BasicPublish("zone.deviceHis", "", property, Encoding.UTF8.GetBytes(message.ToString())); //生产消息
|
|
|
+ }
|
|
|
+ changLeWaterQualityHisId = drMeterHis["HistoryRecordID"].ToString();
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ log.Info("水质设备历史记录同步任务数据推送失败:" + message.ToString() + "\r\n");
|
|
|
+ log.Error(ex.Message + "===========" + ex.StackTrace + "\r\n");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
UpdateAppConfig("ChangLeWaterQualityHisId", changLeWaterQualityHisId);
|