|
|
@@ -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);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|