diff --git a/documents/约定.txt b/documents/约定.txt new file mode 100644 index 0000000..7b9a7e2 --- /dev/null +++ b/documents/约定.txt @@ -0,0 +1,7 @@ +status有五种: + 1, 0 000 未开始 + 2, 1 001 开始未完成 + 3, 3 011 开始已完成未结束 + 4, 5 101 开始未完成已结束 + 5, 7 111 开始已完成已结束 + ,,,其余无效 \ No newline at end of file diff --git a/src/core/process/ProcessManagement.java b/src/core/process/ProcessManagement.java index b7bf2f0..af88a50 100644 --- a/src/core/process/ProcessManagement.java +++ b/src/core/process/ProcessManagement.java @@ -1,11 +1,44 @@ package core.process; +import core.user.User; +import dao.DBManagement; + import java.util.List; +import java.util.Map; public class ProcessManagement { - public Condition getCondition(String userType, List index){ + public static Condition getCondition(User user) { + Map status = getStatus(user); + return getCondition(user,status); + } + public static Condition getCondition(User user, Map status){ + Condition condition = new Condition(); + for(Map.Entry entry:status.entrySet()){ + String[] s = entry.getKey().split("."); + TempProcess tempProcess = (TempProcess) getProcess(s[1]); + tempProcess.setGraduationDesignId(s[0]); + tempProcess.setStatus(entry.getValue()); + condition.add(tempProcess); + } + condition.add(getLastProcesses(user)); + return condition; + } + + private static List getLastProcesses(User user) { + return null; + } + + //Map + public static Map getStatus(User user){ + Map userTables = DBManagement.getUserTables(user.getType()); + for(Map.Entry entry:userTables.entrySet()){ + String[] ti = entry.getKey().split("."); + String[] ts = entry.getValue().split("."); + + } + return null; } - public Process getProcess(int index){ + public static Process getProcess(String process){ return null; } } diff --git a/src/core/process/TempProcess.java b/src/core/process/TempProcess.java index 1bb01d4..2675bff 100644 --- a/src/core/process/TempProcess.java +++ b/src/core/process/TempProcess.java @@ -1,8 +1,17 @@ package core.process; public abstract class TempProcess extends Process { - public static String process; - public static String nextProcess; + private static String process; + private static String nextProcess; + private String graduationDesignId; + + public String getGraduationDesignId() { + return graduationDesignId; + } + + public void setGraduationDesignId(String graduationDesignId) { + this.graduationDesignId = graduationDesignId; + } public static String getProcess() { return process; diff --git a/src/core/user/Student.java b/src/core/user/Student.java index 7365272..4d4987b 100644 --- a/src/core/user/Student.java +++ b/src/core/user/Student.java @@ -6,6 +6,12 @@ import java.util.Map; public class Student extends User { private String grade; private String profession_code; + + @Override + public String getType() { + return "student"; + } + public void setAttr(Map vMap){ super.setAttr(vMap); this.setGrade(vMap.get("grade")); diff --git a/src/core/user/Teacher.java b/src/core/user/Teacher.java index 2a24d05..9b7c053 100644 --- a/src/core/user/Teacher.java +++ b/src/core/user/Teacher.java @@ -7,6 +7,12 @@ public class Teacher extends User { String job_title; String education; String profession_code; + + @Override + public String getType() { + return "teacher"; + } + @Override public void setAttr(Map vMap){ super.setAttr(vMap); diff --git a/src/core/user/User.java b/src/core/user/User.java index 89b29b0..236c2ae 100644 --- a/src/core/user/User.java +++ b/src/core/user/User.java @@ -89,9 +89,7 @@ public abstract class User implements AccountManageable, ProcessConfigurable{ super(); } - public String getType(){ - return this.getClass().getName(); - } + public abstract String getType(); public void destroy(){ core.user.utils.AccountManagement.destroy(this); diff --git a/src/core/utils/GetObjectByName.java b/src/core/utils/GetObjectByName.java index de87637..72f8a8d 100644 --- a/src/core/utils/GetObjectByName.java +++ b/src/core/utils/GetObjectByName.java @@ -7,9 +7,9 @@ public interface GetObjectByName { String userClassPath = "core.user"; String operationClassPath = "core.operation"; static User getUserByName(String name) throws Exception { - return (User)Class.forName(userClassPath+"."+name).getDeclaredConstructor().newInstance(); + return (User)Class.forName(userClassPath+"."+utils.Utils.toUpperFirstChar(name)).getDeclaredConstructor().newInstance(); } static Operation getOperationByName(String name) throws Exception{ - return (Operation)Class.forName(operationClassPath+"."+name).getDeclaredConstructor().newInstance(); + return (Operation)Class.forName(operationClassPath+"."+utils.Utils.toUpperFirstChar(name)).getDeclaredConstructor().newInstance(); } } diff --git a/src/dao/DBManagement.java b/src/dao/DBManagement.java index e9e1ce9..703602a 100644 --- a/src/dao/DBManagement.java +++ b/src/dao/DBManagement.java @@ -29,16 +29,23 @@ public class DBManagement { "graduation_design_reply", "graduation_design_reply_opinion_record_score" }; - // + // public static Map graduationDesignStudentTables = new HashMap<>(){ { - put("graduation_design.student_id","student"); - put("opening_report_secretary_team.leader_student_id","opening_report_secretary_leader"); - put("opening_report_secretary_team.student1_id","opening_report_secretary_member"); - put("opening_report_secretary_team.student2_id","opening_report_secretary_member"); - put("reply_secretary_team.leader_student_id","reply_secretary_leader"); - put("reply_secretary_team.student1_id","reply_secretary_member"); - put("reply_secretary_team.student2_id","reply_secretary_member"); + put("graduation_design.student_id","graduation_design.student_chooser_teacher_status"); + + + put("opening_report_secretary_team.leader_student_id",""); + put("opening_report_secretary_team.student1_id",""); + put("opening_report_secretary_team.student2_id",""); + put("reply_secretary_team.leader_student_id",""); + put("reply_secretary_team.student1_id",""); + put("reply_secretary_team.student2_id",""); + } + }; + public static Map graduationDesignTeacherTables = new HashMap<>(){ + { + put("",""); } }; public static String driverClassName="org.mariadb.jdbc.Driver"; @@ -72,6 +79,15 @@ public class DBManagement { } return null; } + public static Map getUserTables(String userType){ + if(userType.equals("student")){ + return graduationDesignStudentTables; + } + if(userType.equals("teacher")){ + return graduationDesignTeacherTables; + } + return null; + } public static void delete(String table, Map limits) throws GExcptSQL { Delete delete = new Delete(table, limits);