commit:同步2.3版本

This commit is contained in:
Jerry
2022-02-20 13:40:36 +08:00
parent c7cc3f5354
commit cbe0f7947d
668 changed files with 172592 additions and 821 deletions

View File

@@ -156,8 +156,8 @@ public abstract class BaseService<M, K extends Serializable> extends ServiceImpl
*/
private final TableModelInfo tableModelInfo = new TableModelInfo();
private static final String GROUPED_KEY = "groupedKey";
private static final String AGGREGATED_VALUE = "aggregatedValue";
private static final String GROUPED_KEY = "grouped_key";
private static final String AGGREGATED_VALUE = "aggregated_value";
private static final String AND_OP = " AND ";
@Override

View File

@@ -43,6 +43,12 @@ public class MyDateUtil {
private static final DateTimeFormatter DATETIME_PARSE_FORMATTER =
DateTimeFormat.forPattern(MyDateUtil.COMMON_DATETIME_FORMAT);
/**
* 缺省短日期时间格式化器,提前获取提升运行时效率。
*/
private static final DateTimeFormatter DATETIME_SHORT_PARSE_FORMATTER =
DateTimeFormat.forPattern(MyDateUtil.COMMON_SHORT_DATETIME_FORMAT);
/**
* 获取一天的开始时间的字符串格式如2019-08-03 00:00:00.000。
*
@@ -144,6 +150,16 @@ public class MyDateUtil {
return DATETIME_PARSE_FORMATTER.parseDateTime(dateTimeString);
}
/**
* 将缺省格式的(不包含毫秒的)日期时间字符串解析为日期对象。
*
* @param dateTimeString 待解析的字符串。
* @return 解析后的日期对象。
*/
public static DateTime toDateTimeWithoutMs(String dateTimeString) {
return DATETIME_SHORT_PARSE_FORMATTER.parseDateTime(dateTimeString);
}
/**
* 截取时间到天。如2019-10-03 01:20:30 转换为 2019-10-03 00:00:00。
* 由于没有字符串的中间转换,因此效率更高。

View File

@@ -7,8 +7,8 @@
<result column="deploy_id" jdbcType="VARCHAR" property="deployId"/>
<result column="process_definition_id" jdbcType="VARCHAR" property="processDefinitionId"/>
<result column="publish_version" jdbcType="INTEGER" property="publishVersion"/>
<result column="active_status" jdbcType="BIT" property="activeStatus"/>
<result column="main_version" jdbcType="BIT" property="mainVersion"/>
<result column="active_status" jdbcType="BOOLEAN" property="activeStatus"/>
<result column="main_version" jdbcType="BOOLEAN" property="mainVersion"/>
<result column="create_user_id" jdbcType="BIGINT" property="createUserId"/>
<result column="publish_time" jdbcType="TIMESTAMP" property="publishTime"/>
<result column="init_task_info" jdbcType="VARCHAR" property="initTaskInfo"/>

View File

@@ -10,7 +10,7 @@
<result column="bind_datasource_id" jdbcType="BIGINT" property="bindDatasourceId"/>
<result column="bind_relation_id" jdbcType="BIGINT" property="bindRelationId"/>
<result column="bind_column_id" jdbcType="BIGINT" property="bindColumnId"/>
<result column="builtin" jdbcType="BIT" property="builtin"/>
<result column="builtin" jdbcType="BOOLEAN" property="builtin"/>
</resultMap>
<insert id="insertList">

View File

@@ -10,7 +10,7 @@
<result column="bind_datasource_id" jdbcType="BIGINT" property="bindDatasourceId"/>
<result column="bind_relation_id" jdbcType="BIGINT" property="bindRelationId"/>
<result column="bind_column_id" jdbcType="BIGINT" property="bindColumnId"/>
<result column="builtin" jdbcType="BIT" property="builtin"/>
<result column="builtin" jdbcType="BOOLEAN" property="builtin"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
</resultMap>

View File

@@ -17,9 +17,9 @@
<result column="task_name" jdbcType="VARCHAR" property="taskName"/>
<result column="task_start_time" jdbcType="TIMESTAMP" property="taskStartTime"/>
<result column="task_assignee" jdbcType="VARCHAR" property="taskAssignee"/>
<result column="task_finished" jdbcType="BIT" property="taskFinished"/>
<result column="task_finished" jdbcType="BOOLEAN" property="taskFinished"/>
<result column="business_data_shot" jdbcType="LONGVARCHAR" property="businessDataShot"/>
<result column="online_form_data" jdbcType="BIT" property="onlineFormData"/>
<result column="online_form_data" jdbcType="BOOLEAN" property="onlineFormData"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="update_user_id" jdbcType="BIGINT" property="updateUserId"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
@@ -30,7 +30,7 @@
<select id="getRemindingMessageListByUser" resultMap="BaseResultMap">
SELECT a.* FROM zz_flow_message a
<where>
a.task_finished = 0
a.task_finished = false
AND a.message_type = 0
AND (a.task_assignee = #{loginName} OR EXISTS (SELECT * FROM zz_flow_message_candicate_identity b
WHERE a.message_id = b.message_id AND b.candidate_id in
@@ -65,7 +65,7 @@
<select id="countRemindingMessageListByUser" resultType="java.lang.Integer">
SELECT COUNT(1) FROM zz_flow_message a
<where>
a.task_finished = 0
a.task_finished = false
AND a.message_type = 0
AND (a.task_assignee = #{loginName} OR EXISTS (SELECT * FROM zz_flow_message_candicate_identity b
WHERE a.message_id = b.message_id AND b.candidate_id in

View File

@@ -16,7 +16,7 @@
<result column="request_arguments" jdbcType="VARCHAR" property="requestArguments"/>
<result column="response_result" jdbcType="VARCHAR" property="responseResult"/>
<result column="request_ip" jdbcType="VARCHAR" property="requestIp"/>
<result column="success" jdbcType="BIT" property="success"/>
<result column="success" jdbcType="BOOLEAN" property="success"/>
<result column="error_msg" jdbcType="VARCHAR" property="errorMsg"/>
<result column="tenant_id" jdbcType="BIGINT" property="tenantId"/>
<result column="operator_id" jdbcType="BIGINT" property="operatorId"/>

View File

@@ -154,22 +154,19 @@ public class OnlineColumnController {
* 列出符合过滤条件的字段数据列表。
*
* @param onlineColumnDtoFilter 过滤对象。
* @param orderParam 排序参数。
* @param pageParam 分页参数。
* @return 应答结果对象,包含查询结果集。
*/
@PostMapping("/list")
public ResponseResult<MyPageData<OnlineColumnVo>> list(
@MyRequestBody OnlineColumnDto onlineColumnDtoFilter,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody MyPageParam pageParam) {
if (pageParam != null) {
PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize());
}
OnlineColumn onlineColumnFilter = MyModelUtil.copyTo(onlineColumnDtoFilter, OnlineColumn.class);
String orderBy = MyOrderParam.buildOrderBy(orderParam, OnlineColumn.class);
List<OnlineColumn> onlineColumnList =
onlineColumnService.getOnlineColumnListWithRelation(onlineColumnFilter, orderBy);
onlineColumnService.getOnlineColumnListWithRelation(onlineColumnFilter);
return ResponseResult.success(MyPageUtil.makeResponseData(onlineColumnList, OnlineColumn.INSTANCE));
}

View File

@@ -1,6 +1,7 @@
package com.orangeforms.common.online.controller;
import io.swagger.annotations.Api;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.CharUtil;
import cn.hutool.core.util.StrUtil;
@@ -8,9 +9,7 @@ import com.alibaba.fastjson.JSONObject;
import com.orangeforms.common.core.annotation.MyRequestBody;
import com.orangeforms.common.core.constant.ErrorCodeEnum;
import com.orangeforms.common.core.object.*;
import com.orangeforms.common.core.util.ContextUtil;
import com.orangeforms.common.core.util.MyCommonUtil;
import com.orangeforms.common.core.util.MyPageUtil;
import com.orangeforms.common.core.util.*;
import com.orangeforms.common.online.util.OnlineOperationHelper;
import com.orangeforms.common.online.dto.OnlineFilterDto;
import com.orangeforms.common.online.model.*;
@@ -20,7 +19,9 @@ import com.orangeforms.common.online.object.ColumnData;
import com.orangeforms.common.online.service.*;
import com.orangeforms.common.online.util.OnlineConstant;
import com.github.pagehelper.page.PageMethod;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.web.bind.annotation.*;
@@ -56,6 +57,8 @@ public class OnlineOperationController {
private OnlineTableService onlineTableService;
@Autowired
private OnlineOperationHelper onlineOperationHelper;
@Autowired
private OnlineVirtualColumnService onlineVirtualColumnService;
/**
* 新增数据接口。
@@ -237,28 +240,23 @@ public class OnlineOperationController {
@PathVariable("datasourceVariableName") String datasourceVariableName,
@MyRequestBody(required = true) Long datasourceId,
@MyRequestBody(required = true) String dataId) {
String errorMessage;
ResponseResult<OnlineDatasource> datasourceResult =
onlineOperationHelper.verifyAndGetDatasource(datasourceId);
if (!datasourceResult.isSuccess()) {
return ResponseResult.errorFrom(datasourceResult);
}
OnlineDatasource datasource = datasourceResult.getData();
if (!datasource.getVariableName().equals(datasourceVariableName)) {
ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION);
}
OnlineTable masterTable = datasource.getMasterTable();
ResponseResult<List<OnlineDatasourceRelation>> relationListResult =
onlineOperationHelper.verifyAndGetRelationList(datasourceId, RelationType.ONE_TO_MANY);
if (!relationListResult.isSuccess()) {
return ResponseResult.errorFrom(relationListResult);
}
List<OnlineDatasourceRelation> relationList = relationListResult.getData();
if (!onlineOperationService.delete(masterTable, relationList, dataId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
return this.doDelete(datasourceVariableName, datasourceId, CollUtil.newArrayList(dataId));
}
/**
* 批量删除主数据接口。
*
* @param datasourceVariableName 数据源名称。
* @param datasourceId 主表数据源Id。
* @param dataIdList 待删除的数据表主键Id列表。
* @return 应该结果。
*/
@PostMapping("/deleteBatchDatasource/{datasourceVariableName}")
public ResponseResult<Void> deleteBatchDatasource(
@PathVariable("datasourceVariableName") String datasourceVariableName,
@MyRequestBody(required = true) Long datasourceId,
@MyRequestBody(required = true, elementType = String.class) List<String> dataIdList) {
return this.doDelete(datasourceVariableName, datasourceId, dataIdList);
}
/**
@@ -276,26 +274,25 @@ public class OnlineOperationController {
@MyRequestBody(required = true) Long datasourceId,
@MyRequestBody(required = true) Long relationId,
@MyRequestBody(required = true) String dataId) {
String errorMessage;
OnlineDatasource datasource = onlineDatasourceService.getById(datasourceId);
if (datasource == null) {
errorMessage = "数据验证失败数据源Id并不存在";
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
if (!datasource.getVariableName().equals(datasourceVariableName)) {
ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION);
}
ResponseResult<OnlineDatasourceRelation> relationResult =
onlineOperationHelper.verifyAndGetOneToManyRelation(datasourceId, relationId);
if (!relationResult.isSuccess()) {
return ResponseResult.errorFrom(relationResult);
}
OnlineDatasourceRelation relation = relationResult.getData();
if (!onlineOperationService.delete(relation.getSlaveTable(), null, dataId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
return ResponseResult.success();
return this.doDelete(datasourceVariableName, datasourceId, relationId, CollUtil.newArrayList(dataId));
}
/**
* 批量删除一对多关联表单条数据接口。
*
* @param datasourceVariableName 数据源名称。
* @param datasourceId 主表数据源Id。
* @param relationId 一对多关联Id。
* @param dataIdList 一对多关联表主键Id列表。
* @return 应该结果。
*/
@PostMapping("/deleteBatchOneToManyRelation/{datasourceVariableName}")
public ResponseResult<Void> deleteBatchOneToManyRelation(
@PathVariable("datasourceVariableName") String datasourceVariableName,
@MyRequestBody(required = true) Long datasourceId,
@MyRequestBody(required = true) Long relationId,
@MyRequestBody(required = true, elementType = String.class) List<String> dataIdList) {
return this.doDelete(datasourceVariableName, datasourceId, relationId, dataIdList);
}
/**
@@ -593,6 +590,66 @@ public class OnlineOperationController {
return ResponseResult.success(MyPageUtil.makeResponseData(resultList));
}
/**
* 根据数据源Id以及接口参数为动态表单导出数据列表。
*
* @param datasourceVariableName 数据源名称。
* @param datasourceId 数据源Id。
* @param filterDtoList 多虑数据对象列表。
* @param orderParam 排序对象。
* @param exportInfoList 导出字段信息列表。
*/
@PostMapping("/exportByDatasourceId/{datasourceVariableName}")
public void exportByDatasourceId(
@PathVariable("datasourceVariableName") String datasourceVariableName,
@MyRequestBody(required = true) Long datasourceId,
@MyRequestBody(elementType = OnlineFilterDto.class) List<OnlineFilterDto> filterDtoList,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody(elementType = ExportInfo.class, required = true) List<ExportInfo> exportInfoList) throws IOException {
// 1. 验证数据源及其关联
ResponseResult<OnlineDatasource> datasourceResult =
onlineOperationHelper.verifyAndGetDatasource(datasourceId);
if (!datasourceResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, datasourceResult);
}
OnlineDatasource datasource = datasourceResult.getData();
if (!datasource.getVariableName().equals(datasourceVariableName)) {
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
}
OnlineTable masterTable = datasource.getMasterTable();
ResponseResult<List<OnlineDatasourceRelation>> relationListResult =
onlineOperationHelper.verifyAndGetRelationList(datasourceId, null);
if (!relationListResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, relationListResult);
}
List<OnlineDatasourceRelation> allRelationList = relationListResult.getData();
// 2. 验证数据过滤对象中的表名和字段确保没有sql注入。
ResponseResult<Void> filterDtoListResult = this.verifyFilterDtoList(filterDtoList);
if (!filterDtoListResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, filterDtoListResult);
}
// 3. 解析排序参数同时确保没有sql注入。
Map<String, OnlineTable> tableMap = new HashMap<>(4);
tableMap.put(masterTable.getTableName(), masterTable);
List<OnlineDatasourceRelation> oneToOneRelationList = relationListResult.getData().stream()
.filter(r -> r.getRelationType().equals(RelationType.ONE_TO_ONE)).collect(Collectors.toList());
if (CollUtil.isNotEmpty(oneToOneRelationList)) {
Map<String, OnlineTable> relationTableMap = oneToOneRelationList.stream()
.map(OnlineDatasourceRelation::getSlaveTable).collect(Collectors.toMap(OnlineTable::getTableName, c -> c));
tableMap.putAll(relationTableMap);
}
ResponseResult<String> orderByResult = this.makeOrderBy(orderParam, masterTable, tableMap);
if (!orderByResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, orderByResult);
}
String orderBy = orderByResult.getData();
List<Map<String, Object>> resultList = onlineOperationService.getMasterDataList(
masterTable, oneToOneRelationList, allRelationList, filterDtoList, orderBy);
Map<String, String> headerMap = this.makeExportHeaderMap(masterTable, allRelationList, exportInfoList);
String filename = datasourceVariableName + "-" + MyDateUtil.toDateTimeString(DateTime.now()) + ".xlsx";
ExportUtil.doExport(resultList, headerMap, filename);
}
/**
* 根据数据源Id和数据源关联Id以及接口参数为动态表单查询该一对多关联的数据列表。
*
@@ -655,6 +712,68 @@ public class OnlineOperationController {
onlineOperationService.getSlaveDataList(relation, filterDtoList, orderBy);
return ResponseResult.success(MyPageUtil.makeResponseData(resultList));
}
/**
* 根据数据源Id和数据源关联Id以及接口参数为动态表单查询该一对多关联的数据列表。
*
* @param datasourceVariableName 数据源名称。
* @param datasourceId 数据源Id。
* @param relationId 数据源的一对多关联Id。
* @param filterDtoList 多虑数据对象列表。
* @param orderParam 排序对象。
* @param exportInfoList 导出字段信息列表。
*/
@PostMapping("/exportByOneToManyRelationId/{datasourceVariableName}")
public void exportByOneToManyRelationId(
@PathVariable("datasourceVariableName") String datasourceVariableName,
@MyRequestBody(required = true) Long datasourceId,
@MyRequestBody(required = true) Long relationId,
@MyRequestBody(elementType = OnlineFilterDto.class) List<OnlineFilterDto> filterDtoList,
@MyRequestBody MyOrderParam orderParam,
@MyRequestBody(elementType = ExportInfo.class, required = true) List<ExportInfo> exportInfoList) throws IOException {
String errorMessage;
OnlineDatasource datasource = onlineDatasourceService.getById(datasourceId);
if (datasource == null) {
errorMessage = "数据验证失败数据源Id并不存在";
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST,
ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, errorMessage));
}
if (!datasource.getVariableName().equals(datasourceVariableName)) {
ResponseResult.output(HttpServletResponse.SC_FORBIDDEN);
}
ResponseResult<OnlineDatasourceRelation> relationResult =
onlineOperationHelper.verifyAndGetOneToManyRelation(datasourceId, relationId);
if (!relationResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, relationResult);
}
OnlineDatasourceRelation relation = relationResult.getData();
OnlineTable slaveTable = relation.getSlaveTable();
// 验证数据过滤对象中的表名和字段确保没有sql注入。
ResponseResult<Void> filterDtoListResult = this.verifyFilterDtoList(filterDtoList);
if (!filterDtoListResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, filterDtoListResult);
}
Map<String, OnlineTable> tableMap = new HashMap<>(1);
tableMap.put(slaveTable.getTableName(), slaveTable);
if (CollUtil.isNotEmpty(orderParam)) {
for (MyOrderParam.OrderInfo orderInfo : orderParam) {
orderInfo.setFieldName(StrUtil.removePrefix(orderInfo.getFieldName(),
relation.getVariableName() + OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR));
}
}
ResponseResult<String> orderByResult = this.makeOrderBy(orderParam, slaveTable, tableMap);
if (!orderByResult.isSuccess()) {
ResponseResult.output(HttpServletResponse.SC_BAD_REQUEST, orderByResult);
}
String orderBy = orderByResult.getData();
List<Map<String, Object>> resultList =
onlineOperationService.getSlaveDataList(relation, filterDtoList, orderBy);
Map<String, String> headerMap = this.makeExportHeaderMap(
null, CollUtil.newArrayList(relation), exportInfoList);
String filename = datasourceVariableName + "-relation-"
+ MyDateUtil.toDateTimeString(DateTime.now()) + ".xlsx";
ExportUtil.doExport(resultList, headerMap, filename);
}
/**
* 查询字典数据,并以字典的约定方式,返回数据结果集。
@@ -690,6 +809,60 @@ public class OnlineOperationController {
return ResponseResult.success(resultList);
}
private ResponseResult<Void> doDelete(
String datasourceVariableName, Long datasourceId, List<String> dataIdList) {
String errorMessage;
ResponseResult<OnlineDatasource> datasourceResult =
onlineOperationHelper.verifyAndGetDatasource(datasourceId);
if (!datasourceResult.isSuccess()) {
return ResponseResult.errorFrom(datasourceResult);
}
OnlineDatasource datasource = datasourceResult.getData();
if (!datasource.getVariableName().equals(datasourceVariableName)) {
ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION);
}
OnlineTable masterTable = datasource.getMasterTable();
ResponseResult<List<OnlineDatasourceRelation>> relationListResult =
onlineOperationHelper.verifyAndGetRelationList(datasourceId, RelationType.ONE_TO_MANY);
if (!relationListResult.isSuccess()) {
return ResponseResult.errorFrom(relationListResult);
}
List<OnlineDatasourceRelation> relationList = relationListResult.getData();
for (String dataId : dataIdList) {
if (!onlineOperationService.delete(masterTable, relationList, dataId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
}
return ResponseResult.success();
}
private ResponseResult<Void> doDelete(
String datasourceVariableName, Long datasourceId, Long relationId, List<String> dataIdList) {
String errorMessage;
OnlineDatasource datasource = onlineDatasourceService.getById(datasourceId);
if (datasource == null) {
errorMessage = "数据验证失败数据源Id并不存在";
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
if (!datasource.getVariableName().equals(datasourceVariableName)) {
ContextUtil.getHttpResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
return ResponseResult.error(ErrorCodeEnum.NO_OPERATION_PERMISSION);
}
ResponseResult<OnlineDatasourceRelation> relationResult =
onlineOperationHelper.verifyAndGetOneToManyRelation(datasourceId, relationId);
if (!relationResult.isSuccess()) {
return ResponseResult.errorFrom(relationResult);
}
OnlineDatasourceRelation relation = relationResult.getData();
for (String dataId : dataIdList) {
if (!onlineOperationService.delete(relation.getSlaveTable(), null, dataId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
}
return ResponseResult.success();
}
private ResponseResult<Void> verifyFilterDtoList(List<OnlineFilterDto> filterDtoList) {
if (CollUtil.isEmpty(filterDtoList)) {
return ResponseResult.success();
@@ -785,4 +958,57 @@ public class OnlineOperationController {
}
return ResponseResult.success(sb.toString());
}
private Map<String, String> makeExportHeaderMap(
OnlineTable masterTable,
List<OnlineDatasourceRelation> allRelationList,
List<ExportInfo> exportInfoList) {
Map<String, String> headerMap = new LinkedHashMap<>(16);
Map<Long, OnlineDatasourceRelation> allRelationMap = null;
if (CollUtil.isNotEmpty(allRelationList)) {
allRelationMap = allRelationList.stream()
.collect(Collectors.toMap(OnlineDatasourceRelation::getSlaveTableId, r -> r));
}
for (ExportInfo exportInfo : exportInfoList) {
if (masterTable != null && exportInfo.getTableId().equals(masterTable.getTableId())) {
if (exportInfo.getVirtualColumnId() != null) {
OnlineVirtualColumn virtualColumn =
onlineVirtualColumnService.getById(exportInfo.getVirtualColumnId());
if (virtualColumn != null) {
headerMap.put(virtualColumn.getObjectFieldName(), exportInfo.showName);
}
} else {
OnlineColumn column = masterTable.getColumnMap().get(exportInfo.getColumnId());
if (column.getDictId() != null) {
headerMap.put(column.getColumnName() + "__DictMap.name", exportInfo.getShowName());
} else {
headerMap.put(column.getColumnName(), exportInfo.getShowName());
}
}
} else {
if (MapUtil.isEmpty(allRelationMap)) {
continue;
}
OnlineDatasourceRelation relation = allRelationMap.get(exportInfo.getTableId());
if (relation != null) {
OnlineColumn column = relation.getSlaveTable().getColumnMap().get(exportInfo.getColumnId());
String columnName = relation.getVariableName()
+ OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR + column.getColumnName();
if (column.getDictId() != null) {
columnName = columnName + "__DictMap.name";
}
headerMap.put(columnName, exportInfo.getShowName());
}
}
}
return headerMap;
}
@Data
public static class ExportInfo {
private Long tableId;
private Long columnId;
private Long virtualColumnId;
private String showName;
}
}

View File

@@ -18,9 +18,7 @@ public interface OnlineColumnMapper extends BaseDaoMapper<OnlineColumn> {
* 获取过滤后的对象列表。
*
* @param onlineColumnFilter 主表过滤对象。
* @param orderBy 排序字符串order by从句的参数。
* @return 对象列表。
*/
List<OnlineColumn> getOnlineColumnList(
@Param("onlineColumnFilter") OnlineColumn onlineColumnFilter, @Param("orderBy") String orderBy);
List<OnlineColumn> getOnlineColumnList(@Param("onlineColumnFilter") OnlineColumn onlineColumnFilter);
}

View File

@@ -7,18 +7,18 @@
<result column="table_id" jdbcType="BIGINT" property="tableId"/>
<result column="column_type" jdbcType="VARCHAR" property="columnType"/>
<result column="full_column_type" jdbcType="VARCHAR" property="fullColumnType"/>
<result column="primary_key" jdbcType="BIT" property="primaryKey"/>
<result column="auto_increment" jdbcType="BIT" property="autoIncrement"/>
<result column="nullable" jdbcType="BIT" property="nullable"/>
<result column="primary_key" jdbcType="BOOLEAN" property="primaryKey"/>
<result column="auto_increment" jdbcType="BOOLEAN" property="autoIncrement"/>
<result column="nullable" jdbcType="BOOLEAN" property="nullable"/>
<result column="column_default" jdbcType="VARCHAR" property="columnDefault"/>
<result column="column_show_order" jdbcType="INTEGER" property="columnShowOrder"/>
<result column="column_comment" jdbcType="VARCHAR" property="columnComment"/>
<result column="object_field_name" jdbcType="VARCHAR" property="objectFieldName"/>
<result column="object_field_type" jdbcType="VARCHAR" property="objectFieldType"/>
<result column="filter_type" jdbcType="INTEGER" property="filterType"/>
<result column="parent_key" jdbcType="BIT" property="parentKey"/>
<result column="dept_filter" jdbcType="BIT" property="deptFilter"/>
<result column="user_filter" jdbcType="BIT" property="userFilter"/>
<result column="parent_key" jdbcType="BOOLEAN" property="parentKey"/>
<result column="dept_filter" jdbcType="BOOLEAN" property="deptFilter"/>
<result column="user_filter" jdbcType="BOOLEAN" property="userFilter"/>
<result column="field_kind" jdbcType="INTEGER" property="fieldKind"/>
<result column="max_file_count" jdbcType="INTEGER" property="maxFileCount"/>
<result column="dict_id" jdbcType="BIGINT" property="dictId"/>
@@ -49,8 +49,6 @@
<where>
<include refid="filterRef"/>
</where>
<if test="orderBy != null and orderBy != ''">
ORDER BY ${orderBy}
</if>
ORDER BY column_show_order
</select>
</mapper>

View File

@@ -10,8 +10,8 @@
<result column="master_column_id" jdbcType="BIGINT" property="masterColumnId"/>
<result column="slave_table_id" jdbcType="BIGINT" property="slaveTableId"/>
<result column="slave_column_id" jdbcType="BIGINT" property="slaveColumnId"/>
<result column="cascade_delete" jdbcType="BIT" property="cascadeDelete"/>
<result column="left_join" jdbcType="BIT" property="leftJoin"/>
<result column="cascade_delete" jdbcType="BOOLEAN" property="cascadeDelete"/>
<result column="left_join" jdbcType="BOOLEAN" property="leftJoin"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
</resultMap>

View File

@@ -14,7 +14,7 @@
<result column="user_filter_column_name" jdbcType="VARCHAR" property="userFilterColumnName"/>
<result column="dept_filter_column_name" jdbcType="VARCHAR" property="deptFilterColumnName"/>
<result column="tenant_filter_column_name" jdbcType="VARCHAR" property="tenantFilterColumnName"/>
<result column="tree_flag" jdbcType="BIT" property="treeFlag"/>
<result column="tree_flag" jdbcType="BOOLEAN" property="treeFlag"/>
<result column="dict_list_url" jdbcType="VARCHAR" property="dictListUrl"/>
<result column="dict_ids_url" jdbcType="VARCHAR" property="dictIdsUrl"/>
<result column="dict_data_json" jdbcType="LONGVARCHAR" property="dictDataJson"/>

View File

@@ -7,7 +7,7 @@
<result column="page_name" jdbcType="VARCHAR" property="pageName"/>
<result column="page_type" jdbcType="INTEGER" property="pageType"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="published" jdbcType="BIT" property="published"/>
<result column="published" jdbcType="BOOLEAN" property="published"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
</resultMap>

View File

@@ -5,7 +5,7 @@
<id column="rule_id" jdbcType="BIGINT" property="ruleId"/>
<result column="rule_name" jdbcType="VARCHAR" property="ruleName"/>
<result column="rule_type" jdbcType="INTEGER" property="ruleType"/>
<result column="builtin" jdbcType="BIT" property="builtin"/>
<result column="builtin" jdbcType="BOOLEAN" property="builtin"/>
<result column="pattern" jdbcType="VARCHAR" property="pattern"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>

View File

@@ -0,0 +1,24 @@
package com.orangeforms.common.online.object;
import lombok.Data;
import java.util.List;
/**
* 在线表单常量字典的数据结构。
*
* @author Jerry
* @date 2021-06-06
*/
@Data
public class ConstDictInfo {
private List<ConstDictData> dictData;
@Data
public static class ConstDictData {
private String type;
private Object id;
private String name;
}
}

View File

@@ -1,7 +1,6 @@
package com.orangeforms.common.online.service;
import com.orangeforms.common.core.base.service.IBaseService;
import com.orangeforms.common.core.object.CallResult;
import com.orangeforms.common.online.model.OnlineColumn;
import com.orangeforms.common.online.model.OnlineColumnRule;
import com.orangeforms.common.online.object.SqlTableColumn;
@@ -105,22 +104,20 @@ public interface OnlineColumnService extends IBaseService<OnlineColumn, Long> {
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @param filter 过滤对象。
* @return 查询结果集。
*/
List<OnlineColumn> getOnlineColumnList(OnlineColumn filter, String orderBy);
List<OnlineColumn> getOnlineColumnList(OnlineColumn filter);
/**
* 获取主表的查询结果,以及主表关联的字典数据和一对一从表数据,以及一对一从表的字典数据。
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序参数。
* @param filter 主表过滤对象。
* @return 查询结果集。
*/
List<OnlineColumn> getOnlineColumnListWithRelation(OnlineColumn filter, String orderBy);
List<OnlineColumn> getOnlineColumnListWithRelation(OnlineColumn filter);
/**
* 获取指定数据表Id集合的字段对象列表。

View File

@@ -8,8 +8,10 @@ import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.base.service.BaseService;
import com.orangeforms.common.core.object.CallResult;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.core.config.CoreProperties;
import com.orangeforms.common.core.util.RedisKeyUtil;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
import com.orangeforms.common.online.config.OnlineProperties;
import com.orangeforms.common.online.dao.OnlineColumnMapper;
import com.orangeforms.common.online.dao.OnlineColumnRuleMapper;
import com.orangeforms.common.online.model.OnlineColumn;
@@ -51,6 +53,8 @@ public class OnlineColumnServiceImpl extends BaseService<OnlineColumn, Long> imp
private IdGeneratorWrapper idGenerator;
@Autowired
private RedissonClient redissonClient;
@Autowired
private OnlineProperties onlineProperties;
/**
* 返回当前Service的主表Mapper对象。
@@ -168,13 +172,12 @@ public class OnlineColumnServiceImpl extends BaseService<OnlineColumn, Long> imp
* 获取单表查询结果。由于没有关联数据查询,因此在仅仅获取单表数据的场景下,效率更高。
* 如果需要同时获取关联数据,请移步(getOnlineColumnListWithRelation)方法。
*
* @param filter 过滤对象。
* @param orderBy 排序参数。
* @param filter 过滤对象。
* @return 查询结果集。
*/
@Override
public List<OnlineColumn> getOnlineColumnList(OnlineColumn filter, String orderBy) {
return onlineColumnMapper.getOnlineColumnList(filter, orderBy);
public List<OnlineColumn> getOnlineColumnList(OnlineColumn filter) {
return onlineColumnMapper.getOnlineColumnList(filter);
}
/**
@@ -182,13 +185,12 @@ public class OnlineColumnServiceImpl extends BaseService<OnlineColumn, Long> imp
* 该查询会涉及到一对一从表的关联过滤,或一对多从表的嵌套关联过滤,因此性能不如单表过滤。
* 如果仅仅需要获取主表数据,请移步(getOnlineColumnList),以便获取更好的查询性能。
*
* @param filter 主表过滤对象。
* @param orderBy 排序参数。
* @param filter 主表过滤对象。
* @return 查询结果集。
*/
@Override
public List<OnlineColumn> getOnlineColumnListWithRelation(OnlineColumn filter, String orderBy) {
List<OnlineColumn> resultList = onlineColumnMapper.getOnlineColumnList(filter, orderBy);
public List<OnlineColumn> getOnlineColumnListWithRelation(OnlineColumn filter) {
List<OnlineColumn> resultList = onlineColumnMapper.getOnlineColumnList(filter);
// 在缺省生成的代码中如果查询结果resultList不是Page对象说明没有分页那么就很可能是数据导出接口调用了当前方法。
// 为了避免一次性的大量数据关联,规避因此而造成的系统运行性能冲击,这里手动进行了分批次读取,开发者可按需修改该值。
int batchSize = resultList instanceof Page ? 0 : 1000;
@@ -325,41 +327,75 @@ public class OnlineColumnServiceImpl extends BaseService<OnlineColumn, Long> imp
}
private String convertToJavaType(String columnType) {
if ("varchar".equals(columnType)
|| "char".equals(columnType)
|| "text".equals(columnType)
|| "longtext".equals(columnType)
|| "mediumtext".equals(columnType)
|| "tinytext".equals(columnType)) {
return "String";
}
if ("int".equals(columnType)
|| "mediumint".equals(columnType)
|| "smallint".equals(columnType)
|| "tinyint".equals(columnType)) {
return "Integer";
}
if ("bit".equals(columnType)) {
return "Boolean";
}
if ("bigint".equals(columnType)) {
return "Long";
}
if ("decimal".equals(columnType)) {
return "BigDecimal";
}
if ("float".equals(columnType)
|| "double".equals(columnType)) {
return "Double";
}
if ("date".equals(columnType)
|| "datetime".equals(columnType)
|| "timestamp".equals(columnType)
|| "time".equals(columnType)) {
return "Date";
}
if ("blob".equals(columnType)) {
return "byte[]";
if (onlineProperties.getDatabaseType().equals(CoreProperties.MYSQL_TYPE)) {
if ("varchar".equals(columnType)
|| "char".equals(columnType)
|| "text".equals(columnType)
|| "longtext".equals(columnType)
|| "mediumtext".equals(columnType)
|| "tinytext".equals(columnType)) {
return "String";
}
if ("int".equals(columnType)
|| "mediumint".equals(columnType)
|| "smallint".equals(columnType)
|| "tinyint".equals(columnType)) {
return "Integer";
}
if ("bit".equals(columnType)) {
return "Boolean";
}
if ("bigint".equals(columnType)) {
return "Long";
}
if ("decimal".equals(columnType)) {
return "BigDecimal";
}
if ("float".equals(columnType)
|| "double".equals(columnType)) {
return "Double";
}
if ("date".equals(columnType)
|| "datetime".equals(columnType)
|| "timestamp".equals(columnType)
|| "time".equals(columnType)) {
return "Date";
}
if ("blob".equals(columnType)) {
return "byte[]";
}
} else if (onlineProperties.getDatabaseType().equals(CoreProperties.POSTGRESQL_TYPE)) {
if ("varchar".equals(columnType)
|| "char".equals(columnType)
|| "text".equals(columnType)) {
return "String";
}
if ("int4".equals(columnType)
|| "int2".equals(columnType)
|| "bit".equals(columnType)) {
return "Integer";
}
if ("bool".equals(columnType)) {
return "Boolean";
}
if ("int8".equals(columnType)) {
return "Long";
}
if ("numeric".equals(columnType)) {
return "BigDecimal";
}
if ("float4".equals(columnType)
|| "float8".equals(columnType)) {
return "Double";
}
if ("date".equals(columnType)
|| "timestamp".equals(columnType)
|| "time".equals(columnType)) {
return "Date";
}
if ("bytea".equals(columnType)) {
return "byte[]";
}
}
throw new RuntimeException("Unsupported Data Type");
}

View File

@@ -1,8 +1,11 @@
package com.orangeforms.common.online.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.util.StrUtil;
import com.orangeforms.common.core.base.dao.BaseDaoMapper;
import com.orangeforms.common.core.base.service.BaseService;
import com.orangeforms.common.core.config.CoreProperties;
import com.orangeforms.common.core.config.DataSourceContextHolder;
import com.orangeforms.common.core.object.MyRelationParam;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
@@ -166,7 +169,16 @@ public class OnlineDblinkServiceImpl extends BaseService<OnlineDblink, Long> imp
resultList.forEach(r -> {
SqlTableColumn sqlTableColumn =
BeanUtil.mapToBean(r, SqlTableColumn.class, false, null);
sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra()));
if (onlineProperties.getDatabaseType().equals(CoreProperties.POSTGRESQL_TYPE)) {
if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "char", "varchar")) {
sqlTableColumn.setFullColumnType(
sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")");
} else {
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType());
}
} else if (onlineProperties.getDatabaseType().equals(CoreProperties.MYSQL_TYPE)) {
sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra()));
}
columnList.add(sqlTableColumn);
});
return columnList;
@@ -191,9 +203,18 @@ public class OnlineDblinkServiceImpl extends BaseService<OnlineDblink, Long> imp
if (result == null) {
return null;
}
SqlTableColumn sqlTableColumn =
BeanUtil.mapToBean(result, SqlTableColumn.class, false, null);
sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra()));
SqlTableColumn sqlTableColumn = BeanUtil.mapToBean(
result, SqlTableColumn.class, false, CopyOptions.create().ignoreCase());
if (onlineProperties.getDatabaseType().equals(CoreProperties.POSTGRESQL_TYPE)) {
if (StrUtil.equalsAny(sqlTableColumn.getColumnType(), "char", "varchar")) {
sqlTableColumn.setFullColumnType(
sqlTableColumn.getColumnType() + "(" + sqlTableColumn.getStringPrecision() + ")");
} else {
sqlTableColumn.setFullColumnType(sqlTableColumn.getColumnType());
}
} else if (onlineProperties.getDatabaseType().equals(CoreProperties.MYSQL_TYPE)) {
sqlTableColumn.setAutoIncrement("auto_increment".equals(sqlTableColumn.getExtra()));
}
return sqlTableColumn;
} finally {
DataSourceContextHolder.unset(originalType);

View File

@@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.orangeforms.common.core.annotation.MyDataSourceResolver;
import com.orangeforms.common.core.config.CoreProperties;
@@ -19,6 +20,7 @@ import com.orangeforms.common.datafilter.constant.DataPermRuleType;
import com.orangeforms.common.datafilter.config.DataFilterProperties;
import com.orangeforms.common.online.config.OnlineProperties;
import com.orangeforms.common.online.model.constant.*;
import com.orangeforms.common.online.object.ConstDictInfo;
import com.orangeforms.common.online.service.OnlineVirtualColumnService;
import com.orangeforms.common.online.util.OnlineOperationHelper;
import com.orangeforms.common.sequence.wrapper.IdGeneratorWrapper;
@@ -75,14 +77,14 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
/**
* 聚合返回数据中,聚合键的常量字段名。
* 如select groupColumn groupedKey, max(aggregationColumn) aggregatedValue。
* 如select groupColumn grouped_key, max(aggregationColumn) aggregated_value。
*/
private static final String KEY_NAME = "groupedKey";
private static final String KEY_NAME = "grouped_key";
/**
* 聚合返回数据中,聚合值的常量字段名。
* 如select groupColumn groupedKey, max(aggregationColumn) aggregatedValue。
* 如select groupColumn grouped_key, max(aggregationColumn) aggregated_value。
*/
private static final String VALUE_NAME = "aggregatedValue";
private static final String VALUE_NAME = "aggregated_value";
@Transactional(rollbackFor = Exception.class)
@Override
@@ -556,8 +558,10 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
if (CollUtil.isEmpty(dictIdSet)) {
return;
}
List<OnlineDict> dictList = onlineDictService.getOnlineDictList(dictIdSet)
.stream().filter(d -> d.getDictType() == DictType.TABLE).collect(Collectors.toList());
List<OnlineDict> allDictList = onlineDictService.getOnlineDictList(dictIdSet);
List<OnlineDict> dictList = allDictList.stream()
.filter(d -> d.getDictType() == DictType.TABLE || d.getDictType() == DictType.CUSTOM)
.collect(Collectors.toList());
for (OnlineDict dict : dictList) {
Collection<String> columnNameList = dictColumnMap.get(dict.getDictId());
for (String columnName : columnNameList) {
@@ -571,27 +575,38 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
if (CollUtil.isEmpty(dictIdDataSet)) {
continue;
}
String selectFields = this.makeDictSelectFields(dict, true);
List<OnlineFilterDto> filterList = new LinkedList<>();
if (StrUtil.isNotBlank(dict.getDeletedColumnName())) {
OnlineFilterDto filter = new OnlineFilterDto();
filter.setColumnName(dict.getDeletedColumnName());
filter.setColumnValue(GlobalDeletedFlag.NORMAL);
filterList.add(filter);
}
OnlineFilterDto inlistFilter = new OnlineFilterDto();
inlistFilter.setColumnName(dict.getKeyColumnName());
inlistFilter.setColumnValueList(dictIdDataSet);
inlistFilter.setFilterType(FieldFilterType.IN_LIST_FILTER);
filterList.add(inlistFilter);
List<Map<String, Object>> dictResultList =
onlineOperationMapper.getDictList(dict.getTableName(), selectFields, filterList, null);
if (CollUtil.isEmpty(dictResultList)) {
continue;
}
Map<Object, Object> dictResultMap = new HashMap<>(dictResultList.size());
for (Map<String, Object> dictResult : dictResultList) {
dictResultMap.put(dictResult.get("id"), dictResult.get("name"));
Map<Object, Object> dictResultMap;
if (dict.getDictType().equals(DictType.CUSTOM)) {
ConstDictInfo dictInfo =
JSONObject.parseObject(dict.getDictDataJson(), ConstDictInfo.class);
List<ConstDictInfo.ConstDictData> dictDataList = dictInfo.getDictData();
dictResultMap = new HashMap<>(dictDataList.size());
for (ConstDictInfo.ConstDictData dictData : dictDataList) {
dictResultMap.put(dictData.getId(), dictData.getName());
}
} else {
String selectFields = this.makeDictSelectFields(dict, true);
List<OnlineFilterDto> filterList = new LinkedList<>();
if (StrUtil.isNotBlank(dict.getDeletedColumnName())) {
OnlineFilterDto filter = new OnlineFilterDto();
filter.setColumnName(dict.getDeletedColumnName());
filter.setColumnValue(GlobalDeletedFlag.NORMAL);
filterList.add(filter);
}
OnlineFilterDto inlistFilter = new OnlineFilterDto();
inlistFilter.setColumnName(dict.getKeyColumnName());
inlistFilter.setColumnValueList(dictIdDataSet);
inlistFilter.setFilterType(FieldFilterType.IN_LIST_FILTER);
filterList.add(inlistFilter);
List<Map<String, Object>> dictResultList =
onlineOperationMapper.getDictList(dict.getTableName(), selectFields, filterList, null);
if (CollUtil.isEmpty(dictResultList)) {
continue;
}
dictResultMap = new HashMap<>(dictResultList.size());
for (Map<String, Object> dictResult : dictResultList) {
dictResultMap.put(dictResult.get("id"), dictResult.get("name"));
}
}
String dictKeyName = columnName + "__DictMap";
for (Map<String, Object> result : resultList) {
@@ -664,32 +679,32 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
.append(column.getColumnName())
.append(" AS ")
.append(intString)
.append(") ")
.append(") \"")
.append(relationVariableName)
.append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)
.append(column.getColumnName())
.append(",");
.append("\",");
} else if ("date".equals(column.getColumnType())) {
selectFieldBuider
.append("CAST(")
.append(slaveTable.getTableName())
.append(".")
.append(column.getColumnName())
.append(" AS CHAR(10)) ")
.append(" AS CHAR(10)) \"")
.append(relationVariableName)
.append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)
.append(column.getColumnName())
.append(",");
.append("\",");
} else {
selectFieldBuider
.append(slaveTable.getTableName())
.append(".")
.append(column.getColumnName())
.append(" ")
.append(" \"")
.append(relationVariableName)
.append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)
.append(column.getColumnName())
.append(",");
.append("\",");
}
}
return selectFieldBuider.substring(0, selectFieldBuider.length() - 1);
@@ -718,32 +733,32 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
.append(column.getColumnName())
.append(" AS ")
.append(intString)
.append(") ")
.append(") \"")
.append(relation.getVariableName())
.append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)
.append(column.getColumnName())
.append(",");
.append("\",");
} else if ("date".equals(column.getColumnType())) {
selectFieldBuider
.append("CAST(")
.append(slaveTable.getTableName())
.append(".")
.append(column.getColumnName())
.append(" AS CHAR(10)) ")
.append(" AS CHAR(10)) \"")
.append(relation.getVariableName())
.append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)
.append(column.getColumnName())
.append(",");
.append("\",");
} else {
selectFieldBuider
.append(slaveTable.getTableName())
.append(".")
.append(column.getColumnName())
.append(" ")
.append(" \"")
.append(relation.getVariableName())
.append(OnlineConstant.RELATION_TABLE_COLUMN_SEPARATOR)
.append(column.getColumnName())
.append(",");
.append("\",");
}
}
}
@@ -762,18 +777,18 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
.append(column.getColumnName())
.append(" AS ")
.append(intString)
.append(") ")
.append(") \"")
.append(column.getColumnName())
.append(",");
.append("\",");
} else if ("date".equals(column.getColumnType())) {
selectFieldBuider
.append("CAST(")
.append(masterTable.getTableName())
.append(".")
.append(column.getColumnName())
.append(" AS CHAR(10)) ")
.append(" AS CHAR(10)) \"")
.append(column.getColumnName())
.append(",");
.append("\",");
} else {
selectFieldBuider
.append(masterTable.getTableName())
@@ -787,10 +802,10 @@ public class OnlineOperationServiceImpl implements OnlineOperationService {
private String makeDictSelectFields(OnlineDict onlineDict, boolean ignoreParentId) {
StringBuilder sb = new StringBuilder(128);
sb.append(onlineDict.getKeyColumnName()).append(" id, ");
sb.append(onlineDict.getValueColumnName()).append(" name");
sb.append(onlineDict.getKeyColumnName()).append(" \"id\", ");
sb.append(onlineDict.getValueColumnName()).append(" \"name\"");
if (!ignoreParentId && onlineDict.getTreeFlag()) {
sb.append(", ").append(onlineDict.getParentKeyColumnName()).append(" parentId");
sb.append(", ").append(onlineDict.getParentKeyColumnName()).append(" \"parentId\"");
}
return sb.toString();
}

View File

@@ -1,6 +1,7 @@
package com.orangeforms.common.online.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@@ -114,10 +115,6 @@ public class OnlineOperationHelper {
if (relation == null || !relation.getDatasourceId().equals(datasourceId)) {
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST);
}
if (!relation.getRelationType().equals(RelationType.ONE_TO_MANY)) {
errorMessage = "数据验证失败,数据源关联 [" + relation.getRelationName() + " ] 不是一对多关联,不能调用该接口!";
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, errorMessage);
}
OnlineTable slaveTable = onlineTableService.getOnlineTableFromCache(relation.getSlaveTableId());
if (slaveTable == null) {
errorMessage = "数据验证失败,数据源关联 [" + relation.getRelationName() + " ] 引用的从表不存在!";
@@ -173,6 +170,13 @@ public class OnlineOperationHelper {
continue;
}
Object value = tableData.get(column.getColumnName());
if (value != null) {
if ("Long".equals(column.getObjectFieldType())) {
value = Long.valueOf(value.toString());
} else if ("Date".equals(column.getObjectFieldType())) {
value = Convert.toDate(value);
}
}
// 对于主键数据的处理。
if (column.getPrimaryKey()) {
// 如果是更新则必须包含主键参数。