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

添加外部输出日志

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