2024年11月25日 修复错误,兼容部分可能出现空行的报表,不导入空数据,导致统计出错
This commit is contained in:
parent
17ff8e559e
commit
6884e0ea26
|
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.compress.utils.Lists;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
@ -183,21 +185,27 @@ public class BlStuAnswerController extends JeecgController<BlStuAnswer, IBlStuAn
|
||||||
params.setNeedSave(true);
|
params.setNeedSave(true);
|
||||||
try {
|
try {
|
||||||
List<BlStuAnswer> list = ExcelImportUtil.importExcel(file.getInputStream(), BlStuAnswer.class, params);
|
List<BlStuAnswer> list = ExcelImportUtil.importExcel(file.getInputStream(), BlStuAnswer.class, params);
|
||||||
list.forEach(x-> x.setMainId(id));
|
List<BlStuAnswer> saveList = Lists.newArrayList();
|
||||||
|
list.forEach(x-> {
|
||||||
|
if(StringUtils.isNotBlank(x.getNianji())) {
|
||||||
|
x.setMainId(id);
|
||||||
|
saveList.add(x);
|
||||||
|
}
|
||||||
|
});
|
||||||
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
service.saveBatch(list);
|
service.saveBatch(saveList);
|
||||||
//400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
|
//400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
|
||||||
//1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
|
//1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
|
||||||
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
||||||
|
|
||||||
//update-end-author:taoyan date:20190528 for:批量插入数据
|
//update-end-author:taoyan date:20190528 for:批量插入数据
|
||||||
return Result.ok("文件导入成功!数据行数:" + list.size());
|
return Result.ok("文件导入成功!数据行数:" + saveList.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
|
if(msg!=null && msg.contains("Duplicate entry")){
|
||||||
return Result.error("文件导入失败:有重复数据!");
|
return Result.error("文件导入失败:有重复数据!");
|
||||||
}else{
|
}else{
|
||||||
return Result.error("文件导入失败:" + e.getMessage());
|
return Result.error("文件导入失败:" + e.getMessage());
|
||||||
|
|
|
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.compress.utils.Lists;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
|
@ -181,17 +183,21 @@ public class BlTeacherAnswerController extends JeecgController<BlTeacherAnswer,
|
||||||
params.setNeedSave(true);
|
params.setNeedSave(true);
|
||||||
try {
|
try {
|
||||||
List<BlTeacherAnswer> list = ExcelImportUtil.importExcel(file.getInputStream(), BlTeacherAnswer.class, params);
|
List<BlTeacherAnswer> list = ExcelImportUtil.importExcel(file.getInputStream(), BlTeacherAnswer.class, params);
|
||||||
|
List<BlTeacherAnswer> saveList = Lists.newArrayList();
|
||||||
list.forEach(x->{
|
list.forEach(x->{
|
||||||
x.setMainId(id);
|
if(StringUtils.isNotBlank(x.getYear())) {
|
||||||
|
x.setMainId(id);
|
||||||
|
saveList.add(x);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
service.saveBatch(list);
|
service.saveBatch(saveList);
|
||||||
//400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
|
//400条 saveBatch消耗时间1592毫秒 循环插入消耗时间1947毫秒
|
||||||
//1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
|
//1200条 saveBatch消耗时间3687毫秒 循环插入消耗时间5212毫秒
|
||||||
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
||||||
//update-end-author:taoyan date:20190528 for:批量插入数据
|
//update-end-author:taoyan date:20190528 for:批量插入数据
|
||||||
return Result.ok("文件导入成功!数据行数:" + list.size());
|
return Result.ok("文件导入成功!数据行数:" + saveList.size());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
|
||||||
String msg = e.getMessage();
|
String msg = e.getMessage();
|
||||||
|
|
|
@ -1051,7 +1051,7 @@
|
||||||
union all
|
union all
|
||||||
select '关注学生的心理健康状况' as lsname,format(round(sum(EXCHANGE_XLJK)/count('x'),2)*100,0) as tj1 from bl_teacher_answer where main_id = #{id}
|
select '关注学生的心理健康状况' as lsname,format(round(sum(EXCHANGE_XLJK)/count('x'),2)*100,0) as tj1 from bl_teacher_answer where main_id = #{id}
|
||||||
union all
|
union all
|
||||||
select '我将“学生中心”理念全面落实在自己的各个教育教学工作中' as lsname,format(round(sum(EXCHANGE_ZDLW)/count('x'),2)*100,0) as tj1 from bl_teacher_answer where main_id = #{id}
|
select '指导学期、学年和毕业论文' as lsname,format(round(sum(EXCHANGE_ZDLW)/count('x'),2)*100,0) as tj1 from bl_teacher_answer where main_id = #{id}
|
||||||
union all
|
union all
|
||||||
select '指导学生从事研究项目和竞赛活动' as lsname,format(round(sum(EXCHANGE_ZDXM)/count('x'),2)*100,0) as tj1 from bl_teacher_answer where main_id = #{id}
|
select '指导学生从事研究项目和竞赛活动' as lsname,format(round(sum(EXCHANGE_ZDXM)/count('x'),2)*100,0) as tj1 from bl_teacher_answer where main_id = #{id}
|
||||||
union all
|
union all
|
||||||
|
|
Loading…
Reference in New Issue