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

数据导入外键值检查

上级 3c85eee2
...@@ -2800,6 +2800,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -2800,6 +2800,8 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
else{ else{
break; break;
} }
<#comment>外键值校验</#comment>
<@checkForeignKey/>
} }
<#if de.getMajorPSDER1Ns?? && de.getMajorPSDER1Ns()??> <#if de.getMajorPSDER1Ns?? && de.getMajorPSDER1Ns()??>
<#list de.getMinorPSDERs() as MinorPSDER> <#list de.getMinorPSDERs() as MinorPSDER>
...@@ -3165,4 +3167,43 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser ...@@ -3165,4 +3167,43 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#if> </#if>
</#macro> </#macro>
<#comment>外键值文本转成外键</#comment>
<#macro checkForeignKey>
<#if sys.codeName='Sample'>
//填充外键值
<#list item.getMinorPSDERs() as minder>
<#if minder?? && minder.getDERType()=='DER1N'>
<#if minder.getMajorPSDataEntity?? && minder.getMajorPSDataEntity()?? && minder.getCodeName??>
<#assign MajorEntity = minder.getMajorPSDataEntity()>
<#if MajorEntity.getCodeName?? && minder.getCodeName()?? && minder.getPSPickupTextDEField??>
<#assign foreignkeyId = srfcaseformat(MajorEntity.getKeyPSDEField().getCodeName(),'l_u2lC')?cap_first>
<#assign foreignkeyField = MajorEntity.getMajorPSDEField()>
<#assign foreignkeyName = srfcaseformat(foreignkeyField.getCodeName(),'l_u2lC')?cap_first>
<#assign importTag="">
<#if foreignkeyField.getImportTag()??>
<#assign importTag=foreignkeyField.getImportTag()>
<#elseif foreignkeyField.getLogicName()??>
<#assign importTag=foreignkeyField.getLogicName()>
<#else>
<#assign importTag=foreignkeyField.getCodeName()>
</#if>
if(ObjectUtils.isEmpty(entity.get${foreignkeyId}()) && !ObjectUtils.isEmpty(entity.get${foreignkeyName}())){
QueryWrapper<${MajorEntity.getCodeName()}> ${minder.codeName?lower_case}Wrapper = new QueryWrapper<>();
${minder.codeName?lower_case}Wrapper.eq("${foreignkeyField.name?lower_case}",entity.get${foreignkeyName}());
${MajorEntity.getCodeName()} ${minder.codeName?lower_case}Entity = ${srfcaseformat(minder.getCodeName(),'l_u2lC')}Service.getOne(${minder.codeName?lower_case}Wrapper,false);
if(${minder.codeName?lower_case}Entity == null){
Integer lineNum = i + 1;
errorLines.add(lineNum);
errorMsgs.add("第" + lineNum + "行:未能找到[${importTag}:entity.get${foreignkeyName}()]对应的外键值。");
continue;
}else{
entity.set${foreignkeyId}(${minder.codeName?lower_case}Entity.get${foreignkeyId}());
}
}
</#if>
</#if>
</#if>
</#list>
</#if>
</#macro>
</#if> </#if>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册