|
|
@ -125,12 +125,30 @@ public class IcExportTemplateServiceImpl extends BaseServiceImpl<IcExportTemplat |
|
|
|
tempEntity.setSort(sort); |
|
|
|
} |
|
|
|
|
|
|
|
//3.组装待保存和待返回数据对象
|
|
|
|
//3.递归遍历组装待保存和待返回数据对象【目前业务表单项是两层,此方法支持多层】
|
|
|
|
packageData(formDTO.getItemList(), "0", customerId, tempId, resultList, itemList); |
|
|
|
|
|
|
|
//4.执行数据保存
|
|
|
|
if (formDTO.getIsTemp()) { |
|
|
|
baseDao.insert(tempEntity); |
|
|
|
icExportTemplateConfigService.insertBatch(itemList); |
|
|
|
} |
|
|
|
//5.返回组装数据对象
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 递归处理可能存在的多层表单数据[目前业务上是两次] |
|
|
|
**/ |
|
|
|
private void packageData(List<IcExportItemListFormDTO> dataList, String pid, String customerId, String tempId, |
|
|
|
List<IcExportTemplateForExportResultDTO> resultList, List<IcExportTemplateConfigEntity> itemList) { |
|
|
|
int num = 0; |
|
|
|
for (IcExportItemListFormDTO dto : formDTO.getItemList()) { |
|
|
|
//1.遍历一级表单项
|
|
|
|
for (IcExportItemListFormDTO dto : dataList) { |
|
|
|
IcExportTemplateConfigEntity itemEntity = ConvertUtils.sourceToTarget(dto, IcExportTemplateConfigEntity.class); |
|
|
|
itemEntity.setId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
itemEntity.setPid("0"); |
|
|
|
itemEntity.setPid(pid); |
|
|
|
itemEntity.setCustomerId(customerId); |
|
|
|
itemEntity.setTempId(tempId); |
|
|
|
num += 1; |
|
|
@ -141,31 +159,11 @@ public class IcExportTemplateServiceImpl extends BaseServiceImpl<IcExportTemplat |
|
|
|
resultDTO.setPid(itemEntity.getPid()); |
|
|
|
resultDTO.setSort(itemEntity.getSort()); |
|
|
|
resultList.add(resultDTO); |
|
|
|
int subNum = 0; |
|
|
|
for (IcExportItemListFormDTO subDTO : dto.getChildren()) { |
|
|
|
IcExportTemplateConfigEntity subItem = ConvertUtils.sourceToTarget(subDTO, IcExportTemplateConfigEntity.class); |
|
|
|
subItem.setId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
subItem.setPid(itemEntity.getId()); |
|
|
|
subItem.setCustomerId(customerId); |
|
|
|
subItem.setTempId(tempId); |
|
|
|
subNum += 1; |
|
|
|
subItem.setSort(subNum); |
|
|
|
itemList.add(subItem); |
|
|
|
IcExportTemplateForExportResultDTO subResultDTO = ConvertUtils.sourceToTarget(subDTO, IcExportTemplateForExportResultDTO.class); |
|
|
|
subResultDTO.setId(subItem.getId()); |
|
|
|
subResultDTO.setPid(subItem.getPid()); |
|
|
|
subResultDTO.setSort(subItem.getSort()); |
|
|
|
resultList.add(subResultDTO); |
|
|
|
//2.递归遍历子集表单项
|
|
|
|
if (!CollectionUtils.isEmpty(dto.getChildren())) { |
|
|
|
packageData(dto.getChildren(), itemEntity.getId(), customerId, tempId, resultList, itemList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//4.执行数据保存
|
|
|
|
if (formDTO.getIsTemp()) { |
|
|
|
baseDao.insert(tempEntity); |
|
|
|
icExportTemplateConfigService.insertBatch(itemList); |
|
|
|
} |
|
|
|
//5.返回组装数据对象
|
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|