he2802 2 년 전
부모
커밋
502d302441

+ 14 - 0
zhongzheng-admin-data/src/main/java/com/zhongzheng/controller/common/UserStudyLogController.java

@@ -13,6 +13,7 @@ import com.zhongzheng.modules.cd.vo.CdUserExamScoreVo;
 import com.zhongzheng.modules.cd.vo.CdUserStudyCountVo;
 import com.zhongzheng.modules.cd.vo.CdUserStudyLogVo;
 import com.zhongzheng.modules.course.bo.CourseAddBo;
+import com.zhongzheng.modules.grade.service.IClassGradeUserService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +50,8 @@ public class UserStudyLogController extends BaseController {
 
     private final ICdUserExamLogService iCdUserExamLogService;
 
+    private final IClassGradeUserService iClassGradeUserService;
+
     /**
      * 新增课程
      */
@@ -157,4 +160,15 @@ public class UserStudyLogController extends BaseController {
         CdUserExamScoreVo vo = iCdUserStudyLogService.getStudyExamScoreNum(bo);
         return AjaxResult.success(vo);
     }
+
+    @ApiOperation("网课导出")
+    @PreAuthorize("@ss.hasPermi('system:log:list')")
+    @GetMapping("/exportLine")
+    public AjaxResult exportLine(CdUserStudyLogQueryBo bo) {
+        /*if (!ToolsUtils.checkSignFromOldSys(bo.getStamp(), bo.getSign())) {
+            throw new CustomException("签名错误");
+        }*/
+        iClassGradeUserService.exportListVideoUserPeriod(451L,"D:\\test\\网课");
+        return AjaxResult.success();
+    }
 }

+ 62 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/poi/ExcelUtil.java

@@ -30,6 +30,8 @@ import java.io.*;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
 import java.text.DecimalFormat;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -646,6 +648,66 @@ public class ExcelUtil<T>
         }
     }
 
+    public void exportEasyExcelUtil(List<T> list,Class<T> clazz,String path)
+    {
+        OutputStream out = null;
+        //     Workbook workbook = null;
+        ExportParams deptExportParams = new ExportParams();
+        // 设置sheet得名称
+        deptExportParams.setSheetName("表1");
+        String timeStr= LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        Map<String, Object> deptExportMap = new HashMap<>();
+        deptExportMap.put("title", deptExportParams);
+        deptExportMap.put("entity", clazz);
+        // sheet中要填充得数据
+        deptExportMap.put("data", list);
+        List<Map<String, Object>> sheetsList = new ArrayList<>();
+        sheetsList.add(deptExportMap);
+        try
+        {
+            Workbook workbook = ExcelExportUtil.exportExcel(sheetsList, ExcelType.HSSF);
+            File desc = new File(path);
+            if (!desc.getParentFile().exists())
+            {
+                desc.getParentFile().mkdirs();
+            }
+            out = new FileOutputStream(path);
+            workbook.write(out);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            log.error("导出Excel异常{}", e.getMessage());
+            throw new CustomException("导出Excel失败,请联系网站管理员!");
+        }
+        finally
+        {
+
+            if (wb != null)
+            {
+                try
+                {
+                    wb.close();
+                }
+                catch (IOException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+            if (out != null)
+            {
+                try
+                {
+                    out.close();
+                }
+                catch (IOException e1)
+                {
+                    e1.printStackTrace();
+                }
+            }
+        }
+    }
+
 
 
     public void exportEasyExcelStudy(List<Map<String, Object>> sheetsList,String path)

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IClassGradeUserService.java

@@ -148,6 +148,8 @@ public interface IClassGradeUserService extends IService<ClassGradeUser> {
 
 	List<ClassPeriodStudentVo> listVideoUserPeriod(ClassGradeUserQueryBo bo);
 
+	Boolean exportListVideoUserPeriod(Long userId,String dirPath);
+
 	Boolean sevenPushAuthCallBack(SevenPushAuthAddBo bo);
 
 	List<ClassPeriodStudentVo> listBKUserPeriod(ClassGradeUserQueryBo bo);

+ 81 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/ClassGradeUserServiceImpl.java

@@ -26,6 +26,7 @@ import com.zhongzheng.common.utils.ServletUtils;
 import com.zhongzheng.common.utils.ToolsUtils;
 import com.zhongzheng.common.utils.file.FileUtils;
 import com.zhongzheng.common.utils.http.HttpUtils;
+import com.zhongzheng.common.utils.poi.ExcelUtil;
 import com.zhongzheng.modules.alioss.service.OssService;
 import com.zhongzheng.modules.bank.bo.QuestionChapterExamQueryBo;
 import com.zhongzheng.modules.bank.bo.QuestionModuleChapterQueryBo;
@@ -33,6 +34,7 @@ import com.zhongzheng.modules.bank.service.IQuestionChapterExamService;
 import com.zhongzheng.modules.bank.service.IQuestionModuleChapterService;
 import com.zhongzheng.modules.bank.vo.ExamVo;
 import com.zhongzheng.modules.bank.vo.QuestionChapterVo;
+import com.zhongzheng.modules.base.domain.UserProfile;
 import com.zhongzheng.modules.base.service.IUserProfileService;
 import com.zhongzheng.modules.course.bo.CourseBusinessQueryBo;
 import com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo;
@@ -3721,6 +3723,85 @@ public class ClassGradeUserServiceImpl extends ServiceImpl<ClassGradeUserMapper,
         return classPeriodStudentVos;
     }
 
+    @Override
+    public Boolean exportListVideoUserPeriod(Long userId, String dirPath) {
+        ClassGradeUserQueryBo userQueryBo  = new ClassGradeUserQueryBo();
+        userQueryBo.setUserId(userId);
+        //查询班级学员信息
+        List<ClassPeriodStudentVo> classPeriodStudentVos = baseMapper.listVideoUserPeriod(userQueryBo);
+        //查找学员学习记录
+        for (ClassPeriodStudentVo classPeriodStudentVo : classPeriodStudentVos) {
+            Long secLong = 0L;
+            Long studyLong = 0L;
+
+            SubjectStudyRecordQueryBo subjectStudyRecordQueryBo = new SubjectStudyRecordQueryBo();
+            subjectStudyRecordQueryBo.setGoodsId(classPeriodStudentVo.getGoodsId());
+            subjectStudyRecordQueryBo.setUserId(classPeriodStudentVo.getUserId());
+            subjectStudyRecordQueryBo.setGradeId(classPeriodStudentVo.getGradeId());
+            subjectStudyRecordQueryBo.setOrderGoodsId(classPeriodStudentVo.getOrderGoodsId());
+            List<SubjectStudyRecordVo> subjectStudyRecordVos = iUserStudyRecordService.listDangAnSubject(subjectStudyRecordQueryBo);
+            for (SubjectStudyRecordVo subjectStudyRecordVo : subjectStudyRecordVos) {
+                secLong = new BigDecimal(secLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getSectionNum().toString())).longValue();
+                studyLong = new BigDecimal(studyLong.toString()).add(new BigDecimal(subjectStudyRecordVo.getRecordNum().toString())).longValue();
+            }
+            //总节数
+            classPeriodStudentVo.setSecAllNum(secLong);
+            //学习节数
+            classPeriodStudentVo.setStuAllNum(studyLong);
+
+            //总的审核状态按照策划规则
+            ClassGradeUserQueryBo classGradeUserQueryBo = new ClassGradeUserQueryBo();
+            classGradeUserQueryBo.setGradeId(classPeriodStudentVo.getGradeId());
+            classGradeUserQueryBo.setUserId(classPeriodStudentVo.getUserId());
+            classGradeUserQueryBo.setGoodsId(classPeriodStudentVo.getGoodsId());
+            List<ClassPeriodUserVo> classPeriodUserVos1 = baseMapper.listPeriod(classGradeUserQueryBo);
+            ClassPeriodUserVo classPeriodUserVos = classPeriodUserVos1.get(0);
+            classPeriodUserVos.setPending(classPeriodStudentVo.getSecAllNum() - classPeriodUserVos.getPass() - classPeriodUserVos.getCheat());
+            classPeriodUserVos.setExamPending(classPeriodUserVos.getExamNum() - classPeriodUserVos.getExamPass() - classPeriodUserVos.getExamCheat());
+            //當前班級學員審核狀態 -1不可审核 0待審  1未通过 2通过
+            Integer gradePeriodStatus = 0; //班级里的审核状态字段,保持一致 0 未通过 1通过 2待审核 -1 不可审核
+
+            classPeriodStudentVo.setAllStatus(changePeriodStatus(classPeriodStudentVo.getPeriodStatus()));
+
+            classPeriodStudentVo.setWaitRebuildNum(classPeriodUserVos.getCheat() + classPeriodUserVos.getExamCheat());
+            if (!CollectionUtils.isEmpty(baseMapper.selectStart(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGoodsId(), classPeriodStudentVo.getGradeId(),classPeriodStudentVo.getOrderGoodsId()))) {
+                //查找开始学习时间
+                classPeriodStudentVo.setStartTime(baseMapper.selectStart(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGoodsId(), classPeriodStudentVo.getGradeId(),classPeriodStudentVo.getOrderGoodsId()).get(0));
+            }else{
+                classPeriodStudentVo.setStartTime(baseMapper.selectStartNoPhoto(classPeriodStudentVo.getUserId(), classPeriodStudentVo.getGoodsId(), classPeriodStudentVo.getGradeId(),classPeriodStudentVo.getOrderGoodsId())
+                );
+            }
+        }
+
+        List<ClassPeriodStudentExportListVo> exportList = new ArrayList<>();
+        for (ClassPeriodStudentVo classPeriodStudentVo : classPeriodStudentVos) {
+            ClassPeriodStudentExportListVo vo = BeanUtil.toBean(classPeriodStudentVo, ClassPeriodStudentExportListVo.class);
+            vo.setStudyTime(DateUtils.timestampToDate(classPeriodStudentVo.getStudyStartTime())+"至"+DateUtils.timestampToDate(classPeriodStudentVo.getStudyEndTime()));
+            vo.setProcess((classPeriodStudentVo.getRecordNum()+classPeriodStudentVo.getStuAllNum())+"/"+(classPeriodStudentVo.getExamNum()+classPeriodStudentVo.getSecAllNum()));
+            vo.setVideoProcess(classPeriodStudentVo.getStuAllNum()+"/"+classPeriodStudentVo.getSecAllNum());
+            if(classPeriodStudentVo.getPeriodStatus()==0){
+                vo.setPeriodStatus("未通过");
+            }
+            else if(classPeriodStudentVo.getPeriodStatus()==1){
+                vo.setPeriodStatus("通过");
+            }
+            else if(classPeriodStudentVo.getPeriodStatus()==2){
+                vo.setPeriodStatus("待审核");
+            }
+            else if(classPeriodStudentVo.getPeriodStatus()==3){
+                vo.setPeriodStatus("审核中");
+            }
+            else if(classPeriodStudentVo.getPeriodStatus()==-1){
+                vo.setPeriodStatus("不可审核");
+            }
+            exportList.add(vo);
+        }
+        ExcelUtil<ClassPeriodStudentExportListVo> util = new ExcelUtil<ClassPeriodStudentExportListVo>(ClassPeriodStudentExportListVo.class);
+        String filePath = dirPath+"/网课记录.xlsx";
+        util.exportEasyExcelUtil(exportList,ClassPeriodStudentExportListVo.class,filePath);
+        return true;
+    }
+
 
     public Boolean sevenPushAuthCallBack(SevenPushAuthAddBo bo) {
         if(Validator.isEmpty(bo.getGradeUserId())||Validator.isEmpty(bo.getPushStatus())){

+ 69 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/vo/ClassPeriodStudentExportListVo.java

@@ -0,0 +1,69 @@
+package com.zhongzheng.modules.grade.vo;
+
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+
+/**
+ * 学员记录视图对象 mall_package
+ *
+ * @author ruoyi
+ * @date 2021-11-10
+ */
+@Data
+@ApiModel("学员学时视图对象")
+public class ClassPeriodStudentExportListVo {
+	private static final long serialVersionUID = 1L;
+
+
+	/** 学员编码 */
+	@Excel(name = "姓名")
+	@ApiModelProperty("姓名")
+	private String realName;
+
+	/** 学员编码 */
+	@Excel(name = "身份证号码")
+	@ApiModelProperty("身份证号码")
+	private String idCard;
+
+	/** 学员编码 */
+	@Excel(name = "学员电话")
+	@ApiModelProperty("学员电话")
+	private String telPhone;
+
+	@Excel(name = "学习时间")
+	private String studyTime;
+
+	@Excel(name = "课程")
+	private String goodsName;
+
+	@Excel(name = "年份")
+	private String goodsYear;
+
+	@Excel(name = "业务类型")
+	private String businessName;
+
+	@Excel(name = "专业")
+	private String categoryName;
+
+	@Excel(name = "所在班级")
+	private String className;
+
+	@Excel(name = "总学时")
+	private String classHours;
+
+	@Excel(name = "总进度(节)")
+	private String process;
+
+	@Excel(name = "视频总进度")
+	private String videoProcess;
+
+	@Excel(name = "学时审核")
+	private String periodStatus;
+}