|
@@ -3,19 +3,26 @@ package com.fjhx.service.excel.impl;
|
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.base.BaseEntity;
|
|
|
+import com.fjhx.base.Condition;
|
|
|
import com.fjhx.config.TaskPoolConfig;
|
|
|
import com.fjhx.constants.VRedisKeyConstant;
|
|
|
+import com.fjhx.entity.FileInfo;
|
|
|
import com.fjhx.entity.excel.ExcelImportLog;
|
|
|
+import com.fjhx.feign.IFileClient;
|
|
|
import com.fjhx.listener.EasyExcelListener;
|
|
|
import com.fjhx.mapper.excel.ExcelImportLogMapper;
|
|
|
import com.fjhx.params.excel.BaseExcelVo;
|
|
|
import com.fjhx.params.excel.ExcelProcessingProgress;
|
|
|
import com.fjhx.service.excel.ExcelImportLogService;
|
|
|
+import com.fjhx.utils.Assert;
|
|
|
+import com.fjhx.utils.wrapperUtil.IWrapper;
|
|
|
import org.springblade.core.excel.support.ExcelException;
|
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
@@ -50,6 +57,9 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
|
|
|
@Resource
|
|
|
private BladeRedis bladeRedis;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFileClient fileClient;
|
|
|
+
|
|
|
@Override
|
|
|
public <T extends BaseExcelVo> void asyncRead(int pageSize, Long flag, MultipartFile file, Class<T> cls, Integer businessType,
|
|
|
Consumer<List<T>> handleFun, Runnable errorFun) {
|
|
@@ -158,12 +168,18 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
|
|
|
|
|
|
@Override
|
|
|
public void saveLog(Long flag, Integer businessType, MultipartFile file) {
|
|
|
+
|
|
|
+ R<FileInfo> fileInfoR = fileClient.uploadFile(file);
|
|
|
+ FileInfo result = Assert.result(fileInfoR);
|
|
|
+
|
|
|
// 上传记录记录数据库
|
|
|
ExcelImportLog excelImportLog = new ExcelImportLog();
|
|
|
excelImportLog.setId(flag);
|
|
|
excelImportLog.setBusinessType(businessType);
|
|
|
excelImportLog.setStatus(1);
|
|
|
- excelImportLog.setFileName(file.getOriginalFilename());
|
|
|
+ excelImportLog.setFileId(result.getId());
|
|
|
+ excelImportLog.setFileName(result.getFileName());
|
|
|
+ excelImportLog.setFilePath(result.getFilePath());
|
|
|
excelImportLog.setCreateTime(new Date());
|
|
|
excelImportLog.setCreateUser(AuthUtil.getUserId());
|
|
|
save(excelImportLog);
|
|
@@ -187,6 +203,16 @@ public class ExcelImportLogServiceImpl extends ServiceImpl<ExcelImportLogMapper,
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<ExcelImportLog> getPage(Condition condition) {
|
|
|
+ IWrapper<ExcelImportLog> wrapper = IWrapper.getWrapper(condition);
|
|
|
+ wrapper.eq(ExcelImportLog::getBusinessType);
|
|
|
+ wrapper.periodTime(ExcelImportLog::getCreateTime);
|
|
|
+ wrapper.orderByDesc(ExcelImportLog::getId);
|
|
|
+
|
|
|
+ return page(condition.getPage(), wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 插入缓存信息
|
|
|
*
|