|
|
@@ -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");
|