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

补充批处理调用处理逻辑

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