From 6c2109b90a9a75bf8a26642f86fbc82ac275e1c7 Mon Sep 17 00:00:00 2001 From: mmagi Date: Wed, 7 Jun 2023 20:02:50 +0800 Subject: [PATCH] fix: bot for agent temperature scale --- .../controller/services/impl/AlertRobotsServiceImpl.java | 3 ++- .../sonic/controller/tools/robot/message/DeviceMessage.java | 4 +++- .../org/cloud/sonic/controller/tools/RobotMsgToolTest.java | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AlertRobotsServiceImpl.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AlertRobotsServiceImpl.java index 0d7577b6..3a9da073 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AlertRobotsServiceImpl.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/services/impl/AlertRobotsServiceImpl.java @@ -36,6 +36,7 @@ import org.springframework.web.client.RestTemplate; import java.math.BigDecimal; +import java.math.BigInteger; import java.math.RoundingMode; import java.util.Date; import java.util.List; @@ -97,7 +98,7 @@ public void sendProjectReportMessage(int projectId, String projectName, Date sta public void sendErrorDevice(int agentId, int errorType, int tem, String udId) { var robots = baseMapper.computeAgentRobots(agentId); if (robots.isEmpty()) return; - var msg = new DeviceMessage(errorType, tem, udId); + var msg = new DeviceMessage(errorType, new BigDecimal(BigInteger.valueOf(tem),1), udId); send(robots, msg); } diff --git a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/robot/message/DeviceMessage.java b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/robot/message/DeviceMessage.java index 3548db9c..29c9dc16 100644 --- a/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/robot/message/DeviceMessage.java +++ b/sonic-server-controller/src/main/java/org/cloud/sonic/controller/tools/robot/message/DeviceMessage.java @@ -20,9 +20,11 @@ import lombok.AllArgsConstructor; import org.cloud.sonic.controller.tools.robot.Message; +import java.math.BigDecimal; + @AllArgsConstructor public class DeviceMessage extends Message { public int errorType; - public int tem; + public BigDecimal tem; public String udId; } diff --git a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotMsgToolTest.java b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotMsgToolTest.java index c94b911c..d6185ac9 100644 --- a/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotMsgToolTest.java +++ b/sonic-server-controller/src/test/java/org/cloud/sonic/controller/tools/RobotMsgToolTest.java @@ -30,6 +30,7 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.web.client.RestTemplate; +import java.math.BigDecimal; import java.util.Date; @SpringBootTest(classes = ControllerApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @@ -37,7 +38,7 @@ public class RobotMsgToolTest { private void testMessage(RobotMessenger bot, String token, String secret) { - for (var msg : new Message[]{new DeviceMessage(0, 0, "test"), new ProjectSummaryMessage(0, "test", new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000), new Date(), 1, 3, 4, 1.4, 3, "https://sonic/?#=+", true), new ProjectSummaryMessage(0, "test", new Date(System.currentTimeMillis() - 24 * 3600 * 1000), new Date(), 1, 3, 4, 1.4, 3, "https://sonic/?#=+", false), new TestSuiteMessage("asf", 0, 1, 4, 5, 3, "https://sonic/?#=+"),}) { + for (var msg : new Message[]{new DeviceMessage(0, new BigDecimal(0), "test"), new ProjectSummaryMessage(0, "test", new Date(System.currentTimeMillis() - 7 * 24 * 3600 * 1000), new Date(), 1, 3, 4, 1.4, 3, "https://sonic/?#=+", true), new ProjectSummaryMessage(0, "test", new Date(System.currentTimeMillis() - 24 * 3600 * 1000), new Date(), 1, 3, 4, 1.4, 3, "https://sonic/?#=+", false), new TestSuiteMessage("asf", 0, 1, 4, 5, 3, "https://sonic/?#=+"),}) { bot.sendMessage(new RestTemplate(), token, secret, "", msg); } }