mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
feat(WeightDeviceDataAlert): update scene field type to DingtalkBotSceneDto and enhance notification data logging
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package cn.lihongjie.coal.weightDeviceDataAlert.dto;
|
||||
|
||||
import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
import cn.lihongjie.coal.dingtalkBotScene.entity.DingtalkBotSceneEntity;
|
||||
import cn.lihongjie.coal.dingtalkBotScene.dto.DingtalkBotSceneDto;
|
||||
|
||||
import jakarta.persistence.ManyToOne;
|
||||
|
||||
@@ -45,6 +45,6 @@ public class WeightDeviceDataAlertDto extends OrgCommonDto {
|
||||
* 关联的场景 用于推送消息
|
||||
*/
|
||||
@ManyToOne
|
||||
private DingtalkBotSceneEntity scene;
|
||||
private DingtalkBotSceneDto scene;
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
@@ -252,7 +253,7 @@ public class WeightDeviceDataAlertService
|
||||
progressPercent = (totalTonnage / expectedTonnage) * 100.0;
|
||||
}
|
||||
|
||||
log.debug("规则 {}: 实际吨数={}, 预期吨数={}, 进度={}%",
|
||||
log.info("规则 {}: 实际吨数={}, 预期吨数={}, 进度={}%",
|
||||
alert.getName(), totalTonnage, expectedTonnage, String.format("%.2f", progressPercent));
|
||||
|
||||
// 更新实际吨数和进度
|
||||
@@ -372,7 +373,17 @@ public class WeightDeviceDataAlertService
|
||||
notificationData.put("organizationId", alert.getOrganizationId());
|
||||
notificationData.put("sceneId", alert.getScene() != null ? alert.getScene().getId() : null);
|
||||
notificationData.put("timestamp", LocalDateTime.now());
|
||||
List<CommonQuery.QueryItem> value = objectMapper.readValue(
|
||||
|
||||
alert.getQueryJson() != null ? alert.getQueryJson() : "[]",
|
||||
new TypeReference<List<CommonQuery.QueryItem>>() {
|
||||
}
|
||||
);
|
||||
|
||||
var valueObject = value.stream().collect(Collectors.toMap(CommonQuery.QueryItem::getKey, e -> e));
|
||||
notificationData.put("queryJson", valueObject);
|
||||
|
||||
log.info("notificationData: {}", objectMapper.writeValueAsString(notificationData));
|
||||
// 如果配置了钉钉场景,发送钉钉通知
|
||||
if (alert.getScene() != null) {
|
||||
List<DingtalkBotEntity> bots = alert.getScene().getDingtalkBots();
|
||||
|
||||
Reference in New Issue
Block a user