|
@@ -1,9 +1,7 @@
|
|
|
package org.springblade.flow.visual.onlinedev.controller;
|
|
|
|
|
|
import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
import java.sql.SQLException;
|
|
|
-import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
@@ -17,6 +15,7 @@ import org.springblade.bi.client.model.CubeDataModel;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.support.Kv;
|
|
|
import org.springblade.flow.base.ActionResult;
|
|
|
import org.springblade.flow.base.util.FlowDataUtil;
|
|
|
import org.springblade.flow.config.ConfigValueUtil;
|
|
@@ -25,16 +24,13 @@ import org.springblade.flow.datalog.common.ExportService;
|
|
|
import org.springblade.flow.datalog.model.DataExportTask;
|
|
|
import org.springblade.flow.datalog.params.DataExportParam;
|
|
|
import org.springblade.flow.datalog.service.DataExportTaskService;
|
|
|
+import org.springblade.flow.datalog.service.DataImportLogService;
|
|
|
import org.springblade.flow.datalog.service.FormDataLogService;
|
|
|
import org.springblade.flow.engine.entity.FlowEngineEntity;
|
|
|
import org.springblade.flow.engine.service.FlowEngineService;
|
|
|
import org.springblade.flow.engine.service.FlowTaskService;
|
|
|
import org.springblade.flow.exception.WorkFlowException;
|
|
|
-import org.springblade.flow.model.visiual.OnlineDevData;
|
|
|
-import org.springblade.flow.model.visiual.fields.FieldsModel;
|
|
|
-import org.springblade.flow.util.CacheKeyUtil;
|
|
|
import org.springblade.flow.util.JsonUtil;
|
|
|
-import org.springblade.flow.util.JsonUtilEx;
|
|
|
import org.springblade.flow.util.RedisUtil;
|
|
|
import org.springblade.flow.util.StringUtil;
|
|
|
import org.springblade.flow.util.UserProvider;
|
|
@@ -46,24 +42,19 @@ import org.springblade.flow.visual.base.entity.VisualdevEntity;
|
|
|
import org.springblade.flow.visual.base.service.VisualdevService;
|
|
|
import org.springblade.flow.visual.base.service.impl.DataPermissionUserService;
|
|
|
import org.springblade.flow.visual.base.service.impl.VisualdevDataPermissionService;
|
|
|
-import org.springblade.flow.visual.base.util.VisualUtils;
|
|
|
import org.springblade.flow.visual.onlinedev.common.dynamic.DataSourceService;
|
|
|
import org.springblade.flow.visual.onlinedev.common.excel.ExcelFormParam;
|
|
|
import org.springblade.flow.visual.onlinedev.common.formdata.FormDataWithTableService;
|
|
|
import org.springblade.flow.visual.onlinedev.common.relation.RelationField;
|
|
|
import org.springblade.flow.visual.onlinedev.common.relation.RelationUtil;
|
|
|
-import org.springblade.flow.visual.onlinedev.entity.VisualdevModelDataEntity;
|
|
|
import org.springblade.flow.visual.onlinedev.model.BatchRemoveIdsVo;
|
|
|
import org.springblade.flow.visual.onlinedev.model.ColumnDataInfoVO;
|
|
|
import org.springblade.flow.visual.onlinedev.model.DataInfoVO;
|
|
|
import org.springblade.flow.visual.onlinedev.model.FlowTemplateInfoVo;
|
|
|
import org.springblade.flow.visual.onlinedev.model.FormDataInfoVO;
|
|
|
-import org.springblade.flow.visual.onlinedev.model.PaginationModel;
|
|
|
import org.springblade.flow.visual.onlinedev.model.VisualdevModelDataCrForm;
|
|
|
-import org.springblade.flow.visual.onlinedev.model.VisualdevModelDataInfoVO;
|
|
|
import org.springblade.flow.visual.onlinedev.model.VisualdevModelDataUpForm;
|
|
|
import org.springblade.flow.visual.onlinedev.service.VisualdevModelDataService;
|
|
|
-import org.springblade.flow.visual.onlinedev.util.AutoFeildsUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
@@ -146,6 +137,9 @@ public class VisualdevModelDataController extends BladeController {
|
|
|
@Autowired
|
|
|
private ExportService exportService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private DataImportLogService importLogService;
|
|
|
+
|
|
|
@ApiOperation("表单操作 - 获取列表表单配置JSON")
|
|
|
@GetMapping("/{modelId}/Config")
|
|
|
public ActionResult<Object> getData(@PathVariable("modelId") String modelId) {
|
|
@@ -195,55 +189,66 @@ public class VisualdevModelDataController extends BladeController {
|
|
|
return ActionResult.success(vo);
|
|
|
}
|
|
|
|
|
|
- @ApiOperation("数据操作 - 分页查询")
|
|
|
- @PostMapping("/{modelId}/List")
|
|
|
- public ActionResult<?> list(@PathVariable("modelId") String modelId, @RequestBody PaginationModel paginationModel)
|
|
|
- throws ParseException, IOException, SQLException, DataException {
|
|
|
- VisualdevEntity visualdevEntity = visualdevService.getInfo(modelId);
|
|
|
- return formDataWithTableService.list(visualdevEntity, paginationModel);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("数据操作 - 数据详情")
|
|
|
- @GetMapping("/{modelId}/{id}")
|
|
|
- public ActionResult<VisualdevModelDataInfoVO> info(@PathVariable("id") String id,
|
|
|
- @PathVariable("modelId") String modelId) throws DataException, ParseException, SQLException, IOException {
|
|
|
- VisualdevEntity visualdevEntity = visualdevService.getInfo(modelId);
|
|
|
- // 有表
|
|
|
- if (!StringUtil.isEmpty(visualdevEntity.getTables())
|
|
|
- && !OnlineDevData.TABLE_CONST.equals(visualdevEntity.getTables())) {
|
|
|
- VisualdevModelDataInfoVO vo = visualdevModelDataService.tableInfo(id, visualdevEntity);
|
|
|
- return ActionResult.success(vo);
|
|
|
- }
|
|
|
- // 无表
|
|
|
- VisualdevModelDataEntity entity = visualdevModelDataService.getInfo(id);
|
|
|
- Map<String, Object> formData = JsonUtil.stringToMap(visualdevEntity.getFormData());
|
|
|
- List<FieldsModel> modelList = JsonUtil.getJsonToList(formData.get("fields").toString(), FieldsModel.class);
|
|
|
- // 去除模板多级控件
|
|
|
- modelList = VisualUtils.deleteMore(modelList);
|
|
|
- String data = AutoFeildsUtil.autoFeilds(modelList, entity.getData());
|
|
|
- entity.setData(data);
|
|
|
- VisualdevModelDataInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, VisualdevModelDataInfoVO.class);
|
|
|
- return ActionResult.success(vo);
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation("数据操作 - 详情(带转换数据)")
|
|
|
- @GetMapping("/{modelId}/{id}/DataChange")
|
|
|
- public ActionResult<VisualdevModelDataInfoVO> infoWithDataChange(@PathVariable("modelId") String modelId,
|
|
|
- @PathVariable("id") String id) throws DataException, ParseException, IOException, SQLException {
|
|
|
- VisualdevEntity visualdevEntity = visualdevService.getInfo(modelId);
|
|
|
- if (redisUtil.exists(CacheKeyUtil.VISIUALDATA + modelId)) {
|
|
|
- redisUtil.remove(CacheKeyUtil.VISIUALDATA + modelId);
|
|
|
- }
|
|
|
- // 有表
|
|
|
- if (!StringUtil.isEmpty(visualdevEntity.getTables())
|
|
|
- && !OnlineDevData.TABLE_CONST.equals(visualdevEntity.getTables())) {
|
|
|
- VisualdevModelDataInfoVO vo = visualdevModelDataService.tableInfoDataChange(id, visualdevEntity);
|
|
|
- return ActionResult.success(vo);
|
|
|
- }
|
|
|
- // 无表
|
|
|
- VisualdevModelDataInfoVO vo = visualdevModelDataService.infoDataChange(id, visualdevEntity);
|
|
|
- return ActionResult.success(vo);
|
|
|
- }
|
|
|
+ // @ApiOperation("数据操作 - 分页查询")
|
|
|
+ // @PostMapping("/{modelId}/List")
|
|
|
+ // public ActionResult<?> list(@PathVariable("modelId") String modelId,
|
|
|
+ // @RequestBody PaginationModel paginationModel)
|
|
|
+ // throws ParseException, IOException, SQLException, DataException {
|
|
|
+ // VisualdevEntity visualdevEntity = visualdevService.getInfo(modelId);
|
|
|
+ // return formDataWithTableService.list(visualdevEntity, paginationModel);
|
|
|
+ // }
|
|
|
+
|
|
|
+ // @ApiOperation("数据操作 - 数据详情")
|
|
|
+ // @GetMapping("/{modelId}/{id}")
|
|
|
+ // public ActionResult<VisualdevModelDataInfoVO> info(@PathVariable("id") String
|
|
|
+ // id,
|
|
|
+ // @PathVariable("modelId") String modelId) throws DataException,
|
|
|
+ // ParseException, SQLException, IOException {
|
|
|
+ // VisualdevEntity visualdevEntity = visualdevService.getInfo(modelId);
|
|
|
+ // // 有表
|
|
|
+ // if (!StringUtil.isEmpty(visualdevEntity.getTables())
|
|
|
+ // && !OnlineDevData.TABLE_CONST.equals(visualdevEntity.getTables())) {
|
|
|
+ // VisualdevModelDataInfoVO vo = visualdevModelDataService.tableInfo(id,
|
|
|
+ // visualdevEntity);
|
|
|
+ // return ActionResult.success(vo);
|
|
|
+ // }
|
|
|
+ // // 无表
|
|
|
+ // VisualdevModelDataEntity entity = visualdevModelDataService.getInfo(id);
|
|
|
+ // Map<String, Object> formData =
|
|
|
+ // JsonUtil.stringToMap(visualdevEntity.getFormData());
|
|
|
+ // List<FieldsModel> modelList =
|
|
|
+ // JsonUtil.getJsonToList(formData.get("fields").toString(), FieldsModel.class);
|
|
|
+ // // 去除模板多级控件
|
|
|
+ // modelList = VisualUtils.deleteMore(modelList);
|
|
|
+ // String data = AutoFeildsUtil.autoFeilds(modelList, entity.getData());
|
|
|
+ // entity.setData(data);
|
|
|
+ // VisualdevModelDataInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity,
|
|
|
+ // VisualdevModelDataInfoVO.class);
|
|
|
+ // return ActionResult.success(vo);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // @ApiOperation("数据操作 - 详情(带转换数据)")
|
|
|
+ // @GetMapping("/{modelId}/{id}/DataChange")
|
|
|
+ // public ActionResult<VisualdevModelDataInfoVO>
|
|
|
+ // infoWithDataChange(@PathVariable("modelId") String modelId,
|
|
|
+ // @PathVariable("id") String id) throws DataException, ParseException,
|
|
|
+ // IOException, SQLException {
|
|
|
+ // VisualdevEntity visualdevEntity = visualdevService.getInfo(modelId);
|
|
|
+ // if (redisUtil.exists(CacheKeyUtil.VISIUALDATA + modelId)) {
|
|
|
+ // redisUtil.remove(CacheKeyUtil.VISIUALDATA + modelId);
|
|
|
+ // }
|
|
|
+ // // 有表
|
|
|
+ // if (!StringUtil.isEmpty(visualdevEntity.getTables())
|
|
|
+ // && !OnlineDevData.TABLE_CONST.equals(visualdevEntity.getTables())) {
|
|
|
+ // VisualdevModelDataInfoVO vo =
|
|
|
+ // visualdevModelDataService.tableInfoDataChange(id, visualdevEntity);
|
|
|
+ // return ActionResult.success(vo);
|
|
|
+ // }
|
|
|
+ // // 无表
|
|
|
+ // VisualdevModelDataInfoVO vo = visualdevModelDataService.infoDataChange(id,
|
|
|
+ // visualdevEntity);
|
|
|
+ // return ActionResult.success(vo);
|
|
|
+ // }
|
|
|
|
|
|
@ApiOperation("数据操作 - 添加")
|
|
|
@PostMapping("/{modelId}")
|
|
@@ -255,7 +260,7 @@ public class VisualdevModelDataController extends BladeController {
|
|
|
|
|
|
@ApiOperation("数据操作 - Excel导入")
|
|
|
@PostMapping("/createBatch")
|
|
|
- public ActionResult<String> createBatch(@RequestBody ExcelFormParam params) throws WorkFlowException, SQLException {
|
|
|
+ public ActionResult<Kv> createBatch(@RequestBody ExcelFormParam params) throws WorkFlowException, SQLException {
|
|
|
if (params == null) {
|
|
|
return ActionResult.fail("缺少参数");
|
|
|
}
|
|
@@ -275,21 +280,24 @@ public class VisualdevModelDataController extends BladeController {
|
|
|
if (formInfo == null) {
|
|
|
return ActionResult.fail("表单不存在");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
CubeDataModel cubeData = dataSourceService.getCubeData(formInfo.getDbLinkId());
|
|
|
- if (RelationUtil.hasLinkTable(cubeData)) {
|
|
|
- return formDataWithTableService.batchAddForMultipleTable(cubeData,
|
|
|
- params.getWithHeader(),
|
|
|
- formInfo,
|
|
|
- params.getList(),
|
|
|
- excelFile);
|
|
|
+ if(params.isTruncate()) {
|
|
|
+ //先清空数据
|
|
|
+ formDataWithTableService.truncate(cubeData,formInfo);
|
|
|
}
|
|
|
|
|
|
- return formDataWithTableService.batchAddForSingleTable(cubeData,
|
|
|
+ boolean isMultipleTable = RelationUtil.hasLinkTable(cubeData);
|
|
|
+ ActionResult<Kv> ret = formDataWithTableService.batchAdd(cubeData,
|
|
|
params.getWithHeader(),
|
|
|
formInfo,
|
|
|
params.getList(),
|
|
|
- excelFile);
|
|
|
+ excelFile,
|
|
|
+ isMultipleTable);
|
|
|
+ long total = ret.getData().getLong("count");
|
|
|
+ float takeUpTime = ret.getData().getFloat("takeUpTime");
|
|
|
+ importLogService.saveLog(params, total, cubeData.getId(), takeUpTime);
|
|
|
+ return ret;
|
|
|
}
|
|
|
|
|
|
@ApiOperation("数据操作 - 更新")
|
|
@@ -419,7 +427,7 @@ public class VisualdevModelDataController extends BladeController {
|
|
|
DataExportTask task = DataExportTask.builder()
|
|
|
.id(taskId)
|
|
|
.modelId(param.getModelId())
|
|
|
- .cubeId(form.getDbLinkId())
|
|
|
+ .cubeId(Integer.parseInt(form.getDbLinkId()))
|
|
|
.name(param.getTaskName())
|
|
|
.isAll(param.isAll() ? 1 : 0)
|
|
|
.name(param.getTaskName())
|