提交 7de1b0dd 编写于 作者: zhouweidong's avatar zhouweidong

补充批处理调用处理逻辑

上级 09cf5c0f
...@@ -70,6 +70,25 @@ TARGET=PSDATAENTITY ...@@ -70,6 +70,25 @@ TARGET=PSDATAENTITY
<#if item.getDynaInstMode()?? && (item.getDynaInstMode()?c=='1' || item.getDynaInstMode()?c=='2' )> <#if item.getDynaInstMode()?? && (item.getDynaInstMode()?c=='1' || item.getDynaInstMode()?c=='2' )>
<#assign isDynaSys =true> <#assign isDynaSys =true>
</#if> </#if>
<#comment>create.update.remove是否存在附加逻辑</#comment>
<#assign hasCreateLogic = false>
<#assign hasUpdateLogic = false>
<#assign hasDeleteLogic = false>
<#comment>判断行为是否存在有附加逻辑</#comment>
<#if de.getAllPSDEActions()??>
<#list de.getAllPSDEActions() as deAction>
<#if deAction.getCodeName()?lower_case == 'create' && deAction.getPSDEActionLogics()??>
<#assign hasCreateLogic = true>
<#elseif deAction.getCodeName()?lower_case == 'update' && deAction.getPSDEActionLogics()??>
<#assign hasUpdateLogic = true>
<#elseif deAction.getCodeName()?lower_case == 'remove' && deAction.getPSDEActionLogics()??>
<#assign hasDeleteLogic = true>
</#if>
</#list>
</#if>
<#assign isDupCheck=isDupCheckEntity(de)> <#assign isDupCheck=isDupCheckEntity(de)>
<#assign keyfield=de.getKeyPSDEField()> <#assign keyfield=de.getKeyPSDEField()>
<#assign keyfieldPrivateCodeName = srfcaseformat(keyfield.getCodeName(),'l_u2lC') > <#assign keyfieldPrivateCodeName = srfcaseformat(keyfield.getCodeName(),'l_u2lC') >
...@@ -340,11 +359,22 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -340,11 +359,22 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if hasMinorPSDERs gt 0> <#if hasMinorPSDERs gt 0>
list.forEach(item->fillParentData(item)); list.forEach(item->fillParentData(item));
</#if> </#if>
<#comment>联合主键,走SaveOrUpdateBatch,防止因主键冲突导致后续数据无法保存</#comment> <#comment>存在附加逻辑时,则for循环调用单行为,以实现批处理时触发处理逻辑</#comment>
<#if item.getUnionKeyValuePSDEFields()??> <#if hasCreateLogic>
this.saveOrUpdateBatch(list,batchSize); for (${item.getCodeName()} et : list) {
<#if item.getUnionKeyValuePSDEFields()??>
getProxyService().saveOrUpdate(et);
<#else>
getProxyService().save(et);
}
</#if>
<#else> <#else>
<#comment>联合主键,走SaveOrUpdateBatch,防止因主键冲突导致后续数据无法保存</#comment>
<#if item.getUnionKeyValuePSDEFields()??>
this.saveOrUpdateBatch(list,batchSize);
<#else>
this.saveBatch(list, batchSize); this.saveBatch(list, batchSize);
</#if>
</#if> </#if>
<#comment>批量更新父数据(实体关系属性映射)</#comment> <#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
...@@ -423,7 +453,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -423,7 +453,14 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#if hasMinorPSDERs gt 0> <#if hasMinorPSDERs gt 0>
list.forEach(item->fillParentData(item)); list.forEach(item->fillParentData(item));
</#if> </#if>
<#comment>存在附加逻辑时,则for循环调用单行为,以实现批处理时触发处理逻辑</#comment>
<#if hasUpdateLogic>
for (${item.getCodeName()} et : list) {
getProxyService().update(et);
}
<#else>
updateBatchById(list, batchSize); updateBatchById(list, batchSize);
</#if>
<#comment>批量更新父数据(实体关系属性映射)</#comment> <#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
updateParentDataBatch(list); updateParentDataBatch(list);
...@@ -523,11 +560,18 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa ...@@ -523,11 +560,18 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#comment>输出测试行为</#comment> <#comment>输出测试行为</#comment>
<@outputTestAction deaction "removeBatch"/> <@outputTestAction deaction "removeBatch"/>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
List<${item.getCodeName()}> entities= baseMapper.selectBatchIds(idList); List<${item.getCodeName()}> entities = baseMapper.selectBatchIds(idList);
</#if> </#if>
<#comment>主实体删除操作(同时删除、置空、限制删除)</#comment> <#comment>主实体删除操作(同时删除、置空、限制删除)</#comment>
<@majorEntityRemoveBatch/> <@majorEntityRemoveBatch/>
<#comment>存在附加逻辑时,则for循环调用单行为,以实现批处理时触发处理逻辑</#comment>
<#if hasDeleteLogic>
for (${srfr7javatype(keyfield.stdDataType)} id : idList) {
getProxyService().removeById(id);
}
<#else>
removeByIds(idList); removeByIds(idList);
</#if>
<#comment>批量更新父数据(实体关系属性映射)</#comment> <#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping> <#if hasPSDERsMapping>
updateParentDataBatch(entities); updateParentDataBatch(entities);
...@@ -1223,10 +1267,21 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1223,10 +1267,21 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
public void createBatch(List<${item.getCodeName()}> list) { public void createBatch(List<${item.getCodeName()}> list) {
<@outputTestAction deaction "createBatch"/> <@outputTestAction deaction "createBatch"/>
<#comment>联合主键,走SaveOrUpdateBatch,防止因主键冲突导致后续数据无法保存</#comment> <#comment>联合主键,走SaveOrUpdateBatch,防止因主键冲突导致后续数据无法保存</#comment>
<#if item.getUnionKeyValuePSDEFields()??> <#if hasCreateLogic>
<#if item.getUnionKeyValuePSDEFields()??>
repository.saveAll(list); repository.saveAll(list);
<#else>
for (${item.getCodeName()} et : list) {
getProxyService().create(et);
}
</#if>
<#else> <#else>
<#comment>联合主键,走SaveOrUpdateBatch,防止因主键冲突导致后续数据无法保存</#comment>
<#if item.getUnionKeyValuePSDEFields()??>
repository.saveAll(list);
<#else>
repository.insert(list); repository.insert(list);
</#if>
</#if> </#if>
} }
...@@ -1276,7 +1331,13 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1276,7 +1331,13 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
@Override @Override
public void updateBatch(List<${item.getCodeName()}> list) { public void updateBatch(List<${item.getCodeName()}> list) {
<@outputTestAction deaction "updateBatch"/> <@outputTestAction deaction "updateBatch"/>
<#if hasUpdateLogic>
for (${item.getCodeName()} et : list) {
getProxyService().update(et);
}
<#else>
repository.saveAll(list); repository.saveAll(list);
</#if>
} }
<#elseif deaction.getCodeName()?lower_case == "save"> <#elseif deaction.getCodeName()?lower_case == "save">
...@@ -1355,7 +1416,13 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1355,7 +1416,13 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
@Override @Override
public void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList) { public void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList) {
<@outputTestAction deaction "removeBatch"/> <@outputTestAction deaction "removeBatch"/>
<#if hasDeleteLogic>
for (${srfr7javatype(keyfield.stdDataType)} id : idList) {
getProxyService().remove(id);
}
<#else>
repository.deleteAll(repository.findAllById(idList)); repository.deleteAll(repository.findAllById(idList));
</#if>
} }
<#elseif deaction.getCodeName()?lower_case == "getdraft"> <#elseif deaction.getCodeName()?lower_case == "getdraft">
...@@ -1539,6 +1606,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1539,6 +1606,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<@outputSearchContext/> <@outputSearchContext/>
<#comment>动态行为</#comment> <#comment>动态行为</#comment>
<@dynamicCall/> <@dynamicCall/>
<#comment>引入proxyservice</#comment>
<#if hasCreateLogic || hasUpdateLogic || hasDeleteLogic>
<@autowiredProxyService/>
</#if>
} }
...@@ -1715,9 +1786,15 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1715,9 +1786,15 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
public void createBatch(List<${item.codeName}> list){ public void createBatch(List<${item.codeName}> list){
<@outputTestAction deaction "createBatch"/> <@outputTestAction deaction "createBatch"/>
<#if item.isEnableAPIStorage()> <#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? > <#if deaction.getPSSubSysServiceAPIDEMethod()?? >
<#if hasCreateLogic>
for (${item.getCodeName()} et : list) {
getProxyService().create(et);
}
<#else>
${subSysServiceApiDECodeName?uncap_first}FeignClient.createBatch(list) ; ${subSysServiceApiDECodeName?uncap_first}FeignClient.createBatch(list) ;
</#if> </#if>
</#if>
</#if> </#if>
} }
...@@ -1773,9 +1850,15 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1773,9 +1850,15 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
public void updateBatch(List<${item.codeName}> list){ public void updateBatch(List<${item.codeName}> list){
<@outputTestAction deaction "updateBatch"/> <@outputTestAction deaction "updateBatch"/>
<#if item.isEnableAPIStorage()> <#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? > <#if deaction.getPSSubSysServiceAPIDEMethod()?? >
<#if hasUpdateLogic>
for (${item.getCodeName()} et : list) {
getProxyService().update(et);
}
<#else>
${subSysServiceApiDECodeName?uncap_first}FeignClient.updateBatch(list) ; ${subSysServiceApiDECodeName?uncap_first}FeignClient.updateBatch(list) ;
</#if> </#if>
</#if>
</#if> </#if>
} }
...@@ -1884,7 +1967,13 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -1884,7 +1967,13 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<@outputTestAction deaction "removeBatch"/> <@outputTestAction deaction "removeBatch"/>
<#if item.isEnableAPIStorage()> <#if item.isEnableAPIStorage()>
<#if deaction.getPSSubSysServiceAPIDEMethod()?? > <#if deaction.getPSSubSysServiceAPIDEMethod()?? >
<#if hasDeleteLogic>
for (${srfr7javatype(keyfield.stdDataType)} id : idList) {
getProxyService().remove(id);
}
<#else>
${subSysServiceApiDECodeName?uncap_first}FeignClient.removeBatch(idList); ${subSysServiceApiDECodeName?uncap_first}FeignClient.removeBatch(idList);
</#if>
</#if> </#if>
</#if> </#if>
} }
...@@ -2070,6 +2159,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2070,6 +2159,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<@dynamicCall/> <@dynamicCall/>
<#comment>发布es服务对象</#comment> <#comment>发布es服务对象</#comment>
<@esAnno/> <@esAnno/>
<#comment>引入proxyservice</#comment>
<#if hasCreateLogic || hasUpdateLogic || hasDeleteLogic>
<@autowiredProxyService/>
</#if>
} }
<#comment>无存储</#comment> <#comment>无存储</#comment>
...@@ -2187,7 +2280,12 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2187,7 +2280,12 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
} }
public void createBatch(List<${item.codeName}> list){ public void createBatch(List<${item.codeName}> list){
<@outputTestAction deaction "createBatch"/> <@outputTestAction deaction "createBatch"/>
<#if hasCreateLogic>
for (${item.getCodeName()} et : list) {
getProxyService().create(et);
}
</#if>
} }
<#elseif deaction.getCodeName()?lower_case == "update"> <#elseif deaction.getCodeName()?lower_case == "update">
...@@ -2203,7 +2301,12 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2203,7 +2301,12 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
} }
public void updateBatch(List<${item.codeName}> list){ public void updateBatch(List<${item.codeName}> list){
<@outputTestAction deaction "updateBatch"/> <@outputTestAction deaction "updateBatch"/>
<#if hasUpdateLogic>
for (${item.getCodeName()} et : list) {
getProxyService().update(et);
}
</#if>
} }
<#elseif deaction.getCodeName()?lower_case == "save"> <#elseif deaction.getCodeName()?lower_case == "save">
...@@ -2237,7 +2340,12 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2237,7 +2340,12 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
} }
public void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList){ public void removeBatch(Collection<${srfr7javatype(keyfield.stdDataType)}> idList){
<@outputTestAction deaction "removeBatch"/> <@outputTestAction deaction "removeBatch"/>
<#if hasDeleteLogic>
for (${srfr7javatype(keyfield.stdDataType)} id : idList) {
getProxyService().remove(id);
}
</#if>
} }
<#elseif deaction.getCodeName()?lower_case == "getdraft"> <#elseif deaction.getCodeName()?lower_case == "getdraft">
...@@ -2388,6 +2496,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2388,6 +2496,10 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<@dynamicCall/> <@dynamicCall/>
<#comment>发布es服务对象</#comment> <#comment>发布es服务对象</#comment>
<@esAnno/> <@esAnno/>
<#comment>引入proxyservice</#comment>
<#if hasCreateLogic || hasUpdateLogic || hasDeleteLogic>
<@autowiredProxyService/>
</#if>
} }
</#if> </#if>
...@@ -2910,10 +3022,22 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2910,10 +3022,22 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
if(rs.getInteger("rst")==1 && !isIgnoreError) { if(rs.getInteger("rst")==1 && !isIgnoreError) {
return rs; return rs;
} }
List<${de.codeName}> tempDEList=new ArrayList<>();
Set tempIds=new HashSet<>();
for(int i = 0;i < entities.size();i++) { for(int i = 0;i < entities.size();i++) {
${de.codeName} entity = entities.get(i); ${de.codeName} entity = entities.get(i);
getProxyService().save(entity); tempDEList.add(entity);
} Object id=entity.get${keyfieldPublicCodeName}();
if(!ObjectUtils.isEmpty(id)) {
tempIds.add(id);
}
if(tempDEList.size()>=batchSize || (tempDEList.size()<batchSize && i==entities.size()-1)){
commit(tempDEList,tempIds);
tempDEList.clear();
tempIds.clear();
}
}
rs.put("rst", 0); rs.put("rst", 0);
rs.put("data",entities); rs.put("data",entities);
return rs; return rs;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册