xiatian %!s(int64=2) %!d(string=hai) anos
pai
achega
d35bfa4ad4

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

@@ -97,6 +97,9 @@ public class PaperDetailServiceImpl extends ServiceImpl<PaperDetailDao, PaperDet
 			if (u.getNumber() == null || StringUtils.isBlank(u.getName())) {
 				throw new StatusException("大题号、大题名称不能为空");
 			}
+			if (u.getNumber()<=0) {
+				throw new StatusException("大题号必须大于0");
+			}
 			if (CollectionUtils.isEmpty(u.getUnits())) {
 				throw new StatusException("小题信息不能为空");
 			}
@@ -205,7 +208,7 @@ public class PaperDetailServiceImpl extends ServiceImpl<PaperDetailDao, PaperDet
 			throw new StatusException("没有权限");
 		}
 		if (paperGroupService.existsGroup(domain.getPaperId())) {
-			throw new StatusException("请先删除分组信息再提交试卷结构");
+			throw new StatusException("有分组信息,不能修改试卷结构");
 		}
 		clearPaperSruct(domain.getPaperId());
 		paper.setTotalScore(domain.getTotalScore());

+ 284 - 63
src/main/java/cn/com/qmth/mps/service/impl/PaperServiceImpl.java

@@ -3,6 +3,7 @@ package cn.com.qmth.mps.service.impl;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +30,8 @@ import com.qmth.boot.tools.excel.ExcelReader;
 import com.qmth.boot.tools.excel.enums.ExcelType;
 import com.qmth.boot.tools.excel.model.DataMap;
 
+import cn.com.qmth.mps.bean.PaperDetail;
+import cn.com.qmth.mps.bean.PaperDetailUnit;
 import cn.com.qmth.mps.bean.User;
 import cn.com.qmth.mps.dao.PaperDao;
 import cn.com.qmth.mps.entity.CourseEntity;
@@ -41,31 +44,34 @@ import cn.com.qmth.mps.service.PaperDetailService;
 import cn.com.qmth.mps.service.PaperGroupService;
 import cn.com.qmth.mps.service.PaperService;
 import cn.com.qmth.mps.util.BatchSetDataUtil;
+import cn.com.qmth.mps.util.Calculator;
 import cn.com.qmth.mps.util.PageUtil;
 import cn.com.qmth.mps.vo.exam.ExamPaperCountVo;
 import cn.com.qmth.mps.vo.paper.GroupCountVo;
 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;
 
 @Service
 public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> implements PaperService {
-	
+
 	@Autowired
 	private ExamService examService;
-	
+
 	@Autowired
 	private CourseService courseService;
 	@Autowired
 	private PaperGroupService paperGroupService;
 	@Autowired
 	private PaperDetailService paperDetailService;
-	
+
 	@Transactional
 	@Override
 	public List<String> importPaper(Long examId, User user, MultipartFile file) {
-		ExamEntity exam=examService.getById(examId);
-		if(exam==null) {
+		ExamEntity exam = examService.getById(examId);
+		if (exam == null) {
 			throw new StatusException("未找到考试批次");
 		}
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(exam.getSchoolId())) {
@@ -73,7 +79,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		}
 		InputStream inputStream = null;
 		try {
-			inputStream=file.getInputStream();
+			inputStream = file.getInputStream();
 			List<DataMap> lineList = ExcelReader.create(ExcelType.XLSX, inputStream, 0).getDataMapList();
 			if (CollectionUtils.isEmpty(lineList)) {
 				throw new StatusException("Excel无内容");
@@ -109,7 +115,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 					msg.append("  科目名称不能超过20个字符");
 				}
 				if (msg.length() == 0) {
-					CourseEntity course=courseService.saveOrGet(exam.getSchoolId(), code, name);
+					CourseEntity course = courseService.saveOrGet(exam.getSchoolId(), code, name);
 					imp.setCourseId(course.getId());
 				}
 
@@ -141,9 +147,9 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		} catch (StatusException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new StatusException("系统错误",e);
+			throw new RuntimeException("系统错误", e);
 		} finally {
-			if(inputStream!=null) {
+			if (inputStream != null) {
 				try {
 					inputStream.close();
 				} catch (IOException e) {
@@ -151,13 +157,14 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 			}
 		}
 	}
-	
+
 	private String trimAndNullIfBlank(String s) {
 		if (StringUtils.isBlank(s)) {
 			return null;
 		}
 		return s.trim();
 	}
+
 	private String newError(int lineNum, String msg) {
 		return "第" + lineNum + "行" + msg;
 	}
@@ -175,6 +182,32 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		return this.count(wrapper);
 	}
 
+	private PaperEntity findByExamAndCourse(Long examId, Long courseId) {
+		QueryWrapper<PaperEntity> wrapper = new QueryWrapper<>();
+		LambdaQueryWrapper<PaperEntity> lw = wrapper.lambda();
+		lw.eq(PaperEntity::getExamId, examId);
+		lw.eq(PaperEntity::getCourseId, courseId);
+		return this.getOne(wrapper);
+	}
+
+	private PaperEntity saveOrGet(Long schoolId, Long examId, Long courseId) {
+		PaperEntity ret = findByExamAndCourse(examId, courseId);
+		if (ret != null) {
+			return ret;
+		}
+		PaperEntity imp = new PaperEntity();
+		imp.setTotalScore(0.0);
+		imp.setObjectiveScore(0.0);
+		imp.setSubjectiveScore(0.0);
+		imp.setSchoolId(schoolId);
+		imp.setGroupFinish(false);
+		imp.setCourseId(courseId);
+		imp.setExamId(examId);
+		imp.setStructFinish(true);
+		this.save(imp);
+		return imp;
+	}
+
 	@Override
 	public PageResult<PaperVo> page(PaperQuery query, User user) {
 		if (query.getSchoolId() == null) {
@@ -183,34 +216,35 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(query.getSchoolId())) {
 			throw new StatusException("没有权限");
 		}
-		IPage<PaperVo> iPage = this.baseMapper.page(new Page<PaperVo>(query.getPageNumber(), query.getPageSize()), query);
-		if(CollectionUtils.isNotEmpty(iPage.getRecords())) {
+		IPage<PaperVo> iPage = this.baseMapper.page(new Page<PaperVo>(query.getPageNumber(), query.getPageSize()),
+				query);
+		if (CollectionUtils.isNotEmpty(iPage.getRecords())) {
 			new BatchSetDataUtil<PaperVo>() {
 
-                @Override
-                protected void setData(List<PaperVo> dataList) {
-                    List<Long> paperIds = dataList.stream().map(dto -> dto.getId()).distinct()
-                            .collect(Collectors.toList());
-                    List<GroupCountVo> ret = paperGroupService.findGroupCount(paperIds);
-                    if (ret != null && ret.size() > 0) {
-                        Map<Long, Integer> countMap = new HashMap<>();
-                        for (GroupCountVo item : ret) {
-                            countMap.put(item.getPaperId(), item.getGroupCount());
-                        }
-                        for (PaperVo vo : dataList) {
-                            vo.setGroupCount(countMap.get(vo.getId()));
-                        }
-                    }
-                }
-            }.setDataForBatch(iPage.getRecords(), 20);
+				@Override
+				protected void setData(List<PaperVo> dataList) {
+					List<Long> paperIds = dataList.stream().map(dto -> dto.getId()).distinct()
+							.collect(Collectors.toList());
+					List<GroupCountVo> ret = paperGroupService.findGroupCount(paperIds);
+					if (ret != null && ret.size() > 0) {
+						Map<Long, Integer> countMap = new HashMap<>();
+						for (GroupCountVo item : ret) {
+							countMap.put(item.getPaperId(), item.getGroupCount());
+						}
+						for (PaperVo vo : dataList) {
+							vo.setGroupCount(countMap.get(vo.getId()));
+						}
+					}
+				}
+			}.setDataForBatch(iPage.getRecords(), 20);
 		}
 		return PageUtil.of(iPage);
 	}
 
 	@Override
 	public List<PaperVo> list(Long examId, User user) {
-		ExamEntity exam=examService.getById(examId);
-		if(exam==null) {
+		ExamEntity exam = examService.getById(examId);
+		if (exam == null) {
 			throw new StatusException("未找到考试批次");
 		}
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(exam.getSchoolId())) {
@@ -221,16 +255,16 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 
 	@Override
 	public PaperInfoVo info(Long id, User user) {
-		PaperEntity paper=this.getById(id);
-		if(paper==null) {
+		PaperEntity paper = this.getById(id);
+		if (paper == null) {
 			throw new StatusException("未找到试卷结构信息");
 		}
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(paper.getSchoolId())) {
 			throw new StatusException("没有权限");
 		}
-		PaperInfoVo  vo=new PaperInfoVo();
+		PaperInfoVo vo = new PaperInfoVo();
 		BeanUtils.copyProperties(paper, vo);
-		CourseEntity course=courseService.getById(vo.getCourseId());
+		CourseEntity course = courseService.getById(vo.getCourseId());
 		vo.setCourseCode(course.getCode());
 		vo.setCourseName(course.getName());
 		vo.setStructInfo(paperDetailService.getStructInfo(vo.getId()));
@@ -241,8 +275,8 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 	@Transactional
 	@Override
 	public List<String> importSubjectStruct(Long examId, User user, MultipartFile file) {
-		ExamEntity exam=examService.getById(examId);
-		if(exam==null) {
+		ExamEntity exam = examService.getById(examId);
+		if (exam == null) {
 			throw new StatusException("未找到考试批次");
 		}
 		if (!user.getRole().equals(Role.SUPER_ADMIN) && !user.getSchoolId().equals(exam.getSchoolId())) {
@@ -250,28 +284,22 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		}
 		InputStream inputStream = null;
 		try {
-			inputStream=file.getInputStream();
+			inputStream = file.getInputStream();
 			List<DataMap> lineList = ExcelReader.create(ExcelType.XLSX, inputStream, 0).getDataMapList();
 			if (CollectionUtils.isEmpty(lineList)) {
 				throw new StatusException("Excel无内容");
 			}
-			if (1001 < lineList.size()) {
-				throw new StatusException("数据行数不能超过1000");
+			if (10001 < lineList.size()) {
+				throw new StatusException("数据行数不能超过10000");
 			}
 			List<String> failRecords = new ArrayList<>();
-			List<PaperEntity> ret = new ArrayList<>();
+			List<PaperStructInfoVo> ret = new ArrayList<>();
 			for (int i = 0; i < lineList.size(); i++) {
 				DataMap line = lineList.get(i);
 
 				StringBuilder msg = new StringBuilder();
 
-				PaperEntity imp = new PaperEntity();
-				imp.setTotalScore(0.0);
-				imp.setObjectiveScore(0.0);
-				imp.setSubjectiveScore(0.0);
-				imp.setSchoolId(exam.getSchoolId());
-				imp.setGroupFinish(false);
-				imp.setExamId(examId);
+				PaperStructInfoVo imp = new PaperStructInfoVo();
 				String code = trimAndNullIfBlank(line.getValue(0));
 				if (StringUtils.isBlank(code)) {
 					msg.append("  科目代码不能为空");
@@ -286,10 +314,96 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 					msg.append("  科目名称不能超过20个字符");
 				}
 				if (msg.length() == 0) {
-					CourseEntity course=courseService.saveOrGet(exam.getSchoolId(), code, name);
-					imp.setCourseId(course.getId());
+					CourseEntity course = courseService.saveOrGet(exam.getSchoolId(), code, name);
+					PaperEntity paper = saveOrGet(exam.getSchoolId(), examId, course.getId());
+					imp.setPaperId(paper.getId());
 				}
-
+				
+				String detailName = trimAndNullIfBlank(line.getValue(2));
+				if (StringUtils.isBlank(detailName)) {
+					msg.append("  大题名称不能为空");
+				} else if (detailName.length() > 50) {
+					msg.append("  大题名称不能超过50个字符");
+				}
+				imp.setDetailName(detailName);
+				
+				String detailNumber = trimAndNullIfBlank(line.getValue(3));
+				if (StringUtils.isBlank(detailNumber)) {
+					msg.append("  大题号不能为空");
+				} else{
+					try {
+						int n=Integer.valueOf(detailNumber);
+						if (n<=0) {
+							msg.append("  大题号不能小于0");
+						}else {
+							imp.setDetailNumber(n);
+						}
+					} catch (Exception e) {
+						msg.append("  大题号只能是整数");
+					}
+					
+				}
+				
+				String unitNumber = trimAndNullIfBlank(line.getValue(4));
+				if (StringUtils.isBlank(unitNumber)) {
+					msg.append("  小题号不能为空");
+				} else{
+					try {
+						int n=Integer.valueOf(unitNumber);
+						if (n<=0) {
+							msg.append("  小题号不能小于0");
+						}else {
+							imp.setUnitNumber(n);
+						}
+					} catch (Exception e) {
+						msg.append("  小题号只能是整数");
+					}
+					
+				}
+				
+				String score = trimAndNullIfBlank(line.getValue(5));
+				if (StringUtils.isBlank(score)) {
+					msg.append("  小题满分不能为空");
+				} else{
+					try {
+						Double n=Double.valueOf(score);
+						if (n<=0) {
+							msg.append("  小题满分不能小于0");
+						}else {
+							if (score.indexOf(".")<score.length()-2) {
+								msg.append("小题满分只能有一位小数");
+							}else {
+								imp.setScore(n);
+							}
+						}
+					} catch (Exception e) {
+						msg.append("  小题满分格式错误");
+					}
+					
+				}
+				
+				String scoreStep = trimAndNullIfBlank(line.getValue(6));
+				if (StringUtils.isBlank(scoreStep)) {
+					msg.append("  间隔分不能为空");
+				} else{
+					try {
+						Double n=Double.valueOf(scoreStep);
+						if (n<=0) {
+							msg.append("  间隔分不能小于0");
+						}else {
+							if (scoreStep.indexOf(".")<scoreStep.length()-2) {
+								msg.append("小间隔分只能有一位小数");
+							}else {
+								imp.setScoreStep(n);
+							}
+						}
+					} catch (Exception e) {
+						msg.append("  间隔分格式错误");
+					}
+					
+				}
+				
+				
 				if (msg.length() > 0) {
 					failRecords.add(newError(i + 1, msg.toString()));
 				} else {
@@ -300,17 +414,7 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 			if (CollectionUtils.isNotEmpty(failRecords)) {
 				return failRecords;
 			}
-			for (int i = 0; i < ret.size(); i++) {
-				PaperEntity cur = ret.get(i);
-				try {
-					this.save(cur);
-				} catch (DuplicateKeyException e) {
-					failRecords.add(newError(i + 1, "科目已存在"));
-				} catch (Exception e) {
-					failRecords.add(newError(i + 1, "系统异常"));
-					log.error("科目导入系统异常", e);
-				}
-			}
+			this.saveStruct(ret, user, failRecords);
 			if (CollectionUtils.isNotEmpty(failRecords)) {
 				TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
 			}
@@ -318,9 +422,9 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		} catch (StatusException e) {
 			throw e;
 		} catch (Exception e) {
-			throw new StatusException("系统错误",e);
+			throw new RuntimeException("系统错误", e);
 		} finally {
-			if(inputStream!=null) {
+			if (inputStream != null) {
 				try {
 					inputStream.close();
 				} catch (IOException e) {
@@ -329,6 +433,123 @@ public class PaperServiceImpl extends ServiceImpl<PaperDao, PaperEntity> impleme
 		}
 	}
 
+	private void saveStruct(List<PaperStructInfoVo> cards, User user, List<String> failRecords) {
+		List<StructDomain> ces = getBeans(cards);
+		checkStruct(ces, failRecords);
+		if (CollectionUtils.isNotEmpty(failRecords)) {
+			return;
+		}
+		for (StructDomain domain : ces) {
+			try {
+				paperDetailService.structSubmit(domain, user);
+			} catch (StatusException e) {
+				failRecords.add(e.getMessage());
+			} catch (Exception e) {
+				throw new RuntimeException("系统错误", e);
+			}
+		}
+	}
 
+	private void checkStruct(List<StructDomain> ces, List<String> failRecords) {
+		Map<Long, String> courseMap = new HashMap<>();
+		for (StructDomain card : ces) {
+			int lastDetailNum = 0;
+			for (PaperDetail detail : card.getStructInfo()) {
+				if (detail.getNumber() - lastDetailNum != 1) {
+					failRecords.add(
+							"科目:" + getCourseCode(courseMap, card.getPaperId()) + ",大题号" + detail.getNumber() + "错误");
+				}
+				lastDetailNum = detail.getNumber();
+				int lastUnitNum = 0;
+				for (PaperDetailUnit unit : detail.getUnits()) {
+					if (unit.getNumber() - lastUnitNum != 1) {
+						failRecords.add("科目:" + getCourseCode(courseMap, card.getPaperId()) + ",大题号:"
+								+ detail.getNumber() + ",小题号" + unit.getNumber() + "错误");
+					}
+					lastUnitNum = unit.getNumber();
+				}
+			}
+		}
+	}
+
+	private String getCourseCode(Map<Long, String> courseMap, Long paperId) {
+		if (courseMap.get(paperId) != null) {
+			return courseMap.get(paperId);
+		}
+		String code = courseService.getById(this.getById(paperId).getCourseId()).getCode();
+		courseMap.put(paperId, code);
+		return code;
+	}
+
+	private List<StructDomain> getBeans(List<PaperStructInfoVo> cards) {
+		cards.sort(new Comparator<PaperStructInfoVo>() {
+			@Override
+			public int compare(PaperStructInfoVo o1, PaperStructInfoVo o2) {
+				long c1 = o1.getPaperId();
+				long c2 = o2.getPaperId();
+				if (c1 < c2) {
+					return -1;
+				} else if (c1 > c2) {
+					return 1;
+				} else {
+					int indx1 = o1.getDetailNumber();
+					int indx2 = o2.getDetailNumber();
+					if (indx1 < indx2) {
+						return -1;
+					} else if (indx1 > indx2) {
+						return 1;
+					} else {
+						int u1 = o1.getUnitNumber();
+						int u2 = o2.getUnitNumber();
+						if (u1 < u2) {
+							return -1;
+						} else if (u1 > u2) {
+							return 1;
+						} else {
+							return 0;
+						}
+					}
+				}
+			}
+		});
+		List<StructDomain> ces = new ArrayList<>();
+		StructDomain curCard = null;
+		PaperDetail curDetail = null;
+		for (PaperStructInfoVo info : cards) {
+			if (curCard == null || !info.getPaperId().equals(curCard.getPaperId())) {
+				curCard = new StructDomain();
+				curCard.setPaperId(info.getPaperId());
+				curCard.setStructInfo(new ArrayList<>());
+				ces.add(curCard);
+				curDetail = null;
+			}
+			if (curDetail == null || !info.getDetailNumber().equals(curDetail.getNumber())) {
+				curDetail = new PaperDetail();
+				curDetail.setName(info.getDetailName());
+				curDetail.setNumber(info.getDetailNumber());
+				curDetail.setUnits(new ArrayList<>());
+				curCard.getStructInfo().add(curDetail);
+			}
+			PaperDetailUnit unit = new PaperDetailUnit();
+			curDetail.getUnits().add(unit);
+			unit.setNumber(info.getUnitNumber());
+			unit.setScore(info.getScore());
+			unit.setScoreStep(info.getScoreStep());
+		}
+		for (StructDomain sd : ces) {
+			setTotalScore(sd);
+		}
+		return ces;
+	}
+
+	private void setTotalScore(StructDomain domain) {
+		double total = 0.0;
+		for (PaperDetail detial : domain.getStructInfo()) {
+			for (PaperDetailUnit unit : detial.getUnits()) {
+				total = Calculator.add(total, unit.getScore(), 1);
+			}
+		}
+		domain.setTotalScore(total);
+	}
 
 }

+ 0 - 254
src/main/java/cn/com/qmth/mps/support/ControllerAspect.java

@@ -1,254 +0,0 @@
-package cn.com.qmth.mps.support;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.commons.collections4.MapUtils;
-import org.apache.commons.lang3.ArrayUtils;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
-import org.springframework.stereotype.Component;
-
-import cn.com.qmth.mps.enums.HttpServletRequestAttribute;
-import cn.com.qmth.mps.util.JsonMapper;
-import cn.com.qmth.mps.util.ObjectUtil;
-import cn.com.qmth.mps.util.ServletUtil;
-import cn.com.qmth.mps.util.ThreadLocalUtil;
-
-
-/**
- * spring mvc controller aspect.
- *
- */
-@Component
-@Aspect
-public class ControllerAspect {
-
-	private static final Logger LOG = LoggerFactory.getLogger(ControllerAspect.class);
-
-	@Autowired(required = false)
-	HttpMethodProcessor httpMethodProcessor;
-
-	@Autowired
-	LogProperties logProperties;
-
-	/**
-	 * 构造函数
-	 */
-	public ControllerAspect() {
-		super();
-		LOG.info("ControllerAspect init...");
-	}
-
-	private static String[] excludeFields = new String[] { "password", ".*Password" };
-
-	/**
-	 * handlerMethods
-	 *
-	 * @author
-	 */
-	@Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) "
-			+ "|| @annotation(org.springframework.web.bind.annotation.GetMapping) "
-			+ "|| @annotation(org.springframework.web.bind.annotation.PostMapping)"
-			+ "|| @annotation(org.springframework.web.bind.annotation.DeleteMapping)"
-			+ "|| @annotation(org.springframework.web.bind.annotation.PutMapping)")
-	public void handlerMethods() {
-
-	}
-
-	/**
-	 * 接口处理
-	 *
-	 * @param joinPoint
-	 * @return
-	 * @author
-	 * @throws Throwable 
-	 */
-	@Around("handlerMethods()")
-	public Object doAroundWebRequests(ProceedingJoinPoint joinPoint) throws Throwable {
-		// 获取request对象
-		HttpServletRequest request = ServletUtil.getRequest();
-		String path = request.getServletPath();
-		try {
-			if ("/".equals(request.getServletPath())) {
-				return joinPoint.proceed();
-			}
-		} catch (Throwable e) {
-			LOG.error(e.getMessage());
-			throw e;
-		}
-
-		long startTime = System.currentTimeMillis();
-		String method = request.getMethod();
-		Object[] args = joinPoint.getArgs();
-
-		if (LOG.isInfoEnabled()) {
-			StringBuilder params = new StringBuilder();
-
-			// api method params
-			if (ArrayUtils.isNotEmpty(args)) {
-				params.append(" methodParams: ");
-				for (int i = 0; i < args.length; i++) {
-					Object curArg = args[i];
-					String content = this.parseContent(curArg);
-					params.append(content);
-
-					if (i < args.length - 1) {
-						params.append(" | ");
-					}
-				}
-			}
-
-			// api url params
-			Map<String, String[]> paramMaps = request.getParameterMap();
-			if (MapUtils.isNotEmpty(paramMaps)) {
-				params.append(" urlParams: ");
-				for (Map.Entry<String, String[]> entry : paramMaps.entrySet()) {
-					String name = entry.getKey();
-					String[] values = entry.getValue();
-					params.append("&").append(name).append("=");
-
-					if (ArrayUtils.isNotEmpty(values)) {
-						if (name.toLowerCase().indexOf(excludeFields[0]) >= 0) {
-							params.append("***");
-						} else {
-							params.append(values[0]);
-						}
-					}
-				}
-			}
-			if (!isWithoutStackTrace()) {
-				LOG.info(String.format("[request][%s] - %s %s", method, path, params.toString()));
-			}
-		}
-
-		Object ret;
-		try {
-			if (null != httpMethodProcessor) {
-				httpMethodProcessor.beforeMethod(request, args);
-			}
-
-			// 执行
-			ret = joinPoint.proceed();
-
-			request.setAttribute(HttpServletRequestAttribute.$_EXCEPTION_HAPPENED.name(), new Boolean(false));
-		} catch (Throwable e) {
-			request.setAttribute(HttpServletRequestAttribute.$_EXCEPTION_HAPPENED.name(), new Boolean(true));
-
-			if (null != httpMethodProcessor) {
-				try {
-					httpMethodProcessor.onException(request, args, e);
-				} catch (Exception ex) {
-					LOG.error("processor1 - " + ex.getMessage(), ex);
-				}
-			}
-
-			LOG.error(String.format("[execute fail][%s] - %s, cost %sms, err is %s", method, path,
-					System.currentTimeMillis() - startTime, e.getMessage()));
-			throw e;
-		}
-
-		if (null != httpMethodProcessor) {
-			try {
-				httpMethodProcessor.onSuccess(request, args, ret);
-			} catch (Exception ex) {
-				LOG.error("processor2 - " + ex.getMessage(), ex);
-			}
-		}
-
-		if (null != ret && BaseResponse.class.isAssignableFrom(ret.getClass())) {
-			BaseResponse baseResponse = (BaseResponse) ret;
-			baseResponse.setCost(System.currentTimeMillis() - startTime);
-		}
-
-		if (LOG.isDebugEnabled() && logProperties.isNormalResponseLogEnable()) {
-			if (ret == null) {
-				LOG.debug("status = ok, responseMsg = void");
-			} else if (ret instanceof ResponseEntity) {
-				ResponseEntity<?> re = (ResponseEntity<?>) ret;
-				Object body = re.getBody();
-
-				String content = this.parseContent(body);
-				LOG.debug(String.format("status = %s, responseMsg = %s", re.getStatusCodeValue(), content));
-			} else {
-				String content = this.parseContent(ret);
-				LOG.debug(String.format("status = ok, responseMsg = %s", content));
-			}
-		}
-
-		HttpServletResponse response = ServletUtil.getResponse();
-		response.setHeader("Trace-Id", ThreadLocalUtil.getTraceId());
-		response.setHeader("cost", String.valueOf(System.currentTimeMillis() - startTime));
-		if (!isWithoutStackTrace()) {
-			LOG.info(String.format("[response][%s] - %s, cost %sms", method, path,
-					System.currentTimeMillis() - startTime));
-		}
-		return ret;
-	}
-	
-	private boolean isWithoutStackTrace() {
-		HttpServletRequest request = ServletUtil.getRequest();
-		ApiInfo apiInfo = (ApiInfo) request.getAttribute(HttpServletRequestAttribute.$_API_INFO.name());
-		return apiInfo.isWithoutStackTrace();
-	}
-
-	private String parseContent(Object obj) {
-		if (obj == null) {
-			// content empty...
-			return "";
-		}
-
-		if (ObjectUtil.isBaseDataType(obj.getClass()) || obj instanceof String) {
-			return obj.toString();
-		}
-
-		boolean jsonEnable = false;
-		if (obj instanceof Collection) {
-			jsonEnable = true;
-		} else if (obj instanceof Map) {
-			jsonEnable = true;
-		} else if (obj instanceof Serializable) {
-			String classPath = obj.getClass().getName();
-
-			if (classPath.startsWith("org.springframework.data.domain.PageImpl") || classPath.startsWith("cn.com.qmth")
-					|| classPath.startsWith("com.qmth")) {
-				jsonEnable = true;
-			}
-		}
-
-		if (!jsonEnable) {
-			// content ignore...
-			return "...";
-		}
-
-		String content = null;
-		try {
-			// content to json
-			content = new JsonMapper().toJson(obj);
-		} catch (Exception e) {
-			LOG.warn("parseContent " + e.getMessage());
-		}
-
-		if (content == null) {
-			return "......";
-		}
-
-		if (content.length() > logProperties.getResponseLogJsonMaxSize()) {
-			// content too large...
-			return content.substring(0, logProperties.getResponseLogJsonMaxSize()) + " [MORE...]";
-		}
-
-		return content;
-	}
-
-}

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

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

+ 14 - 6
src/main/java/cn/com/qmth/mps/vo/paper/PaperStructInfoVo.java

@@ -3,6 +3,8 @@ package cn.com.qmth.mps.vo.paper;
 import io.swagger.annotations.ApiModelProperty;
 
 public class PaperStructInfoVo {
+	@ApiModelProperty("试卷结构Id")
+	private Long paperId;
 	@ApiModelProperty("科目代码")
 	private String courseCode;
 	@ApiModelProperty("科目名称")
@@ -12,7 +14,7 @@ public class PaperStructInfoVo {
 	@ApiModelProperty("大题号")
 	private Integer detailNumber;
 	@ApiModelProperty("小题号")
-	private Integer deatailUnitNumber;
+	private Integer unitNumber;
 	@ApiModelProperty("小题满分")
 	private Double score;
 	@ApiModelProperty("给分间隔")
@@ -41,11 +43,12 @@ public class PaperStructInfoVo {
 	public void setDetailNumber(Integer detailNumber) {
 		this.detailNumber = detailNumber;
 	}
-	public Integer getDeatailUnitNumber() {
-		return deatailUnitNumber;
+	
+	public Integer getUnitNumber() {
+		return unitNumber;
 	}
-	public void setDeatailUnitNumber(Integer deatailUnitNumber) {
-		this.deatailUnitNumber = deatailUnitNumber;
+	public void setUnitNumber(Integer unitNumber) {
+		this.unitNumber = unitNumber;
 	}
 	public Double getScore() {
 		return score;
@@ -59,6 +62,11 @@ public class PaperStructInfoVo {
 	public void setScoreStep(Double scoreStep) {
 		this.scoreStep = scoreStep;
 	}
-	
+	public Long getPaperId() {
+		return paperId;
+	}
+	public void setPaperId(Long paperId) {
+		this.paperId = paperId;
+	}
 	
 }