wangliang 3 lat temu
rodzic
commit
0959a6fd40

+ 23 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -1331,6 +1331,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
     public Map<String, Object> executeImportStatisticsLogic(Map<String, Object> map) throws Exception {
         InputStream inputStream = (InputStream) map.get("inputStream");
         SysUser sysUser = (SysUser) map.get(SystemConstant.USER);
+
         List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(StatisticsImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
             // 只允许导入一个sheet
             if (finalExcelList.size() > 1) {
@@ -1345,6 +1346,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
             Map<String, BasicClazz> clazzMap = new HashMap<>();//班级
             String batchNo = SystemConstant.getUuid();
             List<TCStatisticsTemp> tcStatisticsImportTempList = new ArrayList<>();
+            Set<Long> collegeIdSet = new HashSet<>(), teachingRoomIdSet = new HashSet<>(), ClazzIdSet = new HashSet<>();
+            Set<String> courseSet = new HashSet<>();
             for (int i = 0; i < finalExcelList.size(); i++) {
                 LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
                 List<Object> statisticsTempList = excelMap.get(i);
@@ -1356,6 +1359,11 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                     String teacherName = statisticsImportDto.getTeacherName();
                     BasicClazz basicClazz = this.validBasicClazzExists(clazzMap, statisticsImportDto.getClazzName(), sysUser.getSchoolId(), excelErrorTemp, (y + 1), (i + 1), "班级名称");
 
+                    collegeIdSet.add(collegeOrg.getId());
+                    teachingRoomIdSet.add(teachingRoomOrg.getId());
+                    courseSet.add(basicCourse.getCode());
+                    ClazzIdSet.add(basicClazz.getId());
+
                     if (excelErrorTemp.size() == 0) {
                         TCStatisticsTemp tcStatistics = new TCStatisticsTemp(collegeOrg.getId(),
                                 collegeOrg.getName(),
@@ -1376,6 +1384,21 @@ public class TaskLogicServiceImpl implements TaskLogicService {
                 List<String> errors = excelErrorTemp.stream().map(m -> m.getExcelErrorType()).collect(Collectors.toList());
                 throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(errors));
             }
+            //加入删除
+            QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
+            tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, collegeIdSet)
+                    .in(TCStatistics::getTeachingRoomId, teachingRoomIdSet)
+                    .in(TCStatistics::getCourseCode, courseSet)
+                    .in(TCStatistics::getClazzId, ClazzIdSet);
+            tcStatisticsService.remove(tcStatisticsQueryWrapper);
+
+            QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
+            tcStatisticsTempQueryWrapper.lambda().in(TCStatisticsTemp::getCollegeId, collegeIdSet)
+                    .in(TCStatisticsTemp::getTeachingRoomId, teachingRoomIdSet)
+                    .in(TCStatisticsTemp::getCourseCode, courseSet)
+                    .in(TCStatisticsTemp::getClazzId, ClazzIdSet);
+            tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
+
             tcStatisticsTempService.saveBatch(tcStatisticsImportTempList);
             map.put("dataCount", tcStatisticsImportTempList.size());