|
@@ -7,19 +7,27 @@ 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.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.entity.ExamDetail;
|
|
import com.qmth.distributed.print.business.entity.ExamDetail;
|
|
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.SysUser;
|
|
|
|
+import com.qmth.distributed.print.business.enums.ClassifyEnum;
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.PrintPlanStatusEnum;
|
|
|
|
+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.ExamDetailService;
|
|
|
|
-import com.qmth.distributed.print.business.service.ExamPrintPlanService;
|
|
|
|
|
|
+import com.qmth.distributed.print.business.service.*;
|
|
|
|
+import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -35,6 +43,12 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
private ExamPrintPlanMapper examPrintPlanMapper;
|
|
private ExamPrintPlanMapper examPrintPlanMapper;
|
|
@Resource
|
|
@Resource
|
|
private ExamDetailService examDetailService;
|
|
private ExamDetailService examDetailService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysUserService sysUserService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysOrgService sysOrgService;
|
|
|
|
+ @Resource
|
|
|
|
+ private BasicTemplateOrgService basicTemplateOrgService;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Override
|
|
@Override
|
|
@@ -68,4 +82,111 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
|
|
}
|
|
}
|
|
return printPlanBriefList;
|
|
return printPlanBriefList;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> printPlanTemplateDatasource(Long schoolId, Long userId) {
|
|
|
|
+ //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){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到用户信息");
|
|
|
|
+ }
|
|
|
|
+ SysUser requestUser = requestUserList.get(0);
|
|
|
|
+ Long orgId = requestUser.getOrgId();
|
|
|
|
+
|
|
|
|
+ //2.根据orgId查询他的所有叶子id 并把这些id放入List<Long> ids
|
|
|
|
+ List<Long> orgIds = new ArrayList<>();
|
|
|
|
+ if ((orgId == null || orgId == 0) && (schoolId == null || schoolId == 0)){
|
|
|
|
+ // 超级管理员权限
|
|
|
|
+ orgIds = sysOrgService.list().stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
|
|
+ }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 {
|
|
|
|
+ // 普通权限
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
+ ids.add(orgId);
|
|
|
|
+ orgIds = this.dp(ids,schoolId,new ArrayList<>());
|
|
|
|
+ System.out.println("ordIds = " + orgIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //3.关联template和template_org表 查询出来orgIds所包含的所有模板并组装
|
|
|
|
+ List<TemplatePrintInfoResult> templateInfoList = basicTemplateOrgService.findTemplateInfoByOrgIds(orgIds);
|
|
|
|
+ Map<String,Object> result = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ // 变量印品
|
|
|
|
+ List<Map<String,Object>> variable = new ArrayList<>();
|
|
|
|
+ List<TemplatePrintInfoResult> SIGNList = templateInfoList.stream()
|
|
|
|
+ .filter(e -> TemplateTypeEnum.VARIABLE.equals(e.getTemplateType()))
|
|
|
|
+ .filter(e -> ClassifyEnum.SIGN.equals(e.getTemplateClassify()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ List<TemplatePrintInfoResult> PACKAGEList = templateInfoList.stream()
|
|
|
|
+ .filter(e -> TemplateTypeEnum.VARIABLE.equals(e.getTemplateType()))
|
|
|
|
+ .filter(e -> ClassifyEnum.PACKAGE.equals(e.getTemplateClassify()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ Map<String,Object> SIGNMap = new HashMap<>();
|
|
|
|
+ List<Map<String,Object>> signTemplate = new ArrayList<>();
|
|
|
|
+ for (TemplatePrintInfoResult sign : SIGNList) {
|
|
|
|
+ Map<String,Object> signMap = new HashMap<>();
|
|
|
|
+ signMap.put("id",sign.getTemplateId());
|
|
|
|
+ signMap.put("name",sign.getTemplateName());
|
|
|
|
+ signTemplate.add(signMap);
|
|
|
|
+ }
|
|
|
|
+ SIGNMap.put("type",ClassifyEnum.SIGN);
|
|
|
|
+ SIGNMap.put("template",signTemplate);
|
|
|
|
+
|
|
|
|
+ Map<String,Object> PACKAGEMap = new HashMap<>();
|
|
|
|
+ List<Map<String,Object>> packageTemplate = new ArrayList<>();
|
|
|
|
+ for (TemplatePrintInfoResult pack : PACKAGEList) {
|
|
|
|
+ Map<String,Object> packageMap = new HashMap<>();
|
|
|
|
+ packageMap.put("id",pack.getTemplateId());
|
|
|
|
+ packageMap.put("name",pack.getTemplateName());
|
|
|
|
+ packageTemplate.add(packageMap);
|
|
|
|
+ }
|
|
|
|
+ PACKAGEMap.put("type",ClassifyEnum.PACKAGE);
|
|
|
|
+ PACKAGEMap.put("template",packageTemplate);
|
|
|
|
+ variable.add(SIGNMap);
|
|
|
|
+ variable.add(PACKAGEMap);
|
|
|
|
+
|
|
|
|
+ // 普通印品
|
|
|
|
+ List<Map<String,Object>> ordinary = new ArrayList<>();
|
|
|
|
+ List<TemplatePrintInfoResult> CHECKINList = templateInfoList.stream()
|
|
|
|
+ .filter(e -> TemplateTypeEnum.ORDINARY.equals(e.getTemplateType()))
|
|
|
|
+ .filter(e -> ClassifyEnum.CHECK_IN.equals(e.getTemplateClassify()))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ Map<String,Object> CHECKINMap = new HashMap<>();
|
|
|
|
+ List<Map<String,Object>> checkInTemplate = new ArrayList<>();
|
|
|
|
+ for (TemplatePrintInfoResult checkIn : CHECKINList) {
|
|
|
|
+ Map<String,Object> checkInMap = new HashMap<>();
|
|
|
|
+ checkInMap.put("id",checkIn.getTemplateId());
|
|
|
|
+ checkInMap.put("name",checkIn.getTemplateName());
|
|
|
|
+ checkInTemplate.add(checkInMap);
|
|
|
|
+ }
|
|
|
|
+ CHECKINMap.put("type",ClassifyEnum.CHECK_IN);
|
|
|
|
+ CHECKINMap.put("template",checkInTemplate);
|
|
|
|
+ ordinary.add(CHECKINMap);
|
|
|
|
+
|
|
|
|
+ result.put("variable",variable);
|
|
|
|
+ result.put("ordinary",ordinary);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查找子机构
|
|
|
|
+ * @param ids 上级机构id集合
|
|
|
|
+ * @param schoolId 学校id
|
|
|
|
+ * @param resultList 已查询所有子机构id集合
|
|
|
|
+ * @return 所有子机构id集合
|
|
|
|
+ */
|
|
|
|
+ private List<Long> dp(List<Long> ids,Long schoolId,List<Long> resultList){
|
|
|
|
+ resultList.addAll(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<Long> childIds = childList.stream().map(SysOrg::getId).collect(Collectors.toList());
|
|
|
|
+ this.dp(childIds,schoolId,resultList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return resultList;
|
|
|
|
+ }
|
|
}
|
|
}
|