Skip to content

Commit

Permalink
fix: bot for agent temperature scale
Browse files Browse the repository at this point in the history
  • Loading branch information
mmagi committed Jun 7, 2023
1 parent 53e0137 commit 6c2109b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
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)
@RunWith(SpringRunner.class)
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);
}
}
Expand Down

0 comments on commit 6c2109b

Please sign in to comment.