|
|
@@ -1,11 +1,15 @@
|
|
|
package com.fs.company.controller.qw;
|
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
|
import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.framework.security.LoginUser;
|
|
|
@@ -16,10 +20,14 @@ import com.fs.qw.param.QwGroupMsgParam;
|
|
|
import com.fs.qw.service.IQwGroupMsgService;
|
|
|
import com.fs.qw.vo.QwGroupMsgDetailsVO;
|
|
|
import com.fs.qw.vo.QwGroupMsgVO;
|
|
|
+import com.fs.qwApi.config.OpenQwConfig;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.net.SocketTimeoutException;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -28,6 +36,7 @@ import java.util.List;
|
|
|
* @author fs
|
|
|
* @date 2024-06-20
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/qw/groupMsg")
|
|
|
public class QwGroupMsgController extends BaseController
|
|
|
@@ -37,6 +46,10 @@ public class QwGroupMsgController extends BaseController
|
|
|
|
|
|
@Autowired
|
|
|
private TokenService tokenService;
|
|
|
+
|
|
|
+ /** HTTP调用超时时间(秒) */
|
|
|
+ @Value("${qw.api.timeout:30}")
|
|
|
+ private int apiTimeout;
|
|
|
/**
|
|
|
* 查询客户群发记录主列表
|
|
|
*/
|
|
|
@@ -90,16 +103,34 @@ public class QwGroupMsgController extends BaseController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 新增客户群发/客户群群发记录
|
|
|
+ * 新增客户群发/客户群群发记录(远程调用fs-qw-api)
|
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('qw:groupMsg:add')")
|
|
|
@Log(title = "客户群发记录", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
public R add(@RequestBody QwGroupMsgParam qwGroupMsgParam) throws Exception {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
-// Long companyId = loginUser.getCompany().getCompanyId();
|
|
|
qwGroupMsgParam.setCreateName(loginUser.getUser().getNickName());
|
|
|
- return qwGroupMsgService.insertQwGroupMsg(qwGroupMsgParam);
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
+ String url = OpenQwConfig.api + "/qw/groupMsg/add?tenantId=" + tenantId;
|
|
|
+ try {
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
+ .body(JSON.toJSONString(qwGroupMsgParam))
|
|
|
+ .execute();
|
|
|
+ if (response.getStatus() == 200) {
|
|
|
+ return JSON.parseObject(response.body(), R.class);
|
|
|
+ } else {
|
|
|
+ log.error("新增客户群发记录失败,HTTP状态码: {}", response.getStatus());
|
|
|
+ return R.error("新增客户群发记录失败,服务返回状态码: " + response.getStatus());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("新增客户群发记录异常, url={}", url, e);
|
|
|
+ if (e.getCause() instanceof SocketTimeoutException) {
|
|
|
+ return R.error("新增客户群发记录超时,请稍后重试");
|
|
|
+ }
|
|
|
+ return R.error("新增客户群发记录失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** 统计数据详情,已发送,未发送,已接收,未接收等
|
|
|
@@ -129,13 +160,30 @@ public class QwGroupMsgController extends BaseController
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
|
- /** 提醒成员群发 */
|
|
|
+ /** 提醒成员群发(远程调用fs-qw-api) */
|
|
|
@PreAuthorize("@ss.hasPermi('qw:groupMsg:remindGroupMsg')")
|
|
|
@GetMapping("/remindGroupMsg")
|
|
|
public R remindGroupMsg(QwGroupMsgDetailsParam qwGroupMsgDetailsParam){
|
|
|
-
|
|
|
-
|
|
|
- return qwGroupMsgService.remindGroupMsg(qwGroupMsgDetailsParam);
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
+ String url = OpenQwConfig.api + "/qw/groupMsg/remindGroupMsg?tenantId=" + tenantId;
|
|
|
+ try {
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
+ .body(JSON.toJSONString(qwGroupMsgDetailsParam))
|
|
|
+ .execute();
|
|
|
+ if (response.getStatus() == 200) {
|
|
|
+ return JSON.parseObject(response.body(), R.class);
|
|
|
+ } else {
|
|
|
+ log.error("提醒成员群发失败,HTTP状态码: {}", response.getStatus());
|
|
|
+ return R.error("提醒成员群发失败,服务返回状态码: " + response.getStatus());
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("提醒成员群发异常, url={}", url, e);
|
|
|
+ if (e.getCause() instanceof SocketTimeoutException) {
|
|
|
+ return R.error("提醒成员群发超时,请稍后重试");
|
|
|
+ }
|
|
|
+ return R.error("提醒成员群发失败: " + e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// /**
|