Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
shandong_datapush
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shiyubin
shandong_datapush
Commits
791352d8
Commit
791352d8
authored
Oct 30, 2020
by
史余彬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加外部输出日志
parent
1bbaa06c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
301 additions
and
6 deletions
+301
-6
config.go
config/config.go
+8
-4
realTimeDataDao.go
dao/realTimeDataDao.go
+24
-0
main.go
main.go
+1
-0
realTimeDataProcess.go
service/realTimeDataProcess.go
+2
-2
test.txt
test.txt
+266
-0
No files found.
config/config.go
View file @
791352d8
...
@@ -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
()
{
...
...
dao/realTimeDataDao.go
View file @
791352d8
...
@@ -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
)
...
...
main.go
View file @
791352d8
...
@@ -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
()
}
}
...
...
service/realTimeDataProcess.go
View file @
791352d8
...
@@ -73,8 +73,8 @@ func BmwyRealTimeDataProcess() {
...
@@ -73,8 +73,8 @@ func BmwyRealTimeDataProcess() {
离线设备实时数据
离线设备实时数据
*/
*/
func
DOLRealTimeDataProcess
()
{
func
DOLRealTimeDataProcess
()
{
Ams
Arrs
:=
dao
.
DeviceOffLineRealDataProcess
()
DOL
Arrs
:=
dao
.
DeviceOffLineRealDataProcess
()
by
,
err
:=
xml
.
Marshal
(
Ams
Arrs
)
by
,
err
:=
xml
.
Marshal
(
DOL
Arrs
)
common
.
ErrorPrintln
(
"设备离线实时数据xml序列化"
,
err
)
common
.
ErrorPrintln
(
"设备离线实时数据xml序列化"
,
err
)
log
.
Println
(
"设备离线实时数据>>>>>>>>>>>>>>>>>>>>>>>>"
,
string
(
by
))
log
.
Println
(
"设备离线实时数据>>>>>>>>>>>>>>>>>>>>>>>>"
,
string
(
by
))
}
}
...
...
test.txt
0 → 100644
View file @
791352d8
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment