Commit 0ad8b707 authored by 耿迪迪's avatar 耿迪迪

培训统计

parent 779b76de
package com.zehong.web.controller.contractTrain;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TContractorTrainCourseTopic;
import com.zehong.system.domain.TrainCourseStat;
import com.zehong.system.domain.TrainCourseStatDetail;
import com.zehong.system.service.TTrainCourseStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author geng
* 培训统计
*/
@RestController
@RequestMapping("/trainStat")
public class TTrainCourseStatController extends BaseController {
@Autowired
private TTrainCourseStatService tTrainCourseStatService;
/**
* 获取培训统计查询
* @param trainCourseStat 统计查询参数
* @return
*/
@GetMapping("/getTrainCourseStatData")
public TableDataInfo getTrainCourseStatData(TrainCourseStat trainCourseStat){
startPage();
List<TrainCourseStat> list = tTrainCourseStatService.getTrainCourseStatData(trainCourseStat);
return getDataTable(list);
}
/**
* 获取培训统计详情
* @param courseId 培训id
* @return
*/
@GetMapping("/getTrainCourseStatDetailData")
public TableDataInfo getTrainCourseStatDetailData(Long courseId){
startPage();
List<TrainCourseStatDetail> list = tTrainCourseStatService.getTrainCourseStatDetailData(courseId);
return getDataTable(list);
}
@GetMapping("/trainCourseStatDetailExport")
public AjaxResult trainCourseStatDetailExport(Long courseId) {
List<TrainCourseStatDetail> list = tTrainCourseStatService.getTrainCourseStatDetailData(courseId);
ExcelUtil<TrainCourseStatDetail> util = new ExcelUtil<>(TrainCourseStatDetail.class);
return util.exportExcel(list, "培训统计详情");
}
}
package com.zehong.system.domain;
import java.util.Date;
public class TrainCourseStat {
private Long courseId;
private String courseName;
private Date releaseTime;
private String planName;
private String maybeTestNum;
private String finishNum;
private Date releaseBeginTime;
private Date releaseEndTime;
public Long getCourseId() {
return courseId;
}
public void setCourseId(Long courseId) {
this.courseId = courseId;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public Date getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(Date releaseTime) {
this.releaseTime = releaseTime;
}
public String getPlanName() {
return planName;
}
public void setPlanName(String planName) {
this.planName = planName;
}
public String getMaybeTestNum() {
return maybeTestNum;
}
public void setMaybeTestNum(String maybeTestNum) {
this.maybeTestNum = maybeTestNum;
}
public String getFinishNum() {
return finishNum;
}
public void setFinishNum(String finishNum) {
this.finishNum = finishNum;
}
public Date getReleaseBeginTime() {
return releaseBeginTime;
}
public void setReleaseBeginTime(Date releaseBeginTime) {
this.releaseBeginTime = releaseBeginTime;
}
public Date getReleaseEndTime() {
return releaseEndTime;
}
public void setReleaseEndTime(Date releaseEndTime) {
this.releaseEndTime = releaseEndTime;
}
}
package com.zehong.system.domain;
import com.zehong.common.annotation.Excel;
public class TrainCourseStatDetail {
private Long userCourseId;
@Excel(name = "培训人员")
private String nickName;
@Excel(name = "所属部门")
private String deptName;
@Excel(name = "培训时长")
private Integer finishDuration;
private Integer trainState;
@Excel(name = "是否完成")
private String isComplete;
public Long getUserCourseId() {
return userCourseId;
}
public void setUserCourseId(Long userCourseId) {
this.userCourseId = userCourseId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public Integer getFinishDuration() {
return finishDuration;
}
public void setFinishDuration(Integer finishDuration) {
this.finishDuration = finishDuration;
}
public Integer getTrainState() {
return trainState;
}
public void setTrainState(Integer trainState) {
this.trainState = trainState;
}
public String getIsComplete() {
return isComplete;
}
public void setIsComplete(String isComplete) {
this.isComplete = isComplete;
}
}
package com.zehong.system.mapper;
import com.zehong.system.domain.TrainCourseStat;
import com.zehong.system.domain.TrainCourseStatDetail;
import java.util.List;
/**
* @author geng
* 培训课程统计
*/
public interface TTrainCourseStatMapper {
/**
* 获取培训统计查询
* @param trainCourseStat 统计查询参数
* @return
*/
List<TrainCourseStat> getTrainCourseStatData(TrainCourseStat trainCourseStat);
/**
* 获取培训统计详情
* @param courseId 培训id
* @return
*/
List<TrainCourseStatDetail> getTrainCourseStatDetailData(Long courseId);
}
package com.zehong.system.service;
import com.zehong.system.domain.TrainCourseStat;
import com.zehong.system.domain.TrainCourseStatDetail;
import java.util.List;
/**
* @author geng
* 培训统计
*/
public interface TTrainCourseStatService {
/**
* 获取培训统计查询
* @param trainCourseStat 统计查询参数
* @return
*/
List<TrainCourseStat> getTrainCourseStatData(TrainCourseStat trainCourseStat);
/**
* 获取培训统计详情
* @param courseId 培训id
* @return
*/
List<TrainCourseStatDetail> getTrainCourseStatDetailData(Long courseId);
}
package com.zehong.system.service.impl;
import com.zehong.system.domain.TrainCourseStat;
import com.zehong.system.domain.TrainCourseStatDetail;
import com.zehong.system.mapper.TTrainCourseStatMapper;
import com.zehong.system.service.TTrainCourseStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author geng
* 培训统计
*/
@Service
public class TTrainCourseStatServiceImpl implements TTrainCourseStatService {
@Autowired
private TTrainCourseStatMapper tTrainCourseStatMapper;
/**
* 获取培训统计查询
* @param trainCourseStat 统计查询参数
* @return
*/
@Override
public List<TrainCourseStat> getTrainCourseStatData(TrainCourseStat trainCourseStat){
return tTrainCourseStatMapper.getTrainCourseStatData(trainCourseStat);
}
/**
* 获取培训统计详情
* @param courseId 培训id
* @return
*/
@Override
public List<TrainCourseStatDetail> getTrainCourseStatDetailData(Long courseId){
return tTrainCourseStatMapper.getTrainCourseStatDetailData(courseId);
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zehong.system.mapper.TTrainCourseStatMapper">
<resultMap id="TrainCourseStatResult" type="TrainCourseStat">
<result property="courseId" column="course_id" />
<result property="courseName" column="course_name" />
<result property="releaseTime" column="release_time" />
<result property="planName" column="plan_name" />
<result property="maybeTestNum" column="maybeTestNum" />
<result property="finishNum" column="finishNum" />
</resultMap>
<resultMap id="TrainCourseStatDetailResult" type="TrainCourseStatDetail">
<result property="userCourseId" column="user_course_id"></result>
<result property="nickName" column="nick_name" />
<result property="deptName" column="dept_name" />
<result property="finishDuration" column="finish_duration" />
<result property="trainState" column="train_state" />
<result property="isComplete" column="isComplete" />
</resultMap>
<select id="getTrainCourseStatData" parameterType="com.zehong.system.domain.TrainCourseStat" resultMap="TrainCourseStatResult">
SELECT
train.course_id,
train.course_name,
train.release_time,
plan.plan_name,
(SELECT count(1) FROM t_train_plan_post post WHERE plan_id = plan.plan_id)AS maybeTestNum,
(SELECT count(1) FROM t_train_user_course courseUse WHERE courseUse.course_id = train.course_id AND courseUse.train_state = '1')AS finishNum
FROM
t_train_course train
LEFT JOIN t_train_plan plan ON plan.plan_id = train.course_type
<where>
train.is_del = '0'
AND train.status = '1'
<if test="courseId != null "> and train.course_id = #{courseId}</if>
<if test="courseName !='' and courseName!= null">and train.course_name like concat('%', #{courseName}, '%')</if>
<if test="releaseBeginTime != null and releaseEndTime">and train.release_time BETWEEN #{releaseBeginTime} AND #{releaseEndTime} </if>
</where>
ORDER BY train.release_time DESC
</select>
<select id="getTrainCourseStatDetailData" parameterType="Long" resultMap="TrainCourseStatDetailResult">
SELECT
courseUse.user_course_id,
us.nick_name,
dept.dept_name,
courseUse.finish_duration,
courseUse.train_state,
(
CASE courseUse.train_state
WHEN '0' THEN
'未完成'
WHEN '1' THEN
'完成'
END
) AS isComplete
FROM
t_train_user_course courseUse
LEFT JOIN sys_user us ON us.user_id = courseUse.user_id
LEFT JOIN sys_dept dept ON dept.dept_id = us.dept_id
WHERE courseUse.course_id = #{courseId}
</select>
</mapper>
import request from '@/utils/request'
// 获取培训统计查询
export function getTrainCourseStatData(query) {
return request({
url: '/trainStat/getTrainCourseStatData',
method: 'get',
params: query
})
}
// 获取培训统计详情
export function getTrainCourseStatDetailData(query) {
return request({
url: '/trainStat/getTrainCourseStatDetailData',
method: 'get',
params: query
})
}
// 培训统计详情导出
export function trainCourseStatDetailExport(query) {
return request({
url: '/trainStat/trainCourseStatDetailExport',
method: 'get',
params: query
})
}
<template>
<div style="margin: 10px">
<el-form
:model="queryParams"
ref="queryForm"
:inline="true"
label-width="68px">
<el-form-item label="培训名称" prop="courseName">
<el-input
v-model="queryParams.courseName"
placeholder="请输入培训名称"
clearable
size="small"
/>
</el-form-item>
<el-form-item label="发布时间" prop="releaseTime">
<el-date-picker
v-model="releaseTime"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
@change="dateFormat">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button
type="primary"
icon="el-icon-search"
size="mini"
@click="search"
>搜索</el-button
>
<el-button icon="el-icon-refresh" size="mini" @click="resetClick"
>重置</el-button
>
</el-form-item>
</el-form>
<!-- 培训统计列表 -->
<el-table v-loading="loading" :data="trainCourseStatData">
<el-table-column label="序号" width='100' align="center" prop="courseNum"/>
<el-table-column label="课程标题" align="center" prop="courseName"/>
<el-table-column label="培训计划" align="center" prop="planName"/>
<el-table-column label="应参加人数" align="center" prop="maybeTestNum"/>
<el-table-column label="实际完成人数" align="center" prop="finishNum"/>
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template v-slot="{ row: { courseId, courseName }}">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="trainCourseStatDetail(courseId,courseName)"
>查看详情</el-button>
</template>
</el-table-column>
</el-table>
<!-- 列表分页 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getTrainStatList"
/>
<!-- 详情 -->
<el-dialog :title="'培训详情:'+courseName" :visible.sync="trainStatDetailOpen" append-to-body :close-on-click-modal="false">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
:loading="exportLoading"
@click="handleExport"
style="position: relative;left: 16px;top: -17px;"
>导出</el-button>
<el-table v-loading="loading" :data="trainStatDetailData">
<el-table-column label="序号" width='100' align="center" prop="detailNum"/>
<el-table-column label="培训人员" align="center" prop="nickName"/>
<el-table-column label="所属部门" align="center" prop="deptName"/>
<el-table-column label="培训时长" align="center" prop="finishDuration"/>
<el-table-column label="是否完成" align="center" prop="isComplete"/>
</el-table>
<pagination
v-show="totalDetail > 0"
:total="totalDetail"
:page.sync="queryDetailParams.pageNum"
:limit.sync="queryDetailParams.pageSize"
@pagination="getTrainStatDetail"
/>
</el-dialog>
</div>
</template>
<script>
import {getTrainCourseStatData,getTrainCourseStatDetailData,trainCourseStatDetailExport} from "@/api/contractTrain/trainCourseStat";
export default {
name: "trainCourseStat",
components: {
},
data() {
return {
queryParams: {
pageNum: 1,
pageSize: 10,
courseName:"",
releaseBeginTime: "",
releaseEndTime: ""
},
releaseTime: "",
trainCourseStatData: [],
// 遮罩层
loading: false,
// 总条数
total: 0,
totalDetail: 0,
queryDetailParams:{
pageNum: 1,
pageSize: 10,
courseId: ""
},
courseName: "",
trainStatDetailOpen: false,
trainStatDetailData: [],
exportLoading: false
}
},
created() {
this.getTrainStatList();
},
methods: {
dateFormat(picker){
this.queryParams.releaseBeginTime = picker[0];
this.queryParams.releaseEndTime = picker[1];
},
search(){
this.getTrainStatList();
},
resetClick(){
this.releaseTime = "";
this.queryParams.releaseBeginTime = null;
this.queryParams.releaseEndTime = null;
this.queryParams={
pageNum: 1,
pageSize: 10,
courseName:"",
releaseBeginTime: "",
releaseEndTime: ""
};
this.getTrainStatList();
},
getTrainStatList(){
getTrainCourseStatData(this.queryParams).then(res =>{
this.trainCourseStatData = res.rows.map((item, index) => {
return {
courseNum:
index +
1 +
(this.queryParams.pageNum - 1) * this.queryParams.pageSize,
...item,
};
});
this.total = res.total;
})
},
trainCourseStatDetail(courseId,courseName){
this.queryDetailParams.courseId = courseId;
this.courseName = courseName;
this.queryDetailParams.pageNum = 1;
this.queryDetailParams.pageSize = 10;
this.getTrainStatDetail();
this.trainStatDetailOpen = true;
},
getTrainStatDetail(){
getTrainCourseStatDetailData(this.queryDetailParams).then(res =>{
this.trainStatDetailData = res.rows.map((item, index) => {
return {
detailNum:
index +
1 +
(this.queryDetailParams.pageNum - 1) * this.queryDetailParams.pageSize,
...item,
};
});
this.totalDetail = res.total;
})
},
handleExport(){
this.$confirm('是否确认导出所有培训详细数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.exportLoading = true;
return trainCourseStatDetailExport({"courseId":this.queryDetailParams.courseId});
}).then(response => {
this.download(response.msg);
this.exportLoading = false;
}).catch(() => {});
},
},
};
</script>
<style lang="scss" scoped>
</style>
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