|
@@ -1,5 +1,6 @@
|
|
|
package biz.kcb;
|
|
package biz.kcb;
|
|
|
|
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.sql.SQLException;
|
|
import java.sql.SQLException;
|
|
|
import java.sql.Timestamp;
|
|
import java.sql.Timestamp;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
@@ -634,6 +635,15 @@ public class RjkcbHomepServ extends Serv {
|
|
|
+ "nvl(cd.MC,'') CD_MC,"
|
|
+ "nvl(cd.MC,'') CD_MC,"
|
|
|
+ "nvl(jz.MC,'') JZ_MC,"
|
|
+ "nvl(jz.MC,'') JZ_MC,"
|
|
|
+ "nvl(k.DDMS,'') DDMS,nvl(k.MS,'') MS,"
|
|
+ "nvl(k.DDMS,'') DDMS,nvl(k.MS,'') MS,"
|
|
|
|
|
+ + "case when exists(select 1 from BJDM d"
|
|
|
|
|
+ + " where d.BJID=k.BJID and d.DMRYID=:dmRyid"
|
|
|
|
|
+ + " and d.JKSSJ=k.KSSJ and d.JJSSJ=k.JSSJ"
|
|
|
|
|
+ + " and " + ObjC.JLZT_useStr + ") then 1 else 0 end DM_DONE,"
|
|
|
|
|
+ + "case when exists(select 1 from JXRZ j"
|
|
|
|
|
+ + " where j.RYID=:jxrzRyid"
|
|
|
|
|
+ + " and (j.KCBID=k.KCBID or j.KCBID=k.SJKCBID)"
|
|
|
|
|
+ + " and " + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and nvl(length(trim(j.MSWJ)),0)>0) then 1 else 0 end LOG_DONE,"
|
|
|
+ "case when k.KSSJ<=SYSTIMESTAMP and k.JSSJ>=SYSTIMESTAMP "
|
|
+ "case when k.KSSJ<=SYSTIMESTAMP and k.JSSJ>=SYSTIMESTAMP "
|
|
|
+ "then 'current' when k.KSSJ>SYSTIMESTAMP "
|
|
+ "then 'current' when k.KSSJ>SYSTIMESTAMP "
|
|
|
+ "then 'upcoming' else 'past' end STATUS"
|
|
+ "then 'upcoming' else 'past' end STATUS"
|
|
@@ -650,6 +660,8 @@ public class RjkcbHomepServ extends Serv {
|
|
|
+ " order by k.KSSJ,k.JCM,k.KCBID";
|
|
+ " order by k.KSSJ,k.JCM,k.KCBID";
|
|
|
SqlCmd sqlCmd = new SqlCmd(sql);
|
|
SqlCmd sqlCmd = new SqlCmd(sql);
|
|
|
sqlCmd.wrLongParm("ryid", userId);
|
|
sqlCmd.wrLongParm("ryid", userId);
|
|
|
|
|
+ sqlCmd.wrLongParm("dmRyid", userId);
|
|
|
|
|
+ sqlCmd.wrLongParm("jxrzRyid", userId);
|
|
|
List<Map<String, Object>> courseList =
|
|
List<Map<String, Object>> courseList =
|
|
|
gdba.doSelMapListByC(sqlCmd);
|
|
gdba.doSelMapListByC(sqlCmd);
|
|
|
if (courseList == null)
|
|
if (courseList == null)
|
|
@@ -664,17 +676,19 @@ public class RjkcbHomepServ extends Serv {
|
|
|
course.put("weekdayText", rdWeekdayText(course.get("tc")));
|
|
course.put("weekdayText", rdWeekdayText(course.get("tc")));
|
|
|
course.put("periodText", mkPeriodText(
|
|
course.put("periodText", mkPeriodText(
|
|
|
course.get("jcm"), course.get("ltjs"), course.get("jc_mc")));
|
|
course.get("jcm"), course.get("ltjs"), course.get("jc_mc")));
|
|
|
- String location = StringUtils.trimToEmpty(
|
|
|
|
|
- String.valueOf(course.get("cd_mc")));
|
|
|
|
|
|
|
+ String location = rdMpText(course.get("cd_mc"));
|
|
|
if (location.isEmpty())
|
|
if (location.isEmpty())
|
|
|
- location = StringUtils.trimToEmpty(
|
|
|
|
|
- String.valueOf(course.get("ddms")));
|
|
|
|
|
|
|
+ location = rdMpText(course.get("ddms"));
|
|
|
if (location.isEmpty())
|
|
if (location.isEmpty())
|
|
|
location = rdOriginalLocation(
|
|
location = rdOriginalLocation(
|
|
|
- String.valueOf(course.get("ms")));
|
|
|
|
|
|
|
+ rdMpText(course.get("ms")));
|
|
|
course.put("location", location);
|
|
course.put("location", location);
|
|
|
|
|
+ course.put("dmDone", rdMpDone(course.get("dm_done")));
|
|
|
|
|
+ course.put("logDone", rdMpDone(course.get("log_done")));
|
|
|
course.put("isToday",
|
|
course.put("isToday",
|
|
|
anchorDate.toString().equals(course.get("course_date")));
|
|
anchorDate.toString().equals(course.get("course_date")));
|
|
|
|
|
+ course.remove("dm_done");
|
|
|
|
|
+ course.remove("log_done");
|
|
|
course.remove("ms");
|
|
course.remove("ms");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -695,6 +709,217 @@ public class RjkcbHomepServ extends Serv {
|
|
|
super.wrJsonByResp(result);
|
|
super.wrJsonByResp(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 小程序课堂日志加载。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 课程与教师身份均由后端重新校验,前端只用于展示。
|
|
|
|
|
+ */
|
|
|
|
|
+ @SuppressWarnings("unused")
|
|
|
|
|
+ public void loadMpJxrzByA() {
|
|
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
|
|
+ Long userId = UserU.rdUserIdByReq(request);
|
|
|
|
|
+ String kcbidStr = request.getParameter("kcbid");
|
|
|
|
|
+ if (userId == null) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "登录状态已失效,请重新登录");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(kcbidStr)) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "缺少课程ID");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
|
|
+ long kcbid = Long.parseLong(kcbidStr);
|
|
|
|
|
+ Map<String, Object> course = selMpJxrzCourse(gdba, kcbid, userId);
|
|
|
|
|
+ if (course == null) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "无权访问该课程或课程不存在");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Object sjkcbidsObj = course.get("sjkcbids");
|
|
|
|
|
+ String logSql = "select * from ("
|
|
|
|
|
+ + "select JXRZID,MSWJ,FJID,JLZTM from JXRZ"
|
|
|
|
|
+ + " where RYID=:ryid and " + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and (KCBID=:kcbid";
|
|
|
|
|
+ if (sjkcbidsObj != null)
|
|
|
|
|
+ logSql += " or KCBID=:sjkcbids";
|
|
|
|
|
+ logSql += ") order by JXRZID desc) where rownum=1";
|
|
|
|
|
+ SqlCmd logCmd = new SqlCmd(logSql);
|
|
|
|
|
+ logCmd.wrLongParm("ryid", userId);
|
|
|
|
|
+ logCmd.wrLongParm("kcbid", kcbid);
|
|
|
|
|
+ if (sjkcbidsObj != null)
|
|
|
|
|
+ logCmd.wrLongParm("sjkcbids", sjkcbidsObj);
|
|
|
|
|
+ gdba.doSelByC(logCmd);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> log = new LinkedHashMap<>();
|
|
|
|
|
+ boolean exists = gdba.rowNum == 1;
|
|
|
|
|
+ log.put("exists", exists);
|
|
|
|
|
+ if (exists) {
|
|
|
|
|
+ log.put("jxrzid", gdba.rdLongCol("jxrzid"));
|
|
|
|
|
+ log.put("content", StringUtils.defaultString(gdba.rdStrCol("mswj")));
|
|
|
|
|
+ log.put("fjid", gdba.rdLongCol("fjid"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.put("content", "");
|
|
|
|
|
+ log.put("fjid", null);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ result.put("ok", true);
|
|
|
|
|
+ result.put("course", course);
|
|
|
|
|
+ result.put("log", log);
|
|
|
|
|
+ result.put("maxLength", 80);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log4j.error("RjkcbHomepServ.loadMpJxrzByA() 异常", e);
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "课堂日志加载失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 小程序课堂日志保存。
|
|
|
|
|
+ *
|
|
|
|
|
+ * 同一教师、同一课程(含主课程)保留一条在用日志。
|
|
|
|
|
+ */
|
|
|
|
|
+ @SuppressWarnings("unused")
|
|
|
|
|
+ public void saveMpJxrzByA() {
|
|
|
|
|
+ HttpServletRequest request = super.req;
|
|
|
|
|
+ Map<String, Object> result = new LinkedHashMap<>();
|
|
|
|
|
+ UserRunB user = UserU.rdUserByReq(request);
|
|
|
|
|
+ String kcbidStr = request.getParameter("kcbid");
|
|
|
|
|
+ String content = StringUtils.trimToEmpty(request.getParameter("mswj"));
|
|
|
|
|
+ if (user == null) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "登录状态已失效,请重新登录");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(kcbidStr)) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "缺少课程ID");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isBlank(content)) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "请填写课堂日志");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (content.getBytes(StandardCharsets.UTF_8).length > 255) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "课堂日志不能超过80个中文");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try (Db gdba = Db.makeConn()) {
|
|
|
|
|
+ long kcbid = Long.parseLong(kcbidStr);
|
|
|
|
|
+ Map<String, Object> course = selMpJxrzCourse(gdba, kcbid, user.ryid);
|
|
|
|
|
+ if (course == null) {
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "无权保存该课程课堂日志或课程不存在");
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ Object sjkcbidsObj = course.get("sjkcbids");
|
|
|
|
|
+ long savedKcbid = sjkcbidsObj == null ? kcbid
|
|
|
|
|
+ : Long.parseLong(String.valueOf(sjkcbidsObj));
|
|
|
|
|
+
|
|
|
|
|
+ String updateSql = "update JXRZ set MSWJ=:mswj,"
|
|
|
|
|
+ + "GLRYID=:glryid"
|
|
|
|
|
+ + " where RYID=:ryid and " + ObjC.JLZT_useStr
|
|
|
|
|
+ + " and (KCBID=:kcbid";
|
|
|
|
|
+ if (sjkcbidsObj != null)
|
|
|
|
|
+ updateSql += " or KCBID=:sjkcbids";
|
|
|
|
|
+ updateSql += ")";
|
|
|
|
|
+ SqlCmd updateCmd = new SqlCmd(updateSql);
|
|
|
|
|
+ updateCmd.wrStrParm("mswj", content);
|
|
|
|
|
+ updateCmd.wrLongParm("glryid", user.ryid);
|
|
|
|
|
+ updateCmd.wrLongParm("ryid", user.ryid);
|
|
|
|
|
+ updateCmd.wrLongParm("kcbid", kcbid);
|
|
|
|
|
+ if (sjkcbidsObj != null)
|
|
|
|
|
+ updateCmd.wrLongParm("sjkcbids", sjkcbidsObj);
|
|
|
|
|
+ int changed = gdba.doModByC(updateCmd);
|
|
|
|
|
+
|
|
|
|
|
+ if (changed == 0) {
|
|
|
|
|
+ SqlCmd insertCmd = new SqlCmd(
|
|
|
|
|
+ "insert into JXRZ"
|
|
|
|
|
+ + "(KCBID,RYID,MSWJ,JLZTM,CJRYID,GLRYID)"
|
|
|
|
|
+ + " values(:kcbid,:ryid,:mswj,:jlztm,:cjryid,:glryid)");
|
|
|
|
|
+ insertCmd.wrLongParm("kcbid", savedKcbid);
|
|
|
|
|
+ insertCmd.wrLongParm("ryid", user.ryid);
|
|
|
|
|
+ insertCmd.wrStrParm("mswj", content);
|
|
|
|
|
+ insertCmd.wrIntParm("jlztm", ObjC.JLZT_inUse);
|
|
|
|
|
+ insertCmd.wrLongParm("cjryid", user.ryid);
|
|
|
|
|
+ insertCmd.wrLongParm("glryid", user.ryid);
|
|
|
|
|
+ gdba.doModByC(insertCmd);
|
|
|
|
|
+ }
|
|
|
|
|
+ gdba.commit();
|
|
|
|
|
+ result.put("ok", true);
|
|
|
|
|
+ result.put("msg", "保存成功");
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log4j.error("RjkcbHomepServ.saveMpJxrzByA() 异常", e);
|
|
|
|
|
+ result.put("ok", false);
|
|
|
|
|
+ result.put("msg", "课堂日志保存失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ super.wrJsonByResp(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Map<String, Object> selMpJxrzCourse(
|
|
|
|
|
+ Db gdba, long kcbid, long userId) throws SQLException {
|
|
|
|
|
+ SqlCmd cmd = new SqlCmd(
|
|
|
|
|
+ "select k.KCBID,k.SJKCBID,k.KCID,k.BJID,k.FZRYID,"
|
|
|
|
|
+ + "nvl(kc.MC,k.MC) KCM,nvl(bj.MC,'') BJMC,"
|
|
|
|
|
+ + "to_char(k.KSSJ,'YYYY-MM-DD') COURSE_DATE,"
|
|
|
|
|
+ + "to_char(k.KSSJ,'HH24')||chr(58)||to_char(k.KSSJ,'MI') START_TIME,"
|
|
|
|
|
+ + "to_char(k.JSSJ,'HH24')||chr(58)||to_char(k.JSSJ,'MI') END_TIME,"
|
|
|
|
|
+ + "k.ZC,k.TC,k.JCM,nvl(k.LTJS,0) LTJS,"
|
|
|
|
|
+ + "nvl(jc.MC,'') JC_MC"
|
|
|
|
|
+ + " from KCB k"
|
|
|
|
|
+ + " left join KC kc on kc.KCID=k.KCID"
|
|
|
|
|
+ + " left join BJ bj on bj.BJID=k.BJID"
|
|
|
|
|
+ + " left join JC jc on jc.JCM=k.JCM"
|
|
|
|
|
+ + " where k.KCBID=:kcbid"
|
|
|
|
|
+ + " and (k.FZRYID=:ryid"
|
|
|
|
|
+ + " or exists(select 1 from KCBCY kcbcy"
|
|
|
|
|
+ + " where kcbcy.KCBID=k.KCBID and kcbcy.RYID=:kcbcyRyid))"
|
|
|
|
|
+ + " and k.JLZTM in (22,25,51,81)");
|
|
|
|
|
+ cmd.wrLongParm("kcbid", kcbid);
|
|
|
|
|
+ cmd.wrLongParm("ryid", userId);
|
|
|
|
|
+ cmd.wrLongParm("kcbcyRyid", userId);
|
|
|
|
|
+ gdba.doSelByC(cmd);
|
|
|
|
|
+ if (gdba.rowNum != 1)
|
|
|
|
|
+ return null;
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> course = new LinkedHashMap<>();
|
|
|
|
|
+ course.put("kcbid", gdba.rdLongCol("kcbid"));
|
|
|
|
|
+ Long sjkcbids = gdba.rdLongCol("SJKCBID");
|
|
|
|
|
+ course.put("sjkcbids", sjkcbids == null || sjkcbids == 0
|
|
|
|
|
+ ? null : sjkcbids);
|
|
|
|
|
+ course.put("kcid", gdba.rdLongCol("kcid"));
|
|
|
|
|
+ course.put("bjid", gdba.rdLongCol("bjid"));
|
|
|
|
|
+ course.put("kcm", StringUtils.defaultString(gdba.rdStrCol("kcm")));
|
|
|
|
|
+ course.put("bjmc", StringUtils.defaultString(gdba.rdStrCol("bjmc")));
|
|
|
|
|
+ course.put("courseDate", gdba.rdStrCol("course_date"));
|
|
|
|
|
+ course.put("startTime", gdba.rdStrCol("start_time"));
|
|
|
|
|
+ course.put("endTime", gdba.rdStrCol("end_time"));
|
|
|
|
|
+ course.put("tc", gdba.rdIntCol("tc"));
|
|
|
|
|
+ course.put("jcm", gdba.rdIntCol("jcm"));
|
|
|
|
|
+ course.put("ltjs", gdba.rdIntCol("ltjs"));
|
|
|
|
|
+ course.put("jcMc", StringUtils.defaultString(gdba.rdStrCol("jc_mc")));
|
|
|
|
|
+ course.put("weekdayText", rdWeekdayText(course.get("tc")));
|
|
|
|
|
+ course.put("periodText", mkPeriodText(
|
|
|
|
|
+ course.get("jcm"), course.get("ltjs"), course.get("jcMc")));
|
|
|
|
|
+ return course;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private LocalDate rdMpKcbDate(HttpServletRequest request) {
|
|
private LocalDate rdMpKcbDate(HttpServletRequest request) {
|
|
|
String dateStr = StringUtils.defaultIfBlank(
|
|
String dateStr = StringUtils.defaultIfBlank(
|
|
|
request.getParameter("rq"), request.getParameter("date"));
|
|
request.getParameter("rq"), request.getParameter("date"));
|
|
@@ -754,6 +979,20 @@ public class RjkcbHomepServ extends Serv {
|
|
|
return StringUtils.trimToEmpty(location);
|
|
return StringUtils.trimToEmpty(location);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String rdMpText(Object value) {
|
|
|
|
|
+ if (value == null)
|
|
|
|
|
+ return "";
|
|
|
|
|
+ String text = StringUtils.trimToEmpty(String.valueOf(value));
|
|
|
|
|
+ return "null".equalsIgnoreCase(text) ? "" : text;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean rdMpDone(Object value) {
|
|
|
|
|
+ if (value instanceof Number)
|
|
|
|
|
+ return ((Number) value).intValue() > 0;
|
|
|
|
|
+ String text = rdMpText(value);
|
|
|
|
|
+ return "1".equals(text) || "true".equalsIgnoreCase(text);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 添加班级点名标记
|
|
* 添加班级点名标记
|