Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
spring-microservice-exam
Project
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
汪想
spring-microservice-exam
Commits
4b812ef1
Commit
4b812ef1
authored
Oct 27, 2019
by
tangyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化
parent
29716af8
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
350 additions
and
121 deletions
+350
-121
CHANGELOG.md
CHANGELOG.md
+6
-0
DateUtils.java
...n/java/com/github/tangyi/common/core/utils/DateUtils.java
+53
-0
docker-compose-nginx.yml
docs/deploy/docker-compose-nginx.yml
+15
-17
start.sh
docs/deploy/start.sh
+1
-0
subject.js
frontend/spring-microservice-exam-ui/src/api/exam/subject.js
+10
-3
zh.js
frontend/spring-microservice-exam-ui/src/lang/zh.js
+1
-1
PanelGroup.vue
...am-ui/src/views/dashboard/admin/components/PanelGroup.vue
+6
-2
exam.vue
frontend/spring-microservice-exam-ui/src/views/exam/exam.vue
+3
-3
examRecord.vue
...spring-microservice-exam-ui/src/views/exam/examRecord.vue
+12
-9
subject.vue
...nd/spring-microservice-exam-ui/src/views/exam/subject.vue
+5
-4
menu.vue
frontend/spring-microservice-exam-ui/src/views/sys/menu.vue
+4
-4
package-lock.json
frontend/spring-microservice-exam-web/package-lock.json
+0
-0
ExamExaminationRecordConstant.java
...gyi/exam/api/constants/ExamExaminationRecordConstant.java
+0
-28
AnswerDto.java
...c/main/java/com/github/tangyi/exam/api/dto/AnswerDto.java
+5
-0
ExaminationRecordDto.java
.../com/github/tangyi/exam/api/dto/ExaminationRecordDto.java
+2
-0
SubmitStatusEnum.java
...va/com/github/tangyi/exam/api/enums/SubmitStatusEnum.java
+49
-0
ExaminationServiceClient.java
...ithub/tangyi/exam/api/feign/ExaminationServiceClient.java
+8
-0
ExaminationServiceClientFallbackImpl.java
.../feign/fallback/ExaminationServiceClientFallbackImpl.java
+6
-0
CourseController.java
...a/com/github/tangyi/exam/controller/CourseController.java
+1
-1
ExamRecordController.java
...m/github/tangyi/exam/controller/ExamRecordController.java
+5
-2
ExaminationController.java
.../github/tangyi/exam/controller/ExaminationController.java
+15
-0
SubjectController.java
.../com/github/tangyi/exam/controller/SubjectController.java
+4
-30
ExaminationMapper.java
...java/com/github/tangyi/exam/mapper/ExaminationMapper.java
+10
-0
ExaminationSubjectMapper.java
...m/github/tangyi/exam/mapper/ExaminationSubjectMapper.java
+10
-0
RabbitSubmitExaminationReceiver.java
...ithub/tangyi/exam/mq/RabbitSubmitExaminationReceiver.java
+4
-4
AnswerService.java
...in/java/com/github/tangyi/exam/service/AnswerService.java
+7
-5
ExaminationService.java
...va/com/github/tangyi/exam/service/ExaminationService.java
+12
-0
ExaminationSubjectService.java
...github/tangyi/exam/service/ExaminationSubjectService.java
+12
-0
SubjectService.java
...n/java/com/github/tangyi/exam/service/SubjectService.java
+35
-1
ExamRecordUtil.java
...ain/java/com/github/tangyi/exam/utils/ExamRecordUtil.java
+25
-3
ExamRecodeMapper.xml
...am-service/src/main/resources/mapper/ExamRecodeMapper.xml
+1
-1
ExaminationMapper.xml
...m-service/src/main/resources/mapper/ExaminationMapper.xml
+4
-0
ExaminationSubjectMapper.xml
...ce/src/main/resources/mapper/ExaminationSubjectMapper.xml
+6
-0
DashboardDto.java
...ain/java/com/github/tangyi/user/api/dto/DashboardDto.java
+5
-0
DashboardController.java
...om/github/tangyi/user/controller/DashboardController.java
+8
-3
No files found.
CHANGELOG.md
View file @
4b812ef1
Version v3.4.0 (2019-10-27)
--------------------------
改进:
*
修复若干bug
Version v3.4.0 (2019-9-14)
Version v3.4.0 (2019-9-14)
--------------------------
--------------------------
改进:
改进:
...
...
common/common-core/src/main/java/com/github/tangyi/common/core/utils/DateUtils.java
View file @
4b812ef1
package
com
.
github
.
tangyi
.
common
.
core
.
utils
;
package
com
.
github
.
tangyi
.
common
.
core
.
utils
;
import
lombok.extern.slf4j.Slf4j
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -13,6 +15,7 @@ import java.util.Date;
...
@@ -13,6 +15,7 @@ import java.util.Date;
* @author tangyi
* @author tangyi
* @date 2019/4/28 16:03
* @date 2019/4/28 16:03
*/
*/
@Slf4j
public
class
DateUtils
{
public
class
DateUtils
{
private
static
final
DateTimeFormatter
FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
private
static
final
DateTimeFormatter
FORMATTER
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
...
@@ -78,4 +81,54 @@ public class DateUtils {
...
@@ -78,4 +81,54 @@ public class DateUtils {
public
static
LocalDateTime
asLocalDateTime
(
Date
date
)
{
public
static
LocalDateTime
asLocalDateTime
(
Date
date
)
{
return
Instant
.
ofEpochMilli
(
date
.
getTime
()).
atZone
(
ZoneId
.
systemDefault
()).
toLocalDateTime
();
return
Instant
.
ofEpochMilli
(
date
.
getTime
()).
atZone
(
ZoneId
.
systemDefault
()).
toLocalDateTime
();
}
}
/**
* 两个时间之差
*
* @param startDate startDate
* @param endDate endDate
* @return 分钟
*/
public
static
Integer
getBetweenMinutes
(
Date
startDate
,
Date
endDate
)
{
int
minutes
=
0
;
try
{
if
(
startDate
!=
null
&&
endDate
!=
null
)
{
long
ss
;
if
(
startDate
.
before
(
endDate
))
{
ss
=
endDate
.
getTime
()
-
startDate
.
getTime
();
}
else
{
ss
=
startDate
.
getTime
()
-
endDate
.
getTime
();
}
minutes
=
(
int
)
(
ss
/
(
60
*
1000
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
return
minutes
;
}
/**
* 两个时间只差
*
* @param startDate startDate
* @param endDate endDate
* @return 秒数
*/
public
static
Integer
getBetweenSecond
(
Date
startDate
,
Date
endDate
)
{
int
seconds
=
0
;
try
{
if
(
startDate
!=
null
&&
endDate
!=
null
)
{
long
ss
;
if
(
startDate
.
before
(
endDate
))
{
ss
=
endDate
.
getTime
()
-
startDate
.
getTime
();
}
else
{
ss
=
startDate
.
getTime
()
-
endDate
.
getTime
();
}
seconds
=
(
int
)
(
ss
/
(
1000
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
return
seconds
;
}
}
}
docs/deploy/docker-compose-nginx.yml
View file @
4b812ef1
...
@@ -32,23 +32,21 @@ services:
...
@@ -32,23 +32,21 @@ services:
networks
:
networks
:
-
net
-
net
# ---------------------------
# # ---------------------------
# example
# # example
# ---------------------------
# # ---------------------------
spring-microservice-exam-web-Spencer
:
# spring-microservice-exam-web-Spencer:
image
:
registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/spring-microservice-exam-web:latest
# image: registry.cn-hangzhou.aliyuncs.com/spring-microservice-exam/exam-web-example:latest
volumes
:
# volumes:
# 挂载nginx的配置文件
# # 挂载nginx的配置文件
-
./nginx.conf:/etc/nginx/nginx.conf
# - ./nginx.conf:/etc/nginx/nginx.conf
container_name
:
web-service-example
# container_name: web-service-example
environment
:
# env_file: docker-compose.env # 从文件中获取配置
-
TENANT_CODE=example
# restart: always
-
GATEWAY_SERVICE_HOST=gateway-service
# ports:
restart
:
always
# - "88:80"
ports
:
# networks:
-
"
88:80"
# - net
networks
:
-
net
networks
:
networks
:
net
:
net
:
...
...
docs/deploy/start.sh
View file @
4b812ef1
...
@@ -17,6 +17,7 @@ MSC_SERVICE=$BASE_IMAGE_NAME/msc-service:$BSEE_IMAGE_TAG
...
@@ -17,6 +17,7 @@ MSC_SERVICE=$BASE_IMAGE_NAME/msc-service:$BSEE_IMAGE_TAG
MONITOR_SERVICE
=
$BASE_IMAGE_NAME
/monitor-service:
$BSEE_IMAGE_TAG
MONITOR_SERVICE
=
$BASE_IMAGE_NAME
/monitor-service:
$BSEE_IMAGE_TAG
UI_SERVICE
=
$BASE_IMAGE_NAME
/spring-microservice-exam-ui:
$BSEE_IMAGE_TAG
UI_SERVICE
=
$BASE_IMAGE_NAME
/spring-microservice-exam-ui:
$BSEE_IMAGE_TAG
WEB_SERVICE
=
$BASE_IMAGE_NAME
/spring-microservice-exam-web:
$BSEE_IMAGE_TAG
WEB_SERVICE
=
$BASE_IMAGE_NAME
/spring-microservice-exam-web:
$BSEE_IMAGE_TAG
WEB_SERVICE_EXAMPLE
=
$BASE_IMAGE_NAME
/exam-web-example:
$BSEE_IMAGE_TAG
case
"
$1
"
in
case
"
$1
"
in
...
...
frontend/spring-microservice-exam-ui/src/api/exam/subject.js
View file @
4b812ef1
...
@@ -58,12 +58,19 @@ export function delAllSubject (obj) {
...
@@ -58,12 +58,19 @@ export function delAllSubject (obj) {
}
}
// 导出
// 导出
export
function
exportSubject
(
obj
)
{
export
function
exportSubject
(
ids
,
examinationId
,
categoryId
)
{
let
url
=
baseSubjectUrl
+
'export?'
if
(
examinationId
!==
null
&&
examinationId
!==
''
)
{
url
=
url
+
'examinationId='
+
examinationId
}
if
(
categoryId
!==
null
&&
categoryId
!==
''
)
{
url
=
url
+
'&categoryId='
+
categoryId
}
return
request
({
return
request
({
url
:
baseSubjectUrl
+
'export'
,
url
:
url
,
method
:
'post'
,
method
:
'post'
,
responseType
:
'arraybuffer'
,
responseType
:
'arraybuffer'
,
headers
:
{
'filename'
:
'utf-8'
},
headers
:
{
'filename'
:
'utf-8'
},
data
:
obj
data
:
ids
})
})
}
}
frontend/spring-microservice-exam-ui/src/lang/zh.js
View file @
4b812ef1
...
@@ -210,7 +210,7 @@ export default {
...
@@ -210,7 +210,7 @@ export default {
score
:
'成绩'
,
score
:
'成绩'
,
examTime
:
'考试时间'
,
examTime
:
'考试时间'
,
submitStatus
:
'状态'
,
submitStatus
:
'状态'
,
details
:
'
成绩
详情'
,
details
:
'详情'
,
marking
:
'批改'
marking
:
'批改'
},
},
knowledge
:
{
knowledge
:
{
...
...
frontend/spring-microservice-exam-ui/src/views/dashboard/admin/components/PanelGroup.vue
View file @
4b812ef1
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
</div>
</div>
<div
class=
"card-panel-description"
>
<div
class=
"card-panel-description"
>
<div
class=
"card-panel-text"
>
参加人数
</div>
<div
class=
"card-panel-text"
>
参加人数
</div>
<count-to
:start-val=
"0"
:end-val=
"
9280
"
:duration=
"2400"
class=
"card-panel-num"
/>
<count-to
:start-val=
"0"
:end-val=
"
examUserNumber
"
:duration=
"2400"
class=
"card-panel-num"
/>
</div>
</div>
</div>
</div>
</el-col>
</el-col>
...
@@ -59,7 +59,8 @@ export default {
...
@@ -59,7 +59,8 @@ export default {
data
()
{
data
()
{
return
{
return
{
onlineUserNumber
:
0
,
onlineUserNumber
:
0
,
examinationNumber
:
0
examinationNumber
:
0
,
examUserNumber
:
0
}
}
},
},
created
()
{
created
()
{
...
@@ -80,6 +81,9 @@ export default {
...
@@ -80,6 +81,9 @@ export default {
if
(
isNotEmpty
(
data
.
examinationNumber
))
{
if
(
isNotEmpty
(
data
.
examinationNumber
))
{
this
.
examinationNumber
=
parseInt
(
data
.
examinationNumber
)
this
.
examinationNumber
=
parseInt
(
data
.
examinationNumber
)
}
}
if
(
isNotEmpty
(
data
.
examUserNumber
))
{
this
.
examUserNumber
=
parseInt
(
data
.
examUserNumber
)
}
}
}
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
error
(
error
)
console
.
error
(
error
)
...
...
frontend/spring-microservice-exam-ui/src/views/exam/exam.vue
View file @
4b812ef1
...
@@ -188,7 +188,7 @@
...
@@ -188,7 +188,7 @@
</el-dialog>
</el-dialog>
<!--题目管理列表-->
<!--题目管理列表-->
<el-dialog
:visible
.
sync=
"dialogSubjectVisible"
:title=
"$t('table.subjectManagement')"
width=
"80%"
top=
"
10
vh"
>
<el-dialog
:visible
.
sync=
"dialogSubjectVisible"
:title=
"$t('table.subjectManagement')"
width=
"80%"
top=
"
5
vh"
>
<div
class=
"filter-container"
>
<div
class=
"filter-container"
>
<el-input
:placeholder=
"$t('table.subjectName')"
v-model=
"subject.listQuery.subjectName"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"handleFilterSubject"
/>
<el-input
:placeholder=
"$t('table.subjectName')"
v-model=
"subject.listQuery.subjectName"
style=
"width: 200px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"handleFilterSubject"
/>
<el-button
v-waves
class=
"filter-item"
type=
"primary"
icon=
"el-icon-search"
@
click=
"handleFilterSubject"
>
{{ $t('table.search') }}
</el-button>
<el-button
v-waves
class=
"filter-item"
type=
"primary"
icon=
"el-icon-search"
@
click=
"handleFilterSubject"
>
{{ $t('table.search') }}
</el-button>
...
@@ -1080,7 +1080,7 @@ export default {
...
@@ -1080,7 +1080,7 @@ export default {
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'success'
type
:
'success'
}).
then
(()
=>
{
}).
then
(()
=>
{
exportSubject
(
{
idString
:
''
,
examinationId
:
this
.
subject
.
examinationId
}
).
then
(
response
=>
{
exportSubject
(
[],
this
.
subject
.
examinationId
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
@@ -1096,7 +1096,7 @@ export default {
...
@@ -1096,7 +1096,7 @@ export default {
for
(
let
i
=
0
;
i
<
this
.
multipleSubjectSelection
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
multipleSubjectSelection
.
length
;
i
++
)
{
ids
.
push
(
this
.
multipleSubjectSelection
[
i
].
id
)
ids
.
push
(
this
.
multipleSubjectSelection
[
i
].
id
)
}
}
exportSubject
(
{
ids
:
ids
,
examinationId
:
''
}
).
then
(
response
=>
{
exportSubject
(
ids
,
''
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
...
frontend/spring-microservice-exam-ui/src/views/exam/examRecord.vue
View file @
4b812ef1
...
@@ -81,7 +81,7 @@
...
@@ -81,7 +81,7 @@
</el-dialog>
</el-dialog>
<!-- 批改 -->
<!-- 批改 -->
<el-dialog
:visible
.
sync=
"dialogMarkingVisible"
:title=
"$t('table.examRecord.marking')"
width=
"80%"
top=
"
10
vh"
>
<el-dialog
:visible
.
sync=
"dialogMarkingVisible"
:title=
"$t('table.examRecord.marking')"
width=
"80%"
top=
"
5
vh"
>
<el-row
:gutter=
"20"
>
<el-row
:gutter=
"20"
>
<el-col
:span=
"20"
class=
"subject-box-card"
v-loading=
"markLoading"
>
<el-col
:span=
"20"
class=
"subject-box-card"
v-loading=
"markLoading"
>
<el-form
ref=
"dataAnswerForm"
:model=
"tempAnswer"
:label-position=
"labelPosition"
label-width=
"100px"
>
<el-form
ref=
"dataAnswerForm"
:model=
"tempAnswer"
:label-position=
"labelPosition"
label-width=
"100px"
>
...
@@ -104,7 +104,7 @@
...
@@ -104,7 +104,7 @@
</el-col>
</el-col>
<el-col
:span=
"6"
>
<el-col
:span=
"6"
>
<el-form-item
label=
"耗时:"
>
<el-form-item
label=
"耗时:"
>
<span>
{{
tempAnswer | consumingFilter
}}
</span>
<span>
{{
tempAnswer.duration
}}
</span>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
...
@@ -222,9 +222,6 @@ export default {
...
@@ -222,9 +222,6 @@ export default {
},
},
timeFilter
(
time
)
{
timeFilter
(
time
)
{
return
formatDate
(
new
Date
(
time
),
'yyyy-MM-dd hh:mm'
)
return
formatDate
(
new
Date
(
time
),
'yyyy-MM-dd hh:mm'
)
},
consumingFilter
(
answer
)
{
return
(
answer
.
endTime
-
answer
.
startTime
)
/
1000
+
'ms'
}
}
},
},
data
()
{
data
()
{
...
@@ -361,17 +358,17 @@ export default {
...
@@ -361,17 +358,17 @@ export default {
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
type
:
'warning'
}).
then
(()
=>
{
}).
then
(()
=>
{
exportObj
(
{
idString
:
''
}
).
then
(
response
=>
{
exportObj
(
[]
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
}).
catch
(()
=>
{})
}).
catch
(()
=>
{})
}
else
{
}
else
{
let
ids
=
''
let
ids
=
[]
for
(
let
i
=
0
;
i
<
this
.
multipleSelection
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
multipleSelection
.
length
;
i
++
)
{
ids
+=
this
.
multipleSelection
[
i
].
id
+
','
ids
.
push
(
this
.
multipleSelection
[
i
].
id
)
}
}
exportObj
(
{
idString
:
ids
}
).
then
(
response
=>
{
exportObj
(
ids
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
@@ -470,6 +467,12 @@ export default {
...
@@ -470,6 +467,12 @@ export default {
})
})
}
else
{
}
else
{
this
.
tempAnswer
=
response
.
data
.
data
this
.
tempAnswer
=
response
.
data
.
data
// 题号
if
(
nextType
===
1
)
{
this
.
currentIndex
--
}
else
if
(
nextType
===
0
)
{
this
.
currentIndex
++
}
}
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
markLoading
=
false
this
.
markLoading
=
false
...
...
frontend/spring-microservice-exam-ui/src/views/exam/subject.vue
View file @
4b812ef1
...
@@ -714,7 +714,7 @@ export default {
...
@@ -714,7 +714,7 @@ export default {
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'success'
type
:
'success'
}).
then
(()
=>
{
}).
then
(()
=>
{
exportSubject
(
{
idString
:
''
,
categoryId
:
this
.
currentCategoryId
,
type
:
this
.
listQuery
.
type
}
).
then
(
response
=>
{
exportSubject
(
[],
''
,
this
.
currentCategoryId
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
@@ -722,6 +722,7 @@ export default {
...
@@ -722,6 +722,7 @@ export default {
})
})
}
else
{
}
else
{
debugger
// 导出选中
// 导出选中
this
.
$confirm
(
'是否导出选中的题目?'
,
'提示'
,
{
this
.
$confirm
(
'是否导出选中的题目?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
confirmButtonText
:
'确定'
,
...
@@ -729,10 +730,10 @@ export default {
...
@@ -729,10 +730,10 @@ export default {
type
:
'success'
type
:
'success'
}).
then
(()
=>
{
}).
then
(()
=>
{
let
ids
=
[]
let
ids
=
[]
for
(
let
i
=
0
;
i
<
this
.
multipleSelection
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
multipleS
ubjectS
election
.
length
;
i
++
)
{
ids
.
push
(
this
.
multipleSelection
[
i
].
id
)
ids
.
push
(
this
.
multipleS
ubjectS
election
[
i
].
id
)
}
}
exportSubject
(
{
ids
:
ids
,
categoryId
:
''
}
).
then
(
response
=>
{
exportSubject
(
ids
,
''
,
''
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
...
frontend/spring-microservice-exam-ui/src/views/sys/menu.vue
View file @
4b812ef1
...
@@ -369,14 +369,14 @@ export default {
...
@@ -369,14 +369,14 @@ export default {
handleExportMenu
()
{
handleExportMenu
()
{
// 获取选中节点
// 获取选中节点
const
keys
=
this
.
$refs
.
menuTree
.
getCheckedKeys
(
true
).
concat
(
this
.
$refs
.
menuTree
.
getHalfCheckedKeys
())
const
keys
=
this
.
$refs
.
menuTree
.
getCheckedKeys
(
true
).
concat
(
this
.
$refs
.
menuTree
.
getHalfCheckedKeys
())
let
menus
=
''
let
ids
=
[]
if
(
keys
.
length
===
0
)
{
if
(
keys
.
length
===
0
)
{
this
.
$confirm
(
'是否导出所有菜单?'
,
'提示'
,
{
this
.
$confirm
(
'是否导出所有菜单?'
,
'提示'
,
{
confirmButtonText
:
'确定'
,
confirmButtonText
:
'确定'
,
cancelButtonText
:
'取消'
,
cancelButtonText
:
'取消'
,
type
:
'success'
type
:
'success'
}).
then
(()
=>
{
}).
then
(()
=>
{
exportObj
(
{
idString
:
menus
}
).
then
(
response
=>
{
exportObj
(
ids
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
@@ -388,9 +388,9 @@ export default {
...
@@ -388,9 +388,9 @@ export default {
type
:
'success'
type
:
'success'
}).
then
(()
=>
{
}).
then
(()
=>
{
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
keys
.
length
;
i
++
)
{
menus
=
menus
+
keys
[
i
]
+
','
ids
.
push
(
keys
[
i
])
}
}
exportObj
(
{
idString
:
menus
}
).
then
(
response
=>
{
exportObj
(
ids
).
then
(
response
=>
{
// 导出Excel
// 导出Excel
exportExcel
(
response
)
exportExcel
(
response
)
})
})
...
...
frontend/spring-microservice-exam-web/package-lock.json
deleted
100644 → 0
View file @
29716af8
This source diff could not be displayed because it is too large. You can
view the blob
instead.
modules/exam-service-parent/exam-service-api/src/main/java/com/github/tangyi/exam/api/constants/ExamExaminationRecordConstant.java
deleted
100644 → 0
View file @
29716af8
package
com
.
github
.
tangyi
.
exam
.
api
.
constants
;
/**
* @author tangyi
* @date 2019/5/3 14:41
*/
public
class
ExamExaminationRecordConstant
{
/**
* 未提交
*/
public
static
final
Integer
STATUS_NOT_SUBMITTED
=
0
;
/**
* 已提交
*/
public
static
final
Integer
STATUS_SUBMITTED
=
1
;
/**
* 正在统计
*/
public
static
final
Integer
STATUS_CALCULATE
=
2
;
/**
* 统计完成
*/
public
static
final
Integer
STATUS_CALCULATED
=
3
;
}
modules/exam-service-parent/exam-service-api/src/main/java/com/github/tangyi/exam/api/dto/AnswerDto.java
View file @
4b812ef1
...
@@ -78,4 +78,9 @@ public class AnswerDto implements Serializable {
...
@@ -78,4 +78,9 @@ public class AnswerDto implements Serializable {
* 结束时间
* 结束时间
*/
*/
private
Date
endTime
;
private
Date
endTime
;
/**
* 耗时
*/
private
String
duration
;
}
}
modules/exam-service-parent/exam-service-api/src/main/java/com/github/tangyi/exam/api/dto/ExaminationRecordDto.java
View file @
4b812ef1
...
@@ -134,4 +134,6 @@ public class ExaminationRecordDto extends BaseEntity<ExaminationRecordDto> {
...
@@ -134,4 +134,6 @@ public class ExaminationRecordDto extends BaseEntity<ExaminationRecordDto> {
* 提交状态 1-已提交 0-未提交
* 提交状态 1-已提交 0-未提交
*/
*/
private
Integer
submitStatus
;
private
Integer
submitStatus
;
private
String
submitStatusName
;
}
}
modules/exam-service-parent/exam-service-api/src/main/java/com/github/tangyi/exam/api/enums/SubmitStatusEnum.java
0 → 100644
View file @
4b812ef1
package
com
.
github
.
tangyi
.
exam
.
api
.
enums
;
/**
* @author tangyi
* @date 2019/10/22 21:44
*/
public
enum
SubmitStatusEnum
{
NOT_SUBMITTED
(
"未提交"
,
0
),
SUBMITTED
(
"已提交"
,
1
),
CALCULATE
(
"正在统计"
,
2
),
CALCULATED
(
"统计完成"
,
3
);
private
String
name
;
private
Integer
value
;
SubmitStatusEnum
(
String
name
,
Integer
value
)
{
this
.
name
=
name
;
this
.
value
=
value
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Integer
getValue
()
{
return
value
;
}
public
void
setValue
(
Integer
value
)
{
this
.
value
=
value
;
}
public
static
SubmitStatusEnum
match
(
Integer
value
,
SubmitStatusEnum
defaultValue
)
{
if
(
value
!=
null
)
{
for
(
SubmitStatusEnum
item
:
SubmitStatusEnum
.
values
())
{
if
(
item
.
value
.
equals
(
value
))
{
return
item
;
}
}
}
return
defaultValue
;
}
}
modules/exam-service-parent/exam-service-api/src/main/java/com/github/tangyi/exam/api/feign/ExaminationServiceClient.java
View file @
4b812ef1
...
@@ -27,4 +27,12 @@ public interface ExaminationServiceClient {
...
@@ -27,4 +27,12 @@ public interface ExaminationServiceClient {
*/
*/
@GetMapping
(
"/v1/examination/examinationCount"
)
@GetMapping
(
"/v1/examination/examinationCount"
)
ResponseBean
<
Integer
>
findExaminationCount
(
@RequestParam
(
"tenantCode"
)
String
tenantCode
);
ResponseBean
<
Integer
>
findExaminationCount
(
@RequestParam
(
"tenantCode"
)
String
tenantCode
);
/**
* 查询参与人数
* @param tenantCode tenantCode
* @return ResponseBean
*/
@GetMapping
(
"/v1/examination/examUserCount"
)
ResponseBean
<
Integer
>
findExamUserCount
(
@RequestParam
(
"tenantCode"
)
String
tenantCode
);
}
}
modules/exam-service-parent/exam-service-api/src/main/java/com/github/tangyi/exam/api/feign/fallback/ExaminationServiceClientFallbackImpl.java
View file @
4b812ef1
...
@@ -24,6 +24,12 @@ public class ExaminationServiceClientFallbackImpl implements ExaminationServiceC
...
@@ -24,6 +24,12 @@ public class ExaminationServiceClientFallbackImpl implements ExaminationServiceC
return
new
ResponseBean
<>(
0
);
return
new
ResponseBean
<>(
0
);
}
}
@Override
public
ResponseBean
<
Integer
>
findExamUserCount
(
String
tenantCode
)
{
log
.
error
(
"调用{}异常, {}, {}"
,
"findExamUserCount"
,
tenantCode
,
throwable
);
return
null
;
}
public
Throwable
getThrowable
()
{
public
Throwable
getThrowable
()
{
return
throwable
;
return
throwable
;
}
}
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/controller/CourseController.java
View file @
4b812ef1
...
@@ -80,7 +80,7 @@ public class CourseController extends BaseController {
...
@@ -80,7 +80,7 @@ public class CourseController extends BaseController {
@RequestParam
(
value
=
CommonConstant
.
SORT
,
required
=
false
,
defaultValue
=
CommonConstant
.
PAGE_SORT_DEFAULT
)
String
sort
,
@RequestParam
(
value
=
CommonConstant
.
SORT
,
required
=
false
,
defaultValue
=
CommonConstant
.
PAGE_SORT_DEFAULT
)
String
sort
,
@RequestParam
(
value
=
CommonConstant
.
ORDER
,
required
=
false
,
defaultValue
=
CommonConstant
.
PAGE_ORDER_DEFAULT
)
String
order
,
@RequestParam
(
value
=
CommonConstant
.
ORDER
,
required
=
false
,
defaultValue
=
CommonConstant
.
PAGE_ORDER_DEFAULT
)
String
order
,
Course
course
)
{
Course
course
)
{
course
.
setTe
acher
(
SysUtil
.
getTenantCode
());
course
.
setTe
nantCode
(
SysUtil
.
getTenantCode
());
return
courseService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
course
);
return
courseService
.
findPage
(
PageUtil
.
pageInfo
(
pageNum
,
pageSize
,
sort
,
order
),
course
);
}
}
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/controller/ExamRecordController.java
View file @
4b812ef1
...
@@ -11,6 +11,7 @@ import com.github.tangyi.common.log.annotation.Log;
...
@@ -11,6 +11,7 @@ import com.github.tangyi.common.log.annotation.Log;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.common.security.constant.SecurityConstant
;
import
com.github.tangyi.exam.api.dto.ExaminationRecordDto
;
import
com.github.tangyi.exam.api.dto.ExaminationRecordDto
;
import
com.github.tangyi.exam.api.dto.StartExamDto
;
import
com.github.tangyi.exam.api.dto.StartExamDto
;
import
com.github.tangyi.exam.api.enums.SubmitStatusEnum
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.ExaminationRecord
;
import
com.github.tangyi.exam.api.module.ExaminationRecord
;
import
com.github.tangyi.exam.service.AnswerService
;
import
com.github.tangyi.exam.service.AnswerService
;
...
@@ -279,12 +280,14 @@ public class ExamRecordController extends BaseController {
...
@@ -279,12 +280,14 @@ public class ExamRecordController extends BaseController {
ExaminationRecordDto
recordDto
=
new
ExaminationRecordDto
();
ExaminationRecordDto
recordDto
=
new
ExaminationRecordDto
();
recordDto
.
setId
(
tempExamRecord
.
getId
());
recordDto
.
setId
(
tempExamRecord
.
getId
());
recordDto
.
setExaminationName
(
examRecordExamination
.
getExaminationName
());
recordDto
.
setExaminationName
(
examRecordExamination
.
getExaminationName
());
//recordDto.setExamTime(tempExamRecord.getCreateDate());
recordDto
.
setStartTime
(
tempExamRecord
.
getStartTime
());
recordDto
.
setEndTime
(
tempExamRecord
.
getEndTime
());
recordDto
.
setDuration
(
ExamRecordUtil
.
getExamDuration
(
tempExamRecord
.
getStartTime
(),
tempExamRecord
.
getEndTime
()));
recordDto
.
setScore
(
tempExamRecord
.
getScore
());
recordDto
.
setScore
(
tempExamRecord
.
getScore
());
recordDto
.
setUserId
(
tempExamRecord
.
getUserId
());
recordDto
.
setUserId
(
tempExamRecord
.
getUserId
());
recordDto
.
setCorrectNumber
(
tempExamRecord
.
getCorrectNumber
());
recordDto
.
setCorrectNumber
(
tempExamRecord
.
getCorrectNumber
());
recordDto
.
setInCorrectNumber
(
tempExamRecord
.
getInCorrectNumber
());
recordDto
.
setInCorrectNumber
(
tempExamRecord
.
getInCorrectNumber
());
recordDto
.
setSubmitStatus
(
tempExamRecord
.
getSubmitStatus
());
recordDto
.
setSubmitStatus
Name
(
SubmitStatusEnum
.
match
(
tempExamRecord
.
getSubmitStatus
(),
SubmitStatusEnum
.
NOT_SUBMITTED
).
getName
());
userIdSet
.
add
(
tempExamRecord
.
getUserId
());
userIdSet
.
add
(
tempExamRecord
.
getUserId
());
examRecordDtoList
.
add
(
recordDto
);
examRecordDtoList
.
add
(
recordDto
);
}
}
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/controller/ExaminationController.java
View file @
4b812ef1
...
@@ -269,4 +269,19 @@ public class ExaminationController extends BaseController {
...
@@ -269,4 +269,19 @@ public class ExaminationController extends BaseController {
examination
.
setId
(
examinationId
);
examination
.
setId
(
examinationId
);
return
new
ResponseBean
<>(
examinationService
.
findListByExaminationId
(
examination
));
return
new
ResponseBean
<>(
examinationService
.
findListByExaminationId
(
examination
));
}
}
/**
* 查询参与考试人数
*
* @param tenantCode tenantCode
* @return ResponseBean
* @author tangyi
* @date 2019/10/27 20:07:38
*/
@GetMapping
(
"examUserCount"
)
public
ResponseBean
<
Integer
>
findExamUserCount
(
@RequestParam
@NotBlank
String
tenantCode
)
{
Examination
examination
=
new
Examination
();
examination
.
setCommonValue
(
SysUtil
.
getUser
(),
SysUtil
.
getSysCode
(),
tenantCode
);
return
new
ResponseBean
<>(
examinationService
.
findExamUserCount
(
examination
));
}
}
}
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/controller/SubjectController.java
View file @
4b812ef1
...
@@ -17,7 +17,6 @@ import io.swagger.annotations.*;
...
@@ -17,7 +17,6 @@ import io.swagger.annotations.*;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ArrayUtils
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
...
@@ -27,11 +26,7 @@ import javax.servlet.http.HttpServletResponse;
...
@@ -27,11 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
/**
* 题目controller
* 题目controller
...
@@ -171,14 +166,12 @@ public class SubjectController extends BaseController {
...
@@ -171,14 +166,12 @@ public class SubjectController extends BaseController {
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"题目ID"
,
required
=
true
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"题目ID"
,
required
=
true
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"examinationId"
,
value
=
"考试ID"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"examinationId"
,
value
=
"考试ID"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"categoryId"
,
value
=
"分类ID"
,
dataType
=
"Long"
),
@ApiImplicitParam
(
name
=
"categoryId"
,
value
=
"分类ID"
,
dataType
=
"Long"
)
@ApiImplicitParam
(
name
=
"type"
,
value
=
"题目类型"
,
required
=
true
,
dataType
=
"Integer"
,
example
=
"3"
)
})
})
@Log
(
"导出题目"
)
@Log
(
"导出题目"
)
public
void
exportSubject
(
@RequestBody
Long
[]
ids
,
public
void
exportSubject
(
@RequestBody
Long
[]
ids
,
@RequestParam
Long
examinationId
,
@RequestParam
(
required
=
false
)
Long
examinationId
,
@RequestParam
Long
categoryId
,
@RequestParam
(
required
=
false
)
Long
categoryId
,
@RequestParam
Integer
type
,
HttpServletRequest
request
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
HttpServletResponse
response
)
{
try
{
try
{
...
@@ -187,26 +180,7 @@ public class SubjectController extends BaseController {
...
@@ -187,26 +180,7 @@ public class SubjectController extends BaseController {
response
.
setContentType
(
"multipart/form-data"
);
response
.
setContentType
(
"multipart/form-data"
);
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
response
.
setHeader
(
HttpHeaders
.
CONTENT_DISPOSITION
,
Servlets
.
getDownName
(
request
,
"题目信息"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
"题目信息"
+
DateUtils
.
localDateMillisToString
(
LocalDateTime
.
now
())
+
".xlsx"
));
List
<
SubjectDto
>
subjects
=
new
ArrayList
<>();
List
<
SubjectDto
>
subjects
=
subjectService
.
export
(
ids
,
examinationId
,
categoryId
);
// 根据题目id导出
if
(
ArrayUtils
.
isNotEmpty
(
ids
))
{
subjects
=
Stream
.
of
(
ids
)
// 根据ID查找题目信息
.
map
(
subjectService:
:
get
)
// 过滤收集
.
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
}
else
if
(
examinationId
!=
null
)
{
// 根据考试ID
SubjectDto
subjectDto
=
new
SubjectDto
();
subjectDto
.
setExaminationId
(
examinationId
);
subjects
=
subjectService
.
findList
(
subjectDto
);
}
else
if
(
categoryId
!=
null
||
type
!=
null
)
{
// 根据分类ID、类型导出
SubjectDto
subjectDto
=
new
SubjectDto
();
subjectDto
.
setCategoryId
(
categoryId
);
subjectDto
.
setType
(
type
);
subjects
=
subjectService
.
findListByType
(
subjectDto
);
}
ExcelToolUtil
.
exportExcel
(
request
.
getInputStream
(),
response
.
getOutputStream
(),
MapUtil
.
java2Map
(
subjects
),
ExcelToolUtil
.
exportExcel
(
request
.
getInputStream
(),
response
.
getOutputStream
(),
MapUtil
.
java2Map
(
subjects
),
SubjectUtil
.
getSubjectMap
());
SubjectUtil
.
getSubjectMap
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/mapper/ExaminationMapper.java
View file @
4b812ef1
...
@@ -22,4 +22,14 @@ public interface ExaminationMapper extends CrudMapper<Examination> {
...
@@ -22,4 +22,14 @@ public interface ExaminationMapper extends CrudMapper<Examination> {
* @date 2019/3/1 15:32
* @date 2019/3/1 15:32
*/
*/
int
findExaminationCount
(
Examination
examination
);
int
findExaminationCount
(
Examination
examination
);
/**
* 查询参与考试人数
*
* @param examination examination
* @return int
* @author tangyi
* @date 2019/10/27 20:08:58
*/
int
findExamUserCount
(
Examination
examination
);
}
}
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/mapper/ExaminationSubjectMapper.java
View file @
4b812ef1
...
@@ -74,4 +74,14 @@ public interface ExaminationSubjectMapper extends CrudMapper<ExaminationSubject>
...
@@ -74,4 +74,14 @@ public interface ExaminationSubjectMapper extends CrudMapper<ExaminationSubject>
* @date 2019/10/07 20:40:16
* @date 2019/10/07 20:40:16
*/
*/
ExaminationSubject
getPreviousByCurrentId
(
ExaminationSubject
examinationSubject
);
ExaminationSubject
getPreviousByCurrentId
(
ExaminationSubject
examinationSubject
);
/**
* 根据分类id查询
*
* @param examinationSubject examinationSubject
* @return List
* @author tangyi
* @date 2019/10/24 21:47:24
*/
List
<
ExaminationSubject
>
findListByCategoryId
(
ExaminationSubject
examinationSubject
);
}
}
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/mq/RabbitSubmitExaminationReceiver.java
View file @
4b812ef1
...
@@ -2,7 +2,7 @@ package com.github.tangyi.exam.mq;
...
@@ -2,7 +2,7 @@ package com.github.tangyi.exam.mq;
import
com.github.tangyi.common.core.constant.MqConstant
;
import
com.github.tangyi.common.core.constant.MqConstant
;
import
com.github.tangyi.common.security.tenant.TenantContextHolder
;
import
com.github.tangyi.common.security.tenant.TenantContextHolder
;
import
com.github.tangyi.exam.api.
constants.ExamExaminationRecordConstant
;
import
com.github.tangyi.exam.api.
enums.SubmitStatusEnum
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.ExaminationRecord
;
import
com.github.tangyi.exam.api.module.ExaminationRecord
;
import
com.github.tangyi.exam.service.AnswerService
;
import
com.github.tangyi.exam.service.AnswerService
;
...
@@ -47,12 +47,12 @@ public class RabbitSubmitExaminationReceiver {
...
@@ -47,12 +47,12 @@ public class RabbitSubmitExaminationReceiver {
examRecord
=
examRecordService
.
get
(
examRecord
);
examRecord
=
examRecordService
.
get
(
examRecord
);
if
(
examRecord
==
null
)
if
(
examRecord
==
null
)
return
;
return
;
if
(
ExamExaminationRecordConstant
.
STATUS_NOT_SUBMITTED
.
equals
(
examRecord
.
getSubmitStatus
()))
if
(
SubmitStatusEnum
.
NOT_SUBMITTED
.
getValue
()
.
equals
(
examRecord
.
getSubmitStatus
()))
log
.
warn
(
"考试:{}未提交"
,
examRecord
.
getId
());
log
.
warn
(
"考试:{}未提交"
,
examRecord
.
getId
());
if
(
ExamExaminationRecordConstant
.
STATUS_CALCULATE
.
equals
(
examRecord
.
getSubmitStatus
()))
if
(
SubmitStatusEnum
.
CALCULATE
.
getValue
()
.
equals
(
examRecord
.
getSubmitStatus
()))
log
.
warn
(
"考试:{}正在统计成绩,请勿重复提交"
,
examRecord
.
getId
());
log
.
warn
(
"考试:{}正在统计成绩,请勿重复提交"
,
examRecord
.
getId
());
// 更新状态为正在统计
// 更新状态为正在统计
examRecord
.
setSubmitStatus
(
ExamExaminationRecordConstant
.
STATUS_CALCULATE
);
examRecord
.
setSubmitStatus
(
SubmitStatusEnum
.
CALCULATE
.
getValue
()
);
// 更新成功
// 更新成功
if
(
examRecordService
.
update
(
examRecord
)
>
0
)
{
if
(
examRecordService
.
update
(
examRecord
)
>
0
)
{
log
.
debug
(
"考试:{}更新状态为正在统计成功"
,
examRecord
.
getId
());
log
.
debug
(
"考试:{}更新状态为正在统计成功"
,
examRecord
.
getId
());
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/service/AnswerService.java
View file @
4b812ef1
...
@@ -8,16 +8,17 @@ import com.github.tangyi.common.core.service.CrudService;
...
@@ -8,16 +8,17 @@ import com.github.tangyi.common.core.service.CrudService;
import
com.github.tangyi.common.core.utils.PageUtil
;
import
com.github.tangyi.common.core.utils.PageUtil
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.common.core.utils.SysUtil
;
import
com.github.tangyi.exam.api.constants.AnswerConstant
;
import
com.github.tangyi.exam.api.constants.AnswerConstant
;
import
com.github.tangyi.exam.api.constants.ExamExaminationRecordConstant
;
import
com.github.tangyi.exam.api.dto.AnswerDto
;
import
com.github.tangyi.exam.api.dto.AnswerDto
;
import
com.github.tangyi.exam.api.dto.StartExamDto
;
import
com.github.tangyi.exam.api.dto.StartExamDto
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.dto.SubjectDto
;
import
com.github.tangyi.exam.api.enums.SubmitStatusEnum
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.Answer
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.Examination
;
import
com.github.tangyi.exam.api.module.ExaminationRecord
;
import
com.github.tangyi.exam.api.module.ExaminationRecord
;
import
com.github.tangyi.exam.api.module.ExaminationSubject
;
import
com.github.tangyi.exam.api.module.ExaminationSubject
;
import
com.github.tangyi.exam.enums.SubjectTypeEnum
;
import
com.github.tangyi.exam.enums.SubjectTypeEnum
;
import
com.github.tangyi.exam.mapper.AnswerMapper
;
import
com.github.tangyi.exam.mapper.AnswerMapper
;
import
com.github.tangyi.exam.utils.ExamRecordUtil
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
...
@@ -204,7 +205,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
...
@@ -204,7 +205,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
}
}
// 如果全部为选择题,则更新状态为统计完成,否则需要阅卷完成后才更改统计状态
// 如果全部为选择题,则更新状态为统计完成,否则需要阅卷完成后才更改统计状态
if
(!
distinctAnswer
.
containsKey
(
SubjectTypeEnum
.
SHORT_ANSWER
.
name
()))
if
(!
distinctAnswer
.
containsKey
(
SubjectTypeEnum
.
SHORT_ANSWER
.
name
()))
record
.
setSubmitStatus
(
ExamExaminationRecordConstant
.
STATUS_CALCULATED
);
record
.
setSubmitStatus
(
SubmitStatusEnum
.
CALCULATED
.
getValue
()
);
// 保存成绩
// 保存成绩
record
.
setCommonValue
(
currentUsername
,
SysUtil
.
getSysCode
());
record
.
setCommonValue
(
currentUsername
,
SysUtil
.
getSysCode
());
record
.
setId
(
answer
.
getExamRecordId
());
record
.
setId
(
answer
.
getExamRecordId
());
...
@@ -240,7 +241,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
...
@@ -240,7 +241,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
examRecord
.
setId
(
answer
.
getExamRecordId
());
examRecord
.
setId
(
answer
.
getExamRecordId
());
// 提交时间
// 提交时间
examRecord
.
setEndTime
(
examRecord
.
getCreateDate
());
examRecord
.
setEndTime
(
examRecord
.
getCreateDate
());
examRecord
.
setSubmitStatus
(
ExamExaminationRecordConstant
.
STATUS_SUBMITTED
);
examRecord
.
setSubmitStatus
(
SubmitStatusEnum
.
SUBMITTED
.
getValue
()
);
// 1. 发送消息
// 1. 发送消息
amqpTemplate
.
convertAndSend
(
MqConstant
.
SUBMIT_EXAMINATION_QUEUE
,
answer
);
amqpTemplate
.
convertAndSend
(
MqConstant
.
SUBMIT_EXAMINATION_QUEUE
,
answer
);
// 2. 更新考试状态
// 2. 更新考试状态
...
@@ -276,7 +277,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
...
@@ -276,7 +277,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
examRecord
.
setCommonValue
(
currentUsername
,
applicationCode
,
tenantCode
);
examRecord
.
setCommonValue
(
currentUsername
,
applicationCode
,
tenantCode
);
examRecord
.
setStartTime
(
examRecord
.
getCreateDate
());
examRecord
.
setStartTime
(
examRecord
.
getCreateDate
());
// 默认未提交状态
// 默认未提交状态
examRecord
.
setSubmitStatus
(
ExamExaminationRecordConstant
.
STATUS_NOT_SUBMITTED
);
examRecord
.
setSubmitStatus
(
SubmitStatusEnum
.
NOT_SUBMITTED
.
getValue
()
);
// 保存考试记录
// 保存考试记录
if
(
examRecordService
.
insert
(
examRecord
)
>
0
)
{
if
(
examRecordService
.
insert
(
examRecord
)
>
0
)
{
startExamDto
.
setExamination
(
examination
);
startExamDto
.
setExamination
(
examination
);
...
@@ -482,6 +483,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
...
@@ -482,6 +483,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
answer
.
setExamRecordId
(
recordId
);
answer
.
setExamRecordId
(
recordId
);
Answer
userAnswer
=
this
.
getAnswer
(
answer
);
Answer
userAnswer
=
this
.
getAnswer
(
answer
);
BeanUtils
.
copyProperties
(
userAnswer
,
answerDto
);
BeanUtils
.
copyProperties
(
userAnswer
,
answerDto
);
answerDto
.
setDuration
(
ExamRecordUtil
.
getExamDuration
(
userAnswer
.
getStartTime
(),
userAnswer
.
getEndTime
()));
return
answerDto
;
return
answerDto
;
}
}
...
@@ -507,7 +509,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
...
@@ -507,7 +509,7 @@ public class AnswerService extends CrudService<AnswerMapper, Answer> {
// 总分
// 总分
Integer
score
=
answers
.
stream
().
mapToInt
(
Answer:
:
getScore
).
sum
();
Integer
score
=
answers
.
stream
().
mapToInt
(
Answer:
:
getScore
).
sum
();
examRecord
.
setScore
(
score
);
examRecord
.
setScore
(
score
);
examRecord
.
setSubmitStatus
(
ExamExaminationRecordConstant
.
STATUS_CALCULATED
);
examRecord
.
setSubmitStatus
(
SubmitStatusEnum
.
CALCULATED
.
getValue
()
);
examRecord
.
setCorrectNumber
((
int
)
correctNumber
);
examRecord
.
setCorrectNumber
((
int
)
correctNumber
);
examRecord
.
setInCorrectNumber
(
answers
.
size
()
-
examRecord
.
getCorrectNumber
());
examRecord
.
setInCorrectNumber
(
answers
.
size
()
-
examRecord
.
getCorrectNumber
());
examRecordService
.
update
(
examRecord
);
examRecordService
.
update
(
examRecord
);
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/service/ExaminationService.java
View file @
4b812ef1
...
@@ -115,6 +115,18 @@ public class ExaminationService extends CrudService<ExaminationMapper, Examinati
...
@@ -115,6 +115,18 @@ public class ExaminationService extends CrudService<ExaminationMapper, Examinati
}
}
/**
/**
* 查询参与考试人数
*
* @param examination examination
* @return int
* @author tangyi
* @date 2019/10/27 20:07:38
*/
public
int
findExamUserCount
(
Examination
examination
)
{
return
this
.
dao
.
findExamUserCount
(
examination
);
}
/**
* 根据考试ID获取题目分页数据
* 根据考试ID获取题目分页数据
*
*
* @param subjectDto subjectDto
* @param subjectDto subjectDto
...
...
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/service/ExaminationSubjectService.java
View file @
4b812ef1
...
@@ -97,4 +97,16 @@ public class ExaminationSubjectService extends CrudService<ExaminationSubjectMap
...
@@ -97,4 +97,16 @@ public class ExaminationSubjectService extends CrudService<ExaminationSubjectMap
public
ExaminationSubject
getPreviousByCurrentId
(
ExaminationSubject
examinationSubject
)
{
public
ExaminationSubject
getPreviousByCurrentId
(
ExaminationSubject
examinationSubject
)
{
return
this
.
dao
.
getPreviousByCurrentId
(
examinationSubject
);
return
this
.
dao
.
getPreviousByCurrentId
(
examinationSubject
);
}
}
/**
* 根据分类id查询
*
* @param examinationSubject examinationSubject
* @return List
* @author tangyi
* @date 2019/10/24 21:47:24
*/
public
List
<
ExaminationSubject
>
findListByCategoryId
(
ExaminationSubject
examinationSubject
)
{
return
this
.
dao
.
findListByCategoryId
(
examinationSubject
);
}
}
}
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/service/SubjectService.java
View file @
4b812ef1
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
...
@@ -23,6 +23,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
/**
* 题目service
* 题目service
...
@@ -264,7 +265,7 @@ public class SubjectService {
...
@@ -264,7 +265,7 @@ public class SubjectService {
/**
/**
* 物理批量删除
* 物理批量删除
*
*
* @param ids
ids
* @param ids ids
* @return int
* @return int
* @author tangyi
* @author tangyi
* @date 2019/06/16 22:52
* @date 2019/06/16 22:52
...
@@ -447,4 +448,37 @@ public class SubjectService {
...
@@ -447,4 +448,37 @@ public class SubjectService {
// 根据题目ID,类型获取题目的详细信息
// 根据题目ID,类型获取题目的详细信息
return
this
.
get
(
examinationSubject
.
getSubjectId
(),
examinationSubject
.
getType
());
return
this
.
get
(
examinationSubject
.
getSubjectId
(),
examinationSubject
.
getType
());
}
}
/**
* 导出
*
* @param ids ids
* @param examinationId examinationId
* @param categoryId categoryId
* @return List
*/
public
List
<
SubjectDto
>
export
(
Long
[]
ids
,
Long
examinationId
,
Long
categoryId
)
{
List
<
SubjectDto
>
subjects
=
new
ArrayList
<>();
ExaminationSubject
examinationSubject
=
new
ExaminationSubject
();
List
<
ExaminationSubject
>
examinationSubjects
=
new
ArrayList
<>();
// 根据题目id导出
if
(
ArrayUtils
.
isNotEmpty
(
ids
))
{
for
(
Long
id
:
ids
)
{
examinationSubject
.
setSubjectId
(
id
);
examinationSubjects
.
addAll
(
examinationSubjectService
.
findListBySubjectId
(
examinationSubject
));
}
}
else
if
(
examinationId
!=
null
)
{
// 根据考试ID
examinationSubjects
=
examinationSubjectService
.
findListByExaminationId
(
examinationId
);
}
else
if
(
categoryId
!=
null
)
{
// 根据分类ID、类型导出
examinationSubject
.
setCategoryId
(
categoryId
);
examinationSubjects
=
examinationSubjectService
.
findListByCategoryId
(
examinationSubject
);
}
if
(
CollectionUtils
.
isNotEmpty
(
examinationSubjects
))
{
for
(
ExaminationSubject
es
:
examinationSubjects
)
subjects
.
add
(
this
.
get
(
es
.
getSubjectId
(),
es
.
getType
()));
}
return
subjects
;
}
}
}
modules/exam-service-parent/exam-service/src/main/java/com/github/tangyi/exam/utils/ExamRecordUtil.java
View file @
4b812ef1
package
com
.
github
.
tangyi
.
exam
.
utils
;
package
com
.
github
.
tangyi
.
exam
.
utils
;
import
com.github.tangyi.common.core.utils.DateUtils
;
import
java.util.Date
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashMap
;
/**
/**
...
@@ -23,11 +26,30 @@ public class ExamRecordUtil {
...
@@ -23,11 +26,30 @@ public class ExamRecordUtil {
map
.
put
(
"examinationName"
,
"考试名称"
);
map
.
put
(
"examinationName"
,
"考试名称"
);
map
.
put
(
"userName"
,
"考生名称"
);
map
.
put
(
"userName"
,
"考生名称"
);
map
.
put
(
"deptName"
,
"部门名称"
);
map
.
put
(
"deptName"
,
"部门名称"
);
map
.
put
(
"submitStatusName"
,
"批改状态"
);
map
.
put
(
"startTime"
,
"开始时间"
);
map
.
put
(
"endTime"
,
"结束时间"
);
map
.
put
(
"duration"
,
"持续时间"
);
map
.
put
(
"score"
,
"成绩"
);
map
.
put
(
"correctNumber"
,
"正确题数"
);
map
.
put
(
"correctNumber"
,
"正确题数"
);
map
.
put
(
"inCorrectNumber"
,
"错误题数"
);
map
.
put
(
"inCorrectNumber"
,
"错误题数"
);
map
.
put
(
"submitStatus"
,
"批改状态"
);
map
.
put
(
"score"
,
"成绩"
);
map
.
put
(
"examTime"
,
"考试时间"
);
return
map
;
return
map
;
}
}
/**
* 计算持续时间
* @param startTime startTime
* @param endTime endTime
* @return String
*/
public
static
String
getExamDuration
(
Date
startTime
,
Date
endTime
)
{
// 持续时间
String
suffix
=
"分钟"
;
Integer
duration
=
DateUtils
.
getBetweenMinutes
(
startTime
,
endTime
);
if
(
duration
<=
0
)
{
duration
=
DateUtils
.
getBetweenSecond
(
startTime
,
endTime
);
suffix
=
"秒"
;
}
return
duration
+
suffix
;
}
}
}
modules/exam-service-parent/exam-service/src/main/resources/mapper/ExamRecodeMapper.xml
View file @
4b812ef1
...
@@ -78,7 +78,7 @@
...
@@ -78,7 +78,7 @@
<select
id=
"findListById"
resultMap=
"examRecordResultMap"
>
<select
id=
"findListById"
resultMap=
"examRecordResultMap"
>
SELECT
SELECT
<include
refid=
"examRecordColumns"
/>
<include
refid=
"examRecordColumns"
/>
FROM exam_record a
FROM exam_
examination_
record a
WHERE a.id IN
WHERE a.id IN
<foreach
collection=
"ids"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
<foreach
collection=
"ids"
index=
"index"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
#{item}
...
...
modules/exam-service-parent/exam-service/src/main/resources/mapper/ExaminationMapper.xml
View file @
4b812ef1
...
@@ -89,6 +89,10 @@
...
@@ -89,6 +89,10 @@
<include
refid=
"whereColumnList"
/>
<include
refid=
"whereColumnList"
/>
</select>
</select>
<select
id=
"findExamUserCount"
resultType=
"java.lang.Integer"
>
SELECT COUNT(*) FROM (SELECT * FROM exam_examination_record WHERE tenant_code = #{tenantCode} GROUP BY user_id) a
</select>
<insert
id=
"insert"
>
<insert
id=
"insert"
>
insert into exam_examination (
insert into exam_examination (
id,
id,
...
...
modules/exam-service-parent/exam-service/src/main/resources/mapper/ExaminationSubjectMapper.xml
View file @
4b812ef1
...
@@ -97,6 +97,12 @@
...
@@ -97,6 +97,12 @@
WHERE a.subject_id
<![CDATA[<]]>
#{subjectId} AND a.examination_id = #{examinationId} ORDER BY subject_id DESC LIMIT 1
WHERE a.subject_id
<![CDATA[<]]>
#{subjectId} AND a.examination_id = #{examinationId} ORDER BY subject_id DESC LIMIT 1
</select>
</select>
<select
id=
"findListByCategoryId"
resultMap=
"examinationSubjectResultMap"
>
SELECT
<include
refid=
"examinationSubjectColumns"
/>
FROM exam_examination_subject a WHERE a.category_id = #{categoryId}
</select>
<insert
id=
"insert"
>
<insert
id=
"insert"
>
insert into exam_examination_subject (
insert into exam_examination_subject (
id,
id,
...
...
modules/user-service-parent/user-service-api/src/main/java/com/github/tangyi/user/api/dto/DashboardDto.java
View file @
4b812ef1
...
@@ -24,4 +24,9 @@ public class DashboardDto implements Serializable {
...
@@ -24,4 +24,9 @@ public class DashboardDto implements Serializable {
* 考试数量
* 考试数量
*/
*/
private
String
examinationNumber
;
private
String
examinationNumber
;
/**
* 参与人数
*/
private
String
examUserNumber
;
}
}
modules/user-service-parent/user-service/src/main/java/com/github/tangyi/user/controller/DashboardController.java
View file @
4b812ef1
...
@@ -49,10 +49,15 @@ public class DashboardController extends BaseController {
...
@@ -49,10 +49,15 @@ public class DashboardController extends BaseController {
userVo
.
setTenantCode
(
tenantCode
);
userVo
.
setTenantCode
(
tenantCode
);
dashboardDto
.
setOnlineUserNumber
(
userService
.
userCount
(
userVo
).
toString
());
dashboardDto
.
setOnlineUserNumber
(
userService
.
userCount
(
userVo
).
toString
());
// 查询考试数量
// 查询考试数量
ResponseBean
<
Integer
>
examinationCountResponseBean
=
examinationService
.
findExaminationCount
(
tenantCode
);
ResponseBean
<
Integer
>
examinationCountResponseBean
=
examinationService
.
findExaminationCount
(
tenantCode
);
if
(!
ResponseUtil
.
isSuccess
(
examinationCountResponseBean
))
if
(!
ResponseUtil
.
isSuccess
(
examinationCountResponseBean
))
throw
new
ServiceException
(
"查询考试数量失败: "
+
examinationCountResponseBean
.
getMsg
());
throw
new
ServiceException
(
"查询考试数量失败: "
+
examinationCountResponseBean
.
getMsg
());
dashboardDto
.
setExaminationNumber
(
examinationCountResponseBean
.
getData
().
toString
());
dashboardDto
.
setExaminationNumber
(
examinationCountResponseBean
.
getData
().
toString
());
// 查询参与人数
ResponseBean
<
Integer
>
examUserCountResponseBean
=
examinationService
.
findExamUserCount
(
tenantCode
);
if
(!
ResponseUtil
.
isSuccess
(
examUserCountResponseBean
))
throw
new
ServiceException
(
"查询参与人数失败: "
+
examUserCountResponseBean
.
getMsg
());
dashboardDto
.
setExamUserNumber
(
examUserCountResponseBean
.
getData
().
toString
());
return
new
ResponseBean
<>(
dashboardDto
);
return
new
ResponseBean
<>(
dashboardDto
);
}
}
}
}
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