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

实体关系属性映射(batch)

上级 2631d585
......@@ -295,6 +295,10 @@ ${deaction.getRender().code}
<#else>
this.saveBatch(list,batchSize);
</#if>
<#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping>
updateParentDataBatch(list);
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "update">
......@@ -356,6 +360,10 @@ ${deaction.getRender().code}
list.forEach(item->fillParentData(item));
</#if>
updateBatchById(list,batchSize);
<#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping>
updateParentDataBatch(list);
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "save">
......@@ -434,7 +442,14 @@ ${deaction.getRender().code}
@Override
public void removeBatch(Collection<${srfjavatype(keyfield.stdDataType)}> idList) {
<#if hasPSDERsMapping>
List<${item.getCodeName()}> entities= baseMapper.selectBatchIds(idList);
</#if>
removeByIds(idList);
<#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping>
updateParentDataBatch(entities);
</#if>
}
<#elseif deaction.getCodeName()?lower_case == "getdraft">
......@@ -663,7 +678,6 @@ ${deaction.getRender().code}
<#assign MajorEntityName=srfcaseformat(MinorPSDER.getCodeName(),'l_u2lC')>
<#assign MajorKeyFieldName =MinorPSDER.getPSPickupDEField().name?lower_case>
<#assign MajorKeyFieldCodeName =srfcaseformat(MinorPSDER.getPSPickupDEField().codeName,'l_u2lC')?cap_first>
<#assign MajorEntityService=srfcaseformat(MinorPSDER.getMajorPSDataEntity().getCodeName(),'l_u2lC')+"Service">
//实体关系[${MinorPSDER.name}]
if(!ObjectUtils.isEmpty(et.get${MajorKeyFieldCodeName}())){
<#if MinorPSDER.getPSDER1NDEFieldMaps?? && MinorPSDER.getPSDER1NDEFieldMaps()??>
......@@ -693,7 +707,7 @@ ${deaction.getRender().code}
</#if>
</#if>
</#list>
${MajorEntityName}.set("${MajorKeyFieldCodeName}",et.get${MajorKeyFieldCodeName}());
${MajorEntityName}.set("${MajorKeyFieldCodeName?lower_case}",et.get${MajorKeyFieldCodeName}());
${srfcaseformat(MinorPSDER.getMajorPSDataEntity().getCodeName(),'l_u2lC')}Service.update(${MajorEntityName});
</#if>
}
......@@ -703,6 +717,35 @@ ${deaction.getRender().code}
}
</#if>
<#comment>批量更新父数据(实体关系属性映射)</#comment>
<#if hasPSDERsMapping>
/**
* 批量更新父数据(实体关系属性映射)
* @param et
*/
private void updateParentDataBatch(List <${item.getCodeName()}> entities){
<#list item.getMinorPSDERs() as MinorPSDER>
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N' && (MinorPSDER.getMajorPSDataEntity().getStorageMode()==1||MinorPSDER.getMajorPSDataEntity().getStorageMode()==2||MinorPSDER.getMajorPSDataEntity().getStorageMode()==4)>
<#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()?? && MinorPSDER.getCodeName?? && MinorPSDER.getCodeName()??>
<#assign MajorKeyFieldCodeName =srfcaseformat(MinorPSDER.getPSPickupDEField().codeName,'l_u2lC')?cap_first>
if(entities.size>0){
for(${item.getCodeName()} entity: entities){
//实体关系[${MinorPSDER.name}]
if(!ObjectUtils.isEmpty(entity.get${MajorKeyFieldCodeName}()) && !map.containsKey(entity.get${MajorKeyFieldCodeName}())){
map.put(entity.get${MajorKeyFieldCodeName}(),entity);
}
}
if(map.size()>0){
Collection<${item.getCodeName()}> collections= map.values();
collections.forEach(collection -> updateParentData(collection));
}
}
</#if>
</#if>
</#list>
}
</#if>
<#comment>同步数据到索引主实体</#comment>
<#if isIndexSubDE && indexPSDER??>
@Autowired
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册