feat: 东区缴费分支初始化
This commit is contained in:
-154
@@ -1,154 +0,0 @@
|
||||
package com.yida.data.common.excel;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yida.data.common.core.entity.EasyExcelExportBaseDTO;
|
||||
import com.yida.data.common.core.enums.FileDealStatusEnum;
|
||||
import com.yida.data.common.core.file.IExportExcelClient;
|
||||
import com.yida.data.common.core.file.common.export.ExportExcelData;
|
||||
import com.yida.data.common.core.file.common.export.SelectExportData;
|
||||
import com.yida.data.common.core.utils.FileUtil;
|
||||
import com.yida.data.common.service.CommonService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 导出excel工具类
|
||||
*
|
||||
* @author ZYJ
|
||||
* @date 2023/10/19 16:49
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public abstract class DefaultExportExcelClient<T extends SelectExportData, R extends EasyExcelExportBaseDTO, O, BaseService extends IService<O>>
|
||||
implements IExportExcelClient<T> {
|
||||
|
||||
/**
|
||||
* 导出的service层
|
||||
*/
|
||||
protected final BaseService baseService;
|
||||
|
||||
protected final RedisService redisService;
|
||||
protected final CommonService commonService;
|
||||
protected final String exportCacheKey;
|
||||
protected final String uploadUrl;
|
||||
|
||||
public Class<R> getClassR() {
|
||||
Type sType = getClass().getGenericSuperclass();
|
||||
Type[] generics = ((ParameterizedType) sType).getActualTypeArguments();
|
||||
return (Class<R>) (generics[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询excel 导出需要的数据
|
||||
*
|
||||
* @param t 查询条件
|
||||
* @return java.util.List<O>
|
||||
* @author ZYJ
|
||||
* @date 2023/12/12 16:54
|
||||
*/
|
||||
public abstract List<O> selectExportData(T t);
|
||||
|
||||
/**
|
||||
* 处理单条数据
|
||||
*
|
||||
* @param o 需要处理的数据
|
||||
* @return R
|
||||
* @author ZYJ
|
||||
* @date 2023/12/13 13:58
|
||||
*/
|
||||
public abstract R handleSingleData(O o);
|
||||
|
||||
@Override
|
||||
public void exportExcelData(T t) {
|
||||
File file = null;
|
||||
try {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
// 生成导出成功excel文件名
|
||||
String fileName = FileUtil.getLocalUploadAddress() + UUID.randomUUID() + ".xls";
|
||||
// 查询需要导出的文件信息
|
||||
List<O> dataList = this.selectExportData(t);
|
||||
|
||||
// 添加处理总数量
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportExcelData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEALING.getStatus())
|
||||
.total(dataList.size())
|
||||
.finish(0)
|
||||
.build());
|
||||
|
||||
// 处理数据
|
||||
List<R> list = new ArrayList<>();
|
||||
// 完成数量
|
||||
int finishNumber = 0;
|
||||
for (O o : dataList) {
|
||||
try {
|
||||
R r = this.handleSingleData(o);
|
||||
list.add(r);
|
||||
} catch (Exception e) {
|
||||
log.error("{}导出错误: {}", t.getFunctionName(), JSONUtil.toJsonStr(o));
|
||||
} finally {
|
||||
finishNumber += 1;
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportExcelData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEALING.getStatus())
|
||||
.total(dataList.size())
|
||||
.finish(finishNumber)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
// 导出数据
|
||||
file = new File(fileName);
|
||||
EasyExcel.write(file, getClassR())
|
||||
.excelType(ExcelTypeEnum.XLS)
|
||||
.sheet("数据导出")
|
||||
.doWrite(list);
|
||||
// 上传文件到媒资
|
||||
String fileUrl = FileUtil.uploadFileToMediaServer(uploadUrl, file);
|
||||
// 处理完成
|
||||
ExportExcelData exportExcelData = ExportExcelData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEAL_SUCCESS.getStatus())
|
||||
.fileName(fileName)
|
||||
.total(dataList.size())
|
||||
.finish(finishNumber)
|
||||
.filePath(fileUrl)
|
||||
.build();
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), exportExcelData);
|
||||
// 添加处理时间
|
||||
stopWatch.stop();
|
||||
log.info("{}数据总共耗时: {}", t.getFunctionName(), stopWatch.getTotalTimeSeconds() + "秒");
|
||||
} catch (Exception e) {
|
||||
log.error("{}导出失败", t.getFunctionName(), e);
|
||||
// 添加处理失败的结果
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportExcelData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEAL_FAIL.getStatus())
|
||||
.build());
|
||||
} finally {
|
||||
if (Objects.nonNull(file)) {
|
||||
cn.hutool.core.io.FileUtil.del(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectExportInfo(String key) {
|
||||
return redisService.hget(exportCacheKey, key);
|
||||
}
|
||||
}
|
||||
-285
@@ -1,285 +0,0 @@
|
||||
package com.yida.data.common.excel;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.support.ExcelTypeEnum;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
|
||||
import com.yida.data.common.core.enums.FileDealStatusEnum;
|
||||
import com.yida.data.common.core.file.IExportLargeClient;
|
||||
import com.yida.data.common.core.file.common.DownloadFileChunk;
|
||||
import com.yida.data.common.core.file.common.export.ExportLargeData;
|
||||
import com.yida.data.common.core.file.common.export.SelectExportData;
|
||||
import com.yida.data.common.core.exception.FebsException;
|
||||
import com.yida.data.common.core.utils.file.ChunkUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* 导出大文件工具类
|
||||
* zip文件
|
||||
*
|
||||
* @author ZYJ
|
||||
* @date 2023/10/19 16:49
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public abstract class DefaultExportLargeClient<T extends SelectExportData, O, BaseService extends IService<O>>
|
||||
implements IExportLargeClient<T> {
|
||||
|
||||
/**
|
||||
* 导出的service层
|
||||
*/
|
||||
protected final BaseService baseService;
|
||||
|
||||
protected final RedisService redisService;
|
||||
protected final String exportCacheKey;
|
||||
protected final String uploadUrl;
|
||||
|
||||
/**
|
||||
* 查询大文件导出需要的数据
|
||||
*
|
||||
* @param t 查询条件
|
||||
* @return java.util.Map<java.lang.String, java.lang.String>
|
||||
* @author ZYJ
|
||||
* @date 2023/10/20 16:09
|
||||
*/
|
||||
public abstract Map<String, String> selectExportData(T t);
|
||||
|
||||
@Override
|
||||
public void exportLargeData(T t) {
|
||||
// 查询需要导出的文件信息
|
||||
Map<String, String> map = this.selectExportData(t);
|
||||
// zip文件
|
||||
File file = null;
|
||||
// 错误信息文件
|
||||
File errorFile = null;
|
||||
try {
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
// 生成的文件名称
|
||||
String fileName = com.yida.data.common.core.utils.FileUtil.getLocalUploadAddress() + t.getKey() + ".zip";
|
||||
file = new File(fileName);
|
||||
ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(file.toPath()));
|
||||
// 添加处理总数量
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportLargeData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEALING.getStatus())
|
||||
.total(map.size())
|
||||
.finish(0)
|
||||
.build());
|
||||
|
||||
// 完成数量
|
||||
int finishNumber = 0;
|
||||
// 错误数量
|
||||
int errorNumber = 0;
|
||||
// 是否完成流程
|
||||
boolean flag;
|
||||
// 错误信息
|
||||
Map<String, String> errorMap = new HashMap<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
flag = true;
|
||||
String name = "";
|
||||
String fileUrl = "";
|
||||
try {
|
||||
// 文件名称
|
||||
name = entry.getKey();
|
||||
// log.info("处理数据: {}", name);
|
||||
// 文件地址
|
||||
fileUrl = entry.getValue();
|
||||
// 下载文件
|
||||
URL url = new URL(fileUrl);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
String message = connection.getHeaderField(0);
|
||||
if (StringUtils.isNotEmpty(message)) {
|
||||
if (message.startsWith("HTTP/1.1 404")) {
|
||||
flag = false;
|
||||
// 添加错误数据
|
||||
errorMap.put(name, fileUrl);
|
||||
errorNumber += 1;
|
||||
finishNumber += 1;
|
||||
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportLargeData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEALING.getStatus())
|
||||
.total(map.size())
|
||||
.finish(finishNumber)
|
||||
.error(errorNumber)
|
||||
.build());
|
||||
continue;
|
||||
}
|
||||
zos.putNextEntry(new ZipEntry(name + ".jpg"));
|
||||
InputStream fis = connection.getInputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int r = 0;
|
||||
while ((r = fis.read(buffer)) != -1) {
|
||||
zos.write(buffer, 0, r);
|
||||
}
|
||||
fis.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
flag = false;
|
||||
// 添加错误数据
|
||||
if (StrUtil.isNotBlank(name) && StrUtil.isNotBlank(fileUrl)) {
|
||||
errorMap.put(name, fileUrl);
|
||||
}
|
||||
errorNumber += 1;
|
||||
finishNumber += 1;
|
||||
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportLargeData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEALING.getStatus())
|
||||
.total(map.size())
|
||||
.finish(finishNumber)
|
||||
.error(errorNumber)
|
||||
.build());
|
||||
} finally {
|
||||
if (flag) {
|
||||
finishNumber += 1;
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportLargeData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEALING.getStatus())
|
||||
.total(map.size())
|
||||
.finish(finishNumber)
|
||||
.error(errorNumber)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
zos.flush();
|
||||
zos.close();
|
||||
stopWatch.stop();
|
||||
// 处理错误数据
|
||||
String errorFileUrl = "";
|
||||
if (CollUtil.isNotEmpty(errorMap)) {
|
||||
// 表头list的生成,实际的表头信息可以从数据库或者缓存等处动态读取
|
||||
List<List<String>> allColList = new ArrayList<>();
|
||||
// 姓名表头
|
||||
allColList.add(CollUtil.newArrayList("名称"));
|
||||
// 校区表头
|
||||
allColList.add(CollUtil.newArrayList("地址"));
|
||||
// 处理错误数据
|
||||
List<List<String>> exportErrorDataList = new ArrayList<>();
|
||||
errorMap.forEach((k, v) -> exportErrorDataList.add(CollUtil.newArrayList(k, v)));
|
||||
|
||||
String errorFileName = com.yida.data.common.core.utils.FileUtil.getLocalUploadAddress() + t.getKey() + ".xls";
|
||||
errorFile = new File(errorFileName);
|
||||
// 导出错误数据
|
||||
EasyExcel.write(errorFile)
|
||||
.excelType(ExcelTypeEnum.XLS)
|
||||
// 这里放入动态头
|
||||
.head(allColList).sheet("错误信息")
|
||||
// 当然这里数据也可以用 List<List<String>> 去传入
|
||||
.doWrite(exportErrorDataList);
|
||||
// 上传文件到媒资
|
||||
errorFileUrl = com.yida.data.common.core.utils.FileUtil.uploadFileToMediaServer(uploadUrl, errorFile);
|
||||
}
|
||||
// 处理完成
|
||||
ExportLargeData exportLargeData = ExportLargeData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEAL_SUCCESS.getStatus())
|
||||
.fileName(fileName)
|
||||
.fileSize(new File(fileName).length())
|
||||
.total(map.size())
|
||||
.finish(finishNumber)
|
||||
.error(errorNumber)
|
||||
.build();
|
||||
if (StrUtil.isNotBlank(errorFileUrl)) {
|
||||
exportLargeData.setErrorFilePath(errorFileUrl);
|
||||
}
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), exportLargeData);
|
||||
log.info("导出照片数据总共耗时: {}", stopWatch.getTotalTimeSeconds() + "秒");
|
||||
} catch (Exception e) {
|
||||
log.error("导出大文件失败", e);
|
||||
// 添加处理失败的结果
|
||||
redisService.hset(this.exportCacheKey, t.getKey(), ExportLargeData.builder()
|
||||
.key(t.getKey())
|
||||
.exportStatus(FileDealStatusEnum.DEAL_FAIL.getStatus())
|
||||
.build());
|
||||
// 删除本地zip文件
|
||||
if (Objects.nonNull(file)) {
|
||||
FileUtil.del(file);
|
||||
}
|
||||
} finally {
|
||||
// 删除本地错误信息文件
|
||||
if (Objects.nonNull(errorFile)) {
|
||||
FileUtil.del(errorFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object selectExportInfo(String key) {
|
||||
return redisService.hget(exportCacheKey, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downLoadChunk(DownloadFileChunk dto, HttpServletResponse response) {
|
||||
// 生成的文件信息
|
||||
File resultFile = null;
|
||||
Integer index = null;
|
||||
Integer chunkTotal = null;
|
||||
|
||||
try {
|
||||
// 获取缓存信息
|
||||
ExportLargeData exportLargeData = (ExportLargeData) redisService.hget(this.exportCacheKey, dto.getKey());
|
||||
String fileName = exportLargeData.getFileName();
|
||||
|
||||
String[] splits = fileName.split("\\.");
|
||||
String type = splits[splits.length - 1];
|
||||
String resultFileName = com.yida.data.common.core.utils.FileUtil.getLocalUploadAddress() + dto.getKey() + "." + type;
|
||||
// 生成的分片文件
|
||||
resultFile = new File(resultFileName);
|
||||
|
||||
// 分片信息
|
||||
Integer chunkSize = dto.getChunkSize();
|
||||
index = dto.getIndex();
|
||||
chunkTotal = dto.getChunkTotal();
|
||||
|
||||
long offset = (long) chunkSize * (index - 1);
|
||||
if (Objects.equals(index, chunkTotal)) {
|
||||
offset = resultFile.length() - chunkSize;
|
||||
}
|
||||
byte[] chunk = ChunkUtil.getChunk(index, chunkSize, resultFileName, offset);
|
||||
|
||||
log.info("下载文件分片" + resultFileName + "," + index + "," + chunkSize + "," + chunk.length + "," + offset);
|
||||
// response.addHeader("Access-Control-Allow-Origin","Content-Disposition");
|
||||
response.addHeader("Content-Disposition", "attachment;filename=" + fileName);
|
||||
response.addHeader("Content-Length", String.valueOf(chunk.length));
|
||||
// response.setHeader("filename", fileName);
|
||||
response.setContentType("application/octet-stream");
|
||||
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
out.write(chunk);
|
||||
out.flush();
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
log.error("下载分片失败", e);
|
||||
throw new FebsException("下载分片失败");
|
||||
} finally {
|
||||
if (Objects.nonNull(resultFile) && Objects.nonNull(index)
|
||||
&& Objects.nonNull(chunkTotal) && index.equals(chunkTotal)) {
|
||||
FileUtil.del(resultFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-562
@@ -1,132 +1,43 @@
|
||||
package com.yida.data.common.service;
|
||||
|
||||
import static com.yida.data.common.core.entity.constant.CachePrefixConstant.STAFF_DATA;
|
||||
|
||||
import cc.mrbird.febs.common.redis.service.RedisService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.net.URLEncoder;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yida.data.common.core.entity.CurrentUser;
|
||||
import com.yida.data.common.core.entity.Dict;
|
||||
import com.yida.data.common.core.entity.constant.AppConstant;
|
||||
import com.yida.data.common.core.entity.constant.CachePrefixConstant;
|
||||
import com.yida.data.common.core.entity.constant.QywxServiceProviderConstant;
|
||||
import com.yida.data.common.core.entity.constant.UPayConstant;
|
||||
import com.yida.data.common.core.entity.consume.DeptConsumeTerminalCache;
|
||||
import com.yida.data.common.core.entity.consume.EduConsumeConfig;
|
||||
import com.yida.data.common.core.entity.school.EduDeptHomeApp;
|
||||
import com.yida.data.common.core.entity.school.EduYidaAppAccount;
|
||||
import com.yida.data.common.core.entity.system.BaiduApiConfig;
|
||||
import com.yida.data.common.core.entity.system.ConstructionPayConfig;
|
||||
import com.yida.data.common.core.entity.system.Dept;
|
||||
import com.yida.data.common.core.entity.system.EduApp;
|
||||
import com.yida.data.common.core.entity.system.EduAppTemplate;
|
||||
import com.yida.data.common.core.entity.system.EduArea;
|
||||
import com.yida.data.common.core.entity.system.EduDeptFunction;
|
||||
import com.yida.data.common.core.entity.system.EduDeptPayType;
|
||||
import com.yida.data.common.core.entity.system.EduDeptWxPublic;
|
||||
import com.yida.data.common.core.entity.system.EduHoliday;
|
||||
import com.yida.data.common.core.entity.system.EduPayWxConfig;
|
||||
import com.yida.data.common.core.entity.system.EduQywxServiceProvider;
|
||||
import com.yida.data.common.core.entity.system.EduQywxServiceProviderSchool;
|
||||
import com.yida.data.common.core.entity.system.EduYidaApp;
|
||||
import com.yida.data.common.core.entity.system.UPayConfig;
|
||||
import com.yida.data.common.core.entity.system.UnionPayConfig;
|
||||
import com.yida.data.common.core.entity.system.WhiteList;
|
||||
import com.yida.data.common.core.entity.system.enums.RoleEnum;
|
||||
import com.yida.data.common.core.entity.system.enums.SysFunctionEnum;
|
||||
import com.yida.data.common.core.entity.user.EduStaff;
|
||||
import com.yida.data.common.core.entity.user.EduStudent;
|
||||
import com.yida.data.common.core.entity.system.*;
|
||||
import com.yida.data.common.core.entity.user.EduUserDept;
|
||||
import com.yida.data.common.core.entity.user.enums.UserDeptTypeEnum;
|
||||
import com.yida.data.common.core.enums.BaiDuModuleEnum;
|
||||
import com.yida.data.common.core.enums.school.DeptAppTypeEnum;
|
||||
import com.yida.data.common.core.utils.FebsUtil;
|
||||
import com.yida.data.common.core.utils.NumberUtil;
|
||||
import com.yida.data.common.core.utils.RedisUtil;
|
||||
import com.yida.data.common.core.utils.UPayUtil;
|
||||
import com.yida.data.common.core.utils.WxServiceProviderUtil;
|
||||
import com.yida.data.common.core.utils.WxUtil;
|
||||
import com.yida.data.school.feign.index.RemoteDeptHomeIndexService;
|
||||
import com.yida.data.system.feign.RemoteAppService;
|
||||
import com.yida.data.system.feign.RemoteBaiDuApiConfigService;
|
||||
import com.yida.data.system.feign.RemoteCommonService;
|
||||
import com.yida.data.system.feign.RemoteConstructionPayConfigService;
|
||||
import com.yida.data.system.feign.RemoteConsumeConfigService;
|
||||
import com.yida.data.system.feign.RemoteDeptFunctionService;
|
||||
import com.yida.data.system.feign.RemoteDeptService;
|
||||
import com.yida.data.system.feign.RemoteDictService;
|
||||
import com.yida.data.system.feign.RemoteHolidayService;
|
||||
import com.yida.data.system.feign.RemotePayTypeService;
|
||||
import com.yida.data.system.feign.RemotePayWxConfigService;
|
||||
import com.yida.data.system.feign.RemoteQywxService;
|
||||
import com.yida.data.system.feign.RemoteUPayConfigService;
|
||||
import com.yida.data.system.feign.RemoteUnionPayConfigService;
|
||||
import com.yida.data.system.feign.RemoteWhiteListService;
|
||||
import com.yida.data.system.feign.RemoteYidaAppAccountService;
|
||||
import com.yida.data.system.feign.RemoteYidaAppService;
|
||||
import com.yida.data.user.feign.RemoteStaffService;
|
||||
import com.yida.data.user.feign.RemoteStudentService;
|
||||
import com.yida.data.system.feign.*;
|
||||
import com.yida.data.user.feign.RemoteUserDeptService;
|
||||
import com.yida.data.user.vo.TeacherDeptVO;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CommonService {
|
||||
|
||||
private final RemoteAppService remoteAppService;
|
||||
private final RemoteQywxService remoteQywxService;
|
||||
private final RemoteDeptService remoteDeptService;
|
||||
private final RemoteDictService remoteDictService;
|
||||
private final RemoteCommonService remoteCommonService;
|
||||
private final RemoteAppService remoteAppService;
|
||||
private final RemoteYidaAppService remoteYidaAppService;
|
||||
private final RemoteHolidayService remoteHolidayService;
|
||||
private final RemotePayTypeService remotePayTypeService;
|
||||
private final RemoteUserDeptService remoteUserDeptService;
|
||||
private final RemoteWhiteListService remoteWhiteListService;
|
||||
private final RemoteUPayConfigService remoteUPayConfigService;
|
||||
private final RemotePayWxConfigService remotePayWxConfigService;
|
||||
private final RemoteDeptFunctionService remoteDeptFunctionService;
|
||||
private final RemoteConsumeConfigService remoteConsumeConfigService;
|
||||
private final RemoteUnionPayConfigService remoteUnionPayConfigService;
|
||||
private final RemoteYidaAppAccountService remoteYidaAppAccountService;
|
||||
private final RemoteBaiDuApiConfigService remoteBaiDuApiConfigService;
|
||||
private final RemoteConstructionPayConfigService remoteConstructionPayConfigService;
|
||||
private final RemoteStaffService remoteStaffService;
|
||||
private final RemoteStudentService remoteStudentService;
|
||||
private final RemoteDeptHomeIndexService remoteDeptHomeIndexService;
|
||||
|
||||
|
||||
private final WxUtil wxUtil;
|
||||
private final WxServiceProviderUtil wxServiceProviderUtil;
|
||||
private final RemotePayWxConfigService remotePayWxConfigService;
|
||||
private final RemoteHolidayService remoteHolidayService;
|
||||
private final RemoteCommonService remoteCommonService;
|
||||
private final RemoteUserDeptService remoteUserDeptService;
|
||||
private final RemotePayTypeService remotePayTypeService;
|
||||
private final RemoteUnionPayConfigService remoteUnionPayConfigService;
|
||||
|
||||
private final RedisService redisService;
|
||||
|
||||
public List<Dict> selectDict(String type) {
|
||||
if (ObjectUtil.isNull(type)) {
|
||||
return null;
|
||||
}
|
||||
return remoteDictService.selectDict(type).getData();
|
||||
}
|
||||
|
||||
public Dict getDictByTypeAndValueOrLabel(String type, String value, String label) {
|
||||
if (ObjectUtil.isNull(type)) {
|
||||
return null;
|
||||
}
|
||||
return remoteDictService.getDictByTypeAndValueOrLabel(type, value, label).getData();
|
||||
}
|
||||
|
||||
public Dept getDept(Long deptId) {
|
||||
if (deptId == null) {
|
||||
return null;
|
||||
@@ -300,7 +211,7 @@ public class CommonService {
|
||||
redisService.llSet(CachePrefixConstant.HOLIDAY, data);
|
||||
for (EduHoliday holiday : data) {
|
||||
// 节假日
|
||||
if (target.equals(holiday.getDate())) {
|
||||
if (target.equals(holiday)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -309,7 +220,7 @@ public class CommonService {
|
||||
for (Object o : objects) {
|
||||
// 节假日
|
||||
EduHoliday holiday = (EduHoliday) o;
|
||||
if (target.equals(holiday.getDate())) {
|
||||
if (target.equals(holiday)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -317,38 +228,6 @@ public class CommonService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 时间段内 节假日集合
|
||||
*/
|
||||
public List<LocalDate> inHolidayDateList(LocalDate startDate, LocalDate endDate) {
|
||||
List<LocalDate> inHolidayList = new ArrayList<>();
|
||||
List<Object> objects = redisService.lGet(CachePrefixConstant.HOLIDAY, 0L, -1L);
|
||||
if (CollUtil.isEmpty(objects)) {
|
||||
List<EduHoliday> data = remoteHolidayService.listAllHoliday().getData();
|
||||
if (CollUtil.isNotEmpty(data)) {
|
||||
redisService.llSet(CachePrefixConstant.HOLIDAY, data);
|
||||
for (EduHoliday holiday : data) {
|
||||
// 节假日
|
||||
LocalDate date = holiday.getDate();
|
||||
if ((date.isAfter(startDate) && date.isBefore(endDate)) || date.equals(startDate) || date.equals(endDate)) {
|
||||
inHolidayList.add(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (Object o : objects) {
|
||||
// 节假日
|
||||
EduHoliday holiday = (EduHoliday) o;
|
||||
LocalDate date = holiday.getDate();
|
||||
if ((date.isAfter(startDate) && date.isBefore(endDate)) || date.equals(startDate) || date.equals(endDate)) {
|
||||
inHolidayList.add(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
return inHolidayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当天的上一个工作日
|
||||
*/
|
||||
@@ -427,83 +306,6 @@ public class CommonService {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门查询建行支付配置
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return com.yida.data.common.core.entity.system.ConstructionPayConfig
|
||||
* @author ZYJ
|
||||
* @date 2023/6/19 16:50
|
||||
*/
|
||||
public ConstructionPayConfig getConstructionPayConfigByDept(Long deptId) {
|
||||
ConstructionPayConfig config = redisService.hasKey(CachePrefixConstant.CONSTRUCTION_PAY_CONFIG)
|
||||
? (ConstructionPayConfig) redisService.hget(CachePrefixConstant.CONSTRUCTION_PAY_CONFIG, deptId.toString())
|
||||
: null;
|
||||
if (config == null) {
|
||||
config = remoteConstructionPayConfigService.getConstructionPayConfigByDept(deptId).getData();
|
||||
redisService.hset(CachePrefixConstant.CONSTRUCTION_PAY_CONFIG, deptId.toString(), config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门查询收钱吧支付配置
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return com.yida.data.common.core.entity.system.UPayConfig
|
||||
* @author ZYJ
|
||||
* @date 2023/3/21 10:42
|
||||
*/
|
||||
public UPayConfig getUPayConfigByDept(Long deptId) {
|
||||
UPayConfig config = redisService.hasKey(CachePrefixConstant.U_PAY_CONFIG)
|
||||
? (UPayConfig) redisService.hget(CachePrefixConstant.U_PAY_CONFIG, deptId.toString())
|
||||
: null;
|
||||
if (config == null) {
|
||||
config = remoteUPayConfigService.getUPayConfigByDept(deptId).getData();
|
||||
redisService.hset(CachePrefixConstant.U_PAY_CONFIG, deptId.toString(), config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学校消费机服务器信息
|
||||
*
|
||||
* @param deptId 部门id
|
||||
* @return com.yida.data.common.core.entity.consume.EduConsumeConfig
|
||||
* @author ZYJ
|
||||
* @date 2023/4/6 17:46
|
||||
*/
|
||||
public EduConsumeConfig getConsumeConfigByDept(Long deptId) {
|
||||
EduConsumeConfig config = redisService.hasKey(CachePrefixConstant.CONSUME_CONFIG)
|
||||
? (EduConsumeConfig) redisService.hget(CachePrefixConstant.CONSUME_CONFIG, deptId.toString())
|
||||
: null;
|
||||
if (config == null) {
|
||||
config = remoteConsumeConfigService.getConsumeConfigByDept(deptId).getData();
|
||||
redisService.hset(CachePrefixConstant.CONSUME_CONFIG, deptId.toString(), config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学校收钱吧终端信息
|
||||
*
|
||||
* @param deptId 学校id
|
||||
* @return com.yida.data.common.core.entity.consume.DeptConsumeTerminalCache
|
||||
* @author ZYJ
|
||||
* @date 2023/4/3 14:47
|
||||
*/
|
||||
public DeptConsumeTerminalCache getDeptConsumeTerminal(Long deptId) {
|
||||
DeptConsumeTerminalCache cache = redisService.hasKey(CachePrefixConstant.DEPT_CONSUME_TERMINAL + deptId.toString())
|
||||
? (DeptConsumeTerminalCache) redisService.get(CachePrefixConstant.DEPT_CONSUME_TERMINAL + deptId.toString())
|
||||
: null;
|
||||
if (cache == null) {
|
||||
cache = UPayUtil.active(getUPayConfigByDept(deptId), UPayConstant.ACTIVE_DEVICE_NAME);
|
||||
cache.setDeptId(deptId);
|
||||
redisService.set(CachePrefixConstant.DEPT_CONSUME_TERMINAL + deptId.toString(), cache);
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向下查询指定家校部门类型的家校部门id(可查询非直接子家校部门) 未毕业家校部门
|
||||
*
|
||||
@@ -529,360 +331,14 @@ public class CommonService {
|
||||
return remoteUserDeptService.findChildIdByParentAndTypeNoPermission(deptId, type).getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务商信息
|
||||
*
|
||||
* @param serviceCorpId 服务商企业微信corpId
|
||||
* @return com.yida.data.common.core.entity.system.EduQywxServiceProvider
|
||||
* @author ZYJ
|
||||
* @date 2022/12/1 10:46
|
||||
*/
|
||||
public EduQywxServiceProvider getServiceProvider(String serviceCorpId) {
|
||||
EduQywxServiceProvider serviceProvider = redisService.hasKey(CachePrefixConstant.SYS_SERVICE_PROVIDER)
|
||||
? (EduQywxServiceProvider) redisService.hget(CachePrefixConstant.SYS_SERVICE_PROVIDER, serviceCorpId)
|
||||
: null;
|
||||
if (Objects.isNull(serviceProvider)) {
|
||||
serviceProvider = remoteAppService.getServiceProviderByServiceCorpId(serviceCorpId).getData();
|
||||
if (Objects.nonNull(serviceProvider)) {
|
||||
redisService.hset(CachePrefixConstant.SYS_SERVICE_PROVIDER, serviceCorpId, serviceProvider);
|
||||
}
|
||||
}
|
||||
return serviceProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应服务商模板信息
|
||||
* 工具学校名称查找机构信息
|
||||
*
|
||||
* @param templateId 模板id
|
||||
* @param serviceCorpId 服务商corpId
|
||||
* @return com.yida.data.common.core.entity.system.EduAppTemplate
|
||||
* @author ZYJ
|
||||
* @date 2022/12/1 9:27
|
||||
*/
|
||||
public EduAppTemplate getAppTemplateByTemplateId(String templateId, String serviceCorpId) {
|
||||
EduAppTemplate eduAppTemplate = redisService.hasKey(CachePrefixConstant.SYS_APP_TEMPLATE)
|
||||
? (EduAppTemplate) redisService.hget(CachePrefixConstant.SYS_APP_TEMPLATE, serviceCorpId + "." + templateId)
|
||||
: null;
|
||||
if (Objects.isNull(eduAppTemplate)) {
|
||||
eduAppTemplate = remoteAppService.getAppTemplateByTemplateId(templateId, serviceCorpId).getData();
|
||||
if (Objects.nonNull(eduAppTemplate)) {
|
||||
redisService.hset(CachePrefixConstant.SYS_APP_TEMPLATE, serviceCorpId + "." + templateId, eduAppTemplate);
|
||||
}
|
||||
}
|
||||
return eduAppTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据学校对应的通讯录应用类型获取不同的access_token 创建、编辑、删除、获取部门ID列表、获取成员ID列表时使用
|
||||
*
|
||||
* @param schoolId 学校id
|
||||
* @return java.lang.String
|
||||
* @author ZYJ
|
||||
* @date 2022/12/1 9:46
|
||||
*/
|
||||
public String getAddressListToken(Long schoolId) {
|
||||
String accessToken;
|
||||
// 获取学校通讯录应用
|
||||
EduApp app = getAppByCodeAndSchool(AppConstant.CONTACT, null, schoolId);
|
||||
|
||||
if (Objects.isNull(app.getTemplateId())) {
|
||||
// 自建应用
|
||||
accessToken = wxUtil.getAccessToken(app.getWxCorpId(), app.getWxSecret());
|
||||
} else {
|
||||
// 服务商代开发应用
|
||||
// 获取对应模板信息
|
||||
EduAppTemplate appTemplate = getAppTemplateByTemplateId(app.getTemplateId(), app.getServiceCorpId());
|
||||
// 获取第三方应用凭证
|
||||
String suiteAccessToken = wxServiceProviderUtil.getSuiteAccessToken(appTemplate.getTemplateId(),
|
||||
appTemplate.getTemplateSecret(),
|
||||
String.valueOf(redisService.get(QywxServiceProviderConstant.SERVICE_SUITE_TICKET + appTemplate.getTemplateId())));
|
||||
// 获取企业微信信息缓存
|
||||
// EduQywxServiceProviderSchool providerSchool = (EduQywxServiceProviderSchool) redisService
|
||||
// .hget(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_ORIGINAL_DATA,
|
||||
// app.getServiceCorpId() + "." + app.getWxCorpId());
|
||||
EduQywxServiceProviderSchool providerSchool = getCorpByOriginalData(app.getServiceCorpId(), app.getWxCorpId());
|
||||
accessToken = wxServiceProviderUtil
|
||||
.getCorpToken(providerSchool.getDeptEncryptionCorpId(), app.getWxSecret(), suiteAccessToken);
|
||||
}
|
||||
return accessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务商对应学校加密corpId数据(原始值为key)
|
||||
*
|
||||
* @param providerCorpId 服务商corpId
|
||||
* @param deptOriginalCorpId 部门原始corpId
|
||||
* @return com.yida.data.common.core.common.ResultBean<com.yida.data.common.core.entity.system.EduQywxServiceProviderSchool>
|
||||
* @author ZYJ
|
||||
* @date 2023/9/25 17:48
|
||||
*/
|
||||
public EduQywxServiceProviderSchool getCorpByOriginalData(String providerCorpId, String deptOriginalCorpId) {
|
||||
EduQywxServiceProviderSchool providerSchool =
|
||||
redisService.hasKey(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_ORIGINAL_DATA)
|
||||
? (EduQywxServiceProviderSchool) redisService.hget(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_ORIGINAL_DATA,
|
||||
providerCorpId + "." + deptOriginalCorpId)
|
||||
: null;
|
||||
if (providerSchool == null) {
|
||||
providerSchool = remoteQywxService.getCorpByOriginalData(providerCorpId, deptOriginalCorpId).getData();
|
||||
redisService
|
||||
.hset(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_ORIGINAL_DATA, providerCorpId + "." + deptOriginalCorpId,
|
||||
providerSchool);
|
||||
}
|
||||
return providerSchool;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务商对应学校加密corpId数据(加密值为key)
|
||||
*
|
||||
* @param providerCorpId 服务商corpId
|
||||
* @param deptEncryptionCorpId 部门加密corpId
|
||||
* @return com.yida.data.common.core.common.ResultBean<com.yida.data.common.core.entity.system.EduQywxServiceProviderSchool>
|
||||
* @author ZYJ
|
||||
* @date 2023/9/25 17:48
|
||||
*/
|
||||
public EduQywxServiceProviderSchool getCorpByEncryptionData(String providerCorpId, String deptEncryptionCorpId) {
|
||||
EduQywxServiceProviderSchool providerSchool = redisService.hasKey(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_DATA)
|
||||
? (EduQywxServiceProviderSchool) redisService.hget(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_DATA,
|
||||
providerCorpId + "." + deptEncryptionCorpId)
|
||||
: null;
|
||||
if (providerSchool == null) {
|
||||
providerSchool = remoteQywxService.getCorpByEncryptionData(providerCorpId, deptEncryptionCorpId).getData();
|
||||
redisService.hset(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_DATA, providerCorpId + "." + deptEncryptionCorpId,
|
||||
providerSchool);
|
||||
}
|
||||
return providerSchool;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业凭证
|
||||
*
|
||||
* @param app 通讯录应用信息
|
||||
* @return java.lang.String
|
||||
* @author ZYJ
|
||||
* @date 2022/12/1 11:24
|
||||
*/
|
||||
public String getCorpToken(EduApp app) {
|
||||
// 获取对应模板信息
|
||||
EduAppTemplate appTemplate = getAppTemplateByTemplateId(app.getTemplateId(), app.getServiceCorpId());
|
||||
// 获取第三方应用凭证
|
||||
String suiteAccessToken = wxServiceProviderUtil.getSuiteAccessToken(appTemplate.getTemplateId(),
|
||||
appTemplate.getTemplateSecret(),
|
||||
String.valueOf(redisService.get(QywxServiceProviderConstant.SERVICE_SUITE_TICKET + appTemplate.getTemplateId())));
|
||||
// 获取企业微信信息缓存
|
||||
// EduQywxServiceProviderSchool providerSchool = (EduQywxServiceProviderSchool) redisService
|
||||
// .hget(QywxServiceProviderConstant.PROVIDER_SCHOOL_CORP_ORIGINAL_DATA,
|
||||
// app.getServiceCorpId() + "." + app.getWxCorpId());
|
||||
EduQywxServiceProviderSchool providerSchool = getCorpByOriginalData(app.getServiceCorpId(), app.getWxCorpId());
|
||||
return wxServiceProviderUtil.getCorpToken(providerSchool.getDeptEncryptionCorpId(), app.getWxSecret(), suiteAccessToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置职工授权url
|
||||
*
|
||||
* @param corpId 企业的CorpID
|
||||
* @param redirectUrl 授权后重定向的回调链接地址,请使用urlencode对链接进行处理
|
||||
* @param agentId 应用agentid,snsapi_privateinfo时必填
|
||||
* @return java.lang.String
|
||||
* @author ZYJ
|
||||
* @date 2022/11/25 15:11
|
||||
*/
|
||||
public String setAuthUrl(String corpId, String redirectUrl, String agentId) {
|
||||
return "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + corpId
|
||||
+ "&redirect_uri=" + URLEncoder.createDefault().encode(redirectUrl, CharsetUtil.CHARSET_UTF_8)
|
||||
+ "&response_type=code&scope=snsapi_privateinfo&state=STATE"
|
||||
+ "&agentid=" + agentId + "#wechat_redirect";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通讯录应用情况获取对应用户明文id 如果不是通讯录模板授权则返回本身userId
|
||||
*
|
||||
* @param userId 企业微信userId
|
||||
* @param schoolId 学校id
|
||||
* @param eduApp 通讯录app
|
||||
* @return java.lang.String
|
||||
* @author ZYJ
|
||||
* @date 2023/2/2 10:41
|
||||
*/
|
||||
public String getPlainUserId(String userId, Long schoolId, EduApp eduApp) {
|
||||
// 获取学校通讯录应用
|
||||
EduApp app = getAppByCodeAndSchool(AppConstant.CONTACT, null, schoolId);
|
||||
|
||||
// 本身就是明文id
|
||||
if (Objects.isNull(app.getTemplateId())) {
|
||||
return userId;
|
||||
} else {
|
||||
// 企业自建应用或基础应用的调用接口凭证
|
||||
EduApp appContactSchool = getAppByCodeAndSchool(AppConstant.CONTACT_SCHOOL, null, schoolId);
|
||||
String accessToken = wxUtil.getAccessToken(appContactSchool.getWxCorpId(), appContactSchool.getWxSecret());
|
||||
// 密文转换成明文id
|
||||
return wxServiceProviderUtil.convertUserIdToPlain(accessToken, userId, eduApp.getWxAgentId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据通讯录应用情况获取对应用户密文id 如果不是通讯录模板授权则返回本身userId
|
||||
*
|
||||
* @param userId 企业微信userId
|
||||
* @param schoolId 学校id
|
||||
* @return java.lang.String
|
||||
* @author ZYJ
|
||||
* @date 2023/2/2 14:45
|
||||
*/
|
||||
public String getSecretUserId(String userId, Long schoolId) {
|
||||
// 获取学校通讯录应用
|
||||
EduApp app = getAppByCodeAndSchool(AppConstant.CONTACT, null, schoolId);
|
||||
|
||||
// 本身就是明文id
|
||||
if (Objects.isNull(app.getTemplateId())) {
|
||||
return userId;
|
||||
} else {
|
||||
EduApp eduApp = getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null, schoolId);
|
||||
// 明文转换成密文id
|
||||
return wxServiceProviderUtil.convertUserIdToSecret(
|
||||
wxUtil.getAccessToken(eduApp.getWxCorpId(), eduApp.getWxSecret()), userId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询学校用于查询的通讯录应用
|
||||
*
|
||||
* @param schoolId 学校id
|
||||
* @return com.yida.data.common.core.entity.system.EduApp
|
||||
* @author ZYJ
|
||||
* @date 2023/4/23 20:25
|
||||
*/
|
||||
public EduApp getAppContactUsedBySelect(Long schoolId) {
|
||||
// 获取学校通讯录应用
|
||||
EduApp app = getAppByCodeAndSchool(AppConstant.CONTACT, null, schoolId);
|
||||
// 本身就是明文id
|
||||
if (Objects.isNull(app.getTemplateId())) {
|
||||
return app;
|
||||
} else {
|
||||
return getAppByCodeAndSchool(AppConstant.CONTACT_SELECT, null, schoolId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据学校名称查找机构信息
|
||||
*
|
||||
* @param schoolName 学校名称
|
||||
* @return com.yida.data.common.core.entity.system.Dept
|
||||
* @author ZYJ
|
||||
* @date 2023/2/2 11:03
|
||||
* @param schoolName
|
||||
* @return
|
||||
*/
|
||||
public Dept getSchoolByName(String schoolName) {
|
||||
return remoteDeptService.getSchoolByName(schoolName).getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取系统白名单信息
|
||||
*
|
||||
* @param functionName 功能名称 {@link SysFunctionEnum}
|
||||
* @return com.yida.data.common.core.entity.system.WhiteList
|
||||
* @author ZYJ
|
||||
* @date 2023/2/20 18:00
|
||||
*/
|
||||
public WhiteList getWhiteList(String functionName) {
|
||||
WhiteList whiteList = redisService.hasKey(CachePrefixConstant.SYS_WHITE_LIST)
|
||||
? (WhiteList) redisService.hget(CachePrefixConstant.SYS_WHITE_LIST, functionName)
|
||||
: null;
|
||||
if (whiteList == null) {
|
||||
whiteList = remoteWhiteListService.getWhiteList(functionName).getData();
|
||||
redisService.hset(CachePrefixConstant.SYS_WHITE_LIST, functionName, whiteList);
|
||||
}
|
||||
return whiteList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门是否开通当前功能
|
||||
*
|
||||
* @param functionName 功能名称
|
||||
* @param schoolId 部门id
|
||||
* @return com.yida.data.common.core.entity.system.EduDeptFunction
|
||||
* @author ZYJ
|
||||
* @date 2023/2/21 16:08
|
||||
*/
|
||||
public EduDeptFunction getDeptFunction(String functionName, Long schoolId) {
|
||||
EduDeptFunction eduDeptFunction = redisService.hasKey(CachePrefixConstant.SYS_DEPT_FUNCTION + schoolId)
|
||||
? (EduDeptFunction) redisService.hget(CachePrefixConstant.SYS_DEPT_FUNCTION + schoolId, functionName)
|
||||
: null;
|
||||
if (eduDeptFunction == null) {
|
||||
eduDeptFunction = remoteDeptFunctionService.getDeptFunction(functionName, schoolId).getData();
|
||||
redisService.hset(CachePrefixConstant.SYS_DEPT_FUNCTION + schoolId, functionName, eduDeptFunction);
|
||||
}
|
||||
return eduDeptFunction;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据学校id查询百度api配置
|
||||
*
|
||||
* @param deptId 学校id
|
||||
* @param moduleName 百度模块名称 {@link BaiDuModuleEnum}
|
||||
* @return com.yida.data.common.core.entity.system.BaiduApiConfig
|
||||
* @author ZYJ
|
||||
* @date 2023/6/20 20:57
|
||||
*/
|
||||
public BaiduApiConfig getBaiDuApiConfigByDept(Long deptId, String moduleName) {
|
||||
BaiduApiConfig config = redisService.hasKey(CachePrefixConstant.BAI_DU_API_CONFIG + deptId)
|
||||
? (BaiduApiConfig) redisService.hget(CachePrefixConstant.BAI_DU_API_CONFIG + deptId, moduleName)
|
||||
: null;
|
||||
if (config == null) {
|
||||
config = remoteBaiDuApiConfigService.getBaiDuApiConfigByDept(deptId, moduleName).getData();
|
||||
redisService.hset(CachePrefixConstant.BAI_DU_API_CONFIG + deptId.toString(), moduleName, config);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public EduStaff getStaffById(Long staffId) {
|
||||
EduStaff staff = (EduStaff) redisService.hget(STAFF_DATA, staffId.toString());
|
||||
if (ObjectUtil.isNull(staff)) {
|
||||
staff = remoteStaffService.getStaff(staffId).getData();
|
||||
if (ObjectUtil.isNotNull(staff)) {
|
||||
redisService.hset(STAFF_DATA, staffId.toString(), staff);
|
||||
}
|
||||
}
|
||||
return staff;
|
||||
}
|
||||
|
||||
public EduStudent getStudentById(Long id) {
|
||||
EduStudent student = (EduStudent) redisService
|
||||
.hget(CachePrefixConstant.STUDENT_DATA, id.toString());
|
||||
if (ObjectUtil.isNull(student)) {
|
||||
student = remoteStudentService.getStudentNoPermission(id).getData();
|
||||
if (student == null) {
|
||||
log.error("学生不存在,id:[{}]", id);
|
||||
return null;
|
||||
} else {
|
||||
redisService.hset(CachePrefixConstant.STUDENT_DATA, id.toString(), student);
|
||||
}
|
||||
}
|
||||
return student;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清除 人员匹配考勤规则
|
||||
*/
|
||||
public void clearAttendanceRuleData() {
|
||||
redisService.del(CachePrefixConstant.ATTENDANCE_STUDENT_RULE);
|
||||
}
|
||||
|
||||
|
||||
public void delUserGenerateUrlLinkCache(Long schoolId, Long userId, Integer userType) {
|
||||
//查询所有的微信小程序app
|
||||
List<EduDeptHomeApp> eduDeptHomeAppList = remoteDeptHomeIndexService.getDeptAppList(schoolId).getData();
|
||||
List<EduDeptHomeApp> wxAppList = eduDeptHomeAppList.stream()
|
||||
.filter(e -> DeptAppTypeEnum.WX.getType().equals(e.getAppType()))
|
||||
.collect(Collectors.toList());
|
||||
for (EduDeptHomeApp homeApp : wxAppList) {
|
||||
redisService.del(CachePrefixConstant.USER_GENERATE_URL_LINK + userId + "" + userType + "" + homeApp.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public List<Long> findStaffMangerClassIdList() {
|
||||
List<Long> ClassIdList = new ArrayList<>();
|
||||
CurrentUser currentUser = FebsUtil.getCurrentUser();
|
||||
String rolePerms = FebsUtil.getCurrentUser().getRolePerms();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user