|
@@ -6,12 +6,7 @@ import cn.hutool.core.util.ClassUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.db.Db;
|
|
|
-import cn.hutool.db.Entity;
|
|
|
-import cn.hutool.db.GlobalDbConfig;
|
|
|
-import cn.hutool.db.Page;
|
|
|
-import cn.hutool.db.PageResult;
|
|
|
-import cn.hutool.db.Session;
|
|
|
+import cn.hutool.db.*;
|
|
|
import cn.hutool.db.meta.Column;
|
|
|
import cn.hutool.db.meta.JdbcType;
|
|
|
import cn.hutool.db.meta.MetaUtil;
|
|
@@ -37,19 +32,7 @@ import com.xjrsoft.common.utils.LocalDateTimeUtil;
|
|
|
import com.xjrsoft.module.app.entity.AppFuncDesign;
|
|
|
import com.xjrsoft.module.app.service.IAppFuncDesignService;
|
|
|
import com.xjrsoft.module.authority.utils.AuthorityUtil;
|
|
|
-import com.xjrsoft.module.form.dto.AppFormExecuteAddOrUpdateDto;
|
|
|
-import com.xjrsoft.module.form.dto.AppFormExecuteDeleteDto;
|
|
|
-import com.xjrsoft.module.form.dto.AppFormExecuteInfoDto;
|
|
|
-import com.xjrsoft.module.form.dto.AppFormExecuteListDto;
|
|
|
-import com.xjrsoft.module.form.dto.AppFormExecutePageDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteAddOrUpdateDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteDeleteDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteInfoDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteListDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecutePageDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteWorkflowAddDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteWorkflowInfoDto;
|
|
|
-import com.xjrsoft.module.form.dto.FormExecuteWorkflowUpdateDto;
|
|
|
+import com.xjrsoft.module.form.dto.*;
|
|
|
import com.xjrsoft.module.form.entity.FormDesignConfig;
|
|
|
import com.xjrsoft.module.form.entity.FormRelease;
|
|
|
import com.xjrsoft.module.form.entity.FormReleaseConfig;
|
|
@@ -61,12 +44,7 @@ import com.xjrsoft.module.form.utils.FormDataTransUtil;
|
|
|
import com.xjrsoft.module.form.vo.DeskColumnsVo;
|
|
|
import com.xjrsoft.module.form.vo.DeskTableInfoVo;
|
|
|
import com.xjrsoft.module.generator.constant.ComponentTypeConstant;
|
|
|
-import com.xjrsoft.module.generator.entity.ColumnConfig;
|
|
|
-import com.xjrsoft.module.generator.entity.ListConfig;
|
|
|
-import com.xjrsoft.module.generator.entity.QueryConfig;
|
|
|
-import com.xjrsoft.module.generator.entity.TableConfig;
|
|
|
-import com.xjrsoft.module.generator.entity.TableFieldConfig;
|
|
|
-import com.xjrsoft.module.generator.entity.TableStructureConfig;
|
|
|
+import com.xjrsoft.module.generator.entity.*;
|
|
|
import com.xjrsoft.module.generator.utils.GeneratorUtil;
|
|
|
import com.xjrsoft.module.system.service.ICodeRuleService;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -95,17 +73,10 @@ import javax.sql.DataSource;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @Author: tzx
|
|
|
* @Date: 2022/5/11 15:05
|
|
@@ -470,7 +441,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
FormTemplate template = formTemplateMapper.selectById(formRelease.getFormId());
|
|
|
|
|
|
long id = insertFormData(formData, template);
|
|
|
- if(id != 0){
|
|
|
+ if (id != 0) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -501,7 +472,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
template.setFormJson(configJson);
|
|
|
|
|
|
long id = insertFormData(formData, template);
|
|
|
- if(id != 0){
|
|
|
+ if (id != 0) {
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
@@ -524,11 +495,13 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
Table tableMeta = SqlRunnerAdapter.db().getTableMeta(tableName);
|
|
|
Collection<Column> columns = tableMeta.getColumns();
|
|
|
Optional<Column> pk = columns.stream().filter(Column::isPk).findFirst();
|
|
|
+ // 根据表单配置获取字典数据
|
|
|
+ Map<String, Map<String, Object>> formDicData = FormDataTransUtil.formConfigGetDicData(formDesignConfig);
|
|
|
|
|
|
for (Map<String, Object> data : dataList) {
|
|
|
Entity where = Entity.create(tableName);
|
|
|
// 处理字段值
|
|
|
- Map<String, Object> toSaveFormData = handleFormDataForSave(data, formDesignConfig, tableName, new ArrayList<>());
|
|
|
+ Map<String, Object> toSaveFormData = handleFormDataForSave(data, formDesignConfig, tableName, new ArrayList<>(), formDicData);
|
|
|
|
|
|
//formData 默认插入雪花Id主键
|
|
|
pk.ifPresent(column -> toSaveFormData.put(column.getName(), IdUtil.getSnowflakeNextId()));
|
|
@@ -660,7 +633,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
|
|
|
long count = SqlRunnerAdapter.db().selectCount("select count(*) from " + childTableConfig.get().getTableName() + " where " + childTableConfig.get().getRelationField() + " in " + keyValuesStr);
|
|
|
|
|
|
- if(count > 0){
|
|
|
+ if (count > 0) {
|
|
|
Boolean result = SqlRunnerAdapter.db().dynamicDelete(childTableConfig.get().getTableName(), childDeleteWhere);
|
|
|
if (!result) {
|
|
|
throw new MyException("删除数据失败");
|
|
@@ -698,7 +671,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
|
|
|
long count = SqlRunnerAdapter.db().selectCount("select count(*) from " + childTableConfig.get().getTableName() + " where " + childTableConfig.get().getRelationField() + " in " + keyValuesStr);
|
|
|
|
|
|
- if(count > 0){
|
|
|
+ if (count > 0) {
|
|
|
Boolean result = SqlRunnerAdapter.db().dynamicDelete(childTableConfig.get().getTableName(), childDeleteWhere);
|
|
|
if (!result) {
|
|
|
throw new MyException("删除数据失败");
|
|
@@ -921,7 +894,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
// 自动编码code
|
|
|
List<String> autoCodeList = new ArrayList<>();
|
|
|
// 处理字段值
|
|
|
- Map<String, Object> toSaveFormData = handleFormDataForSave(formData, formDesignConfig, tableName, autoCodeList);
|
|
|
+ Map<String, Object> toSaveFormData = handleFormDataForSave(formData, formDesignConfig, tableName, autoCodeList, null);
|
|
|
//formData 默认插入雪花Id主键
|
|
|
if (pk.isPresent()) {
|
|
|
formData.put(pk.get().getName(), keyValue);
|
|
@@ -1010,7 +983,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
wrapperChildEntity(tableConfigList, childMaps, formData, formDesignConfig, keyValue2, null);
|
|
|
|
|
|
// 处理字段值
|
|
|
- formData = handleFormDataForSave(formData, formDesignConfig, tableName, null);
|
|
|
+ formData = handleFormDataForSave(formData, formDesignConfig, tableName, null, null);
|
|
|
// for (Map.Entry<String, Object> entry : formData.entrySet()) {
|
|
|
// if (entry.getValue().toString().isEmpty()) {
|
|
|
// entry.setValue(null);
|
|
@@ -1099,7 +1072,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
Map<String, List<Map<String, Object>>> childFormData = wrapperChildEntity(tableConfigList, childMaps, newFormData, formDesignConfig, keyValue, autoCodeList);
|
|
|
|
|
|
// 处理字段值
|
|
|
- newFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, autoCodeList);
|
|
|
+ newFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, autoCodeList, null);
|
|
|
|
|
|
//formData 默认插入雪花Id主键
|
|
|
if (pk.isPresent()) {
|
|
@@ -1183,7 +1156,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
Map<String, List<Map<String, Object>>> childFormData = wrapperChildEntity(tableConfigList, childMaps, newFormData, formDesignConfig, keyValue, null);
|
|
|
|
|
|
// 处理字段值
|
|
|
- newFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, null);
|
|
|
+ newFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, null, null);
|
|
|
|
|
|
//此时的formData 已经是剔除了子表单数据了
|
|
|
newFormData.remove(pk.getName());
|
|
@@ -1287,7 +1260,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
Map<String, List<Map<String, Object>>> childFormData = wrapperChildEntity(tableConfigList, childMaps, newFormData, formDesignConfig, keyValue, null);
|
|
|
|
|
|
// 处理字段值
|
|
|
- Map<String, Object> toSaveFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, null);
|
|
|
+ Map<String, Object> toSaveFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, null, null);
|
|
|
//此时的formData 已经是剔除了子表单数据了
|
|
|
toSaveFormData.remove(pk.getName());
|
|
|
entity.putAll(toSaveFormData);
|
|
@@ -1299,12 +1272,12 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
findwhere.putAll(entity);
|
|
|
Map<String, Object> objectMap = SqlRunnerAdapter.db().dynamicSelectOne(tableName, findwhere);
|
|
|
Boolean isUpdate = false;
|
|
|
- if(objectMap == null){
|
|
|
+ if (objectMap == null) {
|
|
|
isUpdate = true;
|
|
|
}
|
|
|
|
|
|
Boolean result = null;
|
|
|
- if(isUpdate){
|
|
|
+ if (isUpdate) {
|
|
|
result = SqlRunnerAdapter.db().dynamicUpdate(tableName, entity, where);
|
|
|
if (!result) {
|
|
|
throw new MyException("更新数据失败");
|
|
@@ -1320,7 +1293,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
String keyValuesStr = "(" + keyValue + ")";
|
|
|
|
|
|
long count = SqlRunnerAdapter.db().selectCount("select * from " + childTableConfig.get().getTableName() + " where " + childTableConfig.get().getRelationField() + " in " + keyValuesStr);
|
|
|
- if(count > 0){
|
|
|
+ if (count > 0) {
|
|
|
Entity childDeleteWhere = Entity.create(tableMap.getKey()).set(childTableConfig.get().getRelationField(), keyValue);
|
|
|
result = SqlRunnerAdapter.db().dynamicDelete(childTableConfig.get().getTableName(), childDeleteWhere);
|
|
|
if (!result) {
|
|
@@ -1361,7 +1334,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
Map<String, List<Map<String, Object>>> childFormData = wrapperChildEntity(tableConfigList, childMaps, newFormData, formDesignConfig, keyValue, autoCodeList);
|
|
|
System.out.println("insertOrUpdateFormDataByWorkflow 3");
|
|
|
// 处理字段值
|
|
|
- Map<String, Object> toSaveFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, autoCodeList);
|
|
|
+ Map<String, Object> toSaveFormData = handleFormDataForSave(newFormData, formDesignConfig, tableName, autoCodeList, null);
|
|
|
toSaveFormData.put(pk.getName(), keyValue);
|
|
|
formData.put(pk.getName(), keyValue);
|
|
|
//此时的formData 已经是剔除了子表单数据了
|
|
@@ -1598,7 +1571,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
for (Map<String, Object> item : result) {
|
|
|
Entity entity = Entity.create();
|
|
|
for (String key : item.keySet()) {
|
|
|
- entity.set(key,item.get(key));
|
|
|
+ entity.set(key, item.get(key));
|
|
|
}
|
|
|
//将所有查询的数据id 转string
|
|
|
entity.set(pkColumn.getName(), entity.get(pkColumn.getName()).toString());
|
|
@@ -1909,16 +1882,16 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
}
|
|
|
plainSelect.setWhere(queryExpression);
|
|
|
|
|
|
- com.baomidou.mybatisplus.extension.plugins.pagination.Page mybatisPage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page(page.getPageNumber()+1, page.getPageSize());
|
|
|
+ com.baomidou.mybatisplus.extension.plugins.pagination.Page mybatisPage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page(page.getPageNumber() + 1, page.getPageSize());
|
|
|
|
|
|
IPage<Map<String, Object>> pageResult = SqlRunnerAdapter.db().
|
|
|
- selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNumber()+1, page.getPageSize()), plainSelect.toString());
|
|
|
+ selectPage(new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page.getPageNumber() + 1, page.getPageSize()), plainSelect.toString());
|
|
|
|
|
|
List<Entity> rData = new ArrayList<>();
|
|
|
for (Map<String, Object> item : pageResult.getRecords()) {
|
|
|
Entity entity = Entity.create();
|
|
|
for (String key : item.keySet()) {
|
|
|
- entity.set(key,item.get(key));
|
|
|
+ entity.set(key, item.get(key));
|
|
|
}
|
|
|
//将所有查询的数据id 转string
|
|
|
entity.set(pkColumn.getName(), entity.get(pkColumn.getName()).toString());
|
|
@@ -1926,9 +1899,9 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
}
|
|
|
|
|
|
PageOutput<Entity> pageOutput = new PageOutput<>();
|
|
|
- pageOutput.setPageSize((int)pageResult.getSize());
|
|
|
- pageOutput.setCurrentPage((int)pageResult.getCurrent());
|
|
|
- pageOutput.setTotal((int)pageResult.getTotal());
|
|
|
+ pageOutput.setPageSize((int) pageResult.getSize());
|
|
|
+ pageOutput.setCurrentPage((int) pageResult.getCurrent());
|
|
|
+ pageOutput.setTotal((int) pageResult.getTotal());
|
|
|
pageOutput.setList(rData);
|
|
|
|
|
|
return pageOutput;
|
|
@@ -2175,7 +2148,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
|
|
|
List<Entity> childEntities = new ArrayList<>();
|
|
|
for (Map<String, Object> stringObjectMap : childMap) {
|
|
|
- Map<String, Object> handedMap = handleFormDataForSave(stringObjectMap, formDesignConfig, tableConfig.getTableName(), autoCodeList);
|
|
|
+ Map<String, Object> handedMap = handleFormDataForSave(stringObjectMap, formDesignConfig, tableConfig.getTableName(), autoCodeList, null);
|
|
|
Entity entity = Entity.create(tableConfig.getTableName());
|
|
|
entity.putAll(handedMap);
|
|
|
|
|
@@ -2283,7 +2256,7 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
* @param formDesignConfig
|
|
|
*/
|
|
|
private Map<String, Object> handleFormDataForSave(Map<String, Object> formData, FormDesignConfig formDesignConfig,
|
|
|
- String tableName, List<String> autoCodeList) {
|
|
|
+ String tableName, List<String> autoCodeList, Map<String, Map<String, Object>> formDicData) {
|
|
|
Map<String, Object> resultData = new HashMap<>(formData.size());
|
|
|
Map<String, List<ComponentConfig>> componentListMap = GeneratorUtil.buildFormComponentList(formDesignConfig.getFormJson().getList());
|
|
|
List<ComponentConfig> configList = componentListMap.get(tableName);
|
|
@@ -2367,6 +2340,16 @@ public class FormExecuteServiceImpl implements IFormExecuteService {
|
|
|
if (autoCodeList != null)
|
|
|
autoCodeList.add(MapUtils.getString(options, ComponentTypeConstant.AUTO_CODE_RULE));
|
|
|
}
|
|
|
+ // 针对导入数据做处理()
|
|
|
+ if (formDicData != null) {
|
|
|
+ if (formDicData.containsKey(bindField)) {
|
|
|
+ Map<String, Object> dicData = formDicData.get(bindField);
|
|
|
+ List<Object> mapKey = FormDataTransUtil.getMapKey(dicData, formData.get(bindField));
|
|
|
+ if (!mapKey.isEmpty()) {
|
|
|
+ resultData.put(bindField, mapKey.stream().findFirst().get());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return resultData;
|
|
|
}
|