|
@@ -14,6 +14,7 @@ import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
|
import cn.com.qmth.examcloud.core.print.common.utils.Check;
|
|
|
import cn.com.qmth.examcloud.core.print.entity.PrintingProject;
|
|
|
import cn.com.qmth.examcloud.core.print.repository.PrintingProjectRepository;
|
|
|
+import cn.com.qmth.examcloud.core.print.service.CommonService;
|
|
|
import cn.com.qmth.examcloud.core.print.service.PrintingProjectService;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.printingproject.OrgExamInfo;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.printingproject.PrintingProjectConvert;
|
|
@@ -27,13 +28,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
-import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
|
|
-import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.sql.PreparedStatement;
|
|
|
-import java.sql.SQLException;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
|
|
@@ -50,6 +47,8 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
@Autowired
|
|
|
private PrintingProjectRepository printingProjectRepository;
|
|
|
@Autowired
|
|
|
+ private CommonService commonService;
|
|
|
+ @Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Override
|
|
@@ -158,6 +157,18 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
printingProjectRepository.save(project);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncAllPrintingProject() {
|
|
|
+ //获取所有"传统"考试列表
|
|
|
+ log.debug("syncAllPrintingProject...");
|
|
|
+ List<OrgExamInfo> list = commonService.getTraditionExamList();
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ for (OrgExamInfo info : list) {
|
|
|
+ syncPrintingProject(info);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void syncPrintingProjectOrgName(Long orgId, String orgName) {
|
|
|
if (orgId == null || StringUtils.isBlank(orgName)) {
|
|
@@ -194,32 +205,4 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
jdbcTemplate.update(updateSql);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void initAllData() {
|
|
|
- //查询所有传统考试记录(实际数据未超过100条)
|
|
|
- StringBuilder sql = new StringBuilder()
|
|
|
- .append("SELECT em.id as examId,em.name as examName,em.root_org_id as orgId,org.name as orgName FROM ec_e_exam em ")
|
|
|
- .append("INNER JOIN ec_b_org org ON org.id = em.root_org_id WHERE em.exam_type = 'TRADITION' ORDER BY em.id ASC");
|
|
|
- List<OrgExamInfo> list = jdbcTemplate.query(sql.toString(), new BeanPropertyRowMapper(OrgExamInfo.class));
|
|
|
-
|
|
|
- //批量保存数据
|
|
|
- String insertSql = "INSERT INTO ec_prt_project(exam_id,exam_name,org_id,org_name,completed,creation_time,update_time) VALUES (?,?,?,?,?,NOW(),NOW())";
|
|
|
- jdbcTemplate.batchUpdate(insertSql, new BatchPreparedStatementSetter() {
|
|
|
- @Override
|
|
|
- public void setValues(PreparedStatement ps, int i) throws SQLException {
|
|
|
- OrgExamInfo row = list.get(i);
|
|
|
- ps.setLong(1, row.getExamId());
|
|
|
- ps.setString(2, row.getExamName());
|
|
|
- ps.setLong(3, row.getOrgId());
|
|
|
- ps.setString(4, row.getOrgName());
|
|
|
- ps.setBoolean(5, false);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int getBatchSize() {
|
|
|
- return list.size();
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
}
|