|
@@ -68,32 +68,6 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
return tcStatisticsMapper.list(iPage, collegeId, teachingRoomId, Objects.nonNull(status) ? status.name() : null, courseName, teacherName, schoolId, userId);
|
|
return tcStatisticsMapper.list(iPage, collegeId, teachingRoomId, Objects.nonNull(status) ? status.name() : null, courseName, teacherName, schoolId, userId);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 根据batchNo统计信息
|
|
|
|
- *
|
|
|
|
- * @param schoolId
|
|
|
|
- * @param batchNo
|
|
|
|
- * @param orgIds
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo, Set<Long> orgIds) {
|
|
|
|
- return tcStatisticsMapper.findByBatchNoCount(schoolId, batchNo, orgIds);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * 根据batchNo统计信息
|
|
|
|
- *
|
|
|
|
- * @param schoolId
|
|
|
|
- * @param batchNo
|
|
|
|
- * @param orgIds
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- public List<TCStatisticsDto> findByBatchNoCountJoin(Long schoolId, String batchNo, Set<Long> orgIds) {
|
|
|
|
- return tcStatisticsMapper.findByBatchNoCountJoin(schoolId, batchNo, orgIds);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 导入关联数据
|
|
* 导入关联数据
|
|
*
|
|
*
|
|
@@ -106,30 +80,10 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNo(sysUser.getSchoolId(), batchNo);
|
|
List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNo(sysUser.getSchoolId(), batchNo);
|
|
if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
|
|
if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
|
|
batchNo = SystemConstant.getUuid();
|
|
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);
|
|
List<TCStatisticsDto> tcStatisticsDtoList = this.findByBatchNoCount(sysUser.getSchoolId(), batchNo, orgIds);
|
|
if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
|
|
if (Objects.nonNull(tcStatisticsDtoList) && tcStatisticsDtoList.size() > 0) {
|
|
- Gson gson = new Gson();
|
|
|
|
- List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(tcStatisticsDtoList), 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -137,78 +91,31 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
/**
|
|
/**
|
|
* 删除导入数据
|
|
* 删除导入数据
|
|
*
|
|
*
|
|
|
|
+ * @param userId
|
|
* @param courseSet
|
|
* @param courseSet
|
|
* @param setCollections
|
|
* @param setCollections
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public void removeImportData(Set<String> courseSet, Set<Long>... setCollections) {
|
|
|
|
|
|
+ public void removeImportData(Long userId, Set<String> courseSet, Set<Long>... setCollections) {
|
|
TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
|
|
tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, setCollections[0])
|
|
tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, setCollections[0])
|
|
.in(TCStatistics::getTeachingRoomId, setCollections[1])
|
|
.in(TCStatistics::getTeachingRoomId, setCollections[1])
|
|
.in(TCStatistics::getCourseCode, courseSet)
|
|
.in(TCStatistics::getCourseCode, courseSet)
|
|
- .in(TCStatistics::getClazzId, setCollections[2]);
|
|
|
|
|
|
+ .in(TCStatistics::getClazzId, setCollections[2])
|
|
|
|
+ .eq(TCStatistics::getCreateId, userId);
|
|
tcStatisticsService.remove(tcStatisticsQueryWrapper);
|
|
tcStatisticsService.remove(tcStatisticsQueryWrapper);
|
|
|
|
|
|
QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
|
|
tcStatisticsTempQueryWrapper.lambda().in(TCStatisticsTemp::getCollegeId, setCollections[0])
|
|
tcStatisticsTempQueryWrapper.lambda().in(TCStatisticsTemp::getCollegeId, setCollections[0])
|
|
.in(TCStatisticsTemp::getTeachingRoomId, setCollections[1])
|
|
.in(TCStatisticsTemp::getTeachingRoomId, setCollections[1])
|
|
.in(TCStatisticsTemp::getCourseCode, courseSet)
|
|
.in(TCStatisticsTemp::getCourseCode, courseSet)
|
|
- .in(TCStatisticsTemp::getClazzId, setCollections[2]);
|
|
|
|
|
|
+ .in(TCStatisticsTemp::getClazzId, setCollections[2])
|
|
|
|
+ .eq(TCStatisticsTemp::getCreateId, userId);
|
|
tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
|
|
tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 刷新关联数据
|
|
|
|
- *
|
|
|
|
- * @param sysUser
|
|
|
|
- * @param batchNoSet
|
|
|
|
- */
|
|
|
|
- @Override
|
|
|
|
- @Transactional
|
|
|
|
- public void freshenJoinData(SysUser sysUser, Set<String> batchNoSet) {
|
|
|
|
- TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
|
|
- for (String batchNo : batchNoSet) {
|
|
|
|
- List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNoJoin(sysUser.getSchoolId(), batchNo);
|
|
|
|
- if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
|
|
|
|
- QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tcStatisticsTempQueryWrapper.lambda().eq(TCStatisticsTemp::getBatchNo, batchNo);
|
|
|
|
- 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);
|
|
|
|
- }
|
|
|
|
- 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);
|
|
|
|
-
|
|
|
|
- Gson gson = new Gson();
|
|
|
|
- List<TCStatistics> tcStatisticsList = gson.fromJson(JacksonUtil.parseJson(tcStatisticsDtoList), new TypeToken<List<TCStatistics>>() {
|
|
|
|
- }.getType());
|
|
|
|
- for (TCStatistics t : tcStatisticsList) {
|
|
|
|
- t.insertInfo(sysUser.getId());
|
|
|
|
- }
|
|
|
|
- tcStatisticsService.saveBatch(tcStatisticsList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 刷新数据
|
|
* 刷新数据
|
|
*
|
|
*
|
|
@@ -217,11 +124,10 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public Result freshenData() {
|
|
public Result freshenData() {
|
|
- TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
|
|
tcStatisticsQueryWrapper.select(" DISTINCT batch_no ").eq("create_id", sysUser.getId());
|
|
tcStatisticsQueryWrapper.select(" DISTINCT batch_no ").eq("create_id", sysUser.getId());
|
|
- List<TCStatistics> tcStatisticsList = tcStatisticsService.list(tcStatisticsQueryWrapper);
|
|
|
|
|
|
+ List<TCStatistics> tcStatisticsList = this.list(tcStatisticsQueryWrapper);
|
|
if (Objects.nonNull(tcStatisticsList) && tcStatisticsList.size() > 0) {
|
|
if (Objects.nonNull(tcStatisticsList) && tcStatisticsList.size() > 0) {
|
|
Set<String> batchNoSet = tcStatisticsList.stream().map(s -> s.getBatchNo()).collect(Collectors.toSet());
|
|
Set<String> batchNoSet = tcStatisticsList.stream().map(s -> s.getBatchNo()).collect(Collectors.toSet());
|
|
boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_BATCH_NO_PREFIX + Math.abs(batchNoSet.toString().hashCode()), SystemConstant.REDIS_LOCK_BATCH_NO_TIME_OUT);
|
|
boolean lock = redisUtil.lock(SystemConstant.REDIS_LOCK_BATCH_NO_PREFIX + Math.abs(batchNoSet.toString().hashCode()), SystemConstant.REDIS_LOCK_BATCH_NO_TIME_OUT);
|
|
@@ -229,7 +135,7 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
throw ExceptionResultEnum.ERROR.exception("正在刷新数据,请稍候再试!");
|
|
throw ExceptionResultEnum.ERROR.exception("正在刷新数据,请稍候再试!");
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- tcStatisticsService.freshenJoinData(sysUser, batchNoSet);
|
|
|
|
|
|
+ this.freshenJoinData(sysUser, batchNoSet);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("请求出错", e);
|
|
log.error("请求出错", e);
|
|
if (e instanceof ApiException) {
|
|
if (e instanceof ApiException) {
|
|
@@ -257,4 +163,120 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
tcStatisticsService.removeByIds(ids);
|
|
tcStatisticsService.removeByIds(ids);
|
|
return ResultUtil.ok(true);
|
|
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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 刷新关联数据
|
|
|
|
+ *
|
|
|
|
+ * @param sysUser
|
|
|
|
+ * @param batchNoSet
|
|
|
|
+ */
|
|
|
|
+ public void freshenJoinData(SysUser sysUser, Set<String> batchNoSet) {
|
|
|
|
+ TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
|
|
+ for (String batchNo : batchNoSet) {
|
|
|
|
+ List<TCStatisticsTemp> tcStatisticsTempList = tcStatisticsTempService.findByBatchNoJoin(sysUser.getSchoolId(), batchNo);
|
|
|
|
+ if (Objects.nonNull(tcStatisticsTempList) && tcStatisticsTempList.size() > 0) {
|
|
|
|
+ QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tcStatisticsTempQueryWrapper.lambda().eq(TCStatisticsTemp::getBatchNo, batchNo);
|
|
|
|
+ tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
|
|
|
|
+
|
|
|
|
+ String batchNoNew = SystemConstant.getUuid();
|
|
|
|
+ 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);
|
|
|
|
+ this.saveJoinData(sysUser, tcStatisticsDtoList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据batchNo统计信息
|
|
|
|
+ *
|
|
|
|
+ * @param schoolId
|
|
|
|
+ * @param batchNo
|
|
|
|
+ * @param orgIds
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo, Set<Long> orgIds) {
|
|
|
|
+ return tcStatisticsMapper.findByBatchNoCount(schoolId, batchNo, orgIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据batchNo统计信息
|
|
|
|
+ *
|
|
|
|
+ * @param schoolId
|
|
|
|
+ * @param batchNo
|
|
|
|
+ * @param orgIds
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<TCStatisticsDto> findByBatchNoCountJoin(Long schoolId, String batchNo, Set<Long> orgIds) {
|
|
|
|
+ return tcStatisticsMapper.findByBatchNoCountJoin(schoolId, batchNo, orgIds);
|
|
|
|
+ }
|
|
}
|
|
}
|