|
@@ -1,19 +1,31 @@
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
|
|
+import com.google.gson.Gson;
|
|
import com.qmth.distributed.print.business.bean.dto.TCStatisticsDto;
|
|
import com.qmth.distributed.print.business.bean.dto.TCStatisticsDto;
|
|
import com.qmth.distributed.print.business.entity.TCStatistics;
|
|
import com.qmth.distributed.print.business.entity.TCStatistics;
|
|
|
|
+import com.qmth.distributed.print.business.entity.TCStatisticsTemp;
|
|
import com.qmth.distributed.print.business.enums.StatisticsStatusEnum;
|
|
import com.qmth.distributed.print.business.enums.StatisticsStatusEnum;
|
|
import com.qmth.distributed.print.business.mapper.TCStatisticsMapper;
|
|
import com.qmth.distributed.print.business.mapper.TCStatisticsMapper;
|
|
|
|
+import com.qmth.distributed.print.business.mapper.TCStatisticsTempMapper;
|
|
import com.qmth.distributed.print.business.service.TCStatisticsService;
|
|
import com.qmth.distributed.print.business.service.TCStatisticsService;
|
|
|
|
+import com.qmth.distributed.print.business.service.TCStatisticsTempService;
|
|
|
|
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
|
|
|
|
+import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysOrg;
|
|
|
|
+import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
|
+import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
|
+import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
|
|
+import org.springframework.boot.SpringApplication;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -29,6 +41,12 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
@Resource
|
|
@Resource
|
|
TCStatisticsMapper tcStatisticsMapper;
|
|
TCStatisticsMapper tcStatisticsMapper;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TCStatisticsTempService tcStatisticsTempService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ SysOrgService sysOrgService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查找印刷计划信息
|
|
* 查找印刷计划信息
|
|
*
|
|
*
|
|
@@ -59,4 +77,69 @@ public class TCStatisticsServiceImpl extends ServiceImpl<TCStatisticsMapper, TCS
|
|
public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo, Set<Long> orgIds) {
|
|
public List<TCStatisticsDto> findByBatchNoCount(Long schoolId, String batchNo, Set<Long> orgIds) {
|
|
return tcStatisticsMapper.findByBatchNoCount(schoolId, batchNo, orgIds);
|
|
return tcStatisticsMapper.findByBatchNoCount(schoolId, batchNo, orgIds);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导入关联数据
|
|
|
|
+ *
|
|
|
|
+ * @param sysUser
|
|
|
|
+ * @param batchNo
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void importJoinData(SysUser sysUser, String batchNo) {
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ List<TCStatisticsDto> tcStatisticsDtoList = this.findByBatchNoCount(sysUser.getSchoolId(), batchNo, orgIds);
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除导入数据
|
|
|
|
+ *
|
|
|
|
+ * @param courseSet
|
|
|
|
+ * @param setCollections
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void removeImportData(Set<String> courseSet, Set<Long>... setCollections) {
|
|
|
|
+ TCStatisticsService tcStatisticsService = SpringContextHolder.getBean(TCStatisticsService.class);
|
|
|
|
+ QueryWrapper<TCStatistics> tcStatisticsQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tcStatisticsQueryWrapper.lambda().in(TCStatistics::getCollegeId, setCollections[0])
|
|
|
|
+ .in(TCStatistics::getTeachingRoomId, setCollections[1])
|
|
|
|
+ .in(TCStatistics::getCourseCode, courseSet)
|
|
|
|
+ .in(TCStatistics::getClazzId, setCollections[2]);
|
|
|
|
+ tcStatisticsService.remove(tcStatisticsQueryWrapper);
|
|
|
|
+
|
|
|
|
+ QueryWrapper<TCStatisticsTemp> tcStatisticsTempQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tcStatisticsTempQueryWrapper.lambda().in(TCStatisticsTemp::getCollegeId, setCollections[0])
|
|
|
|
+ .in(TCStatisticsTemp::getTeachingRoomId, setCollections[1])
|
|
|
|
+ .in(TCStatisticsTemp::getCourseCode, courseSet)
|
|
|
|
+ .in(TCStatisticsTemp::getClazzId, setCollections[2]);
|
|
|
|
+ tcStatisticsTempService.remove(tcStatisticsTempQueryWrapper);
|
|
|
|
+ }
|
|
}
|
|
}
|