From 77837e86913ee7997ab1ac07f108ce71e7bef451 Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Sun, 3 Jul 2022 11:34:15 +0800 Subject: [PATCH 01/11] init_release --- .github/workflows/deploy-agent.yml | 8 ++++---- .github/workflows/deploy.yml | 4 ++-- docker-compose.yml | 10 +++++----- docker-compose2.yml | 10 +++++----- pom.xml | 2 +- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy-agent.yml b/.github/workflows/deploy-agent.yml index dcc6f82e..cb4dcb10 100644 --- a/.github/workflows/deploy-agent.yml +++ b/.github/workflows/deploy-agent.yml @@ -21,12 +21,12 @@ jobs: - name: git Actions uses: srt32/git-actions@v0.0.3 - name: get agent - run: git clone https://github.com/SonicCloudOrg/sonic-agent.git && cd sonic-agent && mvn package -Plinux-x86_64 && docker build -t sonicorg/sonic-agent-linux:v1.4.1-rc -f src/main/docker/Dockerfile . + run: git clone https://github.com/SonicCloudOrg/sonic-agent.git && cd sonic-agent && mvn package -Plinux-x86_64 && docker build -t sonicorg/sonic-agent-linux:v1.4.1-release -f src/main/docker/Dockerfile . - name: push - run: docker push sonicorg/sonic-agent-linux:v1.4.1-rc + run: docker push sonicorg/sonic-agent-linux:v1.4.1-release - name: login docker hub run: echo "${{ secrets.ACCESS_TOKEN_ALIYUN }}" | docker login --username=小虫哔哔 registry.cn-hangzhou.aliyuncs.com --password-stdin - name: tag - run: docker tag sonicorg/sonic-agent-linux:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-rc + run: docker tag sonicorg/sonic-agent-linux:v1.4.1-release registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-release - name: push - run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-rc + run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-agent-linux:v1.4.1-release diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9bf3f62b..6f49e3fb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,6 +23,6 @@ jobs: - name: login docker hub run: echo "${{ secrets.ACCESS_TOKEN_ALIYUN }}" | docker login --username=小虫哔哔 registry.cn-hangzhou.aliyuncs.com --password-stdin - name: tag - run: docker tag sonicorg/sonic-server-eureka:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-rc && docker tag sonicorg/sonic-server-controller:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-rc && docker tag sonicorg/sonic-server-folder:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-rc && docker tag sonicorg/sonic-server-gateway:v1.4.1-rc registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-rc + run: docker tag sonicorg/sonic-server-eureka:v1.4.1-release registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-release && docker tag sonicorg/sonic-server-controller:v1.4.1-release registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-release && docker tag sonicorg/sonic-server-folder:v1.4.1-release registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-release && docker tag sonicorg/sonic-server-gateway:v1.4.1-release registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-release - name: push - run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-rc && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-rc && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-rc && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-rc + run: docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-release && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-release && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-release && docker push registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-release diff --git a/docker-compose.yml b/docker-compose.yml index c031c8b6..9e9f82ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3' services: sonic-server-eureka: - image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-rc" + image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.1-release" hostname: sonic-server-eureka environment: - SONIC_EUREKA_USERNAME @@ -15,7 +15,7 @@ services: ports: - "${SONIC_EUREKA_PORT}:${SONIC_EUREKA_PORT}" sonic-server-gateway: - image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-rc" + image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.1-release" hostname: sonic-server-gateway environment: - SONIC_EUREKA_USERNAME @@ -32,7 +32,7 @@ services: - sonic-network restart: on-failure sonic-server-controller: - image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-rc" + image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.1-release" environment: - SONIC_EUREKA_USERNAME - SONIC_EUREKA_PASSWORD @@ -64,7 +64,7 @@ services: - sonic-server-eureka restart: on-failure sonic-server-folder: - image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-rc" + image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.1-release" environment: - SONIC_EUREKA_USERNAME - SONIC_EUREKA_PASSWORD @@ -86,7 +86,7 @@ services: - sonic-server-eureka restart: on-failure sonic-client-web: - image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-client-web:v1.4.1-rc" + image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-client-web:v1.4.1-release" environment: - SONIC_SERVER_HOST - SONIC_SERVER_PORT diff --git a/docker-compose2.yml b/docker-compose2.yml index 64826d62..784460d1 100644 --- a/docker-compose2.yml +++ b/docker-compose2.yml @@ -1,7 +1,7 @@ version: '3' services: sonic-server-eureka: - image: "sonicorg/sonic-server-eureka:v1.4.1-rc" + image: "sonicorg/sonic-server-eureka:v1.4.1-release" hostname: sonic-server-eureka environment: - SONIC_EUREKA_USERNAME @@ -15,7 +15,7 @@ services: ports: - "${SONIC_EUREKA_PORT}:${SONIC_EUREKA_PORT}" sonic-server-gateway: - image: "sonicorg/sonic-server-gateway:v1.4.1-rc" + image: "sonicorg/sonic-server-gateway:v1.4.1-release" hostname: sonic-server-gateway environment: - SONIC_EUREKA_USERNAME @@ -32,7 +32,7 @@ services: - sonic-network restart: on-failure sonic-server-controller: - image: "sonicorg/sonic-server-controller:v1.4.1-rc" + image: "sonicorg/sonic-server-controller:v1.4.1-release" environment: - SONIC_EUREKA_USERNAME - SONIC_EUREKA_PASSWORD @@ -64,7 +64,7 @@ services: - sonic-server-eureka restart: on-failure sonic-server-folder: - image: "sonicorg/sonic-server-folder:v1.4.1-rc" + image: "sonicorg/sonic-server-folder:v1.4.1-release" environment: - SONIC_EUREKA_USERNAME - SONIC_EUREKA_PASSWORD @@ -86,7 +86,7 @@ services: - sonic-server-eureka restart: on-failure sonic-client-web: - image: "sonicorg/sonic-client-web:v1.4.1-rc" + image: "sonicorg/sonic-client-web:v1.4.1-release" environment: - SONIC_SERVER_HOST - SONIC_SERVER_PORT diff --git a/pom.xml b/pom.xml index 6de40a3f..53bf7624 100644 --- a/pom.xml +++ b/pom.xml @@ -28,7 +28,7 @@ 15 15 - 1.4.1-rc + 1.4.1-release From 7e6e580bb867ce624264f7fca4733264f342d6b3 Mon Sep 17 00:00:00 2001 From: "shanming.sun" Date: Mon, 4 Jul 2022 19:41:23 +0800 Subject: [PATCH 02/11] =?UTF-8?q?fix:=201.=20=E8=BF=87=E6=BB=A4=E7=88=B6?= =?UTF-8?q?=E7=BA=A7=E7=99=BD=E5=90=8D=E5=8D=95=E8=B5=84=E6=BA=90=202.=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=A7=92=E8=89=B2=E5=A2=9E=E5=8A=A0=E4=B8=8D?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sonic/controller/controller/RolesController.java | 9 +++++++-- .../controller/services/impl/ResourcesServiceImpl.java | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/RolesController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/RolesController.java index 41001adc..30836986 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/RolesController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/RolesController.java @@ -33,12 +33,17 @@ public class RolesController { @GetMapping("/list") @ApiImplicitParams(value = { @ApiImplicitParam(name = "page", value = "页码", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "isAll", value = "是否全部", dataTypeClass = Boolean.class), @ApiImplicitParam(name = "roleName", value = "角色名称", dataTypeClass = String.class), }) - public RespModel> listResources(@RequestParam(name = "page") int page - , @RequestParam(name = "roleName", required = false) String roleName) { + public RespModel> listResources(@RequestParam(name = "page") int page, + @RequestParam(name = "isAll", required = false) boolean isAll, + @RequestParam(name = "roleName", required = false) String roleName) { Page pageable = new Page<>(page, 20); + if (isAll) { + pageable.setSize(1000L); + } return RespModel.result(RespEnum.SEARCH_OK, rolesServices.listRoles(pageable, roleName)); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/ResourcesServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/ResourcesServiceImpl.java index 4c8d9a0e..ab50a08f 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/ResourcesServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/ResourcesServiceImpl.java @@ -99,6 +99,8 @@ private Resources processParent(String beanName, Map parentMa parentResource.setDesc(tag); parentResource.setPath(res); parentResource.setVersion(version); + // 每次扫描都把parent 设置为正常资源 + parentResource.setWhite(UrlType.NORMAL ); if (needInsert) { insert(parentResource); @@ -202,6 +204,7 @@ public CommentPage listResource(Page page, String path, private List listParentResource() { return lambdaQuery().eq(Resources::getParentId, UrlType.PARENT) + .eq(Resources::getWhite, UrlType.NORMAL) .orderByDesc(Resources::getId) .list().stream() .map(TypeConverter::convertTo).collect(Collectors.toList()); From 0b58a6a5a54f34c9bc0c5b4f730e58c4b72d89dc Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Wed, 6 Jul 2022 20:35:46 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E4=BD=93=E8=BF=87=E9=95=BF=E5=AF=BC=E8=87=B4=E6=96=AD=E8=BF=9E?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-sonic-server-gateway.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sonic-server-common/src/main/resources/application-sonic-server-gateway.yml b/sonic-server-common/src/main/resources/application-sonic-server-gateway.yml index c83fa562..fb0caacf 100644 --- a/sonic-server-common/src/main/resources/application-sonic-server-gateway.yml +++ b/sonic-server-common/src/main/resources/application-sonic-server-gateway.yml @@ -8,6 +8,9 @@ filter: spring: cloud: gateway: + httpclient: + websocket: + max-frame-payload-length: 314572800 routes: - id: controller uri: lb://sonic-server-controller From e77d282449ddef04068df4de75f1773b1e806334 Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Wed, 6 Jul 2022 21:21:26 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E9=94=99=E4=BD=8D=E4=B8=8E=E5=AE=89=E8=A3=85=E5=8C=85?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/cloud/sonic/controller/controller/AgentsController.java | 2 +- .../sonic/controller/services/impl/PackagesServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java index 1ffe5f8d..0792a371 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/AgentsController.java @@ -62,7 +62,7 @@ public RespModel update(@RequestBody JSONObject jsonObject) { agentsService.update(jsonObject.getInteger("id"), jsonObject.getString("name"), jsonObject.getInteger("highTemp"), jsonObject.getInteger("highTempTime"), jsonObject.getInteger("robotType"), - jsonObject.getString("robotToken"), jsonObject.getString("robotToken")); + jsonObject.getString("robotToken"), jsonObject.getString("robotSecret")); return new RespModel<>(RespEnum.HANDLE_OK); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PackagesServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PackagesServiceImpl.java index 3a246887..f26d71e8 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PackagesServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/PackagesServiceImpl.java @@ -45,7 +45,7 @@ public String findOne(int projectId, String branch, String platform) { Packages packages = lambdaQuery().eq(Packages::getProjectId, projectId) .eq(StringUtils.isNotBlank(platform), Packages::getPlatform, platform) .like(StringUtils.isNotBlank(branch), Packages::getBranch, branch) - .orderByDesc(Packages::getId).one(); + .orderByDesc(Packages::getId).last("LIMIT 1").one(); if (packages != null) { return packages.getUrl(); } else { From ca70a972726ddc21025c11ce5e856e267b3ccbae Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Thu, 7 Jul 2022 21:32:42 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E6=A1=88?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/controller/GlobalParamsController.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/GlobalParamsController.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/GlobalParamsController.java index b2d1ec59..4a9e245a 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/GlobalParamsController.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/controller/GlobalParamsController.java @@ -31,7 +31,7 @@ import java.util.List; -@Api(tags = "公共参数相关") +@Api(tags = "全局参数相关") @RestController @RequestMapping("/globalParams") public class GlobalParamsController { @@ -40,7 +40,7 @@ public class GlobalParamsController { private GlobalParamsService globalParamsService; @WebAspect - @ApiOperation(value = "更新公共参数", notes = "新增或更新对应的公共参数") + @ApiOperation(value = "更新全局参数", notes = "新增或更新对应的全局参数") @PutMapping public RespModel save(@Validated @RequestBody GlobalParamsDTO globalParamsDTO) { globalParamsService.save(globalParamsDTO.convertTo()); @@ -48,7 +48,7 @@ public RespModel save(@Validated @RequestBody GlobalParamsDTO globalPara } @WebAspect - @ApiOperation(value = "查找公共参数", notes = "查找对应项目id的公共参数列表") + @ApiOperation(value = "查找全局参数", notes = "查找对应项目id的全局参数列表") @ApiImplicitParam(name = "projectId", value = "项目id", dataTypeClass = Integer.class) @GetMapping("/list") public RespModel> findByProjectId(@RequestParam(name = "projectId") int projectId) { @@ -56,7 +56,7 @@ public RespModel> findByProjectId(@RequestParam(name = "proje } @WebAspect - @ApiOperation(value = "删除公共参数", notes = "删除对应id的公共参数") + @ApiOperation(value = "删除全局参数", notes = "删除对应id的全局参数") @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class) @DeleteMapping public RespModel delete(@RequestParam(name = "id") int id) { @@ -68,7 +68,7 @@ public RespModel delete(@RequestParam(name = "id") int id) { } @WebAspect - @ApiOperation(value = "查看公共参数信息", notes = "查看对应id的公共参数") + @ApiOperation(value = "查看全局参数信息", notes = "查看对应id的全局参数") @ApiImplicitParam(name = "id", value = "id", dataTypeClass = Integer.class) @GetMapping public RespModel findById(@RequestParam(name = "id") int id) { From fe8b48ce04c0a32c07507abb00d2f3b239cdb95b Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Sat, 9 Jul 2022 16:07:41 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E9=AB=98=E6=B8=A9=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=A3=9E=E4=B9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sonic/controller/tools/RobotMsgTool.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java index 48b13eee..98e31f9d 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java @@ -290,6 +290,28 @@ public void sendErrorDevice(String token, String secret, int type, int errorType jsonObject.put("msgtype", "markdown"); jsonObject.put("markdown", markdown); } + if (type == RobotType.FeiShu) { + jsonObject.put("msg_type", "interactive"); + JSONObject card = new JSONObject(); + JSONObject config = new JSONObject(); + config.put("wide_screen_mode", true); + card.put("config", config); + JSONObject element = new JSONObject(); + element.put("tag", "markdown"); + List elementList = new ArrayList<>(); + if (errorType == 1) { + element.put("content", "**设备高温预警**\n" + + "设备序列号:" + udId + " \n" + + "电池温度:" + (tem / 10) + " ℃"); + } else { + element.put("content", "**设备高温超时,已关机!**\n" + + "设备序列号:" + udId + " \n" + + "电池温度:" + (tem / 10) + " ℃"); + } + elementList.add(element); + card.put("elements", elementList); + jsonObject.put("card", card); + } signAndSend(token, secret, type, jsonObject); } @@ -340,7 +362,7 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St "项目:" + projectName + " \n" + "时间:" + yesterday + " ~ " + today + " \n" + "共测试:" + count + " 次\n" + - "通过数:" + passCount + " \n" + + "通过数:" + passCount + " \n" + "异常数:" + warnCount + " \n" + "失败数:" + failCount + " \n" + "测试通过率:" + (total > 0 ? From 76db789d0b3a571570b81c00417455bca3f939f8 Mon Sep 17 00:00:00 2001 From: ZhouYixun <291028775@qq.com> Date: Sat, 9 Jul 2022 18:03:26 +0800 Subject: [PATCH 07/11] init_wechat --- .../org/cloud/sonic/controller/tools/RobotMsgTool.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java index 98e31f9d..8fcdc5b6 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java @@ -81,11 +81,16 @@ private void signAndSend(String token, String secret, int type, JSONObject jsonO ResponseEntity responseEntity = restTemplate.postForEntity(token + "×tamp=" + timestamp + "&sign=" + sign , jsonObject, JSONObject.class); - logger.info("机器人发送结果:" + responseEntity.getBody()); + logger.info("robot result: " + responseEntity.getBody()); break; } - case RobotType.WeChat: + case RobotType.WeChat: { + ResponseEntity responseEntity = + restTemplate.postForEntity(token + "?key=" + secret + , jsonObject, JSONObject.class); + logger.info("robot result: " + responseEntity.getBody()); break; + } case RobotType.FeiShu: { String timestamp = String.valueOf(System.currentTimeMillis()).substring(0, 10); String stringToSign = timestamp + "\n" + secret; From c8a230695d6d029e184b5a297a039cc89411bdf3 Mon Sep 17 00:00:00 2001 From: "shanming.sun" Date: Sat, 9 Jul 2022 23:28:39 +0800 Subject: [PATCH 08/11] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E6=9C=BA=E5=99=A8=E4=BA=BA=E5=92=8C=E8=A1=A5=E5=85=85?= =?UTF-8?q?=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sonic-server-controller/pom.xml | 6 + .../sonic/controller/tools/RobotMsgTool.java | 114 +++++++++++++++++- .../org/cloud/sonic/controller/BaseUnit.java | 13 ++ .../sonic/controller/tools/RobotTest.java | 54 +++++++++ 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 sonic-server-controller/src/test/java/org/cloud/sonic/controller/BaseUnit.java create mode 100644 sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java diff --git a/sonic-server-controller/pom.xml b/sonic-server-controller/pom.xml index 2e61320e..3c2c7194 100644 --- a/sonic-server-controller/pom.xml +++ b/sonic-server-controller/pom.xml @@ -20,6 +20,12 @@ org.springframework.cloud spring-cloud-starter-openfeign + + + org.springframework.boot + spring-boot-starter-test + test + org.springframework.cloud diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java index 48b13eee..7f066956 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java @@ -84,7 +84,12 @@ private void signAndSend(String token, String secret, int type, JSONObject jsonO logger.info("机器人发送结果:" + responseEntity.getBody()); break; } - case RobotType.WeChat: + case RobotType.WeChat: { + ResponseEntity responseEntity = + restTemplate.postForEntity(token , jsonObject, JSONObject.class); + logger.info("机器人发送结果:" + responseEntity.getBody()); + } + break; case RobotType.FeiShu: { String timestamp = String.valueOf(System.currentTimeMillis()).substring(0, 10); @@ -143,6 +148,17 @@ public void sendResultFinishReport(String token, String secret, String suiteName jsonObject.put("msgtype", "link"); jsonObject.put("link", link); } + if (type == RobotType.WeChat) { + jsonObject.put("msgtype", "markdown"); + JSONObject markdown = new JSONObject(); + markdown.put("content", "**测试套件: " + suiteName + " 运行完毕!**\n" + + "通过数:" + pass + " \n" + + "异常数:" + warn + " \n" + + "失败数:" + fail + "\n" + + "测试报告:[点击查看](" + clientHost + "/Home/" + projectId + "/ResultDetail/" + resultId + ")"); + jsonObject.put("markdown", markdown); + + } if (type == RobotType.FeiShu) { jsonObject.put("msg_type", "interactive"); JSONObject card = new JSONObject(); @@ -247,6 +263,33 @@ public void sendDayReportMessage(String token, String secret, int projectId, Str jsonObject.put("msgtype", "markdown"); jsonObject.put("markdown", markdown); } + if (type == RobotType.WeChat) { + String warnColorString; + if (warnCount == 0) { + warnColorString = "" + warnCount + ""; + } else { + warnColorString = "" + warnCount + ""; + } + String failColorString; + if (failCount == 0) { + failColorString = "" + failCount + ""; + } else { + failColorString = "" + failCount + ""; + } + int total = passCount + warnCount + failCount; + jsonObject.put("msgtype", "markdown"); + JSONObject markdown = new JSONObject(); + markdown.put("content", "### Sonic云真机测试平台日报 \n" + + "> ###### 项目:" + projectName + " \n" + + "> ###### 时间:" + yesterday + " ~ " + today + " \n" + + "> ###### 通过数:" + passCount + " \n" + + "> ###### 异常数:" + warnColorString + " \n" + + "> ###### 失败数:" + failColorString + " \n" + + "> ###### 测试通过率:" + (total > 0 ? + new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" + + "> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")"); + jsonObject.put("markdown", markdown); + } if (type == RobotType.FeiShu) { jsonObject.put("msg_type", "interactive"); JSONObject card = new JSONObject(); @@ -290,6 +333,46 @@ public void sendErrorDevice(String token, String secret, int type, int errorType jsonObject.put("msgtype", "markdown"); jsonObject.put("markdown", markdown); } + + if (type == RobotType.WeChat) { + JSONObject markdown = new JSONObject(); + if (errorType == 1) { + markdown.put("content", "### 设备高温预警 \n" + + "> ###### 设备序列号:" + udId + " \n" + + "> ###### 电池温度:" + (tem / 10) + " ℃"); + } else { + markdown.put("text", "### 设备高温超时,已关机! \n" + + "> ###### 设备序列号:" + udId + " \n" + + "> ###### 电池温度:" + (tem / 10) + " ℃"); + } + jsonObject.put("msgtype", "markdown"); + jsonObject.put("markdown", markdown); + } + + if (type == RobotType.FeiShu) { + jsonObject.put("msg_type", "interactive"); + JSONObject card = new JSONObject(); + JSONObject config = new JSONObject(); + config.put("wide_screen_mode", true); + card.put("config", config); + JSONObject element = new JSONObject(); + element.put("tag", "markdown"); + List elementList = new ArrayList<>(); + + if (errorType == 1) { + element.put("content", "**设备高温预警** \n" + + "设备序列号:" + udId + " \n" + + "电池温度:" + (tem / 10) + " ℃"); + } else { + element.put("text", "### 设备高温超时,已关机! \n" + + "设备序列号:" + udId + " \n" + + "电池温度:" + (tem / 10) + " ℃"); + } + elementList.add(element); + card.put("elements", elementList); + jsonObject.put("card", card); + } + signAndSend(token, secret, type, jsonObject); } @@ -326,6 +409,35 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St jsonObject.put("msgtype", "markdown"); jsonObject.put("markdown", markdown); } + if (type == RobotType.WeChat) { + String warnColorString; + if (warnCount == 0) { + warnColorString = "" + warnCount + ""; + } else { + warnColorString = "" + warnCount + ""; + } + String failColorString; + if (failCount == 0) { + failColorString = "" + failCount + ""; + } else { + failColorString = "" + failCount + ""; + } + int total = passCount + warnCount + failCount; + jsonObject.put("msgtype", "markdown"); + JSONObject markdown = new JSONObject(); + markdown.put("content", "### Sonic云真机测试平台周报 \n" + + "> ###### 项目:" + projectName + " \n" + + "> ###### 时间:" + yesterday + " ~ " + today + " \n" + + "> ###### 共测试:" + count + " 次\n" + + "> ###### 通过数:" + passCount + " \n" + + "> ###### 异常数:" + warnColorString + " \n" + + "> ###### 失败数:" + failColorString + " \n" + + "> ###### 测试通过率:" + (total > 0 ? + new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" + + "> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")"); + jsonObject.put("markdown", markdown); + } + if (type == RobotType.FeiShu) { jsonObject.put("msg_type", "interactive"); JSONObject card = new JSONObject(); diff --git a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/BaseUnit.java b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/BaseUnit.java new file mode 100644 index 00000000..e99ec49a --- /dev/null +++ b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/BaseUnit.java @@ -0,0 +1,13 @@ +package org.cloud.sonic.controller; + +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; + +@SpringBootTest(classes = ControllerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@AutoConfigureMockMvc +// 单元测试读取dev配置文件 +@ActiveProfiles +public class BaseUnit { + +} diff --git a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java new file mode 100644 index 00000000..99688b1b --- /dev/null +++ b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java @@ -0,0 +1,54 @@ +package org.cloud.sonic.controller.tools; + +import org.cloud.sonic.controller.BaseUnit; +import org.cloud.sonic.controller.models.interfaces.RobotType; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +public class RobotTest extends BaseUnit { + + @Autowired + RobotMsgTool robotMsgTool; + + private String wechatToken = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxx"; + + private String feishuToken = "https://open.feishu.cn/open-apis/bot/v2/hook/xxx"; + @Test + public void sendDayReportMessage() { + robotMsgTool.sendDayReportMessage(wechatToken, "" ,1, "2", + "1", "2" , 1,2,3, RobotType.WeChat); + } + + @Test + public void sendDayReportMessage2() { + robotMsgTool.sendDayReportMessage(wechatToken, "" ,1, "2", + "1", "2" , 1,0,0, RobotType.WeChat); + } + + @Test + public void testSendErrorDevice() { + robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 1, 80,"111"); + } + + + public void testSendErrorDeviceFeishu() { + robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 1, 80,"测试"); + } + + @Test + public void testSendErrorDevice2() { + robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 2, 80,"111"); + } + + @Test + public void sendWeekReportMessage() { + robotMsgTool.sendWeekReportMessage(wechatToken, "" ,1, "2", + "1", "2" , 1,0,0,100, RobotType.WeChat); + } + + @Test + public void sendResultFinishReport() { + robotMsgTool.sendResultFinishReport(wechatToken, "","111", 1,1,1,1, + 1,RobotType.WeChat); + } +} From 164021bc4200c8292e2b8d30bba20658dbbb72d8 Mon Sep 17 00:00:00 2001 From: "shanming.sun" Date: Sat, 9 Jul 2022 23:53:40 +0800 Subject: [PATCH 09/11] =?UTF-8?q?fix:=20=E6=89=BE=E5=9B=9E=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E4=B8=A2=E5=A4=B1=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sonic/controller/tools/RobotMsgTool.java | 78 ++++++++++++++++++- 1 file changed, 75 insertions(+), 3 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java index 11380005..d4df8f5b 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java @@ -81,10 +81,15 @@ private void signAndSend(String token, String secret, int type, JSONObject jsonO ResponseEntity responseEntity = restTemplate.postForEntity(token + "×tamp=" + timestamp + "&sign=" + sign , jsonObject, JSONObject.class); - logger.info("机器人发送结果:" + responseEntity.getBody()); + logger.info("robot result: " + responseEntity.getBody()); break; } - case RobotType.WeChat: + case RobotType.WeChat: { + ResponseEntity responseEntity = + restTemplate.postForEntity(token , jsonObject, JSONObject.class); + logger.info("robot result: " + responseEntity.getBody()); + } + break; case RobotType.FeiShu: { String timestamp = String.valueOf(System.currentTimeMillis()).substring(0, 10); @@ -143,6 +148,17 @@ public void sendResultFinishReport(String token, String secret, String suiteName jsonObject.put("msgtype", "link"); jsonObject.put("link", link); } + if (type == RobotType.WeChat) { + jsonObject.put("msgtype", "markdown"); + JSONObject markdown = new JSONObject(); + markdown.put("content", "**测试套件: " + suiteName + " 运行完毕!**\n" + + "通过数:" + pass + " \n" + + "异常数:" + warn + " \n" + + "失败数:" + fail + "\n" + + "测试报告:[点击查看](" + clientHost + "/Home/" + projectId + "/ResultDetail/" + resultId + ")"); + jsonObject.put("markdown", markdown); + + } if (type == RobotType.FeiShu) { jsonObject.put("msg_type", "interactive"); JSONObject card = new JSONObject(); @@ -247,6 +263,33 @@ public void sendDayReportMessage(String token, String secret, int projectId, Str jsonObject.put("msgtype", "markdown"); jsonObject.put("markdown", markdown); } + if (type == RobotType.WeChat) { + String warnColorString; + if (warnCount == 0) { + warnColorString = "" + warnCount + ""; + } else { + warnColorString = "" + warnCount + ""; + } + String failColorString; + if (failCount == 0) { + failColorString = "" + failCount + ""; + } else { + failColorString = "" + failCount + ""; + } + int total = passCount + warnCount + failCount; + jsonObject.put("msgtype", "markdown"); + JSONObject markdown = new JSONObject(); + markdown.put("content", "### Sonic云真机测试平台日报 \n" + + "> ###### 项目:" + projectName + " \n" + + "> ###### 时间:" + yesterday + " ~ " + today + " \n" + + "> ###### 通过数:" + passCount + " \n" + + "> ###### 异常数:" + warnColorString + " \n" + + "> ###### 失败数:" + failColorString + " \n" + + "> ###### 测试通过率:" + (total > 0 ? + new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" + + "> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")"); + jsonObject.put("markdown", markdown); + } if (type == RobotType.FeiShu) { jsonObject.put("msg_type", "interactive"); JSONObject card = new JSONObject(); @@ -366,6 +409,35 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St jsonObject.put("msgtype", "markdown"); jsonObject.put("markdown", markdown); } + if (type == RobotType.WeChat) { + String warnColorString; + if (warnCount == 0) { + warnColorString = "" + warnCount + ""; + } else { + warnColorString = "" + warnCount + ""; + } + String failColorString; + if (failCount == 0) { + failColorString = "" + failCount + ""; + } else { + failColorString = "" + failCount + ""; + } + int total = passCount + warnCount + failCount; + jsonObject.put("msgtype", "markdown"); + JSONObject markdown = new JSONObject(); + markdown.put("content", "### Sonic云真机测试平台周报 \n" + + "> ###### 项目:" + projectName + " \n" + + "> ###### 时间:" + yesterday + " ~ " + today + " \n" + + "> ###### 共测试:" + count + " 次\n" + + "> ###### 通过数:" + passCount + " \n" + + "> ###### 异常数:" + warnColorString + " \n" + + "> ###### 失败数:" + failColorString + " \n" + + "> ###### 测试通过率:" + (total > 0 ? + new BigDecimal((float) passCount / total).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0) + "% \n" + + "> ###### 详细统计:[点击查看](" + clientHost + "/Home/" + projectId + ")"); + jsonObject.put("markdown", markdown); + } + if (type == RobotType.FeiShu) { jsonObject.put("msg_type", "interactive"); JSONObject card = new JSONObject(); @@ -380,7 +452,7 @@ public void sendWeekReportMessage(String token, String secret, int projectId, St "项目:" + projectName + " \n" + "时间:" + yesterday + " ~ " + today + " \n" + "共测试:" + count + " 次\n" + - "通过数:" + passCount + " \n" + + "通过数:" + passCount + " \n" + "异常数:" + warnCount + " \n" + "失败数:" + failCount + " \n" + "测试通过率:" + (total > 0 ? From b870c036e7794bc4844b19c1648b07b3fb5ab8c1 Mon Sep 17 00:00:00 2001 From: "shanming.sun" Date: Sun, 10 Jul 2022 00:16:04 +0800 Subject: [PATCH 10/11] =?UTF-8?q?feat:=20=E5=8E=BB=E6=8E=89=20secret=20?= =?UTF-8?q?=E5=BF=85=E5=A1=AB=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/models/domain/Projects.java | 2 +- .../controller/models/dto/ProjectsDTO.java | 2 +- .../services/impl/ResultsServiceImpl.java | 6 +-- .../sonic/controller/tools/RobotMsgTool.java | 52 +++++++++++-------- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Projects.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Projects.java index 733a8990..e71e7d16 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Projects.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/models/domain/Projects.java @@ -56,7 +56,7 @@ public class Projects implements Serializable, TypeConverter 0 && projects.getRobotSecret().length() > 0) { + if (projects.getRobotType() != 0 && projects.getRobotToken().length() > 0 ) { robotMsgTool.sendDayReportMessage(projects.getRobotToken(), projects.getRobotSecret(), projects.getId() , projects.getProjectName(), sf.format(yesterday), sf.format(today), suc, warn, fail, projects.getRobotType()); } @@ -266,7 +266,7 @@ public void sendWeekReport() { break; } } - if (projects.getRobotType() != 0 && projects.getRobotToken().length() > 0 && projects.getRobotSecret().length() > 0) { + if (projects.getRobotType() != 0 && projects.getRobotToken().length() > 0 ) { robotMsgTool.sendWeekReportMessage(projects.getRobotToken(), projects.getRobotSecret(), projects.getId() , projects.getProjectName(), sf.format(lastWeek), sf.format(today), suc, warn, fail, count, projects.getRobotType()); } @@ -330,7 +330,7 @@ public void setStatus(Results results) { results.setEndTime(new Date()); save(results); Projects projects = projectsService.findById(results.getProjectId()); - if (projects != null && projects.getRobotType() != 0 && projects.getRobotToken().length() > 0 && projects.getRobotSecret().length() > 0) { + if (projects != null && projects.getRobotType() != 0 && projects.getRobotToken().length() > 0) { robotMsgTool.sendResultFinishReport(projects.getRobotToken(), projects.getRobotSecret(), results.getSuiteName(), sucCount, warnCount, failCount, projects.getId(), results.getId(), projects.getRobotType()); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java index d4df8f5b..b046e69a 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java @@ -25,6 +25,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.util.Base64Utils; +import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; import javax.crypto.Mac; @@ -72,14 +73,19 @@ private void signAndSend(String token, String secret, int type, JSONObject jsonO try { switch (type) { case RobotType.DingTalk: { - Long timestamp = System.currentTimeMillis(); - String stringToSign = timestamp + "\n" + secret; - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); - byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); - String sign = URLEncoder.encode(new String(Base64Utils.encode(signData)), "UTF-8"); + String path = ""; + if (!StringUtils.isEmpty(secret)) { + Long timestamp = System.currentTimeMillis(); + String stringToSign = timestamp + "\n" + secret; + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), "HmacSHA256")); + byte[] signData = mac.doFinal(stringToSign.getBytes("UTF-8")); + String sign = URLEncoder.encode(new String(Base64Utils.encode(signData)), "UTF-8"); + path = "×tamp=" + timestamp + "&sign=" + sign; + } + ResponseEntity responseEntity = - restTemplate.postForEntity(token + "×tamp=" + timestamp + "&sign=" + sign + restTemplate.postForEntity(token + path , jsonObject, JSONObject.class); logger.info("robot result: " + responseEntity.getBody()); break; @@ -92,14 +98,18 @@ private void signAndSend(String token, String secret, int type, JSONObject jsonO break; case RobotType.FeiShu: { - String timestamp = String.valueOf(System.currentTimeMillis()).substring(0, 10); - String stringToSign = timestamp + "\n" + secret; - Mac mac = Mac.getInstance("HmacSHA256"); - mac.init(new SecretKeySpec(stringToSign.getBytes(StandardCharsets.UTF_8), "HmacSHA256")); - byte[] signData = mac.doFinal(new byte[]{}); - String sign = new String(Base64Utils.encode(signData)); - jsonObject.put("timestamp", timestamp); - jsonObject.put("sign", sign); + + if (!StringUtils.isEmpty(secret)) { + String timestamp = String.valueOf(System.currentTimeMillis()).substring(0, 10); + String stringToSign = timestamp + "\n" + secret; + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(new SecretKeySpec(stringToSign.getBytes(StandardCharsets.UTF_8), "HmacSHA256")); + byte[] signData = mac.doFinal(new byte[]{}); + String sign = new String(Base64Utils.encode(signData)); + jsonObject.put("timestamp", timestamp); + jsonObject.put("sign", sign); + } + ResponseEntity responseEntity = restTemplate.postForEntity(token, jsonObject, JSONObject.class); logger.info("robot result: " + responseEntity.getBody()); @@ -321,11 +331,11 @@ public void sendErrorDevice(String token, String secret, int type, int errorType if (type == RobotType.DingTalk) { JSONObject markdown = new JSONObject(); if (errorType == 1) { - markdown.put("text", "### 设备高温预警 \n" + + markdown.put("text", "### Sonic设备高温预警 \n" + "> ###### 设备序列号:" + udId + " \n" + "> ###### 电池温度:" + (tem / 10) + " ℃"); } else { - markdown.put("text", "### 设备高温超时,已关机! \n" + + markdown.put("text", "### Sonic设备高温超时,已关机! \n" + "> ###### 设备序列号:" + udId + " \n" + "> ###### 电池温度:" + (tem / 10) + " ℃"); } @@ -337,11 +347,11 @@ public void sendErrorDevice(String token, String secret, int type, int errorType if (type == RobotType.WeChat) { JSONObject markdown = new JSONObject(); if (errorType == 1) { - markdown.put("content", "### 设备高温预警 \n" + + markdown.put("content", "### Sonic设备高温预警 \n" + "> ###### 设备序列号:" + udId + " \n" + "> ###### 电池温度:" + (tem / 10) + " ℃"); } else { - markdown.put("text", "### 设备高温超时,已关机! \n" + + markdown.put("text", "### Sonic设备高温超时,已关机! \n" + "> ###### 设备序列号:" + udId + " \n" + "> ###### 电池温度:" + (tem / 10) + " ℃"); } @@ -360,11 +370,11 @@ public void sendErrorDevice(String token, String secret, int type, int errorType List elementList = new ArrayList<>(); if (errorType == 1) { - element.put("content", "**设备高温预警** \n" + + element.put("content", "**Sonic设备高温预警** \n" + "设备序列号:" + udId + " \n" + "电池温度:" + (tem / 10) + " ℃"); } else { - element.put("text", "### 设备高温超时,已关机! \n" + + element.put("text", "**Sonic设备高温超时,已关机!** \n" + "设备序列号:" + udId + " \n" + "电池温度:" + (tem / 10) + " ℃"); } From eedad208217bcd067a3a762cdfd447b9986ece7b Mon Sep 17 00:00:00 2001 From: "shanming.sun" Date: Sun, 10 Jul 2022 14:46:15 +0800 Subject: [PATCH 11/11] =?UTF-8?q?fix:=20=E5=8F=82=E6=95=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cloud/sonic/controller/tools/RobotMsgTool.java | 4 ++-- .../org/cloud/sonic/controller/tools/RobotTest.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java index b046e69a..edfd57bc 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/RobotMsgTool.java @@ -351,7 +351,7 @@ public void sendErrorDevice(String token, String secret, int type, int errorType "> ###### 设备序列号:" + udId + " \n" + "> ###### 电池温度:" + (tem / 10) + " ℃"); } else { - markdown.put("text", "### Sonic设备高温超时,已关机! \n" + + markdown.put("content", "### Sonic设备高温超时,已关机! \n" + "> ###### 设备序列号:" + udId + " \n" + "> ###### 电池温度:" + (tem / 10) + " ℃"); } @@ -374,7 +374,7 @@ public void sendErrorDevice(String token, String secret, int type, int errorType "设备序列号:" + udId + " \n" + "电池温度:" + (tem / 10) + " ℃"); } else { - element.put("text", "**Sonic设备高温超时,已关机!** \n" + + element.put("content", "**Sonic设备高温超时,已关机!** \n" + "设备序列号:" + udId + " \n" + "电池温度:" + (tem / 10) + " ℃"); } diff --git a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java index 99688b1b..5c3360ea 100644 --- a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java +++ b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotTest.java @@ -26,20 +26,27 @@ public void sendDayReportMessage2() { } @Test - public void testSendErrorDevice() { + public void testSendErrorDevice1() { robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 1, 80,"111"); } + @Test + public void testSendErrorDevice2() { + robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 2, 80,"111"); + } + + @Test public void testSendErrorDeviceFeishu() { robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 1, 80,"测试"); } @Test - public void testSendErrorDevice2() { - robotMsgTool.sendErrorDevice(wechatToken, "", RobotType.WeChat, 2, 80,"111"); + public void testSendErrorDeviceFeishu2() { + robotMsgTool.sendErrorDevice(feishuToken, "", RobotType.FeiShu, 2, 80,"测试"); } + @Test public void sendWeekReportMessage() { robotMsgTool.sendWeekReportMessage(wechatToken, "" ,1, "2",