|
@@ -7,6 +7,7 @@
|
|
|
|
|
|
package cn.com.qmth.examcloud.core.print.service.impl;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.base.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.OrderBuilder;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SearchBuilder;
|
|
|
import cn.com.qmth.examcloud.core.print.common.jpa.SpecUtils;
|
|
@@ -23,6 +24,10 @@ import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.domain.Specification;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static cn.com.qmth.examcloud.core.print.common.Constants.PRT_CODE_500;
|
|
|
+
|
|
|
/**
|
|
|
* 印刷项目相关接口
|
|
|
*
|
|
@@ -61,11 +66,63 @@ public class PrintingProjectServiceImpl implements PrintingProjectService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void savePrintingProject(PrintingProjectInfo info) {
|
|
|
- PrintingProject entity = PrintingProjectConvert.of(info);
|
|
|
- Check.isNull(entity.getOrgId(), "学校机构ID不能为空!");
|
|
|
- Check.isNull(entity.getExamId(), "考试ID不能为空!");
|
|
|
+ public void updatePrintingProject(PrintingProjectInfo info) {
|
|
|
+ Check.isNull(info.getId(), "ID不能为空!");
|
|
|
+ Check.isNull(info.getSupplierId(), "供应商ID不能为空!");
|
|
|
+ Check.isBlank(info.getSupplierName(), "供应商名称不能为空!");
|
|
|
+ Check.isNull(info.getPmId(), "项目经理ID不能为空!");
|
|
|
+ Check.isBlank(info.getPmName(), "项目经理名称不能为空!");
|
|
|
+ Check.isNull(info.getPrepareStartTime(), "准备开始时间不能为空!");
|
|
|
+ Check.isNull(info.getPrepareEndTime(), "准备结束时间不能为空!");
|
|
|
+ Check.isNull(info.getPrintStartTime(), "印刷开始时间不能为空!");
|
|
|
+ Check.isNull(info.getPrintEndTime(), "印刷结束时间不能为空!");
|
|
|
+ Check.isNull(info.getMailStartTime(), "邮寄开始时间不能为空!");
|
|
|
+ Check.isNull(info.getMailEndTime(), "邮寄结束时间不能为空!");
|
|
|
+
|
|
|
+ PrintingProject entity = printingProjectRepository.findOne(info.getId());
|
|
|
+ if (entity == null) {
|
|
|
+ throw new StatusException(PRT_CODE_500, "印刷项目信息不存在!");
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setSupplierId(info.getSupplierId());
|
|
|
+ entity.setSupplierName(info.getSupplierName());
|
|
|
+ entity.setPmId(info.getPmId());
|
|
|
+ entity.setPmName(info.getPmName());
|
|
|
+ entity.setPrepareStartTime(info.getPrepareStartTime());
|
|
|
+ entity.setPrepareEndTime(info.getPrepareEndTime());
|
|
|
+ entity.setPrintStartTime(info.getPrintStartTime());
|
|
|
+ entity.setPrintEndTime(info.getPrintEndTime());
|
|
|
+ entity.setMailStartTime(info.getMailStartTime());
|
|
|
+ entity.setMailEndTime(info.getMailEndTime());
|
|
|
printingProjectRepository.save(entity);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void syncPrintingProject(PrintingProjectInfo info) {
|
|
|
+ Check.isNull(info.getOrgId(), "学校ID不能为空!");
|
|
|
+ Check.isBlank(info.getOrgName(), "学校名称不能为空!");
|
|
|
+ Check.isNull(info.getExamId(), "考试ID不能为空!");
|
|
|
+ Check.isBlank(info.getExamName(), "考试名称不能为空!");
|
|
|
+
|
|
|
+ SearchBuilder searches = new SearchBuilder()
|
|
|
+ .eq("orgId", info.getOrgId())
|
|
|
+ .eq("examId", info.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);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新信息
|
|
|
+ for (PrintingProject project : projects) {
|
|
|
+ project.setOrgName(info.getOrgName());
|
|
|
+ project.setExamName(info.getExamName());
|
|
|
+ }
|
|
|
+ printingProjectRepository.save(projects);
|
|
|
+ }
|
|
|
+
|
|
|
}
|