xiaof 3 gadi atpakaļ
vecāks
revīzija
d4022b2838

+ 1 - 2
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/ExamTaskService.java

@@ -8,7 +8,6 @@ import com.qmth.distributed.print.business.bean.result.WorkResult;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.entity.ExamTask;
 import com.qmth.distributed.print.business.entity.ExamTaskDetail;
 import com.qmth.distributed.print.business.entity.ExamTaskDetail;
 import com.qmth.distributed.print.business.entity.ExamTaskReviewLog;
 import com.qmth.distributed.print.business.entity.ExamTaskReviewLog;
-import com.qmth.distributed.print.business.entity.TFFlow;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
 import com.qmth.distributed.print.business.enums.ExamStatusEnum;
 import com.qmth.distributed.print.business.enums.MakeMethodEnum;
 import com.qmth.distributed.print.business.enums.MakeMethodEnum;
 import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
 import com.qmth.teachcloud.common.bean.dto.BlurryUserDto;
@@ -40,7 +39,7 @@ public interface ExamTaskService extends IService<ExamTask> {
 
 
     List<BlurryUserDto> listUser(String param);
     List<BlurryUserDto> listUser(String param);
 
 
-    boolean assignUser(ExamTask examTask);
+    Boolean assignUser(ExamTask examTask);
 
 
     boolean enable(ExamTask examTask);
     boolean enable(ExamTask examTask);
 
 

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

@@ -219,6 +219,7 @@ public class BasicStudentServiceImpl extends ServiceImpl<BasicStudentMapper, Bas
             basicStudent.setCampusId(campusId);
             basicStudent.setCampusId(campusId);
             basicStudent.setClazz(clazz);
             basicStudent.setClazz(clazz);
             basicStudent.setSchoolId(schoolId);
             basicStudent.setSchoolId(schoolId);
+            basicStudent.setOrgId(sysUser.getOrgId());
 
 
             // 保存
             // 保存
             if (!SystemConstant.longNotNull(id)) {
             if (!SystemConstant.longNotNull(id)) {

+ 28 - 6
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/ExamTaskServiceImpl.java

@@ -203,11 +203,13 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
     }
     }
 
 
     @Override
     @Override
-    public boolean assignUser(ExamTask examTask) {
+    public Boolean assignUser(ExamTask examTask) {
         if (examTask.getId() == null) {
         if (examTask.getId() == null) {
             throw ExceptionResultEnum.ERROR.exception("参数有误");
             throw ExceptionResultEnum.ERROR.exception("参数有误");
         }
         }
 
 
+        ExamStatusEnum examStatusEnum = ExamStatusEnum.DRAFT;
+        Long flowId = null;
         UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
         UpdateWrapper<ExamTask> updateWrapper = new UpdateWrapper<>();
         ExamTask task = this.getById(examTask.getId());
         ExamTask task = this.getById(examTask.getId());
         // 指派命题老师
         // 指派命题老师
@@ -215,23 +217,43 @@ public class ExamTaskServiceImpl extends ServiceImpl<ExamTaskMapper, ExamTask> i
             if (!task.getEnable()) {
             if (!task.getEnable()) {
                 throw ExceptionResultEnum.ERROR.exception("命题任务已禁用,不能指派命题老师");
                 throw ExceptionResultEnum.ERROR.exception("命题任务已禁用,不能指派命题老师");
             }
             }
-            updateWrapper.lambda().set(ExamTask::getUserId, examTask.getUserId()).set(ExamTask::getStatus, ExamStatusEnum.SUBMIT).eq(ExamTask::getId, examTask.getId());
-        }
 
 
+            if(Objects.nonNull(examTask.getUserId())) {
+                examStatusEnum = ExamStatusEnum.STAGE;
+                //TODO 这里以后要判断学校code来取流程key
+                Map<String, Object> map = new HashMap<>();
+                map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
+                ProcessInstance processInstance = activitiService.startActivity(SystemConstant.GDYKDX_FLOW_KEY, map);
+                flowId = Long.parseLong(processInstance.getId());
+            }
+        }
         // 更改命题老师
         // 更改命题老师
-        if (task.getStatus().name().equals(ExamStatusEnum.SUBMIT.name())) {
+       else if (task.getStatus().name().equals(ExamStatusEnum.STAGE.name())) {
             if (task.getEnable()) {
             if (task.getEnable()) {
                 throw ExceptionResultEnum.ERROR.exception("命题任务禁用后,才能更改命题老师");
                 throw ExceptionResultEnum.ERROR.exception("命题任务禁用后,才能更改命题老师");
             }
             }
-            ExamStatusEnum examStatusEnum;
+
             if (examTask.getUserId() == null) {
             if (examTask.getUserId() == null) {
                 examStatusEnum = ExamStatusEnum.DRAFT;
                 examStatusEnum = ExamStatusEnum.DRAFT;
             } else {
             } else {
                 examStatusEnum = ExamStatusEnum.STAGE;
                 examStatusEnum = ExamStatusEnum.STAGE;
+
+                if(examTask.getUserId().longValue() != task.getUserId().longValue()) {
+                    Map<String, Object> map = new HashMap<>();
+                    map.computeIfAbsent(SystemConstant.APPROVE_ID, v -> String.valueOf(examTask.getUserId()));
+                    ProcessInstance processInstance = activitiService.startActivity(SystemConstant.GDYKDX_FLOW_KEY, map);
+                    flowId = Long.parseLong(processInstance.getId());
+                } else {
+                    flowId = task.getFlowId();
+                }
             }
             }
-            updateWrapper.lambda().set(ExamTask::getUserId, examTask.getUserId()).set(ExamTask::getStatus, examStatusEnum).eq(ExamTask::getId, examTask.getId());
         }
         }
 
 
+        updateWrapper.lambda().set(ExamTask::getUserId, examTask.getUserId())
+                .set(ExamTask::getStatus, examStatusEnum)
+                .set(ExamTask::getFlowId, flowId)
+                .eq(ExamTask::getId, examTask.getId());
+
         return this.update(updateWrapper);
         return this.update(updateWrapper);
     }
     }
 
 

+ 61 - 0
distributed-print/src/test/java/com/qmth/distributed/print/CreateSchoolPrivilegeTest.java

@@ -0,0 +1,61 @@
+package com.qmth.distributed.print;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.SysPrivilege;
+import com.qmth.teachcloud.common.service.SysPrivilegeService;
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.*;
+
+/**
+ * @Date: 2021/8/9.
+ */
+@SpringBootTest
+@RunWith(SpringRunner.class)
+public class CreateSchoolPrivilegeTest {
+
+    private static final Long SCHOOL_ID = 2l;
+
+    @Autowired
+    private SysPrivilegeService sysPrivilegeService;
+
+    @Test
+    public void test(){
+        QueryWrapper<SysPrivilege> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(SysPrivilege::getSchoolId, SCHOOL_ID);
+        List<SysPrivilege> sysPrivileges = sysPrivilegeService.list(queryWrapper);
+        Map<Long, Long> map = new HashMap<>();
+        List<SysPrivilege> newList = new ArrayList<>();
+        for (SysPrivilege sysPrivilege : sysPrivileges) {
+            Long id = SystemConstant.getDbUuid();
+            map.put(sysPrivilege.getId(), id);
+            sysPrivilege.setId(id);
+            sysPrivilege.setSchoolId(137l);
+            newList.add(sysPrivilege);
+        }
+        for (SysPrivilege sysPrivilege : newList) {
+            if(Objects.nonNull(sysPrivilege.getParentId())){
+                sysPrivilege.setParentId(map.get(sysPrivilege.getParentId()));
+            }
+            String relateId = sysPrivilege.getRelated();
+            if(StringUtils.isNotBlank(relateId)){
+                String[] relateIds = relateId.split(",");
+                List<String> newRelateIds = new ArrayList<>();
+                for (String id : relateIds) {
+                    Long lid = Long.valueOf(id.trim());
+                    newRelateIds.add(String.valueOf(map.get(lid)));
+                }
+                String newRelateId = String.join(",", newRelateIds);
+                sysPrivilege.setRelated(newRelateId);
+            }
+        }
+        sysPrivilegeService.saveBatch(newList);
+    }
+
+}

+ 76 - 0
distributed-print/src/test/java/com/qmth/distributed/print/RandomABCTest.java

@@ -0,0 +1,76 @@
+package com.qmth.distributed.print;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @Date: 2021/8/9.
+ */
+public class RandomABCTest {
+    
+    private final static String TYPE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+    public static void main(String[] args) {
+        int count = 5;
+        List<String> types = generateType(count);
+        List<Student> students = generateStudent();
+        int i = 0;
+        for (Student student : students) {
+            int mod = i % count;
+            student.setType(types.get(mod));
+            student.print();
+            i++;
+        }
+    }
+    
+    static List<String> generateType(int count){
+        String types = TYPE.substring(0, count);
+        return Arrays.asList(types.split(""));
+    }
+
+    static List<Student> generateStudent(){
+        List<Student> list = new ArrayList<>();
+        for (int i = 1; i <= 20; i++) {
+            Student student = new Student();
+            student.setId(i);
+            student.setName("学生"+i);
+            list.add(student);
+        }
+        return list;
+    }
+
+    static class Student{
+        private int id;
+        private String name;
+        private String type;
+
+        public int getId() {
+            return id;
+        }
+
+        public void setId(int id) {
+            this.id = id;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        public String getType() {
+            return type;
+        }
+
+        public void setType(String type) {
+            this.type = type;
+        }
+
+        public void print(){
+            System.out.println("id:" + id +", type:" + type);
+        }
+    }
+}