Prechádzať zdrojové kódy

Merge branch 'master' of http://60.205.104.179:3000/yinyujing/zhihuishuiwuDataSyn

yinyujing 1 rok pred
rodič
commit
63234c9d12

+ 1 - 1
TimedUpload/QuartzJobs/ChangleSecondPumpDataJob.cs

@@ -89,7 +89,7 @@ namespace TimedUpload.QuartzJobs
 
                 for (int k = 0; k < dtDevice.Rows.Count; k++)
                 {
-                    string table = "历史记录_" + dtDevice.Rows[k]["devId"].ToString().PadLeft(6,'0')+"_"+DateTime.Now.Year.ToString();
+                    string table = "历史记录_" + dtDevice.Rows[k]["devId"].ToString().PadLeft(6,'0') + "_ " + DateTime.Now.Year.ToString();
                     String sql = @"SELECT TOP 2000 [id]
                         ,[设备ID],[记录时间],[采集时间]
                         ,[设备状态],[通讯状态],[数据来源]

+ 37 - 1
TimedUpload/QuartzJobs/ChangleWorkmanshipDataUploadJob.cs

@@ -11,10 +11,12 @@ using System.Text;
 
 namespace TimedUpload.QuartzJobs
 {
+    [DisallowConcurrentExecution]
     public class ChangleWorkmanshipDataUploadJob : IJob
     {
         private readonly ILog log = LogManager.GetLogger(typeof(WorkmanshipDataUploadJob));
 
+
         public void Execute(IJobExecutionContext context)
         {
 
@@ -173,7 +175,41 @@ namespace TimedUpload.QuartzJobs
                 log.Info("水厂工艺图数据同步任务开始执行.................\r\n");
                 DateTime newTime = DateTime.Now;
                 String yearStr = newTime.Year.ToString();
-                string factorySql = "";
+                // 进水
+                Decimal inFlow = 0;
+                Decimal inTotalFlow = 0;
+                string insql = @"SELECT TOP 1 [id],[设备ID],[记录时间],[采集时间],[设备状态],[通讯状态],[净累计流量],[瞬时流量] FROM [dbo].[历史记录_000523_" + yearStr + "] order by 采集时间 DESC";
+                DataTable inDt = dbHelper.Fill(insql);
+                if (inDt != null && inDt.Rows.Count > 0) {
+                    inFlow = Convert.ToDecimal(inDt.Rows[0]["瞬时流量"]);
+                    inTotalFlow = Convert.ToDecimal(inDt.Rows[0]["净累计流量"]);
+                }
+                // 出水
+                Decimal outFlow = 0;
+                Decimal outTotalFlow = 0;
+                string outsql = @"SELECT TOP 1 [id],[设备ID],[记录时间],[采集时间],[设备状态],[通讯状态],[净累计流量],[瞬时流量] FROM [dbo].[历史记录_000286_" + yearStr + "] Order by 采集时间 DESC"; ;
+                DataTable outDt = dbHelper.Fill(outsql);
+                if (outDt != null && outDt.Rows.Count > 0)
+                {
+                    outFlow = Convert.ToDecimal(inDt.Rows[0]["瞬时流量"]);
+                    outTotalFlow = Convert.ToDecimal(inDt.Rows[0]["净累计流量"]);
+                }
+
+                string factorySql = @"SELECT TOP 1
+                        1 rid,3 Type,1 ridl,CONVERT(varchar(100), CollectTime, 111) 日期,CONVERT(varchar(100), CollectTime, 108) 时间, CONVERT(varchar(100), CollectTime, 111) 日期1,CONVERT(varchar(100), CollectTime, 108) 时间1,
+                        CONVERT(varchar(100), CollectTime, 111) + ' ' + CONVERT(varchar(100), CollectTime, 108) ReadTime,CONVERT(varchar(100), CollectTime, 111) + ' ' + CONVERT(varchar(5), CollectTime, 108) 更新时间,CONVERT(varchar(100), CollectTime, 111) + ' ' + CONVERT(varchar(5), CollectTime, 108) 更新时间1,
+                        '' FactoryId,'sc001' DeviceCode,1 FactoryId1,0 反冲流量,0 管网压力," + outTotalFlow + " 一号正累计流量,"+ outFlow + @" 一号流量计流量,0 一号负累计流量,0  一号送水泵压力,0 一号反冲泵压力,0 三号反冲泵压力,0 三号送水泵压力,0 二号反冲泵压力,0 二号正累计流量,
+                        0 二号负累计流量,0 二号送水泵压力,0 反冲正累计流量,0 反冲负累计流量,0 四号送水泵压力,"+ inFlow + @" 仓库流量计瞬时1,0 仓库流量计瞬时2, 0 仓库流量计瞬时3,"+inTotalFlow+ @" 仓库流量计正累计1,0 仓库流量计正累计2,0 仓库流量计正累计3,0 仓库流量计负累计1,
+                        0 仓库流量计负累计2,0 仓库流量计负累计3
+                        ,[originWaterZD] 进水浊度
+                        ,[originWaterPH] 进水PH
+                        ,[lvhouZD] 泵房出水浊度
+                        ,[lvhouYulv] 进水氨氮
+                        ,[outWaterZD]  出水浊度
+                        ,[outWaterPH] 泵房出水PH
+                        ,[outWaterYulv] 泵房出水余氯
+                        ,[qingshuichiFluidLevel] 清水池液位
+                    FROM[Waterwell].[dbo].[WaterFactoryDaliyRecord] order by id DESC";
 
                 DataTable dtDevice = dbHelper.Fill(factorySql);
                 if (dtDevice == null || dtDevice.Rows.Count == 0)