소스 검색

初始化

xuwei 3 년 전
부모
커밋
1d9c9cd60a

+ 1 - 0
.gitignore

@@ -108,3 +108,4 @@ _UpgradeReport_Files/
 Backup*/
 UpgradeLog*.XML
 
+/.vs

+ 41 - 0
HEGII.ss.mes.export.sln

@@ -0,0 +1,41 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32929.386
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "wwwroot", "wwwroot\", "{DB74DD9E-F84B-4372-A298-41376272D607}"
+	ProjectSection(WebsiteProperties) = preProject
+		TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
+		Debug.AspNetCompiler.VirtualPath = "/localhost_62172"
+		Debug.AspNetCompiler.PhysicalPath = "wwwroot\"
+		Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_62172\"
+		Debug.AspNetCompiler.Updateable = "true"
+		Debug.AspNetCompiler.ForceOverwrite = "true"
+		Debug.AspNetCompiler.FixedNames = "false"
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.VirtualPath = "/localhost_62172"
+		Release.AspNetCompiler.PhysicalPath = "wwwroot\"
+		Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_62172\"
+		Release.AspNetCompiler.Updateable = "true"
+		Release.AspNetCompiler.ForceOverwrite = "true"
+		Release.AspNetCompiler.FixedNames = "false"
+		Release.AspNetCompiler.Debug = "False"
+		VWDPort = "62172"
+		SlnRelativePath = "wwwroot\"
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{DB74DD9E-F84B-4372-A298-41376272D607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DB74DD9E-F84B-4372-A298-41376272D607}.Debug|Any CPU.Build.0 = Debug|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {9CA3E13F-6ECD-4AFF-BB80-B7C099FAE7B3}
+	EndGlobalSection
+EndGlobal

+ 0 - 3
README.md

@@ -1,3 +0,0 @@
-# HEGII.ss.mes.export
-
-上报数据

+ 148 - 0
wwwroot/Api/export01.ashx

@@ -0,0 +1,148 @@
+<%@ WebHandler Language="C#" Class="export01" %>
+
+using System;
+using System.Web;
+using System.Data;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+public class export01 : IHttpHandler
+{
+
+	public void ProcessRequest(HttpContext context)
+	{
+		context.Response.ContentType = "text/plain";
+
+
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'GYZJ' || GROUTINGLINECODE AS deviceCode,
+				'高压注浆设备' || GROUTINGLINECODE AS name 
+			FROM
+				TP_PM_H_GROUTINGPARAS 
+			GROUP BY
+				GROUTINGLINECODE 
+			ORDER BY
+				GROUTINGLINECODE"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.LZTIME_低注时间,
+				t.GZTIME_高注时间,
+				t.PNTIME_排泥时间,
+				t.GGTIME_巩固时间,
+				t.PRESSURE_压力,
+				t.TEMPERATURE_温度 
+			FROM
+				(
+				SELECT
+					'GYZJ' || GP.GROUTINGLINECODE AS deviceCode,
+					'高压注浆设备' || GP.GROUTINGLINECODE AS name,
+					GP.LZ_TIME AS LZTIME_低注时间,
+					GP.GZ_TIME AS GZTIME_高注时间,
+					GP.PN_TIME AS PNTIME_排泥时间,
+					GP.GG_TIME AS GGTIME_巩固时间,
+					GPT.G_PRESSURE AS PRESSURE_压力,
+					GPT.G_TEMPERATURE AS TEMPERATURE_温度,
+					rank ( ) over ( PARTITION BY GP.GROUTINGDAILYID ORDER BY GPT.HGPT_ID DESC ) AS rk 
+				FROM
+					TP_PM_H_GROUTINGPARAS GP
+					INNER JOIN ( SELECT MAX( GROUTINGDAILYID ) AS GROUTINGDAILYID FROM TP_PM_H_GROUTINGPARAS GROUP BY GROUTINGLINECODE, H_LINEINDEX ) T ON T.GROUTINGDAILYID = GP.GROUTINGDAILYID
+					LEFT JOIN TP_PM_H_GROUTINGPARAS_PT GPT ON GPT.GROUTINGDAILYID = GP.GROUTINGDAILYID 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "高压注浆设备"));
+			data.Add(new JProperty("productCode", "FSHJGYZJ"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+
+			//上报数据
+			//string url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+			string url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+			string message = JsonClient.Post(url, data.ToString());
+			context.Response.Write(message);
+
+			context.Response.Write(data.ToString());
+
+			//data.Add("deviceData", JArray.Parse(JsonConvert.SerializeObject(dt)));
+		}
+	}
+
+	public bool IsReusable
+	{
+		get
+		{
+			return false;
+		}
+	}
+
+}

+ 157 - 0
wwwroot/Api/export02.ashx

@@ -0,0 +1,157 @@
+<%@ WebHandler Language="C#" Class="export02" %>
+
+using System;
+using System.Web;
+using System.Data;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+public class export02 : IHttpHandler
+{
+
+	public void ProcessRequest(HttpContext context)
+	{
+		context.Response.ContentType = "text/plain";
+
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'HGQ' || p.PLC_ID AS deviceCode,
+				'烘干区' || P.PLC_NAME AS name 
+			FROM
+				T_XT_PLC_V V
+				INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+			WHERE
+				V.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND V.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				p.PLC_ID,
+				P.PLC_NAME 
+			ORDER BY
+				P.PLC_NAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.FNTEMPERATURE_房内温度,
+				t.SDTEMPERATURE_设定温度,
+				t.FNHUMIDITY_房内湿度,
+				t.SDHUMIDITY_设定湿度,
+				t.RSSTEMPERATURE_燃烧室温度,
+				t.YRTEMPERATURE_余热温度 
+			FROM
+				(
+				SELECT
+					'HGQ' || p.PLC_ID AS deviceCode,
+					'烘干区' || P.PLC_NAME AS name,
+					nvl( V.V100, 0 ) AS FNTEMPERATURE_房内温度,
+					nvl( V.V104, 0 ) AS SDTEMPERATURE_设定温度,
+					nvl( V.V108, 0 ) AS FNHUMIDITY_房内湿度,
+					nvl( V.V112, 0 ) AS SDHUMIDITY_设定湿度,
+					nvl( V.V120, 0 ) AS RSSTEMPERATURE_燃烧室温度,
+					nvl( V.V124, 0 ) AS YRTEMPERATURE_余热温度,
+					rank ( ) over ( PARTITION BY P.PLC_ID ORDER BY V.VID DESC ) AS rk 
+				FROM
+					T_XT_PLC_V V
+					INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+				WHERE
+					V.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND V.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				context.Response.Write("当前时段无数据");
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "烘干区"));
+			data.Add(new JProperty("productCode", "FSHJHGQ"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			//string url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+			string url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+			string message = JsonClient.Post(url, data.ToString());
+			context.Response.Write(message);
+
+			context.Response.Write(data.ToString());
+		}
+	}
+
+	public bool IsReusable
+	{
+		get
+		{
+			return false;
+		}
+	}
+
+}

+ 152 - 0
wwwroot/Api/export03.ashx

@@ -0,0 +1,152 @@
+<%@ WebHandler Language="C#" Class="export03" %>
+
+using System;
+using System.Web;
+using System.Data;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+public class export03 : IHttpHandler
+{
+
+	public void ProcessRequest(HttpContext context)
+	{
+		context.Response.ContentType = "text/plain";
+
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+				'施釉房' || GD.GLAZINGROOM AS name 
+			FROM
+				TP_PM_PRODUCTIONDATA P
+				INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+				INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+			WHERE
+				P.PROCEDUREID = 98 
+				AND P.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND P.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				GD.GLAZINGROOM 
+			ORDER BY
+				GD.GLAZINGROOM"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TEMP_釉温,
+				t.PRESSURE_釉压 
+			FROM
+				(
+				SELECT
+					'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+					'施釉房' || GD.GLAZINGROOM AS name,
+					G.G_TEMP AS TEMP_釉温,
+					G.G_PRESSURE AS PRESSURE_釉压,
+					rank ( ) over ( PARTITION BY GD.GLAZINGROOM ORDER BY P.GROUTINGDAILYDETAILID DESC ) AS rk 
+				FROM
+					TP_PM_PRODUCTIONDATA P
+					INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+					INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+				WHERE
+					P.PROCEDUREID = 98 
+					AND P.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND P.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				context.Response.Write("当前时段无数据");
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "施釉房"));
+			data.Add(new JProperty("productCode", "FSHJSYF"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			//string url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+			string url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+			string message = JsonClient.Post(url, data.ToString());
+			context.Response.Write(message);
+
+			context.Response.Write(data.ToString());
+		}
+	}
+
+	public bool IsReusable
+	{
+		get
+		{
+			return false;
+		}
+	}
+
+}

+ 151 - 0
wwwroot/Api/export04.ashx

@@ -0,0 +1,151 @@
+<%@ WebHandler Language="C#" Class="export04" %>
+
+using System;
+using System.Web;
+using System.Data;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+public class export04 : IHttpHandler
+{
+
+	public void ProcessRequest(HttpContext context)
+	{
+		context.Response.ContentType = "text/plain";
+
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'CPCL' || W.WORKSTATIONID AS deviceCode,
+				'成品测漏' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 1 
+				AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果,
+				t.LEAKAGE_泄漏量 
+			FROM
+				(
+				SELECT
+					'CPCL' || W.WORKSTATIONID AS deviceCode,
+					'成品测漏' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					L.LEAKAGE AS LEAKAGE_泄漏量,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 1 
+					AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				context.Response.Write("当前时段无数据");
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "成品测漏"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			//string url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+			string url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+			string message = JsonClient.Post(url, data.ToString());
+			context.Response.Write(message);
+
+			context.Response.Write(data.ToString());
+		}
+	}
+
+	public bool IsReusable
+	{
+		get
+		{
+			return false;
+		}
+	}
+
+}

+ 149 - 0
wwwroot/Api/export05.ashx

@@ -0,0 +1,149 @@
+<%@ WebHandler Language="C#" Class="export05" %>
+
+using System;
+using System.Web;
+using System.Data;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+public class export05 : IHttpHandler
+{
+
+	public void ProcessRequest(HttpContext context)
+	{
+		context.Response.ContentType = "text/plain";
+
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYJG' || W.WORKSTATIONID AS deviceCode,
+				'试用结果' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 2 
+				AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果
+			FROM
+				(
+				SELECT
+					'SYJG' || W.WORKSTATIONID AS deviceCode,
+					'试用结果' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 2
+					AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				context.Response.Write("当前时段无数据");
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "试用结果"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			//string url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+			//string url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+			//string message = JsonClient.Post(url, data.ToString());
+			//context.Response.Write(message);
+
+			context.Response.Write(data.ToString());
+		}
+	}
+
+	public bool IsReusable
+	{
+		get
+		{
+			return false;
+		}
+	}
+
+}

+ 9 - 0
wwwroot/Api/readme.txt

@@ -0,0 +1,9 @@
+
+1次性上报数据=======================================
+export01.ashx 高压注浆参数上报:注浆设定值,只上报1次
+
+每1小时上报数据=====================================
+export02.ashx 烘干区数据数据上报(温度、湿度)
+export03.ashx 施釉数据上报(釉压、釉温)
+export04.ashx 成品测漏数据上报(是否漏气)
+export05.ashx 试用结果数据上报(是否合格)

+ 19 - 0
wwwroot/Api/start.ashx

@@ -0,0 +1,19 @@
+<%@ WebHandler Language="C#" Class="start" %>
+
+using System;
+using System.Web;
+
+public class start : IHttpHandler {
+    
+    public void ProcessRequest (HttpContext context) {
+        context.Response.ContentType = "text/plain";
+        context.Response.Write("开始任务!");
+    }
+ 
+    public bool IsReusable {
+        get {
+            return false;
+        }
+    }
+
+}

BIN
wwwroot/Api/佛山恒洁设备接入文档.pdf


+ 717 - 0
wwwroot/App_Code/PushData.cs

@@ -0,0 +1,717 @@
+using System;
+using System.Web;
+using System.Web.SessionState;
+using System.Data;
+using System.Collections;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+
+public static class PushData
+{
+	//private static string _url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+	private static string _url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+
+	/// <summary>
+	/// 烘干区
+	/// </summary>
+	public static void export02()
+	{
+		try {
+			using (IDataAccess conn = DataAccess.Create())
+			{
+				DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'HGQ' || p.PLC_ID AS deviceCode,
+				'烘干区' || P.PLC_NAME AS name 
+			FROM
+				T_XT_PLC_V V
+				INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+			WHERE
+				V.CREATETIME >= date'2021-07-01'
+				AND V.CREATETIME < sysdate + 1 
+			GROUP BY
+				p.PLC_ID,
+				P.PLC_NAME 
+			ORDER BY
+				P.PLC_NAME"
+				);
+				string str = "";
+				for (int m = 7; m < 12; m++) {
+					for (int i = 0; i < DateTime.DaysInMonth(2021, m); i++) {
+						if (m == 7) ;
+					DataTable dtDeviceData = conn.ExecuteDatatable(@"
+					SELECT
+						'HGQ' || p.PLC_ID AS deviceCode,
+						'烘干区' || P.PLC_NAME AS name,
+						TO_CHAR(V.CREATETIME,'YYYY-MM-DD') as time,
+						SUM(nvl( V.V100, 0 )) AS FNTEMPERATURE_房内温度,
+						SUM(nvl( V.V104, 0 )) AS SDTEMPERATURE_设定温度,
+						SUM(nvl( V.V108, 0 )) AS FNHUMIDITY_房内湿度,
+						SUM(nvl( V.V112, 0 )) AS SDHUMIDITY_设定湿度,
+						SUM(nvl( V.V120, 0 )) AS RSSTEMPERATURE_燃烧室温度,
+						SUM(nvl( V.V124, 0 )) AS YRTEMPERATURE_余热温度
+					FROM
+						T_XT_PLC_V V
+						INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+					WHERE
+						V.CREATETIME >= date'2021-07-01' + {I}
+						AND V.CREATETIME < date'2021-07-01' + 1 + {I}
+					GROUP BY 
+						p.PLC_ID,P.PLC_NAME,TO_CHAR(V.CREATETIME,'YYYY-MM-DD')
+					ORDER BY 
+						p.PLC_ID,TO_CHAR(V.CREATETIME,'YYYY-MM-DD')".Replace("{I}",i + "")
+					);
+
+					if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+					{
+						return;
+					}
+
+					// 拼接主体
+					JObject data = new JObject();
+					data.Add(new JProperty("industryName", "广东区域"));
+					data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+					data.Add(new JProperty("productName", "烘干区"));
+					data.Add(new JProperty("productCode", "FSHJHGQ"));
+					data.Add(new JProperty("protocol", "HTTP"));
+					data.Add(new JProperty("classfy", "陶瓷生产设备"));
+					data.Add(new JProperty("lever", "低端"));
+					data.Add(new JProperty("dimension", "工业品"));
+
+					// 拼接device
+					JArray arrDevice = new JArray();
+					JObject device = null;
+					foreach (DataRow row in dtDevice.Rows)
+					{
+						device = new JObject();
+						device.Add(new JProperty("name", row["name"]));
+						device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+						device.Add(new JProperty("province", "广东省"));
+						device.Add(new JProperty("city", "佛山市"));
+						device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+						device.Add(new JProperty("worth", "0"));
+						device.Add(new JProperty("latitude", "0"));
+						device.Add(new JProperty("longitude", "0"));
+						device.Add(new JProperty("manufacture", "2021-10-13"));
+						arrDevice.Add(device);
+					}
+					data.Add("device", arrDevice);
+
+					// 拼接deviceData
+					JArray arrDeviceData = new JArray();
+					JObject deviceData = null;
+					string[] colNames;
+
+					// 时间戳
+					TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+					string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+					foreach (DataRow row in dtDeviceData.Rows)
+					{
+						foreach (DataColumn col in dtDeviceData.Columns)
+						{
+							if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+							{
+								continue;
+							}
+
+							colNames = col.ColumnName.Split('_');
+							deviceData = new JObject();
+							deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+							deviceData.Add(new JProperty("name", colNames[1]));
+							deviceData.Add(new JProperty("mark", colNames[0]));
+							deviceData.Add(new JProperty("value", row[col].ToString()));
+							deviceData.Add(new JProperty("timestamp", timestamp));
+							arrDeviceData.Add(deviceData);
+						}
+					}
+
+					data.Add("deviceData", arrDeviceData);
+				//上报数据
+				string message = JsonClient.Post(_url, data.ToString());
+					}
+				}
+			}
+			Curtain.Log.Logger.Debug("烘干区数据上报成功!");
+		}
+		catch (Exception ex) {
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 施釉房
+	/// </summary>
+	public static void export03()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+				'施釉房' || GD.GLAZINGROOM AS name 
+			FROM
+				TP_PM_PRODUCTIONDATA P
+				INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+				INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+			WHERE
+				P.PROCEDUREID = 98 
+				AND P.CREATETIME >= date'2021-07-01'
+				AND P.CREATETIME < sysdate + 1 
+			GROUP BY
+				GD.GLAZINGROOM 
+			ORDER BY
+				GD.GLAZINGROOM"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TEMP_釉温,
+				t.PRESSURE_釉压 
+			FROM
+				(
+				SELECT
+					'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+					'施釉房' || GD.GLAZINGROOM AS name,
+					G.G_TEMP AS TEMP_釉温,
+					G.G_PRESSURE AS PRESSURE_釉压,
+					rank ( ) over ( PARTITION BY GD.GLAZINGROOM ORDER BY P.GROUTINGDAILYDETAILID DESC ) AS rk 
+				FROM
+					TP_PM_PRODUCTIONDATA P
+					INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+					INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+				WHERE
+					P.PROCEDUREID = 98 
+					AND P.CREATETIME >= date'2021-07-01'
+					AND P.CREATETIME < sysdate + 1 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "施釉房"));
+			data.Add(new JProperty("productCode", "FSHJSYF"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("施釉房数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 成品测漏
+	/// </summary>
+	public static void export04()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'CPCL' || W.WORKSTATIONID AS deviceCode,
+				'成品测漏' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 1 
+				AND L.CREATETIME >= date'2021-07-01'
+				AND L.CREATETIME < sysdate + 1 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果,
+				t.LEAKAGE_泄漏量 
+			FROM
+				(
+				SELECT
+					'CPCL' || W.WORKSTATIONID AS deviceCode,
+					'成品测漏' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					L.LEAKAGE AS LEAKAGE_泄漏量,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 1 
+					AND L.CREATETIME >= date'2021-07-01'
+					AND L.CREATETIME < sysdate + 1 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "成品测漏"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("成品侧漏数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 试用结果
+	/// </summary>
+	public static void export05()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYJG' || W.WORKSTATIONID AS deviceCode,
+				'试用结果' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 2 
+				AND L.CREATETIME >= date'2021-07-01'
+				AND L.CREATETIME < sysdate + 1 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果
+			FROM
+				(
+				SELECT
+					'SYJG' || W.WORKSTATIONID AS deviceCode,
+					'试用结果' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 2
+					AND L.CREATETIME >= date'2021-07-01'
+					AND L.CREATETIME < sysdate + 1 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "试用结果"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("试用数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 获取在用电能设备
+	/// </summary>
+	public static void getDeviceId()
+	{
+        try {
+		using (IDataAccess conn = DataAccess.Create())
+		{
+            string data00 = @"
+             DELETE FROM TP_DEV_DEVICEONUSING            
+             ";
+            int result00 = conn.ExecuteNonQuery(data00);
+            string data0 = @"{
+                ""appid"": ""ETP001018"",
+				""token"": ""6d06bb6d2173a4fdcfd098eba8a6605c""
+            }
+            ";
+			string url = "http://htemp.cn/opi/devices";// 生产
+			string message = JsonClient.Post(url, data0.ToString());
+			//Dictionary<string, object> ret = JsonHelper.JsonToDictionaryso(message + "");
+			//JsonConvert.DeserializeObject<Dictionary<string, object>>(message);
+
+			JObject ja = (JObject)JsonConvert.DeserializeObject(message); //反序列化为数组
+
+			string code = ja["code"].ToString();
+			string msg = ja["msg"].ToString();
+			string timestamp = ja["timestamp"].ToString();
+			string data = ja["data"].ToString();
+
+			JArray ja2 = (JArray)JsonConvert.DeserializeObject(data); //反序列化为数组
+			string name = ja2[0]["name"].ToString();
+			string item = ja2[0]["item"].ToString();
+
+			JArray ja3 = (JArray)JsonConvert.DeserializeObject(item); //反序列化为数组
+			string device = ja3[0]["device"].ToString();
+			string maters = ja3[0]["maters"].ToString();
+			for (int i = 0 + 1; i < ja3.Count; i++)
+			{
+				device += "," + ja3[i]["device"].ToString();
+				maters += "," + ja3[i]["maters"].ToString();
+			}
+			string str = "[" + maters.Replace("[", "").Replace("]", "") + "]";
+
+			JArray ja4 = (JArray)JsonConvert.DeserializeObject(str); //反序列化为数组
+			List<int> list1 = new List<int>();
+			list1.Add(Convert.ToInt32(ja4[0]["id"].ToString()));
+			List<int> list2 = new List<int>();
+			list2.Add(Convert.ToInt32(ja4[0]["position"].ToString()));
+			List<string> list3 = new List<string>();
+			list3.Add(ja4[0]["component_no"].ToString());
+			for (int i = 0 + 1; i < ja4.Count; i++)
+			{
+				list1.Add(Convert.ToInt32(ja4[i]["id"].ToString()));
+				list2.Add(Convert.ToInt32(ja4[i]["position"].ToString()));
+				list3.Add(ja4[i]["component_no"].ToString());
+			}
+			int result = 0;
+			foreach (int i in list1)
+			{
+				//context.Response.Write(i + "___");
+				string data2 = @"
+                INSERT INTO TP_DEV_DEVICEONUSING(ID,CREATETIME) VALUES({ID},SYSDATE)               
+                ".Replace("{ID}", i + "");
+				result += conn.ExecuteNonQuery(data2);
+			}
+		}
+			Curtain.Log.Logger.Debug("在用电能设备获取成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 获取设备电量
+	/// </summary>
+	public static void getDeviceElectronicCharge()
+	{
+		try
+        {
+			using (IDataAccess conn = DataAccess.Create())
+		{
+            string data00 = @"
+            DELETE
+            FROM
+            TP_DEV_DEVICEELECTRICCHARGE
+			WHERE TRUNC(DEVICEDATE,'DD') = TRUNC(SYSDATE,'DD')
+            ";
+            DataTable dt00 = conn.ExecuteDatatable(data00);
+            string data0 = @"
+            SELECT
+            ID
+            FROM
+            TP_DEV_DEVICEONUSING           
+            ";
+			DataTable dt = conn.ExecuteDatatable(data0);
+			string str = "";
+			int result = 0;
+			for (int n = 0; n < dt.Rows.Count; n++)
+			{
+				int num = Convert.ToInt32(dt.Rows[n]["ID"] + "");
+				string data2 = @"{
+                         ""appid"": ""ETP001018"",
+				         ""token"": ""6d06bb6d2173a4fdcfd098eba8a6605c"",
+				         ""meter_id"": {ID}
+                    }
+                    ".Replace("{ID}", num + "");
+				string url = "http://htemp.cn/opi/energy";// 生产
+				string message = JsonClient.Post(url, data2.ToString());
+
+				Curtain.Log.Logger.Info(message);
+
+				JObject ja = new JObject();
+				ja = (JObject)JsonConvert.DeserializeObject(message); //反序列化为数组
+
+				string code = ja["code"].ToString();
+				string msg = ja["msg"].ToString();
+				string timestamp = ja["timestamp"].ToString();
+				string data = ja["data"].ToString();
+				JArray ja2 = new JArray();
+				ja2 = (JArray)JsonConvert.DeserializeObject("[" + data + "]"); //反序列化为数组
+				string meter_id = ja2[0]["meter_id"].ToString();
+				string item = ja2[0]["item"].ToString();
+
+				//JArray ja3 = (JArray)JsonConvert.DeserializeObject(item); //反序列化为数组
+				//string device = ja3[0]["device"].ToString();
+				//string maters = ja3[0]["maters"].ToString();
+				//for (int i = 0 + 1; i < ja3.Count; i++)
+				//{
+				//    device += "," + ja3[i]["device"].ToString();
+				//    maters += "," + ja3[i]["maters"].ToString();
+				//}
+				str = "[" + item.Replace("[", "").Replace("]", "") + "]";
+				JArray ja4 = new JArray();
+				ja4 = (JArray)JsonConvert.DeserializeObject(str); //反序列化为数组
+				string date = "_";
+				double epi = 0;
+				double etp = 0;
+				double eta = 0;
+				double etv = 0;
+				
+				for (int m = 0; m < ja4.Count; m++)
+				{
+					if (ja4[m].ToString().IndexOf("date") > 0)
+					{
+						date = ja4[m]["date"].ToString();
+					}
+					if (ja4[m].ToString().IndexOf("epi") > 0)
+					{
+						epi = Convert.ToDouble(ja4[m]["epi"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("etp") > 0)
+					{
+						etp = Convert.ToDouble(ja4[m]["etp"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("eta") > 0)
+					{
+						eta = Convert.ToDouble(ja4[m]["eta"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("etv") > 0)
+					{
+						etv = Convert.ToDouble(ja4[m]["etv"].ToString());
+					}
+					string data3 = @"
+                    INSERT INTO TP_DEV_DEVICEELECTRICCHARGE(APPID,TOKEN,METER_ID,DEVICEDATE,EPI,ETP,ETA,ETV,CREATETIME)
+                    VALUES('ETP001018','6d06bb6d2173a4fdcfd098eba8a6605c',{ID},TO_DATE('{DATE}', 'YYYY-MM-DD HH24-MI-SS'),{EPI},{ETP},{ETA},{ETV},SYSDATE)         
+                    ".Replace("{ID}", num + "").Replace("{DATE}", date).Replace("{EPI}", epi + "").Replace("{ETP}", etp + "").Replace("{ETA}", eta + "").Replace("{ETV}", etv + "");
+					result += conn.ExecuteNonQuery(data3);
+				}
+			}
+		}
+			Curtain.Log.Logger.Debug("电能数据获取成功!" );
+        }
+        catch(Exception ex)
+        {
+			Curtain.Log.Logger.Error(ex);
+        }
+
+	}
+}

+ 722 - 0
wwwroot/App_Code/PushData20211104.cs

@@ -0,0 +1,722 @@
+using System;
+using System.Web;
+using System.Web.SessionState;
+using System.Data;
+using System.Collections;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+
+public static class PushData20211104
+{
+	//private static string _url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+	private static string _url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+
+	/// <summary>
+	/// 烘干区
+	/// </summary>
+	public static void export02()
+	{
+		try {
+			using (IDataAccess conn = DataAccess.Create())
+			{
+				DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'HGQ' || p.PLC_ID AS deviceCode,
+				'烘干区' || P.PLC_NAME AS name 
+			FROM
+				T_XT_PLC_V V
+				INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+			WHERE
+				V.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND V.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				p.PLC_ID,
+				P.PLC_NAME 
+			ORDER BY
+				P.PLC_NAME"
+				);
+
+				DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.FNTEMPERATURE_房内温度,
+				t.SDTEMPERATURE_设定温度,
+				t.FNHUMIDITY_房内湿度,
+				t.SDHUMIDITY_设定湿度,
+				t.RSSTEMPERATURE_燃烧室温度,
+				t.YRTEMPERATURE_余热温度 
+			FROM
+				(
+				SELECT
+					'HGQ' || p.PLC_ID AS deviceCode,
+					'烘干区' || P.PLC_NAME AS name,
+					nvl( V.V100, 0 ) AS FNTEMPERATURE_房内温度,
+					nvl( V.V104, 0 ) AS SDTEMPERATURE_设定温度,
+					nvl( V.V108, 0 ) AS FNHUMIDITY_房内湿度,
+					nvl( V.V112, 0 ) AS SDHUMIDITY_设定湿度,
+					nvl( V.V120, 0 ) AS RSSTEMPERATURE_燃烧室温度,
+					nvl( V.V124, 0 ) AS YRTEMPERATURE_余热温度,
+					rank ( ) over ( PARTITION BY P.PLC_ID ORDER BY V.VID DESC ) AS rk 
+				FROM
+					T_XT_PLC_V V
+					INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+				WHERE
+					V.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND V.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+				);
+
+				if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+				{
+					return;
+				}
+
+				// 拼接主体
+				JObject data = new JObject();
+				data.Add(new JProperty("industryName", "广东区域"));
+				data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+				data.Add(new JProperty("productName", "烘干区"));
+				data.Add(new JProperty("productCode", "FSHJHGQ"));
+				data.Add(new JProperty("protocol", "HTTP"));
+				data.Add(new JProperty("classfy", "陶瓷生产设备"));
+				data.Add(new JProperty("lever", "低端"));
+				data.Add(new JProperty("dimension", "工业品"));
+
+				// 拼接device
+				JArray arrDevice = new JArray();
+				JObject device = null;
+				foreach (DataRow row in dtDevice.Rows)
+				{
+					device = new JObject();
+					device.Add(new JProperty("name", row["name"]));
+					device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					device.Add(new JProperty("province", "广东省"));
+					device.Add(new JProperty("city", "佛山市"));
+					device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+					device.Add(new JProperty("worth", "0"));
+					device.Add(new JProperty("latitude", "0"));
+					device.Add(new JProperty("longitude", "0"));
+					device.Add(new JProperty("manufacture", "2021-10-13"));
+					arrDevice.Add(device);
+				}
+				data.Add("device", arrDevice);
+
+				// 拼接deviceData
+				JArray arrDeviceData = new JArray();
+				JObject deviceData = null;
+				string[] colNames;
+
+				// 时间戳
+				TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+				string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+				foreach (DataRow row in dtDeviceData.Rows)
+				{
+					foreach (DataColumn col in dtDeviceData.Columns)
+					{
+						if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+						{
+							continue;
+						}
+
+						colNames = col.ColumnName.Split('_');
+						deviceData = new JObject();
+						deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+						deviceData.Add(new JProperty("name", colNames[1]));
+						deviceData.Add(new JProperty("mark", colNames[0]));
+						deviceData.Add(new JProperty("value", row[col].ToString()));
+						deviceData.Add(new JProperty("timestamp", timestamp));
+						arrDeviceData.Add(deviceData);
+					}
+				}
+
+				data.Add("deviceData", arrDeviceData);
+
+				//上报数据
+				string message = JsonClient.Post(_url, data.ToString());
+			}
+			Curtain.Log.Logger.Debug("烘干区数据上报成功!");
+		}
+		catch (Exception ex) {
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 施釉房
+	/// </summary>
+	public static void export03()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+				'施釉房' || GD.GLAZINGROOM AS name 
+			FROM
+				TP_PM_PRODUCTIONDATA P
+				INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+				INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+			WHERE
+				P.PROCEDUREID = 98 
+				AND P.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND P.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				GD.GLAZINGROOM 
+			ORDER BY
+				GD.GLAZINGROOM"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TEMP_釉温,
+				t.PRESSURE_釉压 
+			FROM
+				(
+				SELECT
+					'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+					'施釉房' || GD.GLAZINGROOM AS name,
+					G.G_TEMP AS TEMP_釉温,
+					G.G_PRESSURE AS PRESSURE_釉压,
+					rank ( ) over ( PARTITION BY GD.GLAZINGROOM ORDER BY P.GROUTINGDAILYDETAILID DESC ) AS rk 
+				FROM
+					TP_PM_PRODUCTIONDATA P
+					INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+					INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+				WHERE
+					P.PROCEDUREID = 98 
+					AND P.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND P.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "施釉房"));
+			data.Add(new JProperty("productCode", "FSHJSYF"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("施釉房数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 成品测漏
+	/// </summary>
+	public static void export04()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'CPCL' || W.WORKSTATIONID AS deviceCode,
+				'成品测漏' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 1 
+				AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果,
+				t.LEAKAGE_泄漏量 
+			FROM
+				(
+				SELECT
+					'CPCL' || W.WORKSTATIONID AS deviceCode,
+					'成品测漏' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					L.LEAKAGE AS LEAKAGE_泄漏量,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 1 
+					AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "成品测漏"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("成品侧漏数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 试用结果
+	/// </summary>
+	public static void export05()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYJG' || W.WORKSTATIONID AS deviceCode,
+				'试用结果' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 2 
+				AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果
+			FROM
+				(
+				SELECT
+					'SYJG' || W.WORKSTATIONID AS deviceCode,
+					'试用结果' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 2
+					AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "试用结果"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("试用数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 获取在用电能设备
+	/// </summary>
+	public static void getDeviceId()
+	{
+        try {
+		using (IDataAccess conn = DataAccess.Create())
+		{
+            string data00 = @"
+             DELETE FROM TP_DEV_DEVICEONUSING            
+             ";
+            int result00 = conn.ExecuteNonQuery(data00);
+            string data0 = @"{
+                ""appid"": ""ETP001018"",
+				""token"": ""6d06bb6d2173a4fdcfd098eba8a6605c""
+            }
+            ";
+			string url = "http://htemp.net/opi/devices";// 生产
+			string message = JsonClient.Post(url, data0.ToString());
+			//Dictionary<string, object> ret = JsonHelper.JsonToDictionaryso(message + "");
+			//JsonConvert.DeserializeObject<Dictionary<string, object>>(message);
+
+			JObject ja = (JObject)JsonConvert.DeserializeObject(message); //反序列化为数组
+
+			string code = ja["code"].ToString();
+			string msg = ja["msg"].ToString();
+			string timestamp = ja["timestamp"].ToString();
+			string data = ja["data"].ToString();
+
+			JArray ja2 = (JArray)JsonConvert.DeserializeObject(data); //反序列化为数组
+			string name = ja2[0]["name"].ToString();
+			string item = ja2[0]["item"].ToString();
+
+			JArray ja3 = (JArray)JsonConvert.DeserializeObject(item); //反序列化为数组
+			string device = ja3[0]["device"].ToString();
+			string maters = ja3[0]["maters"].ToString();
+			for (int i = 0 + 1; i < ja3.Count; i++)
+			{
+				device += "," + ja3[i]["device"].ToString();
+				maters += "," + ja3[i]["maters"].ToString();
+			}
+			string str = "[" + maters.Replace("[", "").Replace("]", "") + "]";
+
+			JArray ja4 = (JArray)JsonConvert.DeserializeObject(str); //反序列化为数组
+			List<int> list1 = new List<int>();
+			list1.Add(Convert.ToInt32(ja4[0]["id"].ToString()));
+			List<int> list2 = new List<int>();
+			list2.Add(Convert.ToInt32(ja4[0]["position"].ToString()));
+			List<string> list3 = new List<string>();
+			list3.Add(ja4[0]["component_no"].ToString());
+			for (int i = 0 + 1; i < ja4.Count; i++)
+			{
+				list1.Add(Convert.ToInt32(ja4[i]["id"].ToString()));
+				list2.Add(Convert.ToInt32(ja4[i]["position"].ToString()));
+				list3.Add(ja4[i]["component_no"].ToString());
+			}
+			int result = 0;
+			foreach (int i in list1)
+			{
+				//context.Response.Write(i + "___");
+				string data2 = @"
+                INSERT INTO TP_DEV_DEVICEONUSING(ID,CREATETIME) VALUES({ID},SYSDATE)               
+                ".Replace("{ID}", i + "");
+				result += conn.ExecuteNonQuery(data2);
+			}
+		}
+			Curtain.Log.Logger.Debug("在用电能设备获取成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 获取设备电量
+	/// </summary>
+	public static void getDeviceElectronicCharge()
+	{
+		try
+        {
+			using (IDataAccess conn = DataAccess.Create())
+		{
+            string data00 = @"
+            DELETE
+            FROM
+            TP_DEV_DEVICEELECTRICCHARGE
+			WHERE TRUNC(DEVICEDATE,'DD') = TRUNC(SYSDATE,'DD')
+            ";
+            DataTable dt00 = conn.ExecuteDatatable(data00);
+            string data0 = @"
+            SELECT
+            ID
+            FROM
+            TP_DEV_DEVICEONUSING           
+            ";
+			DataTable dt = conn.ExecuteDatatable(data0);
+			string str = "";
+			int result = 0;
+			for (int n = 0; n < dt.Rows.Count; n++)
+			{
+				int num = Convert.ToInt32(dt.Rows[n]["ID"] + "");
+				string data2 = @"{
+                         ""appid"": ""ETP001018"",
+				         ""token"": ""6d06bb6d2173a4fdcfd098eba8a6605c"",
+				         ""meter_id"": {ID}
+                    }
+                    ".Replace("{ID}", num + "");
+				string url = "http://htemp.net/opi/energy";// 生产
+				string message = JsonClient.Post(url, data2.ToString());
+				JObject ja = new JObject();
+				ja = (JObject)JsonConvert.DeserializeObject(message); //反序列化为数组
+
+				string code = ja["code"].ToString();
+				string msg = ja["msg"].ToString();
+				string timestamp = ja["timestamp"].ToString();
+				string data = ja["data"].ToString();
+				JArray ja2 = new JArray();
+				ja2 = (JArray)JsonConvert.DeserializeObject("[" + data + "]"); //反序列化为数组
+				string meter_id = ja2[0]["meter_id"].ToString();
+				string item = ja2[0]["item"].ToString();
+
+				//JArray ja3 = (JArray)JsonConvert.DeserializeObject(item); //反序列化为数组
+				//string device = ja3[0]["device"].ToString();
+				//string maters = ja3[0]["maters"].ToString();
+				//for (int i = 0 + 1; i < ja3.Count; i++)
+				//{
+				//    device += "," + ja3[i]["device"].ToString();
+				//    maters += "," + ja3[i]["maters"].ToString();
+				//}
+				str = "[" + item.Replace("[", "").Replace("]", "") + "]";
+				JArray ja4 = new JArray();
+				ja4 = (JArray)JsonConvert.DeserializeObject(str); //反序列化为数组
+				string date = "_";
+				double epi = 0;
+				double etp = 0;
+				double eta = 0;
+				double etv = 0;
+				
+				for (int m = 0; m < ja4.Count; m++)
+				{
+					if (ja4[m].ToString().IndexOf("date") > 0)
+					{
+						date = ja4[m]["date"].ToString();
+					}
+					if (ja4[m].ToString().IndexOf("epi") > 0)
+					{
+						epi = Convert.ToDouble(ja4[m]["epi"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("etp") > 0)
+					{
+						etp = Convert.ToDouble(ja4[m]["etp"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("eta") > 0)
+					{
+						eta = Convert.ToDouble(ja4[m]["eta"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("etv") > 0)
+					{
+						etv = Convert.ToDouble(ja4[m]["etv"].ToString());
+					}
+					string data3 = @"
+                    INSERT INTO TP_DEV_DEVICEELECTRICCHARGE(APPID,TOKEN,METER_ID,DEVICEDATE,EPI,ETP,ETA,ETV,CREATETIME)
+                    VALUES('ETP001018','6d06bb6d2173a4fdcfd098eba8a6605c',{ID},TO_DATE('{DATE}', 'YYYY-MM-DD HH24-MI-SS'),{EPI},{ETP},{ETA},{ETV},SYSDATE)         
+                    ".Replace("{ID}", num + "").Replace("{DATE}", date).Replace("{EPI}", epi + "").Replace("{ETP}", etp + "").Replace("{ETA}", eta + "").Replace("{ETV}", etv + "");
+					result += conn.ExecuteNonQuery(data3);
+				}
+			}
+		}
+			Curtain.Log.Logger.Debug("电能数据获取成功!");
+        }
+        catch(Exception ex)
+        {
+			Curtain.Log.Logger.Error(ex);
+        }
+
+	}
+}

+ 722 - 0
wwwroot/App_Code/PushDataCopy.cs

@@ -0,0 +1,722 @@
+using System;
+using System.Web;
+using System.Web.SessionState;
+using System.Data;
+using System.Collections;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+
+public static class PushDataCopy
+{
+	//private static string _url = "http://edge.cosmoplat.com:30152/company/device/access";// 测试
+	private static string _url = "http://edge.cosmoplat.com:30032/company/device/access";// 生产
+
+	/// <summary>
+	/// 烘干区
+	/// </summary>
+	public static void export02()
+	{
+		try {
+			using (IDataAccess conn = DataAccess.Create())
+			{
+				DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'HGQ' || p.PLC_ID AS deviceCode,
+				'烘干区' || P.PLC_NAME AS name 
+			FROM
+				T_XT_PLC_V V
+				INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+			WHERE
+				V.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND V.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				p.PLC_ID,
+				P.PLC_NAME 
+			ORDER BY
+				P.PLC_NAME"
+				);
+
+				DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.FNTEMPERATURE_房内温度,
+				t.SDTEMPERATURE_设定温度,
+				t.FNHUMIDITY_房内湿度,
+				t.SDHUMIDITY_设定湿度,
+				t.RSSTEMPERATURE_燃烧室温度,
+				t.YRTEMPERATURE_余热温度 
+			FROM
+				(
+				SELECT
+					'HGQ' || p.PLC_ID AS deviceCode,
+					'烘干区' || P.PLC_NAME AS name,
+					nvl( V.V100, 0 ) AS FNTEMPERATURE_房内温度,
+					nvl( V.V104, 0 ) AS SDTEMPERATURE_设定温度,
+					nvl( V.V108, 0 ) AS FNHUMIDITY_房内湿度,
+					nvl( V.V112, 0 ) AS SDHUMIDITY_设定湿度,
+					nvl( V.V120, 0 ) AS RSSTEMPERATURE_燃烧室温度,
+					nvl( V.V124, 0 ) AS YRTEMPERATURE_余热温度,
+					rank ( ) over ( PARTITION BY P.PLC_ID ORDER BY V.VID DESC ) AS rk 
+				FROM
+					T_XT_PLC_V V
+					INNER JOIN T_XT_PLC P ON P.PLC_ID = V.PLC_ID 
+				WHERE
+					V.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND V.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+				);
+
+				if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+				{
+					return;
+				}
+
+				// 拼接主体
+				JObject data = new JObject();
+				data.Add(new JProperty("industryName", "广东区域"));
+				data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+				data.Add(new JProperty("productName", "烘干区"));
+				data.Add(new JProperty("productCode", "FSHJHGQ"));
+				data.Add(new JProperty("protocol", "HTTP"));
+				data.Add(new JProperty("classfy", "陶瓷生产设备"));
+				data.Add(new JProperty("lever", "低端"));
+				data.Add(new JProperty("dimension", "工业品"));
+
+				// 拼接device
+				JArray arrDevice = new JArray();
+				JObject device = null;
+				foreach (DataRow row in dtDevice.Rows)
+				{
+					device = new JObject();
+					device.Add(new JProperty("name", row["name"]));
+					device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					device.Add(new JProperty("province", "广东省"));
+					device.Add(new JProperty("city", "佛山市"));
+					device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+					device.Add(new JProperty("worth", "0"));
+					device.Add(new JProperty("latitude", "0"));
+					device.Add(new JProperty("longitude", "0"));
+					device.Add(new JProperty("manufacture", "2021-10-13"));
+					arrDevice.Add(device);
+				}
+				data.Add("device", arrDevice);
+
+				// 拼接deviceData
+				JArray arrDeviceData = new JArray();
+				JObject deviceData = null;
+				string[] colNames;
+
+				// 时间戳
+				TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+				string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+				foreach (DataRow row in dtDeviceData.Rows)
+				{
+					foreach (DataColumn col in dtDeviceData.Columns)
+					{
+						if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+						{
+							continue;
+						}
+
+						colNames = col.ColumnName.Split('_');
+						deviceData = new JObject();
+						deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+						deviceData.Add(new JProperty("name", colNames[1]));
+						deviceData.Add(new JProperty("mark", colNames[0]));
+						deviceData.Add(new JProperty("value", row[col].ToString()));
+						deviceData.Add(new JProperty("timestamp", timestamp));
+						arrDeviceData.Add(deviceData);
+					}
+				}
+
+				data.Add("deviceData", arrDeviceData);
+
+				//上报数据
+				string message = JsonClient.Post(_url, data.ToString());
+			}
+			Curtain.Log.Logger.Debug("烘干区数据上报成功!");
+		}
+		catch (Exception ex) {
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 施釉房
+	/// </summary>
+	public static void export03()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+				'施釉房' || GD.GLAZINGROOM AS name 
+			FROM
+				TP_PM_PRODUCTIONDATA P
+				INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+				INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+			WHERE
+				P.PROCEDUREID = 98 
+				AND P.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND P.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				GD.GLAZINGROOM 
+			ORDER BY
+				GD.GLAZINGROOM"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TEMP_釉温,
+				t.PRESSURE_釉压 
+			FROM
+				(
+				SELECT
+					'SYF' || REPLACE ( GD.GLAZINGROOM, '#', '' ) AS deviceCode,
+					'施釉房' || GD.GLAZINGROOM AS name,
+					G.G_TEMP AS TEMP_釉温,
+					G.G_PRESSURE AS PRESSURE_釉压,
+					rank ( ) over ( PARTITION BY GD.GLAZINGROOM ORDER BY P.GROUTINGDAILYDETAILID DESC ) AS rk 
+				FROM
+					TP_PM_PRODUCTIONDATA P
+					INNER JOIN TP_PM_GROUTINGDAILYDETAIL GD ON GD.GROUTINGDAILYDETAILID = P.GROUTINGDAILYDETAILID
+					INNER JOIN TP_PM_GOODSGLAZING G ON P.GROUTINGDAILYDETAILID = G.GROUTINGDAILYDETAILID 
+				WHERE
+					P.PROCEDUREID = 98 
+					AND P.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND P.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "施釉房"));
+			data.Add(new JProperty("productCode", "FSHJSYF"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("施釉房数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 成品测漏
+	/// </summary>
+	public static void export04()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'CPCL' || W.WORKSTATIONID AS deviceCode,
+				'成品测漏' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 1 
+				AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果,
+				t.LEAKAGE_泄漏量 
+			FROM
+				(
+				SELECT
+					'CPCL' || W.WORKSTATIONID AS deviceCode,
+					'成品测漏' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					L.LEAKAGE AS LEAKAGE_泄漏量,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 1 
+					AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "成品测漏"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("成品侧漏数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 试用结果
+	/// </summary>
+	public static void export05()
+	{
+        try { 
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			DataTable dtDevice = conn.ExecuteDatatable(@"
+			SELECT
+				'SYJG' || W.WORKSTATIONID AS deviceCode,
+				'试用结果' || W.WORKSTATIONNAME AS name 
+			FROM
+				TP_PM_GOODSLEAK L
+				INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+			WHERE
+				L.LEAKTYPE = 2 
+				AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+			GROUP BY
+				W.WORKSTATIONID,
+				W.WORKSTATIONNAME 
+			ORDER BY
+				W.WORKSTATIONNAME"
+			);
+
+			DataTable dtDeviceData = conn.ExecuteDatatable(@"
+			SELECT
+				t.deviceCode,
+				t.name,
+				t.TESTRESULT_测试结果
+			FROM
+				(
+				SELECT
+					'SYJG' || W.WORKSTATIONID AS deviceCode,
+					'试用结果' || W.WORKSTATIONNAME AS name,
+					DECODE( L.IS_GOOD, 0, '不合格', 1, '合格', '' ) AS TESTRESULT_测试结果,
+					rank ( ) over ( PARTITION BY W.WORKSTATIONNAME ORDER BY L.CREATETIME DESC ) AS rk 
+				FROM
+					TP_PM_GOODSLEAK L
+					INNER JOIN TP_MST_WORKSTATION W ON W.WORKSTATIONID = L.WS_ID 
+				WHERE
+					L.LEAKTYPE = 2
+					AND L.CREATETIME >= to_date( to_char( SYSDATE, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+					AND L.CREATETIME < to_date( to_char( SYSDATE + 1 / 24, 'yyyy-mm-dd hh' ), 'yyyy-mm-dd hh:mi:ss' ) 
+				) t 
+			WHERE
+				t.rk <= 1 
+			ORDER BY
+				t.name"
+			);
+
+			if (dtDevice.Rows.Count == 0 || dtDeviceData.Rows.Count == 0)
+			{
+				return;
+			}
+
+			// 拼接主体
+			JObject data = new JObject();
+			data.Add(new JProperty("industryName", "广东区域"));
+			data.Add(new JProperty("companyName", "佛山恒洁卫浴有限公司"));
+			data.Add(new JProperty("productName", "试用结果"));
+			data.Add(new JProperty("productCode", "FSHJCPCL"));
+			data.Add(new JProperty("protocol", "HTTP"));
+			data.Add(new JProperty("classfy", "陶瓷生产设备"));
+			data.Add(new JProperty("lever", "低端"));
+			data.Add(new JProperty("dimension", "工业品"));
+
+			// 拼接device
+			JArray arrDevice = new JArray();
+			JObject device = null;
+			foreach (DataRow row in dtDevice.Rows)
+			{
+				device = new JObject();
+				device.Add(new JProperty("name", row["name"]));
+				device.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+				device.Add(new JProperty("province", "广东省"));
+				device.Add(new JProperty("city", "佛山市"));
+				device.Add(new JProperty("address", "三水区乐平镇中油大道 3 号"));
+				device.Add(new JProperty("worth", "0"));
+				device.Add(new JProperty("latitude", "0"));
+				device.Add(new JProperty("longitude", "0"));
+				device.Add(new JProperty("manufacture", "2021-10-13"));
+				arrDevice.Add(device);
+			}
+			data.Add("device", arrDevice);
+
+			// 拼接deviceData
+			JArray arrDeviceData = new JArray();
+			JObject deviceData = null;
+			string[] colNames;
+
+			// 时间戳
+			TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+			string timestamp = Convert.ToInt64(ts.TotalMilliseconds).ToString();
+
+			foreach (DataRow row in dtDeviceData.Rows)
+			{
+				foreach (DataColumn col in dtDeviceData.Columns)
+				{
+					if (col.ColumnName.Equals("DEVICECODE") || col.ColumnName.Equals("NAME"))
+					{
+						continue;
+					}
+
+					colNames = col.ColumnName.Split('_');
+					deviceData = new JObject();
+					deviceData.Add(new JProperty("deviceCode", "FSHJ" + row["deviceCode"]));
+					deviceData.Add(new JProperty("name", colNames[1]));
+					deviceData.Add(new JProperty("mark", colNames[0]));
+					deviceData.Add(new JProperty("value", row[col].ToString()));
+					deviceData.Add(new JProperty("timestamp", timestamp));
+					arrDeviceData.Add(deviceData);
+				}
+			}
+
+			data.Add("deviceData", arrDeviceData);
+
+			//上报数据
+			string message = JsonClient.Post(_url, data.ToString());
+		}
+			Curtain.Log.Logger.Debug("试用数据上报成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 获取在用电能设备
+	/// </summary>
+	public static void getDeviceId()
+	{
+        try {
+		using (IDataAccess conn = DataAccess.Create())
+		{
+            string data00 = @"
+             DELETE FROM TP_DEV_DEVICEONUSING            
+             ";
+            int result00 = conn.ExecuteNonQuery(data00);
+            string data0 = @"{
+                ""appid"": ""ETP001018"",
+				""token"": ""6d06bb6d2173a4fdcfd098eba8a6605c""
+            }
+            ";
+			string url = "http://htemp.net/opi/devices";// 生产
+			string message = JsonClient.Post(url, data0.ToString());
+			//Dictionary<string, object> ret = JsonHelper.JsonToDictionaryso(message + "");
+			//JsonConvert.DeserializeObject<Dictionary<string, object>>(message);
+
+			JObject ja = (JObject)JsonConvert.DeserializeObject(message); //反序列化为数组
+
+			string code = ja["code"].ToString();
+			string msg = ja["msg"].ToString();
+			string timestamp = ja["timestamp"].ToString();
+			string data = ja["data"].ToString();
+
+			JArray ja2 = (JArray)JsonConvert.DeserializeObject(data); //反序列化为数组
+			string name = ja2[0]["name"].ToString();
+			string item = ja2[0]["item"].ToString();
+
+			JArray ja3 = (JArray)JsonConvert.DeserializeObject(item); //反序列化为数组
+			string device = ja3[0]["device"].ToString();
+			string maters = ja3[0]["maters"].ToString();
+			for (int i = 0 + 1; i < ja3.Count; i++)
+			{
+				device += "," + ja3[i]["device"].ToString();
+				maters += "," + ja3[i]["maters"].ToString();
+			}
+			string str = "[" + maters.Replace("[", "").Replace("]", "") + "]";
+
+			JArray ja4 = (JArray)JsonConvert.DeserializeObject(str); //反序列化为数组
+			List<int> list1 = new List<int>();
+			list1.Add(Convert.ToInt32(ja4[0]["id"].ToString()));
+			List<int> list2 = new List<int>();
+			list2.Add(Convert.ToInt32(ja4[0]["position"].ToString()));
+			List<string> list3 = new List<string>();
+			list3.Add(ja4[0]["component_no"].ToString());
+			for (int i = 0 + 1; i < ja4.Count; i++)
+			{
+				list1.Add(Convert.ToInt32(ja4[i]["id"].ToString()));
+				list2.Add(Convert.ToInt32(ja4[i]["position"].ToString()));
+				list3.Add(ja4[i]["component_no"].ToString());
+			}
+			int result = 0;
+			foreach (int i in list1)
+			{
+				//context.Response.Write(i + "___");
+				string data2 = @"
+                INSERT INTO TP_DEV_DEVICEONUSING(ID,CREATETIME) VALUES({ID},SYSDATE)               
+                ".Replace("{ID}", i + "");
+				result += conn.ExecuteNonQuery(data2);
+			}
+		}
+			Curtain.Log.Logger.Debug("在用电能设备获取成功!");
+		}
+		catch (Exception ex)
+		{
+			Curtain.Log.Logger.Error(ex);
+		}
+	}
+
+	/// <summary>
+	/// 获取设备电量
+	/// </summary>
+	public static void getDeviceElectronicCharge()
+	{
+		try
+        {
+			using (IDataAccess conn = DataAccess.Create())
+		{
+            string data00 = @"
+            DELETE
+            FROM
+            TP_DEV_DEVICEELECTRICCHARGE
+			WHERE TRUNC(DEVICEDATE,'DD') = TRUNC(SYSDATE,'DD')
+            ";
+            DataTable dt00 = conn.ExecuteDatatable(data00);
+            string data0 = @"
+            SELECT
+            ID
+            FROM
+            TP_DEV_DEVICEONUSING           
+            ";
+			DataTable dt = conn.ExecuteDatatable(data0);
+			string str = "";
+			int result = 0;
+			for (int n = 0; n < dt.Rows.Count; n++)
+			{
+				int num = Convert.ToInt32(dt.Rows[n]["ID"] + "");
+				string data2 = @"{
+                         ""appid"": ""ETP001018"",
+				         ""token"": ""6d06bb6d2173a4fdcfd098eba8a6605c"",
+				         ""meter_id"": {ID}
+                    }
+                    ".Replace("{ID}", num + "");
+				string url = "http://htemp.net/opi/energy";// 生产
+				string message = JsonClient.Post(url, data2.ToString());
+				JObject ja = new JObject();
+				ja = (JObject)JsonConvert.DeserializeObject(message); //反序列化为数组
+
+				string code = ja["code"].ToString();
+				string msg = ja["msg"].ToString();
+				string timestamp = ja["timestamp"].ToString();
+				string data = ja["data"].ToString();
+				JArray ja2 = new JArray();
+				ja2 = (JArray)JsonConvert.DeserializeObject("[" + data + "]"); //反序列化为数组
+				string meter_id = ja2[0]["meter_id"].ToString();
+				string item = ja2[0]["item"].ToString();
+
+				//JArray ja3 = (JArray)JsonConvert.DeserializeObject(item); //反序列化为数组
+				//string device = ja3[0]["device"].ToString();
+				//string maters = ja3[0]["maters"].ToString();
+				//for (int i = 0 + 1; i < ja3.Count; i++)
+				//{
+				//    device += "," + ja3[i]["device"].ToString();
+				//    maters += "," + ja3[i]["maters"].ToString();
+				//}
+				str = "[" + item.Replace("[", "").Replace("]", "") + "]";
+				JArray ja4 = new JArray();
+				ja4 = (JArray)JsonConvert.DeserializeObject(str); //反序列化为数组
+				string date = "_";
+				double epi = 0;
+				double etp = 0;
+				double eta = 0;
+				double etv = 0;
+				
+				for (int m = 0; m < ja4.Count; m++)
+				{
+					if (ja4[m].ToString().IndexOf("date") > 0)
+					{
+						date = ja4[m]["date"].ToString();
+					}
+					if (ja4[m].ToString().IndexOf("epi") > 0)
+					{
+						epi = Convert.ToDouble(ja4[m]["epi"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("etp") > 0)
+					{
+						etp = Convert.ToDouble(ja4[m]["etp"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("eta") > 0)
+					{
+						eta = Convert.ToDouble(ja4[m]["eta"].ToString());
+					}
+					if (ja4[m].ToString().IndexOf("etv") > 0)
+					{
+						etv = Convert.ToDouble(ja4[m]["etv"].ToString());
+					}
+					string data3 = @"
+                    INSERT INTO TP_DEV_DEVICEELECTRICCHARGE(APPID,TOKEN,METER_ID,DEVICEDATE,EPI,ETP,ETA,ETV,CREATETIME)
+                    VALUES('ETP001018','6d06bb6d2173a4fdcfd098eba8a6605c',{ID},TO_DATE('{DATE}', 'YYYY-MM-DD HH24-MI-SS'),{EPI},{ETP},{ETA},{ETV},SYSDATE)         
+                    ".Replace("{ID}", num + "").Replace("{DATE}", date).Replace("{EPI}", epi + "").Replace("{ETP}", etp + "").Replace("{ETA}", eta + "").Replace("{ETV}", etv + "");
+					result += conn.ExecuteNonQuery(data3);
+				}
+			}
+		}
+			Curtain.Log.Logger.Debug("电能数据获取成功!");
+        }
+        catch(Exception ex)
+        {
+			Curtain.Log.Logger.Error(ex);
+        }
+
+	}
+}

+ 17 - 0
wwwroot/App_Data/PublishProfiles/三水厂172.18.32.32.pubxml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+https://go.microsoft.com/fwlink/?LinkID=208121. 
+-->
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <DeleteExistingFiles>False</DeleteExistingFiles>
+    <ExcludeApp_Data>False</ExcludeApp_Data>
+    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
+    <LastUsedPlatform>Any CPU</LastUsedPlatform>
+    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
+    <PublishProvider>FileSystem</PublishProvider>
+    <PublishUrl>\\172.18.32.32\d$\dongke\IBOSS.PRD\DK.MES.EXPORT.9500</PublishUrl>
+    <WebPublishMethod>FileSystem</WebPublishMethod>
+    <SiteUrlToLaunchAfterPublish />
+  </PropertyGroup>
+</Project>

+ 96 - 0
wwwroot/Global.asax

@@ -0,0 +1,96 @@
+<%@ Application Language="C#" %>
+<%@ Import Namespace="Curtain.DataAccess" %>
+<%@ Import Namespace="Curtain.Log" %>
+<%@ Import Namespace="DK.XuWei.WebMes" %>
+
+<script runat="server">
+
+    void Application_Start(object sender, EventArgs e)
+    {
+        // 在应用程序启动时运行的代码
+        string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
+        DataAccess.DefaultParameterType = SQLParameterType.CDA;
+        DataAccess.DefaultDataBaseType = Curtain.DataAccess.DataBaseType.Oracle;
+        DataAccess.DefaultConnectionString = connStr;
+
+        Curtain.Log.Logger.Debug("系统定时推送启动!");
+
+        PushData.export02();    // 烘干区
+        PushData.export03();    // 施釉房
+        PushData.export04();    // 成品检测
+        PushData.export05();    // 使用结果
+        PushData.getDeviceId();    // 获取在用电能设备
+        PushData.getDeviceElectronicCharge();    // 获取设备电量
+
+        //定时器任务 自动推送数据
+        tr_Load();
+    }
+
+    void Application_End(object sender, EventArgs e)
+    {
+        //  在应用程序关闭时运行的代码
+        System.Threading.Thread.Sleep(1000);
+        string url = "http://172.18.32.32:9500/api/start.ashx";
+        System.Net.HttpWebRequest myHttpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
+        System.Net.HttpWebResponse myHttpWebResponse = (System.Net.HttpWebResponse)myHttpWebRequest.GetResponse();
+        System.IO.Stream receiveStream = myHttpWebResponse.GetResponseStream();
+        myHttpWebResponse.Close();
+        receiveStream.Close();
+    }
+
+    void Application_Error(object sender, EventArgs e)
+    {
+        // 在出现未处理的错误时运行的代码
+        //Exception error = Server.GetLastError().GetBaseException();
+        //if (error != null)
+        //{
+        //    //记录日志
+        //    Logger.Error(error);
+        //    //输出错误信息
+        //    HttpContext.Current.Response.Write(new JsonResult(JsonStatus.otherError).ToJson());
+        //}
+        //Server.ClearError();
+    }
+
+    void Session_Start(object sender, EventArgs e)
+    {
+        // 在新会话启动时运行的代码
+
+    }
+
+    void Session_End(object sender, EventArgs e)
+    {
+        // 在会话结束时运行的代码。 
+        // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
+        // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
+        // 或 SQLServer,则不引发该事件。
+
+    }
+
+    //定时器任务 自动推送数据===============================
+    void tr_Load()
+    {
+        //取刷新时间1小时
+        int refreshTime = 900000;
+
+        //设置timer
+        System.Timers.Timer tr = new System.Timers.Timer(refreshTime);
+        tr.Elapsed += new System.Timers.ElapsedEventHandler(tr_Elapsed);
+        tr.Enabled = true;
+        tr.AutoReset = true;
+    }
+
+    void tr_Elapsed(object sender, EventArgs e)
+    {
+        PushData.export02();    // 烘干区
+        PushData.export03();    // 施釉房
+        PushData.export04();    // 成品检测
+        PushData.export05();    // 使用结果
+        PushData.getDeviceId();    // 获取在用电能设备
+        PushData.getDeviceElectronicCharge();    // 获取设备电量
+
+        //Curtain.Log.Logger.Debug(DateTime.Now.ToString());
+
+    }
+
+</script>

+ 37 - 0
wwwroot/Web.config

@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!--
+  有关如何配置 ASP.NET 应用程序的详细信息,请访问
+  https://go.microsoft.com/fwlink/?LinkId=169433
+-->
+<configuration>
+  <connectionStrings>
+    <!--三水服务器-->
+    <add name="ConnectionString" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.18.32.51)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=hgmes)));User Id=hgiboss;Password=dongke" providerName="Oracle.ManagedDataAccess.Client"/>
+  </connectionStrings>
+  <appSettings>
+    <add key="ProductCheckServer" value="http://172.18.32.32:5678"/>
+  </appSettings>
+  <system.web>
+    <customErrors mode="Off"/>
+    <compilation targetFramework="4.0" debug="true"/>
+    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" validateRequest="false"/>
+    <httpRuntime/>
+    <!--<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="1440"/>-->
+  </system.web>
+  <system.data>
+    <DbProviderFactories>
+      <remove invariant="Oracle.ManagedDataAccess.Client"/>
+      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
+    </DbProviderFactories>
+  </system.data>
+  <system.webServer>
+    <security>
+      <requestFiltering>
+        <requestLimits maxAllowedContentLength="1048576000"/>
+      </requestFiltering>
+    </security>
+    <staticContent>
+      <mimeMap fileExtension=".log" mimeType="text/plain"/>
+    </staticContent>
+  </system.webServer>
+</configuration>