|
@ -9,6 +9,7 @@ import com.storeroom.modules.dictionary.service.ArchivesDictionaryService; |
|
|
import com.storeroom.modules.dictionary.service.DynamicTableService; |
|
|
import com.storeroom.modules.dictionary.service.DynamicTableService; |
|
|
import com.storeroom.modules.dictionary.service.FieldService; |
|
|
import com.storeroom.modules.dictionary.service.FieldService; |
|
|
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; |
|
|
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO; |
|
|
|
|
|
import com.storeroom.utils.NanoIdUtils; |
|
|
import com.storeroom.utils.StringUtils; |
|
|
import com.storeroom.utils.StringUtils; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
|
|
@ -16,6 +17,7 @@ import lombok.RequiredArgsConstructor; |
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
import org.springframework.jdbc.datasource.DataSourceUtils; |
|
|
import org.springframework.jdbc.datasource.DataSourceUtils; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
import javax.sql.DataSource; |
|
@ -37,6 +39,7 @@ public class DynamicTableImpl implements DynamicTableService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void DynamicCreate(Integer type, String archiveTypeId, String tableName) { |
|
|
public void DynamicCreate(Integer type, String archiveTypeId, String tableName) { |
|
|
|
|
|
|
|
|
List<Integer> integerList = new ArrayList<>(); |
|
|
List<Integer> integerList = new ArrayList<>(); |
|
@ -76,37 +79,40 @@ public class DynamicTableImpl implements DynamicTableService { |
|
|
/** |
|
|
/** |
|
|
* 生成模版表 |
|
|
* 生成模版表 |
|
|
* |
|
|
* |
|
|
* @param categoryId |
|
|
|
|
|
* @param tableName |
|
|
|
|
|
|
|
|
* @param categoryId 查询门类id |
|
|
|
|
|
* @param tableName 表明 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public void DynamicTemplateTable(String categoryId, String tableName) { |
|
|
|
|
|
List<ArchivesDictionary> arcList = archivesDictionaryService.queryCategoryId(categoryId); |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void DynamicTemplateTable(String arcTypeId, String categoryId,Integer isType, String tableName) { |
|
|
|
|
|
List<ArchivesDictionary> arcList = archivesDictionaryService.queryCategoryIdAndIsType(categoryId,2); |
|
|
//#生成文件表名称 |
|
|
//#生成文件表名称 |
|
|
String fileTableName = "file_" + tableName; |
|
|
|
|
|
|
|
|
// String fileTableName = "file_" + tableName; |
|
|
List<FieldVO> fieldVOList = new ArrayList<>(); |
|
|
List<FieldVO> fieldVOList = new ArrayList<>(); |
|
|
arcList.forEach(item -> { |
|
|
arcList.forEach(item -> { |
|
|
FieldVO fieldVO = new FieldVO(); |
|
|
FieldVO fieldVO = new FieldVO(); |
|
|
Field field = fieldService.findByCNName(item.getFieldCnName()); |
|
|
|
|
|
|
|
|
Field field = fieldService.findByCNName(item.getFieldCnName(), item.getIsType()); |
|
|
|
|
|
//如果系统默认字段里面不为空就为复制数据 |
|
|
if (!ObjectUtil.isEmpty(field)) { |
|
|
if (!ObjectUtil.isEmpty(field)) { |
|
|
fieldVO.setId(field.getId()); |
|
|
fieldVO.setId(field.getId()); |
|
|
fieldVO.setIsSystem(field.getIsSystem()); |
|
|
fieldVO.setIsSystem(field.getIsSystem()); |
|
|
|
|
|
fieldVO.setDictionaryId(field.getDictionaryId()); |
|
|
} |
|
|
} |
|
|
fieldVO.setFieldName(item.getFieldName()); |
|
|
fieldVO.setFieldName(item.getFieldName()); |
|
|
fieldVO.setFieldCnName(item.getFieldCnName()); |
|
|
fieldVO.setFieldCnName(item.getFieldCnName()); |
|
|
fieldVO.setIsDefaultValue(item.getIsDefaultValue()); |
|
|
fieldVO.setIsDefaultValue(item.getIsDefaultValue()); |
|
|
fieldVO.setIsDataType(item.getIsDataType()); |
|
|
fieldVO.setIsDataType(item.getIsDataType()); |
|
|
fieldVO.setIsDataTypeDetails(item.getIsDataTypeDetails()); |
|
|
fieldVO.setIsDataTypeDetails(item.getIsDataTypeDetails()); |
|
|
fieldVO.setIsDefaultValue(item.getIsDefaultValue()); |
|
|
|
|
|
fieldVO.setIsColumnLength(item.getIsColumnLength()); |
|
|
fieldVO.setIsColumnLength(item.getIsColumnLength()); |
|
|
fieldVO.setIsSequence(item.getIsSequence()); |
|
|
fieldVO.setIsSequence(item.getIsSequence()); |
|
|
fieldVO.setIsType(item.getIsType()); |
|
|
fieldVO.setIsType(item.getIsType()); |
|
|
|
|
|
fieldVO.setCategoryId(arcTypeId); |
|
|
|
|
|
|
|
|
fieldVOList.add(fieldVO); |
|
|
fieldVOList.add(fieldVO); |
|
|
}); |
|
|
}); |
|
|
DynamicInsert(fieldVOList, categoryId); |
|
|
|
|
|
DynamicCreateFileTable(fieldVOList, categoryId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DynamicInsert(fieldVOList, arcTypeId); |
|
|
|
|
|
DynamicCreateFileTable(fieldVOList, tableName); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -163,7 +169,6 @@ public class DynamicTableImpl implements DynamicTableService { |
|
|
* @param list |
|
|
* @param list |
|
|
* @param archiveTypeId |
|
|
* @param archiveTypeId |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
private void DynamicInsert(List<FieldVO> list, String archiveTypeId) { |
|
|
private void DynamicInsert(List<FieldVO> list, String archiveTypeId) { |
|
|
List<ArchivesDictionaryDTO> newList = new ArrayList<>(); |
|
|
List<ArchivesDictionaryDTO> newList = new ArrayList<>(); |
|
|
for (FieldVO j : list) { |
|
|
for (FieldVO j : list) { |
|
@ -190,6 +195,7 @@ public class DynamicTableImpl implements DynamicTableService { |
|
|
archivesDictionaryService.saveAll(newList); |
|
|
archivesDictionaryService.saveAll(newList); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void DynamicCreateFileTable(List<FieldVO> list, String tableName) { |
|
|
private void DynamicCreateFileTable(List<FieldVO> list, String tableName) { |
|
|
|
|
|
|
|
|
List<Map<String, Object>> maps = ArchivesListToMap.getMaps(list); |
|
|
List<Map<String, Object>> maps = ArchivesListToMap.getMaps(list); |
|
|