Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DataCenter_Core2.1_20190520
Overview
Overview
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
bltdc
DataCenter_Core2.1_20190520
Commits
92bcbf49
Commit
92bcbf49
authored
Jun 01, 2022
by
jianshuqin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加功能:离线导出
parent
1c4a7fe6
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
147 additions
and
27 deletions
+147
-27
QueryFilterDTO.cs
Bailun.DC.Models/Component/DTO/QueryFilterDTO.cs
+18
-1
dc_component_offline_download.cs
....Models/Component/Entity/dc_component_offline_download.cs
+5
-0
OfflineDownloadService.cs
Bailun.DC.Services/Component/OfflineDownloadService.cs
+59
-17
TableService.cs
Bailun.DC.Services/Component/TableService.cs
+2
-2
OfflineDownloadController.cs
.../Areas/Component/Controllers/OfflineDownloadController.cs
+51
-3
el-dialog-form.css
Bailun.DC.Web/wwwroot/css/component/el-dialog-form.css
+5
-0
el-table-query.js
Bailun.DC.Web/wwwroot/js/component/el-table-query.js
+7
-4
No files found.
Bailun.DC.Models/Component/DTO/QueryFilterDTO.cs
View file @
92bcbf49
...
...
@@ -20,7 +20,7 @@ namespace Bailun.DC.Models.Component.DTO
/// <summary>
/// 每页数量
/// </summary>
public
int
?
p
ageSize
{
get
;
set
;
}
public
int
?
P
ageSize
{
get
;
set
;
}
/// <summary>
/// 字段过虑条件
...
...
@@ -37,4 +37,20 @@ namespace Bailun.DC.Models.Component.DTO
/// </summary>
public
IList
<
FieldOrderDTO
>
ListField
{
get
;
set
;
}
}
/// <summary>
/// 离线查询条件
/// </summary>
public
class
OfflineQueryFilterDTO
:
QueryFilterDTO
{
/// <summary>
/// ID
/// </summary>
public
int
?
Id
{
get
;
set
;
}
/// <summary>
/// 名称
/// </summary>
public
string
Name
{
get
;
set
;
}
}
}
\ No newline at end of file
Bailun.DC.Models/Component/Entity/dc_component_offline_download.cs
View file @
92bcbf49
...
...
@@ -30,6 +30,11 @@ namespace Bailun.DC.Models.Component.Entity
public
string
suffix
{
get
;
set
;
}
/// <summary>
/// 过虑条件
/// </summary>
public
string
filter
{
get
;
set
;
}
/// <summary>
/// 状态:0:未执行, 1:执行中, 2:完成, 3:失败
/// </summary>
public
OfflineDownloadStatusEnum
?
status
{
get
;
set
;
}
...
...
Bailun.DC.Services/Component/OfflineDownloadService.cs
View file @
92bcbf49
...
...
@@ -4,9 +4,11 @@ using Bailun.DC.Models.Component.Entity;
using
Bailun.DC.Models.Component.Enum
;
using
Dapper
;
using
MySql.Data.MySqlClient
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
Qiniu.Http
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
...
...
@@ -18,14 +20,14 @@ namespace Bailun.DC.Services.Component
public
class
OfflineDownloadService
:
BaseService
{
public
ResultDTO
Export
(
QueryFilterDTO
queryFilter
,
string
cookies
)
public
ResultDTO
Export
(
Offline
QueryFilterDTO
queryFilter
,
string
cookies
)
{
ResultDTO
<
int
?>
result
=
default
(
ResultDTO
<
int
?>);
TableService
service
=
new
TableService
();
TableDTO
entity
=
service
.
Get
(
queryFilter
.
Code
);
if
(
entity
!=
null
)
{
string
name
=
$"
{
string
.
Join
(
string
.
Empty
,
entity
.
ListCrumb
)}
_
{
DateTime
.
Now
.
ToString
(
"yyyyMMddhhmm"
)}
"
;
string
name
=
!
string
.
IsNullOrWhiteSpace
(
queryFilter
.
Name
)
?
queryFilter
.
Name
.
Trim
()
:
$"
{
string
.
Join
(
string
.
Empty
,
entity
.
ListCrumb
)}
_
{
DateTime
.
Now
.
ToString
(
"yyyyMMddhhmm"
)}
"
;
result
=
this
.
Save
(
queryFilter
,
name
,
cookies
);
if
(
result
?.
Result
==
true
)
{
...
...
@@ -63,12 +65,45 @@ namespace Bailun.DC.Services.Component
return
result
;
}
public
ResultDTO
ReExport
(
int
[]
id
,
string
cookies
=
null
)
{
ResultDTO
result
=
this
.
BeforeSave
(
id
);
if
(
result
.
Result
)
{
using
(
var
db
=
DB
)
{
string
sql
=
"select * from dc_component_offline_download where id in @id"
;
IList
<
dc_component_offline_download
>
list
=
db
.
Query
<
dc_component_offline_download
>(
sql
,
new
{
id
=
id
}).
ToList
();
if
(
list
?.
Count
>
0
)
{
list
.
ForEach
((
l
,
i
)
=>
{
OfflineQueryFilterDTO
queryFilter
=
new
OfflineQueryFilterDTO
()
{
Id
=
l
.
id
,
Code
=
l
.
code
,
Name
=
l
.
name
,
ListFilter
=
JsonConvert
.
DeserializeObject
<
IList
<
FieldFilterDTO
>>(
l
.
filter
)
};
this
.
Export
(
queryFilter
,
cookies
);
});
}
}
}
else
{
result
=
new
ResultDTO
<
int
?>()
{
Message
=
"参数异常"
};
}
return
result
;
}
/// <summary>
/// 保存报表组件
/// </summary>
/// <param name="dto">报表组件对象</param>
/// <returns>保存结果</returns>
public
ResultDTO
<
int
?>
Save
(
QueryFilterDTO
queryFilter
,
string
name
,
string
cookies
)
public
ResultDTO
<
int
?>
Save
(
Offline
QueryFilterDTO
queryFilter
,
string
name
,
string
cookies
)
{
ResultDTO
<
int
?>
result
=
this
.
BeforeSave
(
queryFilter
,
cookies
);
...
...
@@ -76,23 +111,29 @@ namespace Bailun.DC.Services.Component
{
dc_component_offline_download
entity
=
new
dc_component_offline_download
()
{
id
=
queryFilter
.
Id
??
0
,
code
=
queryFilter
.
Code
,
name
=
name
,
gmt_create_time
=
DateTime
.
Now
,
gmt_modified_time
=
DateTime
.
Now
,
status
=
OfflineDownloadStatusEnum
.
Executing
status
=
OfflineDownloadStatusEnum
.
Executing
,
filter
=
JsonConvert
.
SerializeObject
(
queryFilter
.
ListFilter
)
};
JObject
json
=
default
(
JObject
);
if
(!
string
.
IsNullOrWhiteSpace
(
cookies
))
{
var
user
=
HttpHelper
.
NetHelper
.
Request
(
"http://sso.bailuntec.com/GetUserResource"
,
new
string
[]
{
"Authorization"
},
new
string
[]
{
cookies
});
var
json
=
JObject
.
Parse
(
user
);
if
(
json
[
"statusCode"
].
ToString
()
==
"200"
&&
json
[
"result"
][
"success"
].
ToString
().
ToLower
()
==
"true"
)
json
=
JObject
.
Parse
(
user
);
}
if
(
json
!=
null
&&
json
[
"statusCode"
].
ToString
()
==
"200"
&&
json
[
"result"
][
"success"
].
ToString
().
ToLower
()
==
"true"
)
{
entity
.
gmt_create_userid
=
int
.
TryParse
(
json
[
"result"
][
"OaUserId"
].
ToString
(),
out
int
userid
)
?
userid
:
0
;
entity
.
gmt_create_username
=
json
[
"result"
][
"Account"
].
ToString
()
??
"
system
"
;
entity
.
gmt_create_username
=
json
[
"result"
][
"Account"
].
ToString
()
??
"
系统
"
;
}
else
{
entity
.
gmt_create_userid
=
0
;
entity
.
gmt_create_username
=
"
system
"
;
entity
.
gmt_create_username
=
"
系统
"
;
}
using
(
var
db
=
DB
)
{
...
...
@@ -100,19 +141,20 @@ namespace Bailun.DC.Services.Component
MySqlTransaction
transaction
=
db
.
BeginTransaction
();
try
{
int
?
id
=
db
.
Insert
(
entity
);
if
(
id
==
0
)
{
result
.
Result
=
false
;
result
.
Message
=
"保存失败"
;
}
else
result
.
Data
=
entity
.
id
>
0
?
(
db
.
Update
(
entity
)
>
0
?
entity
.
id
:
0
)
:
db
.
Insert
(
entity
);
result
.
Result
=
result
.
Data
>
0
;
if
(
result
.
Result
)
{
//提交事务
transaction
.
Commit
();
result
.
Data
=
id
;
result
.
Message
=
"保存成功"
;
}
else
{
//回滚事务
transaction
.
Rollback
();
result
.
Message
=
"保存失败"
;
}
}
catch
(
Exception
ex
)
{
...
...
@@ -224,7 +266,7 @@ namespace Bailun.DC.Services.Component
/// </summary>
/// <param name="dto">报表组件对象</param>
/// <returns>保存结果</returns>
private
ResultDTO
<
int
?>
BeforeSave
(
QueryFilterDTO
queryFilter
,
string
cookies
)
private
ResultDTO
<
int
?>
BeforeSave
(
Offline
QueryFilterDTO
queryFilter
,
string
cookies
)
{
ResultDTO
<
int
?>
result
=
new
ResultDTO
<
int
?>();
...
...
Bailun.DC.Services/Component/TableService.cs
View file @
92bcbf49
...
...
@@ -495,7 +495,7 @@ namespace Bailun.DC.Services.Component
DataTypeEnum
?[]
dataTypes
=
{
DataTypeEnum
.
Table
,
DataTypeEnum
.
Sql
};
//全部数据导出
queryFilter
.
CurrentPage
=
null
;
queryFilter
.
p
ageSize
=
null
;
queryFilter
.
P
ageSize
=
null
;
if
(!
string
.
IsNullOrWhiteSpace
(
entity
.
DataValue
)
&&
dataTypes
.
Contains
(
entity
.
DataType
))
{
(
int
,
IDataReader
)
reader
=
this
.
GetListDataReader
(
queryFilter
,
entity
);
...
...
@@ -798,7 +798,7 @@ namespace Bailun.DC.Services.Component
{
(
int
,
IDataReader
)
reader
=
(
0
,
null
);
DynamicParameters
sqlparam
=
new
DynamicParameters
();
int
fetch
=
(
queryFilter
.
pageSize
>
0
?
queryFilter
.
p
ageSize
:
int
.
MaxValue
).
Value
;
int
fetch
=
(
queryFilter
.
PageSize
>
0
?
queryFilter
.
P
ageSize
:
int
.
MaxValue
).
Value
;
int
offset
=
(((
queryFilter
.
CurrentPage
>
1
?
queryFilter
.
CurrentPage
:
1
)
-
1
)
*
fetch
).
Value
;
//查询字段
string
selectSql
=
"*"
;
...
...
Bailun.DC.Web/Areas/Component/Controllers/OfflineDownloadController.cs
View file @
92bcbf49
...
...
@@ -12,7 +12,7 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
public
class
OfflineDownloadController
:
Base
.
BaseController
{
[
HttpPost
]
public
JsonResult
Export
(
QueryFilterDTO
queryFilter
)
public
JsonResult
Export
(
Offline
QueryFilterDTO
queryFilter
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
...
...
@@ -24,10 +24,26 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
byte
[]
buffer
=
new
byte
[
Request
.
ContentLength
.
Value
];
stream
.
Read
(
buffer
,
0
,
buffer
.
Length
);
string
content
=
Encoding
.
UTF8
.
GetString
(
buffer
);
queryFilter
=
JsonConvert
.
DeserializeObject
<
QueryFilterDTO
>(
content
);
queryFilter
=
JsonConvert
.
DeserializeObject
<
Offline
QueryFilterDTO
>(
content
);
}
}
result
=
new
OfflineDownloadService
().
Export
(
queryFilter
,
Request
.
Cookies
[
"BailunToken"
]);
result
=
new
OfflineDownloadService
().
Export
(
queryFilter
,
this
.
GetBailunToken
());
}
catch
(
Exception
ex
)
{
result
=
new
ResultDTO
()
{
Message
=
ex
.
Message
};
}
return
Json
(
result
);
}
[
HttpPost
]
public
JsonResult
ReExport
(
int
[]
id
)
{
ResultDTO
result
=
default
(
ResultDTO
);
try
{
result
=
new
OfflineDownloadService
().
ReExport
(
id
,
this
.
GetBailunToken
());
}
catch
(
Exception
ex
)
{
...
...
@@ -52,5 +68,37 @@ namespace Bailun.DC.Web.Areas.Component.Controllers
return
Json
(
result
);
}
private
string
GetBailunToken
()
{
string
bailunToken
=
default
(
string
);
string
cookie
=
Request
.
Headers
[
"Cookie"
];
if
(!
string
.
IsNullOrWhiteSpace
(
cookie
))
{
int
startIndex
=
cookie
.
IndexOf
(
"BailunToken"
);
if
(
startIndex
>
0
)
{
int
lastIndex
=
cookie
.
IndexOf
(
";"
,
cookie
.
IndexOf
(
"BailunToken"
));
if
(
lastIndex
>
0
)
{
bailunToken
=
cookie
.
Substring
(
startIndex
,
lastIndex
);
}
else
{
bailunToken
=
cookie
.
Substring
(
startIndex
);
}
}
}
if
(!
string
.
IsNullOrWhiteSpace
(
bailunToken
))
{
string
[]
split
=
bailunToken
.
Split
(
"="
,
StringSplitOptions
.
RemoveEmptyEntries
);
if
(
split
.
Length
>
1
)
{
bailunToken
=
split
[
1
];
}
}
return
bailunToken
;
}
}
}
Bailun.DC.Web/wwwroot/css/component/el-dialog-form.css
View file @
92bcbf49
...
...
@@ -55,3 +55,7 @@
.el-dialog__wrapper.el-dialog-form
{
overflow
:
hidden
;
}
.el-dialog-form
.el-dialog
.el-dialog__body
.el-main
.el-form
.el-form-item
.el-table__body-wrapper
{
max-height
:
400px
;
}
\ No newline at end of file
Bailun.DC.Web/wwwroot/js/component/el-table-query.js
View file @
92bcbf49
...
...
@@ -160,7 +160,7 @@
}
else
if
(
fileInfo
.
length
>
1
)
{
exportName
=
fileInfo
[
1
].
replace
(
" filename="
,
""
);
}
else
{
exportName
=
(
that
.
setting
.
listCrumb
&&
that
.
setting
.
listCrumb
.
length
>
0
?
that
.
setting
.
listCrumb
.
join
(
""
)
:
(
'Export'
))
+
"_"
+
(
new
Date
().
format
(
"yyyyMMddhhmm"
))
+
"xls"
;
exportName
=
(
that
.
setting
.
listCrumb
&&
that
.
setting
.
listCrumb
.
length
>
0
?
that
.
setting
.
listCrumb
.
join
(
""
)
:
(
'Export'
))
+
"_"
+
(
new
Date
().
format
(
"yyyyMMddhhmm"
))
+
"
.
xls"
;
}
saveAs
(
respons
.
bodyBlob
,
exportName
);
}
...
...
@@ -184,17 +184,19 @@
//离线导出
onOfflineExport
:
function
(
filterParams
,
cb
)
{
var
that
=
this
;
var
name
=
exportName
=
(
that
.
setting
.
listCrumb
&&
that
.
setting
.
listCrumb
.
length
>
0
?
that
.
setting
.
listCrumb
.
join
(
""
)
:
(
'Export'
))
+
"_"
+
(
new
Date
().
format
(
"yyyyMMddhhmm"
));
that
.
$prompt
(
''
,
'离线导出'
,
{
closeOnClickModal
:
false
,
inputPlaceholder
:
name
}).
then
((
result
)
=>
{
//异步请求
if
(
that
.
$refs
.
formFilter
.
validate
())
{
that
.
$http
.
post
(
"/Component/OfflineDownload/Export"
,
((
filterParams
.
constructor
===
Object
?
filterParams
:
null
)
||
that
.
filterParams
),
{
emulateJSON
:
true
}).
then
(
function
(
response
)
{
that
.
$http
.
post
(
"/Component/OfflineDownload/Export"
,
$
.
extend
({
name
:
result
.
value
},
((
filterParams
.
constructor
===
Object
?
filterParams
:
null
)
||
that
.
filterParams
)
),
{
emulateJSON
:
true
}).
then
(
function
(
response
)
{
var
result
=
response
.
data
;
if
(
response
.
status
===
200
&&
result
.
result
)
{
that
.
$message
({
message
:
'正在导出,请稍后在离线下载页面下载文件!'
,
type
:
'success'
});
}
else
{
this
.
$message
(
result
.
message
||
" 未知错误!"
);
that
.
$message
(
result
.
message
||
" 未知错误!"
);
}
},
function
(
error
)
{
this
.
$message
(
error
.
statusText
||
" 未知错误!"
);
that
.
$message
(
error
.
statusText
||
" 未知错误!"
);
});
}
else
{
var
message
=
that
.
$refs
.
formFilter
.
getValidateMessage
();
...
...
@@ -202,6 +204,7 @@
that
.
$message
({
dangerouslyUseHTMLString
:
true
,
message
:
message
.
join
(
"<br/>"
)
});
}
}
})
},
//单击事件
onClick
:
function
(
fn
)
{
...
...
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