Commit ebb358f3 authored by 耿迪迪's avatar 耿迪迪

培训统计

parent d2f50f83
package com.zehong.web.controller.trainmanage;
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.TrainStat;
import com.zehong.system.domain.TrainStatDetail;
import com.zehong.system.service.ITTrainStatService;
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("/train/stat")
public class TTrainStatController extends BaseController {
@Autowired
private ITTrainStatService itTrainStatService;
/**
* 培训统计查询
* @param trainStat 查询条件
* @return AjaxResult
*/
@GetMapping("/trainStatData")
public TableDataInfo trainStatData(TrainStat trainStat) {
startPage();
List<TrainStat> list = itTrainStatService.trainStatData(trainStat);
return getDataTable(list);
}
/**
* 培训统计详情
* @param trainManageId 培训id
* @return AjaxResult
*/
@GetMapping("/trainStatDetail")
public TableDataInfo trainStatDetail(Long trainManageId) {
startPage();
List<TrainStatDetail> list = itTrainStatService.trainStatDetail(trainManageId);
return getDataTable(list);
}
/**
* 培训详情导出
* @param trainManageId 培训id
* @return AjaxResult
*/
@GetMapping("/export")
public AjaxResult export(Long trainManageId){
List<TrainStatDetail> list = itTrainStatService.trainStatDetail(trainManageId);
ExcelUtil<TrainStatDetail> util = new ExcelUtil<>(TrainStatDetail.class);
return util.exportExcel(list, "培训人员详情");
}
}
......@@ -62,7 +62,6 @@ public class TTrainManage extends BaseEntity
private Date publishTime;
/** 删除标志(0正常,1删除) */
@Excel(name = "删除标志", readConverterExp = "0=正常,1删除")
private String isDel;
/**培训人员*/
......
package com.zehong.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* @author geng
* 培训统计
*/
public class TrainStat {
private Long trainManageId;
/**培训课程*/
private String lessonName;
/**培训开始时间*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date trainStartTime;
/**培训开始结束*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date trainEndTime;
/**应考人数*/
private int mustTestNum;
/**考试完成人数*/
private int finishTestNum;
private Date publishBeginTime;
private Date publishEndTime;
public Long getTrainManageId() {
return trainManageId;
}
public void setTrainManageId(Long trainManageId) {
this.trainManageId = trainManageId;
}
public String getLessonName() {
return lessonName;
}
public void setLessonName(String lessonName) {
this.lessonName = lessonName;
}
public Date getTrainStartTime() {
return trainStartTime;
}
public void setTrainStartTime(Date trainStartTime) {
this.trainStartTime = trainStartTime;
}
public Date getTrainEndTime() {
return trainEndTime;
}
public void setTrainEndTime(Date trainEndTime) {
this.trainEndTime = trainEndTime;
}
public int getMustTestNum() {
return mustTestNum;
}
public void setMustTestNum(int mustTestNum) {
this.mustTestNum = mustTestNum;
}
public int getFinishTestNum() {
return finishTestNum;
}
public void setFinishTestNum(int finishTestNum) {
this.finishTestNum = finishTestNum;
}
public Date getPublishBeginTime() {
return publishBeginTime;
}
public void setPublishBeginTime(Date publishBeginTime) {
this.publishBeginTime = publishBeginTime;
}
public Date getPublishEndTime() {
return publishEndTime;
}
public void setPublishEndTime(Date publishEndTime) {
this.publishEndTime = publishEndTime;
}
@Override
public String toString() {
return "TrainStat{" +
"trainManageId='" + trainManageId + '\'' +
"lessonName='" + lessonName + '\'' +
", trainStartTime=" + trainStartTime +
", trainEndTime=" + trainEndTime +
", mustTestNum=" + mustTestNum +
", finishTestNum=" + finishTestNum +
'}';
}
}
package com.zehong.system.domain;
import com.zehong.common.annotation.Excel;
/**
* @author geng
* 培训统计详情
*/
public class TrainStatDetail {
/**员工名称*/
@Excel(name = "培训员工")
private String employedPeopleName;
/**所属企业名称*/
@Excel(name = "所属企业")
private String enterpriseName;
/**培训时长*/
@Excel(name = "培训时长")
private String realityTrainDuration;
/**是否完成培训*/
@Excel(name = "是否完成培训")
private String isComplete;
public String getEmployedPeopleName() {
return employedPeopleName;
}
public void setEmployedPeopleName(String employedPeopleName) {
this.employedPeopleName = employedPeopleName;
}
public String getEnterpriseName() {
return enterpriseName;
}
public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName;
}
public String getRealityTrainDuration() {
return realityTrainDuration;
}
public void setRealityTrainDuration(String realityTrainDuration) {
this.realityTrainDuration = realityTrainDuration;
}
public String getIsComplete() {
return isComplete;
}
public void setIsComplete(String isComplete) {
this.isComplete = isComplete;
}
@Override
public String toString() {
return "TrainStatDetail{" +
"employedPeopleName='" + employedPeopleName + '\'' +
", enterpriseName='" + enterpriseName + '\'' +
", realityTrainDuration='" + realityTrainDuration + '\'' +
", isComplete='" + isComplete + '\'' +
'}';
}
}
package com.zehong.system.mapper;
import com.zehong.system.domain.TrainStat;
import com.zehong.system.domain.TrainStatDetail;
import java.util.List;
/**
* @author geng
* 培训统计
*/
public interface TTrainStatMapper {
/**
* 培训统计查询
* @param trainStat 查询条件
* @return
*/
List<TrainStat> trainStatData(TrainStat trainStat);
/**
* 培训统计详情
* @param trainManageId 培训id
* @return
*/
List<TrainStatDetail> trainStatDetail(Long trainManageId);
}
package com.zehong.system.service;
import com.zehong.system.domain.TrainStat;
import com.zehong.system.domain.TrainStatDetail;
import java.util.List;
/**
* @author geng
* 培训统计
*/
public interface ITTrainStatService {
/**
* 培训统计查询
* @param trainStat 查询条件
* @return
*/
List<TrainStat> trainStatData(TrainStat trainStat);
/**
* 培训统计详情
* @param trainManageId 培训id
* @return
*/
List<TrainStatDetail> trainStatDetail(Long trainManageId);
}
package com.zehong.system.service.impl;
import com.zehong.system.domain.TrainStat;
import com.zehong.system.domain.TrainStatDetail;
import com.zehong.system.mapper.TTrainStatMapper;
import com.zehong.system.service.ITTrainStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ITTrainStatServiceImpl implements ITTrainStatService{
@Autowired
private TTrainStatMapper tTrainStatMapper;
/**
* 培训统计查询
* @param trainStat 查询条件
* @return
*/
@Override
public List<TrainStat> trainStatData(TrainStat trainStat) {
return tTrainStatMapper.trainStatData(trainStat);
}
/**
* 培训统计详情
* @param trainManageId 培训id
* @return
*/
@Override
public List<TrainStatDetail> trainStatDetail(Long trainManageId) {
return tTrainStatMapper.trainStatDetail(trainManageId);
}
}
<?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.TTrainStatMapper">
<resultMap id="trainStatResult" type="TrainStat">
<result property="trainManageId" column="train_manage_id"/>
<result property="lessonName" column="lesson_name" />
<result property="trainStartTime" column="train_start_time" />
<result property="trainEndTime" column="train_end_time" />
<result property="mustTestNum" column="mustTestNum" />
<result property="finishTestNum" column="finishTestNum" />
</resultMap>
<resultMap id="trainStatDetailResult" type="TrainStatDetail">
<result property="employedPeopleName" column="employed_people_name"/>
<result property="enterpriseName" column="enterprise_name"/>
<result property="realityTrainDuration" column="reality_train_duration"/>
<result property="isComplete" column="isComplete"/>
</resultMap>
<select id="trainStatData" parameterType="TrainStat" resultMap="trainStatResult">
SELECT
manage.train_manage_id,
manage.lesson_name,
manage.train_start_time,
manage.train_end_time,
(SELECT count(*) FROM t_train_person WHERE train_manage_id = manage.train_manage_id) AS mustTestNum,
(SELECT count(*) FROM t_train_person WHERE train_manage_id = manage.train_manage_id AND is_finish = '1') AS finishTestNum
FROM
t_train_manage manage
<where>
manage.is_del = '0'
AND manage.train_status = '1'
<if test="lessonName !='' and lessonName!= null">and manage.lesson_name like concat('%', #{lessonName}, '%')</if>
<if test="publishBeginTime != null and publishEndTime">and manage.publish_time BETWEEN #{publishBeginTime} AND #{publishEndTime} </if>
</where>
ORDER BY manage.publish_time DESC
</select>
<select id="trainStatDetail" parameterType="Long" resultMap="trainStatDetailResult">
SELECT
people.employed_people_name,
enterprise.enterprise_name,
SEC_TO_TIME(person.reality_train_duration) AS reality_train_duration,
(
CASE person.is_finish
WHEN '0' THEN
'未完成'
WHEN '1' THEN
'完成'
END
) AS isComplete
FROM
t_train_person person
LEFT JOIN t_employed_people_info people ON people.employed_people_id = person.train_person_id
LEFT JOIN t_enterprise_info enterprise ON enterprise.enterprise_id = people.beyond_enterprise_id
<where>
person.train_manage_id = #{trainManageId}
</where>
</select>
</mapper>
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