|
@@ -35,6 +35,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
import static cn.com.qmth.examcloud.core.print.common.Constants.SYS_CODE_500;
|
|
import static cn.com.qmth.examcloud.core.print.common.Constants.SYS_CODE_500;
|
|
|
|
|
|
@@ -83,11 +84,11 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
@Override
|
|
@Override
|
|
public PrintingProjectInfo getPrintingProjectById(Long id) {
|
|
public PrintingProjectInfo getPrintingProjectById(Long id) {
|
|
Check.isNull(id, "印刷项目ID不能为空!");
|
|
Check.isNull(id, "印刷项目ID不能为空!");
|
|
- PrintingProject project = printingProjectRepository.findOne(id);
|
|
|
|
- if (project == null) {
|
|
|
|
|
|
+ Optional<PrintingProject> optional = printingProjectRepository.findById(id);
|
|
|
|
+ if (!optional.isPresent()) {
|
|
throw new StatusException(SYS_CODE_500, "印刷项目信息不存在!");
|
|
throw new StatusException(SYS_CODE_500, "印刷项目信息不存在!");
|
|
}
|
|
}
|
|
- return PrintingProjectConvert.of(project);
|
|
|
|
|
|
+ return PrintingProjectConvert.of(optional.get());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -96,7 +97,11 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
.eq("orgId", orgId)
|
|
.eq("orgId", orgId)
|
|
.eq("examId", examId);
|
|
.eq("examId", examId);
|
|
Specification<PrintingProject> spec = SpecUtils.buildSearchers(PrintingProject.class, searches.build());
|
|
Specification<PrintingProject> spec = SpecUtils.buildSearchers(PrintingProject.class, searches.build());
|
|
- return printingProjectRepository.findOne(spec);
|
|
|
|
|
|
+ Optional<PrintingProject> optional = printingProjectRepository.findOne(spec);
|
|
|
|
+ if (optional.isPresent()) {
|
|
|
|
+ return optional.get();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -113,11 +118,11 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
Check.isNull(info.getMailStartTime(), "邮寄开始时间不能为空!");
|
|
Check.isNull(info.getMailStartTime(), "邮寄开始时间不能为空!");
|
|
Check.isNull(info.getMailEndTime(), "邮寄结束时间不能为空!");
|
|
Check.isNull(info.getMailEndTime(), "邮寄结束时间不能为空!");
|
|
|
|
|
|
- PrintingProject entity = printingProjectRepository.findOne(info.getId());
|
|
|
|
- if (entity == null) {
|
|
|
|
|
|
+ Optional<PrintingProject> optional = printingProjectRepository.findById(info.getId());
|
|
|
|
+ if (!optional.isPresent()) {
|
|
throw new StatusException(SYS_CODE_500, "印刷项目信息不存在!");
|
|
throw new StatusException(SYS_CODE_500, "印刷项目信息不存在!");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ PrintingProject entity = optional.get();
|
|
entity.setSupplierId(info.getSupplierId());
|
|
entity.setSupplierId(info.getSupplierId());
|
|
entity.setSupplierName(info.getSupplierName());
|
|
entity.setSupplierName(info.getSupplierName());
|
|
entity.setPmId(info.getPmId());
|
|
entity.setPmId(info.getPmId());
|
|
@@ -144,9 +149,10 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
Specification<PrintingProject> spec = SpecUtils.buildSearchers(PrintingProject.class, searches.build());
|
|
Specification<PrintingProject> spec = SpecUtils.buildSearchers(PrintingProject.class, searches.build());
|
|
|
|
|
|
//某学校某考试仅当作一个项目
|
|
//某学校某考试仅当作一个项目
|
|
- PrintingProject project = printingProjectRepository.findOne(spec);
|
|
|
|
- if (project != null) {
|
|
|
|
|
|
+ Optional<PrintingProject> optional = printingProjectRepository.findOne(spec);
|
|
|
|
+ if (optional.isPresent()) {
|
|
//更新学校名称、考试名称等信息
|
|
//更新学校名称、考试名称等信息
|
|
|
|
+ PrintingProject project = optional.get();
|
|
project.setOrgName(examInfo.getOrgName());
|
|
project.setOrgName(examInfo.getOrgName());
|
|
project.setExamName(examInfo.getExamName());
|
|
project.setExamName(examInfo.getExamName());
|
|
printingProjectRepository.save(project);
|
|
printingProjectRepository.save(project);
|
|
@@ -154,7 +160,7 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
}
|
|
}
|
|
|
|
|
|
//新增印刷项目信息
|
|
//新增印刷项目信息
|
|
- project = new PrintingProject();
|
|
|
|
|
|
+ PrintingProject project = new PrintingProject();
|
|
project.setOrgId(examInfo.getOrgId());
|
|
project.setOrgId(examInfo.getOrgId());
|
|
project.setOrgName(examInfo.getOrgName());
|
|
project.setOrgName(examInfo.getOrgName());
|
|
project.setExamId(examInfo.getExamId());
|
|
project.setExamId(examInfo.getExamId());
|