Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33d20c518e | ||
|
|
d0935cbda0 | ||
|
|
3ed9a47c66 | ||
|
|
3f6989d039 | ||
|
|
6f6e997fd3 | ||
|
|
d9987b41ea | ||
|
|
c33ad6075e | ||
|
|
a32c333a6c | ||
|
|
ed66f035e5 | ||
|
|
f5dd706e6e |
20
pom.xml
20
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>springboot-parent</name>
|
||||
<description>杭州铁晟科技有限公司基础依赖</description>
|
||||
@@ -57,55 +57,55 @@
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-database</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-login</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-util</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-message</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
BIN
springboot-ademo/.DS_Store
vendored
BIN
springboot-ademo/.DS_Store
vendored
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-ademo</artifactId>
|
||||
@@ -25,6 +25,12 @@
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package com.tiesheng.demo.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.sax.handler.RowHandler;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.tiesheng.annotation.token.TokenIgnore;
|
||||
import com.tiesheng.core.service.CoreMessageService;
|
||||
import com.tiesheng.demo.pojos.PoiBean;
|
||||
import com.tiesheng.demo.pojos.TestFile;
|
||||
import com.tiesheng.login.config.token.TsTokenConfig;
|
||||
import com.tiesheng.login.config.token.bean.TokenBean;
|
||||
@@ -19,6 +26,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -121,4 +129,43 @@ public class TestController {
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("poi")
|
||||
@TokenIgnore
|
||||
public ApiResp<String> poi() {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
|
||||
FileUploadPath file = FileUploadPath.file("/upload/test.xlsx");
|
||||
|
||||
EasyExcel.read(new File(file.getAbsolutePath()), PoiBean.class, new ReadListener<PoiBean>() {
|
||||
|
||||
@Override
|
||||
public void invoke(PoiBean poiBean, AnalysisContext analysisContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
|
||||
}
|
||||
}).sheet().doRead();
|
||||
|
||||
System.out.println("timeInterval: " + timeInterval.interval());
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
@RequestMapping("poiTool")
|
||||
@TokenIgnore
|
||||
public ApiResp<String> poiTool() {
|
||||
TimeInterval timeInterval = new TimeInterval();
|
||||
|
||||
FileUploadPath file = FileUploadPath.file("/upload/test.xlsx");
|
||||
|
||||
ExcelUtil.getReader(new File(file.getAbsolutePath())).read();
|
||||
|
||||
System.out.println("timeInterval: " + timeInterval.interval());
|
||||
|
||||
return ApiResp.respOK("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.tiesheng.demo.pojos;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
|
||||
public class PoiBean {
|
||||
|
||||
@ExcelProperty("学院")
|
||||
private String college;
|
||||
private String type;
|
||||
private String name;
|
||||
private String no;
|
||||
private String sex;
|
||||
private String fdy;
|
||||
private String fdyNo;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// setter\getter
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public String getCollege() {
|
||||
return college;
|
||||
}
|
||||
|
||||
public void setCollege(String college) {
|
||||
this.college = college;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNo() {
|
||||
return no;
|
||||
}
|
||||
|
||||
public void setNo(String no) {
|
||||
this.no = no;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getFdy() {
|
||||
return fdy;
|
||||
}
|
||||
|
||||
public void setFdy(String fdy) {
|
||||
this.fdy = fdy;
|
||||
}
|
||||
|
||||
public String getFdyNo() {
|
||||
return fdyNo;
|
||||
}
|
||||
|
||||
public void setFdyNo(String fdyNo) {
|
||||
this.fdyNo = fdyNo;
|
||||
}
|
||||
}
|
||||
@@ -7,31 +7,10 @@
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
|
||||
name="viewport"
|
||||
/>
|
||||
<title>钉钉授权</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="dingtalk.open.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) return decodeURI(r[2]);
|
||||
return null;
|
||||
}
|
||||
|
||||
dd.runtime.permission.requestAuthCode({
|
||||
corpId: getQueryString("corpId"),
|
||||
onSuccess: function (result) {
|
||||
let search = window.location.search + "&code=" + result.code;
|
||||
window.location.href = "/auth/ding/oauth2/" + getQueryString("service") + search;
|
||||
},
|
||||
onFail: function (err) {
|
||||
window.location.href = "./error.html?message=" + JSON.stringify(err);
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -7,30 +7,10 @@
|
||||
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
|
||||
name="viewport"
|
||||
/>
|
||||
<title>钉钉授权</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="dingtalk.open.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
function getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
if (r != null) return decodeURI(r[2]);
|
||||
return null;
|
||||
}
|
||||
|
||||
dd.runtime.permission.requestAuthCode({
|
||||
corpId: getQueryString("corpId"),
|
||||
onSuccess: function (result) {
|
||||
let search = window.location.search + "&code=" + result.code;
|
||||
window.location.href = "/auth/ding/oauth2/" + getQueryString("service") + search;
|
||||
},
|
||||
onFail: function (err) {
|
||||
window.location.href = "./error.html?message=" + JSON.stringify(err);
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-annotation</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-database</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-encrypt</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-login</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-message</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-platform</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-poi</artifactId>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-util</artifactId>
|
||||
|
||||
@@ -5,6 +5,7 @@ import cn.hutool.core.comparator.VersionComparator;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.log.LogFactory;
|
||||
import com.tiesheng.util.exception.ApiException;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -13,6 +14,7 @@ import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -71,12 +73,24 @@ public class GlobalConfig {
|
||||
}
|
||||
PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
|
||||
try {
|
||||
Resource[] resources = patternResolver.getResources(String.format("classpath*:static/%s*/index.html", htmlDir));
|
||||
List<String> versions = new ArrayList<>();
|
||||
|
||||
// jar包中的资源
|
||||
Resource[] resources = patternResolver.getResources(String.format("classpath*:static/%s*/index.html", htmlDir));
|
||||
for (Resource resource : resources) {
|
||||
String path = FileUtil.normalize(resource.getURL().getPath());
|
||||
versions.add(StrUtil.subBetween(path, htmlDir, "/index.html"));
|
||||
}
|
||||
|
||||
// 目录中的资源
|
||||
String folder = String.format("%s/static/%s", System.getProperty("user.dir"), htmlDir);
|
||||
if (FileUtil.exist(folder)) {
|
||||
File[] files = FileUtil.ls(folder);
|
||||
for (File file : files) {
|
||||
versions.add(StrUtil.subAfter(file.getAbsolutePath(), htmlDir, true));
|
||||
}
|
||||
}
|
||||
|
||||
if (CollUtil.isEmpty(versions)) {
|
||||
throw new ApiException("无法重定向,请检查资源");
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>com.tiesheng.springboot-parent</groupId>
|
||||
<artifactId>springboot-parent</artifactId>
|
||||
<version>0.9.9</version>
|
||||
<version>0.9.14</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>springboot-web</artifactId>
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.tiesheng.core.pojos.DaoBase;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -37,12 +36,6 @@ public class CoreLogProcess extends DaoBase {
|
||||
@TableField(value = "fail_num")
|
||||
private Integer failNum;
|
||||
|
||||
/**
|
||||
* 失败的文件
|
||||
*/
|
||||
@TableField(value = "fail_file")
|
||||
private String failFile;
|
||||
|
||||
/**
|
||||
* 类型(import-导入,sync-同步)
|
||||
*/
|
||||
@@ -50,11 +43,29 @@ public class CoreLogProcess extends DaoBase {
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 状态(0-未完成,1-完成)
|
||||
* 状态(0-未完成,1-已完成)
|
||||
*/
|
||||
@TableField(value = "`status`")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 失败的文件
|
||||
*/
|
||||
@TableField(value = "fail_file")
|
||||
private String failFile;
|
||||
|
||||
/**
|
||||
* 异常说明
|
||||
*/
|
||||
@TableField(value = "error")
|
||||
private String error;
|
||||
|
||||
/**
|
||||
* 进度
|
||||
*/
|
||||
@TableField(value = "`process`")
|
||||
private Integer process;
|
||||
|
||||
/**
|
||||
* 获取标题
|
||||
*
|
||||
@@ -127,14 +138,6 @@ public class CoreLogProcess extends DaoBase {
|
||||
this.failNum = failNum;
|
||||
}
|
||||
|
||||
public String getFailFile() {
|
||||
return failFile;
|
||||
}
|
||||
|
||||
public void setFailFile(String failFile) {
|
||||
this.failFile = failFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型(import-导入,sync-同步)
|
||||
*
|
||||
@@ -154,20 +157,74 @@ public class CoreLogProcess extends DaoBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态(0-未完成,1-完成)
|
||||
* 获取状态(0-未完成,1-已完成)
|
||||
*
|
||||
* @return status - 状态(0-未完成,1-完成)
|
||||
* @return status - 状态(0-未完成,1-已完成)
|
||||
*/
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置状态(0-未完成,1-完成)
|
||||
* 设置状态(0-未完成,1-已完成)
|
||||
*
|
||||
* @param status 状态(0-未完成,1-完成)
|
||||
* @param status 状态(0-未完成,1-已完成)
|
||||
*/
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取失败的文件
|
||||
*
|
||||
* @return fail_file - 失败的文件
|
||||
*/
|
||||
public String getFailFile() {
|
||||
return failFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置失败的文件
|
||||
*
|
||||
* @param failFile 失败的文件
|
||||
*/
|
||||
public void setFailFile(String failFile) {
|
||||
this.failFile = failFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取异常说明
|
||||
*
|
||||
* @return error - 异常说明
|
||||
*/
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置异常说明
|
||||
*
|
||||
* @param error 异常说明
|
||||
*/
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取进度
|
||||
*
|
||||
* @return process - 进度
|
||||
*/
|
||||
public Integer getProcess() {
|
||||
return process;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度
|
||||
*
|
||||
* @param process 进度
|
||||
*/
|
||||
public void setProcess(Integer process) {
|
||||
this.process = process;
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,16 @@ public class ProcessDetailVo {
|
||||
|
||||
private Integer failNum;
|
||||
|
||||
private Integer process;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String failFile;
|
||||
|
||||
private String error;
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
@@ -74,4 +78,20 @@ public class ProcessDetailVo {
|
||||
public void setFailFile(String failFile) {
|
||||
this.failFile = failFile;
|
||||
}
|
||||
|
||||
public Integer getProcess() {
|
||||
return process;
|
||||
}
|
||||
|
||||
public void setProcess(Integer process) {
|
||||
this.process = process;
|
||||
}
|
||||
|
||||
public String getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(String error) {
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
* @param title 标题
|
||||
* @param list 要导入的数据
|
||||
*/
|
||||
public <T> CoreLogProcess addProcess(String title, List<T> list, ProcessImportConsumer consumer) {
|
||||
public <T> CoreLogProcess addProcess(String title, List<T> list, ProcessImportConsumer<T> consumer) {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
throw new ApiException("文件中不存在数据");
|
||||
}
|
||||
@@ -79,21 +79,28 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
coreLogProcess.setType("import");
|
||||
coreLogProcess.setSuccessNum(0);
|
||||
coreLogProcess.setFailNum(0);
|
||||
coreLogProcess.setProcess(0);
|
||||
coreLogProcess.setError("");
|
||||
coreLogProcessMapper.insert(coreLogProcess);
|
||||
|
||||
ThreadUtil.execute(() -> {
|
||||
CollUtil.split(list, 100).forEach((it) -> {
|
||||
int accept = consumer.accept(it);
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
||||
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + 100 - accept);
|
||||
|
||||
if (coreLogProcess.getFailNum() + coreLogProcess.getSuccessNum() == list.size()) {
|
||||
coreLogProcess.setFailFile(consumer.getFailFile());
|
||||
coreLogProcess.setStatus(1);
|
||||
int accept = 0;
|
||||
try {
|
||||
accept = consumer.accept(it);
|
||||
} catch (Exception e) {
|
||||
coreLogProcess.setError(coreLogProcess.getError() + ";" + JSONUtil.toJsonStr(e));
|
||||
}
|
||||
|
||||
coreLogProcess.setProcess(coreLogProcess.getProcess() + it.size());
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + accept);
|
||||
coreLogProcess.setFailNum(coreLogProcess.getFailNum() + it.size() - accept);
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
// 执行结束
|
||||
coreLogProcess.setFailFile(consumer.getFailFile());
|
||||
coreLogProcess.setStatus(1);
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
|
||||
@@ -111,24 +118,34 @@ public class CoreLogService extends TsServiceBase<CoreLogOperationMapper, CoreLo
|
||||
public CoreLogProcess addProcess(String title, ProcessSyncConsumer consumer) {
|
||||
CoreLogProcess coreLogProcess = new CoreLogProcess();
|
||||
coreLogProcess.setTitle(title);
|
||||
coreLogProcess.setTotal(0);
|
||||
|
||||
coreLogProcess.setType("sync");
|
||||
coreLogProcess.setSuccessNum(0);
|
||||
coreLogProcess.setFailNum(0);
|
||||
coreLogProcess.setTotal(0);
|
||||
coreLogProcess.setProcess(0);
|
||||
coreLogProcess.setError("");
|
||||
coreLogProcessMapper.insert(coreLogProcess);
|
||||
|
||||
ThreadUtil.execute(() -> {
|
||||
int pageSize = 1000;
|
||||
int pageNum = 1, lastCount = pageSize;
|
||||
while (lastCount == pageSize) {
|
||||
lastCount = consumer.accept(pageNum, pageSize);
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
||||
if (lastCount != pageSize) {
|
||||
coreLogProcess.setStatus(1);
|
||||
try {
|
||||
lastCount = consumer.accept(pageNum, pageSize);
|
||||
coreLogProcess.setTotal(coreLogProcess.getTotal() + lastCount);
|
||||
coreLogProcess.setProcess(coreLogProcess.getTotal());
|
||||
coreLogProcess.setSuccessNum(coreLogProcess.getSuccessNum() + lastCount);
|
||||
} catch (Exception e) {
|
||||
coreLogProcess.setError(coreLogProcess.getError() + ";" + JSONUtil.toJsonStr(e));
|
||||
}
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
// 执行结束
|
||||
coreLogProcess.setStatus(1);
|
||||
coreLogProcessMapper.updateById(coreLogProcess);
|
||||
});
|
||||
|
||||
return coreLogProcess;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.tiesheng.core.util;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ProcessImportConsumer {
|
||||
public interface ProcessImportConsumer<T> {
|
||||
|
||||
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ public interface ProcessImportConsumer {
|
||||
* @param <T>
|
||||
* @return 返回成功的数量
|
||||
*/
|
||||
<T> int accept(List<T> list);
|
||||
int accept(List<T> list);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,12 @@ ALTER TABLE core_log_process
|
||||
ALTER TABLE core_log_process
|
||||
ADD fail_file varchar(500) null default null COMMENT '失败的文件';
|
||||
|
||||
ALTER TABLE core_log_process
|
||||
ADD error text null default null COMMENT '异常说明';
|
||||
|
||||
ALTER TABLE core_log_process
|
||||
ADD process int(6) not null default 0 COMMENT '进度';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for core_log_operation
|
||||
-- ----------------------------
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
<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" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
|
||||
`status`, fail_file
|
||||
id, create_time, update_time, is_deleted, title, total, success_num, fail_num, `type`,
|
||||
`status`, fail_file, error, `process`
|
||||
</sql>
|
||||
</mapper>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user