|
@@ -1,5 +1,8 @@
|
|
|
package com.fs.company.controller.qw;
|
|
package com.fs.company.controller.qw;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.http.HttpRequest;
|
|
|
|
|
+import cn.hutool.http.HttpResponse;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.annotation.Log;
|
|
import com.fs.common.annotation.Log;
|
|
|
import com.fs.common.core.controller.BaseController;
|
|
import com.fs.common.core.controller.BaseController;
|
|
@@ -7,6 +10,7 @@ import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
import com.fs.common.enums.BusinessType;
|
|
|
|
|
+import com.fs.common.utils.SecurityUtils;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.TimeUtils;
|
|
import com.fs.common.utils.TimeUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
@@ -17,10 +21,14 @@ import com.fs.qw.domain.QwContactWay;
|
|
|
import com.fs.qw.param.QwStatisticsParam;
|
|
import com.fs.qw.param.QwStatisticsParam;
|
|
|
import com.fs.qw.service.IQwContactWayService;
|
|
import com.fs.qw.service.IQwContactWayService;
|
|
|
import com.fs.qw.service.IQwInformationService;
|
|
import com.fs.qw.service.IQwInformationService;
|
|
|
|
|
+import com.fs.qwApi.config.OpenQwConfig;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
+import java.net.SocketTimeoutException;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
@@ -31,6 +39,7 @@ import java.util.stream.Collectors;
|
|
|
* @author fs
|
|
* @author fs
|
|
|
* @date 2024-07-05
|
|
* @date 2024-07-05
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/qw/contactWay")
|
|
@RequestMapping("/qw/contactWay")
|
|
|
public class QwContactWayController extends BaseController
|
|
public class QwContactWayController extends BaseController
|
|
@@ -42,10 +51,13 @@ public class QwContactWayController extends BaseController
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IQwInformationService qwInformationService;
|
|
private IQwInformationService qwInformationService;
|
|
|
|
|
|
|
|
|
|
+ /** HTTP调用超时时间(秒) */
|
|
|
|
|
+ @Value("${qw.api.timeout:30}")
|
|
|
|
|
+ private int apiTimeout;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询企微活码列表
|
|
* 查询企微活码列表
|
|
|
*/
|
|
*/
|
|
|
-
|
|
|
|
|
@GetMapping("/list")
|
|
@GetMapping("/list")
|
|
|
public TableDataInfo list(QwContactWay qwContactWay)
|
|
public TableDataInfo list(QwContactWay qwContactWay)
|
|
|
{
|
|
{
|
|
@@ -60,9 +72,27 @@ public class QwContactWayController extends BaseController
|
|
|
@GetMapping("/sync/{corpId}")
|
|
@GetMapping("/sync/{corpId}")
|
|
|
public R sync(@PathVariable("corpId")String corpId)
|
|
public R sync(@PathVariable("corpId")String corpId)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- return qwContactWayService.selectQwContactWaysync(corpId);
|
|
|
|
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
|
|
+ String url = OpenQwConfig.api + "/qw/contactWay/sync/" + corpId + "?tenantId=" + tenantId;
|
|
|
|
|
+ try {
|
|
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
|
|
+ .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());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 导出企微活码列表
|
|
* 导出企微活码列表
|
|
|
*/
|
|
*/
|
|
@@ -71,7 +101,6 @@ public class QwContactWayController extends BaseController
|
|
|
@GetMapping("/export")
|
|
@GetMapping("/export")
|
|
|
public AjaxResult export(QwContactWay qwContactWay)
|
|
public AjaxResult export(QwContactWay qwContactWay)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
List<QwContactWay> list = qwContactWayService.selectQwContactWayList(qwContactWay);
|
|
List<QwContactWay> list = qwContactWayService.selectQwContactWayList(qwContactWay);
|
|
|
ExcelUtil<QwContactWay> util = new ExcelUtil<QwContactWay>(QwContactWay.class);
|
|
ExcelUtil<QwContactWay> util = new ExcelUtil<QwContactWay>(QwContactWay.class);
|
|
|
return util.exportExcel(list, "企微活码数据");
|
|
return util.exportExcel(list, "企微活码数据");
|
|
@@ -97,7 +126,26 @@ public class QwContactWayController extends BaseController
|
|
|
{
|
|
{
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
qwContactWay.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
qwContactWay.setCompanyId(loginUser.getCompany().getCompanyId());
|
|
|
- return qwContactWayService.insertQwContactWay(qwContactWay);
|
|
|
|
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
|
|
+ String url = OpenQwConfig.api + "/qw/contactWay/add?tenantId=" + tenantId;
|
|
|
|
|
+ try {
|
|
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
|
|
+ .body(JSON.toJSONString(qwContactWay))
|
|
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
|
|
+ .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());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -108,7 +156,26 @@ public class QwContactWayController extends BaseController
|
|
|
@PutMapping
|
|
@PutMapping
|
|
|
public R edit(@RequestBody QwContactWay qwContactWay)
|
|
public R edit(@RequestBody QwContactWay qwContactWay)
|
|
|
{
|
|
{
|
|
|
- return qwContactWayService.updateQwContactWay(qwContactWay);
|
|
|
|
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
|
|
+ String url = OpenQwConfig.api + "/qw/contactWay/edit?tenantId=" + tenantId;
|
|
|
|
|
+ try {
|
|
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
|
|
+ .body(JSON.toJSONString(qwContactWay))
|
|
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
|
|
+ .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());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -116,17 +183,34 @@ public class QwContactWayController extends BaseController
|
|
|
*/
|
|
*/
|
|
|
@PreAuthorize("@ss.hasPermi('qw:contactWay:remove')")
|
|
@PreAuthorize("@ss.hasPermi('qw:contactWay:remove')")
|
|
|
@Log(title = "企微活码", businessType = BusinessType.DELETE)
|
|
@Log(title = "企微活码", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
|
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
public R remove(@PathVariable Long[] ids)
|
|
public R remove(@PathVariable Long[] ids)
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- return qwContactWayService.deleteQwContactWayByIds(ids);
|
|
|
|
|
|
|
+ Long tenantId = SecurityUtils.getTenantId();
|
|
|
|
|
+ String url = OpenQwConfig.api + "/qw/contactWay/delete?tenantId=" + tenantId;
|
|
|
|
|
+ try {
|
|
|
|
|
+ HttpResponse response = HttpRequest.post(url)
|
|
|
|
|
+ .body(JSON.toJSONString(ids))
|
|
|
|
|
+ .timeout(apiTimeout * 1000)
|
|
|
|
|
+ .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());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/statistics")
|
|
@GetMapping("/statistics")
|
|
|
public R statistics(QwStatisticsParam param)
|
|
public R statistics(QwStatisticsParam param)
|
|
|
{
|
|
{
|
|
|
-// List<QwWayStatisticsListVO> list= qwContactWayService.QwWayStatisticsListVO(param);
|
|
|
|
|
TimeUtils.TimeEntity timeEntity= TimeUtils.parseTime(param.getType().toString(),param.getStartTime(),param.getEndTime());
|
|
TimeUtils.TimeEntity timeEntity= TimeUtils.parseTime(param.getType().toString(),param.getStartTime(),param.getEndTime());
|
|
|
timeEntity.setCompanyId(param.getWayId());
|
|
timeEntity.setCompanyId(param.getWayId());
|
|
|
Integer cycleNum = timeEntity.getCycleNum();
|
|
Integer cycleNum = timeEntity.getCycleNum();
|
|
@@ -142,7 +226,6 @@ public class QwContactWayController extends BaseController
|
|
|
List<Integer> deleteNum = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("deleteNum")).collect(Collectors.toList());
|
|
List<Integer> deleteNum = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("deleteNum")).collect(Collectors.toList());
|
|
|
List<Integer> num = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("num")).collect(Collectors.toList());
|
|
List<Integer> num = jsonObjectList.stream().map(jsonObject -> jsonObject.getInteger("num")).collect(Collectors.toList());
|
|
|
return R.ok().put("list",jsonObjectList).put("dates",dates).put("addNum",addNum).put("deleteNum",deleteNum).put("num",num);
|
|
return R.ok().put("list",jsonObjectList).put("dates",dates).put("addNum",addNum).put("deleteNum",deleteNum).put("num",num);
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|