Commit 62b4033d by 叶立庆

Merge branch 'v5.6.1' into 'master'

上线合并

See merge request !1
2 parents 3de084f5 ac9c1368
......@@ -20,7 +20,9 @@ import com.rop.annotation.ServiceMethodBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import javax.annotation.Resource;
import java.util.List;
......@@ -42,6 +44,9 @@ public class BatchMessagingController {
@Autowired
private GroupRemote groupRemote;
@Autowired
private Environment env;
@ServiceMethod(method = "entmicro.api.wechatcloudcontrol.nosession.batchmessaging.create", needInSession = NeedInSessionType.NO)
@ApiOperation("企微高级群发任务创建")
public RopResponse<Boolean> createBatchMessagingNoSessionTask(BatchMessagingCreateRopRequest request) {
......@@ -156,7 +161,15 @@ public class BatchMessagingController {
@ApiOperation("查询worktool群列表")
public RopResponse<RpcResponse<List<ScrmWorktoolGroupResponse>>> worktoolGroupList(WorkToolGroupListRopRequest workToolGroupListRopRequest) {
try {
return RopResponse.success(groupRemote.groupList(workToolGroupListRopRequest.getCloudId()));
RpcResponse<List<ScrmWorktoolGroupResponse>> groupResponse;
// 查询新版本喜报配置是否开启
String switchOpen = env.getProperty("dj.new.report.group.push.switch");
if (StringUtils.isNotEmpty(switchOpen) && "1".equals(switchOpen)){
groupResponse = batchMessagingService.getNewReportGroupList();
}else {
groupResponse = groupRemote.groupList(workToolGroupListRopRequest.getCloudId());
}
return RopResponse.success(groupResponse);
} catch (RpcServiceException e) {
log.info("=======BatchMessagingController_getActivityReportLogPage_invoke__exception:{}", e.getMessage());
return RopResponse.error(e.getErrId(), e.getMessage());
......
package cn.com.glsx.entmicro.response.entmicromerchant;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
* 接收群列表API响应的数据
*/
@Data
public class GroupItemResponse {
@JsonProperty("group_name")
private String groupName;
@JsonProperty("group_remark")
private String groupRemark;
}
......@@ -21,8 +21,14 @@ import cn.com.glsx.entmicro.response.wechatcloudcontrol.batchmessaging.BatchMess
import cn.com.glsx.entmicro.utils.Pagination;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.entmicro.utils.RopHttpUtil;
import cn.com.glsx.worktool.model.response.ScrmWorktoolGroupResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
......@@ -41,6 +47,9 @@ public class BatchMessagingService {
@Resource
private BatchMessagingRemote batchMessagingRemote;
@Autowired
private Environment env;
/**
* 企微高级群发任务创建
* @param ropRequest
......@@ -151,4 +160,23 @@ public class BatchMessagingService {
}
throw new RpcServiceException(response.getError(), response.getMessage());
}
public RpcResponse<List<ScrmWorktoolGroupResponse>> getNewReportGroupList() {
// 获取请求url
String requestUrl = env.getProperty("dj.new.report.group.push.url");
if (StringUtils.isBlank(requestUrl)) {
log.error("新版群推送url配置为空");
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, "新版群推送url配置为空");
}
log.info("requestUrl:{}", requestUrl);
try {
// 获取群列表
List<ScrmWorktoolGroupResponse> groupList = RopHttpUtil.getGroupList(requestUrl);
return RpcResponse.success(groupList);
} catch (Exception e) {
log.error("获取群列表失败", e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, "获取群列表失败: " + e.getMessage());
}
}
}
package cn.com.glsx.entmicro.utils;
import cn.com.glsx.entmicro.response.entmicromerchant.GroupItemResponse;
import cn.com.glsx.worktool.model.response.ScrmWorktoolGroupResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
......@@ -8,6 +11,8 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
import org.springframework.web.util.UriBuilder;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
......@@ -17,6 +22,7 @@ import java.util.Map.Entry;
* @description: http调用rop端服务
* @date 2021/7/30 11:26
*/
@Slf4j
public class RopHttpUtil {
private final static String appKey = "48e5e13229b82c1b4e6e8c96151f0637";
......@@ -69,6 +75,40 @@ public class RopHttpUtil {
return params;
}
/**
* 获取群列表
* @param requestUrl 请求URL
* @return 群列表
*/
public static List<ScrmWorktoolGroupResponse> getGroupList(String requestUrl) {
try {
RestTemplate restTemplate = new RestTemplate();
log.info("获取群列表,请求URL: {}", requestUrl);
// 发送GET请求获取群列表
GroupItemResponse[] groupItems = restTemplate.getForObject(requestUrl, GroupItemResponse[].class);
if (groupItems == null || groupItems.length == 0) {
log.warn("获取群列表为空");
return new ArrayList<>();
}
List<ScrmWorktoolGroupResponse> result = new ArrayList<>();
for (GroupItemResponse item : groupItems) {
ScrmWorktoolGroupResponse response = new ScrmWorktoolGroupResponse();
response.setId(null);
response.setRootId(null);
response.setDelFlag(0);
response.setGroupName(item.getGroupName());
String groupRemark = item.getGroupRemark();
response.setGroupRemark(groupRemark);
result.add(response);
}
log.info("获取群列表成功,共{}个群", result.size());
return result;
} catch (Exception e) {
log.error("获取群列表异常,URL: {}", requestUrl, e);
throw new RuntimeException("获取群列表失败: " + e.getMessage(), e);
}
}
static class RopUriTemplateHandler extends DefaultUriBuilderFactory {
public RopUriTemplateHandler(String baseUriTemplate) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!