|
@@ -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);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 导入关联数据
|
|
* 导入关联数据
|
|
*
|
|
*
|
|
@@ -142,36 +116,6 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
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> 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);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 刷新数据
|
|
* 刷新数据
|
|
*
|
|
*
|
|
@@ -180,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);
|
|
@@ -192,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) {
|
|
@@ -284,4 +227,56 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
tcStatisticsService.saveBatch(tcStatisticsList);
|
|
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);
|
|
|
|
+ }
|
|
}
|
|
}
|