Commit 791352d8 authored by 史余彬's avatar 史余彬

添加外部输出日志

parent 1bbaa06c
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"gopkg.in/ini.v1" "gopkg.in/ini.v1"
"log" "log"
"os"
"shandong_datapush/common" "shandong_datapush/common"
_ "github.com/denisenkom/go-mssqldb" _ "github.com/denisenkom/go-mssqldb"
_ "github.com/lib/pq" _ "github.com/lib/pq"
...@@ -26,14 +27,17 @@ func init() { ...@@ -26,14 +27,17 @@ func init() {
common.ErrorPrintln("读取配置文件异常", err) common.ErrorPrintln("读取配置文件异常", err)
DBType = file.Section("databaseType").Key("type").String() DBType = file.Section("databaseType").Key("type").String()
DBConnInfo = new(common.DBConnectInfo) DBConnInfo = new(common.DBConnectInfo)
err = file.Section("databaseConnection").MapTo(DBConnInfo) _ = file.Section("databaseConnection").MapTo(DBConnInfo)
TailPond = new(common.TailPondInfor) TailPond = new(common.TailPondInfor)
err = file.Section("wkkBasicInfo").MapTo(TailPond) _ = file.Section("wkkBasicInfo").MapTo(TailPond)
StaticSql = new(common.StaticSqlLanguage) StaticSql = new(common.StaticSqlLanguage)
file.Section("StaticSqlLanguage").MapTo(StaticSql) _ = file.Section("StaticSqlLanguage").MapTo(StaticSql)
RealTimeSql = new(common.RealTimeSqlLanguage) RealTimeSql = new(common.RealTimeSqlLanguage)
file.Section("RealTimeSqlLanguage").MapTo(RealTimeSql) _ = file.Section("RealTimeSqlLanguage").MapTo(RealTimeSql)
common.ErrorPrintln("数据库连接信息映射异常", err) common.ErrorPrintln("数据库连接信息映射异常", err)
f, err := os.OpenFile("test.txt", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
common.ErrorPrintln("日志文件创建失败", err)
log.SetOutput(f)
} }
func DBConnection() { func DBConnection() {
......
...@@ -11,6 +11,9 @@ import ( ...@@ -11,6 +11,9 @@ import (
func GtRealDataProcess() []*common.DryBeachData { func GtRealDataProcess() []*common.DryBeachData {
row, err := config.DB.Query(config.RealTimeSql.GtRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.GtRealTimeSql)
common.ErrorPrintln("干滩实时数据查询异常", err) common.ErrorPrintln("干滩实时数据查询异常", err)
defer func() {
common.ErrorPrintln("干滩实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.DryBeachData, 0) Arrs := make([]*common.DryBeachData, 0)
for row.Next() { for row.Next() {
dryBeach := new(common.DryBeachData) dryBeach := new(common.DryBeachData)
...@@ -27,6 +30,9 @@ func GtRealDataProcess() []*common.DryBeachData { ...@@ -27,6 +30,9 @@ func GtRealDataProcess() []*common.DryBeachData {
func KswRealDataProcess() []*common.ReserWaterLevelData { func KswRealDataProcess() []*common.ReserWaterLevelData {
row, err := config.DB.Query(config.RealTimeSql.KswRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.KswRealTimeSql)
common.ErrorPrintln("库水位实时数据查询异常", err) common.ErrorPrintln("库水位实时数据查询异常", err)
defer func() {
common.ErrorPrintln("库水位实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.ReserWaterLevelData, 0) Arrs := make([]*common.ReserWaterLevelData, 0)
for row.Next() { for row.Next() {
reserWater := new(common.ReserWaterLevelData) reserWater := new(common.ReserWaterLevelData)
...@@ -43,6 +49,9 @@ func KswRealDataProcess() []*common.ReserWaterLevelData { ...@@ -43,6 +49,9 @@ func KswRealDataProcess() []*common.ReserWaterLevelData {
func JrxRealDataProcess() []*common.SaturationLineData { func JrxRealDataProcess() []*common.SaturationLineData {
row, err := config.DB.Query(config.RealTimeSql.JrxRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.JrxRealTimeSql)
common.ErrorPrintln("浸润线实时数据查询异常", err) common.ErrorPrintln("浸润线实时数据查询异常", err)
defer func() {
common.ErrorPrintln("浸润线实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.SaturationLineData, 0) Arrs := make([]*common.SaturationLineData, 0)
for row.Next() { for row.Next() {
saturation := new(common.SaturationLineData) saturation := new(common.SaturationLineData)
...@@ -59,6 +68,9 @@ func JrxRealDataProcess() []*common.SaturationLineData { ...@@ -59,6 +68,9 @@ func JrxRealDataProcess() []*common.SaturationLineData {
func JylRealDataProcess() []*common.RainfallData { func JylRealDataProcess() []*common.RainfallData {
row, err := config.DB.Query(config.RealTimeSql.JylRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.JylRealTimeSql)
common.ErrorPrintln("降雨量实时数据查询异常", err) common.ErrorPrintln("降雨量实时数据查询异常", err)
defer func() {
common.ErrorPrintln("降雨量实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.RainfallData, 0) Arrs := make([]*common.RainfallData, 0)
for row.Next() { for row.Next() {
rainfall := new(common.RainfallData) rainfall := new(common.RainfallData)
...@@ -76,6 +88,9 @@ func JylRealDataProcess() []*common.RainfallData { ...@@ -76,6 +88,9 @@ func JylRealDataProcess() []*common.RainfallData {
func NbwyRealDataProcess() []*common.InclinometerData { func NbwyRealDataProcess() []*common.InclinometerData {
row, err := config.DB.Query(config.RealTimeSql.NbwyRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.NbwyRealTimeSql)
common.ErrorPrintln("内部位移实时数据查询异常", err) common.ErrorPrintln("内部位移实时数据查询异常", err)
defer func() {
common.ErrorPrintln("内部位移实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.InclinometerData, 0) Arrs := make([]*common.InclinometerData, 0)
for row.Next() { for row.Next() {
inclinometer := new(common.InclinometerData) inclinometer := new(common.InclinometerData)
...@@ -94,6 +109,9 @@ func NbwyRealDataProcess() []*common.InclinometerData { ...@@ -94,6 +109,9 @@ func NbwyRealDataProcess() []*common.InclinometerData {
func BmwyRealDataProcess() []*common.DisplacementData { func BmwyRealDataProcess() []*common.DisplacementData {
row, err := config.DB.Query(config.RealTimeSql.BmwyRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.BmwyRealTimeSql)
common.ErrorPrintln("表面位移实时数据查询异常", err) common.ErrorPrintln("表面位移实时数据查询异常", err)
defer func() {
common.ErrorPrintln("表面位移实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.DisplacementData, 0) Arrs := make([]*common.DisplacementData, 0)
for row.Next() { for row.Next() {
displacement := new(common.DisplacementData) displacement := new(common.DisplacementData)
...@@ -111,6 +129,9 @@ func BmwyRealDataProcess() []*common.DisplacementData { ...@@ -111,6 +129,9 @@ func BmwyRealDataProcess() []*common.DisplacementData {
func DeviceOffLineRealDataProcess() []*common.DeviceOffLineData { func DeviceOffLineRealDataProcess() []*common.DeviceOffLineData {
row, err := config.DB.Query(config.RealTimeSql.DeviceOffLineDataRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.DeviceOffLineDataRealTimeSql)
common.ErrorPrintln("设备离线实时数据查询异常", err) common.ErrorPrintln("设备离线实时数据查询异常", err)
defer func() {
common.ErrorPrintln("设备离线实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.DeviceOffLineData, 0) Arrs := make([]*common.DeviceOffLineData, 0)
for row.Next() { for row.Next() {
deviceOffLine := new(common.DeviceOffLineData) deviceOffLine := new(common.DeviceOffLineData)
...@@ -129,6 +150,9 @@ func DeviceOffLineRealDataProcess() []*common.DeviceOffLineData { ...@@ -129,6 +150,9 @@ func DeviceOffLineRealDataProcess() []*common.DeviceOffLineData {
func AlarmDataRealDataProcess() []*common.AlarmMessData { func AlarmDataRealDataProcess() []*common.AlarmMessData {
row, err := config.DB.Query(config.RealTimeSql.AlarmMessDataRealTimeSql) row, err := config.DB.Query(config.RealTimeSql.AlarmMessDataRealTimeSql)
common.ErrorPrintln("报警实时数据查询异常", err) common.ErrorPrintln("报警实时数据查询异常", err)
defer func() {
common.ErrorPrintln("报警实时数据关闭异常", row.Close())
}()
Arrs := make([]*common.AlarmMessData, 0) Arrs := make([]*common.AlarmMessData, 0)
for row.Next() { for row.Next() {
alarmMess := new(common.AlarmMessData) alarmMess := new(common.AlarmMessData)
......
...@@ -40,6 +40,7 @@ func realTimeDataPush() { ...@@ -40,6 +40,7 @@ func realTimeDataPush() {
service.JrxRealTimeDataProcess() service.JrxRealTimeDataProcess()
service.JylRealTimeDataProcess() service.JylRealTimeDataProcess()
service.NbwyRealTimeDataProcess() service.NbwyRealTimeDataProcess()
service.BmwyRealTimeDataProcess()
service.DOLRealTimeDataProcess() service.DOLRealTimeDataProcess()
service.AMSRealTimeDataProcess() service.AMSRealTimeDataProcess()
} }
......
...@@ -73,8 +73,8 @@ func BmwyRealTimeDataProcess() { ...@@ -73,8 +73,8 @@ func BmwyRealTimeDataProcess() {
离线设备实时数据 离线设备实时数据
*/ */
func DOLRealTimeDataProcess() { func DOLRealTimeDataProcess() {
AmsArrs := dao.DeviceOffLineRealDataProcess() DOLArrs := dao.DeviceOffLineRealDataProcess()
by, err := xml.Marshal(AmsArrs) by, err := xml.Marshal(DOLArrs)
common.ErrorPrintln("设备离线实时数据xml序列化", err) common.ErrorPrintln("设备离线实时数据xml序列化", err)
log.Println("设备离线实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by)) log.Println("设备离线实时数据>>>>>>>>>>>>>>>>>>>>>>>>", string(by))
} }
......
This diff is collapsed.
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