Browse Source

fix bug修改动态生成模版字典问题

master
liu_li 2 years ago
parent
commit
ae760e378f
  1. 7
      archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java
  2. 7
      archives/src/main/java/com/storeroom/modules/dictionary/repository/FieldRepository.java
  3. 8
      archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java
  4. 8
      archives/src/main/java/com/storeroom/modules/dictionary/service/DynamicTableService.java
  5. 6
      archives/src/main/java/com/storeroom/modules/dictionary/service/FieldService.java
  6. 5
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java
  7. 2
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java
  8. 44
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java
  9. 10
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/FieldServiceImpl.java

7
archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java

@ -81,4 +81,11 @@ public interface ArchivesDictionaryRepository extends JpaRepository<ArchivesDict
@Query(nativeQuery = true,value = "delete from archives_dictionary where category_id = ?1")
void deleteByCategoryId(String categoryId);
/**
* 根据门类id查询
* @param categoryId 门类id
* @return
*/
List<ArchivesDictionary> findByCategoryId(String categoryId);
}

7
archives/src/main/java/com/storeroom/modules/dictionary/repository/FieldRepository.java

@ -26,4 +26,11 @@ public interface FieldRepository extends JpaRepository<Field, String>{
value = "select max(is_sequence) from archives_field where is_type = ?1 ")
Integer getMaxSequence(Integer isType);
/**
* 根据字段名称查询
* @param fieldCnName
* @return
*/
Field findByFieldCnName(String fieldCnName);
}

8
archives/src/main/java/com/storeroom/modules/dictionary/service/ArchivesDictionaryService.java

@ -1,6 +1,7 @@
package com.storeroom.modules.dictionary.service;
import com.storeroom.modules.dictionary.domain.ArchivesDictionary;
import com.storeroom.modules.dictionary.service.dto.ArchivesDicStateDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionaryDTO;
import com.storeroom.modules.dictionary.service.dto.ArchivesDictionarySmallDTO;
@ -112,4 +113,11 @@ public interface ArchivesDictionaryService {
* @param id /
*/
void updateIsDisplayFormat(String id,Boolean isDisplayformat);
/**
* 根据门类id 查询门类字典
* @param archiveTypeid 门类id
* @return
*/
List<ArchivesDictionary> queryCategoryId(String categoryId);
}

8
archives/src/main/java/com/storeroom/modules/dictionary/service/DynamicTableService.java

@ -21,5 +21,13 @@ public interface DynamicTableService {
void DeleteTable(String name);
/**
* 生成模版表
* @param categoryId 门类id
* @param tableName 表名
*/
void DynamicTemplateTable(String categoryId, String tableName);
}

6
archives/src/main/java/com/storeroom/modules/dictionary/service/FieldService.java

@ -1,5 +1,6 @@
package com.storeroom.modules.dictionary.service;
import com.storeroom.modules.dictionary.domain.Field;
import com.storeroom.modules.dictionary.domain.vo.DictionaryVO;
import com.storeroom.modules.dictionary.domain.vo.FieldVO;
import com.storeroom.modules.dictionary.service.dto.DictionaryDTO;
@ -18,4 +19,9 @@ public interface FieldService {
//获取自动生成表字段
List<FieldVO> findGroupType(List types);
/**
* 根据字段名查询
*/
Field findByCNName(String fieldCnName);
}

5
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesDictionaryImpl.java

@ -274,4 +274,9 @@ public class ArchivesDictionaryImpl implements ArchivesDictionaryService {
archivesDictionaryRepository.save(ad);
}
@Override
public List<ArchivesDictionary> queryCategoryId(String categoryId) {
return archivesDictionaryRepository.findByCategoryId(categoryId);
}
}

2
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

@ -109,7 +109,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
arcProject.setRemark(item.getRemark());
arcProject.setEnName(tableName1);
arcProject.setTypeMetic(item.isTypeMetic());
dynamicTableService.DynamicCreate(arcProject.getIsType(), arcProject.getId(), tableName1);
dynamicTableService.DynamicTemplateTable(arcProject.getId(), tableName1);
archivesTypeRepository.save(arcProject);
return arcProject;
}

44
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java

@ -1,6 +1,9 @@
package com.storeroom.modules.dictionary.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.storeroom.modules.common.ArchivesListToMap;
import com.storeroom.modules.dictionary.domain.ArchivesDictionary;
import com.storeroom.modules.dictionary.domain.Field;
import com.storeroom.modules.dictionary.domain.vo.FieldVO;
import com.storeroom.modules.dictionary.service.ArchivesDictionaryService;
import com.storeroom.modules.dictionary.service.DynamicTableService;
@ -15,7 +18,6 @@ import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.stereotype.Service;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
@ -40,7 +42,7 @@ public class DynamicTableImpl implements DynamicTableService {
List<Integer> integerList = new ArrayList<>();
if (type == 4 || type == 5) {
//#生成文件表名称
String fileTableName = "file_"+tableName;
String fileTableName = "file_" + tableName;
integerList.add(1);
integerList.add(2);
//先查询类型1和2的数据字段
@ -71,6 +73,42 @@ public class DynamicTableImpl implements DynamicTableService {
}
/**
* 生成模版表
*
* @param categoryId
* @param tableName
*/
@Override
public void DynamicTemplateTable(String categoryId, String tableName) {
List<ArchivesDictionary> arcList = archivesDictionaryService.queryCategoryId(categoryId);
//#生成文件表名称
String fileTableName = "file_" + tableName;
List<FieldVO> fieldVOList = new ArrayList<>();
arcList.forEach(item -> {
FieldVO fieldVO = new FieldVO();
Field field = fieldService.findByCNName(item.getFieldCnName());
if (!ObjectUtil.isEmpty(field)) {
fieldVO.setId(field.getId());
fieldVO.setIsSystem(field.getIsSystem());
}
fieldVO.setFieldName(item.getFieldName());
fieldVO.setFieldCnName(item.getFieldCnName());
fieldVO.setIsDefaultValue(item.getIsDefaultValue());
fieldVO.setIsDataType(item.getIsDataType());
fieldVO.setIsDataTypeDetails(item.getIsDataTypeDetails());
fieldVO.setIsDefaultValue(item.getIsDefaultValue());
fieldVO.setIsColumnLength(item.getIsColumnLength());
fieldVO.setIsSequence(item.getIsSequence());
fieldVO.setIsType(item.getIsType());
fieldVOList.add(fieldVO);
});
DynamicInsert(fieldVOList, categoryId);
DynamicCreateFileTable(fieldVOList, categoryId);
}
/**
* 查询字典字段
@ -143,7 +181,7 @@ public class DynamicTableImpl implements DynamicTableService {
archivesDictionaryDTO.setIsSystem(j.getIsSystem());
archivesDictionaryDTO.setIsColumnType(j.getIsType());
archivesDictionaryDTO.setIsInput(true);
archivesDictionaryDTO.setIsInputClass(j.getIsDataType()==2?"number":"text");
archivesDictionaryDTO.setIsInputClass(j.getIsDataType() == 2 ? "number" : "text");
archivesDictionaryDTO.setEditLength(196);
newList.add(archivesDictionaryDTO);
}

10
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/FieldServiceImpl.java

@ -1,6 +1,7 @@
package com.storeroom.modules.dictionary.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.storeroom.exception.BaseException;
import com.storeroom.modules.dictionary.domain.Field;
import com.storeroom.modules.dictionary.domain.vo.FieldVO;
import com.storeroom.modules.dictionary.repository.FieldRepository;
@ -8,6 +9,7 @@ import com.storeroom.modules.dictionary.service.FieldService;
import com.storeroom.modules.dictionary.service.dto.FieldDTO;
import com.storeroom.utils.NanoIdUtils;
import com.storeroom.utils.RsaUtils;
import com.storeroom.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -72,4 +74,12 @@ public class FieldServiceImpl implements FieldService {
}
return fieldVOList;
}
@Override
public Field findByCNName(String fieldCNName){
if (StringUtils.isEmpty(fieldCNName)){
throw new BaseException("字段名不能为空");
}
return fieldRepository.findByFieldCnName(fieldCNName);
}
}
Loading…
Cancel
Save