|
@@ -1,16 +1,22 @@
|
|
|
package restcontroller.webmanage.saletool.courseware;
|
|
|
|
|
|
+import beans.department.Department;
|
|
|
+import beans.salearea.SaleArea;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import common.Controller;
|
|
|
import common.YosException;
|
|
|
import common.annotation.API;
|
|
|
+import common.annotation.CACHEING;
|
|
|
import common.data.*;
|
|
|
import restcontroller.R;
|
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.IntStream;
|
|
|
|
|
|
/**
|
|
|
* 考试表头
|
|
@@ -166,8 +172,6 @@ public class coursewaretesthead extends Controller {
|
|
|
testquestions.removeAll(CoursewareHelper.getRemoveArray(testquestions, sat_courseware_testlibraryids));
|
|
|
//添加考试题目
|
|
|
testquestions.addAll(CoursewareHelper.getTestlibraryRows(this, sat_courseware_testlibraryids));
|
|
|
- //设置考试分数
|
|
|
- testquestions = CoursewareHelper.setTestquestionsScore(testquestions);
|
|
|
|
|
|
|
|
|
int testaddmode = testheadRows.get(0).getInteger("testaddmode");
|
|
@@ -202,9 +206,6 @@ public class coursewaretesthead extends Controller {
|
|
|
//移除考试题目
|
|
|
testquestions.removeAll(CoursewareHelper.getRemoveArray(testquestions, sat_courseware_testlibraryids));
|
|
|
|
|
|
- //设置考试分数
|
|
|
- testquestions = CoursewareHelper.setTestquestionsScore(testquestions);
|
|
|
-
|
|
|
|
|
|
int testaddmode = testheadRows.get(0).getInteger("testaddmode");
|
|
|
|
|
@@ -244,7 +245,7 @@ public class coursewaretesthead extends Controller {
|
|
|
}
|
|
|
if (whereObject.containsKey("sat_courseware_classids") && !"".equals(whereObject.getString("sat_courseware_classids"))) {
|
|
|
JSONArray sat_courseware_classids = whereObject.getJSONArray("sat_courseware_classids");
|
|
|
- if(sat_courseware_classids.size()>0) {
|
|
|
+ if (sat_courseware_classids.size() > 0) {
|
|
|
where.append(" and (1=2");
|
|
|
for (Object obj : sat_courseware_classids) {
|
|
|
JSONArray array = (JSONArray) obj;
|
|
@@ -303,4 +304,162 @@ public class coursewaretesthead extends Controller {
|
|
|
|
|
|
return getSucReturnObject().setData(rows).toString();
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @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()) {
|
|
|
+ return getErrReturnObject().setErrMsg("考试不存在").toString();
|
|
|
+ }
|
|
|
+ int testaddmode = testheadRows.get(0).getInteger("testaddmode");
|
|
|
+ int num = testheadRows.get(0).getInteger("num");
|
|
|
+ JSONArray testquestions = testheadRows.get(0).getJSONArray("testquestions");
|
|
|
+ if (testaddmode == 1) {
|
|
|
+ if (num > testquestions.size()) {
|
|
|
+ return getErrReturnObject().setErrMsg("无法添加,题库数量小于考试题目数量").toString();
|
|
|
+ }
|
|
|
+ Collections.shuffle(testquestions);
|
|
|
+ testquestions = new JSONArray(
|
|
|
+ IntStream.range(0, num)
|
|
|
+ .mapToObj(testquestions::get)
|
|
|
+ .collect(Collectors.toList())
|
|
|
+ );
|
|
|
+ }
|
|
|
+ ArrayList<String> sqlList = CoursewareHelper.getCoursewareTestSql(this, sat_courseware_testheadid, userids, testquestions);
|
|
|
+ dbConnect.runSqlUpdate(sqlList);
|
|
|
+
|
|
|
+ return getSucReturnObject().toString();
|
|
|
+ }
|
|
|
+
|
|
|
+ @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");
|
|
|
+
|
|
|
+ QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sat_courseware_test", "sat_courseware_testid");
|
|
|
+ querySQL.setSiteid(siteid);
|
|
|
+ querySQL.setWhere("sat_courseware_testheadid", sat_courseware_testheadid);
|
|
|
+ querySQL.setWhere("userid", userids.toArray());
|
|
|
+ ArrayList ids = querySQL.query().toArrayList("sat_courseware_testid");
|
|
|
+
|
|
|
+ DeleteSQL deleteSQL=SQLFactory.createDeleteSQL(this,"sat_courseware_test");
|
|
|
+ deleteSQL.setSiteid(siteid);
|
|
|
+ deleteSQL.setWhere("sat_courseware_testid",ids);
|
|
|
+ deleteSQL.delete();
|
|
|
+
|
|
|
+ DeleteSQL deleteSQL2=SQLFactory.createDeleteSQL(this,"sat_courseware_testitems");
|
|
|
+ deleteSQL2.setSiteid(siteid);
|
|
|
+ deleteSQL2.setWhere("sat_courseware_testid",ids);
|
|
|
+ deleteSQL2.delete();
|
|
|
+
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|