add 获取表单模型

This commit is contained in:
liao
2023-08-23 11:57:35 +08:00
parent 8e7bd2f5cc
commit ee56da57b5
5 changed files with 133 additions and 16 deletions
@@ -34,7 +34,8 @@ public class JwtUtil {
// Token过期时间30分钟(用户登录过期时间也是30分钟,以token在reids缓存时间为准)
public static final long EXPIRE_TIME = 180 * 60 * 1000L;
//public static final long EXPIRE_TIME = 180 * 60 * 1000L;
public static final long EXPIRE_TIME = 7 * 24 * 60 * 60 * 1000L; // 设置成七天(开发用)
private static final String USERNAME_FIELD = "username";
@@ -631,7 +631,12 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
sysCategoryTreeVOList = sysCategoryTree.stream().filter(e -> dictId.equals(e.getDictId())).collect(Collectors.toList());
}
Map<String, Object> map = new HashMap<>();
mapPut(cut, map, "field_show_type", onlCgformField.getFieldShowType(), "dict_field", onlCgformField.getDictField(), "db_field_name", onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(), "db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, sysCategoryTreeVOList);
mapPut(cut, map, "field_show_type", onlCgformField.getFieldShowType(),
"dict_field", onlCgformField.getDictField(), "db_field_name",
onlCgformField.getDbFieldName(), "db_field_txt", onlCgformField.getDbFieldTxt(),
"db_field_en_name", onlCgformField.getDbFieldEnName(), "area", areaName, sysCategoryTreeVOList);
map.put("field_must_input", onlCgformField.getFieldMustInput());//是否必填
map.put("db_length", onlCgformField.getDbLength());//字段长度
if (fieldFileList.contains(onlCgformField.getDbFieldName()) && onlCgformField.getIsReadOnly() == 1) {
@@ -51,4 +51,12 @@ public class LawsBasicInfoController extends JeroController<LawsBasicInfo, ILaws
return Result.OK(lawsBasicInfoService.getListHeader(flag));
}
@AutoLog(value = "获取表单模型")
@ApiOperation(value="获取表单模型", notes="获取表单模型")
@GetMapping(value = "getFormModel")
public Result<List<Map<String,Object>>> getFormModel(@RequestParam(name="flag") String flag) {
List<Map<String, Object>> list = lawsBasicInfoService.getFormModel(flag);
return Result.OK(list);
}
}
@@ -34,4 +34,11 @@ public interface ILawsBasicInfoService extends IService<LawsBasicInfo> {
* @Description: 获取列表表头
**/
List<Map<String, Object>> getListHeader(String flag);
/**
* @Author: liao
* @Date: 2023/8/23 11:20
* @Description: 获取表单模型
**/
List<Map<String, Object>> getFormModel(String flag);
}
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.enums.LanguageEnum;
import com.jero.common.constant.enums.ModuleEnum;
import com.jero.common.constant.enums.YesOrNoEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.util.MessageUtils;
@@ -20,9 +21,11 @@ import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.service.ISysDictItemService;
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import com.jero.modules.system.util.MyStringUtils;
import com.jero.modules.tag.entity.LawsArea;
import com.jero.modules.tag.entity.LawsTag;
import com.jero.modules.tag.enums.FileTableIdEnum;
import com.jero.modules.tag.mapper.LawsTagMapper;
import com.jero.modules.tag.service.ILawsAreaService;
import com.jero.modules.tag.service.ILawsTagService;
import com.spire.ms.System.Collections.ArrayList;
import org.apache.commons.collections.CollectionUtils;
@@ -60,6 +63,8 @@ public class LawsBasicInfoServiceImpl extends ServiceImpl<LawsBasicInfoMapper, L
private ISysDictItemService sysDictItemService;
@Autowired
private IOSSFileService ossFileService;
@Autowired
private ILawsAreaService lawsAreaService;
/**
* @Author: liao
@@ -201,12 +206,114 @@ public class LawsBasicInfoServiceImpl extends ServiceImpl<LawsBasicInfoMapper, L
return resultList;
}
/**
* @Author: liao
* @Date: 2023/8/23 11:20
* @Description: 获取表单模型
**/
@Override
public List<Map<String, Object>> getFormModel(String flag) {
String cut = MessageUtils.getLanguage().getValue();
LawsArea lawsArea = new LawsArea();
lawsArea.setIsModel(flag);
// 区域管理
List<LawsArea> areaList = lawsAreaService.queryList(lawsArea);
// 字段字段集合
List<LawsTag> fieldList = getFieldList(flag);
// 文件类型字段集合
List<LawsTag> lawsTagFieldList = fieldList.stream().filter(lawsTag -> FieldTypeEnum.FILE.getValue()
.equals(lawsTag.getFieldShowType())).collect(Collectors.toList());
List<String> fieldFileList = lawsTagFieldList.stream().map(LawsTag::getDbFieldName).collect(Collectors.toList());
//过滤出字段为树形结构的
if (fieldList.size() != 0) {
//过滤出表单字段(is_show_form-->表单是否显示0否 1是)
fieldList = fieldList.stream()
.filter(e -> YesOrNoEnum.YES.getValue().equals(MyStringUtils.valueOf(e.getIsShowForm())))
.collect(Collectors.toList());
}
Map<String,Object> params = new HashedMap();
params.put("cut",cut);
// 获取树型字典
List<SysCategoryTreeVO> sysCategoryTree = sysCategoryService.getSysCategoryTree(null,params);
List<Map<String, Object>> resultTemp = new java.util.ArrayList<>();
for (LawsArea lawsAreaTemp : areaList) {
List<Map<String, Object>> Results = new java.util.ArrayList<>();
Map<String, Object> mapTemp = new HashMap<>();
String areaName = "";
// 获取展示区域名称
if (LanguageEnum.CN.getValue().equals(cut)) {
areaName = lawsAreaTemp.getShowArea();
} else {
areaName = lawsAreaTemp.getEnName();
}
// 获取该区域的所有字段
List<LawsTag> fieldListTemp = fieldList.stream().filter(e -> lawsAreaTemp.getId()
.equals(e.getShowArea())).collect(Collectors.toList());
for (LawsTag lawsTag : fieldListTemp) {
if (lawsAreaTemp.getId().equals(lawsTag.getShowArea())) {
String dictId = lawsTag.getDictId();
List<SysCategoryTreeVO> sysCategoryTreeVOList = new java.util.ArrayList<>();
// 如果字典标识字段不为空,则筛选出该字典的全部配置项集合
if (StringUtils.isNotBlank(dictId)) {
sysCategoryTreeVOList = sysCategoryTree.stream().filter(e -> dictId.equals(e.getDictId())).collect(Collectors.toList());
}
Map<String, Object> map = new HashMap<>();
mapPut(cut, map, "field_show_type", lawsTag.getFieldShowType(),
"dict_field", lawsTag.getDictField(), "db_field_name",
lawsTag.getDbFieldName(), "db_field_txt", lawsTag.getDbFieldTxt(),
"db_field_en_name", lawsTag.getDbFieldEnName(), "area", areaName, sysCategoryTreeVOList);
map.put("field_must_input", lawsTag.getFieldMustInput());//是否必填
map.put("db_length", lawsTag.getDbLength());//字段长度
if (fieldFileList.contains(lawsTag.getDbFieldName()) && lawsTag.getIsReadOnly() == 1) {
map.put("flag", "1");//固定文件标识
} else if (fieldFileList.contains(lawsTag.getDbFieldName()) && lawsTag.getIsReadOnly() == 0) {
map.put("flag", "0");//非固定文件字段
}
Results.add(map);
}
}
if (LanguageEnum.CN.getValue().equals(cut)) {
mapTemp.put(lawsAreaTemp.getShowArea(), Results);
} else {
mapTemp.put(lawsAreaTemp.getEnName(), Results);
}
resultTemp.add(mapTemp);
}
return resultTemp;
}
private void mapPut(String cut, Map<String, Object> map, String field_show_type,
String fieldShowType2, String dict_field, String dictField,
String db_field_name, String dbFieldName2, String db_field_txt,
String dbFieldTxt, String db_field_en_name, String dbFieldEnName,
String area, String showArea, List<SysCategoryTreeVO> sysCategoryTreeVOS) {
if(FieldTypeEnum.TEXT_LINK.getValue().equals(fieldShowType2)){
map.put("urlClick", "true");
}
map.put(field_show_type, fieldShowType2);//类型(判断是下拉还是输入框,等等)
map.put(dict_field, dictField);
map.put(db_field_name, dbFieldName2);//字段
if (StringUtils.isNotBlank(cut)) {
if (LanguageEnum.CN.getValue().equals(cut)) {
map.put(db_field_txt, dbFieldTxt);//字段中文名
} else {
map.put(db_field_txt, dbFieldEnName);//字段中文名
}
} else {
map.put(db_field_txt, dbFieldTxt);//字段中文名
}
map.put(area, showArea);//区域
map.put("tree", sysCategoryTreeVOS);//区域
}
/**
* @Author: liao
* @Date: 2023/8/22 13:41
* @Description: 属性字典处理中文
**/
public void treeDictItem(List<SysCategory> categoryList, Map.Entry<String, Object> entry, List<LawsTag> treeFieldList, String cut,String flag) {
private void treeDictItem(List<SysCategory> categoryList, Map.Entry<String, Object> entry, List<LawsTag> treeFieldList, String cut,String flag) {
List<String> treeFields = treeFieldList.stream().map(LawsTag::getDbFieldName).collect(Collectors.toList());
String key = entry.getKey();
if (treeFields.contains(entry.getKey())) {
@@ -232,7 +339,7 @@ public class LawsBasicInfoServiceImpl extends ServiceImpl<LawsBasicInfoMapper, L
* @Date: 2023/8/22 13:42
* @Description: 属性字典处理中文
**/
public void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, String cut, List<LawsTag> fieldList,String flag) {
private void dictItem(List<SysDictItem> sysDictItems, Map.Entry<String, Object> entry, String cut, List<LawsTag> fieldList,String flag) {
//通过dictField判断字段是否为下拉选(不为空则为下拉选)
List<LawsTag> lawsTagFieldList = fieldList.stream().filter(field ->
entry.getKey().equals(field.getDbFieldName())).collect(Collectors.toList());
@@ -433,18 +540,7 @@ public class LawsBasicInfoServiceImpl extends ServiceImpl<LawsBasicInfoMapper, L
* @Description: 根据table_name查询字段集合
**/
private List<LawsTag> getFieldList(String flag) {
List<LawsTag> fieldList = new java.util.ArrayList<>();
if (FileTableIdEnum.DOMESTIC_REGULATIONS.getValue().equals(flag)) {
// 国内法规
fieldList = lawsTagMapper.getFieldList(FileTableIdEnum.DOMESTIC_REGULATIONS.getTableName());
} else if (FileTableIdEnum.FOREIGN_REGULATIONS.getValue().equals(flag)) {
// 国外法规
fieldList = lawsTagMapper.getFieldList(FileTableIdEnum.FOREIGN_REGULATIONS.getTableName());
} else if (FileTableIdEnum.ENTERPRISE_STANDARDS.getValue().equals(flag)) {
// 企业标准
fieldList = lawsTagMapper.getFieldList(FileTableIdEnum.ENTERPRISE_STANDARDS.getTableName());
}
return fieldList;
return lawsTagMapper.getFieldList(FileTableIdEnum.getTableName(flag));
}
/**