修改考核、补考信息接口

master
pd 4 years ago
parent 14c5d06bf7
commit c8a44c97d0
  1. 10
      src/main/java/com/yipin/liuwanr/controller/MakeuplistController.java
  2. 37
      src/main/java/com/yipin/liuwanr/helper/ExcelImportHelper.java
  3. 5
      src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java
  4. 6
      src/main/java/com/yipin/liuwanr/mapper/MakeuplistMapper.java
  5. 22
      src/main/java/com/yipin/liuwanr/service/AssesmentService.java
  6. 24
      src/main/java/com/yipin/liuwanr/service/MakeuplistService.java
  7. 11
      src/main/java/com/yipin/liuwanr/vo/MakeupStudentsVo.java

@ -33,7 +33,6 @@ public class MakeuplistController {
Response resp = new Response();
MultipartFile file=vo.getFile();
Integer staffId=vo.getStaffId();
Integer uploadType=vo.getUploadType();
Integer schoolId=vo.getSchoolId();
long uploadTime=vo.getUploadTime();
@ -43,14 +42,11 @@ public class MakeuplistController {
}else if(StringUtils.isEmpty(uploadTime)){
resp.setStatus(300);
resp.setMessage("文件上传时间为空");
}else if(StringUtils.isEmpty(uploadType)){
resp.setStatus(300);
resp.setMessage("文件上传选项为空");
}else if(StringUtils.isEmpty(schoolId)){
resp.setStatus(300);
resp.setMessage("学校为空");
}else{
HashMap<String, Object> ret = makeuplistService.addMakeuplist(file,schoolId,staffId,uploadType,uploadTime);
HashMap<String, Object> ret = makeuplistService.addMakeuplist(file,schoolId,staffId,uploadTime);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
@ -69,7 +65,7 @@ public class MakeuplistController {
* @return
*/
@GetMapping("/queryGetByClassName")
Response queryGetByClassName(@RequestParam Integer staffId,@RequestParam long uploadTime,
Response queryGetByClassName(@RequestParam Integer staffId,@RequestParam Long uploadTime,
@RequestParam Integer uploadType,@RequestParam Integer schoolId) {
Response resp = new Response();
if(StringUtils.isEmpty(staffId)) {
@ -123,7 +119,7 @@ public class MakeuplistController {
}
@GetMapping("/getStudent")
Response getStudent(@RequestParam Integer staffId,@RequestParam long uploadTime,@RequestParam Integer uploadType,
Response getStudent(@RequestParam Integer staffId,@RequestParam Long uploadTime,@RequestParam Integer uploadType,
@RequestParam Integer schoolId){
Response resp = new Response();
if(StringUtils.isEmpty(staffId)) {

@ -2,8 +2,10 @@ package com.yipin.liuwanr.helper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.yipin.liuwanr.vo.MakeupStudentsVo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
@ -11,6 +13,7 @@ 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.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import com.yipin.liuwanr.entity.Makeuplist;
@ -24,9 +27,11 @@ public class ExcelImportHelper {
* @param file
* @return
*/
public static List<Makeuplist> readExcel(MultipartFile file,Integer uploadType) {
public static HashMap<String,Object> readExcel(MultipartFile file) {
HashMap<String,Object> resp=new HashMap<String,Object>();
List<Makeuplist> list = new ArrayList<Makeuplist>();
List<String> names=new ArrayList<String>();
Integer uploadType=null;
try {
String fileName = file.getOriginalFilename();
Workbook workbook = null;
@ -37,15 +42,26 @@ public class ExcelImportHelper {
}
Makeuplist makeuplist = null;
// 循环工作表Sheet
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
Sheet hssfSheet = workbook.getSheetAt(numSheet);
if (hssfSheet == null) {
continue;
Sheet hssfSheet = workbook.getSheetAt(0);
if (hssfSheet != null) {
Row row1 = hssfSheet.getRow(0);
if(row1!=null){
row1.getCell(0).setCellType(CellType.STRING);
Cell readClassName = row1.getCell(0);
String readName=readClassName.getStringCellValue();
if(!StringUtils.isEmpty(readName)){
if(readName.equals("实验班级名称")){
uploadType=0;
}else if(readName.equals("行政班级名称")){
uploadType=1;
}else{
throw new RuntimeException("数据模板被修改");
}
}
// 循环行Row
for (int rowNum = 1; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
Row row = hssfSheet.getRow(rowNum);
if (row != null) {
makeuplist = new Makeuplist();
row.getCell(0).setCellType(CellType.STRING);
@ -74,13 +90,18 @@ public class ExcelImportHelper {
}
}
}
}
}else{
return null;
}
}
resp.put("uploadType",uploadType);
resp.put("makeuplists",list);
} catch (Exception e) {
}
return list;
return resp;
}
/**

@ -341,4 +341,9 @@ public interface AssesmentMapper {
//开始考核
@Select("select id,assesmentName,timesum from assessment where courseId=#{courseId} and releaseType=0 and assesmentState=0")
List<Assesment> releaseAssesment(Integer courseId);
//考核名称去重
@Select("select count(*) from assessment where assesmentName=#{assesmentName}")
Integer getByAssesmentName(String assesmentName);
}

@ -25,8 +25,8 @@ public interface MakeuplistMapper {
"where m.studentId=s.studentId and s.classId=c.classId and c.gradeId=g.gradeId and s.professionalId=p.professionalId and m.experimentalClassId=ecn .experimentalClassId and m.staffId=#{staffId} and m.uploadTime=#{uploadTime} and m.schoolId=#{schoolId}")
List<Makeuplist> queryExperimentalClassMakeuplist(@Param("staffId")Integer staffId, @Param("uploadTime")String uploadTime,@Param("schoolId") Integer schoolId);
@Select("select experimentalClassId,studentId,classId from makeuplist where staffId=#{staffId} and uploadTime=#{uploadTime} and schoolId=#{schoolId}")
List<Student> getstudent(@Param("staffId")Integer staffId, @Param("uploadTime")String uploadTime,@Param("schoolId") Integer schoolId);
@Select("select experimentalClassId,studentId,classId from makeuplist where staffId=#{staffId} and uploadTime=#{uploadTime} and schoolId=#{schoolId} and uploadType=#{uploadType}")
List<Student> getstudent(@Param("staffId")Integer staffId, @Param("uploadTime")String uploadTime,@Param("schoolId") Integer schoolId,@Param("uploadType")Integer uploadType);
@Select("select classId,studentId from makeuplist where staffId=#{staffId} and uploadTime=#{uploadTime}")
List<Student> getClass(@Param("staffId")Integer staffId, @Param("uploadTime")String uploadTime);
@ -38,7 +38,7 @@ public interface MakeuplistMapper {
//实验班级信息
@Select("SELECT exn.experimentalClassId,studentNumber,s.studentId from student s left join experimental_class_student ecs on s.studentId=ecs.studentId left join experimental_class_ning exn on ecs.experimentalClassId=exn.experimentalClassId " +
" where exn.experimentalClassName='111' and exn.schoolId=1 and s.studentNumber='123'")
" where exn.experimentalClassName=#{experimentalClassName} and exn.schoolId=#{schoolId} and s.studentNumber=#{studentNumber}")
Student queryExperimentalClassStudent(@Param("experimentalClassName") String experimentalClassName,@Param("schoolId")Integer schoolId,@Param("studentNumber")String studentNumber);
//行政班级信息

@ -90,6 +90,14 @@ public class AssesmentService {
mapper.insertAssesment(assesment);
//得到考核id
Integer assesmentId = assesment.getId();
String name=assesment.getAssesmentName();
Integer number=mapper.getByAssesmentName(name);
if(number!=null&&number>0){
name+=(number+1);
assesment.setAssesmentName(name);
}
//往记录表中添加选中的学生信息,哪名学生要参与某一课程的什么考核,该考核下的 哪一项目
mapper.insertRecore(studentIds, assesment.getExperimentId(), assesment.getCourseId(), assesmentId);
@ -135,14 +143,14 @@ public class AssesmentService {
*/
public HashMap<String, Object> queryGetById(Integer id) {
HashMap<String, Object> resp = new HashMap<String, Object>();
List<Object> obj = new ArrayList<Object>();
HashMap<String, Object> obj=new HashMap<>();
try {
//考核信息
Assesment assesment = mapper.queryGetById(id);
//之前选中的学生
List<Student> students = mapper.queryStudent(id);
obj.add(assesment);
obj.add(students);
obj.put("assesment",assesment);
obj.put("students",students);
resp.put("retvalue", obj);
resp.put("retcode", 200);
@ -206,6 +214,14 @@ public class AssesmentService {
//判分点数量
Integer pointNumber = mapper.queryPointNumber(assesment.getExperimentId());
assesment.setAssessmentNumber(pointNumber);
String name=assesment.getAssesmentName();
Integer number=mapper.getByAssesmentName(name);
if(number!=null&&number>0){
name+=(number+1);
assesment.setAssesmentName(name);
}
mapper.updateAssesment(assesment);
resp.put("retcode", 200);

@ -61,7 +61,7 @@ public class MakeuplistService {
HashMap<String, Object> resp = new HashMap<String, Object>();
String time= AssesmentHelper.longPointDate(uploadTime);
try{
resp.put("retvalue",makeuplistMapper.getstudent(staffId,time,schoolId));
resp.put("retvalue",makeuplistMapper.getstudent(staffId,time,schoolId,uploadType));
resp.put("retcode", 200);
}catch (RuntimeException e){
logger.error(e.getMessage());
@ -72,8 +72,6 @@ public class MakeuplistService {
return resp;
}
public HashMap<String, Object> getByMakeuplist(Integer staffId,long uploadTime,Integer uploadType,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>();
String time= AssesmentHelper.longPointDate(uploadTime);
@ -103,20 +101,34 @@ public class MakeuplistService {
* @return
*/
@Transactional
public HashMap<String, Object> addMakeuplist( MultipartFile file,Integer schoolId,Integer staffId,Integer uploadType,long uploadTime) {
public HashMap<String, Object> addMakeuplist( MultipartFile file,Integer schoolId,Integer staffId,long uploadTime) {
HashMap<String, Object> resp = new HashMap<String, Object>();
MakeupStudentsVo vo;
MakeupStudentsVo vo=new MakeupStudentsVo();
String time= AssesmentHelper.longPointDate(uploadTime);
try {
//补考学生信息
List<Makeuplist> makeuplists= ExcelImportHelper.readExcel(file,uploadType);
HashMap<String,Object> obj= ExcelImportHelper.readExcel(file);
if(obj!=null){
Integer uploadType=(Integer) obj.get("uploadType");
List<Makeuplist> makeuplists=(List<Makeuplist>)obj.get("makeuplists");
if(!makeuplists.isEmpty()&&makeuplists.size()>0){
if(uploadType!=null){
if(uploadType.equals(0)){
addMakeuplist(makeuplists,schoolId,staffId,uploadType,time);
}else if(uploadType.equals(1)){
addMakeuplist(makeuplists,schoolId,staffId,uploadType,time);
}
resp.put("retcode", 200);
vo.setUploadType(uploadType);
resp.put("retvalue", vo);
}else{
resp.put("retcode", 300);
resp.put("retvalue", "文件模板错误");
}
}else{
resp.put("retcode", 300);
resp.put("retvalue", "导入文件失败");
}
}else{
resp.put("retcode", 300);
resp.put("retvalue", "导入文件失败");

@ -4,6 +4,8 @@ import com.yipin.liuwanr.entity.Makeuplist;
import com.yipin.liuwanr.entity.Student;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* 补考名单信息
*/
@ -12,15 +14,12 @@ public class MakeupStudentsVo extends Makeuplist {
private MultipartFile file;//上传文件
private Integer staffId;//教师id
private Integer schoolId;//学校id
private long uploadTime;//上传时间
private Long uploadTime;//上传时间
private Integer uploadType;//上传方式
private String time;//yyyy-MM-dd HH:mm
public MakeupStudentsVo() { }
public String getTime() {
return time;
}
@ -53,11 +52,11 @@ public class MakeupStudentsVo extends Makeuplist {
this.staffId = staffId;
}
public long getUploadTime() {
public Long getUploadTime() {
return uploadTime;
}
public void setUploadTime(long uploadTime) {
public void setUploadTime(Long uploadTime) {
this.uploadTime = uploadTime;
}

Loading…
Cancel
Save