Browse Source

课表导入

tags/正式3.3.0
雍文秀 2 years ago
parent
commit
a50c47475c

+ 0
- 7
slive/src/main/java/com/xhkjedu/slive/controller/xz/XzController.java View File

184
         Integer xzid = xz.getXzid();
184
         Integer xzid = xz.getXzid();
185
         Integer createid = xz.getCreateid();
185
         Integer createid = xz.getCreateid();
186
         N_Utils.validation(new Object[]{xzid, "行政直播id", 1, createid, "创建人id", 1});
186
         N_Utils.validation(new Object[]{xzid, "行政直播id", 1, createid, "创建人id", 1});
187
-        /*Map<String, Object> map = PoiUtils.readKb(file, xz, xzService);
188
-        Integer code = (Integer) map.get("code");
189
-        if (code != 0) return new ResultVo(1, map.get("msg").toString());
190
-        LinkedHashMap<Integer, List<String>> errMsg = (LinkedHashMap<Integer, List<String>>) map.get("errMsg");
191
-        if (errMsg.size() != 0) return new ResultVo(1, null, errMsg);
192
-        List<XzDateVo> xzdatas = (List<XzDateVo>) map.get("xzdatas");*/
193
         return xzService.importKb(file, xzid, createid);
187
         return xzService.importKb(file, xzid, createid);
194
-        //return new ResultVo(0, "导入评价用户成功");
195
     }
188
     }
196
 
189
 
197
 }
190
 }

+ 3
- 0
slive/src/main/java/com/xhkjedu/slive/mapper/gradeclass/ClassTeacherMapper.java View File

25
 
25
 
26
     //获取科目列表
26
     //获取科目列表
27
     List<CTeacherVo> listSubjectBySubjectIds(@Param("subjectids") String subjectids);
27
     List<CTeacherVo> listSubjectBySubjectIds(@Param("subjectids") String subjectids);
28
+
29
+    //获取学校所有教师
30
+    List<CTeacherVo> listTeacherBySchoolId(@Param("schoolid") Integer schoolid);
28
 }
31
 }

+ 10
- 2
slive/src/main/java/com/xhkjedu/slive/service/xz/XzService.java View File

725
         try {
725
         try {
726
             //获取行政直播信息
726
             //获取行政直播信息
727
             LXz xz = xzMapper.selectByPrimaryKey(xzid);
727
             LXz xz = xzMapper.selectByPrimaryKey(xzid);
728
+            List<XzKjVo> kjs = xzKjMapper.listXzKjByXzId(xzid);//获取行政直播课节详情
729
+            Integer noTimeKjNum = kjs.stream().filter(k -> k.getBegintime() == null).collect(Collectors.toList()).size();
730
+            if (noTimeKjNum != 0) return new ResultVo(1, "请设置课节时间");
728
 
731
 
729
             //根据行政直播id获取该学校当前年份指定年级下的行政班和提高班
732
             //根据行政直播id获取该学校当前年份指定年级下的行政班和提高班
730
             Integer gradeid = xz.getGradeid();
733
             Integer gradeid = xz.getGradeid();
740
             Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid, CTeacherVo::getSubjectname));
743
             Map<String, String> subjectNameMap = subjects2.stream().collect(Collectors.toMap(CTeacherVo::getSubjectid, CTeacherVo::getSubjectname));
741
             Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid, CTeacherVo::getSubjectid));
744
             Map<Integer, String> subjectMap = subjects.stream().collect(Collectors.toMap(CTeacherVo::getTeacherid, CTeacherVo::getSubjectid));
742
             Map<Integer, String> classMap = classlst.stream().collect(Collectors.toMap(XzClassVo::getClassid, XzClassVo::getClassname));
745
             Map<Integer, String> classMap = classlst.stream().collect(Collectors.toMap(XzClassVo::getClassid, XzClassVo::getClassname));
746
+            List<CTeacherVo> users = classTeacherMapper.listTeacherBySchoolId(schoolid);//获取学校所有教师
747
+            Set<String> userNameSet = users.stream().map(CTeacherVo::getUsername).collect(Collectors.toCollection(TreeSet::new));
743
             Map<String, CTeacherVo> classTeacherMap = new HashMap<>();//班级教师map
748
             Map<String, CTeacherVo> classTeacherMap = new HashMap<>();//班级教师map
744
             for (CTeacherVo teacher : teachers) {
749
             for (CTeacherVo teacher : teachers) {
750
+                CTeacherVo vo = users.stream().filter(u -> u.getTeacherid().equals(teacher.getTeacherid())).findFirst().orElse(null);
751
+                if (vo != null) teacher.setUsername(vo.getUsername());
745
                 teacher.setClassname(classMap.get(teacher.getClassid()));
752
                 teacher.setClassname(classMap.get(teacher.getClassid()));
746
                 teacher.setSubjectid(subjectMap.get(teacher.getTeacherid()));
753
                 teacher.setSubjectid(subjectMap.get(teacher.getTeacherid()));
747
                 teacher.setSubjectname(subjectNameMap.get(teacher.getSubjectid()));
754
                 teacher.setSubjectname(subjectNameMap.get(teacher.getSubjectid()));
748
                 classTeacherMap.put(teacher.getClassname() + "_" + teacher.getUsername(), teacher);
755
                 classTeacherMap.put(teacher.getClassname() + "_" + teacher.getUsername(), teacher);
749
             }
756
             }
750
-            List<XzKjVo> kjs = xzKjMapper.listXzKjByXzId(xzid);//获取行政直播课节详情
751
 
757
 
752
-            Map<String, Object> map = PoiUtils.readKb(file, xz, classTeacherMap, kjs);
758
+            Map<String, Object> map = PoiUtils.readKb(file, xz, classTeacherMap, userNameSet, kjs);
753
             Integer code = (Integer) map.get("code");
759
             Integer code = (Integer) map.get("code");
754
             if (code != 0) return new ResultVo(1, map.get("msg").toString());
760
             if (code != 0) return new ResultVo(1, map.get("msg").toString());
755
             LinkedHashMap<String, List<String>> errMsg = (LinkedHashMap<String, List<String>>) map.get("errMsg");
761
             LinkedHashMap<String, List<String>> errMsg = (LinkedHashMap<String, List<String>>) map.get("errMsg");
819
                 c.setGradeid(gradeid);
825
                 c.setGradeid(gradeid);
820
                 c.setClasstype(99);//已直播班级
826
                 c.setClasstype(99);//已直播班级
821
                 c.setCreatetime(createtime);
827
                 c.setCreatetime(createtime);
828
+                c.setClassnum(0);
829
+                c.setClassstate(1);
822
                 classList.add(c);
830
                 classList.add(c);
823
 
831
 
824
                 TClassTeacher ct = new TClassTeacher();
832
                 TClassTeacher ct = new TClassTeacher();

+ 25
- 10
slive/src/main/java/com/xhkjedu/slive/utils/PoiUtils.java View File

24
 import java.util.LinkedHashMap;
24
 import java.util.LinkedHashMap;
25
 import java.util.List;
25
 import java.util.List;
26
 import java.util.Map;
26
 import java.util.Map;
27
+import java.util.Set;
27
 import java.util.stream.Collectors;
28
 import java.util.stream.Collectors;
28
 
29
 
29
 /**
30
 /**
167
      * @Date 2022/6/21 15:13
168
      * @Date 2022/6/21 15:13
168
      **/
169
      **/
169
     public static Map<String, Object> readKb(MultipartFile file, LXz xz
170
     public static Map<String, Object> readKb(MultipartFile file, LXz xz
170
-            , Map<String, CTeacherVo> classTeacherMap, List<XzKjVo> kjs) {
171
+            , Map<String, CTeacherVo> classTeacherMap, Set<String> userNameSet, List<XzKjVo> kjs) {
171
         Map<String, Object> resultMap = new HashMap<>();
172
         Map<String, Object> resultMap = new HashMap<>();
172
         Map<String, List<String>> errMsg = new LinkedHashMap<>();
173
         Map<String, List<String>> errMsg = new LinkedHashMap<>();
173
         try {
174
         try {
192
                 sheet = work.getSheetAt(i);
193
                 sheet = work.getSheetAt(i);
193
                 String sheetName = sheet.getSheetName();
194
                 String sheetName = sheet.getSheetName();
194
                 String sectiondate = weeks.get(sheetName);
195
                 String sectiondate = weeks.get(sheetName);
196
+                if (sectiondate == null) continue;//没有当天的课不处理
195
                 int rows = sheet.getLastRowNum(); // 获取最后一个实际行的下标,比行数小1
197
                 int rows = sheet.getLastRowNum(); // 获取最后一个实际行的下标,比行数小1
196
                 int firstRowNum = sheet.getFirstRowNum(); // 获取第一个实际行的下标,(firstRowNum=0)
198
                 int firstRowNum = sheet.getFirstRowNum(); // 获取第一个实际行的下标,(firstRowNum=0)
197
                 //遍历当前sheet中的所有行,排除第一行(标题)不纳入遍历
199
                 //遍历当前sheet中的所有行,排除第一行(标题)不纳入遍历
207
                     int lastCellNum = row.getLastCellNum();// 每一行的最后一列,获取列数,比最后一列列标大1
209
                     int lastCellNum = row.getLastCellNum();// 每一行的最后一列,获取列数,比最后一列列标大1
208
                     if (lastCellNum > daynum) lastCellNum = daynum;//节数大于课程的节数不处理
210
                     if (lastCellNum > daynum) lastCellNum = daynum;//节数大于课程的节数不处理
209
                     List<String> mrows = new ArrayList<>();
211
                     List<String> mrows = new ArrayList<>();
212
+                    String errMsgKey = sheetName + "第" + (x + 1) + "行";
210
                     //遍历所有的列
213
                     //遍历所有的列
211
                     String classname = getCellValue(row.getCell(0));//第一列为班级
214
                     String classname = getCellValue(row.getCell(0));//第一列为班级
212
                     for (int y = firstCellNum + 1; y <= lastCellNum; y++) {
215
                     for (int y = firstCellNum + 1; y <= lastCellNum; y++) {
214
                         String username = getCellValue(cell);
217
                         String username = getCellValue(cell);
215
                         if (N_Utils.isEmpty(username)) {
218
                         if (N_Utils.isEmpty(username)) {
216
                             if (y == lastCellNum && N_Utils.isListNotEmpty(mrows)) {
219
                             if (y == lastCellNum && N_Utils.isListNotEmpty(mrows)) {
217
-                                errMsg.put(sheetName + "_" + (x + 1), mrows);
220
+                                errMsg.put(errMsgKey, mrows);
218
                             }
221
                             }
219
                             continue;//教师为空执行下一条数据
222
                             continue;//教师为空执行下一条数据
220
                         }
223
                         }
221
                         CTeacherVo vo = classTeacherMap.get(classname + "_" + username);
224
                         CTeacherVo vo = classTeacherMap.get(classname + "_" + username);
222
-                        if (vo == null) {
223
-                            mrows.add("本班下教师【" + username + "】不存在");
225
+                        Integer kjorder = y;//课节排序
226
+                        XzKjVo kj = kjs.stream().filter(k -> k.getKjorder() == kjorder).findFirst().orElse(null);
227
+                        String kjname = kj.getKjname();
228
+                        if (!userNameSet.contains(username)) {
229
+                            mrows.add(kjname + "【" + username + "】不存在");
230
+                        } else if (vo == null) {
231
+                            mrows.add(kjname + "【" + username + "】与【" + classname + "】不匹配");
232
+                        } else if (N_Utils.isEmpty(vo.getSubjectid())) {
233
+                            mrows.add(kjname + "【" + username + "】未设置科目");
224
                         } else {
234
                         } else {
225
-                            Integer kjorder = y;//课节排序
226
-                            XzKjVo kj = kjs.stream().filter(k -> k.getKjorder() == kjorder).findFirst().orElse(null);
227
-                            String coursename = sheetName + kj.getKjname() + vo.getSubjectname() + "(" + username + ")";
235
+                            String coursename = sheetName + kjname + vo.getSubjectname() + "(" + username + ")";
228
                             LCourse t = new LCourse();
236
                             LCourse t = new LCourse();
229
                             Integer kjid = kjMap.get(y).get(0).getKjid();
237
                             Integer kjid = kjMap.get(y).get(0).getKjid();
230
                             t.setKjid(kjid);
238
                             t.setKjid(kjid);
234
                             t.setTeacherid(vo.getTeacherid());
242
                             t.setTeacherid(vo.getTeacherid());
235
                             t.setBegintime(kj.getBegintime());
243
                             t.setBegintime(kj.getBegintime());
236
                             t.setEndtime(kj.getEndtime());
244
                             t.setEndtime(kj.getEndtime());
237
-                            Integer sectionstate = kj.getSectionstate();
245
+                            kj = kjs.stream().filter(k -> k.getKjorder() == kjorder
246
+                                    && sectiondate.equals(k.getSectiondate())).findFirst().orElse(null);
247
+                            Integer sectionstate = kj == null ? null : kj.getSectionstate();
238
                             if (sectionstate == null || sectionstate == 0) {//已经开始或结束的课不处理
248
                             if (sectionstate == null || sectionstate == 0) {//已经开始或结束的课不处理
239
                                 t.setBegindate(sectiondate);
249
                                 t.setBegindate(sectiondate);
240
                                 t.setEnddate(sectiondate);
250
                                 t.setEnddate(sectiondate);
242
                             }
252
                             }
243
                             List<String> meetDates = LiveUtil.getDaysForMeetDates(sectiondate, enddate);
253
                             List<String> meetDates = LiveUtil.getDaysForMeetDates(sectiondate, enddate);
244
                             for (int m = 1; m < meetDates.size(); m++) {
254
                             for (int m = 1; m < meetDates.size(); m++) {
255
+                                String date = meetDates.get(m);
256
+                                String begintime = date + " " + t.getBegintime();
257
+                                Integer beginTimestamp = N_Utils.getDataToTimestamp(begintime, "yyyy-MM-dd HH:mm");
258
+                                Integer timestamp = N_Utils.getSecondTimestamp();
259
+                                if (beginTimestamp.compareTo(timestamp) != 1) continue;//如果课节开始时间不大于当前时间不处理
260
+
245
                                 LCourse t2 = new LCourse();
261
                                 LCourse t2 = new LCourse();
246
                                 BeanUtils.copyProperties(t, t2);
262
                                 BeanUtils.copyProperties(t, t2);
247
-                                String date = meetDates.get(m);
248
                                 t2.setBegindate(date);
263
                                 t2.setBegindate(date);
249
                                 t2.setEnddate(date);
264
                                 t2.setEnddate(date);
250
                                 kjTeas.add(t2);
265
                                 kjTeas.add(t2);
251
                             }
266
                             }
252
                         }
267
                         }
253
                         if (y == lastCellNum && N_Utils.isListNotEmpty(mrows)) {
268
                         if (y == lastCellNum && N_Utils.isListNotEmpty(mrows)) {
254
-                            errMsg.put(sheetName + "_" + (x + 1), mrows);
269
+                            errMsg.put(errMsgKey, mrows);
255
                         }
270
                         }
256
                     }
271
                     }
257
                 }
272
                 }

+ 7
- 3
slive/src/main/resources/mapper/gradeclass/ClassTeacherMapper.xml View File

15
     </select>
15
     </select>
16
     <!--获取班级教师-->
16
     <!--获取班级教师-->
17
     <select id="listTeacherByClassIds" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
17
     <select id="listTeacherByClassIds" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
18
-        select ct.classid,ct.teacherid,u.username
19
-        from t_class_teacher ct left join t_user u on ct.teacherid=u.userid
20
-        where ct.classid in(${classids}) and u.usertype=1 and u.userstate=1
18
+        select ct.classid,ct.teacherid
19
+        from t_class_teacher ct
20
+        where ct.classid in(${classids})
21
     </select>
21
     </select>
22
     <!--获取教师科目-->
22
     <!--获取教师科目-->
23
     <select id="listSubjectByTeacherIds" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
23
     <select id="listSubjectByTeacherIds" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
30
     <select id="listSubjectBySubjectIds" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
30
     <select id="listSubjectBySubjectIds" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
31
         select subjectid,subjectname from t_subject where subjectid in('${subjectids}')
31
         select subjectid,subjectname from t_subject where subjectid in('${subjectids}')
32
     </select>
32
     </select>
33
+    <!--获取学校所有教师-->
34
+    <select id="listTeacherBySchoolId" resultType="com.xhkjedu.slive.vo.gradeclass.CTeacherVo">
35
+        select userid teacherid,username from t_user where schoolid=#{schoolid} and usertype=1 and userstate=1
36
+    </select>
33
 </mapper>
37
 </mapper>

Loading…
Cancel
Save