|
@@ -37,6 +37,8 @@ public class BuckStrategyV1 implements ReplyStrategyService {
|
|
|
*/
|
|
|
private static final String bucketStrategyConfig = "{\"stg0909-base\":[5,6],\"stg0909-explore1\":[7],\"stg0909-explore2\":[8,9]}";
|
|
|
|
|
|
+ private static final String bucketStrategyConfigV2 = "{\"default\":{\"base\":[0,1,2,3,4],\"stg0909-base\":[5,6],\"stg0909-explore1\":[7],\"stg0909-explore2\":[8,9]},\"gh_ac43e43b253b\":{\"base\":[0,1],\"stg0909-base\":[2,3,4,5,6],\"stg0909-explore1\":[7],\"stg0909-explore2\":[8,9]}}";
|
|
|
+
|
|
|
/**
|
|
|
* 自动回复使用小程序Id
|
|
|
*/
|
|
@@ -56,7 +58,7 @@ public class BuckStrategyV1 implements ReplyStrategyService {
|
|
|
@Override
|
|
|
public ReplyBucketData getResult(BucketDataParam bucketDataParam) {
|
|
|
// 0 获取策略key
|
|
|
- JSONObject bucketStrategyConfigJsonObject = JSON.parseObject(bucketStrategyConfig);
|
|
|
+ JSONObject bucketStrategyConfigJsonObject = getStrategyConfig(bucketDataParam.getGhId());
|
|
|
Set<String> keyedSet = bucketStrategyConfigJsonObject.keySet();
|
|
|
// 1 处理文章--算法引擎--排序文章数据
|
|
|
// getWenzhangData();
|
|
@@ -71,11 +73,32 @@ public class BuckStrategyV1 implements ReplyStrategyService {
|
|
|
return getReplyBucketData(bucketStrategyConfigJsonObject, keyedSet, bucketDataParam.getGhId());
|
|
|
}
|
|
|
|
|
|
+ private JSONObject getStrategyConfig(String ghId) {
|
|
|
+ JSONObject allStrategyConfigs = JSON.parseObject(bucketStrategyConfigV2);
|
|
|
+ JSONObject currentGhIdStrategyConfig = null;
|
|
|
+ if (allStrategyConfigs.containsKey(ghId)) {
|
|
|
+ currentGhIdStrategyConfig = allStrategyConfigs.getJSONObject(ghId);
|
|
|
+ } else if (allStrategyConfigs.containsKey("default")) {
|
|
|
+ currentGhIdStrategyConfig = allStrategyConfigs.getJSONObject("default");
|
|
|
+ } else {
|
|
|
+ log.error("invalid strategy config: default key does not exist");
|
|
|
+ throw new RuntimeException("Default strategy config does not exist");
|
|
|
+ }
|
|
|
+ // check param
|
|
|
+ if (!currentGhIdStrategyConfig.containsKey("base")) {
|
|
|
+ throw new RuntimeException("Strategy config does not have manual base");
|
|
|
+ }
|
|
|
+ return currentGhIdStrategyConfig;
|
|
|
+ }
|
|
|
+
|
|
|
private ReplyBucketData getReplyBucketData(JSONObject bucketStrategyConfigJsonObject, Set<String> keyedSet, String ghId) {
|
|
|
// 策略小程序数据
|
|
|
ReplyBucketData replyBucketData = new ReplyBucketData();
|
|
|
List<GroupData> groupDataList = new ArrayList<>();
|
|
|
for (String key : keyedSet) {
|
|
|
+ if ("base".equals(key)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key).andGhIdEqualTo(ghId);
|
|
|
cgiReplyBucketDataExample.setOrderByClause("sort");
|
|
@@ -110,6 +133,10 @@ public class BuckStrategyV1 implements ReplyStrategyService {
|
|
|
}
|
|
|
// 获取人工实验数据
|
|
|
List<GroupData> groupDataBaseList = httpClientService.sendPenGongBaseRequest(ghId);
|
|
|
+ int baseBucketNum = bucketStrategyConfigJsonObject.getJSONArray("base").size();
|
|
|
+ if (groupDataBaseList.size() > baseBucketNum) {
|
|
|
+ groupDataBaseList = groupDataBaseList.subList(0, baseBucketNum);
|
|
|
+ }
|
|
|
if (!CollectionUtils.isEmpty(groupDataBaseList)) {
|
|
|
GroupData groupData = groupDataBaseList.get(0);
|
|
|
List<MsgData> msgDataList = groupData.getMsgDataList();
|