From bf8a701e57847f01a35e785a8e2703f6770903a5 Mon Sep 17 00:00:00 2001 From: huangweixiong Date: Fri, 26 Aug 2022 13:44:04 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=91=E5=AE=8F=E5=BE=85=E5=8A=9E=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/config/RestTemplateConfig.java | 4 + .../controller/MonitorControllerV2.java | 14 +++ .../service/impl/SysNoticeServiceImpl.java | 90 ++++++++++++++++++- .../domain/TsingtaoDataResourceService.java | 2 +- .../modules/sys/entity/SysUserEntity.java | 5 ++ 5 files changed, 110 insertions(+), 5 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java b/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java index a4004984..9eccef43 100644 --- a/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java +++ b/renren-admin/src/main/java/io/renren/common/config/RestTemplateConfig.java @@ -31,6 +31,10 @@ public class RestTemplateConfig { factory.setReadTimeout(30 * 000);//单位为ms factory.setConnectTimeout(5 * 1000);//单位为ms factory.setOutputStreaming(false); + +// InetSocketAddress socketAddress = new InetSocketAddress("192.168.124.31", 8888); +// factory.setProxy(new Proxy(Proxy.Type.HTTP, socketAddress)); + return factory; } } diff --git a/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorControllerV2.java b/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorControllerV2.java index c9c2eccf..3614dd09 100644 --- a/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorControllerV2.java +++ b/renren-admin/src/main/java/io/renren/modules/gateway/controller/MonitorControllerV2.java @@ -4,10 +4,13 @@ package io.renren.modules.gateway.controller; import cn.hutool.core.io.FileUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.google.common.collect.Lists; import io.renren.modules.gateway.dao.ApiCountHistoryDao; import io.renren.modules.gateway.entity.ApiCountHistoryEntity; import io.renren.modules.gateway.service.MonitorServiceV2; import io.renren.modules.monitor.entity.Result; +import io.renren.modules.notice.dto.SysNoticeDTO; +import io.renren.modules.notice.service.impl.SysNoticeServiceImpl; import io.renren.modules.resource.dao.AttrDao; import io.renren.modules.resource.dao.ResourceDao; import io.renren.modules.resource.entity.AttrEntity; @@ -75,6 +78,9 @@ public class MonitorControllerV2 { @Autowired private ApiCountHistoryDao apiCountHistoryDao; + @Autowired + private SysNoticeServiceImpl sysNoticeService; + public List queryMetricCount(String queryFormat, Long start, Long end, String metricElement, int limit) throws InterruptedException, ExecutionException, TimeoutException { String url = gatewayDomain + "/juapi/metrics/api/v1/query?query={query}&time={time}"; @@ -325,4 +331,12 @@ public class MonitorControllerV2 { return Result.success(callCount); } + @GetMapping("/sendMsg") + @ApiOperation("查询总api调用总量") + public void sendMsg(){ + SysNoticeDTO sysNoticeDTO = new SysNoticeDTO(); + sysNoticeDTO.setTitle("请审批yyyy的流程申请"); + sysNoticeService.sendToYaweiUser(sysNoticeDTO, Lists.newArrayList(1513432847327199233L)); + } + } diff --git a/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java index eeee3649..003670b9 100644 --- a/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/notice/service/impl/SysNoticeServiceImpl.java @@ -7,6 +7,7 @@ import io.renren.common.constant.Constant; import io.renren.common.page.PageData; import io.renren.common.service.impl.CrudServiceImpl; import io.renren.common.utils.ConvertUtils; +import io.renren.common.utils.Result; import io.renren.modules.notice.dao.SysNoticeDao; import io.renren.modules.notice.dto.SysNoticeDTO; import io.renren.modules.notice.entity.SysNoticeEntity; @@ -17,7 +18,9 @@ import io.renren.modules.notice.enums.ReceiverTypeEnum; import io.renren.modules.notice.service.SysNoticeService; import io.renren.modules.notice.service.SysNoticeUserService; import io.renren.modules.security.user.SecurityUser; +import io.renren.modules.sys.dao.SysUserDao; import io.renren.modules.sys.dto.SysUserDTO; +import io.renren.modules.sys.entity.SysUserEntity; import io.renren.modules.sys.service.SysUserService; import io.renren.websocket.WebSocketServer; import io.renren.websocket.data.MessageData; @@ -26,14 +29,16 @@ import org.apache.shiro.session.UnknownSessionException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.nio.charset.StandardCharsets; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -53,6 +58,10 @@ public class SysNoticeServiceImpl extends CrudServiceImpl getWrapper(Map params) { @@ -185,6 +194,7 @@ public class SysNoticeServiceImpl extends CrudServiceImpl message = new MessageData().msg(notice.getTitle()); webSocketServer.sendMessage(finalUserIdList, message); + sendToYaweiUser(notice, finalUserIdList); }, executor); } } @@ -213,5 +223,77 @@ public class SysNoticeServiceImpl extends CrudServiceImpl userIdList) { + + List sysUserEntities = sysUserDao.selectBatchIds(userIdList); + + StringBuilder userNames = new StringBuilder(); + StringBuilder userGuids = new StringBuilder(); + StringBuilder exchangeCodes = new StringBuilder(); + for (SysUserEntity sysUserEntity : sysUserEntities) { + userNames.append(sysUserEntity.getUsername() + ";"); + String guid = sysUserEntity.getGuid(); + if (StringUtils.isNotBlank(guid)) { + userGuids.append(guid + ";"); + } + String ywMobile = sysUserEntity.getYwMobile(); + if (StringUtils.isNotBlank(ywMobile)) { + exchangeCodes.append(ywMobile + ";"); + } + } + if (userNames.charAt(userNames.length()-1) == ';') { + userNames.deleteCharAt(userNames.length()-1); + } + if (userGuids.charAt(userGuids.length()-1) == ';') { + userGuids.deleteCharAt(userGuids.length()-1); + } + if (exchangeCodes.charAt(exchangeCodes.length()-1) == ';') { + exchangeCodes.deleteCharAt(exchangeCodes.length()-1); + } + + + String url = "http://15.72.158.155/jhoa200/OAReceiver/OuterSystemOAReceiver.asmx"; + String param = "\n" + + "\n" + + " \n" + + " \n" + + String.format("{%s}\n", UUID.randomUUID().toString().toUpperCase()) + + String.format("{%s}\n", UUID.randomUUID().toString().toUpperCase()) + + String.format("%s\n",notice.getTitle()) + + " 2\n" + + String.format("%s\n", userNames.toString()) + + String.format("%s\n", userGuids.toString()) + + " 能力平台\n" + //没有发送人定义,先写死 + " BE604908-D7A3-4947-9CAD-A70FF2E48AB1\n" + //没有发送人定义,先写死 + " 其他\n" + + " 1\n" + + " http://15.72.183.90:7008\n" + + " 1\n" + + " 0\n" + + " 0\n" + + " 00010000000000000058\n" + + String.format("%s\n", exchangeCodes.toString()) + + " 20040\n" + + " \n" + + " \n" + + ""; + HttpHeaders requestHeaders = new HttpHeaders(); + requestHeaders.set("SOAPAction", "http://tempuri.org/InsertTodealByPollCode"); + requestHeaders.setContentType(new MediaType("text", "xml", StandardCharsets.UTF_8)); + HttpEntity requestEntity = new HttpEntity<>(param, requestHeaders); + try { + String body = restTemplate.postForEntity(url, requestEntity, String.class).getBody(); + //返回示例 +// +// 1 +// + if (!body.contains("1")) { + logger.error("推送待办失败:" + body); + } + } catch (Exception e) { + logger.error("推送亚威待办失败", e); + } + } + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java index 89fbdb4b..e6e68702 100644 --- a/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java +++ b/renren-admin/src/main/java/io/renren/modules/resource/dataResource/domain/TsingtaoDataResourceService.java @@ -78,7 +78,7 @@ public class TsingtaoDataResourceService extends AbstractDataResourceService { return result; } catch (Exception e) { - logger.error("青岛市资源数据调用失败!!!"); + logger.error("青岛市资源数据调用失败!!!",e); return null; } } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/entity/SysUserEntity.java b/renren-admin/src/main/java/io/renren/modules/sys/entity/SysUserEntity.java index 030bf5a3..f5242299 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/entity/SysUserEntity.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/entity/SysUserEntity.java @@ -79,4 +79,9 @@ public class SysUserEntity extends BaseEntity { */ private String guid; + /** + * 亚威的不知道什么exchangecode + */ + private String ywMobile; + } \ No newline at end of file