Explorar o código

考试管理权限调整

eganwu %!s(int64=2) %!d(string=hai) anos
pai
achega
557be131ae

+ 27 - 2
src/custom/restcontroller/R.java

@@ -5836,12 +5836,37 @@ public class R {
         }
     }
 
-    public static class ID20240327094702 {
+    public static class ID20240328130602 {
         public static class v1 {
         }
     }
 
-    public static class ID20240327094802 {
+    public static class ID20240328130702 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240328130802 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240328130902 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240328131002 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240328131102 {
+        public static class v1 {
+        }
+    }
+
+    public static class ID20240328131202 {
         public static class v1 {
         }
     }

+ 21 - 23
src/custom/restcontroller/webmanage/saletool/courseware/CoursewareHelper.java

@@ -117,34 +117,32 @@ public class CoursewareHelper extends BaseClass {
         return rows;
     }
 
-    public static ArrayList<String> getCoursewareTestSql(Controller controller, Long sat_courseware_testheadid, JSONArray userids, JSONArray testquestions) throws YosException {
+    public static ArrayList<String> getCoursewareTestSql(Controller controller, Long sat_courseware_testheadid,Long sat_courseware_testid , JSONArray testquestions) throws YosException {
         String sat_courseware_test = "sat_courseware_test";
         ArrayList<String> sqlList = new ArrayList<>();
-        for (Object obj : userids) {
-            Long userid = Long.valueOf(obj.toString());
-            Long sat_courseware_testid = controller.createTableID(sat_courseware_test);
-            InsertSQL insertSQL = SQLFactory.createInsertSQL(controller, sat_courseware_test);
-            insertSQL.setSiteid(controller.siteid);
-            insertSQL.setUniqueid(sat_courseware_testid);
-            insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
-            insertSQL.setValue("userid", userid);
-            insertSQL.setValue("name", controller.getUser(userid).getString("name"));
-            sqlList.add(insertSQL.getSQL());
-            int num = testquestions.size();
-            int count = 0;
-            for (Object object : testquestions) {
-                JSONObject testquestion = (JSONObject) object;
-                int score = 0;
-                if (count == testquestions.size() - 1) {
-                    score = 100 / num + 100 % num;
-                } else {
-                    score = 100 / num;
-                }
-                sqlList.add(getCoursewareTestItemsSql(controller, sat_courseware_testid, testquestion, score));
-                count++;
+
+        InsertSQL insertSQL = SQLFactory.createInsertSQL(controller, sat_courseware_test);
+        insertSQL.setSiteid(controller.siteid);
+        insertSQL.setUniqueid(sat_courseware_testid);
+        insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
+        insertSQL.setValue("userid", controller.userid);
+        insertSQL.setValue("name", controller.getUser(controller.userid).getString("name"));
+        sqlList.add(insertSQL.getSQL());
+        int num = testquestions.size();
+        int count = 0;
+        for (Object object : testquestions) {
+            JSONObject testquestion = (JSONObject) object;
+            int score = 0;
+            if (count == testquestions.size() - 1) {
+                score = 100 / num + 100 % num;
+            } else {
+                score = 100 / num;
             }
+            sqlList.add(getCoursewareTestItemsSql(controller, sat_courseware_testid, testquestion, score));
+            count++;
         }
 
+
         return sqlList;
 
     }

+ 18 - 0
src/custom/restcontroller/webmanage/saletool/courseware/SQL/我的考试列表.sql

@@ -0,0 +1,18 @@
+SELECT
+    t1.sat_courseware_testheadid,
+    t1.title,
+    t1.num,
+    t2.sat_courseware_testid,
+    t2.status,
+    t2.score,
+    t2.answercount
+FROM
+    sat_courseware_testhead t1
+left join  sat_courseware_test t2 on t2.sat_courseware_testheadid=t1.sat_courseware_testheadid and t2.siteid=t1.siteid
+
+
+where $where$ and t1.status = '发布'   and t1.siteid = $siteid$ and t1.sat_courseware_testheadid IN
+                                                                    (
+                                                                        SELECT sat_courseware_testheadid FROM sat_courseware_testauth WHERE
+                                                                            departmentid IN $departmentid$  OR hrid IN  $hrid$ OR sys_enterpriseid IN  $sys_enterpriseid$ OR sa_saleareaid IN  $sa_saleareaid$ or roleid in $roleid$
+    )

+ 6 - 6
src/custom/restcontroller/webmanage/saletool/courseware/coursewareauth.java

@@ -232,7 +232,7 @@ public class coursewareauth extends Controller {
     }
 
 
-    @API(title = "通告权限新增", apiversion = R.ID20240314145102.v1.class)
+    @API(title = "课程权限新增", apiversion = R.ID20240314145102.v1.class)
     public String add() throws YosException {
         Long sat_coursewareid = content.getLongValue("sat_coursewareid");
 
@@ -330,7 +330,7 @@ public class coursewareauth extends Controller {
         return getSucReturnObject().toString();
     }
 
-    @API(title = "通告角色权限删除", apiversion = R.ID20240314145302.v1.class)
+    @API(title = "课程权限删除", apiversion = R.ID20240314145302.v1.class)
     public String deleteQuanXian() throws YosException {
         Long sat_coursewareid = content.getLongValue("sat_coursewareid");
 
@@ -382,7 +382,7 @@ public class coursewareauth extends Controller {
 
 
 
-    @API(title = "部门列表",apiversion = R.ID20240314145402.v1.class)
+    @API(title = "课程部门列表",apiversion = R.ID20240314145402.v1.class)
     public String depList() throws YosException {
 
         Long sat_coursewareid = content.getLongValue("sat_coursewareid");
@@ -402,7 +402,7 @@ public class coursewareauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "人员列表",apiversion = R.ID20240314145502.v1.class)
+    @API(title = "课程人员列表",apiversion = R.ID20240314145502.v1.class)
     public String hrList() throws YosException {
         Long sat_coursewareid = content.getLongValue("sat_coursewareid");
 
@@ -420,7 +420,7 @@ public class coursewareauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "区域列表",apiversion = R.ID20240314145602.v1.class)
+    @API(title = "课程区域列表",apiversion = R.ID20240314145602.v1.class)
     public String areaList() throws YosException {
 
         Long sat_coursewareid = content.getLongValue("sat_coursewareid");
@@ -440,7 +440,7 @@ public class coursewareauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "合作伙伴列表",apiversion = R.ID20240314145702.v1.class)
+    @API(title = "课程合作伙伴列表",apiversion = R.ID20240314145702.v1.class)
     public String enterpriseList() throws YosException {
         Long sat_coursewareid = content.getLongValue("sat_coursewareid");
 

+ 263 - 0
src/custom/restcontroller/webmanage/saletool/courseware/coursewaretestauth.java

@@ -0,0 +1,263 @@
+package restcontroller.webmanage.saletool.courseware;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import common.Controller;
+import common.YosException;
+import common.annotation.API;
+import common.data.*;
+import org.apache.commons.lang.StringUtils;
+import restcontroller.R;
+
+import java.util.ArrayList;
+
+public class coursewaretestauth extends Controller {
+    /**
+     * 构造函数
+     *
+     * @param content
+     */
+    public coursewaretestauth(JSONObject content) throws YosException {
+        super(content);
+    }
+
+    String sat_courseware_testauth="sat_courseware_testauth";
+
+    @API(title = "考试权限新增", apiversion = R.ID20240328130602.v1.class)
+    public String add() throws YosException {
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        if (content.containsKey("sys_enterpriseids")) {
+            JSONArray sys_enterpriseids = content.getJSONArray("sys_enterpriseids");
+            for (Object obj : sys_enterpriseids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware_testauth");
+                insertSQL.setUniqueid(createTableID("sat_courseware_testauth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
+                insertSQL.setValue("sys_enterpriseid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_courseware_testauth where sys_enterpriseid=" + obj + " and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (content.containsKey("departmentids")) {
+            JSONArray departmentids = content.getJSONArray("departmentids");
+            for (Object obj : departmentids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware_testauth");
+                insertSQL.setUniqueid(createTableID("sat_courseware_testauth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
+                insertSQL.setValue("departmentid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_courseware_testauth where departmentid=" + obj + " and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (content.containsKey("hrids")) {
+            JSONArray hrids = content.getJSONArray("hrids");
+            for (Object obj : hrids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware_testauth");
+                insertSQL.setUniqueid(createTableID("sat_courseware_testauth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
+                insertSQL.setValue("hrid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_courseware_testauth where hrid=" + obj + " and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (content.containsKey("sa_saleareaids")) {
+            JSONArray sa_saleareaids = content.getJSONArray("sa_saleareaids");
+            for (Object obj : sa_saleareaids) {
+                InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware_testauth");
+                insertSQL.setUniqueid(createTableID("sat_courseware_testauth"));
+                insertSQL.setSiteid(siteid);
+                insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
+                insertSQL.setValue("sa_saleareaid", obj);
+                insertSQL.setWhere("not exists(select 1 from  sat_courseware_testauth where sa_saleareaid=" + obj + " and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
+                sqlList.add(insertSQL.getSQL());
+            }
+        }
+
+        if (sqlList.size() > 0) {
+            dbConnect.runSqlUpdate(sqlList);
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+
+    @API(title = "考试角色权限新增", apiversion = R.ID20240328130702.v1.class)
+    public String addrole() throws YosException {
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+
+        JSONArray roleids = content.getJSONArray("roleids");
+        for (Object obj : roleids) {
+            InsertSQL insertSQL = SQLFactory.createInsertSQL(this, "sat_courseware_testauth");
+            insertSQL.setUniqueid(createTableID("sat_courseware_testauth"));
+            insertSQL.setSiteid(siteid);
+            insertSQL.setValue("sat_courseware_testheadid", sat_courseware_testheadid);
+            insertSQL.setValue("roleid", obj);
+            insertSQL.setValue("roleid", obj);
+            insertSQL.setWhere("not exists(select 1 from  sat_courseware_testauth where roleid=" + obj + " and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
+            sqlList.add(insertSQL.getSQL());
+        }
+
+        if (sqlList.size() > 0) {
+            dbConnect.runSqlUpdate(sqlList);
+        }
+
+        DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_courseware_testauth");
+        deleteSQL.setSiteid(siteid);
+        deleteSQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadid);
+        deleteSQL.setWhere("roleid not in " + roleids.toString().replace("[", "(").replace("]", ")") + "");
+        deleteSQL.delete();
+        return getSucReturnObject().toString();
+    }
+
+    @API(title = "考试权限删除", apiversion = R.ID20240328130802.v1.class)
+    public String deleteQuanXian() throws YosException {
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+        ArrayList<String> sqlList = new ArrayList<>();
+
+        if (content.containsKey("sys_enterpriseids")) {
+            JSONArray sys_enterpriseids = content.getJSONArray("sys_enterpriseids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_courseware_testauth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadid);
+            deleteSQL.setWhere("sys_enterpriseid ", sys_enterpriseids.toArray());
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (content.containsKey("departmentids")) {
+            JSONArray departmentids = content.getJSONArray("departmentids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_courseware_testauth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadid);
+            deleteSQL.setWhere("departmentid ", departmentids);
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (content.containsKey("hrids")) {
+            JSONArray hrids = content.getJSONArray("hrids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_courseware_testauth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadid);
+            deleteSQL.setWhere("hrid ", hrids);
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (content.containsKey("sa_saleareaids")) {
+            JSONArray sa_saleareaids = content.getJSONArray("sa_saleareaids");
+            DeleteSQL deleteSQL = SQLFactory.createDeleteSQL(this, "sat_courseware_testauth");
+            deleteSQL.setSiteid(siteid);
+            deleteSQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadid);
+            deleteSQL.setWhere("sa_saleareaid ", sa_saleareaids);
+            sqlList.add(deleteSQL.getSQL());
+        }
+
+        if (sqlList.size() > 0) {
+            dbConnect.runSqlUpdate(sqlList);
+        }
+
+
+        return getSucReturnObject().toString();
+    }
+
+
+
+    @API(title = "考试部门列表",apiversion = R.ID20240328130902.v1.class)
+    public String depList() throws YosException {
+
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_department",
+                "departmentid", "depname", "depno");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t2", "t2.departmentid=t1.parentid and t2.siteid=t1.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_courseware_testauth", "t3", "t1.siteid=t3.siteid and t1.departmentid=t3.departmentid");
+        querySQL.addQueryFields("parentdepname","t2.depname");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_courseware_testheadid",sat_courseware_testheadid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "考试人员列表",apiversion = R.ID20240328131002.v1.class)
+    public String hrList() throws YosException {
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr",
+                "hrid", "hrcode", "name",  "position");
+        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t2", "t1.siteid=t2.siteid and t1.departmentid=t2.departmentid",
+                "depname");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_courseware_testauth", "t3", "t1.siteid=t3.siteid and t1.hrid=t3.hrid");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_courseware_testheadid",sat_courseware_testheadid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "考试区域列表",apiversion = R.ID20240328131102.v1.class)
+    public String areaList() throws YosException {
+
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_salearea",
+                "areaname", "sa_saleareaid");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t2", "t2.sa_saleareaid=t1.parentid and t2.siteid=t1.siteid");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_courseware_testauth", "t3", "t1.siteid=t3.siteid and t1.sa_saleareaid=t3.sa_saleareaid");
+        querySQL.addQueryFields("parentareaname","t2.areaname");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_courseware_testheadid",sat_courseware_testheadid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+
+        Rows rows = querySQL.query();
+
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+    @API(title = "考试合作伙伴列表",apiversion = R.ID20240328131202.v1.class)
+    public String enterpriseList() throws YosException {
+        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
+
+
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents",
+                "agentnum", "sys_enterpriseid", "type");
+
+        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
+                "enterprisename");
+        querySQL.addJoinTable(JOINTYPE.left, "sat_courseware_testauth", "t3", "t1.siteid=t3.siteid and t1.sys_enterpriseid=t3.sys_enterpriseid");
+        querySQL.setWhere("t1.siteid", siteid);
+        querySQL.setWhere("t3.sat_courseware_testheadid",sat_courseware_testheadid);
+        querySQL.setTableAlias("t1").setPage(pageSize, pageNumber);
+        Rows rows = querySQL.query();
+
+        SQLFactory sqlFactory = new SQLFactory(this, "查询经销商区域");
+        sqlFactory.addParameter_in("sys_enterpriseid", rows.toArray("sys_enterpriseid"));
+        sqlFactory.addParameter("siteid", siteid);
+        RowsMap areaRows = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sys_enterpriseid");
+
+        for (Row row : rows) {
+            Rows areas = areaRows.getOrDefault(row.getString("sys_enterpriseid"), new Rows());
+            row.put("areaname", StringUtils.join(areas.toArray("areaname"),","));
+        }
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+}

+ 53 - 161
src/custom/restcontroller/webmanage/saletool/courseware/coursewaretesthead.java

@@ -106,6 +106,17 @@ public class coursewaretesthead extends Controller {
         Rows rows = querySQL.query();
         Row detailRow = rows.isNotEmpty() ? rows.get(0) : new Row();
 
+        QuerySQL querySQL2 = SQLFactory.createQuerySQL(this, "sat_courseware_testauth",
+                "roleid");
+        querySQL2.addJoinTable(JOINTYPE.inner, "sys_role", "t2", "t1.roleid=t2.roleid and t1.siteid=t2.siteid",
+                "rolename");
+        querySQL2.setTableAlias("t1");
+        querySQL2.setWhere("t1.siteid", siteid);
+        querySQL2.setWhere("t1.sat_courseware_testheadid", sat_courseware_testheadid);
+        Rows roleRows = querySQL2.query();
+
+        detailRow.put("role", roleRows.toArrayList("roleid", new ArrayList<Long>()));
+
         JSONArray jsonArray = detailRow.getJSONArray("testquestions");
         detailRow.put("testquestions", jsonArray);
         for (Object object : jsonArray) {
@@ -327,10 +338,9 @@ public class coursewaretesthead extends Controller {
     }
 
 
-    @API(title = "添加人员和试卷", apiversion = R.ID20240325102202.v1.class)
+    @API(title = "生成试卷", apiversion = R.ID20240325102202.v1.class)
     public String addTest() throws YosException {
         Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
-        JSONArray userids = content.getJSONArray("userids");
 
         Rows testheadRows = dbConnect.runSqlQuery("SELECT * from sat_courseware_testhead WHERE sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "'");
         if (testheadRows.isEmpty()) {
@@ -350,13 +360,17 @@ public class coursewaretesthead extends Controller {
                             .collect(Collectors.toList())
             );
         }
-        ArrayList<String> sqlList = CoursewareHelper.getCoursewareTestSql(this, sat_courseware_testheadid, userids, testquestions);
+        Long sat_courseware_testid = createTableID("sat_courseware_test");
+        ArrayList<String> sqlList = CoursewareHelper.getCoursewareTestSql(this, sat_courseware_testheadid, sat_courseware_testid, testquestions);
         dbConnect.runSqlUpdate(sqlList);
 
-        return getSucReturnObject().toString();
+        Row row = new Row();
+        row.put("sat_courseware_testid", sat_courseware_testid);
+
+        return getSucReturnObject().setData(row).toString();
     }
 
-    @API(title = "删除人员和试卷", apiversion = R.ID20240325105502.v1.class)
+    @API(title = "删除试卷", apiversion = R.ID20240325105502.v1.class)
     public String deleteTest() throws YosException {
         Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
         JSONArray userids = content.getJSONArray("userids");
@@ -380,150 +394,6 @@ public class coursewaretesthead extends Controller {
         return getSucReturnObject().toString();
     }
 
-    @API(title = "选择员工列表", apiversion = R.ID20240325110702.v1.class)
-    public String query_hrList() throws YosException {
-        /*
-        过滤条件设置
-       */
-        StringBuffer where = new StringBuffer(" 1=1 ");
-        if (content.containsKey("where")) {
-            JSONObject whereObject = content.getJSONObject("where");
-            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                where.append(" and(");
-                where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t1.phonenumber like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t1.position like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t1.hrcode like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append(")");
-            }
-        }
-        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
-        boolean containssub = content.getBoolean("containssub");
-        JSONArray departmentidsArray = content.getJSONArray("departmentids");
-        ArrayList<Long> departmentidsList = new ArrayList<>();
-        for (Object o : departmentidsArray) {
-            long departmentid = Long.parseLong(o.toString());
-            departmentidsList.add(departmentid);
-            if (containssub) {
-                departmentidsList.addAll(Department.getSubDepartmentIds(this, departmentid));
-            }
-        }
-        where.append(" and not exists(select 1 from  sat_courseware_test where userid = t1.userid and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
-        SQLFactory sqlFactory = new SQLFactory(this, "员工列表查询", pageSize, pageNumber, pageSorting);
-        sqlFactory.addParameter("siteid", siteid);
-        sqlFactory.addParameter_in("departmentid", departmentidsList);
-        sqlFactory.addParameter_SQL("where", where);
-        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
-
-
-        return getSucReturnObject().setData(rows).toString();
-    }
-
-
-    @API(title = "选择营销区域查询经销商成员", apiversion = R.ID20240325130602.v1.class)
-    public String query_agent() throws YosException, IOException {
-        /*
-          过滤条件设置
-         */
-        StringBuffer where = new StringBuffer(" 1=1 ");
-        if (content.containsKey("where")) {
-            JSONObject whereObject = content.getJSONObject("where");
-            if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                where.append(" and(");
-                where.append("t1.name like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t1.position like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.province like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.city like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.county like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t2.address like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t3.agentnum like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append(")");
-            }
-        }
-        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
-
-        boolean containssub = content.getBoolean("containssub");
-        JSONArray sa_saleareaidsArray = content.getJSONArray("sa_saleareaids");
-        ArrayList<Long> sa_saleareaidsList = new ArrayList<>();
-        for (Object o : sa_saleareaidsArray) {
-            Long sa_saleareaid = Long.valueOf(o.toString());
-            sa_saleareaidsList.add(sa_saleareaid);
-            if (containssub) {
-                sa_saleareaidsList.addAll(SaleArea.getSubSaleAreaIds(this, sa_saleareaid));
-            }
-        }
-
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_hr",
-                        "userid", "name", "position")
-                .setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
-                "enterprisename", "province", "city", "county", "address");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t3", "t3.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid",
-                "type", "agentnum");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_tradefield", "t4", "t4.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t5", "t5.sa_saleareaid=t4.sa_saleareaid and t5.siteid=t4.siteid",
-                "areaname");
-        querySQL.setWhere("t1.siteid", siteid);
-        querySQL.setWhere("t4.sa_saleareaid", sa_saleareaidsList);
-        querySQL.setWhere(where.toString());
-        querySQL.setWhere("not exists(select 1 from  sat_courseware_test where userid = t1.userid and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
-        querySQL.setOrderBy(pageSorting);
-        querySQL.setPage(pageSize, pageNumber);
-        Rows rows = querySQL.query();
-
-        for (Row row : rows) {
-            row.put("pcc", row.getString("province") + row.getString("city") + row.getString("county"));
-
-        }
-
-
-        return getSucReturnObject().setData(rows).toString();
-    }
-
-    @API(title = "(部门)人员列表", apiversion = R.ID20240325134302.v1.class)
-    public String queryhrList() throws YosException {
-
-        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_hr",
-                        "hrid", "hrcode", "name", "phonenumber", "position", "userid")
-                .setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_department", "t2", "t1.siteid = t2.siteid and t1.departmentid = t2.departmentid",
-                "depname", "depfullname");
-        querySQL.setWhere(" exists(select 1 from  sat_courseware_test where userid = t1.userid and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
-        Rows rows = querySQL.query();
-
-
-        return getSucReturnObject().setData(rows).toString();
-    }
-
-    @API(title = "(区域)人员列表", apiversion = R.ID20240325135402.v1.class)
-    public String queryagent() throws YosException, IOException {
-
-        Long sat_courseware_testheadid = content.getLongValue("sat_courseware_testheadid");
-
-
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sys_enterprise_hr",
-                        "userid", "name", "position")
-                .setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
-                "enterprisename");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t3", "t3.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid",
-                "agentnum");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_tradefield", "t4", "t4.sys_enterpriseid=t1.sys_enterpriseid and t3.siteid=t1.siteid");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_salearea", "t5", "t5.sa_saleareaid=t4.sa_saleareaid and t5.siteid=t4.siteid",
-                "areaname");
-        querySQL.setWhere("t1.siteid", siteid);
-        querySQL.setWhere(" exists(select 1 from  sat_courseware_test where userid = t1.userid and sat_courseware_testheadid=" + sat_courseware_testheadid + " and siteid='" + siteid + "' )");
-        querySQL.setOrderBy(pageSorting);
-        querySQL.setPage(pageSize, pageNumber);
-        Rows rows = querySQL.query();
-
-
-        return getSucReturnObject().setData(rows).toString();
-    }
-
-
     @API(title = "试卷列表", apiversion = R.ID20240325141602.v1.class)
     public String testlist() throws YosException {
 
@@ -648,28 +518,50 @@ public class coursewaretesthead extends Controller {
                 }
             }
         }
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_courseware_testhead"
-                        , "sat_courseware_testheadid", "title", "num")
-                .setTableAlias("t1");
-        querySQL.addJoinTable(JOINTYPE.inner, "sat_courseware_test", "t2", "t2.sat_courseware_testheadid=t1.sat_courseware_testheadid and t2.siteid=t1.siteid"
-                , "sat_courseware_testid", "status", "score", "answercount");
-        querySQL.setWhere(where.toString());
-        if (!userInfo.isSysAdministrator()) {
-            querySQL.setWhere("t2.userid", userid);
+
+        ArrayList<Long> departmentids = new ArrayList<>();
+        departmentids.addAll(Department.getSubDepartmentIds(this, departmentid));
+        departmentids.add(departmentid);
+        if (departmentids.size() == 0) {
+            departmentids.add(-1l);
         }
 
-        querySQL.setSiteid(siteid);
-        querySQL.setPage(pageSize, pageNumber).setOrderBy(pageSorting);
-        Rows rows = querySQL.query();
+        ArrayList<Long> sa_saleareaids = new ArrayList<>();
+        sa_saleareaids.addAll(SaleArea.getSubSaleAreaIds(this, userInfo.getSaleAreaIds()));
+        sa_saleareaids.addAll(userInfo.getSaleAreaIds());
+        if (sa_saleareaids.size() == 0) {
+            sa_saleareaids.add(-1l);
+        }
+
+        ArrayList<Long> roleids = dbConnect.runSqlQuery("SELECT roleid from sys_userrole WHERE userid=" + userid + " and siteid='" + siteid + "' ").toArrayList("roleid", new ArrayList<>());
+        if (roleids.size() == 0) {
+            roleids.add(-1L);
+        }
+
+        SQLFactory sqlFactory = new SQLFactory(this, "我的考试列表", pageSize, pageNumber, pageSorting);
+        sqlFactory.addParameter_SQL("where", where);
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_in("departmentid", departmentids);
+        sqlFactory.addParameter_in("hrid", hrid);
+        sqlFactory.addParameter_in("userid", userid);
+        sqlFactory.addParameter_in("sys_enterpriseid", sys_enterpriseid);
+        sqlFactory.addParameter_in("sa_saleareaid", sa_saleareaids);
+        sqlFactory.addParameter_in("roleid", roleids);
+        String sql = sqlFactory.getSQL();
+        Rows rows = dbConnect.runSqlQuery(sql);
+
 
         for (Row row : rows) {
             row.put("answerinfo", row.getString("answercount") + "/" + row.getString("num"));
             row.putIfAbsent("score", 0.0);
+            if (row.getString("status").equals("")) {
+                row.put("status", "未开始");
+            }
         }
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "查询我的考试列表", apiversion = R.ID20240326145902.v1.class)
+    @API(title = "考试提交", apiversion = R.ID20240326145902.v1.class)
     public String submit() throws YosException {
 
         JSONArray answers = content.getJSONArray("answers");

+ 5 - 5
src/custom/restcontroller/webmanage/saletool/notice/noticeauth.java

@@ -332,7 +332,7 @@ public class noticeauth extends Controller {
         return getSucReturnObject().toString();
     }
 
-    @API(title = "通告角色权限删除", apiversion = R.ID20240312142702.v1.class)
+    @API(title = "通告权限删除", apiversion = R.ID20240312142702.v1.class)
     public String deleteQuanXian() throws YosException {
         Long sat_noticeid = content.getLongValue("sat_noticeid");
 
@@ -455,7 +455,7 @@ public class noticeauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "部门列表", apiversion = R.ID20240312162402.v1.class)
+    @API(title = "通告部门列表", apiversion = R.ID20240312162402.v1.class)
     public String depList() throws YosException {
 
         Long sat_noticeid = content.getLongValue("sat_noticeid");
@@ -475,7 +475,7 @@ public class noticeauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "人员列表", apiversion = R.ID20240312161602.v1.class)
+    @API(title = "通告人员列表", apiversion = R.ID20240312161602.v1.class)
     public String hrList() throws YosException {
         Long sat_noticeid = content.getLongValue("sat_noticeid");
 
@@ -493,7 +493,7 @@ public class noticeauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "区域列表", apiversion = R.ID20240312163202.v1.class)
+    @API(title = "通告区域列表", apiversion = R.ID20240312163202.v1.class)
     public String areaList() throws YosException {
 
         Long sat_noticeid = content.getLongValue("sat_noticeid");
@@ -513,7 +513,7 @@ public class noticeauth extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
-    @API(title = "合作伙伴列表", apiversion = R.ID20240312163702.v1.class)
+    @API(title = "通告合作伙伴列表", apiversion = R.ID20240312163702.v1.class)
     public String enterpriseList() throws YosException {
         Long sat_noticeid = content.getLongValue("sat_noticeid");