Ver código fonte

3.2.7 bug修改

xiaofei 1 ano atrás
pai
commit
e5166abb27

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicPrintConfigService.java

@@ -32,4 +32,6 @@ public interface BasicPrintConfigService extends IService<BasicPrintConfig> {
     List<BasicPrintConfig> listBySchoolId(Long schoolId);
 
     void removeByExamId(Long examId);
+
+    void updateAttachmentIdByTemplateId(Long templateId, Long attachmentId);
 }

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamPrintPlanService.java

@@ -117,4 +117,6 @@ public interface ExamPrintPlanService extends IService<ExamPrintPlan> {
     void checkSyncMode(SyncDataParam syncDataParam);
 
     void autoSyncStudent();
+
+    void updateAttachmentIdByTemplateId(Long templateId, Long attachmentId);
 }

+ 23 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicPrintConfigServiceImpl.java

@@ -18,9 +18,11 @@ import com.qmth.teachcloud.common.entity.BasicExam;
 import com.qmth.teachcloud.common.entity.BasicPrintConfig;
 import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.enums.ClassifyEnum;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
 import com.qmth.teachcloud.common.service.BasicRoleDataPermissionService;
 import com.qmth.teachcloud.common.util.ServletUtil;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -119,4 +121,25 @@ public class BasicPrintConfigServiceImpl extends ServiceImpl<BasicPrintConfigMap
         updateWrapper.lambda().eq(BasicPrintConfig::getExamId, examId);
         this.remove(updateWrapper);
     }
+
+    @Override
+    public void updateAttachmentIdByTemplateId(Long templateId, Long attachmentId) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        QueryWrapper<BasicPrintConfig> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(BasicPrintConfig::getSchoolId, schoolId);
+        List<BasicPrintConfig> basicPrintConfigList = this.list(queryWrapper);
+        for (BasicPrintConfig basicPrintConfig : basicPrintConfigList) {
+            String ordinaryContent = basicPrintConfig.getOrdinaryContent();
+            if(StringUtils.isNotBlank(ordinaryContent)){
+                List<JSONObject> jsonObjectList = JSON.parseArray(ordinaryContent, JSONObject.class);
+                for (JSONObject jsonObject : jsonObjectList) {
+                    if(ClassifyEnum.CHECK_IN.name().equals(jsonObject.getString("type")) && templateId.equals(jsonObject.getLong("templateId"))){
+                        jsonObject.put("attachmentId", String.valueOf(attachmentId));
+                    }
+                }
+                basicPrintConfig.setOrdinaryContent(JSON.toJSONString(jsonObjectList));
+            }
+        }
+        this.updateBatchById(basicPrintConfigList);
+    }
 }

+ 8 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTemplateServiceImpl.java

@@ -15,6 +15,7 @@ import com.qmth.distributed.print.business.mapper.BasicTemplateMapper;
 import com.qmth.distributed.print.business.service.BasicExamRuleService;
 import com.qmth.distributed.print.business.service.BasicPrintConfigService;
 import com.qmth.distributed.print.business.service.BasicTemplateService;
+import com.qmth.distributed.print.business.service.ExamPrintPlanService;
 import com.qmth.distributed.print.business.util.PdfFillUtils;
 import com.qmth.teachcloud.common.bean.dto.DataPermissionRule;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -71,6 +72,9 @@ public class BasicTemplateServiceImpl extends ServiceImpl<BasicTemplateMapper, B
     @Resource
     private BasicExamRuleService basicExamRuleService;
 
+    @Resource
+    private ExamPrintPlanService examPrintPlanService;
+
     @Override
     public IPage<TemplateDto> list(Boolean enable, String name, Long startTime, Long endTime, Integer pageNumber, Integer pageSize) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
@@ -115,6 +119,10 @@ public class BasicTemplateServiceImpl extends ServiceImpl<BasicTemplateMapper, B
             }
             template.setPreviewPath(null);
             template.updateInfo(sysUser.getId());
+
+            // 普通印品重新上传附件后,同是更新使用的附件ID
+            basicPrintConfigService.updateAttachmentIdByTemplateId(template.getId(), template.getAttachmentId());
+            examPrintPlanService.updateAttachmentIdByTemplateId(template.getId(), template.getAttachmentId());
         }
         return this.saveOrUpdate(template);
     }

+ 1 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPaperStructureServiceImpl.java

@@ -126,7 +126,7 @@ public class ExamPaperStructureServiceImpl extends ServiceImpl<ExamPaperStructur
 
             ExamTaskDetail examTaskDetail = examTaskDetailService.getOne(new QueryWrapper<ExamTaskDetail>().lambda()
                     .eq(ExamTaskDetail::getExamTaskId, m.getExamTaskId()));
-            if (StringUtils.isNotBlank(examTaskDetail.getPaperAttachmentIds())) {
+            if (examTaskDetail != null && StringUtils.isNotBlank(examTaskDetail.getPaperAttachmentIds())) {
                 List<JSONObject> jsonObjectList = JSON.parseArray(examTaskDetail.getPaperAttachmentIds(), JSONObject.class);
                 Optional<JSONObject> objectOptional = jsonObjectList.stream().filter(t -> m.getPaperType().equals(t.getString("name"))).findFirst();
                 if (objectOptional.isPresent()) {

+ 21 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamPrintPlanServiceImpl.java

@@ -548,6 +548,27 @@ public class ExamPrintPlanServiceImpl extends ServiceImpl<ExamPrintPlanMapper, E
         }
     }
 
+    @Override
+    public void updateAttachmentIdByTemplateId(Long templateId, Long attachmentId) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        QueryWrapper<ExamPrintPlan> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(ExamPrintPlan::getSchoolId, schoolId);
+        List<ExamPrintPlan> examPrintPlanList = this.list(queryWrapper);
+        for (ExamPrintPlan examPrintPlan : examPrintPlanList) {
+            String ordinaryContent = examPrintPlan.getOrdinaryContent();
+            if(StringUtils.isNotBlank(ordinaryContent)){
+                List<JSONObject> jsonObjectList = JSON.parseArray(ordinaryContent, JSONObject.class);
+                for (JSONObject jsonObject : jsonObjectList) {
+                    if(ClassifyEnum.CHECK_IN.name().equals(jsonObject.getString("type")) && templateId.equals(jsonObject.getLong("templateId"))){
+                        jsonObject.put("attachmentId", String.valueOf(attachmentId));
+                    }
+                }
+                examPrintPlan.setOrdinaryContent(JSON.toJSONString(jsonObjectList));
+            }
+        }
+        this.updateBatchById(examPrintPlanList);
+    }
+
     /**
      * 查找子机构
      *

+ 21 - 16
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -32,6 +32,7 @@ import com.qmth.teachcloud.common.bean.dto.MqDto;
 import com.qmth.teachcloud.common.bean.dto.excel.DescribeImportDto;
 import com.qmth.teachcloud.common.bean.params.BasicStudentExtrasParam;
 import com.qmth.teachcloud.common.bean.result.BasicStudentResult;
+import com.qmth.teachcloud.common.bean.result.MenuResult;
 import com.qmth.teachcloud.common.bean.result.SysUserResult;
 import com.qmth.teachcloud.common.bean.result.TbTaskDetailResult;
 import com.qmth.teachcloud.common.contant.SystemConstant;
@@ -1499,24 +1500,28 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
                 }
 
                 if (!CollectionUtils.isEmpty(errorClassIds)) {
-                    Map<String, List<String>> finalMap = new HashMap<>();
-                    StringJoiner stringJoiner = new StringJoiner(",");
-                    List<BasicClazz> basicClazzList = basicClazzService.listByIds(errorClassIds);
-                    for (BasicClazz basicClazz : basicClazzList) {
-                        String key = usedClassIdsMap.get(basicClazz.getId().toString());
-                        List<String> value;
-                        if (finalMap.containsKey(key)) {
-                            value = finalMap.get(key);
-                        } else {
-                            value = new ArrayList<>();
+                    // 选择学生时,不校验
+                    boolean containsPrivilege = teachcloudCommonService.containsPrivilege(sysUser.getId(), "button", "SelectStudent");
+                    if (!containsPrivilege) {
+                        Map<String, List<String>> finalMap = new HashMap<>();
+                        StringJoiner stringJoiner = new StringJoiner(",");
+                        List<BasicClazz> basicClazzList = basicClazzService.listByIds(errorClassIds);
+                        for (BasicClazz basicClazz : basicClazzList) {
+                            String key = usedClassIdsMap.get(basicClazz.getId().toString());
+                            List<String> value;
+                            if (finalMap.containsKey(key)) {
+                                value = finalMap.get(key);
+                            } else {
+                                value = new ArrayList<>();
+                            }
+                            value.add(basicClazz.getClazzName());
+                            finalMap.put(key, value);
                         }
-                        value.add(basicClazz.getClazzName());
-                        finalMap.put(key, value);
-                    }
-                    for (Map.Entry<String, List<String>> entry : finalMap.entrySet()) {
-                        stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被" + entry.getKey() + "选择");
+                        for (Map.Entry<String, List<String>> entry : finalMap.entrySet()) {
+                            stringJoiner.add("考试对象[" + String.join(",", entry.getValue()) + "]已被" + entry.getKey() + "选择");
+                        }
+                        throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
                     }
-                    throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
                 }
             }
 

+ 2 - 0
distributed-print-business/src/main/resources/db/log/脚本-xiaof.sql

@@ -226,6 +226,8 @@ ALTER TABLE `exam_task` DROP COLUMN `paper_number_id`;
 ALTER TABLE `exam_detail_course` DROP COLUMN `org_id`;
 
 update exam_print_plan set status = 'FINISH' where status = 'PRINT_FINISH';
+update exam_print_plan set status = 'FINISH' where status = 'END';
+update exam_detail set status = 'CANCEL' where status = 'EXPIRED';
 
 ALTER TABLE `exam_detail`
     ADD COLUMN `task_id` BIGINT(20) NULL COMMENT 'pdf生成异步任务ID(t_b_task)' AFTER `backup_count`,

+ 2 - 0
distributed-print-business/src/main/resources/db/upgrade/3.2.7.sql

@@ -126,6 +126,8 @@ ALTER TABLE `exam_task` DROP COLUMN `paper_number_id`;
 ALTER TABLE `exam_detail_course` DROP COLUMN `org_id`;
 
 update exam_print_plan set status = 'FINISH' where status = 'PRINT_FINISH';
+update exam_print_plan set status = 'FINISH' where status = 'END';
+update exam_detail set status = 'CANCEL' where status = 'EXPIRED';
 
 ALTER TABLE `exam_detail`
     ADD COLUMN `task_id` BIGINT(20) NULL COMMENT 'pdf生成异步任务ID(t_b_task)' AFTER `backup_count`,

+ 9 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/TeachcloudCommonService.java

@@ -216,4 +216,13 @@ public interface TeachcloudCommonService {
      * @return 系统编码
      */
     public String getSysIncrCode(SystemCodeEnum type, SysUser requestUser);
+
+    /**
+     * 校验用户是否包含某权限
+     *
+     * @param userId        用户ID
+     * @param button        类型
+     * @param selectStudent 权限url名称
+     */
+    boolean containsPrivilege(Long userId, String button, String selectStudent);
 }

+ 18 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

@@ -821,6 +821,24 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         return paperNumber;
     }
 
+    @Override
+    public boolean containsPrivilege(Long userId, String button, String selectStudent) {
+        MenuResult menuResult = commonCacheService.userMenuCache(userId);
+        if (menuResult != null && !CollectionUtils.isEmpty(menuResult.getPrivileges())) {
+            List<MenuPrivilegeDto> menuResultPrivileges = menuResult.getPrivileges();
+            long count = 0;
+            for (MenuPrivilegeDto menuResultPrivilege : menuResultPrivileges) {
+                List<MenuDto> menuDtoList = "button".equals(button) ? menuResultPrivilege.getButtons() : "link".equals(button) ? menuResultPrivilege.getLinks() : null;
+                if (!CollectionUtils.isEmpty(menuDtoList)) {
+                    long filterCount = menuDtoList.stream().filter(m -> m.getUrl().equalsIgnoreCase(selectStudent)).count();
+                    count = count + filterCount;
+                }
+            }
+            return count > 0;
+        }
+        return false;
+    }
+
     private Set<Long> getOrgIds(Set<Long> stringSet, List<OrgDto> orgDtos, Long parentId) {
         for (OrgDto orgDto : orgDtos) {
             Long tempParentId = orgDto.getParentId();