提交 0dd64b4d 编写于 作者: zhouweidong's avatar zhouweidong

支持异步数据导入

上级 c11c9da4
......@@ -205,6 +205,9 @@ public interface I${item.codeName}Service{
<#comment>实体数据导入</#comment>
<#if hasDEImport>
JSONObject importData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError);
@org.springframework.scheduling.annotation.Async
void asyncImportData(List<${de.codeName}> entities,int batchSize,boolean isIgnoreError);
</#if>
</#macro>
......
......@@ -2458,6 +2458,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#macro deImportData>
<#if hasDEImport>
<@autowiredProxyService/>
@Value("${r'${ibiz.syncImportLimit:1000}'}")
private int syncImportLimit;
/**
* 上传数据检查
* @param entities
......@@ -2556,6 +2560,32 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
@Override
@Transactional
public JSONObject importData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError) {
if(entities.size()>syncImportLimit){
proxyService.asyncImportData(entities,batchSize,isIgnoreError);
JSONObject rs=new JSONObject();
rs.put("rst", 0);
rs.put("msg",String.format("当前导入数据已超过同步导入数量上限[%s],系统正在进行异步导入,请稍后!",syncImportLimit));
rs.put("data",entities);
return rs;
}
else{
return syncImportData(entities,batchSize,isIgnoreError);
}
}
@Transactional
public void asyncImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError){
executeImportData(entities,batchSize,isIgnoreError);
}
@Transactional
public JSONObject syncImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError){
return executeImportData(entities,batchSize,isIgnoreError);
}
@Override
@Transactional
public JSONObject executeImportData(List<${de.codeName}> entities, int batchSize ,boolean isIgnoreError) {
JSONObject rs=testImportData(entities,isIgnoreError);
if(rs.getInteger("rst")==1 && !isIgnoreError)
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册