Commit 3a67c4ec authored by 耿迪迪's avatar 耿迪迪

考试统计 gengdidi

parent 90c14366
package com.zehong.web.controller.train; package com.zehong.web.controller.train;
import java.util.List; import com.zehong.common.annotation.Log;
import java.util.Map; import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.alibaba.fastjson.JSON;
import com.zehong.common.core.domain.entity.SysUser; import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.domain.model.LoginUser; import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.ServletUtils; import com.zehong.common.utils.ServletUtils;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.framework.web.service.TokenService; import com.zehong.framework.web.service.TokenService;
import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainUserCourse;
import com.zehong.system.domain.vo.UserCourseVo; import com.zehong.system.domain.vo.UserCourseVo;
import com.zehong.system.service.ITTrainCourseService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController; import java.util.List;
import com.zehong.common.core.domain.AjaxResult; import java.util.Map;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.service.ITTrainCourseService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/** /**
* 培训课程Controller * 培训课程Controller
...@@ -147,4 +147,28 @@ public class TTrainCourseController extends BaseController ...@@ -147,4 +147,28 @@ public class TTrainCourseController extends BaseController
public AjaxResult testPublish(@RequestBody TTrainCourse tTrainCourse){ public AjaxResult testPublish(@RequestBody TTrainCourse tTrainCourse){
return toAjax(tTrainCourseService.testPublish(tTrainCourse)); return toAjax(tTrainCourseService.testPublish(tTrainCourse));
} }
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return TableDataInfo
*/
@PostMapping(value = "statisticsTrainCourse")
public TableDataInfo statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse){
startPage();
List<StatisticsTrainCourse> statisticsTrainCourses = tTrainCourseService.statisticsTrainCourse(statisticsTrainCourse);
return getDataTable(statisticsTrainCourses);
}
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
@PostMapping(value = "statisticsTrainCourse")
public TableDataInfo testPersonDetailByCourseId(Long courseId){
startPage();
List<TTrainUserCourse> persons = tTrainCourseService.testPersonDetailByCourseId(courseId);
return getDataTable(persons);
}
} }
package com.zehong.system.domain;
public class StatisticsTrainCourse {
/**
* 课程id
*/
private Long courseId;
/**
* 课程名称
*/
private String courseName;
/**
* 发布时间
*/
private String releaseTime;
/**
* 考试类型
*/
private String dataKind;
/**
* 应考人数
*/
private String count;
/**
* 参考人数
*/
private String test;
/**
* 通过人数
*/
private String pass;
/**
* 通过率
*/
private String rate;
/**
* 发布开始时间
*/
private String releaseTimeBegin;
/**
* 发布结束时间
*/
private String releaseTimeEnd;
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 String getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(String releaseTime) {
this.releaseTime = releaseTime;
}
public String getDataKind() {
return dataKind;
}
public void setDataKind(String dataKind) {
this.dataKind = dataKind;
}
public String getCount() {
return count;
}
public void setCount(String count) {
this.count = count;
}
public String getTest() {
return test;
}
public void setTest(String test) {
this.test = test;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String getRate() {
return rate;
}
public void setRate(String rate) {
this.rate = rate;
}
public String getReleaseTimeBegin() {
return releaseTimeBegin;
}
public void setReleaseTimeBegin(String releaseTimeBegin) {
this.releaseTimeBegin = releaseTimeBegin;
}
public String getReleaseTimeEnd() {
return releaseTimeEnd;
}
public void setReleaseTimeEnd(String releaseTimeEnd) {
this.releaseTimeEnd = releaseTimeEnd;
}
}
...@@ -45,6 +45,12 @@ public class TTrainUserCourse extends BaseEntity ...@@ -45,6 +45,12 @@ public class TTrainUserCourse extends BaseEntity
@Excel(name = "创建人") @Excel(name = "创建人")
private String createUser; private String createUser;
/**人员名称**/
private String staffName;
/**人员部门**/
private String deptName;
public void setUserCourseId(Long userCourseId) public void setUserCourseId(Long userCourseId)
{ {
this.userCourseId = userCourseId; this.userCourseId = userCourseId;
...@@ -109,6 +115,22 @@ public class TTrainUserCourse extends BaseEntity ...@@ -109,6 +115,22 @@ public class TTrainUserCourse extends BaseEntity
return createUser; return createUser;
} }
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......
package com.zehong.system.mapper; package com.zehong.system.mapper;
import java.util.List; import java.util.List;
import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TTrainCourse; import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.vo.UserCourseVo; import com.zehong.system.domain.vo.UserCourseVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -75,4 +77,11 @@ public interface TTrainCourseMapper ...@@ -75,4 +77,11 @@ public interface TTrainCourseMapper
* @return * @return
*/ */
public List<UserCourseVo> userCourseList(@Param("userId")Long userId,@Param("type") Integer type); public List<UserCourseVo> userCourseList(@Param("userId")Long userId,@Param("type") Integer type);
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return List<StatisticsTrainCourse>
*/
List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse);
} }
...@@ -58,4 +58,11 @@ public interface TTrainUserCourseMapper ...@@ -58,4 +58,11 @@ public interface TTrainUserCourseMapper
* @return 结果 * @return 结果
*/ */
public int deleteTTrainUserCourseByIds(Long[] userCourseIds); public int deleteTTrainUserCourseByIds(Long[] userCourseIds);
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
List<TTrainUserCourse> testPersonDetailByCourseId(Long courseId);
} }
...@@ -3,7 +3,9 @@ package com.zehong.system.service; ...@@ -3,7 +3,9 @@ package com.zehong.system.service;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TTrainCourse; import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainUserCourse;
import com.zehong.system.domain.vo.UserCourseVo; import com.zehong.system.domain.vo.UserCourseVo;
/** /**
...@@ -86,5 +88,19 @@ public interface ITTrainCourseService ...@@ -86,5 +88,19 @@ public interface ITTrainCourseService
* @return int * @return int
*/ */
int testPublish( TTrainCourse tTrainCourse); int testPublish( TTrainCourse tTrainCourse);
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return List<StatisticsTrainCourse>
*/
List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse);
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
List<TTrainUserCourse> testPersonDetailByCourseId(Long courseId);
} }
package com.zehong.system.service.impl; package com.zehong.system.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TTrainCourse; import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainCourseTopic; import com.zehong.system.domain.TTrainCourseTopic;
import com.zehong.system.domain.TTrainUserCourse; import com.zehong.system.domain.TTrainUserCourse;
...@@ -15,6 +18,7 @@ import org.springframework.stereotype.Service; ...@@ -15,6 +18,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* 培训课程Service业务层处理 * 培训课程Service业务层处理
...@@ -184,9 +188,31 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService ...@@ -184,9 +188,31 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
return 0; return 0;
} }
//新增考试人员 //新增考试人员
tTrainCourseMapper.insertUserCourse(tTrainCourse.getCourseId(),Arrays.asList(course.getTestPersons())); List<JSONObject> personList = JSONObject.parseArray(course.getTestPersons(),JSONObject.class);
List<String> persons = personList.stream().map(item ->(String)item.get("staffId")).collect(Collectors.toList());
tTrainCourseMapper.insertUserCourse(tTrainCourse.getCourseId(),persons);
tTrainCourse.setStatus(1); tTrainCourse.setStatus(1);
tTrainCourse.setReleaseTime(new Date()); tTrainCourse.setReleaseTime(new Date());
return tTrainCourseMapper.updateTTrainCourse(tTrainCourse); return tTrainCourseMapper.updateTTrainCourse(tTrainCourse);
} }
/**
* 考试统计接口
* @param statisticsTrainCourse 统计实体
* @return List<StatisticsTrainCourse>
*/
@Override
public List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse){
return tTrainCourseMapper.statisticsTrainCourse(statisticsTrainCourse);
}
/**
* 根据考试查询人员考试详情
* @param courseId 考试id
* @return List<TTrainUserCourse>
*/
@Override
public List<TTrainUserCourse> testPersonDetailByCourseId(Long courseId){
return tTrainUserCourseMapper.testPersonDetailByCourseId(courseId);
}
} }
...@@ -25,6 +25,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -25,6 +25,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="testPersons" column="test_persons" /> <result property="testPersons" column="test_persons" />
</resultMap> </resultMap>
<resultMap id="StatisticsTrainCourseResult" type="StatisticsTrainCourse">
<result property="courseId" column="course_id" />
<result property="courseName" column="course_name" />
<result property="releaseTime" column="release_time" />
<result property="count" column="count" />
<result property="test" column="test" />
<result property="pass" column="pass" />
<result property="rate" column="rate" />
</resultMap>
<sql id="selectTTrainCourseVo"> <sql id="selectTTrainCourseVo">
select course_id, course_name, course_type, course_conent, status, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons from t_train_course select course_id, course_name, course_type, course_conent, status, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons from t_train_course
</sql> </sql>
...@@ -155,4 +165,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -155,4 +165,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by uc.examination_time desc order by uc.examination_time desc
</if> </if>
</select> </select>
<select id="statisticsTrainCourse" parameterType="StatisticsTrainCourse" resultMap="StatisticsTrainCourseResult">
SELECT
course.course_id,
course.course_name,
course.release_time,
course.data_kind,
COUNT(user.user_course_id)AS count,
SUM(case when user.state > 0 then 1 else 0 end)AS test,
SUM(case when user.state = 2 then 1 else 0 end)AS pass,
ROUND(SUM(case when user.state = 2 then 1 else 0 end)/COUNT(user.user_course_id)*100)AS rate
FROM
t_train_course course
INNER JOIN t_train_user_course user ON course.course_id = user.course_id
where course.status = '1' AND course.is_del = '0' AND user.is_del = '0'
<where>
<if test="courseName != null and courseName != ''"> and c.course_name like concat('%', #{courseName}, '%')</if>
<if test="dataKind != null and dataKind != ''"> and data_kind = #{dataKind}</if>
<if test="releaseTimeBegin != null and releaseTimeBegin != '' and releaseTimeEnd != null and releaseTimeEnd != ''"> and release_time BETWEEN #{releaseTimeBegin} AND #{releaseTimeEnd}</if>
</where>
GROUP BY course.course_id
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -13,6 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="examinationResult" column="examination_result" /> <result property="examinationResult" column="examination_result" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
<result property="createUser" column="create_user" /> <result property="createUser" column="create_user" />
<result property="staffName" column="staff_name"/>
<result property="deptName" column="dept_name"/>
</resultMap> </resultMap>
<sql id="selectTTrainUserCourseVo"> <sql id="selectTTrainUserCourseVo">
...@@ -82,4 +84,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -82,4 +84,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{userCourseId} #{userCourseId}
</foreach> </foreach>
</delete> </delete>
<select id="testPersonDetailByCourseId" parameterType="Long" resultMap="TTrainUserCourseResult">
SELECT
sys.staff_name,
d.dept_name,
train.examination_result,
train.state
FROM
t_train_user_course train
LEFT JOIN sys_user sys ON train.user_id = sys.user_id
left join sys_dept d on sys.dept_id = d.dept_id
WHERE train.course_id = #{courseId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -141,3 +141,21 @@ export function setAnswer(query) { ...@@ -141,3 +141,21 @@ export function setAnswer(query) {
}) })
} }
//统计
export function statisticsTrainCourse(data) {
return request({
url: '/system/course/statisticsTrainCourse',
method: 'post',
data: data
})
}
//成绩详情
export function statisticsTrainCourse(data) {
return request({
url: '/system/course/statisticsTrainCourse',
method: 'post',
data: data
})
}
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