|
@@ -5,11 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.qmth.distributed.print.business.bean.params.DeleteParams;
|
|
|
|
+import com.qmth.distributed.print.business.bean.params.PrintPlanParams;
|
|
import com.qmth.distributed.print.business.bean.result.PrintPlanBrief;
|
|
import com.qmth.distributed.print.business.bean.result.PrintPlanBrief;
|
|
import com.qmth.distributed.print.business.bean.result.PrintPlanResult;
|
|
import com.qmth.distributed.print.business.bean.result.PrintPlanResult;
|
|
-import com.qmth.distributed.print.business.bean.result.PrintPlanTemplateResult;
|
|
|
|
import com.qmth.distributed.print.business.bean.result.TemplatePrintInfoResult;
|
|
import com.qmth.distributed.print.business.bean.result.TemplatePrintInfoResult;
|
|
-import com.qmth.distributed.print.business.entity.ExamDetail;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.entity.BasicSchool;
|
|
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
import com.qmth.distributed.print.business.entity.ExamPrintPlan;
|
|
import com.qmth.distributed.print.business.entity.SysOrg;
|
|
import com.qmth.distributed.print.business.entity.SysOrg;
|
|
import com.qmth.distributed.print.business.entity.SysUser;
|
|
import com.qmth.distributed.print.business.entity.SysUser;
|
|
@@ -18,7 +19,11 @@ import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.TemplateTypeEnum;
|
|
import com.qmth.distributed.print.business.enums.TemplateTypeEnum;
|
|
import com.qmth.distributed.print.business.mapper.ExamPrintPlanMapper;
|
|
import com.qmth.distributed.print.business.mapper.ExamPrintPlanMapper;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
|
+import com.qmth.distributed.print.business.util.ServletUtil;
|
|
|
|
+import com.qmth.distributed.print.common.contant.SystemConstant;
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
@@ -49,6 +54,8 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
private SysOrgService sysOrgService;
|
|
private SysOrgService sysOrgService;
|
|
@Resource
|
|
@Resource
|
|
private BasicTemplateOrgService basicTemplateOrgService;
|
|
private BasicTemplateOrgService basicTemplateOrgService;
|
|
|
|
+ @Resource
|
|
|
|
+ private BasicSchoolService basicSchoolService;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
@@ -56,7 +63,7 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
IPage<PrintPlanResult> page = examPrintPlanMapper.findPrintPlanPage(new Page<>(pageNumber, pageSize), schoolId, name, status, startTime, endTime);
|
|
IPage<PrintPlanResult> page = examPrintPlanMapper.findPrintPlanPage(new Page<>(pageNumber, pageSize), schoolId, name, status, startTime, endTime);
|
|
List<PrintPlanResult> list = page.getRecords();
|
|
List<PrintPlanResult> list = page.getRecords();
|
|
for (PrintPlanResult printPlanResult : list) {
|
|
for (PrintPlanResult printPlanResult : list) {
|
|
- List<Map> variableContent = JSONObject.parseArray(printPlanResult.getVariableContentTemp(),Map.class);
|
|
|
|
|
|
+ List<Map> variableContent = JSONObject.parseArray(printPlanResult.getVariableContentTemp(), Map.class);
|
|
List<Map> ordinaryContent = JSONObject.parseArray(printPlanResult.getOrdinaryContentTemp(),Map.class);
|
|
List<Map> ordinaryContent = JSONObject.parseArray(printPlanResult.getOrdinaryContentTemp(),Map.class);
|
|
printPlanResult.setVariableContent(variableContent);
|
|
printPlanResult.setVariableContent(variableContent);
|
|
printPlanResult.setOrdinaryContent(ordinaryContent);
|
|
printPlanResult.setOrdinaryContent(ordinaryContent);
|
|
@@ -73,11 +80,11 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
@Override
|
|
@Override
|
|
public List<PrintPlanBrief> printPlanBriefQuery(String param) {
|
|
public List<PrintPlanBrief> printPlanBriefQuery(String param) {
|
|
List<PrintPlanBrief> printPlanBriefList = new ArrayList<>();
|
|
List<PrintPlanBrief> printPlanBriefList = new ArrayList<>();
|
|
- List<ExamPrintPlan> examPrintPlanList = this.list(new QueryWrapper<ExamPrintPlan>().lambda().like(ExamPrintPlan::getName,param));
|
|
|
|
|
|
+ List<ExamPrintPlan> examPrintPlanList = this.list(new QueryWrapper<ExamPrintPlan>().lambda().like(ExamPrintPlan::getName, param));
|
|
for (ExamPrintPlan examPrintPlan : examPrintPlanList) {
|
|
for (ExamPrintPlan examPrintPlan : examPrintPlanList) {
|
|
Long id = examPrintPlan.getId();
|
|
Long id = examPrintPlan.getId();
|
|
String name = examPrintPlan.getName();
|
|
String name = examPrintPlan.getName();
|
|
- printPlanBriefList.add(new PrintPlanBrief(id,name));
|
|
|
|
|
|
+ printPlanBriefList.add(new PrintPlanBrief(id, name));
|
|
}
|
|
}
|
|
return printPlanBriefList;
|
|
return printPlanBriefList;
|
|
}
|
|
}
|
|
@@ -86,35 +93,35 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> printPlanTemplateDatasource(Long schoolId, Long userId) {
|
|
public Map<String, Object> printPlanTemplateDatasource(Long schoolId, Long userId) {
|
|
//1.根据userId,schoolId查出orgId(应该从requestUser 获取)
|
|
//1.根据userId,schoolId查出orgId(应该从requestUser 获取)
|
|
- List<SysUser> requestUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getId,userId).eq(SysUser::getSchoolId,schoolId));
|
|
|
|
- if (requestUserList.size() != 1){
|
|
|
|
|
|
+ List<SysUser> requestUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda().eq(SysUser::getId, userId).eq(SysUser::getSchoolId, schoolId));
|
|
|
|
+ if (requestUserList.size() != 1) {
|
|
throw ExceptionResultEnum.ERROR.exception("未找到用户信息");
|
|
throw ExceptionResultEnum.ERROR.exception("未找到用户信息");
|
|
}
|
|
}
|
|
SysUser requestUser = requestUserList.get(0);
|
|
SysUser requestUser = requestUserList.get(0);
|
|
Long orgId = requestUser.getOrgId();
|
|
Long orgId = requestUser.getOrgId();
|
|
|
|
|
|
//2.根据orgId查询他的所有叶子id 并把这些id放入List<Long> ids
|
|
//2.根据orgId查询他的所有叶子id 并把这些id放入List<Long> ids
|
|
- List<Long> orgIds = new ArrayList<>();
|
|
|
|
- if ((orgId == null || orgId == 0) && (schoolId == null || schoolId == 0)){
|
|
|
|
|
|
+ List<Long> orgIds;
|
|
|
|
+ if ((orgId == null || orgId == 0) && (schoolId == null || schoolId == 0)) {
|
|
// 超级管理员权限
|
|
// 超级管理员权限
|
|
orgIds = sysOrgService.list().stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
orgIds = sysOrgService.list().stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
- }else if ((orgId == null || orgId == 0) && schoolId > 0){
|
|
|
|
|
|
+ } else if ((orgId == null || orgId == 0) && schoolId > 0) {
|
|
// 学校管理员权限
|
|
// 学校管理员权限
|
|
- orgIds = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId,schoolId)).stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
|
|
- }else {
|
|
|
|
|
|
+ orgIds = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getSchoolId, schoolId)).stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
// 普通权限
|
|
// 普通权限
|
|
List<Long> ids = new ArrayList<>();
|
|
List<Long> ids = new ArrayList<>();
|
|
ids.add(orgId);
|
|
ids.add(orgId);
|
|
- orgIds = this.dp(ids,schoolId,new ArrayList<>());
|
|
|
|
|
|
+ orgIds = this.dp(ids, schoolId, new ArrayList<>());
|
|
System.out.println("ordIds = " + orgIds);
|
|
System.out.println("ordIds = " + orgIds);
|
|
}
|
|
}
|
|
|
|
|
|
//3.关联template和template_org表 查询出来orgIds所包含的所有模板并组装
|
|
//3.关联template和template_org表 查询出来orgIds所包含的所有模板并组装
|
|
List<TemplatePrintInfoResult> templateInfoList = basicTemplateOrgService.findTemplateInfoByOrgIds(orgIds);
|
|
List<TemplatePrintInfoResult> templateInfoList = basicTemplateOrgService.findTemplateInfoByOrgIds(orgIds);
|
|
- Map<String,Object> result = new HashMap<>();
|
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
// 变量印品
|
|
// 变量印品
|
|
- List<Map<String,Object>> variable = new ArrayList<>();
|
|
|
|
|
|
+ List<Map<String, Object>> variable = new ArrayList<>();
|
|
List<TemplatePrintInfoResult> SIGNList = templateInfoList.stream()
|
|
List<TemplatePrintInfoResult> SIGNList = templateInfoList.stream()
|
|
.filter(e -> TemplateTypeEnum.VARIABLE.equals(e.getTemplateType()))
|
|
.filter(e -> TemplateTypeEnum.VARIABLE.equals(e.getTemplateType()))
|
|
.filter(e -> ClassifyEnum.SIGN.equals(e.getTemplateClassify()))
|
|
.filter(e -> ClassifyEnum.SIGN.equals(e.getTemplateClassify()))
|
|
@@ -123,67 +130,127 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
.filter(e -> TemplateTypeEnum.VARIABLE.equals(e.getTemplateType()))
|
|
.filter(e -> TemplateTypeEnum.VARIABLE.equals(e.getTemplateType()))
|
|
.filter(e -> ClassifyEnum.PACKAGE.equals(e.getTemplateClassify()))
|
|
.filter(e -> ClassifyEnum.PACKAGE.equals(e.getTemplateClassify()))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
- Map<String,Object> SIGNMap = new HashMap<>();
|
|
|
|
- List<Map<String,Object>> signTemplate = new ArrayList<>();
|
|
|
|
|
|
+ Map<String, Object> SIGNMap = new HashMap<>();
|
|
|
|
+ List<Map<String, Object>> signTemplate = new ArrayList<>();
|
|
for (TemplatePrintInfoResult sign : SIGNList) {
|
|
for (TemplatePrintInfoResult sign : SIGNList) {
|
|
- Map<String,Object> signMap = new HashMap<>();
|
|
|
|
- signMap.put("id",sign.getTemplateId());
|
|
|
|
- signMap.put("name",sign.getTemplateName());
|
|
|
|
|
|
+ Map<String, Object> signMap = new HashMap<>();
|
|
|
|
+ signMap.put("id", sign.getTemplateId());
|
|
|
|
+ signMap.put("name", sign.getTemplateName());
|
|
signTemplate.add(signMap);
|
|
signTemplate.add(signMap);
|
|
}
|
|
}
|
|
- SIGNMap.put("type",ClassifyEnum.SIGN);
|
|
|
|
- SIGNMap.put("template",signTemplate);
|
|
|
|
|
|
+ SIGNMap.put("type", ClassifyEnum.SIGN);
|
|
|
|
+ SIGNMap.put("template", signTemplate);
|
|
|
|
|
|
- Map<String,Object> PACKAGEMap = new HashMap<>();
|
|
|
|
- List<Map<String,Object>> packageTemplate = new ArrayList<>();
|
|
|
|
|
|
+ Map<String, Object> PACKAGEMap = new HashMap<>();
|
|
|
|
+ List<Map<String, Object>> packageTemplate = new ArrayList<>();
|
|
for (TemplatePrintInfoResult pack : PACKAGEList) {
|
|
for (TemplatePrintInfoResult pack : PACKAGEList) {
|
|
- Map<String,Object> packageMap = new HashMap<>();
|
|
|
|
- packageMap.put("id",pack.getTemplateId());
|
|
|
|
- packageMap.put("name",pack.getTemplateName());
|
|
|
|
|
|
+ Map<String, Object> packageMap = new HashMap<>();
|
|
|
|
+ packageMap.put("id", pack.getTemplateId());
|
|
|
|
+ packageMap.put("name", pack.getTemplateName());
|
|
packageTemplate.add(packageMap);
|
|
packageTemplate.add(packageMap);
|
|
}
|
|
}
|
|
- PACKAGEMap.put("type",ClassifyEnum.PACKAGE);
|
|
|
|
- PACKAGEMap.put("template",packageTemplate);
|
|
|
|
|
|
+ PACKAGEMap.put("type", ClassifyEnum.PACKAGE);
|
|
|
|
+ PACKAGEMap.put("template", packageTemplate);
|
|
variable.add(SIGNMap);
|
|
variable.add(SIGNMap);
|
|
variable.add(PACKAGEMap);
|
|
variable.add(PACKAGEMap);
|
|
|
|
|
|
// 普通印品
|
|
// 普通印品
|
|
- List<Map<String,Object>> ordinary = new ArrayList<>();
|
|
|
|
|
|
+ List<Map<String, Object>> ordinary = new ArrayList<>();
|
|
List<TemplatePrintInfoResult> CHECKINList = templateInfoList.stream()
|
|
List<TemplatePrintInfoResult> CHECKINList = templateInfoList.stream()
|
|
.filter(e -> TemplateTypeEnum.ORDINARY.equals(e.getTemplateType()))
|
|
.filter(e -> TemplateTypeEnum.ORDINARY.equals(e.getTemplateType()))
|
|
.filter(e -> ClassifyEnum.CHECK_IN.equals(e.getTemplateClassify()))
|
|
.filter(e -> ClassifyEnum.CHECK_IN.equals(e.getTemplateClassify()))
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
- Map<String,Object> CHECKINMap = new HashMap<>();
|
|
|
|
- List<Map<String,Object>> checkInTemplate = new ArrayList<>();
|
|
|
|
|
|
+ Map<String, Object> CHECKINMap = new HashMap<>();
|
|
|
|
+ List<Map<String, Object>> checkInTemplate = new ArrayList<>();
|
|
for (TemplatePrintInfoResult checkIn : CHECKINList) {
|
|
for (TemplatePrintInfoResult checkIn : CHECKINList) {
|
|
- Map<String,Object> checkInMap = new HashMap<>();
|
|
|
|
- checkInMap.put("id",checkIn.getTemplateId());
|
|
|
|
- checkInMap.put("name",checkIn.getTemplateName());
|
|
|
|
|
|
+ Map<String, Object> checkInMap = new HashMap<>();
|
|
|
|
+ checkInMap.put("id", checkIn.getTemplateId());
|
|
|
|
+ checkInMap.put("name", checkIn.getTemplateName());
|
|
checkInTemplate.add(checkInMap);
|
|
checkInTemplate.add(checkInMap);
|
|
}
|
|
}
|
|
- CHECKINMap.put("type",ClassifyEnum.CHECK_IN);
|
|
|
|
- CHECKINMap.put("template",checkInTemplate);
|
|
|
|
|
|
+ CHECKINMap.put("type", ClassifyEnum.CHECK_IN);
|
|
|
|
+ CHECKINMap.put("template", checkInTemplate);
|
|
ordinary.add(CHECKINMap);
|
|
ordinary.add(CHECKINMap);
|
|
|
|
|
|
- result.put("variable",variable);
|
|
|
|
- result.put("ordinary",ordinary);
|
|
|
|
|
|
+ result.put("variable", variable);
|
|
|
|
+ result.put("ordinary", ordinary);
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean savePrintPlan(PrintPlanParams printPlanParams) {
|
|
|
|
+ boolean result;
|
|
|
|
+ System.out.println("JSON = " + printPlanParams.getOrdinaryContent());
|
|
|
|
+ SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
+ Long id = printPlanParams.getId();
|
|
|
|
+ Long schoolId = printPlanParams.getSchoolId();
|
|
|
|
+ if (basicSchoolService.list(new QueryWrapper<BasicSchool>().lambda().eq(BasicSchool::getId,schoolId).eq(BasicSchool::getEnable,true)).size() != 1) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("输入的学校id不满足条件 schoolId = " + schoolId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<String> printContentList = printPlanParams.getPrintContentList();
|
|
|
|
+ if (printContentList.contains("PAPER") && !printContentList.contains("CARD")) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("如果试卷题卡印品选择了试卷,题卡必须被选择");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ExamPrintPlan examPrintPlan = new ExamPrintPlan();
|
|
|
|
+ BeanUtils.copyProperties(printPlanParams, examPrintPlan);
|
|
|
|
+ String printContent = StringUtils.join(printContentList, ",");
|
|
|
|
+ examPrintPlan.setPrintContent(printContent);
|
|
|
|
+ examPrintPlan.setCreateId(sysUser.getId());
|
|
|
|
+ examPrintPlan.setUpdateId(sysUser.getId());
|
|
|
|
+ if (id == null || id == 0) {
|
|
|
|
+ // 没有印刷计划id -> 新增印刷计划
|
|
|
|
+ examPrintPlan.setId(SystemConstant.getDbUuid());
|
|
|
|
+ examPrintPlan.setStatus(PrintPlanStatusEnum.NEW);
|
|
|
|
+ result = this.save(examPrintPlan);
|
|
|
|
+ } else {
|
|
|
|
+ // 包含印刷计划id -> 编辑印刷计划
|
|
|
|
+ ExamPrintPlan tmp = this.getById(id);
|
|
|
|
+ if (tmp == null){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("印刷计划id不存在 id= " + id);
|
|
|
|
+ }
|
|
|
|
+ PrintPlanStatusEnum status = tmp.getStatus();
|
|
|
|
+ if (!PrintPlanStatusEnum.NEW.equals(status) && !PrintPlanStatusEnum.READY.equals(status)) {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("已经开始打印的印刷计划不能编辑");
|
|
|
|
+ }
|
|
|
|
+ // 学校id不能更改
|
|
|
|
+ examPrintPlan.setSchoolId(tmp.getSchoolId());
|
|
|
|
+ result = this.updateById(examPrintPlan);
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public Boolean removePrintPlan(DeleteParams deleteParams) {
|
|
|
|
+ Long id = deleteParams.getId();
|
|
|
|
+ ExamPrintPlan examPrintPlan = this.getById(id);
|
|
|
|
+ if (examPrintPlan == null){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("要删除的项目计划不存在 id = " + id);
|
|
|
|
+ }
|
|
|
|
+ if (!PrintPlanStatusEnum.NEW.equals(examPrintPlan.getStatus())){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("只有'新建'状态的项目计划可以被删除 status = " + examPrintPlan.getStatus());
|
|
|
|
+ }
|
|
|
|
+ return this.removeById(id);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查找子机构
|
|
* 查找子机构
|
|
- * @param ids 上级机构id集合
|
|
|
|
- * @param schoolId 学校id
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param ids 上级机构id集合
|
|
|
|
+ * @param schoolId 学校id
|
|
* @param resultList 已查询所有子机构id集合
|
|
* @param resultList 已查询所有子机构id集合
|
|
* @return 所有子机构id集合
|
|
* @return 所有子机构id集合
|
|
*/
|
|
*/
|
|
- private List<Long> dp(List<Long> ids,Long schoolId,List<Long> resultList){
|
|
|
|
|
|
+ private List<Long> dp(List<Long> ids, Long schoolId, List<Long> resultList) {
|
|
resultList.addAll(ids);
|
|
resultList.addAll(ids);
|
|
for (Long id : ids) {
|
|
for (Long id : ids) {
|
|
- List<SysOrg> childList = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getParentId,id).eq(SysOrg::getSchoolId,schoolId));
|
|
|
|
- if (childList.size() > 0){
|
|
|
|
|
|
+ List<SysOrg> childList = sysOrgService.list(new QueryWrapper<SysOrg>().lambda().eq(SysOrg::getParentId, id).eq(SysOrg::getSchoolId, schoolId));
|
|
|
|
+ if (childList.size() > 0) {
|
|
List<Long> childIds = childList.stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
List<Long> childIds = childList.stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
- this.dp(childIds,schoolId,resultList);
|
|
|
|
|
|
+ this.dp(childIds, schoolId, resultList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return resultList;
|
|
return resultList;
|