Compare commits
2 Commits
2.0.0.rc42
...
2.0.0.rc44
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90029faa53 | ||
|
|
ecb5aa1b29 |
22
pom.xml
22
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -58,61 +58,61 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-role</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.tiesheng.demo.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||
import com.tiesheng.web.service.imex.TsImportHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class UserImportHandler implements TsImportHandler<String> {
|
||||
|
||||
@Override
|
||||
public List<String> ready(ImportDealDTO dto, TokenBean token) {
|
||||
return CollUtil.newArrayList("11111");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateUrl() {
|
||||
return "/template/xsxxzx_teacher_leader.xlsx";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAction() {
|
||||
return "user_import";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchHandler(List<String> list) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailFile() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-role</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>2.0.0.rc42</version>
|
||||
<version>2.0.0.rc44</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.tiesheng.web.config.template;
|
||||
|
||||
import com.tiesheng.web.pojos.dto.TemplateDealDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class TieshengTemplateHandler implements ToolTemplateHandler {
|
||||
@Override
|
||||
public String handler(TemplateDealDTO dto) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateUrl() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getParms(Object params) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getAction() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.tiesheng.web.config.template;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.web.pojos.dto.TemplateDealDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface ToolTemplateHandler {
|
||||
|
||||
|
||||
/**
|
||||
* 处理对象
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
String handler(TemplateDealDTO dto);
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getTemplateUrl();
|
||||
|
||||
Object getParms(Object params);
|
||||
|
||||
|
||||
/**
|
||||
* 动作说明(唯一)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getAction();
|
||||
|
||||
|
||||
/**
|
||||
* 排序,如果action相同,只会使用sort大的来处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getSort();
|
||||
|
||||
/**
|
||||
* 获取模版ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getTeamplateId() {
|
||||
return StrUtil.format("{}_{}", getAction(), getSort());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,19 +4,33 @@ package com.tiesheng.web.controller.comm;
|
||||
import cn.hutool.captcha.LineCaptcha;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.tiesheng.annotation.operation.OperationIgnore;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import com.tiesheng.web.config.template.ToolTemplateHandler;
|
||||
import com.tiesheng.web.pojos.dto.*;
|
||||
import com.tiesheng.web.pojos.vo.TemplateInfoVO;
|
||||
import com.tiesheng.web.pojos.vo.PicVerifyVo;
|
||||
import com.tiesheng.web.service.FileUploadService;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.ApiResp;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.util.service.TsCacheService;
|
||||
import com.tiesheng.web.pojos.dao.CoreLogProcess;
|
||||
import com.tiesheng.web.pojos.dto.ChunkCheckDTO;
|
||||
import com.tiesheng.web.pojos.dto.ChunkMergeDTO;
|
||||
import com.tiesheng.web.pojos.dto.ChunkStartDTO;
|
||||
import com.tiesheng.web.pojos.dto.ImageCodeDTO;
|
||||
import com.tiesheng.web.pojos.imex.ExportDealDTO;
|
||||
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||
import com.tiesheng.web.pojos.imex.ImportInfoDTO;
|
||||
import com.tiesheng.web.pojos.imex.ImportInfoVO;
|
||||
import com.tiesheng.web.pojos.vo.PicVerifyVo;
|
||||
import com.tiesheng.web.service.CoreLogService;
|
||||
import com.tiesheng.web.service.FileUploadService;
|
||||
import com.tiesheng.web.service.imex.TsExportHandler;
|
||||
import com.tiesheng.web.service.imex.TsImportHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -35,7 +49,11 @@ public class ToolController {
|
||||
@Autowired
|
||||
FileUploadService fileUploadService;
|
||||
@Autowired
|
||||
List<ToolTemplateHandler> templateHandlerList;
|
||||
List<TsImportHandler> importHandlers;
|
||||
@Autowired
|
||||
List<TsExportHandler> exportHandlers;
|
||||
@Autowired
|
||||
CoreLogService coreLogService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,40 +142,102 @@ public class ToolController {
|
||||
}
|
||||
|
||||
|
||||
@TokenIgnore
|
||||
@GetMapping("/template/info")
|
||||
public ApiResp<TemplateInfoVO> templateInfo(TemplateInfoDTO dto) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// import
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
List<ToolTemplateHandler> collect = templateHandlerList.stream()
|
||||
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("没有找到对应的模版");
|
||||
@TokenIgnore
|
||||
@GetMapping("/imex/info")
|
||||
public ApiResp<ImportInfoVO> importInfo(@Valid ImportInfoDTO dto) {
|
||||
|
||||
ImportInfoVO template = new ImportInfoVO();
|
||||
|
||||
if (Objects.equals(dto.getType(), "import")) {
|
||||
List<TsImportHandler> collect = importHandlers.stream()
|
||||
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
TsImportHandler toolTemplateHandler = collect.get(0);
|
||||
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
||||
template.setImexId(toolTemplateHandler.getImexId());
|
||||
}
|
||||
} else if (Objects.equals(dto.getType(), "export")) {
|
||||
List<TsExportHandler> collect = exportHandlers.stream()
|
||||
.filter(it -> Objects.equals(it.getAction(), dto.getAction()))
|
||||
.sorted((it, it2) -> it2.getSort() - it.getSort())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
TsExportHandler toolTemplateHandler = collect.get(0);
|
||||
template.setImexId(toolTemplateHandler.getImexId());
|
||||
}
|
||||
}
|
||||
|
||||
ToolTemplateHandler toolTemplateHandler = collect.get(0);
|
||||
|
||||
TemplateInfoVO template = new TemplateInfoVO();
|
||||
template.setTemplateUrl(toolTemplateHandler.getTemplateUrl());
|
||||
template.setParams(toolTemplateHandler.getParms(dto.getParams()));
|
||||
template.setTemplateId(toolTemplateHandler.getTeamplateId());
|
||||
if (StrUtil.isEmpty(template.getImexId())) {
|
||||
throw new ApiException("没有找到对应的模版");
|
||||
}
|
||||
|
||||
return ApiResp.respOK(template);
|
||||
}
|
||||
|
||||
@TokenIgnore
|
||||
@PostMapping("/template/deal")
|
||||
public ApiResp<String> templateDeal(@RequestBody TemplateDealDTO dto) {
|
||||
|
||||
List<ToolTemplateHandler> collect = templateHandlerList.stream().
|
||||
filter(it -> Objects.equals(it.getTeamplateId(), dto.getTemplateId()))
|
||||
@TokenIgnore
|
||||
@OperationIgnore
|
||||
@PostMapping("/import/deal")
|
||||
public ApiResp<String> importDeal(@RequestBody @Valid ImportDealDTO dto, TokenBean token) {
|
||||
|
||||
List<TsImportHandler> collect = importHandlers.stream().
|
||||
filter(it -> Objects.equals(it.getImexId(), dto.getImexId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("模版ID不存在");
|
||||
throw new ApiException("导入ID不存在");
|
||||
}
|
||||
|
||||
return ApiResp.respOK(collect.get(0).handler(dto));
|
||||
TsImportHandler tsImportHandler = collect.get(0);
|
||||
tsImportHandler.validToken(token);
|
||||
List read = tsImportHandler.ready(dto, token);
|
||||
if (CollUtil.isEmpty(read)) {
|
||||
throw new ApiException("没有数据可以导入");
|
||||
}
|
||||
CoreLogProcess coreLogProcess = coreLogService.addProcess(tsImportHandler.getImexId(), read, tsImportHandler);
|
||||
coreLogProcess.setParams(JSON.toJSONString(dto));
|
||||
coreLogService.getCoreLogProcessMapper().updateById(coreLogProcess);
|
||||
|
||||
return ApiResp.respOK(coreLogProcess.getId());
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// export
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@TokenIgnore
|
||||
@OperationIgnore
|
||||
@PostMapping("/export/deal")
|
||||
public ApiResp<String> exportDeal(@RequestBody @Valid ExportDealDTO dto, TokenBean token) {
|
||||
|
||||
List<TsExportHandler> collect = exportHandlers.stream().
|
||||
filter(it -> Objects.equals(it.getImexId(), dto.getImexId()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollUtil.isEmpty(collect)) {
|
||||
throw new ApiException("导出ID不存在");
|
||||
}
|
||||
|
||||
TsExportHandler tsExportHandler = collect.get(0);
|
||||
tsExportHandler.validToken(token);
|
||||
List read = tsExportHandler.ready(dto, token);
|
||||
if (CollUtil.isEmpty(read)) {
|
||||
throw new ApiException("没有数据可以导出");
|
||||
}
|
||||
CoreLogProcess coreLogProcess = coreLogService.addProcess(tsExportHandler.getImexId(), read, tsExportHandler);
|
||||
coreLogProcess.setType("export");
|
||||
coreLogProcess.setParams(JSON.toJSONString(dto));
|
||||
coreLogService.getCoreLogProcessMapper().updateById(coreLogProcess);
|
||||
|
||||
return ApiResp.respOK(coreLogProcess.getId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -51,18 +51,18 @@ public class CoreLogProcess extends DaoBase {
|
||||
@TableField(value = "fail_file")
|
||||
private String failFile;
|
||||
|
||||
/**
|
||||
* 异常说明
|
||||
*/
|
||||
@TableField(value = "error")
|
||||
private String error;
|
||||
|
||||
/**
|
||||
* 进度
|
||||
*/
|
||||
@TableField(value = "`process`")
|
||||
private Integer process;
|
||||
|
||||
/**
|
||||
* 异常说明
|
||||
*/
|
||||
@TableField(value = "params")
|
||||
private String params;
|
||||
|
||||
/**
|
||||
* 获取标题
|
||||
*
|
||||
@@ -189,24 +189,6 @@ public class CoreLogProcess extends DaoBase {
|
||||
this.failFile = failFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常说明
|
||||
*
|
||||
* @return error - 异常说明
|
||||
*/
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异常说明
|
||||
*
|
||||
* @param error 异常说明
|
||||
*/
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度
|
||||
*
|
||||
@@ -224,4 +206,22 @@ public class CoreLogProcess extends DaoBase {
|
||||
public void setProcess(Integer process) {
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常说明
|
||||
*
|
||||
* @return params - 异常说明
|
||||
*/
|
||||
public String getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异常说明
|
||||
*
|
||||
* @param params 异常说明
|
||||
*/
|
||||
public void setParams(String params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class ExportDealDTO {
|
||||
|
||||
@NotEmpty(message = "模版ID")
|
||||
private String imexId;
|
||||
private JSONObject params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public String getImexId() {
|
||||
return imexId;
|
||||
}
|
||||
|
||||
public void setImexId(String imexId) {
|
||||
this.imexId = imexId;
|
||||
}
|
||||
|
||||
public JSONObject getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(JSONObject params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,27 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class TemplateDealDTO {
|
||||
public class ImportDealDTO {
|
||||
|
||||
@NotEmpty(message = "模版ID")
|
||||
private String templateId;
|
||||
private String imexId;
|
||||
@NotEmpty(message = "文件路径必填")
|
||||
private String file;
|
||||
private Object params;
|
||||
private JSONObject params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
public String getImexId() {
|
||||
return imexId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
public void setImexId(String imexId) {
|
||||
this.imexId = imexId;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
@@ -30,11 +32,11 @@ public class TemplateDealDTO {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public Object getParams() {
|
||||
public JSONObject getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Object params) {
|
||||
public void setParams(JSONObject params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.tiesheng.web.pojos.dto;
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
|
||||
public class TemplateInfoDTO {
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class ImportInfoDTO {
|
||||
|
||||
@NotEmpty(message = "操作必须存在")
|
||||
private String action;
|
||||
private Object params;
|
||||
|
||||
@NotEmpty(message = "类型必须存在")
|
||||
private String type;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
@@ -18,11 +23,11 @@ public class TemplateInfoDTO {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Object getParams() {
|
||||
return params;
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setParams(Object params) {
|
||||
this.params = params;
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.tiesheng.web.pojos.imex;
|
||||
|
||||
|
||||
public class ImportInfoVO {
|
||||
|
||||
private String imexId;
|
||||
private String templateUrl;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getImexId() {
|
||||
return imexId;
|
||||
}
|
||||
|
||||
public void setImexId(String imexId) {
|
||||
this.imexId = imexId;
|
||||
}
|
||||
|
||||
public String getTemplateUrl() {
|
||||
return templateUrl;
|
||||
}
|
||||
|
||||
public void setTemplateUrl(String templateUrl) {
|
||||
this.templateUrl = templateUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.tiesheng.web.pojos.vo;
|
||||
|
||||
|
||||
public class TemplateInfoVO {
|
||||
|
||||
private String templateId;
|
||||
private String templateUrl;
|
||||
private Object params;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getTemplateId() {
|
||||
return templateId;
|
||||
}
|
||||
|
||||
public void setTemplateId(String templateId) {
|
||||
this.templateId = templateId;
|
||||
}
|
||||
|
||||
public String getTemplateUrl() {
|
||||
return templateUrl;
|
||||
}
|
||||
|
||||
public void setTemplateUrl(String templateUrl) {
|
||||
this.templateUrl = templateUrl;
|
||||
}
|
||||
|
||||
public Object getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public void setParams(Object params) {
|
||||
this.params = params;
|
||||
}
|
||||
}
|
||||
@@ -79,33 +79,24 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
coreLogProcess.setSuccessNum(0);
|
||||
coreLogProcess.setFailNum(0);
|
||||
coreLogProcess.setProcess(0);
|
||||
coreLogProcess.setError("");
|
||||
coreLogProcess.setParams("");
|
||||
coreLogProcessMapper.insert(coreLogProcess);
|
||||
|
||||
ThreadUtil.execute(() -> {
|
||||
List<Exception> errorList = new ArrayList<>();
|
||||
CollUtil.split(list, 100).forEach((it) -> {
|
||||
int accept = 0;
|
||||
try {
|
||||
accept = consumer.accept(it);
|
||||
} catch (Exception e) {
|
||||
errorList.add(e);
|
||||
}
|
||||
int accept = consumer.batchHandler(it);
|
||||
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
||||
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
// 执行结束
|
||||
coreLogProcess.setFailFile(consumer.getFailFile());
|
||||
coreLogProcess.setStatus(1);
|
||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
|
||||
return coreLogProcess;
|
||||
}
|
||||
|
||||
@@ -126,29 +117,24 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
coreLogProcess.setFailNum(0);
|
||||
coreLogProcess.setTotal(0);
|
||||
coreLogProcess.setProcess(0);
|
||||
coreLogProcess.setError("");
|
||||
coreLogProcessMapper.insert(coreLogProcess);
|
||||
|
||||
ThreadUtil.execute(() -> {
|
||||
int pageSize = 1000;
|
||||
int pageNum = 1, lastCount = pageSize;
|
||||
List<Exception> errorList = new ArrayList<>();
|
||||
while (lastCount == pageSize) {
|
||||
try {
|
||||
lastCount = consumer.accept(pageNum, pageSize);
|
||||
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
||||
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
||||
} catch (Exception e) {
|
||||
errorList.add(e);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
// 执行结束
|
||||
coreLogProcess.setError(JSON.toJSONString(errorList));
|
||||
coreLogProcess.setStatus(1);
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.tiesheng.web.service.imex;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.web.pojos.imex.ExportDealDTO;
|
||||
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class DefaultImexHandler implements TsImportHandler<String>, TsExportHandler<String> {
|
||||
|
||||
@Override
|
||||
public List<String> ready(ExportDealDTO dto, TokenBean token) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> ready(ImportDealDTO dto, TokenBean token) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateUrl() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAction() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int batchHandler(List<String> list) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFailFile() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.tiesheng.web.service.imex;
|
||||
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.web.pojos.imex.ExportDealDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TsExportHandler<T> extends TsImexBase<T> {
|
||||
|
||||
|
||||
/**
|
||||
* 数据准备中
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<T> ready(ExportDealDTO dto, TokenBean token);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.tiesheng.web.service.imex;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.web.util.ProcessImportConsumer;
|
||||
|
||||
public interface TsImexBase<T> extends ProcessImportConsumer<T> {
|
||||
|
||||
/**
|
||||
* 动作说明(唯一)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getAction();
|
||||
|
||||
/**
|
||||
* 排序,如果action相同,只会使用sort大的来处理
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default int getSort() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证是否登录
|
||||
*
|
||||
* @param tokenBean
|
||||
*/
|
||||
default void validToken(TokenBean tokenBean) {
|
||||
if (tokenBean == null || StrUtil.isEmpty(tokenBean.getId())) {
|
||||
throw new ApiException("请先登录");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版ID
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getImexId() {
|
||||
return StrUtil.format("{}_{}", getAction(), getSort());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.tiesheng.web.service.imex;
|
||||
|
||||
import com.tiesheng.util.pojos.TokenBean;
|
||||
import com.tiesheng.web.pojos.imex.ImportDealDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TsImportHandler<T> extends TsImexBase<T> {
|
||||
|
||||
|
||||
/**
|
||||
* 读取文件内容
|
||||
*
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
List<T> ready(ImportDealDTO dto, TokenBean token);
|
||||
|
||||
|
||||
/**
|
||||
* 获取模版地址
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getTemplateUrl();
|
||||
|
||||
}
|
||||
@@ -6,13 +6,12 @@ public interface ProcessImportConsumer<T> {
|
||||
|
||||
|
||||
/**
|
||||
* 处理数据
|
||||
* 分批处理
|
||||
*
|
||||
* @param list
|
||||
* @param <T>
|
||||
* @return 返回成功的数量
|
||||
*/
|
||||
int accept(List<T> list);
|
||||
int batchHandler(List<T> list);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -72,4 +72,7 @@ CREATE TABLE `core_log_operation`
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='日志-操作';
|
||||
|
||||
|
||||
alter table core_log_process
|
||||
modify params longtext null comment '异常说明';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
<result column="fail_file" jdbcType="VARCHAR" property="failFile" />
|
||||
<result column="error" jdbcType="LONGVARCHAR" property="error" />
|
||||
<result column="process" jdbcType="INTEGER" property="process" />
|
||||
<result column="params" jdbcType="LONGVARCHAR" property="params" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
|
||||
Reference in New Issue
Block a user