Commit 1bbaa06c authored by 史余彬's avatar 史余彬

静态数据,实时数据逻辑处理完成

parent 6b8408d9
......@@ -20,6 +20,7 @@ type StaticSqlLanguage struct {
JrxStaticSql string `ini:"jrx_static_sql"`
JylStaticSql string `ini:"jyl_static_sql"`
NbwystaticSql string `ini:"nbwy_static_sql"`
BmwystaticSql string `ini:"bmwy_static_sql"`
}
type RealTimeSqlLanguage struct {
......@@ -28,6 +29,9 @@ type RealTimeSqlLanguage struct {
JrxRealTimeSql string `ini:"jrx_real_time_sql"`
JylRealTimeSql string `ini:"jyl_real_time_sql"`
NbwyRealTimeSql string `ini:"nbwy_real_time_sql"`
BmwyRealTimeSql string `ini:"bmwy_real_time_sql"`
DeviceOffLineDataRealTimeSql string `ini:"device_off_Line_sql"`
AlarmMessDataRealTimeSql string `ini:"alarm_mess_data"`
}
/*
......@@ -261,12 +265,12 @@ type ReserWaterLevelData struct {
表面位移实时数据
*/
type DisplacementData struct {
Recordid string `xml:"recordid"`
Sensorno string `xml:"sensorno"`
Collectdate string `xml:"collectdate"`
Xvalue string `xml:"xvalue"`
Yvalue string `xml:"yvalue"`
Zvalue string `xml:"zvalue"`
Recordid string `grom:"recordid" xml:"recordid"`
Sensorno string `grom:"sensorno" xml:"sensorno"`
Collectdate string `grom:"collectdate" xml:"collectdate"`
Xvalue string `grom:"xvalue" xml:"xvalue"`
Yvalue string `grom:"yvalue" xml:"yvalue"`
Zvalue string `grom:"zvalue" xml:"zvalue"`
}
......@@ -283,7 +287,7 @@ type SaturationLineData struct {
/*
降雨量实时数据
*/
type RailfallData struct {
type RainfallData struct {
Recordid string `grom:"recordid" xml:"recordid"`
Sensorno string `grom:"sensorno" xml:"sensorno"`
Collectdate string `grom:"collectdate" xml:"collectdate"`
......
......@@ -95,7 +95,7 @@ supervisoryunit=北京康迪建设监理咨询有限公司
supervisorylevel=甲级
safetycheckunit=山东信力安全技术有限公司
safetychecklevel=甲级
safetyacceptancetime=2015-9-28
safetyacceptancetime=2015-09-28
safetyevaluationunit=山东信力安全技术有限公司
safetyevaluationlevel=甲级
filingperson=烟台中嘉矿业有限公司(岳翔宇)
......@@ -111,10 +111,15 @@ ksw_static_sql=SELECT equipno, equipname, installlocation, longitude, latitude,
jrx_static_sql=SELECT equipno, equipname, holedepth, burialdepth, longitude, latitude, altitude, isUsed, isSync FROM wkkInfo a INNER JOIN (SELECT ID FROM SensorInfo WHERE Location like '%浸润线%') b on a.equipname = b.ID
jyl_static_sql=SELECT equipno, equipname, longitude, latitude, altitude, isUsed, isSync FROM wkkInfo where equipname like '%雨量%'
nbwy_static_sql=SELECT equipno, equipname, longitude, latitude, altitude, isUsed, isSync FROM wkkInfo a INNER JOIN (SELECT ID FROM SensorInfo WHERE Location like '%内部位移%') b on a.equipname = b.ID
bmwy_static_sql=SELECT equipno, equipname, longitude, latitude, altitude, isUsed, isSync FROM wkkInfo a INNER JOIN (SELECT ID FROM SensorInfo WHERE Location like '位移%') b on a.equipname = b.ID
[RealTimeSqlLanguage]
gt_real_time_sql=SELECT b.equipno AS sensorno, a.upTempValue AS value, a.upTime AS collectdate from TempT a inner join (select equipno, equipname from [mssensors].[dbo].[wkkInfo] where equipname like '%干滩%') b on a.ID = b.equipname
ksw_real_time_sql=
jrx_real_time_sql=
jyl_real_time_sql=
nbwy_real_time_sql=
\ No newline at end of file
gt_real_time_sql=SELECT b.equipno AS sensorno, a.upTempValue AS value, CONVERT(varchar(100),a.upTime, 20) AS collectdate from TempT a inner join (select equipno, equipname from wkkInfo where equipname like '%干滩%') b on a.ID = b.equipname
ksw_real_time_sql=SELECT a.sensorno, a.set@p value, a.collectdate from (SELECT b.equipno AS sensorno, set@p=a.upTempValue/100, CONVERT(varchar(100), a.upTime, 20) AS collectdate from TempT a inner join (select a.equipno, a.equipname from wkkInfo a inner join (select ID from SensorInfo where Location like '%水位%') b on a.equipname = b.ID) b on a.ID = b.equipname) a
jrx_real_time_sql=SELECT a.sensorno, a.set@p value, a.collectdate from (SELECT b.equipno AS sensorno, set@p=a.upTempValue/100, CONVERT(varchar(100), a.upTime, 20) AS collectdate from [mssensors].[dbo].[TempT] a inner join (select a.equipno, a.equipname from [mssensors].[dbo].[wkkInfo] a inner join (select ID from [mssensors].[dbo].[SensorInfo] where Location like '%浸润线%') b on a.equipname = b.ID) b on a.ID = b.equipname) a
jyl_real_time_sql=SELECT b.equipno AS sensorno, a.upTempValue AS value, CONVERT(varchar(100),a.upTime,20) AS collectdate from [mssensors].[dbo].[TempT] a inner join (select equipno, equipname from [mssensors].[dbo].[wkkInfo] where equipname like '%雨量%') b on a.ID = b.equipname
nbwy_real_time_sql=SELECT b.equipno AS sensorno, a.upTempValue AS xvalue, 0 AS yvalue, CONVERT(varchar(100), a.upTime, 20) AS collectdate from [mssensors].[dbo].[TempT] a inner join (select a.equipno, a.equipname from [mssensors].[dbo].[wkkInfo] a inner join (select ID from [mssensors].[dbo].[SensorInfo] where Location like '%内部位移%') b on a.equipname = b.ID) b on a.ID = b.equipname
bmwy_real_time_sql=SELECT b.equipno AS sensorno, a.upTempValue AS xvalue, 0 AS yvalue, 0 AS zvalue, CONVERT(varchar(100), a.upTime, 20) AS collectdate from [mssensors].[dbo].[TempT] a inner join (select a.equipno, a.equipname from [mssensors].[dbo].[wkkInfo] a inner join (select ID from [mssensors].[dbo].[SensorInfo] where Location like '位移%') b on a.equipname = b.ID) b on a.ID = b.equipname
device_off_Line_sql=select equipno, CONVERT(VARCHAR(100), GETDATE(), 20) from TempT a right join (select equipno, equipname from wkkInfo) b on a.ID = b.equipname where a.ID is null
alarm_mess_data=select a.equipno AS sensorno, b.Temperature AS value, CASE b.warnTTemp WHEN '5' THEN '二级预警' WHEN '2' THEN '三级预警' END AS warninglevel, CONVERT(VARCHAR(100), b.warnTime, 20) AS warningdate from wkkInfo a inner join (select ID, Temperature, warnTTemp, warnTime from DataWarn where warnTime > convert(varchar(100), DATEADD(hour,-1,GETDATE()), 20)) b on a.equipname = b.ID
......@@ -30,7 +30,7 @@ func init() {
TailPond = new(common.TailPondInfor)
err = file.Section("wkkBasicInfo").MapTo(TailPond)
StaticSql = new(common.StaticSqlLanguage)
file.Section("staticSqlLanguage").MapTo(StaticSql)
file.Section("StaticSqlLanguage").MapTo(StaticSql)
RealTimeSql = new(common.RealTimeSqlLanguage)
file.Section("RealTimeSqlLanguage").MapTo(RealTimeSql)
common.ErrorPrintln("数据库连接信息映射异常", err)
......
package dao
import (
"shandong_datapush/common"
"shandong_datapush/config"
)
/*
干滩实时数据
*/
func GtRealDataProcess() []*common.DryBeachData {
row, err := config.DB.Query(config.RealTimeSql.GtRealTimeSql)
common.ErrorPrintln("干滩实时数据查询异常", err)
Arrs := make([]*common.DryBeachData, 0)
for row.Next() {
dryBeach := new(common.DryBeachData)
err := row.Scan(&dryBeach.Sensorno, &dryBeach.Value, &dryBeach.Collectdate)
common.ErrorPrintln("Scan 干滩实时数据关系映射异常", err)
Arrs = append(Arrs, dryBeach)
}
return Arrs
}
/*
库水位实时数据
*/
func KswRealDataProcess() []*common.ReserWaterLevelData {
row, err := config.DB.Query(config.RealTimeSql.KswRealTimeSql)
common.ErrorPrintln("库水位实时数据查询异常", err)
Arrs := make([]*common.ReserWaterLevelData, 0)
for row.Next() {
reserWater := new(common.ReserWaterLevelData)
err := row.Scan(&reserWater.Sensorno, &reserWater.Value, &reserWater.Collectdate)
common.ErrorPrintln("Scan 库水位实时数据关系映射异常", err)
Arrs = append(Arrs, reserWater)
}
return Arrs
}
/*
浸润线实时数据
*/
func JrxRealDataProcess() []*common.SaturationLineData {
row, err := config.DB.Query(config.RealTimeSql.JrxRealTimeSql)
common.ErrorPrintln("浸润线实时数据查询异常", err)
Arrs := make([]*common.SaturationLineData, 0)
for row.Next() {
saturation := new(common.SaturationLineData)
err := row.Scan(&saturation.Sensorno, &saturation.Value, &saturation.Collectdate)
common.ErrorPrintln("Scan 浸润线实时数据关系映射异常", err)
Arrs = append(Arrs, saturation)
}
return Arrs
}
/*
降雨量实时数据
*/
func JylRealDataProcess() []*common.RainfallData {
row, err := config.DB.Query(config.RealTimeSql.JylRealTimeSql)
common.ErrorPrintln("降雨量实时数据查询异常", err)
Arrs := make([]*common.RainfallData, 0)
for row.Next() {
rainfall := new(common.RainfallData)
err := row.Scan(&rainfall.Sensorno, &rainfall.Value, &rainfall.Collectdate)
common.ErrorPrintln("Scan 降雨量实时数据关系映射异常", err)
Arrs = append(Arrs, rainfall)
}
return Arrs
}
/*
内部位移实时数据
*/
func NbwyRealDataProcess() []*common.InclinometerData {
row, err := config.DB.Query(config.RealTimeSql.NbwyRealTimeSql)
common.ErrorPrintln("内部位移实时数据查询异常", err)
Arrs := make([]*common.InclinometerData, 0)
for row.Next() {
inclinometer := new(common.InclinometerData)
err := row.Scan(&inclinometer.Sensorno, &inclinometer.Xvalue, &inclinometer.Yvalue, &inclinometer.Collectdate)
common.ErrorPrintln("Scan 内部位移实时数据关系映射异常", err)
Arrs = append(Arrs, inclinometer)
}
return Arrs
}
/*
表面位移实时数据
*/
func BmwyRealDataProcess() []*common.DisplacementData {
row, err := config.DB.Query(config.RealTimeSql.BmwyRealTimeSql)
common.ErrorPrintln("表面位移实时数据查询异常", err)
Arrs := make([]*common.DisplacementData, 0)
for row.Next() {
displacement := new(common.DisplacementData)
err := row.Scan(&displacement.Sensorno, &displacement.Xvalue, &displacement.Yvalue, &displacement.Zvalue, &displacement.Collectdate)
common.ErrorPrintln("Scan 表面位移实时数据关系映射异常", err)
Arrs = append(Arrs, displacement)
}
return Arrs
}
/*
设备离线实时数据
*/
func DeviceOffLineRealDataProcess() []*common.DeviceOffLineData {
row, err := config.DB.Query(config.RealTimeSql.DeviceOffLineDataRealTimeSql)
common.ErrorPrintln("设备离线实时数据查询异常", err)
Arrs := make([]*common.DeviceOffLineData, 0)
for row.Next() {
deviceOffLine := new(common.DeviceOffLineData)
err := row.Scan(&deviceOffLine.Sensorno, &deviceOffLine.Collectdate)
common.ErrorPrintln("Scan 设备离线实时数据关系映射异常", err)
Arrs = append(Arrs, deviceOffLine)
}
return Arrs
}
/*
报警设备实时数据
*/
func AlarmDataRealDataProcess() []*common.AlarmMessData {
row, err := config.DB.Query(config.RealTimeSql.AlarmMessDataRealTimeSql)
common.ErrorPrintln("报警实时数据查询异常", err)
Arrs := make([]*common.AlarmMessData, 0)
for row.Next() {
alarmMess := new(common.AlarmMessData)
err := row.Scan(&alarmMess.Sensorno, &alarmMess.Value, &alarmMess.Warninglevel, &alarmMess.Warningdate)
common.ErrorPrintln("Scan 报警实时数据关系映射异常", err)
Arrs = append(Arrs, alarmMess)
}
return Arrs
}
package dao
import (
"fmt"
"shandong_datapush/common"
"shandong_datapush/config"
)
......@@ -104,4 +105,26 @@ func NeibuweiyiStaticData() []*common.InclinometerInfor {
Arrs = append(Arrs, saturation)
}
return Arrs
}
/*
表面位移静态数据
*/
func BiaomianweiyiStaticData() []*common.DisplacementInfor {
row, err := config.DB.Query(config.StaticSql.BmwystaticSql)
fmt.Println(">>>" , config.StaticSql.BmwystaticSql)
common.ErrorPrintln("表面位移静态数据查询异常", err)
defer func() {
err := row.Close()
common.ErrorPrintln("row 关闭异常", err)
}()
Arrs := make([]*common.DisplacementInfor, 0)
for row.Next() {
saturation := new(common.DisplacementInfor)
err := row.Scan(&saturation.Equipno, &saturation.Equipname, &saturation.Longitude, &saturation.Latitude, &saturation.Altitude, &saturation.IsUsed, &saturation.IsSync)
common.ErrorPrintln("scan 表面位移数据读取异常", err)
Arrs = append(Arrs, saturation)
}
return Arrs
}
\ No newline at end of file
......@@ -10,20 +10,22 @@ import (
func main() {
log.Println("==================数据推送程序启动=================")
config.DBConnection()
service.WkkBasicDataProcess()
service.KswStaticDataProcess()
service.GtStaticDataProcess()
service.JrxStaticDataProcess()
service.JylStaticDataProcess()
service.NbwyStaticDataProcess()
go staticDataPush()
realTimeDataPush()
}
/*
静态数据推送
*/
func staticDataPush() {
for range time.Tick(time.Second * 10){
for range time.Tick(time.Second * 10) {
log.Println("=======================================staticDataPush")
service.WkkBasicDataProcess()
service.KswStaticDataProcess()
service.GtStaticDataProcess()
service.JrxStaticDataProcess()
service.JylStaticDataProcess()
service.NbwyStaticDataProcess()
}
}
......@@ -31,7 +33,14 @@ func staticDataPush() {
实时数据推送
*/
func realTimeDataPush() {
for range time.Tick(time.Second * 20){
for range time.Tick(time.Second * 15) {
log.Println("=======================================realTimeDataPush")
service.GtRealTimeDataProcess()
service.KswRealTimeDataProcess()
service.JrxRealTimeDataProcess()
service.JylRealTimeDataProcess()
service.NbwyRealTimeDataProcess()
service.DOLRealTimeDataProcess()
service.AMSRealTimeDataProcess()
}
}
\ No newline at end of file
package service
import (
"encoding/xml"
"log"
"shandong_datapush/common"
"shandong_datapush/dao"
)
/*
干滩实时数据
*/
func GtRealDataProcess() {
/*row, err := config.DB.Query(config.RealTimeSql.GtRealTimeSql)
common.ErrorPrintln("干滩实时数据查询异常", err)
Arrs := make([]*common.DryBeachData, 0)
for row.Next() {
dryBeach := new(common.DryBeachData)
row.Scan()
}*/
func GtRealTimeDataProcess() {
gtArrs := dao.GtRealDataProcess()
by, err := xml.Marshal(gtArrs)
common.ErrorPrintln("干滩实时数据xml序列化", err)
log.Println("干滩实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
库水位实时数据
*/
func KswRealTimeDataProcess() {
kswArrs := dao.KswRealDataProcess()
by, err := xml.Marshal(kswArrs)
common.ErrorPrintln("库水位实时数据xml序列化", err)
log.Println("库水位实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
浸润线实时数据
*/
func JrxRealTimeDataProcess() {
jrxArrs := dao.JrxRealDataProcess()
by, err := xml.Marshal(jrxArrs)
common.ErrorPrintln("浸润线实时数据xml序列化", err)
log.Println("浸润线实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
降雨量实时数据
*/
func JylRealTimeDataProcess() {
jylArrs := dao.JylRealDataProcess()
by, err := xml.Marshal(jylArrs)
common.ErrorPrintln("降雨量实时数据xml序列化", err)
log.Println("降雨量实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
内部位移实时数据
*/
func NbwyRealTimeDataProcess() {
nbwyArrs := dao.NbwyRealDataProcess()
by, err := xml.Marshal(nbwyArrs)
common.ErrorPrintln("内部位移实时数据xml序列化", err)
log.Println("内部位移实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
表面位移位移实时数据
*/
func BmwyRealTimeDataProcess() {
bmwyArrs := dao.BmwyRealDataProcess()
by, err := xml.Marshal(bmwyArrs)
common.ErrorPrintln("表面位移位移实时数据xml序列化", err)
log.Println("表面位移实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
离线设备实时数据
*/
func DOLRealTimeDataProcess() {
AmsArrs := dao.DeviceOffLineRealDataProcess()
by, err := xml.Marshal(AmsArrs)
common.ErrorPrintln("设备离线实时数据xml序列化", err)
log.Println("设备离线实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
报警设备实时数据
*/
func AMSRealTimeDataProcess() {
AmsArrs := dao.AlarmDataRealDataProcess()
by, err := xml.Marshal(AmsArrs)
common.ErrorPrintln("报警设备实时数据xml序列化", err)
log.Println("报警设备实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
\ No newline at end of file
......@@ -16,7 +16,7 @@ import (
func WkkBasicDataProcess() {
client := &http.Client{}
by, err := xml.Marshal(config.TailPond)
log.Println(">>>>>>>>>>>>>>>>>>>", string(by))
log.Println("尾矿库静态数据>>>>>>>>>>>>>>>>>>>", string(by))
common.ErrorPrintln("wkkBasicDataProcess", err)
req, err := http.NewRequest("POST", "https://www.baidu.com", bytes.NewReader(by))
client.Do(req)
......@@ -30,7 +30,7 @@ func GtStaticDataProcess() {
gtArrs := dao.GantanStaticData()
by, err := xml.Marshal(gtArrs)
common.ErrorPrintln("干滩静态数据格式化失败", err)
log.Println("干滩>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
log.Println("干滩静态数据>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
......@@ -41,7 +41,7 @@ func KswStaticDataProcess() {
kswArrs := dao.KushuiweiStaticData()
by, err := xml.Marshal(kswArrs)
common.ErrorPrintln("库水位静态数据格式化失败", err)
log.Println("库水位>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
log.Println("库水位静态数据>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
......@@ -52,7 +52,7 @@ func JrxStaticDataProcess() {
jrxArrs := dao.JinrunxianStaticData()
by, err := xml.Marshal(jrxArrs)
common.ErrorPrintln("浸润线静态数据格式化失败", err)
log.Println("浸润线>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
log.Println("浸润线静态数据>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
......@@ -62,15 +62,25 @@ func JylStaticDataProcess() {
jylArrs := dao.JiangyuliangStaticData()
by, err := xml.Marshal(jylArrs)
common.ErrorPrintln("降雨量静态数据格式化失败", err)
log.Println("降雨量>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
log.Println("降雨量静态数据>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
降雨量静态数据处理
内部位移静态数据处理
*/
func NbwyStaticDataProcess() {
jylArrs := dao.NeibuweiyiStaticData()
by, err := xml.Marshal(jylArrs)
nbwyArrs := dao.NeibuweiyiStaticData()
by, err := xml.Marshal(nbwyArrs)
common.ErrorPrintln("内部位移静态数据格式化失败", err)
log.Println("内部位移>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
log.Println("内部位移静态数据>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
/*
表面位移静态数据处理
*/
func BmwyStaticDataProcess() {
bmwyArrs := dao.BiaomianweiyiStaticData()
by, err := xml.Marshal(bmwyArrs)
common.ErrorPrintln("表面位移静态数据格式化失败", err)
log.Println("表面位移静态数据>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment