Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bi-report
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
data
bi-report
Commits
aab6081e
Commit
aab6081e
authored
May 06, 2020
by
赵建伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update codes
parent
f280c2df
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
115 additions
and
18 deletions
+115
-18
workspace.xml
.idea/workspace.xml
+2
-4
workspace.xml
lib/java/bi-report-service/.idea/workspace.xml
+3
-5
BiReportEndpoint.java
...m/gmei/data/gateway/server/endpoint/BiReportEndpoint.java
+6
-0
BiReportService.java
...com/gmei/data/gateway/server/service/BiReportService.java
+1
-0
HivesqlService.java
.../com/gmei/data/gateway/server/service/HivesqlService.java
+7
-0
BiReportServiceImpl.java
...data/gateway/server/service/impl/BiReportServiceImpl.java
+9
-5
HivesqlServiceImpl.java
.../data/gateway/server/service/impl/HivesqlServiceImpl.java
+81
-0
SparksqlServiceImpl.java
...data/gateway/server/service/impl/SparksqlServiceImpl.java
+3
-3
application.yml
...service/service-server/src/main/resources/application.yml
+3
-1
No files found.
.idea/workspace.xml
View file @
aab6081e
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"18c38e3b-9b7f-4a3f-b141-edcb320b1d24"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/conf/en-cn.properties"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/conf/en-cn.properties"
afterDir=
"false"
/>
</list>
<list
default=
"true"
id=
"18c38e3b-9b7f-4a3f-b141-edcb320b1d24"
name=
"Default Changelist"
comment=
""
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
...
...
@@ -125,7 +123,7 @@
<workItem
from=
"1588154352798"
duration=
"195000"
/>
<workItem
from=
"1588220085338"
duration=
"7993000"
/>
<workItem
from=
"1588248522289"
duration=
"2820000"
/>
<workItem
from=
"1588344251422"
duration=
"1
3761
000"
/>
<workItem
from=
"1588344251422"
duration=
"1
6485
000"
/>
</task>
<task
id=
"LOCAL-00001"
summary=
"add init codes."
>
<created>
1587723565207
</created>
...
...
lib/java/bi-report-service/.idea/workspace.xml
View file @
aab6081e
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"73604af3-3cbc-41f8-9a5f-e6a14a2ada76"
name=
"Default Changelist"
comment=
"add"
>
<change
beforePath=
"$PROJECT_DIR$/../../../conf/en-cn.properties"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/../../../conf/en-cn.properties"
afterDir=
"false"
/>
</list>
<list
default=
"true"
id=
"73604af3-3cbc-41f8-9a5f-e6a14a2ada76"
name=
"Default Changelist"
comment=
"add"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
<option
name=
"HIGHLIGHT_CONFLICTS"
value=
"true"
/>
<option
name=
"HIGHLIGHT_NON_ACTIVE_CHANGELIST"
value=
"false"
/>
...
...
@@ -75,8 +73,8 @@
</component>
<component
name=
"RecentsManager"
>
<key
name=
"CopyClassDialog.RECENTS_KEY"
>
<recent
name=
"com.gmei.data.gateway.server.service"
/>
<recent
name=
"com.gmei.data.gateway.server.service.impl"
/>
<recent
name=
"com.gmei.data.gateway.server.service"
/>
<recent
name=
"com.gmei.data.gateway.server.bean"
/>
</key>
</component>
...
...
@@ -219,7 +217,7 @@
<workItem
from=
"1588148891822"
duration=
"2318000"
/>
<workItem
from=
"1588152718016"
duration=
"1463000"
/>
<workItem
from=
"1588154601852"
duration=
"28557000"
/>
<workItem
from=
"1588344252163"
duration=
"
8979
000"
/>
<workItem
from=
"1588344252163"
duration=
"
11055
000"
/>
</task>
<servers
/>
</component>
...
...
lib/java/bi-report-service/service-server/src/main/java/com/gmei/data/gateway/server/endpoint/BiReportEndpoint.java
View file @
aab6081e
...
...
@@ -11,6 +11,12 @@ public class BiReportEndpoint {
@Autowired
public
BiReportService
biReportService
;
@ResponseBody
@RequestMapping
(
value
=
"/execSql"
)
public
int
execSql
(
@RequestParam
String
name
){
return
biReportService
.
genExcel
(
name
);
}
@ResponseBody
@RequestMapping
(
value
=
"/genExcel"
)
public
int
genExcel
(
@RequestParam
String
name
){
...
...
lib/java/bi-report-service/service-server/src/main/java/com/gmei/data/gateway/server/service/BiReportService.java
View file @
aab6081e
package
com
.
gmei
.
data
.
gateway
.
server
.
service
;
public
interface
BiReportService
{
int
execSql
(
String
name
);
int
genExcel
(
String
name
);
int
sendEmail
(
String
to
,
String
cc
,
String
name
);
}
lib/java/bi-report-service/service-server/src/main/java/com/gmei/data/gateway/server/service/HivesqlService.java
0 → 100644
View file @
aab6081e
package
com
.
gmei
.
data
.
gateway
.
server
.
service
;
import
com.gmei.data.gateway.server.dto.ExcelGenDto
;
public
interface
HivesqlService
{
int
executeSql
(
String
name
);
}
lib/java/bi-report-service/service-server/src/main/java/com/gmei/data/gateway/server/service/impl/BiReportServiceImpl.java
View file @
aab6081e
...
...
@@ -2,10 +2,7 @@ package com.gmei.data.gateway.server.service.impl;
import
com.gmei.data.gateway.server.common.Constants
;
import
com.gmei.data.gateway.server.dto.ExcelGenDto
;
import
com.gmei.data.gateway.server.service.BiReportService
;
import
com.gmei.data.gateway.server.service.EmailService
;
import
com.gmei.data.gateway.server.service.ExcelService
;
import
com.gmei.data.gateway.server.service.SparksqlService
;
import
com.gmei.data.gateway.server.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -23,15 +20,22 @@ public class BiReportServiceImpl implements BiReportService {
@Autowired
public
ExcelService
excelService
;
@Autowired
public
HivesqlService
hivesqlService
;
@Autowired
public
SparksqlService
sparksqlService
;
@Override
public
int
execSql
(
String
name
){
return
hivesqlService
.
executeSql
(
name
);
}
@Override
public
int
genExcel
(
String
name
){
ExcelGenDto
resultDto
=
sparksqlService
.
getResultDto
(
name
);
if
(
null
==
resultDto
){
return
Constants
.
FAIL
;
}
else
{
return
excelService
.
genExcel
(
resultDto
,
"测试示例"
);
return
excelService
.
genExcel
(
resultDto
,
name
);
}
}
...
...
lib/java/bi-report-service/service-server/src/main/java/com/gmei/data/gateway/server/service/impl/HivesqlServiceImpl.java
0 → 100644
View file @
aab6081e
package
com
.
gmei
.
data
.
gateway
.
server
.
service
.
impl
;
import
com.gmei.data.gateway.server.service.HivesqlService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.Statement
;
/**
* @ClassName HivesqlServiceImpl
* @Author apple
* @Date 2020/5/01
* @Version V1.0
**/
@Service
public
class
HivesqlServiceImpl
implements
HivesqlService
{
@Value
(
"${sql.input.path}"
)
private
String
sqlPath
;
@Value
(
"${datasource.hiveSql.jdbcUrl}"
)
private
String
hiveSqlJdbcUrl
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
HivesqlServiceImpl
.
class
);
@Override
public
int
executeSql
(
String
name
){
File
sqlDir
=
new
File
(
sqlPath
+
name
);
File
[]
files
=
sqlDir
.
listFiles
();
for
(
File
file
:
files
){
BufferedReader
reader
=
null
;
StringBuffer
sbf
=
new
StringBuffer
();
try
{
reader
=
new
BufferedReader
(
new
FileReader
(
file
));
String
tempStr
;
while
((
tempStr
=
reader
.
readLine
())
!=
null
)
{
sbf
.
append
(
"\n"
).
append
(
tempStr
);
}
reader
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
e
.
getMessage
());
continue
;
}
finally
{
if
(
reader
!=
null
)
{
try
{
reader
.
close
();
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
logger
.
error
(
e1
.
getMessage
());
continue
;
}
}
}
String
hql
=
sbf
.
toString
();
Connection
conn
=
null
;
try
{
conn
=
DriverManager
.
getConnection
(
hiveSqlJdbcUrl
,
"data"
,
""
);
Statement
statement
=
conn
.
createStatement
();
int
updateCount
=
statement
.
executeUpdate
(
hql
);
if
(
updateCount
>
0
){
logger
.
info
(
"*** Execute success, hql: {}"
,
hql
);
}
else
{
logger
.
warn
(
"*** Execute finish, hql: {}"
,
hql
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
logger
.
error
(
"*** Execute failed, error message: {}, hql: {}"
,
e
.
getMessage
(),
hql
);
return
1
;
}
}
return
0
;
}
}
lib/java/bi-report-service/service-server/src/main/java/com/gmei/data/gateway/server/service/impl/SparksqlServiceImpl.java
View file @
aab6081e
...
...
@@ -27,8 +27,8 @@ public class SparksqlServiceImpl implements SparksqlService {
@Value
(
"${sql.input.path}"
)
private
String
sqlPath
;
@Value
(
"${datasource.spark
s
ql.jdbcUrl}"
)
private
String
spark
s
qlJdbcUrl
;
@Value
(
"${datasource.spark
S
ql.jdbcUrl}"
)
private
String
spark
S
qlJdbcUrl
;
@Value
(
"${proper.file.path}"
)
private
String
properFilePath
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SparksqlServiceImpl
.
class
);
...
...
@@ -84,7 +84,7 @@ public class SparksqlServiceImpl implements SparksqlService {
String
hql
=
sbf
.
toString
();
Connection
conn
=
null
;
try
{
conn
=
DriverManager
.
getConnection
(
spark
s
qlJdbcUrl
,
"data"
,
""
);
conn
=
DriverManager
.
getConnection
(
spark
S
qlJdbcUrl
,
"data"
,
""
);
Statement
statement
=
conn
.
createStatement
();
ResultSet
rs
=
statement
.
executeQuery
(
hql
);
ResultSetMetaData
metaData
=
rs
.
getMetaData
();
...
...
lib/java/bi-report-service/service-server/src/main/resources/application.yml
View file @
aab6081e
...
...
@@ -10,8 +10,10 @@ spring:
default-encoding
:
UTF-8
datasource
:
spark
s
ql
:
spark
S
ql
:
jdbcUrl
:
jdbc:hive2://bj-gm-prod-cos-datacenter003:10010
hiveSql
:
jdbcUrl
:
jdbc:hive2://bj-gm-prod-cos-datacenter006:10000
#---email send config---
mail
:
...
...
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