Ver código fonte

Merge remote-tracking branch 'origin/master'

jochu_liu 1 ano atrás
pai
commit
ceedaa2435

+ 34 - 30
TimedUpload/QuartzJobs/DABusinessDataJob.cs

@@ -72,22 +72,26 @@ namespace TimedUpload.QuartzJobs
             log.Info("营收户表基础数据同步任务开始执行.................\r\n");
             while (true)
             {
-                
-                string sql = "SELECT top 100 b.CM_ID,c.RouteCode,RouteName,a.CustomerCode,a.CustomerName,b.ElecAddress,b.DetailedAddress MeterAddress,a.DetailedAddress CustomerAddress";
-                sql += " FROM BCS_Customer a,BCS_CustomerMeter b, BCS_MeterReadingRoute c WHERE a.Cus_ID = b.Cus_ID and b.Mrr_ID = c.MRR_ID ";
-                sql += " AND b.CM_ID > " + meterId + " ORDER BY CM_ID";
+                DataTable dt = null;
+                try
+                {
+                    string sql = "SELECT top 100 b.CM_ID,c.RouteCode,RouteName,a.CustomerCode,a.CustomerName,b.ElecAddress,b.DetailedAddress MeterAddress,a.DetailedAddress CustomerAddress";
+                    sql += " FROM BCS_Customer a,BCS_CustomerMeter b, BCS_MeterReadingRoute c WHERE a.Cus_ID = b.Cus_ID and b.Mrr_ID = c.MRR_ID ";
+                    sql += " AND b.CM_ID > " + meterId + " ORDER BY CM_ID";
 
-                // log.Info(sql);
-                
-                DataTable dt = dbHelper.Fill(sql);
+                    dt = dbHelper.Fill(sql);
+                }
+                catch (Exception ex)
+                {
+                    log.Info("营收户表基础数据同步查询数据异常" + ex.StackTrace + "\r\n");
+                }
 
-                // log.Info("营业收费户表 | " + dt.Rows.Count);
                 if (dt == null || dt.Rows.Count == 0)
                 {
                     break;
                 }
 
-                
+                log.Info("营收户表基础数据同步获取记录数:【" + dt.Rows.Count + "】................\r\n");
 
                 StringBuilder message = new StringBuilder();
                 for (int i = 0; i < dt.Rows.Count; i++)
@@ -97,10 +101,7 @@ namespace TimedUpload.QuartzJobs
                     {
                         DataRow dr = dt.Rows[i];
 
-                        if (i == dt.Rows.Count - 1)
-                        {
-                            meterId = Convert.ToString(dr["CM_ID"]);
-                        }
+                        meterId = Convert.ToString(dr["CM_ID"]);
 
                         string meterLineNo = Convert.ToString(dr["RouteCode"]);
                         string meterLineName = Convert.ToString(dr["RouteName"]);
@@ -147,39 +148,42 @@ namespace TimedUpload.QuartzJobs
         private void SendZoneMeterUserHis(Dictionary<string, IModel> channels, Dictionary<string, IBasicProperties> properties)
         {
             string userMeterReadId = Constants.UserMeterReadId;
-            //log.Info("营收户表抄表数据同步任务开始执行.................\r\n");
+            log.Info("营收户表抄表数据同步任务开始执行.................\r\n");
             while (true)
             {
-
-                string sql = "SELECT top 100 UsedWater_ID,CM_ID,ThisMeterNumber,ThisMeterDt,BetweenMeteNumber,b.CreateDT FROM BCS_UsedWater b";
-                sql += " WHERE b.BM_ID >= " + bmId + " AND b.UsedWater_ID > " + userMeterReadId + " ORDER BY b.BM_ID,b.UsedWater_ID";
-                // log.Info(sql);
-                DataTable dt = dbHelper.Fill(sql);
+                DataTable dt = null;
+                try
+                {
+                    string sql = "SELECT top 100 UsedWater_ID,CM_ID,ThisMeterNumber,ThisMeterDt,BetweenMeteNumber,b.CreateDT FROM BCS_UsedWater b";
+                    sql += " WHERE b.BM_ID >= " + bmId + " AND b.UsedWater_ID > " + userMeterReadId + " ORDER BY b.BM_ID,b.UsedWater_ID";
+                    dt = dbHelper.Fill(sql);
+                }
+                catch (Exception ex)
+                {
+                    log.Info("营收户表抄表数据同步查询数据异常" + ex.StackTrace + "\r\n");
+                }
 
                 if (dt == null || dt.Rows.Count == 0)
                 {
 
                     break;
                 }
+                log.Info("营收户表抄表数据同步获取记录数:【" + dt.Rows.Count + "】................\r\n");
 
                 StringBuilder message = new StringBuilder();
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     message.Clear();
-
-                    DataRow dr = dt.Rows[i];
-
-                    if (i == dt.Rows.Count - 1)
+                    try
                     {
+                        DataRow dr = dt.Rows[i];
                         userMeterReadId = Convert.ToString(dr["UsedWater_ID"]);
-                    }
 
-                    string meterCode = Convert.ToString(dr["CM_ID"]);
-                    string getDateTime = Convert.ToDateTime(dr["ThisMeterDt"]).ToString("yyyy-MM-dd HH:mm:ss");
-                    string currReadingValue = Convert.ToString(dr["ThisMeterNumber"]);
-                    string waterUsed = Convert.ToString(dr["BetweenMeteNumber"]);
-                    try
-                    {
+                        string meterCode = Convert.ToString(dr["CM_ID"]);
+                        string getDateTime = Convert.ToDateTime(dr["ThisMeterDt"]).ToString("yyyy-MM-dd HH:mm:ss");
+                        string currReadingValue = Convert.ToString(dr["ThisMeterNumber"]);
+                        string waterUsed = Convert.ToString(dr["BetweenMeteNumber"]);
+
                         message.Append("{");
                         message.Append("\"meterCode\": \"").Append(meterCode).Append("\",");
                         message.Append("\"fromWhere\": \"").Append(manufacturerCode).Append("\",");

+ 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;

+ 3 - 3
TimedUpload/app.config

@@ -18,10 +18,10 @@
     <!-- 二供设备已同步到分区计量的设备编码 -->
     <add key="SecondaryToDMACode" value="" />
 
-    <add key="BmId" value="145" />
-    <add key="UserMeterId" value="0" />
+    <add key="BmId" value="154" />
+    <add key="UserMeterId" value="78843" />
     <add key="UserMeterDate" value="20220225" />
-    <add key="UserMeterReadId" value="0" />
+    <add key="UserMeterReadId" value="8389976" />
     <add key="UserMeterReadDate" value="2022-02-25 00:00:00" />