|
@@ -6,12 +6,11 @@ import com.qmth.boot.api.exception.ApiException;
|
|
import com.qmth.boot.tools.excel.ExcelReader;
|
|
import com.qmth.boot.tools.excel.ExcelReader;
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
import com.qmth.distributed.print.business.bean.excel.PaperStructDto;
|
|
import com.qmth.distributed.print.business.bean.excel.PaperStructDto;
|
|
|
|
+import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
|
|
|
|
+import com.qmth.distributed.print.business.bean.result.report.PaperStructDimensionResult;
|
|
import com.qmth.distributed.print.business.entity.TCPaperStruct;
|
|
import com.qmth.distributed.print.business.entity.TCPaperStruct;
|
|
import com.qmth.distributed.print.business.mapper.TCPaperStructMapper;
|
|
import com.qmth.distributed.print.business.mapper.TCPaperStructMapper;
|
|
-import com.qmth.distributed.print.business.service.PrintCommonService;
|
|
|
|
-import com.qmth.distributed.print.business.service.TCFinalScoreService;
|
|
|
|
-import com.qmth.distributed.print.business.service.TCPaperStructService;
|
|
|
|
-import com.qmth.distributed.print.business.service.TRBasicInfoService;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
@@ -24,6 +23,7 @@ import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -60,6 +60,9 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
|
|
@Resource
|
|
@Resource
|
|
RedisUtil redisUtil;
|
|
RedisUtil redisUtil;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CourseTargetService courseTargetService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据考试id/课程编码/试卷编码查询数据库数据
|
|
* 根据考试id/课程编码/试卷编码查询数据库数据
|
|
*
|
|
*
|
|
@@ -181,7 +184,7 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 同步试卷蓝图结构
|
|
|
|
|
|
+ * 同步试卷结构
|
|
*
|
|
*
|
|
* @param examId
|
|
* @param examId
|
|
* @param courseCode
|
|
* @param courseCode
|
|
@@ -191,8 +194,56 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public Map<String, String> paperStructDimensionSync(Long examId, String courseCode, String paperNumber) throws IOException {
|
|
|
|
- return null;
|
|
|
|
|
|
+ public Map<String, String> paperStructSync(Long examId, String courseCode, String paperNumber) throws IOException {
|
|
|
|
+ Map<String, String> messageMap = new LinkedHashMap<>();
|
|
|
|
+ try {
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ StringJoiner errorData = new StringJoiner("");
|
|
|
|
+ StringJoiner successData = new StringJoiner("");
|
|
|
|
+ List<PaperStructDimensionResult> paperStructDimensionResultList = courseTargetService.findTikuPaperStruct(examId, paperNumber);
|
|
|
|
+ if (!CollectionUtils.isEmpty(paperStructDimensionResultList)) {
|
|
|
|
+ for (PaperStructDimensionResult paperStructDimensionResult : paperStructDimensionResultList) {
|
|
|
|
+ Objects.requireNonNull(paperStructDimensionResult.getMainNumber(), "大题号为空");
|
|
|
|
+ Objects.requireNonNull(paperStructDimensionResult.getSubNumber(), "小题号为空");
|
|
|
|
+ if (!CollectionUtils.isEmpty(paperStructDimensionResult.getTargetList()) && paperStructDimensionResult.getTargetList().size() > 1) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ successData.add("共同步").add(paperStructDimensionResultList.size() + "").add("条数据");
|
|
|
|
+ TCPaperStruct tcPaperStructDb = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, examId).eq(TCPaperStruct::getCourseCode, courseCode).eq(TCPaperStruct::getPaperNumber, paperNumber));
|
|
|
|
+ TCPaperStruct tcPaperStruct = null;
|
|
|
|
+ if (Objects.nonNull(tcPaperStructDb) && Objects.nonNull(tcPaperStructDb.getPaperStructDimension())) {
|
|
|
|
+ tcPaperStruct = new TCPaperStruct();
|
|
|
|
+ BeanUtils.copyProperties(tcPaperStructDb, tcPaperStruct);
|
|
|
|
+ tcPaperStruct.setPaperStructDimension(JacksonUtil.parseJson(paperStructDimensionResultList));
|
|
|
|
+
|
|
|
|
+ if (!tcPaperStruct.equals(tcPaperStructDb)) {
|
|
|
|
+ trBasicInfoService.clearReportData(examId, courseCode, paperNumber, false);
|
|
|
|
+ }
|
|
|
|
+ tcPaperStruct.updateInfo(sysUser.getId());
|
|
|
|
+ } else {
|
|
|
|
+ MarkPaper markPaper = printCommonService.getMarkPaper(examId, paperNumber);
|
|
|
|
+ CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
|
|
|
|
+ tcPaperStruct = new TCPaperStruct(examId, courseCode, markPaper.getCourseName(), paperNumber, JacksonUtil.parseJson(paperStructDimensionResultList), sysUser.getId(), courseWeightResult.getDimensionSign());
|
|
|
|
+ trBasicInfoService.clearReportData(examId, courseCode, paperNumber, false);
|
|
|
|
+ }
|
|
|
|
+ tcPaperStructService.saveOrUpdate(tcPaperStruct);
|
|
|
|
+ }
|
|
|
|
+ messageMap.put(SystemConstant.SUCCESS, successData.length() > 0 ? successData.toString() : "无");
|
|
|
|
+ messageMap.put(SystemConstant.EXCEL_ERROR, errorData.length() > 0 ? errorData.toString() : "无");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
+ if (e instanceof DuplicateKeyException) {
|
|
|
|
+ String errorColumn = e.getCause().toString();
|
|
|
|
+ String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
|
|
|
|
+ throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
|
|
|
|
+ } else if (e instanceof ApiException) {
|
|
|
|
+ ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
|
|
|
|
+ } else {
|
|
|
|
+ ResultUtil.error(e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return messageMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|