Browse Source

add: 导出

caozixuan 10 months ago
parent
commit
f43eda3a08

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

@@ -7,6 +7,7 @@ import java.util.List;
 
 import javax.servlet.http.HttpServletResponse;
 
+import cn.com.qmth.mps.enums.ArbitrateMethod;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.CellType;
@@ -96,22 +97,22 @@ public class PaperController extends BaseController {
 	@PostMapping("export-subjective")
 	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");
+		response.setHeader("Content-Disposition", "inline; filename=" + fileName + ".xlsx");
+		response.setContentType("application/vnd.ms-excel");
 
-        List<PaperStructInfoVo> list = paperService.subjectiveList(query,getAccessUser());
-        Workbook wb=null;
-        OutputStream out=null;
-        try {
+		List<PaperStructInfoVo> list = paperService.subjectiveList(query, getAccessUser());
+		Workbook wb = null;
+		OutputStream out = null;
+		try {
 			wb = new XSSFWorkbook(ResouceUtil.getStream("importtemplates/structImport.xlsx"));
-			if(CollectionUtils.isNotEmpty(list)) {
+			if (CollectionUtils.isNotEmpty(list)) {
 				CellStyle style = wb.createCellStyle();
 				style.setAlignment(HorizontalAlignment.CENTER);
-				Sheet sheet=wb.getSheetAt(0);
-				int rowIndex=1;
-				for(PaperStructInfoVo vo:list) {
+				Sheet sheet = wb.getSheetAt(0);
+				int rowIndex = 1;
+				for (PaperStructInfoVo vo : list) {
 					rowIndex++;
-					Row row=sheet.createRow(rowIndex);
+					Row row = sheet.createRow(rowIndex);
 					row.createCell(0, CellType.STRING).setCellValue(getStringVal(vo.getCourseCode()));
 					row.createCell(1, CellType.STRING).setCellValue(getStringVal(vo.getCourseName()));
 					row.createCell(2, CellType.STRING).setCellValue(getStringVal(vo.getDetailName()));
@@ -121,18 +122,29 @@ public class PaperController extends BaseController {
 					row.createCell(6, CellType.STRING).setCellValue(getStringVal(vo.getScore()));
 					row.createCell(7, CellType.STRING).setCellValue(getStringVal(vo.getScoreStep()));
 					row.createCell(8, CellType.STRING).setCellValue(getStringVal(vo.getGroupNumber()));
-					for(int i=0;i<9;i++) {
+					row.createCell(9, CellType.STRING).setCellValue("");
+					ArbitrateMethod arbitrateMethod = vo.getArbitrateMethod();
+					String arbitrateMethodStr = "";
+					if (arbitrateMethod != null) {
+						arbitrateMethodStr = getStringVal(arbitrateMethod.getValue());
+					}
+					row.createCell(10, CellType.STRING).setCellValue(arbitrateMethodStr);
+					row.createCell(11, CellType.STRING).setCellValue(getStringVal(vo.getDoubleRate()));
+					row.createCell(12, CellType.STRING).setCellValue(getStringVal(vo.getArbitrateThreshold()));
+					row.createCell(13, CellType.STRING).setCellValue("1");
+					row.createCell(14, CellType.STRING).setCellValue("track");
+					for (int i = 0; i < 15; i++) {
 						row.getCell(i).setCellStyle(style);
 					}
 				}
 			}
-			out=response.getOutputStream();
+			out = response.getOutputStream();
 			wb.write(out);
 		} finally {
-			if(wb!=null) {
+			if (wb != null) {
 				wb.close();
 			}
-			if(out!=null) {
+			if (out != null) {
 				out.close();
 			}
 		}

+ 2 - 1
src/main/java/cn/com/qmth/mps/dao/PaperDao.java

@@ -2,6 +2,7 @@ package cn.com.qmth.mps.dao;
 
 import java.util.List;
 
+import cn.com.qmth.mps.enums.ArbitrateMethod;
 import org.apache.ibatis.annotations.Param;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -22,6 +23,6 @@ public interface PaperDao extends BaseMapper<PaperEntity> {
 
 	List<PaperVo> myPaperlist(@Param(value = "examId")Long examId,@Param(value = "userId")Long userId);
 
-	List<PaperStructInfoVo> subjectiveList(@Param(value = "req")PaperQuery query);
+	List<PaperStructInfoVo> subjectiveList(@Param(value = "req")PaperQuery query,@Param(value = "arbitrateMethod")ArbitrateMethod arbitrateMethod);
 
 }

+ 1 - 4
src/main/java/cn/com/qmth/mps/service/impl/PaperServiceImpl.java

@@ -754,10 +754,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		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;
+		return this.baseMapper.subjectiveList(query,ArbitrateMethod.GROUP_ARBITRATE);
 	}
 
 }

+ 33 - 20
src/main/resources/mapper/PaperMapper.xml

@@ -56,25 +56,39 @@
 
 	<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
+		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,
+			gg.arbitrate_method AS arbitrateMethod,
+			gg.double_rate AS doubleRate,
+			IF(gg.arbitrate_method = #{arbitrateMethod},
+			   gg.arbitrate_threshold,
+			   g.arbitrate_threshold) AS arbitrateThreshold
+		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}
@@ -94,7 +108,6 @@
 		<if test="req.totalScoreMax != null">
 			and t.total_score &lt;=#{req.totalScoreMax}
 		</if>
-
 		order by t.id,d.number,u.number
 	</select>
 </mapper>