|
@@ -19,6 +19,7 @@ import cn.com.qmth.examcloud.core.print.service.bean.OrgExamInfo;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectConvert;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectInfo;
|
|
|
import cn.com.qmth.examcloud.core.print.service.bean.PrintingProjectQuery;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
@@ -116,31 +117,33 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void syncPrintingProject(PrintingProjectInfo info) {
|
|
|
- Check.isNull(info.getOrgId(), "学校ID不能为空!");
|
|
|
- Check.isBlank(info.getOrgName(), "学校名称不能为空!");
|
|
|
- Check.isNull(info.getExamId(), "考试ID不能为空!");
|
|
|
- Check.isBlank(info.getExamName(), "考试名称不能为空!");
|
|
|
+ public void syncPrintingProject(OrgExamInfo examInfo) {
|
|
|
+ Check.isNull(examInfo.getOrgId(), "学校ID不能为空!");
|
|
|
+ Check.isBlank(examInfo.getOrgName(), "学校名称不能为空!");
|
|
|
+ Check.isNull(examInfo.getExamId(), "考试ID不能为空!");
|
|
|
+ Check.isBlank(examInfo.getExamName(), "考试名称不能为空!");
|
|
|
|
|
|
SearchBuilder searches = new SearchBuilder()
|
|
|
- .eq("orgId", info.getOrgId())
|
|
|
- .eq("examId", info.getExamId());
|
|
|
+ .eq("orgId", examInfo.getOrgId())
|
|
|
+ .eq("examId", examInfo.getExamId());
|
|
|
Specification<PrintingProject> spec = SpecUtils.buildSearchers(PrintingProject.class, searches.build());
|
|
|
|
|
|
List<PrintingProject> projects = printingProjectRepository.findAll(spec);
|
|
|
- if (projects == null || projects.isEmpty()) {
|
|
|
- //新增信息
|
|
|
- PrintingProject project = PrintingProjectConvert.of(info);
|
|
|
- printingProjectRepository.save(project);
|
|
|
+ if (projects != null && !projects.isEmpty()) {
|
|
|
+ for (PrintingProject project : projects) {
|
|
|
+ //更新学校名称、考试名称等信息
|
|
|
+ project.setOrgName(examInfo.getOrgName());
|
|
|
+ project.setExamName(examInfo.getExamName());
|
|
|
+ }
|
|
|
+ printingProjectRepository.save(projects);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //更新信息
|
|
|
- for (PrintingProject project : projects) {
|
|
|
- project.setOrgName(info.getOrgName());
|
|
|
- project.setExamName(info.getExamName());
|
|
|
- }
|
|
|
- printingProjectRepository.save(projects);
|
|
|
+ //新增印刷项目信息
|
|
|
+ PrintingProject project = new PrintingProject();
|
|
|
+ BeanUtils.copyProperties(examInfo, project);
|
|
|
+ project.setCompleted(false);
|
|
|
+ printingProjectRepository.save(project);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -151,7 +154,7 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
List<OrgExamInfo> list = jdbcTemplate.query(selectSql, new BeanPropertyRowMapper(OrgExamInfo.class));
|
|
|
|
|
|
//批量保存数据
|
|
|
- String insertSql = "INSERT INTO ec_prt_project(exam_id,exam_name,org_id,org_name,creation_time,update_time) VALUES (?,?,?,?,NOW(),NOW())";
|
|
|
+ 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 {
|
|
@@ -160,6 +163,7 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
ps.setString(2, row.getExamName());
|
|
|
ps.setLong(3, row.getOrgId());
|
|
|
ps.setString(4, row.getOrgName());
|
|
|
+ ps.setBoolean(5, false);
|
|
|
}
|
|
|
|
|
|
@Override
|