|
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
24
|
24
|
import java.util.LinkedHashMap;
|
25
|
25
|
import java.util.List;
|
26
|
26
|
import java.util.Map;
|
|
27
|
+import java.util.Set;
|
27
|
28
|
import java.util.stream.Collectors;
|
28
|
29
|
|
29
|
30
|
/**
|
|
@@ -167,7 +168,7 @@ public class PoiUtils {
|
167
|
168
|
* @Date 2022/6/21 15:13
|
168
|
169
|
**/
|
169
|
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
|
172
|
Map<String, Object> resultMap = new HashMap<>();
|
172
|
173
|
Map<String, List<String>> errMsg = new LinkedHashMap<>();
|
173
|
174
|
try {
|
|
@@ -192,6 +193,7 @@ public class PoiUtils {
|
192
|
193
|
sheet = work.getSheetAt(i);
|
193
|
194
|
String sheetName = sheet.getSheetName();
|
194
|
195
|
String sectiondate = weeks.get(sheetName);
|
|
196
|
+ if (sectiondate == null) continue;//没有当天的课不处理
|
195
|
197
|
int rows = sheet.getLastRowNum(); // 获取最后一个实际行的下标,比行数小1
|
196
|
198
|
int firstRowNum = sheet.getFirstRowNum(); // 获取第一个实际行的下标,(firstRowNum=0)
|
197
|
199
|
//遍历当前sheet中的所有行,排除第一行(标题)不纳入遍历
|
|
@@ -207,6 +209,7 @@ public class PoiUtils {
|
207
|
209
|
int lastCellNum = row.getLastCellNum();// 每一行的最后一列,获取列数,比最后一列列标大1
|
208
|
210
|
if (lastCellNum > daynum) lastCellNum = daynum;//节数大于课程的节数不处理
|
209
|
211
|
List<String> mrows = new ArrayList<>();
|
|
212
|
+ String errMsgKey = sheetName + "第" + (x + 1) + "行";
|
210
|
213
|
//遍历所有的列
|
211
|
214
|
String classname = getCellValue(row.getCell(0));//第一列为班级
|
212
|
215
|
for (int y = firstCellNum + 1; y <= lastCellNum; y++) {
|
|
@@ -214,17 +217,22 @@ public class PoiUtils {
|
214
|
217
|
String username = getCellValue(cell);
|
215
|
218
|
if (N_Utils.isEmpty(username)) {
|
216
|
219
|
if (y == lastCellNum && N_Utils.isListNotEmpty(mrows)) {
|
217
|
|
- errMsg.put(sheetName + "_" + (x + 1), mrows);
|
|
220
|
+ errMsg.put(errMsgKey, mrows);
|
218
|
221
|
}
|
219
|
222
|
continue;//教师为空执行下一条数据
|
220
|
223
|
}
|
221
|
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
|
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
|
236
|
LCourse t = new LCourse();
|
229
|
237
|
Integer kjid = kjMap.get(y).get(0).getKjid();
|
230
|
238
|
t.setKjid(kjid);
|
|
@@ -234,7 +242,9 @@ public class PoiUtils {
|
234
|
242
|
t.setTeacherid(vo.getTeacherid());
|
235
|
243
|
t.setBegintime(kj.getBegintime());
|
236
|
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
|
248
|
if (sectionstate == null || sectionstate == 0) {//已经开始或结束的课不处理
|
239
|
249
|
t.setBegindate(sectiondate);
|
240
|
250
|
t.setEnddate(sectiondate);
|
|
@@ -242,16 +252,21 @@ public class PoiUtils {
|
242
|
252
|
}
|
243
|
253
|
List<String> meetDates = LiveUtil.getDaysForMeetDates(sectiondate, enddate);
|
244
|
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
|
261
|
LCourse t2 = new LCourse();
|
246
|
262
|
BeanUtils.copyProperties(t, t2);
|
247
|
|
- String date = meetDates.get(m);
|
248
|
263
|
t2.setBegindate(date);
|
249
|
264
|
t2.setEnddate(date);
|
250
|
265
|
kjTeas.add(t2);
|
251
|
266
|
}
|
252
|
267
|
}
|
253
|
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
|
}
|