Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/flowerfine/carp into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
kalencaya committed Oct 1, 2024
2 parents 04df7bd + 7c97e8d commit 85e6250
Show file tree
Hide file tree
Showing 99 changed files with 1,419 additions and 456 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public class AGEIPortConfig {
public AgeiPort ageiPort() {
AgeiPortOptions options = AgeiPortOptions.debug();

HttpTaskServerClientOptions clientOptions = new HttpTaskServerClientOptions();
clientOptions.setEndpoint("localhost");
options.setTaskServerClientOptions(clientOptions);
// HttpTaskServerClientOptions clientOptions = new HttpTaskServerClientOptions();
// clientOptions.setEndpoint("localhost");
// options.setTaskServerClientOptions(clientOptions);

return AgeiPort.ageiPort(options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
package cn.sliew.carp.example.ageiport.controller;

import cn.sliew.carp.processor.core.TestHelper;
import cn.sliew.carp.processor.core.exporter.DynamicColumnExportProcessor;
import cn.sliew.carp.processor.core.exporter.MultiSheetExportProcessor;
import cn.sliew.carp.processor.core.exporter.StandaloneExportProcessor;
import cn.sliew.carp.processor.core.model.Query;
import cn.sliew.carp.processor.core.model.UserQuery;
import cn.sliew.milky.common.util.JacksonUtil;
import com.alibaba.ageiport.common.utils.JsonUtil;
import com.alibaba.ageiport.processor.core.AgeiPort;
Expand All @@ -31,7 +33,6 @@
import org.junit.jupiter.api.Assertions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -47,12 +48,12 @@ public class ExportController {
@Operation(summary = "测试 Standalone", description = "测试 Standalone")
public void testStandalone() throws Exception {
//2.构造查询参数TaskExecuteParam
Query query = new Query();
UserQuery query = new UserQuery();
query.setTotalCount(1);

//3.调用本地方法executeTask,开始执行任务,并获取任务实例ID。
TaskExecuteParam request = new TaskExecuteParam();
request.setTaskSpecificationCode(StandaloneExportProcessor.class.getSimpleName());
request.setTaskSpecificationCode(DynamicColumnExportProcessor.class.getSimpleName());
request.setBizUserId("userId");
request.setBizQuery(JsonUtil.toJsonString(query));
TaskExecuteResult response = ageiPort.getTaskService().executeTask(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import cn.sliew.carp.processor.core.TestHelper;
import cn.sliew.carp.processor.core.exporter.StandaloneExportProcessor;
import cn.sliew.carp.processor.core.model.Query;
import cn.sliew.carp.processor.core.model.UserQuery;
import cn.sliew.milky.common.util.JacksonUtil;
import com.alibaba.ageiport.common.utils.JsonUtil;
import com.alibaba.ageiport.processor.core.AgeiPort;
Expand All @@ -40,7 +40,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -59,7 +58,7 @@ public class HttpController {
@GetMapping
@Operation(summary = "测试", description = "测试")
public void reqeust() throws Exception {
Query query = new Query();
UserQuery query = new UserQuery();
query.setTotalCount(100);
ExecuteMainTaskRequest executeMainTaskRequest = new ExecuteMainTaskRequest();
executeMainTaskRequest.setTaskSpecificationCode(StandaloneExportProcessor.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cn.sliew.carp.processor.core.exporter;

import cn.sliew.carp.processor.core.model.Data;
import cn.sliew.carp.processor.core.model.Query;
import cn.sliew.carp.processor.core.model.View;
import cn.sliew.carp.processor.core.model.UserData;
import cn.sliew.carp.processor.core.model.UserQuery;
import cn.sliew.carp.processor.core.model.UserView;
import com.alibaba.ageiport.common.utils.BeanUtils;
import com.alibaba.ageiport.processor.core.annotation.ExportSpecification;
import com.alibaba.ageiport.processor.core.exception.BizException;
Expand All @@ -18,24 +18,24 @@

//1.实现ExportProcessor接口
@ExportSpecification(code = "CSVExportProcessor", name = "CSVExportProcessor")
public class CSVExportProcessor implements ExportProcessor<Query, Data, View> {
public class CSVExportProcessor implements ExportProcessor<UserQuery, UserData, UserView> {

//2.实现ExportProcessor接口的TotalCount方法
@Override
public Integer totalCount(BizUser bizUser, Query query) throws BizException {
public Integer totalCount(BizUser bizUser, UserQuery query) throws BizException {
return query.getTotalCount();
}

//3.实现ExportProcessor接口的queryData方法
@Override
public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPage) throws BizException {
List<Data> dataList = new ArrayList<>();
public List<UserData> queryData(BizUser user, UserQuery query, BizExportPage bizExportPage) throws BizException {
List<UserData> dataList = new ArrayList<>();

Integer offset = bizExportPage.getOffset();
Integer size = bizExportPage.getSize();
for (int i = 1; i <= size; i++) {
int index = offset + i;
final Data data = new Data();
final UserData data = new UserData();
data.setId(index);
data.setName("name" + index);
if (index % 3 == 0) {
Expand All @@ -54,16 +54,16 @@ public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPa

//4.实现ExportProcessor接口的convert方法
@Override
public List<View> convert(BizUser user, Query query, List<Data> data) throws BizException {
List<View> dataList = new ArrayList<>();
for (Data datum : data) {
View view = BeanUtils.cloneProp(datum, View.class);
public List<UserView> convert(BizUser user, UserQuery query, List<UserData> data) throws BizException {
List<UserView> dataList = new ArrayList<>();
for (UserData datum : data) {
UserView view = BeanUtils.cloneProp(datum, UserView.class);
dataList.add(view);
}
return dataList;
}

public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, Query query) throws BizException {
public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, UserQuery query) throws BizException {
final BizExportTaskRuntimeConfigImpl runtimeConfig = new BizExportTaskRuntimeConfigImpl();
runtimeConfig.setExecuteType("STANDALONE");
runtimeConfig.setFileType("csv");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cn.sliew.carp.processor.core.exporter;

import cn.sliew.carp.processor.core.model.Data;
import cn.sliew.carp.processor.core.model.Query;
import cn.sliew.carp.processor.core.model.View;
import cn.sliew.carp.processor.core.model.UserData;
import cn.sliew.carp.processor.core.model.UserQuery;
import cn.sliew.carp.processor.core.model.UserView;
import com.alibaba.ageiport.common.utils.BeanUtils;
import com.alibaba.ageiport.processor.core.annotation.ExportSpecification;
import com.alibaba.ageiport.processor.core.constants.ExecuteType;
Expand All @@ -17,19 +17,19 @@
import java.util.List;

@ExportSpecification(code = "ClusterExportProcessor", name = "ClusterExportProcessor", executeType = ExecuteType.CLUSTER)
public class ClusterExportProcessor implements ExportProcessor<Query, Data, View> {
public class ClusterExportProcessor implements ExportProcessor<UserQuery, UserData, UserView> {
@Override
public Integer totalCount(BizUser bizUser, Query query) throws BizException {
public Integer totalCount(BizUser bizUser, UserQuery query) throws BizException {
return query.getTotalCount();
}

@Override
public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPage) throws BizException {
List<Data> dataList = new ArrayList<>();
public List<UserData> queryData(BizUser user, UserQuery query, BizExportPage bizExportPage) throws BizException {
List<UserData> dataList = new ArrayList<>();

Integer totalCount = query.getTotalCount();
for (int i = 1; i <= totalCount; i++) {
final Data data = new Data();
final UserData data = new UserData();
data.setId(i);
data.setName("name" + i);
if (i % 3 == 0) {
Expand All @@ -47,17 +47,17 @@ public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPa
}

@Override
public List<View> convert(BizUser user, Query query, List<Data> data) throws BizException {
List<View> dataList = new ArrayList<>();
for (Data datum : data) {
View view = BeanUtils.cloneProp(datum, View.class);
public List<UserView> convert(BizUser user, UserQuery query, List<UserData> data) throws BizException {
List<UserView> dataList = new ArrayList<>();
for (UserData datum : data) {
UserView view = BeanUtils.cloneProp(datum, UserView.class);
dataList.add(view);
}
return dataList;
}

@Override
public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, Query query) throws BizException {
public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, UserQuery query) throws BizException {
final BizExportTaskRuntimeConfigImpl runtimeConfig = new BizExportTaskRuntimeConfigImpl();
runtimeConfig.setExecuteType("CLUSTER");
return runtimeConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cn.sliew.carp.processor.core.exporter;

import cn.sliew.carp.processor.core.model.Data;
import cn.sliew.carp.processor.core.model.DynamicColumnView;
import cn.sliew.carp.processor.core.model.Query;
import cn.sliew.carp.processor.core.model.UserData;
import cn.sliew.carp.processor.core.model.DynamicColumnUserView;
import cn.sliew.carp.processor.core.model.UserQuery;
import com.alibaba.ageiport.common.collections.Lists;
import com.alibaba.ageiport.common.utils.BeanUtils;
import com.alibaba.ageiport.common.utils.DateUtils;
Expand All @@ -21,16 +21,16 @@

//1.实现ExportProcessor接口
@ExportSpecification(code = "DynamicColumnExportProcessor", name = "DynamicColumnExportProcessor")
public class DynamicColumnExportProcessor implements ExportProcessor<Query, Data, DynamicColumnView> {
public class DynamicColumnExportProcessor implements ExportProcessor<UserQuery, UserData, DynamicColumnUserView> {

//2.实现ExportProcessor接口的TotalCount方法
@Override
public Integer totalCount(BizUser bizUser, Query query) throws BizException {
public Integer totalCount(BizUser bizUser, UserQuery query) throws BizException {
return query.getTotalCount();
}

@Override
public BizDynamicColumnHeaders getDynamicHeaders(BizUser user, Query query) throws BizException {
public BizDynamicColumnHeaders getDynamicHeaders(BizUser user, UserQuery query) throws BizException {
//一般此接口返回值是由query查询数据库or接口获取到的,此处仅为示例,直接由入参传入并构造动态列

Integer dynamicHeaderCount = query.getDynamicHeaderCount();
Expand Down Expand Up @@ -72,14 +72,14 @@ public BizDynamicColumnHeaders getDynamicHeaders(BizUser user, Query query) thro

//3.实现ExportProcessor接口的queryData方法
@Override
public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPage) throws BizException {
List<Data> dataList = new ArrayList<>();
public List<UserData> queryData(BizUser user, UserQuery query, BizExportPage bizExportPage) throws BizException {
List<UserData> dataList = new ArrayList<>();

Integer offset = bizExportPage.getOffset();
Integer size = bizExportPage.getSize();
for (int i = 1; i <= size; i++) {
int index = offset + i;
final Data data = new Data();
final UserData data = new UserData();
data.setId(index);
data.setName("name" + index);
if (index % 3 == 0) {
Expand All @@ -99,13 +99,13 @@ public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPa

//4.实现ExportProcessor接口的convert方法
@Override
public List<DynamicColumnView> convert(BizUser user, Query query, List<Data> data) throws BizException {
List<DynamicColumnView> dataList = new ArrayList<>();
public List<DynamicColumnUserView> convert(BizUser user, UserQuery query, List<UserData> data) throws BizException {
List<DynamicColumnUserView> dataList = new ArrayList<>();

int row = 1;

for (Data datum : data) {
DynamicColumnView view = BeanUtils.cloneProp(datum, DynamicColumnView.class);
for (UserData datum : data) {
DynamicColumnUserView view = BeanUtils.cloneProp(datum, DynamicColumnUserView.class);
dataList.add(view);

Integer dynamicHeaderCount = query.getDynamicHeaderCount();
Expand Down Expand Up @@ -134,7 +134,7 @@ public List<DynamicColumnView> convert(BizUser user, Query query, List<Data> dat
}

@Override
public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, Query query) throws BizException {
public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, UserQuery query) throws BizException {
final BizExportTaskRuntimeConfigImpl runtimeConfig = new BizExportTaskRuntimeConfigImpl();
runtimeConfig.setExecuteType("STANDALONE");
return runtimeConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package cn.sliew.carp.processor.core.exporter;

import cn.sliew.carp.processor.core.model.Data;
import cn.sliew.carp.processor.core.model.Query;
import cn.sliew.carp.processor.core.model.View;
import cn.sliew.carp.processor.core.model.UserData;
import cn.sliew.carp.processor.core.model.UserQuery;
import cn.sliew.carp.processor.core.model.UserView;
import com.alibaba.ageiport.common.utils.BeanUtils;
import com.alibaba.ageiport.processor.core.annotation.ExportSpecification;
import com.alibaba.ageiport.processor.core.exception.BizException;
Expand All @@ -16,24 +16,24 @@
import java.util.List;

@ExportSpecification(code = "ExcelStyleExportProcessor", name = "ExcelStyleExportProcessor")
public class ExcelStyleExportProcessor implements ExportProcessor<Query, Data, View> {
public class ExcelStyleExportProcessor implements ExportProcessor<UserQuery, UserData, UserView> {

//2.实现ExportProcessor接口的TotalCount方法
@Override
public Integer totalCount(BizUser bizUser, Query query) throws BizException {
public Integer totalCount(BizUser bizUser, UserQuery query) throws BizException {
return query.getTotalCount();
}

//3.实现ExportProcessor接口的queryData方法
@Override
public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPage) throws BizException {
List<Data> dataList = new ArrayList<>();
public List<UserData> queryData(BizUser user, UserQuery query, BizExportPage bizExportPage) throws BizException {
List<UserData> dataList = new ArrayList<>();

Integer offset = bizExportPage.getOffset();
Integer size = bizExportPage.getSize();
for (int i = 1; i <= size; i++) {
int index = offset + i;
final Data data = new Data();
final UserData data = new UserData();
data.setId(index);
data.setName("name" + index);
if (index % 3 == 0) {
Expand All @@ -52,16 +52,16 @@ public List<Data> queryData(BizUser user, Query query, BizExportPage bizExportPa

//4.实现ExportProcessor接口的convert方法
@Override
public List<View> convert(BizUser user, Query query, List<Data> data) throws BizException {
List<View> dataList = new ArrayList<>();
for (Data datum : data) {
View view = BeanUtils.cloneProp(datum, View.class);
public List<UserView> convert(BizUser user, UserQuery query, List<UserData> data) throws BizException {
List<UserView> dataList = new ArrayList<>();
for (UserData datum : data) {
UserView view = BeanUtils.cloneProp(datum, UserView.class);
dataList.add(view);
}
return dataList;
}

public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, Query query) throws BizException {
public BizExportTaskRuntimeConfig taskRuntimeConfig(BizUser user, UserQuery query) throws BizException {
final BizExportTaskRuntimeConfigImpl runtimeConfig = new BizExportTaskRuntimeConfigImpl();
runtimeConfig.setExecuteType("STANDALONE");
return runtimeConfig;
Expand Down
Loading

0 comments on commit 85e6250

Please sign in to comment.