|
|
@ -1,27 +1,43 @@
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
|
|
|
import java.text.DecimalFormat;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
import com.ibeetl.admin.core.entity.CoreUser;
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
import com.ibeetl.admin.core.util.TimeTool;
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseScoreDashboardDao;
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseScoreDashboardDao;
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseScoreDashboard;
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseScoreDashboard;
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseScoreDashboardQuery;
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseScoreDashboardQuery;
|
|
|
|
|
|
|
|
import com.ibeetl.jlw.entity.FileEntity;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 开课成绩看板 Service
|
|
|
|
* 成绩 Service
|
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
@ -58,7 +74,7 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
teacherOpenCourseScoreDashboardDao.deleteTeacherOpenCourseScoreDashboardByIds(ids);
|
|
|
|
teacherOpenCourseScoreDashboardDao.deleteTeacherOpenCourseScoreDashboardByIds(ids);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new PlatformException("批量删除开课成绩看板失败", e);
|
|
|
|
throw new PlatformException("批量删除成绩失败", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -144,4 +160,223 @@ public class TeacherOpenCourseScoreDashboardService extends CoreBaseService<Teac
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JsonResult importTemplate(List<FileEntity> fileEntityList,List<Long>list,CoreUser coreUser){
|
|
|
|
|
|
|
|
List<String[]>errMsg = new ArrayList<>();
|
|
|
|
|
|
|
|
String msg ="";
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
|
|
|
for(int item=0;null != fileEntityList && item<fileEntityList.size();item++){
|
|
|
|
|
|
|
|
FileEntity fileEntity = fileEntityList.get(item);
|
|
|
|
|
|
|
|
if(null != fileEntity){
|
|
|
|
|
|
|
|
File file = new File(fileEntity.getAbsoluteUrl());
|
|
|
|
|
|
|
|
if(file.exists() && file.isFile() && file.canRead() && ToolUtils.findInSet("xls,xlsx",fileEntity.getFormat())){
|
|
|
|
|
|
|
|
Workbook wb = null;
|
|
|
|
|
|
|
|
InputStream is = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
is = new FileInputStream(fileEntity.getAbsoluteUrl());
|
|
|
|
|
|
|
|
if("xls".equals(fileEntity.getFormat())){
|
|
|
|
|
|
|
|
wb = new HSSFWorkbook(is);
|
|
|
|
|
|
|
|
}else if("xlsx".equals(fileEntity.getFormat())){
|
|
|
|
|
|
|
|
wb = new XSSFWorkbook(is);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if(null != is){
|
|
|
|
|
|
|
|
is.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(wb != null){
|
|
|
|
|
|
|
|
//获取Sheet1
|
|
|
|
|
|
|
|
Sheet sheet = wb.getSheet("Sheet1");
|
|
|
|
|
|
|
|
//获取最大行数
|
|
|
|
|
|
|
|
int rowNum = sheet.getPhysicalNumberOfRows();
|
|
|
|
|
|
|
|
//获取第一行
|
|
|
|
|
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
|
|
|
|
|
//获取最大列数
|
|
|
|
|
|
|
|
int colNum = firstRow.getPhysicalNumberOfCells();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String columns[] = {
|
|
|
|
|
|
|
|
"学生",
|
|
|
|
|
|
|
|
"签到成绩",
|
|
|
|
|
|
|
|
"章节练习成绩",
|
|
|
|
|
|
|
|
"课程实操成绩",
|
|
|
|
|
|
|
|
"作业成绩",
|
|
|
|
|
|
|
|
"考试成绩",
|
|
|
|
|
|
|
|
"互动成绩",
|
|
|
|
|
|
|
|
"总成绩",
|
|
|
|
|
|
|
|
"手动调整的分数",
|
|
|
|
|
|
|
|
"最终成绩",
|
|
|
|
|
|
|
|
"成绩状态",
|
|
|
|
|
|
|
|
"创建时间"
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<String,Integer> map = new HashMap<>();//获取需要的表头的列
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//从第一列找到需要的表头
|
|
|
|
|
|
|
|
for (int i=0; i<colNum; i++){
|
|
|
|
|
|
|
|
String cellData = getCellFormatValue(firstRow.getCell(i));
|
|
|
|
|
|
|
|
for(int j=0;j<columns.length;j++){
|
|
|
|
|
|
|
|
if(columns[j].equals(cellData)){
|
|
|
|
|
|
|
|
map.put(columns[j],i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//验证所需要的表头是否全
|
|
|
|
|
|
|
|
Integer flag = 0;
|
|
|
|
|
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
|
|
|
|
|
if(null != map.get(columns[i])){
|
|
|
|
|
|
|
|
flag ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(flag != columns.length){
|
|
|
|
|
|
|
|
String str = " ";
|
|
|
|
|
|
|
|
for(int i=0;i<columns.length;i++){
|
|
|
|
|
|
|
|
str += "\""+columns[i]+"\""+(i == columns.length-1?"":", ");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return JsonResult.failMessage("导入失败,表格表头应包含"+str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i<rowNum; i++) {
|
|
|
|
|
|
|
|
Row row = sheet.getRow(i);
|
|
|
|
|
|
|
|
if(null == row){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+(i+1)+"数据为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String studentId = getCellFormatValue(row.getCell(map.get(columns[0])));
|
|
|
|
|
|
|
|
String signinScore = getCellFormatValue(row.getCell(map.get(columns[1])));
|
|
|
|
|
|
|
|
String courseScore = getCellFormatValue(row.getCell(map.get(columns[2])));
|
|
|
|
|
|
|
|
String realOperationScore = getCellFormatValue(row.getCell(map.get(columns[3])));
|
|
|
|
|
|
|
|
String questionHomeworkScore = getCellFormatValue(row.getCell(map.get(columns[4])));
|
|
|
|
|
|
|
|
String examScore = getCellFormatValue(row.getCell(map.get(columns[5])));
|
|
|
|
|
|
|
|
String chatScore = getCellFormatValue(row.getCell(map.get(columns[6])));
|
|
|
|
|
|
|
|
String totalScore = getCellFormatValue(row.getCell(map.get(columns[7])));
|
|
|
|
|
|
|
|
String manualScore = getCellFormatValue(row.getCell(map.get(columns[8])));
|
|
|
|
|
|
|
|
String lastScore = getCellFormatValue(row.getCell(map.get(columns[9])));
|
|
|
|
|
|
|
|
String lastStatus = getCellFormatValue(row.getCell(map.get(columns[10])));
|
|
|
|
|
|
|
|
String createTime = getCellFormatValue(row.getCell(map.get(columns[11])));
|
|
|
|
|
|
|
|
//TODO 判断(如重复等复杂判断要额外写)
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(studentId)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[0])+1)+"列,第"+(i+1)+"行学生为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(signinScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[1])+1)+"列,第"+(i+1)+"行签到成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(courseScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[2])+1)+"列,第"+(i+1)+"行章节练习成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(realOperationScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[3])+1)+"列,第"+(i+1)+"行课程实操成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(questionHomeworkScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[4])+1)+"列,第"+(i+1)+"行作业成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(examScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[5])+1)+"列,第"+(i+1)+"行考试成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(chatScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[6])+1)+"列,第"+(i+1)+"行互动成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(totalScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[7])+1)+"列,第"+(i+1)+"行总成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(manualScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[8])+1)+"列,第"+(i+1)+"行手动调整的分数为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(lastScore)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[9])+1)+"列,第"+(i+1)+"行最终成绩为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(lastStatus)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[10])+1)+"列,第"+(i+1)+"行成绩状态为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
if(StringUtils.isBlank(createTime)){
|
|
|
|
|
|
|
|
errMsg.add(new String[]{"第"+ToolUtils.numberToLetter(map.get(columns[11])+1)+"列,第"+(i+1)+"行创建时间为空"});
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//TODO 保存
|
|
|
|
|
|
|
|
TeacherOpenCourseScoreDashboard teacherOpenCourseScoreDashboard = new TeacherOpenCourseScoreDashboard();
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setStudentId(Long.parseLong(studentId));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setSigninScore(new BigDecimal(signinScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setCourseScore(new BigDecimal(courseScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setRealOperationScore(new BigDecimal(realOperationScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setQuestionHomeworkScore(new BigDecimal(questionHomeworkScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setExamScore(new BigDecimal(examScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setChatScore(new BigDecimal(chatScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setTotalScore(new BigDecimal(totalScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setManualScore(new BigDecimal(manualScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setLastScore(new BigDecimal(lastScore));
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setLastStatus(lastStatus);
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setOrgId(coreUser.getOrgId());
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setUserId(coreUser.getId());
|
|
|
|
|
|
|
|
teacherOpenCourseScoreDashboard.setCreateTime(TimeTool.getTime(createTime));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
|
|
|
|
|
jsonResult.setCode(count>0?JsonReturnCode.SUCCESS.getCode():JsonReturnCode.FAIL.getCode());
|
|
|
|
|
|
|
|
jsonResult.setData(errMsg);
|
|
|
|
|
|
|
|
jsonResult.setMsg((count>0?"导入成功,共导入"+count+"条":"导入失败")+(StringUtils.isNotBlank(msg)?"<br>"+msg:""));
|
|
|
|
|
|
|
|
return jsonResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public List<Map<String,Object>> getExcelValues (TeacherOpenCourseScoreDashboardQuery teacherOpenCourseScoreDashboardQuery){
|
|
|
|
|
|
|
|
return teacherOpenCourseScoreDashboardDao.getExcelValues(teacherOpenCourseScoreDashboardQuery);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getCellFormatValue(Cell cell) {
|
|
|
|
|
|
|
|
String value = null;
|
|
|
|
|
|
|
|
if (cell != null){
|
|
|
|
|
|
|
|
switch (cell.getCellTypeEnum()) {
|
|
|
|
|
|
|
|
case STRING:
|
|
|
|
|
|
|
|
value = cell.getRichStringCellValue().getString();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NUMERIC:
|
|
|
|
|
|
|
|
String dataFormatString = cell.getCellStyle().getDataFormatString();
|
|
|
|
|
|
|
|
if ("m/d/yy".equals(dataFormatString) || "yyyy-mm-dd".equals(dataFormatString)) {
|
|
|
|
|
|
|
|
DateFormat df = new SimpleDateFormat(dataFormatString);
|
|
|
|
|
|
|
|
value = TimeTool.getNowTime(df.format(cell.getDateCellValue()));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
DecimalFormat df = new DecimalFormat("#");
|
|
|
|
|
|
|
|
value = df.format(cell.getNumericCellValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BOOLEAN:
|
|
|
|
|
|
|
|
value = String.valueOf(cell.getBooleanCellValue());
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FORMULA:
|
|
|
|
|
|
|
|
value = cell.getCellFormula();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|