[improvement][launcher]Clean code logic of s2demos and remove tag-related constructs.

This commit is contained in:
Jun Zhang
2024-11-16 15:49:51 +08:00
committed by jerryjzhang
parent ba1938f04b
commit e8c9855163
15 changed files with 14130 additions and 16503 deletions

View File

@@ -1,6 +1,7 @@
package com.tencent.supersonic.headless.api.pojo;
import com.tencent.supersonic.common.pojo.Constants;
import com.tencent.supersonic.headless.api.pojo.enums.DimensionType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -12,7 +13,7 @@ public class Dim {
private String name;
private String type;
private DimensionType type;
private String expr;
@@ -28,23 +29,15 @@ public class Dim {
private int isTag;
public Dim(String name, String bizName, String type, Integer isCreateDimension) {
public Dim(String name, String bizName, DimensionType type, Integer isCreateDimension) {
this.name = name;
this.type = type;
this.isCreateDimension = isCreateDimension;
this.bizName = bizName;
}
public Dim(String name, String bizName, String type, Integer isCreateDimension, int isTag) {
this.name = name;
this.type = type;
this.isCreateDimension = isCreateDimension;
this.bizName = bizName;
this.isTag = isTag;
}
public Dim(String name, String type, String expr, String dateFormat,
DimensionTimeTypeParams typeParams, Integer isCreateDimension, String bizName) {
public Dim(String name, String bizName, DimensionType type, Integer isCreateDimension,
String expr, String dateFormat, DimensionTimeTypeParams typeParams) {
this.name = name;
this.type = type;
this.expr = expr;
@@ -55,8 +48,8 @@ public class Dim {
}
public static Dim getDefault() {
return new Dim("日期", "time", "2023-05-28", Constants.DAY_FORMAT,
new DimensionTimeTypeParams("true", "day"), 0, "imp_date");
return new Dim("数据日期", "imp_date", DimensionType.partition_time, 0, "imp_date",
Constants.DAY_FORMAT, new DimensionTimeTypeParams("false", "day"));
}
public String getFieldName() {

View File

@@ -43,8 +43,7 @@ public class ModelDetail {
if (CollectionUtils.isEmpty(dimensions)) {
return Lists.newArrayList();
}
return dimensions.stream()
.filter(dim -> DimensionType.partition_time.name().equalsIgnoreCase(dim.getType()))
return dimensions.stream().filter(dim -> DimensionType.partition_time.equals(dim.getType()))
.collect(Collectors.toList());
}

View File

@@ -35,8 +35,6 @@ public class ModelReq extends SchemaItem {
private List<String> adminOrgs;
private Long tagObjectId;
private Map<String, Object> ext;
public String getViewer() {

View File

@@ -37,7 +37,7 @@ public class SysTimeDimensionBuilder {
private static Dim generateSysDayDimension(Dim timeDim, DbAdaptor engineAdaptor) {
Dim dim = new Dim();
dim.setBizName(TimeDimensionEnum.DAY.getName());
dim.setType(DimensionType.partition_time.name());
dim.setType(DimensionType.partition_time);
dim.setExpr(generateTimeExpr(timeDim, TimeDimensionEnum.DAY.name().toLowerCase(),
engineAdaptor));
DimensionTimeTypeParams typeParams = new DimensionTimeTypeParams();
@@ -50,7 +50,7 @@ public class SysTimeDimensionBuilder {
private static Dim generateSysWeekDimension(Dim timeDim, DbAdaptor engineAdaptor) {
Dim dim = new Dim();
dim.setBizName(TimeDimensionEnum.WEEK.getName());
dim.setType(DimensionType.partition_time.name());
dim.setType(DimensionType.partition_time);
dim.setExpr(generateTimeExpr(timeDim, TimeDimensionEnum.WEEK.name().toLowerCase(),
engineAdaptor));
DimensionTimeTypeParams typeParams = new DimensionTimeTypeParams();
@@ -63,7 +63,7 @@ public class SysTimeDimensionBuilder {
private static Dim generateSysMonthDimension(Dim timeDim, DbAdaptor engineAdaptor) {
Dim dim = new Dim();
dim.setBizName(TimeDimensionEnum.MONTH.getName());
dim.setType(DimensionType.partition_time.name());
dim.setType(DimensionType.partition_time);
dim.setExpr(generateTimeExpr(timeDim, TimeDimensionEnum.MONTH.name().toLowerCase(),
engineAdaptor));
DimensionTimeTypeParams typeParams = new DimensionTimeTypeParams();
@@ -92,7 +92,7 @@ public class SysTimeDimensionBuilder {
private static Dim getTimeDim(List<Dim> timeDims) {
for (Dim dim : timeDims) {
if (dim.getType().equalsIgnoreCase(DimensionType.partition_time.name())) {
if (dim.getType().equals(DimensionType.partition_time)) {
return dim;
}
}

View File

@@ -120,7 +120,7 @@ public class ModelConverter {
}
dimensionReq.setModelId(modelDO.getId());
dimensionReq.setExpr(dim.getBizName());
dimensionReq.setType(dim.getType());
dimensionReq.setType(dim.getType().name());
dimensionReq
.setDescription(Objects.isNull(dim.getDescription()) ? "" : dim.getDescription());
dimensionReq.setIsTag(dim.getIsTag());

View File

@@ -96,10 +96,10 @@ class ModelServiceImplTest {
identifiers.add(new Identify("用户名", IdentifyType.primary.name(), "user_name"));
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time, 0);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("", "page", DimensionType.categorical.name(), 0);
Dim dimension2 = new Dim("", "page", DimensionType.categorical, 0);
dimension2.setExpr("page");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);
@@ -135,10 +135,10 @@ class ModelServiceImplTest {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date_a", DimensionType.partition_time.name(), 0);
Dim dimension1 = new Dim("", "imp_date_a", DimensionType.partition_time, 0);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("", "page_a", DimensionType.categorical.name(), 0);
Dim dimension2 = new Dim("", "page_a", DimensionType.categorical, 0);
dimension2.setExpr("page_a");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);
@@ -170,10 +170,10 @@ class ModelServiceImplTest {
identifiers.add(new Identify("用户名", IdentifyType.primary.name(), "user_name"));
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time, 0);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("", "page", DimensionType.categorical.name(), 0);
Dim dimension2 = new Dim("", "page", DimensionType.categorical, 0);
dimension2.setExpr("page");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);
@@ -208,10 +208,10 @@ class ModelServiceImplTest {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time, 0);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("", "page", DimensionType.categorical.name(), 0);
Dim dimension2 = new Dim("", "page", DimensionType.categorical, 0);
dimension2.setExpr("page");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);
@@ -253,10 +253,10 @@ class ModelServiceImplTest {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date_a", DimensionType.partition_time.name(), 0);
Dim dimension1 = new Dim("", "imp_date_a", DimensionType.partition_time, 0);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("", "page_a", DimensionType.categorical.name(), 0);
Dim dimension2 = new Dim("", "page_a", DimensionType.categorical, 0);
dimension2.setExpr("page_a");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);

View File

@@ -2,6 +2,7 @@ package com.tencent.supersonic.demo;
import com.google.common.collect.Lists;
import com.tencent.supersonic.auth.api.authorization.service.AuthService;
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
import com.tencent.supersonic.chat.server.service.AgentService;
import com.tencent.supersonic.chat.server.service.ChatManageService;
import com.tencent.supersonic.chat.server.service.ChatQueryService;
@@ -17,16 +18,23 @@ import com.tencent.supersonic.headless.api.pojo.DrillDownDimension;
import com.tencent.supersonic.headless.api.pojo.MetaFilter;
import com.tencent.supersonic.headless.api.pojo.RelateDimension;
import com.tencent.supersonic.headless.api.pojo.enums.DataType;
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
import com.tencent.supersonic.headless.api.pojo.request.DatabaseReq;
import com.tencent.supersonic.headless.api.pojo.request.DictItemReq;
import com.tencent.supersonic.headless.api.pojo.request.DictSingleTaskReq;
import com.tencent.supersonic.headless.api.pojo.request.TagReq;
import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
import com.tencent.supersonic.headless.server.service.*;
import com.tencent.supersonic.headless.server.service.DataSetService;
import com.tencent.supersonic.headless.server.service.DatabaseService;
import com.tencent.supersonic.headless.server.service.DictConfService;
import com.tencent.supersonic.headless.server.service.DictTaskService;
import com.tencent.supersonic.headless.server.service.DimensionService;
import com.tencent.supersonic.headless.server.service.DomainService;
import com.tencent.supersonic.headless.server.service.MetricService;
import com.tencent.supersonic.headless.server.service.ModelRelaService;
import com.tencent.supersonic.headless.server.service.ModelService;
import com.tencent.supersonic.headless.server.service.TermService;
import com.tencent.supersonic.headless.server.service.impl.DictWordService;
import dev.langchain4j.provider.ModelProvider;
import lombok.extern.slf4j.Slf4j;
@@ -61,8 +69,6 @@ public abstract class S2BaseDemo implements CommandLineRunner {
@Autowired
protected MetricService metricService;
@Autowired
protected TagMetaService tagMetaService;
@Autowired
protected AuthService authService;
@Autowired
protected DataSetService dataSetService;
@@ -73,8 +79,6 @@ public abstract class S2BaseDemo implements CommandLineRunner {
@Autowired
protected DataSourceProperties dataSourceProperties;
@Autowired
protected TagObjectService tagObjectService;
@Autowired
protected ChatQueryService chatQueryService;
@Autowired
protected ChatManageService chatManageService;
@@ -133,7 +137,7 @@ public abstract class S2BaseDemo implements CommandLineRunner {
protected ChatModel addChatModelIfNotExist() {
List<ChatModel> chatModels = chatModelService.getChatModels();
if (chatModels.size() > 0) {
if (!chatModels.isEmpty()) {
return chatModels.get(0);
} else {
ChatModel chatModel = new ChatModel();
@@ -180,13 +184,6 @@ public abstract class S2BaseDemo implements CommandLineRunner {
return dataSetModelConfigs;
}
protected void addTag(Long itemId, TagDefineType tagDefineType) {
TagReq tagReq = new TagReq();
tagReq.setTagDefineType(tagDefineType);
tagReq.setItemId(itemId);
tagMetaService.create(tagReq, User.getDefaultUser());
}
protected DimensionResp getDimension(String bizName, ModelResp model) {
return dimensionService.getDimension(bizName, model.getId());
}
@@ -209,4 +206,13 @@ public abstract class S2BaseDemo implements CommandLineRunner {
dictTaskService.addDictTask(DictSingleTaskReq.builder().itemId(dimension.getId())
.type(TypeEnums.DIMENSION).build(), defaultUser);
}
protected void submitText(int chatId, int agentId, String queryText) {
chatQueryService.parseAndExecute(ChatParseReq.builder().chatId(chatId).agentId(agentId)
.queryText(queryText).user(defaultUser).disableLLM(true).build());
}
protected void loadDictWord() {
dictWordService.loadDictWord();
}
}

View File

@@ -7,6 +7,7 @@ import com.tencent.supersonic.chat.server.agent.Agent;
import com.tencent.supersonic.chat.server.agent.AgentToolType;
import com.tencent.supersonic.chat.server.agent.DatasetTool;
import com.tencent.supersonic.chat.server.agent.ToolConfig;
import com.tencent.supersonic.chat.server.processor.execute.DataInterpretProcessor;
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.JoinCondition;
import com.tencent.supersonic.common.pojo.ModelRela;
@@ -56,13 +57,10 @@ public class S2CompanyDemo extends S2BaseDemo {
ModelResp model_company = addModel_1(domain, demoDatabase);
ModelResp model_brand = addModel_2(domain, demoDatabase);
ModelResp company_brand_revenue_proportion = addModel_3(domain, demoDatabase);
ModelResp model_brand_revenue = addModel_4(domain, demoDatabase);
ModelResp model_brand_revenue = addModel_3(domain, demoDatabase);
addModelRela(domain, company_brand_revenue_proportion, model_company, "company_id");
addModelRela(domain, company_brand_revenue_proportion, model_brand, "brand_id");
addModelRela(domain, model_brand, model_company, "company_id");
addModelRela(domain, model_brand_revenue, model_brand, "brand_id");
addModelRela(domain, model_company, model_brand, "company_id");
addModelRela(domain, model_brand, model_brand_revenue, "brand_id");
DataSetResp dataset = addDataSet(domain);
addAgent(dataset.getId());
@@ -107,18 +105,14 @@ public class S2CompanyDemo extends S2BaseDemo {
modelReq.setAdminOrgs(Collections.emptyList());
ModelDetail modelDetail = new ModelDetail();
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
DimensionTimeTypeParams dimensionTimeTypeParams =
new DimensionTimeTypeParams("false", "none");
dimension1.setTypeParams(dimensionTimeTypeParams);
dimensions.add(dimension1);
dimensions.add(new Dim("公司名称", "company_name", DimensionType.categorical.name(), 1));
dimensions.add(new Dim("总部地点", "headquarter_address", DimensionType.categorical.name(), 1));
dimensions.add(new Dim("成立时间", "company_established_time", DimensionType.time.name(), 1));
dimensions.add(new Dim("创始人", "founder", DimensionType.categorical.name(), 1));
dimensions.add(new Dim("首席执行官", "ceo", DimensionType.categorical.name(), 1));
modelDetail.setDimensions(dimensions);
dimensions.add(new Dim("公司名称", "company_name", DimensionType.categorical, 1));
dimensions.add(new Dim("总部地点", "headquarter_address", DimensionType.categorical, 1));
dimensions.add(new Dim("成立时间", "company_established_time", DimensionType.time, 1));
dimensions.add(new Dim("创始人", "founder", DimensionType.categorical, 1));
dimensions.add(new Dim("首席执行官", "ceo", DimensionType.categorical, 1));
List<Identify> identifiers = new ArrayList<>();
identifiers.add(new Identify("公司id", IdentifyType.primary.name(), "company_id"));
modelDetail.setIdentifiers(identifiers);
@@ -130,7 +124,7 @@ public class S2CompanyDemo extends S2BaseDemo {
modelDetail.setMeasures(measures);
modelDetail.setQueryType("sql_query");
modelDetail.setSqlQuery("SELECT imp_date,company_id,company_name,headquarter_address,"
modelDetail.setSqlQuery("SELECT company_id,company_name,headquarter_address,"
+ "company_established_time,founder,ceo,annual_turnover,employee_count FROM company");
modelReq.setModelDetail(modelDetail);
ModelResp companyModel = modelService.createModel(modelReq, defaultUser);
@@ -154,17 +148,12 @@ public class S2CompanyDemo extends S2BaseDemo {
modelReq.setAdminOrgs(Collections.emptyList());
ModelDetail modelDetail = new ModelDetail();
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
DimensionTimeTypeParams dimensionTimeTypeParams =
new DimensionTimeTypeParams("false", "none");
dimension1.setTypeParams(dimensionTimeTypeParams);
dimensions.add(dimension1);
dimensions.add(new Dim("品牌名称", "brand_name", DimensionType.categorical.name(), 1));
dimensions.add(new Dim("品牌成立时间", "brand_established_time", DimensionType.time.name(), 1));
dimensions
.add(new Dim("法定代表人", "legal_representative", DimensionType.categorical.name(), 1));
modelDetail.setDimensions(dimensions);
dimensions.add(new Dim("品牌名称", "brand_name", DimensionType.categorical, 1));
dimensions.add(new Dim("品牌成立时间", "brand_established_time", DimensionType.time, 1));
dimensions.add(new Dim("法定代表人", "legal_representative", DimensionType.categorical, 1));
List<Identify> identifiers = new ArrayList<>();
identifiers.add(new Identify("品牌id", IdentifyType.primary.name(), "brand_id"));
identifiers.add(new Identify("公司id", IdentifyType.foreign.name(), "company_id"));
@@ -175,7 +164,7 @@ public class S2CompanyDemo extends S2BaseDemo {
modelDetail.setMeasures(measures);
modelDetail.setQueryType("sql_query");
modelDetail.setSqlQuery("SELECT imp_date,brand_id,brand_name,brand_established_time,"
modelDetail.setSqlQuery("SELECT brand_id,brand_name,brand_established_time,"
+ "company_id,legal_representative,registered_capital FROM brand");
modelReq.setModelDetail(modelDetail);
ModelResp brandModel = modelService.createModel(modelReq, defaultUser);
@@ -187,8 +176,8 @@ public class S2CompanyDemo extends S2BaseDemo {
public ModelResp addModel_3(DomainResp domain, DatabaseResp database) throws Exception {
ModelReq modelReq = new ModelReq();
modelReq.setName("公司品牌收入占比");
modelReq.setBizName("company_brand_revenue_proportion");
modelReq.setName("品牌历年收入");
modelReq.setBizName("brand_revenue");
modelReq.setDatabaseId(database.getId());
modelReq.setDomainId(domain.getId());
modelReq.setViewers(Arrays.asList("admin", "tom", "jack"));
@@ -197,50 +186,10 @@ public class S2CompanyDemo extends S2BaseDemo {
modelReq.setAdminOrgs(Collections.emptyList());
ModelDetail modelDetail = new ModelDetail();
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
DimensionTimeTypeParams dimensionTimeTypeParams =
new DimensionTimeTypeParams("false", "none");
dimension1.setTypeParams(dimensionTimeTypeParams);
dimensions.add(dimension1);
modelDetail.setDimensions(dimensions);
List<Identify> identifiers = new ArrayList<>();
identifiers.add(new Identify("公司id", IdentifyType.foreign.name(), "company_id"));
identifiers.add(new Identify("品牌id", IdentifyType.foreign.name(), "brand_id"));
modelDetail.setIdentifiers(identifiers);
List<Measure> measures = new ArrayList<>();
measures.add(new Measure("营收占比", "revenue_proportion", AggOperatorEnum.MAX.name(), 1));
measures.add(new Measure("利润占比", "profit_proportion", AggOperatorEnum.MAX.name(), 1));
measures.add(new Measure("支出占比", "expenditure_proportion", AggOperatorEnum.MAX.name(), 1));
modelDetail.setMeasures(measures);
modelDetail.setQueryType("sql_query");
modelDetail.setSqlQuery("SELECT imp_date,company_id,brand_id,revenue_proportion,"
+ "profit_proportion,expenditure_proportion FROM company_revenue");
modelReq.setModelDetail(modelDetail);
return modelService.createModel(modelReq, defaultUser);
}
public ModelResp addModel_4(DomainResp domain, DatabaseResp database) throws Exception {
ModelReq modelReq = new ModelReq();
modelReq.setName("公司品牌历年收入");
modelReq.setBizName("company_brand_revenue");
modelReq.setDatabaseId(database.getId());
modelReq.setDomainId(domain.getId());
modelReq.setViewers(Arrays.asList("admin", "tom", "jack"));
modelReq.setViewOrgs(Collections.singletonList("1"));
modelReq.setAdmins(Collections.singletonList("admin"));
modelReq.setAdminOrgs(Collections.emptyList());
ModelDetail modelDetail = new ModelDetail();
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
DimensionTimeTypeParams dimensionTimeTypeParams =
new DimensionTimeTypeParams("false", "none");
dimension1.setTypeParams(dimensionTimeTypeParams);
dimensions.add(dimension1);
dimensions.add(new Dim("年份", "year_time", DimensionType.categorical.name(), 1));
modelDetail.setDimensions(dimensions);
dimensions.add(new Dim("财年", "year_time", DimensionType.time, 1, "year_time", "yyyy",
new DimensionTimeTypeParams("false", "year")));
List<Identify> identifiers = new ArrayList<>();
identifiers.add(new Identify("品牌id", IdentifyType.foreign.name(), "brand_id"));
@@ -250,14 +199,14 @@ public class S2CompanyDemo extends S2BaseDemo {
measures.add(new Measure("营收", "revenue", AggOperatorEnum.SUM.name(), 1));
measures.add(new Measure("利润", "profit", AggOperatorEnum.SUM.name(), 1));
measures.add(new Measure("营收同比增长", "revenue_growth_year_on_year",
AggOperatorEnum.SUM.name(), 1));
AggOperatorEnum.AVG.name(), 1));
measures.add(
new Measure("利润同比增长", "profit_growth_year_on_year", AggOperatorEnum.SUM.name(), 1));
new Measure("利润同比增长", "profit_growth_year_on_year", AggOperatorEnum.AVG.name(), 1));
modelDetail.setMeasures(measures);
modelDetail.setQueryType("sql_query");
modelDetail.setSqlQuery("SELECT imp_date,year_time,brand_id,revenue,profit,"
+ "revenue_growth_year_on_year,profit_growth_year_on_year FROM company_brand_revenue");
modelDetail.setSqlQuery("SELECT year_time,brand_id,revenue,profit,"
+ "revenue_growth_year_on_year,profit_growth_year_on_year FROM brand_revenue");
modelReq.setModelDetail(modelDetail);
return modelService.createModel(modelReq, defaultUser);
}
@@ -279,7 +228,7 @@ public class S2CompanyDemo extends S2BaseDemo {
QueryConfig queryConfig = new QueryConfig();
AggregateTypeDefaultConfig aggregateTypeDefaultConfig = new AggregateTypeDefaultConfig();
TimeDefaultConfig timeDefaultConfig = new TimeDefaultConfig();
timeDefaultConfig.setTimeMode(TimeMode.RECENT);
timeDefaultConfig.setTimeMode(TimeMode.LAST);
timeDefaultConfig.setUnit(1);
aggregateTypeDefaultConfig.setTimeDefaultConfig(timeDefaultConfig);
queryConfig.setAggregateTypeDefaultConfig(aggregateTypeDefaultConfig);
@@ -301,43 +250,6 @@ public class S2CompanyDemo extends S2BaseDemo {
modelRelaService.save(modelRelaReq, defaultUser);
}
public void addModelRela_2(DomainResp domain, ModelResp fromModel, ModelResp toModel) {
List<JoinCondition> joinConditions = Lists.newArrayList();
joinConditions
.add(new JoinCondition("company_id", "company_id", FilterOperatorEnum.EQUALS));
ModelRela modelRelaReq = new ModelRela();
modelRelaReq.setDomainId(domain.getId());
modelRelaReq.setFromModelId(fromModel.getId());
modelRelaReq.setToModelId(toModel.getId());
modelRelaReq.setJoinType("left join");
modelRelaReq.setJoinConditions(joinConditions);
modelRelaService.save(modelRelaReq, defaultUser);
}
public void addModelRela_3(DomainResp domain, ModelResp fromModel, ModelResp toModel) {
List<JoinCondition> joinConditions = Lists.newArrayList();
joinConditions.add(new JoinCondition("brand_id", "brand_id", FilterOperatorEnum.EQUALS));
ModelRela modelRelaReq = new ModelRela();
modelRelaReq.setDomainId(domain.getId());
modelRelaReq.setFromModelId(fromModel.getId());
modelRelaReq.setToModelId(toModel.getId());
modelRelaReq.setJoinType("left join");
modelRelaReq.setJoinConditions(joinConditions);
modelRelaService.save(modelRelaReq, defaultUser);
}
public void addModelRela_4(DomainResp domain, ModelResp fromModel, ModelResp toModel) {
List<JoinCondition> joinConditions = Lists.newArrayList();
joinConditions.add(new JoinCondition("brand_id", "brand_id", FilterOperatorEnum.EQUALS));
ModelRela modelRelaReq = new ModelRela();
modelRelaReq.setDomainId(domain.getId());
modelRelaReq.setFromModelId(fromModel.getId());
modelRelaReq.setToModelId(toModel.getId());
modelRelaReq.setJoinType("left join");
modelRelaReq.setJoinConditions(joinConditions);
modelRelaService.save(modelRelaReq, defaultUser);
}
private void addAgent(Long dataSetId) {
Agent agent = new Agent();
agent.setName("企业分析助手");
@@ -345,7 +257,7 @@ public class S2CompanyDemo extends S2BaseDemo {
agent.setStatus(1);
agent.setEnableSearch(1);
agent.setExamples(
Lists.newArrayList("各公司员工都有多少人", "利润最高的公司top 3", "英伟达2024利润", "特斯拉下有哪些品牌"));
Lists.newArrayList("各公司员工都有多少人", "利润最高的品牌top 3", "2024财年aws的营收和利润", "特斯拉下有哪些品牌"));
ToolConfig toolConfig = new ToolConfig();
// configure tools
@@ -360,6 +272,7 @@ public class S2CompanyDemo extends S2BaseDemo {
Map<String, ChatApp> chatAppConfig =
Maps.newHashMap(ChatAppManager.getAllApps(AppModule.CHAT));
chatAppConfig.values().forEach(app -> app.setChatModelId(demoChatModel.getId()));
chatAppConfig.get(DataInterpretProcessor.APP_KEY).setEnable(true);
agent.setChatAppConfig(chatAppConfig);
agentService.createAgent(agent, defaultUser);

View File

@@ -23,16 +23,13 @@ import com.tencent.supersonic.headless.api.pojo.ModelDetail;
import com.tencent.supersonic.headless.api.pojo.QueryConfig;
import com.tencent.supersonic.headless.api.pojo.enums.DimensionType;
import com.tencent.supersonic.headless.api.pojo.enums.IdentifyType;
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
import com.tencent.supersonic.headless.api.pojo.request.DataSetReq;
import com.tencent.supersonic.headless.api.pojo.request.DomainReq;
import com.tencent.supersonic.headless.api.pojo.request.ModelReq;
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
import com.tencent.supersonic.headless.api.pojo.response.DataSetResp;
import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@@ -71,14 +68,6 @@ public class S2SingerDemo extends S2BaseDemo {
return true;
}
private TagObjectResp addTagObjectSinger(DomainResp singerDomain) throws Exception {
TagObjectReq tagObjectReq = new TagObjectReq();
tagObjectReq.setDomainId(singerDomain.getId());
tagObjectReq.setName("歌手");
tagObjectReq.setBizName("singer");
return tagObjectService.create(tagObjectReq, defaultUser);
}
public DomainResp addDomain() {
DomainReq domainReq = new DomainReq();
domainReq.setName("歌手数据域");
@@ -111,9 +100,9 @@ public class S2SingerDemo extends S2BaseDemo {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
dimensions.add(new Dim("活跃区域", "act_area", DimensionType.categorical.name(), 1, 1));
dimensions.add(new Dim("代表作", "song_name", DimensionType.categorical.name(), 1));
dimensions.add(new Dim("流派", "genre", DimensionType.categorical.name(), 1, 1));
dimensions.add(new Dim("活跃区域", "act_area", DimensionType.categorical, 1));
dimensions.add(new Dim("代表作", "song_name", DimensionType.categorical, 1));
dimensions.add(new Dim("流派", "genre", DimensionType.categorical, 1));
modelDetail.setDimensions(dimensions);
Measure measure1 = new Measure("播放量", "js_play_cnt", "sum", 1);
@@ -134,18 +123,6 @@ public class S2SingerDemo extends S2BaseDemo {
return modelResp;
}
private void addTags(ModelResp model) {
addTag(dimensionService.getDimension("act_area", model.getId()).getId(),
TagDefineType.DIMENSION);
addTag(dimensionService.getDimension("song_name", model.getId()).getId(),
TagDefineType.DIMENSION);
addTag(dimensionService.getDimension("genre", model.getId()).getId(),
TagDefineType.DIMENSION);
addTag(dimensionService.getDimension("singer_name", model.getId()).getId(),
TagDefineType.DIMENSION);
addTag(metricService.getMetric(model.getId(), "js_play_cnt").getId(), TagDefineType.METRIC);
}
public long addDataSet(DomainResp singerDomain, ModelResp singerModel) {
DataSetReq dataSetReq = new DataSetReq();
dataSetReq.setName("歌手数据集");

View File

@@ -5,7 +5,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.tencent.supersonic.auth.api.authorization.pojo.AuthGroup;
import com.tencent.supersonic.auth.api.authorization.pojo.AuthRule;
import com.tencent.supersonic.chat.api.pojo.request.ChatParseReq;
import com.tencent.supersonic.chat.server.agent.Agent;
import com.tencent.supersonic.chat.server.agent.AgentToolType;
import com.tencent.supersonic.chat.server.agent.DatasetTool;
@@ -13,7 +12,6 @@ import com.tencent.supersonic.chat.server.agent.ToolConfig;
import com.tencent.supersonic.chat.server.plugin.ChatPlugin;
import com.tencent.supersonic.chat.server.plugin.PluginParseConfig;
import com.tencent.supersonic.chat.server.plugin.build.WebBase;
import com.tencent.supersonic.chat.server.plugin.build.webpage.WebPageQuery;
import com.tencent.supersonic.chat.server.plugin.build.webservice.WebServiceQuery;
import com.tencent.supersonic.common.pojo.ChatApp;
import com.tencent.supersonic.common.pojo.JoinCondition;
@@ -45,13 +43,11 @@ import com.tencent.supersonic.headless.api.pojo.enums.DimensionType;
import com.tencent.supersonic.headless.api.pojo.enums.IdentifyType;
import com.tencent.supersonic.headless.api.pojo.enums.MetricDefineType;
import com.tencent.supersonic.headless.api.pojo.enums.SemanticType;
import com.tencent.supersonic.headless.api.pojo.enums.TagDefineType;
import com.tencent.supersonic.headless.api.pojo.request.DataSetReq;
import com.tencent.supersonic.headless.api.pojo.request.DimensionReq;
import com.tencent.supersonic.headless.api.pojo.request.DomainReq;
import com.tencent.supersonic.headless.api.pojo.request.MetricReq;
import com.tencent.supersonic.headless.api.pojo.request.ModelReq;
import com.tencent.supersonic.headless.api.pojo.request.TagObjectReq;
import com.tencent.supersonic.headless.api.pojo.request.TermReq;
import com.tencent.supersonic.headless.api.pojo.response.DataSetResp;
import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
@@ -59,7 +55,6 @@ import com.tencent.supersonic.headless.api.pojo.response.DimensionResp;
import com.tencent.supersonic.headless.api.pojo.response.DomainResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricResp;
import com.tencent.supersonic.headless.api.pojo.response.ModelResp;
import com.tencent.supersonic.headless.api.pojo.response.TagObjectResp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
@@ -79,15 +74,13 @@ public class S2VisitsDemo extends S2BaseDemo {
try {
// create domain
DomainResp s2Domain = addDomain();
TagObjectResp s2TagObject = addTagObjectUser(s2Domain);
// create models
ModelResp userModel = addModel_1(s2Domain, demoDatabase, s2TagObject);
ModelResp userModel = addModel_1(s2Domain, demoDatabase);
ModelResp pvUvModel = addModel_2(s2Domain, demoDatabase);
ModelResp stayTimeModel = addModel_3(s2Domain, demoDatabase);
addModelRela_1(s2Domain, userModel, pvUvModel);
addModelRela_2(s2Domain, userModel, stayTimeModel);
addTags(userModel);
addModelRela(s2Domain, userModel, pvUvModel, "user_name");
addModelRela(s2Domain, userModel, stayTimeModel, "user_name");
// create metrics and dimensions
DimensionResp departmentDimension = getDimension("department", userModel);
@@ -112,9 +105,7 @@ public class S2VisitsDemo extends S2BaseDemo {
// create terms and plugin
addTerm(s2Domain);
addTerm_1(s2Domain);
addPlugin(s2DataSet);
addPlugin_1();
addPlugin();
// load dict word
loadDictWord();
@@ -130,7 +121,7 @@ public class S2VisitsDemo extends S2BaseDemo {
}
@Override
boolean checkNeedToRun() {
public boolean checkNeedToRun() {
List<DomainResp> domainList = domainService.getDomainList();
for (DomainResp domainResp : domainList) {
if (domainResp.getBizName().equalsIgnoreCase("supersonic")) {
@@ -141,18 +132,13 @@ public class S2VisitsDemo extends S2BaseDemo {
return true;
}
public void addSampleChats(Integer agentId) {
private void addSampleChats(Integer agentId) {
Long chatId = chatManageService.addChat(defaultUser, "样例对话1", agentId);
submitText(chatId.intValue(), agentId, "超音数 访问次数");
submitText(chatId.intValue(), agentId, "按部门统计近7天访问次数");
submitText(chatId.intValue(), agentId, "alice 停留时长");
}
private void submitText(int chatId, int agentId, String queryText) {
chatQueryService.parseAndExecute(ChatParseReq.builder().chatId(chatId).agentId(agentId)
.queryText(queryText).user(defaultUser).disableLLM(true).build());
}
private Integer addAgent(long dataSetId) {
Agent agent = new Agent();
agent.setName("超音数分析助手");
@@ -180,7 +166,7 @@ public class S2VisitsDemo extends S2BaseDemo {
return agentCreated.getId();
}
public DomainResp addDomain() {
private DomainResp addDomain() {
DomainReq domainReq = new DomainReq();
domainReq.setName("产品数据域");
domainReq.setBizName("supersonic");
@@ -192,15 +178,13 @@ public class S2VisitsDemo extends S2BaseDemo {
return domainService.createDomain(domainReq, defaultUser);
}
public ModelResp addModel_1(DomainResp s2Domain, DatabaseResp s2Database,
TagObjectResp s2TagObject) throws Exception {
private ModelResp addModel_1(DomainResp s2Domain, DatabaseResp s2Database) throws Exception {
ModelReq modelReq = new ModelReq();
modelReq.setName("用户部门");
modelReq.setBizName("user_department");
modelReq.setDescription("用户部门信息");
modelReq.setDatabaseId(s2Database.getId());
modelReq.setDomainId(s2Domain.getId());
modelReq.setTagObjectId(s2TagObject.getId());
modelReq.setViewers(Arrays.asList("admin", "tom", "jack"));
modelReq.setViewOrgs(Collections.singletonList("1"));
modelReq.setAdmins(Arrays.asList("admin", "alice"));
@@ -211,7 +195,7 @@ public class S2VisitsDemo extends S2BaseDemo {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
dimensions.add(new Dim("部门", "department", DimensionType.categorical.name(), 1));
dimensions.add(new Dim("部门", "department", DimensionType.categorical, 1));
modelDetail.setDimensions(dimensions);
List<Field> fields = Lists.newArrayList();
fields.add(Field.builder().fieldName("user_name").dataType("Varchar").build());
@@ -224,7 +208,7 @@ public class S2VisitsDemo extends S2BaseDemo {
return modelService.createModel(modelReq, defaultUser);
}
public ModelResp addModel_2(DomainResp s2Domain, DatabaseResp s2Database) throws Exception {
private ModelResp addModel_2(DomainResp s2Domain, DatabaseResp s2Database) throws Exception {
ModelReq modelReq = new ModelReq();
modelReq.setName("PVUV统计");
modelReq.setBizName("s2_pv_uv_statis");
@@ -241,10 +225,10 @@ public class S2VisitsDemo extends S2BaseDemo {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time.name(), 0);
Dim dimension1 = new Dim("", "imp_date", DimensionType.partition_time, 0);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("", "page", DimensionType.categorical.name(), 0);
Dim dimension2 = new Dim("", "page", DimensionType.categorical, 0);
dimension2.setExpr("page");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);
@@ -268,7 +252,7 @@ public class S2VisitsDemo extends S2BaseDemo {
return modelService.createModel(modelReq, defaultUser);
}
public ModelResp addModel_3(DomainResp s2Domain, DatabaseResp s2Database) throws Exception {
private ModelResp addModel_3(DomainResp s2Domain, DatabaseResp s2Database) throws Exception {
ModelReq modelReq = new ModelReq();
modelReq.setName("停留时长统计");
modelReq.setBizName("s2_stay_time_statis");
@@ -285,10 +269,10 @@ public class S2VisitsDemo extends S2BaseDemo {
modelDetail.setIdentifiers(identifiers);
List<Dim> dimensions = new ArrayList<>();
Dim dimension1 = new Dim("数据日期", "imp_date", DimensionType.partition_time.name(), 1);
Dim dimension1 = new Dim("数据日期", "imp_date", DimensionType.partition_time, 1);
dimension1.setTypeParams(new DimensionTimeTypeParams());
dimensions.add(dimension1);
Dim dimension2 = new Dim("页面", "page", DimensionType.categorical.name(), 1);
Dim dimension2 = new Dim("页面", "page", DimensionType.categorical, 1);
dimension2.setExpr("page");
dimensions.add(dimension2);
modelDetail.setDimensions(dimensions);
@@ -310,38 +294,20 @@ public class S2VisitsDemo extends S2BaseDemo {
return modelService.createModel(modelReq, defaultUser);
}
public void addModelRela_1(DomainResp s2Domain, ModelResp userDepartmentModel,
ModelResp pvUvModel) {
private void addModelRela(DomainResp s2Domain, ModelResp fromModel, ModelResp toModel,
String joinField) {
List<JoinCondition> joinConditions = Lists.newArrayList();
joinConditions.add(new JoinCondition("user_name", "user_name", FilterOperatorEnum.EQUALS));
joinConditions.add(new JoinCondition(joinField, joinField, FilterOperatorEnum.EQUALS));
ModelRela modelRelaReq = new ModelRela();
modelRelaReq.setDomainId(s2Domain.getId());
modelRelaReq.setFromModelId(userDepartmentModel.getId());
modelRelaReq.setToModelId(pvUvModel.getId());
modelRelaReq.setFromModelId(fromModel.getId());
modelRelaReq.setToModelId(toModel.getId());
modelRelaReq.setJoinType("left join");
modelRelaReq.setJoinConditions(joinConditions);
modelRelaService.save(modelRelaReq, defaultUser);
}
public void addModelRela_2(DomainResp s2Domain, ModelResp userDepartmentModel,
ModelResp stayTimeModel) {
List<JoinCondition> joinConditions = Lists.newArrayList();
joinConditions.add(new JoinCondition("user_name", "user_name", FilterOperatorEnum.EQUALS));
ModelRela modelRelaReq = new ModelRela();
modelRelaReq.setDomainId(s2Domain.getId());
modelRelaReq.setFromModelId(userDepartmentModel.getId());
modelRelaReq.setToModelId(stayTimeModel.getId());
modelRelaReq.setJoinType("left join");
modelRelaReq.setJoinConditions(joinConditions);
modelRelaService.save(modelRelaReq, defaultUser);
}
private void addTags(ModelResp model) {
addTag(dimensionService.getDimension("department", model.getId()).getId(),
TagDefineType.DIMENSION);
}
public void updateDimension(ModelResp stayTimeModel, DimensionResp pageDimension)
private void updateDimension(ModelResp stayTimeModel, DimensionResp pageDimension)
throws Exception {
DimensionReq dimensionReq = new DimensionReq();
dimensionReq.setType(DimensionType.categorical.name());
@@ -349,16 +315,15 @@ public class S2VisitsDemo extends S2BaseDemo {
dimensionReq.setName("页面");
dimensionReq.setBizName("page");
dimensionReq.setModelId(stayTimeModel.getId());
dimensionReq.setAlias("page");
dimensionReq.setSemanticType(SemanticType.CATEGORY.name());
dimensionReq.setSensitiveLevel(SensitiveLevelEnum.HIGH.getCode());
dimensionReq.setSensitiveLevel(SensitiveLevelEnum.MID.getCode());
dimensionReq.setDescription("页面");
dimensionReq.setExpr("page");
dimensionReq.setDimValueMaps(Collections.emptyList());
dimensionService.updateDimension(dimensionReq, defaultUser);
}
public void updateMetric(ModelResp stayTimeModel, DimensionResp departmentDimension,
private void updateMetric(ModelResp stayTimeModel, DimensionResp departmentDimension,
DimensionResp userDimension) throws Exception {
MetricResp stayHoursMetric = metricService.getMetric(stayTimeModel.getId(), "stay_hours");
MetricReq metricReq = new MetricReq();
@@ -383,7 +348,7 @@ public class S2VisitsDemo extends S2BaseDemo {
metricService.updateMetric(metricReq, defaultUser);
}
public void updateMetric_pv(ModelResp pvUvModel, DimensionResp departmentDimension,
private void updateMetric_pv(ModelResp pvUvModel, DimensionResp departmentDimension,
DimensionResp userDimension, MetricResp metricPv) throws Exception {
MetricReq metricReq = new MetricReq();
metricReq.setModelId(pvUvModel.getId());
@@ -405,7 +370,7 @@ public class S2VisitsDemo extends S2BaseDemo {
metricService.updateMetric(metricReq, defaultUser);
}
public MetricResp addMetric_uv(ModelResp uvModel, DimensionResp departmentDimension)
private MetricResp addMetric_uv(ModelResp uvModel, DimensionResp departmentDimension)
throws Exception {
MetricReq metricReq = new MetricReq();
metricReq.setModelId(uvModel.getId());
@@ -426,7 +391,7 @@ public class S2VisitsDemo extends S2BaseDemo {
return metricService.createMetric(metricReq, defaultUser);
}
public MetricResp addMetric_pv_avg(MetricResp metricPv, MetricResp metricUv,
private MetricResp addMetric_pv_avg(MetricResp metricPv, MetricResp metricUv,
DimensionResp departmentDimension, ModelResp pvModel) throws Exception {
MetricReq metricReq = new MetricReq();
metricReq.setModelId(pvModel.getId());
@@ -451,7 +416,7 @@ public class S2VisitsDemo extends S2BaseDemo {
return metricService.createMetric(metricReq, defaultUser);
}
public DataSetResp addDataSet(DomainResp s2Domain) {
private DataSetResp addDataSet(DomainResp s2Domain) {
DataSetReq dataSetReq = new DataSetReq();
dataSetReq.setName("超音数数据集");
dataSetReq.setBizName("s2");
@@ -466,25 +431,23 @@ public class S2VisitsDemo extends S2BaseDemo {
return dataSetService.save(dataSetReq, defaultUser);
}
public void addTerm(DomainResp s2Domain) {
private void addTerm(DomainResp s2Domain) {
TermReq termReq = new TermReq();
termReq.setName("近期");
termReq.setDescription("指近10天");
termReq.setAlias(Lists.newArrayList("近一段时间"));
termReq.setDomainId(s2Domain.getId());
termService.saveOrUpdate(termReq, defaultUser);
}
public void addTerm_1(DomainResp s2Domain) {
TermReq termReq = new TermReq();
termReq.setName("核心用户");
termReq.setDescription("用户为tom和lucy");
termReq.setAlias(Lists.newArrayList("VIP用户"));
termReq.setDomainId(s2Domain.getId());
TermReq termReq1 = new TermReq();
termReq1.setName("核心用户");
termReq1.setDescription("用户为tom和lucy");
termReq1.setAlias(Lists.newArrayList("VIP用户"));
termReq1.setDomainId(s2Domain.getId());
termService.saveOrUpdate(termReq, defaultUser);
}
public void addAuthGroup_1(ModelResp stayTimeModel) {
private void addAuthGroup_1(ModelResp stayTimeModel) {
AuthGroup authGroupReq = new AuthGroup();
authGroupReq.setModelId(stayTimeModel.getId());
authGroupReq.setName("jack_column_permission");
@@ -501,7 +464,7 @@ public class S2VisitsDemo extends S2BaseDemo {
authService.addOrUpdateAuthGroup(authGroupReq);
}
public void addAuthGroup_2(ModelResp pvuvModel) {
private void addAuthGroup_2(ModelResp pvuvModel) {
AuthGroup authGroupReq = new AuthGroup();
authGroupReq.setModelId(pvuvModel.getId());
authGroupReq.setName("tom_row_permission");
@@ -515,25 +478,7 @@ public class S2VisitsDemo extends S2BaseDemo {
authService.addOrUpdateAuthGroup(authGroupReq);
}
private void addPlugin(DataSetResp s2DataSet) {
ChatPlugin plugin1 = new ChatPlugin();
plugin1.setType(WebPageQuery.QUERY_MODE);
plugin1.setDataSetList(Collections.singletonList(s2DataSet.getId()));
plugin1.setPattern("用于分析超音数的流量概况包含UV、PV等核心指标的追踪。P.S. 仅作为示例展示,无实际看板");
plugin1.setName("超音数流量分析看板");
PluginParseConfig pluginParseConfig = new PluginParseConfig();
pluginParseConfig.setDescription(plugin1.getPattern());
pluginParseConfig.setName(plugin1.getName());
pluginParseConfig.setExamples(Lists.newArrayList("tom最近访问超音数情况怎么样"));
plugin1.setParseModeConfig(JSONObject.toJSONString(pluginParseConfig));
WebBase webBase = new WebBase();
webBase.setUrl("www.yourbi.com");
webBase.setParamOptions(Lists.newArrayList());
plugin1.setConfig(JsonUtil.toString(webBase));
pluginService.createPlugin(plugin1, defaultUser);
}
private void addPlugin_1() {
private void addPlugin() {
ChatPlugin plugin1 = new ChatPlugin();
plugin1.setType(WebServiceQuery.QUERY_MODE);
plugin1.setDataSetList(Collections.singletonList(-1L));
@@ -551,15 +496,4 @@ public class S2VisitsDemo extends S2BaseDemo {
pluginService.createPlugin(plugin1, defaultUser);
}
private TagObjectResp addTagObjectUser(DomainResp s2Domain) throws Exception {
TagObjectReq tagObjectReq = new TagObjectReq();
tagObjectReq.setDomainId(s2Domain.getId());
tagObjectReq.setName("用户");
tagObjectReq.setBizName("user");
return tagObjectService.create(tagObjectReq, defaultUser);
}
private void loadDictWord() {
dictWordService.loadDictWord();
}
}

View File

@@ -1044,41 +1044,40 @@ insert INTO artist(artist_name,citizenship,gender,g_name) VALUES ('Michel','英
-------S2CompanyDemo
insert into company(imp_date,company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_131','微软','西雅图','1975','盖茨','纳德拉',102300000000,210000);
insert into company(imp_date,company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_132','特斯拉','加州','2003','艾伯哈德','马斯克',376800000000,140473);
insert into company(imp_date,company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_133','谷歌','加州','1998','拉里佩奇','劈柴',321600000000,182503);
insert into company(imp_date,company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_134','亚马逊','加州','1994','贝索斯','贝索斯',28800000000,950000);
insert into company(imp_date,company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_135','英伟达','杭州','1993','黄仁勋','黄仁勋',67500000000,29000);
insert into company(company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES ('item_enterprise_13_131','微软','西雅图','1975','盖茨','纳德拉',102300000000,210000);
insert into company(company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES ('item_enterprise_13_132','特斯拉','加州','2003','艾伯哈德','马斯克',376800000000,140473);
insert into company(company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES ('item_enterprise_13_133','谷歌','加州','1998','拉里佩奇','劈柴',321600000000,182503);
insert into company(company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES ('item_enterprise_13_134','亚马逊','加州','1994','贝索斯','贝索斯',28800000000,950000);
insert into company(company_id,company_name,headquarter_address,company_established_time,founder,ceo,annual_turnover,employee_count) VALUES ('item_enterprise_13_135','英伟达','杭州','1993','黄仁勋','黄仁勋',67500000000,29000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_131','Office','1990','item_enterprise_13_131','盖茨',50000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_132','Windows','1991','item_enterprise_13_131','盖茨',50000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_133','Model 3','2017','item_enterprise_13_132','马斯克',100000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_134','Model Y','2020','item_enterprise_13_132','马斯克',100000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_135','Google','2003','item_enterprise_13_133','拉里佩奇',50000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_136','Android','2007','item_enterprise_13_133','拉里佩奇',50000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_137','AWS','2004','item_enterprise_13_134','贝索斯',100000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_138','Kindle','2007','item_enterprise_13_134','贝索斯',100000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_139','H100','2022','item_enterprise_13_135','黄仁勋',100000000);
insert into brand(imp_date,brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES (DATEADD('DAY', -1, CURRENT_DATE()),'item_brand_13_140','A100','2021','item_enterprise_13_135','黄仁勋',100000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_131','Office','1990','item_enterprise_13_131','盖茨',50000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_132','Windows','1991','item_enterprise_13_131','盖茨',50000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_133','Model 3','2017','item_enterprise_13_132','马斯克',100000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_134','Model Y','2020','item_enterprise_13_132','马斯克',100000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_135','Google','2003','item_enterprise_13_133','拉里佩奇',50000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_136','Android','2007','item_enterprise_13_133','拉里佩奇',50000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_137','aws','2004','item_enterprise_13_134','贝索斯',100000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_138','kindle','2007','item_enterprise_13_134','贝索斯',100000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_139','H100','2022','item_enterprise_13_135','黄仁勋',100000000);
insert into brand(brand_id,brand_name,brand_established_time,company_id,legal_representative,registered_capital) VALUES ('item_brand_13_140','A100','2021','item_enterprise_13_135','黄仁勋',100000000);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_131','item_brand_13_131',10,10,30);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_131','item_brand_13_132',10,10,30);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_132','item_brand_13_133',30,30,60);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_132','item_brand_13_134',20,20,30);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_133','item_brand_13_135',40,50,60);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_133','item_brand_13_136',20,30,40);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_134','item_brand_13_137',10,30,50);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_134','item_brand_13_138',40,30,60);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_135','item_brand_13_139',20,10,80);
insert into company_revenue(imp_date,company_id,brand_id,revenue_proportion,profit_proportion,expenditure_proportion) VALUES ( DATEADD('DAY', -1, CURRENT_DATE()),'item_enterprise_13_135','item_brand_13_140',20,10,30);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_131',500000000, 13100000000,10,10);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_132',600000000, 13200000000,20,20);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_133',700000000, 13300000000,30,30);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_134',500000000, 13400000000,10,10);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_135',600000000, 13500000000,30,30);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_136',700000000, 13600000000,40,40);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_137',800000000, 13700000000,50,50);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_138',400000000, 13800000000,20,10);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_139',300000000, 13900000000,60,70);
insert into company_brand_revenue(imp_date,year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES (DATEADD('DAY', -1, CURRENT_DATE()), '2024','item_brand_13_140',900000000, 14000000000,80,100);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_131',12100000000, 2100000000,10,10);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_132',12200000000, 2200000000,20,20);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_133',12300000000, 2300000000,30,30);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_134',12400000000, 2400000000,10,10);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_135',12500000000, 2500000000,30,30);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_136',12600000000, 2600000000,40,40);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_137',12700000000, 2700000000,50,50);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_138',12800000000, 2800000000,20,10);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_139',12900000000, 2900000000,60,70);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2023','item_brand_13_140',13000000000, 3000000000,80,100);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_131',13100000000,3100000000, 10,10);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_132',13200000000, 3200000000,20,20);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_133',13300000000, 3300000000,30,30);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_134',13400000000, 3400000000,10,10);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_135',13500000000, 3500000000,30,30);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_136',13600000000, 3600000000,40,40);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_137',13700000000, 3700000000,50,50);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_138',13800000000, 3800000000,20,10);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_139',13900000000, 3900000000,60,70);
insert into brand_revenue(year_time,brand_id,revenue,profit,revenue_growth_year_on_year,profit_growth_year_on_year) VALUES ('2024','item_brand_13_140',14000000000, 4000000000,80,100);

View File

@@ -53,7 +53,6 @@ COMMENT ON TABLE artist IS 'artist';
-------S2CompanyDemo
CREATE TABLE IF NOT EXISTS `company` (
`imp_date` varchar(50) ,
`company_id` varchar(50) NOT NULL ,
`company_name` varchar(50) NOT NULL ,
`headquarter_address` varchar(50) NOT NULL ,
@@ -66,7 +65,6 @@ CREATE TABLE IF NOT EXISTS `company` (
);
CREATE TABLE IF NOT EXISTS `brand` (
`imp_date` varchar(50) ,
`brand_id` varchar(50) NOT NULL ,
`brand_name` varchar(50) NOT NULL ,
`brand_established_time` varchar(20) NOT NULL ,
@@ -76,17 +74,7 @@ CREATE TABLE IF NOT EXISTS `brand` (
PRIMARY KEY (`brand_id`)
);
CREATE TABLE IF NOT EXISTS `company_revenue` (
`imp_date` varchar(50) ,
`company_id` varchar(50) NOT NULL ,
`brand_id` varchar(50) NOT NULL ,
`revenue_proportion` double NOT NULL,
`profit_proportion` double NOT NULL ,
`expenditure_proportion` double NOT NULL
);
CREATE TABLE IF NOT EXISTS `company_brand_revenue` (
`imp_date` varchar(50) ,
CREATE TABLE IF NOT EXISTS `brand_revenue` (
`year_time` varchar(10) NOT NULL ,
`brand_id` varchar(50) NOT NULL ,
`revenue` bigint(15) NOT NULL,

View File

@@ -1,3 +1,4 @@
-------S2VisitsDemo
CREATE TABLE IF NOT EXISTS `s2_user_department` (
`user_name` varchar(200) NOT NULL,
`department` varchar(200) NOT NULL
@@ -26,7 +27,7 @@ CREATE TABLE IF NOT EXISTS `singer` (
`favor_cnt` bigint DEFAULT NULL
)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- benchmark
-------S2ArtistDemo
CREATE TABLE IF NOT EXISTS `genre` (
`g_name` varchar(20) NOT NULL , -- genre name
`rating` INT ,

View File

@@ -1,27 +0,0 @@
package com.tencent.supersonic.headless;
import com.tencent.supersonic.common.pojo.User;
import com.tencent.supersonic.headless.api.pojo.request.ItemValueReq;
import com.tencent.supersonic.headless.api.pojo.response.ItemValueResp;
import com.tencent.supersonic.headless.server.service.TagQueryService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.springframework.beans.factory.annotation.Autowired;
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class TagTest extends BaseTest {
@Autowired
private TagQueryService tagQueryService;
@Test
public void testQueryTagValue() throws Exception {
ItemValueReq itemValueReq = new ItemValueReq();
itemValueReq.setId(1L);
ItemValueResp itemValueResp =
tagQueryService.queryTagValue(itemValueReq, User.getDefaultUser());
Assertions.assertNotNull(itemValueResp);
}
}

30118
webapp/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff