2 Commits 0fb3087e61 ... 7745fd5e80

Autor SHA1 Mensagem Data
  yinyujing 7745fd5e80 Merge branch 'master' of http://60.205.104.179:3000/yinyujing/zhihuishuiwuDataSyn 1 ano atrás
  yinyujing 7665cf08bf 营收数据同步优化 1 ano atrás
2 arquivos alterados com 37 adições e 33 exclusões
  1. 34 30
      TimedUpload/QuartzJobs/DABusinessDataJob.cs
  2. 3 3
      TimedUpload/app.config

+ 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("\",");

+ 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" />