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

实体数据导入

上级 fdd3455d
...@@ -12,7 +12,7 @@ public interface ${de.codeName}${item.codeName} { ...@@ -12,7 +12,7 @@ public interface ${de.codeName}${item.codeName} {
<#if item.getPSDEDataImportItems?? && item.getPSDEDataImportItems()??> <#if item.getPSDEDataImportItems?? && item.getPSDEDataImportItems()??>
@Mappings({ @Mappings({
<#list de.getPSDEDataImportItems as importItem> <#list item.getPSDEDataImportItems as importItem>
<#if importItem.getPSDEField()??> <#if importItem.getPSDEField()??>
<#assign deFieldName = srfcaseformat(importItem.getPSDEField().getCodeName(),'l_u2lC') > <#assign deFieldName = srfcaseformat(importItem.getPSDEField().getCodeName(),'l_u2lC') >
@Mapping(target = "${deFieldName}",source = "${deFieldName}"), @Mapping(target = "${deFieldName}",source = "${deFieldName}"),
......
...@@ -96,6 +96,7 @@ import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?low ...@@ -96,6 +96,7 @@ import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?low
import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service.I${de.getCodeName()}Service; import ${pub.getPKGCodeName()}.core.${item.getPSSystemModule().getCodeName()?lower_case}.service.I${de.getCodeName()}Service;
import ${pub.getPKGCodeName()}.util.helper.CachedBeanCopier; import ${pub.getPKGCodeName()}.util.helper.CachedBeanCopier;
import ${pub.getPKGCodeName()}.util.helper.DEFieldCacheMap;
<#comment>SQL存储-Mybatis</#comment> <#comment>SQL存储-Mybatis</#comment>
<#if de.getStorageMode()==1> <#if de.getStorageMode()==1>
...@@ -2443,7 +2444,7 @@ ${deaction.getRender().code} ...@@ -2443,7 +2444,7 @@ ${deaction.getRender().code}
/** /**
* 上传数据检查 * 上传数据检查
* @param entities * @param entities
* @param mode * @param isIgnoreError
* @return * @return
*/ */
private JSONObject testImportData(List<${de.codeName}> entities,boolean isIgnoreError) { private JSONObject testImportData(List<${de.codeName}> entities,boolean isIgnoreError) {
...@@ -2463,7 +2464,7 @@ ${deaction.getRender().code} ...@@ -2463,7 +2464,7 @@ ${deaction.getRender().code}
} }
//主键重复性判断.外键约束判断(上传数据自身的检查/数据库的检查) //主键重复性判断.外键约束判断(上传数据自身的检查/数据库的检查)
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);
Object id = entity.get(keyField); Object id = entity.get(keyField);
if(ObjectUtils.isEmpty(id)) { if(ObjectUtils.isEmpty(id)) {
id = entity.getDefaultKey(true); id = entity.getDefaultKey(true);
...@@ -2490,17 +2491,18 @@ ${deaction.getRender().code} ...@@ -2490,17 +2491,18 @@ ${deaction.getRender().code}
<#if MinorPSDER?? && MinorPSDER.getDERType()=='DER1N' && (MinorPSDER.getMajorPSDataEntity().getStorageMode()==1||MinorPSDER.getMajorPSDataEntity().getStorageMode()==2||MinorPSDER.getMajorPSDataEntity().getStorageMode()==4)> <#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()??> <#if MinorPSDER.getMajorPSDataEntity?? && MinorPSDER.getMajorPSDataEntity()?? && MinorPSDER.getCodeName?? && MinorPSDER.getCodeName()??>
<#assign MajorKeyFieldCodeName =srfcaseformat(MinorPSDER.getPSPickupDEField().codeName,'l_u2lC')?cap_first> <#assign MajorKeyFieldCodeName =srfcaseformat(MinorPSDER.getPSPickupDEField().codeName,'l_u2lC')?cap_first>
<#assign MajorEntity=MinorPSDER.getMajorPSDataEntity()>
<#assign MajorEntityCodeName=MinorPSDER.getMajorPSDataEntity().codeName> <#assign MajorEntityCodeName=MinorPSDER.getMajorPSDataEntity().codeName>
<#assign MajorEntityService=srfcaseformat(MinorPSDER.getMajorPSDataEntity().getCodeName(),'l_u2lC')+"Service"> <#assign MajorEntityService=srfcaseformat(MinorPSDER.getMajorPSDataEntity().getCodeName(),'l_u2lC')+"Service">
//实体关系[${MinorPSDER.name}] //实体关系[${MinorPSDER.name}]
if(!ObjectUtils.isEmpty(et.get${MajorKeyFieldCodeName}())){ if(!ObjectUtils.isEmpty(entity.get${MajorKeyFieldCodeName}())){
${MajorEntityCodeName} fkEntity=${MajorEntityService}.getById(et.get${MajorKeyFieldCodeName}()); ${pub.getPKGCodeName()}.core.${MajorEntity.getPSSystemModule().getCodeName()?lower_case}.domain.${MajorEntityCodeName} fkEntity=${MajorEntityService}.getById(entity.get${MajorKeyFieldCodeName}());
if(ObjectUtils.isEmpty(fkEntity)){ if(ObjectUtils.isEmpty(fkEntity)){
Integer lineNum = i + 1; Integer lineNum = i + 1;
errorLines.add(lineNum); errorLines.add(lineNum);
errorMsgs.add(String.format("第" + lineNum + "行:[%s]父数据有误。",et.get${MajorKeyFieldCodeName}())); errorMsgs.add(String.format("第" + lineNum + "行:[%s]父数据有误。",entity.get${MajorKeyFieldCodeName}()));
if(isIgnoreError){ if(isIgnoreError){
et.set${MajorKeyFieldCodeName}(null); entity.set${MajorKeyFieldCodeName}(null);
continue; continue;
} }
else{ else{
...@@ -2532,7 +2534,7 @@ ${deaction.getRender().code} ...@@ -2532,7 +2534,7 @@ ${deaction.getRender().code}
* 实体数据导入 * 实体数据导入
* @param entities * @param entities
* @param batchSize * @param batchSize
* @param mode * @param isIgnoreError
* @return * @return
*/ */
@Override @Override
......
...@@ -645,7 +645,7 @@ public class ${itemCodeName}Resource { ...@@ -645,7 +645,7 @@ public class ${itemCodeName}Resource {
} }
<#else> <#else>
else if(config.equals("${deImport.codeName}")){ else if(config.equals("${deImport.codeName}")){
rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()},${deImport.isIgnoreError()?c}); rs=${deCodeNameLC}Service.importData(${deImport.codeName?lower_case}ImpMapping.toDomain(dtos),${deImport.getBatchSize()?c},${deImport.isIgnoreError()?c});
} }
</#if> </#if>
</#list> </#list>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册