|
@@ -8,6 +8,7 @@ import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.distributed.print.business.bean.dto.ExaminationExportDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.FieldsDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
|
+import com.qmth.distributed.print.business.bean.params.SerialNumberParams;
|
|
|
import com.qmth.distributed.print.business.entity.*;
|
|
|
import com.qmth.distributed.print.business.enums.ExamStatusEnum;
|
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
@@ -26,6 +27,8 @@ import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
+import org.springframework.data.redis.support.atomic.RedisAtomicLong;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -92,6 +95,9 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
@Resource
|
|
|
CreatePdfUtil createPdfUtil;
|
|
|
|
|
|
+ @Resource
|
|
|
+ RedisTemplate<String, Object> redisTemplate;
|
|
|
+
|
|
|
/**
|
|
|
* 创建pdf逻辑
|
|
|
*
|
|
@@ -317,7 +323,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional
|
|
|
@Override
|
|
|
public Map<String, Object> executeImportExaminationLogic(Map<String, Object> map) throws Exception {
|
|
|
TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
|
|
@@ -474,29 +480,41 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
|
|
|
|
// 删除印刷计划下的考务数据
|
|
|
examDetailService.deleteExaminationData(printPlanId);
|
|
|
- // 组装exam_detail数据
|
|
|
- examDetailService.disposeExamDetailByExaminationExcel(dataList, userId);
|
|
|
- // 组装exam_detail_course数据
|
|
|
- examDetailService.disposeExamDetailCourseByExaminationExcel(dataList, userId);
|
|
|
- // 组装exam_student数据
|
|
|
- examDetailService.disposeExamStudentByExaminationExcel(dataList, userId);
|
|
|
-
|
|
|
- List<Map<String, Object>> checkList = dataList.stream().flatMap(e -> {
|
|
|
- Map<String, Object> tmp = new HashMap<>();
|
|
|
- tmp.put("schoolId", e.get("schoolId"));
|
|
|
- tmp.put("courseCode", e.get("courseCode"));
|
|
|
- tmp.put("paperNumber", e.get("paperNumber"));
|
|
|
- return Stream.of(tmp);
|
|
|
- }).distinct().collect(Collectors.toList());
|
|
|
- for (Map<String, Object> stringObjectMap : checkList) {
|
|
|
- Long checkSchoolId = SystemConstant.convertIdToLong(String.valueOf(stringObjectMap.get("schoolId")));
|
|
|
- String checkCourseCode = String.valueOf(stringObjectMap.get("courseCode"));
|
|
|
- String checkPaperNumber = String.valueOf(stringObjectMap.get("paperNumber"));
|
|
|
- SysUser user = (SysUser) map.get(SystemConstant.USER);
|
|
|
- user.setSchoolId(schoolId);
|
|
|
- commonService.checkData(checkSchoolId, checkCourseCode, checkPaperNumber, user);
|
|
|
+
|
|
|
+
|
|
|
+ SerialNumberParams serialNumberParams = new SerialNumberParams("packageCode-","p",6);
|
|
|
+ String key = serialNumberParams.getModel() + serialNumberParams.getPrefix();
|
|
|
+ RedisAtomicLong counter = new RedisAtomicLong(key, Objects.requireNonNull(redisTemplate.getConnectionFactory()));
|
|
|
+ Long value = counter.get();
|
|
|
+ try {
|
|
|
+ // 组装exam_detail数据
|
|
|
+ examDetailService.disposeExamDetailByExaminationExcel(dataList, userId , serialNumberParams);
|
|
|
+ // 组装exam_detail_course数据
|
|
|
+ examDetailService.disposeExamDetailCourseByExaminationExcel(dataList, userId);
|
|
|
+ // 组装exam_student数据
|
|
|
+ examDetailService.disposeExamStudentByExaminationExcel(dataList, userId);
|
|
|
+
|
|
|
+ List<Map<String, Object>> checkList = dataList.stream().flatMap(e -> {
|
|
|
+ Map<String, Object> tmp = new HashMap<>();
|
|
|
+ tmp.put("schoolId", e.get("schoolId"));
|
|
|
+ tmp.put("courseCode", e.get("courseCode"));
|
|
|
+ tmp.put("paperNumber", e.get("paperNumber"));
|
|
|
+ return Stream.of(tmp);
|
|
|
+ }).distinct().collect(Collectors.toList());
|
|
|
+ for (Map<String, Object> stringObjectMap : checkList) {
|
|
|
+ Long checkSchoolId = SystemConstant.convertIdToLong(String.valueOf(stringObjectMap.get("schoolId")));
|
|
|
+ String checkCourseCode = String.valueOf(stringObjectMap.get("courseCode"));
|
|
|
+ String checkPaperNumber = String.valueOf(stringObjectMap.get("paperNumber"));
|
|
|
+ SysUser user = (SysUser) map.get(SystemConstant.USER);
|
|
|
+ user.setSchoolId(schoolId);
|
|
|
+ commonService.checkData(checkSchoolId, checkCourseCode, checkPaperNumber, user);
|
|
|
+ }
|
|
|
+ map.put("dataCount", dataList.size());
|
|
|
+ }catch (Exception e){
|
|
|
+ redisTemplate.opsForValue().set(key,value);
|
|
|
+ throw new RuntimeException(e);
|
|
|
}
|
|
|
- map.put("dataCount", dataList.size());
|
|
|
+
|
|
|
return map;
|
|
|
}
|
|
|
}
|