yinyujing 1 год назад
Родитель
Сommit
1b7e4982cd
1 измененных файлов с 28 добавлено и 28 удалено
  1. 28 28
      TimedUpload/QuartzJobs/SecondaryPumpDataUploadJob.cs

+ 28 - 28
TimedUpload/QuartzJobs/SecondaryPumpDataUploadJob.cs

@@ -123,29 +123,29 @@ namespace TimedUpload.QuartzJobs
                     DataRow dr = dtDevice.Rows[i];
                     string id = dr["更新时间"].ToString();
                     string deviceCode = dr["编码"].ToString();
-                    string PressureIn = dr["泵进口压力"].ToString();
-                    string PressureOut = dr["泵出口压力"].ToString();
-                    string PressureSet = dr["泵设定压力"].ToString();
-                    string InstantFlow = dr["瞬时流量"].ToString();
-                    string TotalFlow = dr["净累计流量"].ToString();
-                    string PositiveToTalFlow = dr["正累计流量"].ToString();
-                    string NegativeTotalFlow = dr["负累计流量"].ToString();
-                    string PH = dr["PH"].ToString();
-                    string Chlorine = dr["余氯"].ToString();
-                    string Turbidity = dr["浊度"].ToString();
-                    string LiquidHeight = dr["水箱液位"].ToString();
-                    string VoltageA = dr["电压AB"].ToString();
-                    string VoltageB = dr["电压AC"].ToString();
-                    string VoltageC = dr["电压BC"].ToString();
-                    string CurrentA = dr["电流A"].ToString();
-                    string CurrentB = dr["电流B"].ToString();
-                    string CurrentC = dr["电流C"].ToString();
-                    string Consumption = dr["用电量"].ToString();
-                    string LackWater = dr["缺水报警"].ToString();
-                    string OverPressure = dr["超压报警"].ToString();
-                    string HouseInlet = dr["进水报警"].ToString(); // 进水报警0为正常,1为进水。
-                    string TubeBurst = dr["爆管报警"].ToString();
-                    string NetState = dr["网络状态"].ToString(); // 0代表通讯正常,1代表网络故障,2代表现场485设备通讯故障
+                    string PressureIn = dr["泵进口压力"] == DBNull.Value ? "0" : dr["泵进口压力"].ToString();
+                    string PressureOut = dr["泵出口压力"] == DBNull.Value ? "0" : dr["泵出口压力"].ToString();
+                    string PressureSet = dr["泵设定压力"] == DBNull.Value ? "0" : dr["泵设定压力"].ToString();
+                    string InstantFlow = dr["瞬时流量"] == DBNull.Value ? "0" : dr["瞬时流量"].ToString();
+                    string TotalFlow = dr["净累计流量"] == DBNull.Value ? "0" : dr["净累计流量"].ToString();
+                    string PositiveToTalFlow = dr["正累计流量"] == DBNull.Value ? "0" : dr["正累计流量"].ToString();
+                    string NegativeTotalFlow = dr["负累计流量"] == DBNull.Value ? "0" : dr["负累计流量"].ToString();
+                    string PH = dr["PH"] == DBNull.Value ? "0" : dr["PH"].ToString();
+                    string Chlorine = dr["余氯"] == DBNull.Value ? "0" : dr["余氯"].ToString();
+                    string Turbidity = dr["浊度"] == DBNull.Value ? "0" : dr["浊度"].ToString();
+                    string LiquidHeight = dr["水箱液位"] == DBNull.Value ? "0" : dr["水箱液位"].ToString();
+                    string VoltageA = dr["电压AB"] == DBNull.Value ? "0" : dr["电压AB"].ToString();
+                    string VoltageB = dr["电压AC"] == DBNull.Value ? "0" : dr["电压AC"].ToString();
+                    string VoltageC = dr["电压BC"] == DBNull.Value ? "0" : dr["电压BC"].ToString();
+                    string CurrentA = dr["电流A"] == DBNull.Value ? "0" : dr["电流A"].ToString();
+                    string CurrentB = dr["电流B"] == DBNull.Value ? "0" : dr["电流B"].ToString();
+                    string CurrentC = dr["电流C"] == DBNull.Value ? "0" : dr["电流C"].ToString();
+                    string Consumption = dr["用电量"] == DBNull.Value ? "0" : dr["用电量"].ToString();
+                    string LackWater = dr["缺水报警"] == DBNull.Value ? "0" : dr["缺水报警"].ToString();
+                    string OverPressure = dr["超压报警"] == DBNull.Value ? "0" : dr["超压报警"].ToString();
+                    string HouseInlet = dr["进水报警"] == DBNull.Value ? "0" : dr["进水报警"].ToString(); // 进水报警0为正常,1为进水。
+                    string TubeBurst = dr["爆管报警"] == DBNull.Value ? "0" : dr["爆管报警"].ToString();
+                    string NetState = dr["网络状态"] == DBNull.Value ? "0" : dr["网络状态"].ToString(); // 0代表通讯正常,1代表网络故障,2代表现场485设备通讯故障
 
                     string readTime = dr["日期"].ToString().Trim() + " " + dr["时间"].ToString().Trim();
 
@@ -195,11 +195,11 @@ namespace TimedUpload.QuartzJobs
                         }
 
                         string meterCode = "wwkj" + j.ToString().PadLeft(3, '0');
-                        string frequency = dr[colPre + "频率"].ToString();
-                        string current = dr[colPre + "电流"].ToString();
-                        string runState = dr[colPre + "运行状态"].ToString();
-                        string power = dr[colPre + "功率"].ToString();
-                        string voltage = dr[colPre + "电压"].ToString();
+                        string frequency = dr[colPre + "频率"] == DBNull.Value ? "0" : dr[colPre + "频率"].ToString();
+                        string current = dr[colPre + "电流"] == DBNull.Value ? "0" : dr[colPre + "电流"].ToString();
+                        string runState = dr[colPre + "运行状态"] == DBNull.Value ? "0" : dr[colPre + "运行状态"].ToString();
+                        string power = dr[colPre + "功率"] == DBNull.Value ? "0" : dr[colPre + "功率"].ToString();
+                        string voltage = dr[colPre + "电压"] == DBNull.Value ? "0" : dr[colPre + "电压"].ToString();
 
                         meterMap["PumpCode"] = meterCode;
                         meterMap["ReadTime"] = readTime;