xiatian 2 سال پیش
والد
کامیت
141cf733ca

+ 2 - 2
db/init.sql

@@ -146,8 +146,8 @@ CREATE TABLE `mps_paper_group_unit` (
   `updater_id` bigint DEFAULT NULL,
   `group_id` bigint NOT NULL,
   `paper_id` bigint NOT NULL,
-  `deatil_number` int NOT NULL,
-  `deatil_unit_number` int NOT NULL,
+  `detail_number` int NOT NULL,
+  `detail_unit_number` int NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `IDX_PAPER_GROUP_UNIT_01` (`paper_id`,`group_id`,`deatil_number`,`deatil_unit_number`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

+ 15 - 1
src/main/java/cn/com/qmth/mps/controller/PaperController.java

@@ -1,5 +1,7 @@
 package cn.com.qmth.mps.controller;
 
+import java.io.IOException;
+import java.net.URLEncoder;
 import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
@@ -18,6 +20,8 @@ import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.boot.core.collection.PageResult;
+import com.qmth.boot.tools.excel.ExcelWriter;
+import com.qmth.boot.tools.excel.enums.ExcelType;
 
 import cn.com.qmth.mps.bean.ImportMsg;
 import cn.com.qmth.mps.service.PaperDetailService;
@@ -29,6 +33,7 @@ import cn.com.qmth.mps.vo.paper.GroupVo;
 import cn.com.qmth.mps.vo.paper.PaperGroupDomain;
 import cn.com.qmth.mps.vo.paper.PaperInfoVo;
 import cn.com.qmth.mps.vo.paper.PaperQuery;
+import cn.com.qmth.mps.vo.paper.PaperStructInfoVo;
 import cn.com.qmth.mps.vo.paper.PaperVo;
 import cn.com.qmth.mps.vo.paper.StructDomain;
 import io.swagger.annotations.Api;
@@ -83,7 +88,16 @@ public class PaperController extends BaseController {
 
 	@ApiOperation(value = "导出主观题")
 	@PostMapping("export-subjective")
-	public void exportSubjective(PaperQuery query, HttpServletResponse response) {
+	public void exportSubjective(PaperQuery query, HttpServletResponse response) throws IOException {
+		String fileName = URLEncoder.encode("主观题", "UTF-8");
+        response.setHeader("Content-Disposition", "inline; filename=" + fileName + ".xlsx");
+        response.setContentType("application/vnd.ms-excel");
+
+        List<PaperStructInfoVo> list = paperService.subjectiveList(query,getAccessUser());
+        ExcelWriter writer = ExcelWriter.create(ExcelType.XLSX);
+
+        writer.writeObjects("sheet1", null, PaperStructInfoVo.class, list.iterator());
+        writer.output(response.getOutputStream());
 	}
 
 	@ApiOperation(value = "获取分页")

+ 3 - 0
src/main/java/cn/com/qmth/mps/dao/PaperDao.java

@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import cn.com.qmth.mps.entity.PaperEntity;
 import cn.com.qmth.mps.vo.exam.ExamPaperCountVo;
 import cn.com.qmth.mps.vo.paper.PaperQuery;
+import cn.com.qmth.mps.vo.paper.PaperStructInfoVo;
 import cn.com.qmth.mps.vo.paper.PaperVo;
 
 public interface PaperDao extends BaseMapper<PaperEntity> {
@@ -21,4 +22,6 @@ public interface PaperDao extends BaseMapper<PaperEntity> {
 
 	List<PaperVo> list(@Param(value = "examId")Long examId);
 
+	List<PaperStructInfoVo> subjectiveList(@Param(value = "req")PaperQuery query);
+
 }

+ 0 - 1
src/main/java/cn/com/qmth/mps/service/PaperDetailService.java

@@ -20,5 +20,4 @@ public interface PaperDetailService  extends IService<PaperDetailEntity> {
 	void structSubmit(StructDomain domain, User accessUser);
 
 
-
 }

+ 3 - 0
src/main/java/cn/com/qmth/mps/service/PaperService.java

@@ -12,6 +12,7 @@ import cn.com.qmth.mps.entity.PaperEntity;
 import cn.com.qmth.mps.vo.exam.ExamPaperCountVo;
 import cn.com.qmth.mps.vo.paper.PaperInfoVo;
 import cn.com.qmth.mps.vo.paper.PaperQuery;
+import cn.com.qmth.mps.vo.paper.PaperStructInfoVo;
 import cn.com.qmth.mps.vo.paper.PaperVo;
 
 public interface PaperService  extends IService<PaperEntity> {
@@ -30,4 +31,6 @@ public interface PaperService  extends IService<PaperEntity> {
 
 	List<String> importSubjectStruct(Long examId, User accessUser, MultipartFile file);
 
+	List<PaperStructInfoVo> subjectiveList(PaperQuery query,User user);
+
 }

+ 1 - 0
src/main/java/cn/com/qmth/mps/service/impl/PaperDetailServiceImpl.java

@@ -236,4 +236,5 @@ public class PaperDetailServiceImpl extends ServiceImpl<PaperDetailDao, PaperDet
 			throw new StatusException("试卷满分与小题分不一致");
 		}
 	}
+
 }

+ 44 - 31
src/main/java/cn/com/qmth/mps/service/impl/PaperServiceImpl.java

@@ -318,7 +318,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 					PaperEntity paper = saveOrGet(exam.getSchoolId(), examId, course.getId());
 					imp.setPaperId(paper.getId());
 				}
-				
+
 				String detailName = trimAndNullIfBlank(line.getValue(2));
 				if (StringUtils.isBlank(detailName)) {
 					msg.append("  大题名称不能为空");
@@ -326,84 +326,83 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 					msg.append("  大题名称不能超过50个字符");
 				}
 				imp.setDetailName(detailName);
-				
+
 				String detailNumber = trimAndNullIfBlank(line.getValue(3));
 				if (StringUtils.isBlank(detailNumber)) {
 					msg.append("  大题号不能为空");
-				} else{
+				} else {
 					try {
-						int n=Integer.valueOf(detailNumber);
-						if (n<=0) {
+						int n = Integer.valueOf(detailNumber);
+						if (n <= 0) {
 							msg.append("  大题号不能小于0");
-						}else {
+						} else {
 							imp.setDetailNumber(n);
 						}
 					} catch (Exception e) {
 						msg.append("  大题号只能是整数");
 					}
-					
+
 				}
-				
+
 				String unitNumber = trimAndNullIfBlank(line.getValue(4));
 				if (StringUtils.isBlank(unitNumber)) {
 					msg.append("  小题号不能为空");
-				} else{
+				} else {
 					try {
-						int n=Integer.valueOf(unitNumber);
-						if (n<=0) {
+						int n = Integer.valueOf(unitNumber);
+						if (n <= 0) {
 							msg.append("  小题号不能小于0");
-						}else {
+						} else {
 							imp.setUnitNumber(n);
 						}
 					} catch (Exception e) {
 						msg.append("  小题号只能是整数");
 					}
-					
+
 				}
-				
+
 				String score = trimAndNullIfBlank(line.getValue(5));
 				if (StringUtils.isBlank(score)) {
 					msg.append("  小题满分不能为空");
-				} else{
+				} else {
 					try {
-						Double n=Double.valueOf(score);
-						if (n<=0) {
+						Double n = Double.valueOf(score);
+						if (n <= 0) {
 							msg.append("  小题满分不能小于0");
-						}else {
-							if (score.indexOf(".")<score.length()-2) {
+						} else {
+							if (score.indexOf(".") < score.length() - 2) {
 								msg.append("小题满分只能有一位小数");
-							}else {
+							} else {
 								imp.setScore(n);
 							}
 						}
 					} catch (Exception e) {
 						msg.append("  小题满分格式错误");
 					}
-					
+
 				}
-				
+
 				String scoreStep = trimAndNullIfBlank(line.getValue(6));
 				if (StringUtils.isBlank(scoreStep)) {
 					msg.append("  间隔分不能为空");
-				} else{
+				} else {
 					try {
-						Double n=Double.valueOf(scoreStep);
-						if (n<=0) {
+						Double n = Double.valueOf(scoreStep);
+						if (n <= 0) {
 							msg.append("  间隔分不能小于0");
-						}else {
-							if (scoreStep.indexOf(".")<scoreStep.length()-2) {
+						} else {
+							if (scoreStep.indexOf(".") < scoreStep.length() - 2) {
 								msg.append("小间隔分只能有一位小数");
-							}else {
+							} else {
 								imp.setScoreStep(n);
 							}
 						}
 					} catch (Exception e) {
 						msg.append("  间隔分格式错误");
 					}
-					
+
 				}
-				
-				
+
 				if (msg.length() > 0) {
 					failRecords.add(newError(i + 1, msg.toString()));
 				} else {
@@ -552,4 +551,18 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		domain.setTotalScore(total);
 	}
 
+	@Override
+	public List<PaperStructInfoVo> subjectiveList(PaperQuery query, User user) {
+		if (query.getSchoolId() == null) {
+			throw new StatusException("学校不能为空");
+		}
+		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(query.getSchoolId())) {
+			throw new StatusException("没有权限");
+		}
+		List<PaperStructInfoVo> ret = this.baseMapper.subjectiveList(query);
+		if (CollectionUtils.isNotEmpty(ret)) {
+		}
+		return ret;
+	}
+
 }

+ 2 - 2
src/main/java/cn/com/qmth/mps/util/AuthorizationCreateUtil.java

@@ -12,8 +12,8 @@ public class AuthorizationCreateUtil {
     public static void main(String[] args) {
     	long time = System.currentTimeMillis();
     	String identity="SUPER_ADMIN_1";//登录后user属性
-    	String token="000000005c674c3d000000005ed585da";//登录后user属性
-    	String url="/api/paper/import-struct-subject";//请求路径
+    	String token="fffffffff9f5f4a4000000006c266958";//登录后user属性
+    	String url="/api/paper/export-subjective";//请求路径
     	String s = SignatureEntity.build(SignatureType.TOKEN, "post", url, time, identity, token);
     	System.out.println("time:"+time);
     	System.out.println("Authorization:"+s);

+ 16 - 9
src/main/java/cn/com/qmth/mps/vo/paper/PaperStructInfoVo.java

@@ -1,24 +1,25 @@
 package cn.com.qmth.mps.vo.paper;
 
-import io.swagger.annotations.ApiModelProperty;
+import com.qmth.boot.tools.excel.annotation.ExcelColumn;
 
 public class PaperStructInfoVo {
-	@ApiModelProperty("试卷结构Id")
 	private Long paperId;
-	@ApiModelProperty("科目代码")
+	@ExcelColumn(name = "科目代码", index = 0)
 	private String courseCode;
-	@ApiModelProperty("科目名称")
+	@ExcelColumn(name = "科目名称", index = 1)
     private String courseName;
-	@ApiModelProperty("大题名称")
+	@ExcelColumn(name = "大题名称", index = 2)
 	private String detailName;
-	@ApiModelProperty("大题号")
+	@ExcelColumn(name = "大题号", index =3)
 	private Integer detailNumber;
-	@ApiModelProperty("小题号")
+	@ExcelColumn(name = "小题号", index = 4)
 	private Integer unitNumber;
-	@ApiModelProperty("小题满分")
+	@ExcelColumn(name = "小题满分", index = 5)
 	private Double score;
-	@ApiModelProperty("给分间隔")
+	@ExcelColumn(name = "给分间隔", index = 6)
 	private Double scoreStep;
+	@ExcelColumn(name = "评卷分组", index = 7)
+	private Integer groupNumber;
 	public String getCourseCode() {
 		return courseCode;
 	}
@@ -68,5 +69,11 @@ public class PaperStructInfoVo {
 	public void setPaperId(Long paperId) {
 		this.paperId = paperId;
 	}
+	public Integer getGroupNumber() {
+		return groupNumber;
+	}
+	public void setGroupNumber(Integer groupNumber) {
+		this.groupNumber = groupNumber;
+	}
 	
 }

+ 55 - 9
src/main/resources/mapper/PaperMapper.xml

@@ -15,9 +15,11 @@
 	</select>
 
 	<select id="page" resultType="cn.com.qmth.mps.vo.paper.PaperVo">
-		select t.*,c.name courseName,c.code courseCode,e.name examName from mps_paper
+		select t.*,c.name courseName,c.code courseCode,e.name examName from
+		mps_paper
 		t left join mps_course c on t.course_id=c.id
-		left join mps_exam e on t.exam_id=e.id
+		left join
+		mps_exam e on t.exam_id=e.id
 		where
 		t.school_id=#{req.schoolId}
 		<if test="req.examId != null">
@@ -32,23 +34,67 @@
 		<if test="req.courseName != null and req.courseName !=''">
 			and c.name like concat('%', #{req.courseName}, '%')
 		</if>
-		<if test="req.name != null and req.name !=''">
-			and t.name like concat('%', #{req.name}, '%')
-		</if>
 		<if test="req.totalScoreMin != null">
 			and t.total_score &gt;=#{req.totalScoreMin}
 		</if>
 		<if test="req.totalScoreMax != null">
 			and t.total_score &lt;=#{req.totalScoreMax}
 		</if>
-		
+
 		order by t.update_time desc
 	</select>
 	<select id="list" resultType="cn.com.qmth.mps.vo.paper.PaperVo">
-		select t.*,c.name courseName,c.code courseCode,e.name examName from mps_paper
-		t left join mps_course c on t.course_id=c.id
+		select t.*,c.name courseName,c.code
+		courseCode,e.name examName from mps_paper
+		t left join mps_course c on
+		t.course_id=c.id
 		left join mps_exam e on t.exam_id=e.id
-		where t.exam_id =#{req.examId}
+		where t.exam_id
+		=#{req.examId}
 		order by t.update_time desc
 	</select>
+
+	<select id="subjectiveList"
+		resultType="cn.com.qmth.mps.vo.paper.PaperStructInfoVo">
+		select t.*,t.id paperId,c.name courseName,c.code courseCode,d.name
+		detailname,d.number detailNumber,u.number
+		unitNumber,u.score,u.score_step,gg.number groupNumber from mps_paper
+		t
+		left join mps_course
+		c on t.course_id=c.id
+		left join mps_exam e on
+		t.exam_id=e.id
+		left join
+		mps_paper_detail d on t.id=d.paper_id
+		left join
+		mps_paper_detail_unit u on d.id=u.detail_id
+		left join
+		mps_paper_group_unit g on g.paper_id=t.id and g.detail_number=d.number
+		and
+		g.detail_unit_number=u.number
+		left join mps_paper_group gg on
+		g.group_id=gg.id
+		where
+		t.school_id=#{req.schoolId}
+		<if test="req.examId != null">
+			and t.exam_id =#{req.examId}
+		</if>
+		<if test="req.groupFinish != null">
+			and t.group_finish =#{req.groupFinish}
+		</if>
+		<if test="req.courseCode != null and req.courseCode !=''">
+			and c.code like concat('%', #{req.courseCode}, '%')
+		</if>
+		<if test="req.courseName != null and req.courseName !=''">
+			and c.name like concat('%', #{req.courseName}, '%')
+		</if>
+		<if test="req.totalScoreMin != null">
+			and t.total_score &gt;=#{req.totalScoreMin}
+		</if>
+		<if test="req.totalScoreMax != null">
+			and t.total_score &lt;=#{req.totalScoreMax}
+		</if>
+
+		order by t.id,d.number,u.number
+	</select>
 </mapper>