|
@@ -22,7 +22,6 @@ import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
import com.qmth.teachcloud.common.util.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
@@ -107,51 +106,10 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
|
List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNo(sysUser.getSchoolId(), batchNo);
|
|
|
if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
|
|
|
batchNo = SystemConstant.getUuid();
|
|
|
- Set<Long> collegeIdSet = new HashSet<>();
|
|
|
- for (TCStatisticsTemp t : tcStatisticsTempList) {
|
|
|
- collegeIdSet.add(t.getCollegeId());
|
|
|
- t.insertInfo(sysUser.getId());
|
|
|
- t.setBatchNo(batchNo);
|
|
|
- }
|
|
|
- tcStatisticsTempService.saveBatch(tcStatisticsTempList);
|
|
|
-
|
|
|
- Set<Long> orgIds = new HashSet<>();
|
|
|
- for (Long l : collegeIdSet) {
|
|
|
- List<SysOrg> sysOrgList = sysOrgService.findByConnectByRootOrgId(l);
|
|
|
- Set<Long> orgTempIds = sysOrgList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
- orgIds.addAll(orgTempIds);
|
|
|
- }
|
|
|
+ Set<Long> orgIds = this.joinDataGetOrgIds(sysUser, batchNo, tcStatisticsTempList);
|
|
|
List<TCStatisticsDto> tcStatisticsDtoList = this.findByBatchNoCount(sysUser.getSchoolId(), batchNo, orgIds);
|
|
|
if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
|
|
|
- //进行过滤
|
|
|
- Map<String, TCStatisticsDto> map = new LinkedHashMap<>();
|
|
|
- for (TCStatisticsDto t : tcStatisticsDtoList) {
|
|
|
- String key = t.getCollegeId() + ":" +
|
|
|
- t.getTeachingRoomId() + ":" +
|
|
|
- t.getCourseCode() + ":" +
|
|
|
- t.getPaperNumber() + ":" +
|
|
|
- t.getPrintPlanId() + ":" +
|
|
|
- t.getClazzId();
|
|
|
- if (!map.containsKey(key)) {
|
|
|
- map.computeIfAbsent(key, v -> t);
|
|
|
- } else {
|
|
|
- TCStatisticsDto temp = map.get(key);
|
|
|
- if (t.getPrintSum().intValue() > temp.getPrintSum().intValue()) {
|
|
|
- map.put(key, t);
|
|
|
- } else if (t.getPrintSum().intValue() == temp.getPrintSum().intValue()) {
|
|
|
- temp.setExamDetailId(null);
|
|
|
- temp.setStatus(StatisticsStatusEnum.UN_JOIN);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Gson gson = new Gson();
|
|
|
- List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(map.values()), new TypeToken<List<TCStatistics>>() {
|
|
|
- }.getType());
|
|
|
- for (TCStatistics t : tcStatisticsList) {
|
|
|
- t.insertInfo(sysUser.getId());
|
|
|
- }
|
|
|
- TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
|
- tcStatisticsService.saveBatch(tcStatisticsList);
|
|
|
+ this.saveJoinData(sysUser, tcStatisticsDtoList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -199,54 +157,13 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
|
tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
|
|
|
|
|
|
String batchNoNew = SystemConstant.getUuid();
|
|
|
- Set<Long> collegeIdSet = new HashSet<>();
|
|
|
- for (TCStatisticsTemp t : tcStatisticsTempList) {
|
|
|
- collegeIdSet.add(t.getCollegeId());
|
|
|
- t.insertInfo(sysUser.getId());
|
|
|
- t.setBatchNo(batchNoNew);
|
|
|
- }
|
|
|
- tcStatisticsTempService.saveBatch(tcStatisticsTempList);
|
|
|
-
|
|
|
- Set<Long> orgIds = new HashSet<>();
|
|
|
- for (Long l : collegeIdSet) {
|
|
|
- List<SysOrg> sysOrgList = sysOrgService.findByConnectByRootOrgId(l);
|
|
|
- Set<Long> orgTempIds = sysOrgList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
- orgIds.addAll(orgTempIds);
|
|
|
- }
|
|
|
+ Set<Long> orgIds = this.joinDataGetOrgIds(sysUser, batchNoNew, tcStatisticsTempList);
|
|
|
List<TCStatisticsDto> tcStatisticsDtoList = this.findByBatchNoCountJoin(sysUser.getSchoolId(), batchNoNew, orgIds);
|
|
|
if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
|
|
|
QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
|
|
|
tcStatisticsQueryWrapper.lambda().eq(TCStatistics::getBatchNo, batchNo);
|
|
|
tcStatisticsService.remove(tcStatisticsQueryWrapper);
|
|
|
-
|
|
|
- //进行过滤
|
|
|
- Map<String, TCStatisticsDto> map = new LinkedHashMap<>();
|
|
|
- for (TCStatisticsDto t : tcStatisticsDtoList) {
|
|
|
- String key = t.getCollegeId() + ":" +
|
|
|
- t.getTeachingRoomId() + ":" +
|
|
|
- t.getCourseCode() + ":" +
|
|
|
- t.getPaperNumber() + ":" +
|
|
|
- t.getPrintPlanId() + ":" +
|
|
|
- t.getClazzId();
|
|
|
- if (!map.containsKey(key)) {
|
|
|
- map.computeIfAbsent(key, v -> t);
|
|
|
- } else {
|
|
|
- TCStatisticsDto temp = map.get(key);
|
|
|
- if (t.getPrintSum().intValue() > temp.getPrintSum().intValue()) {
|
|
|
- map.put(key, t);
|
|
|
- } else if (t.getPrintSum().intValue() == temp.getPrintSum().intValue()) {
|
|
|
- temp.setExamDetailId(null);
|
|
|
- temp.setStatus(StatisticsStatusEnum.UN_JOIN);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Gson gson = new Gson();
|
|
|
- List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(map.values()), new TypeToken<List<TCStatistics>>() {
|
|
|
- }.getType());
|
|
|
- for (TCStatistics t : tcStatisticsList) {
|
|
|
- t.insertInfo(sysUser.getId());
|
|
|
- }
|
|
|
- tcStatisticsService.saveBatch(tcStatisticsList);
|
|
|
+ this.saveJoinData(sysUser, tcStatisticsDtoList);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -300,4 +217,68 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
|
tcStatisticsService.removeByIds(ids);
|
|
|
return ResultUtil.ok(true);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关联数据获取orgIds
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param batchNo
|
|
|
+ * @param tcStatisticsTempList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Set<Long> joinDataGetOrgIds(SysUser sysUser, String batchNo, List<TCStatisticsTemp> tcStatisticsTempList) {
|
|
|
+ Set<Long> collegeIdSet = new HashSet<>();
|
|
|
+ for (TCStatisticsTemp t : tcStatisticsTempList) {
|
|
|
+ collegeIdSet.add(t.getCollegeId());
|
|
|
+ t.insertInfo(sysUser.getId());
|
|
|
+ t.setBatchNo(batchNo);
|
|
|
+ }
|
|
|
+ tcStatisticsTempService.saveBatch(tcStatisticsTempList);
|
|
|
+
|
|
|
+ Set<Long> orgIds = new HashSet<>();
|
|
|
+ for (Long l : collegeIdSet) {
|
|
|
+ List<SysOrg> sysOrgList = sysOrgService.findByConnectByRootOrgId(l);
|
|
|
+ Set<Long> orgTempIds = sysOrgList.stream().map(s -> s.getId()).collect(Collectors.toSet());
|
|
|
+ orgIds.addAll(orgTempIds);
|
|
|
+ }
|
|
|
+ return orgIds;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存正式统计数据
|
|
|
+ *
|
|
|
+ * @param sysUser
|
|
|
+ * @param tcStatisticsDtoList
|
|
|
+ */
|
|
|
+ private void saveJoinData(SysUser sysUser, List<TCStatisticsDto> tcStatisticsDtoList) {
|
|
|
+ //进行过滤
|
|
|
+ Map<String, TCStatisticsDto> map = new LinkedHashMap<>();
|
|
|
+ for (TCStatisticsDto t : tcStatisticsDtoList) {
|
|
|
+ String key = t.getCollegeId() + ":" +
|
|
|
+ t.getTeachingRoomId() + ":" +
|
|
|
+ t.getCourseCode() + ":" +
|
|
|
+ t.getPaperNumber() + ":" +
|
|
|
+ t.getPrintPlanId() + ":" +
|
|
|
+ t.getClazzId();
|
|
|
+ if (!map.containsKey(key)) {
|
|
|
+ map.computeIfAbsent(key, v -> t);
|
|
|
+ } else {
|
|
|
+ TCStatisticsDto temp = map.get(key);
|
|
|
+ if (t.getPrintSum().intValue() > temp.getPrintSum().intValue()) {
|
|
|
+ map.put(key, t);
|
|
|
+ } else if (t.getPrintSum().intValue() == temp.getPrintSum().intValue()) {
|
|
|
+ temp.setExamDetailId(null);
|
|
|
+ temp.setStatus(StatisticsStatusEnum.UN_JOIN);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Gson gson = new Gson();
|
|
|
+ List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(map.values()), new TypeToken<List<TCStatistics>>() {
|
|
|
+ }.getType());
|
|
|
+ for (TCStatistics t : tcStatisticsList) {
|
|
|
+ t.insertInfo(sysUser.getId());
|
|
|
+ }
|
|
|
+ TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
|
+ tcStatisticsService.saveBatch(tcStatisticsList);
|
|
|
+ }
|
|
|
}
|