Commit 30b905cb by zhouhaibao

[+]新增预警管理,录音查询的逻辑调整

1 parent e22814b1
......@@ -3,6 +3,8 @@ package cn.com.glsx.dj.mindworkplate.model.warning;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Transient;
import lombok.Data;
@Data
......@@ -93,4 +95,17 @@ public class MonitoringMsgDTO implements Serializable {
private String fieldName;
/**
* sortId
*/
@ApiModelProperty(notes = "sortId")
private Integer sortId;
/**
* sortOrder
*/
@ApiModelProperty(notes = "sortOrder")
private Integer sortOrder;
}
\ No newline at end of file
......@@ -197,4 +197,16 @@ public class Rule implements Serializable {
@Transient
private String fieldName;
/**
* sortId
*/
@Column(name = "sort_id")
private Integer sortId;
/**
* sortId
*/
@Transient
private Integer sortOrder;
}
\ No newline at end of file
......@@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -107,9 +108,6 @@ public class MonitoringService {
Map<Integer, List<MonitoringMsgDTO>> warningsByMerchant = monitorListByCondition.stream()
.collect(Collectors.groupingBy(MonitoringMsgDTO::getMerchantId4s));
// 转化成StoreItemResponse对象
Set<Integer> merchantList = warningsByMerchant.keySet();
// 3. 转换为 StoreItemResponse 列表
List<StoreItemResponse> storeResponses = warningsByMerchant.entrySet().stream()
.map(entry -> {
......@@ -121,6 +119,7 @@ public class MonitoringService {
StoreItemResponse info = new StoreItemResponse();
info.setMerchantNo(merchantId+"");
info.setStoreName(value.get(0).getMerchantName4s());
info.setWarningTotalCount(warnings.size());
// 预警摘要:取前2条
List<String> summary = warnings.stream()
.limit(2)
......@@ -129,7 +128,7 @@ public class MonitoringService {
info.setWarningSummary(summary);
// 预警总数
info.setWarningTotalCount(warnings.size());
return info;
})
......@@ -162,6 +161,11 @@ public class MonitoringService {
List<MonitoringMsgDTO> allWarnings = futures.stream()
.map(CompletableFuture::join) // 阻塞等待每个 future 完成
.flatMap(List::stream) // 合并所有 List<WarningMsg> 为一个流
.sorted(Comparator
.comparing(MonitoringMsgDTO::getMerchantId4s, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(MonitoringMsgDTO::getSortOrder, Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(MonitoringMsgDTO::getSortId, Comparator.nullsLast(Comparator.naturalOrder()))
)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(allWarnings)){
......@@ -463,6 +467,8 @@ public class MonitoringService {
warningMsg.setRule(rule.getRule());
warningMsg.setRuleType(rule.getRuleType());
warningMsg.setFieldName(rule.getFieldName());
warningMsg.setSortOrder(rule.getSortOrder());
warningMsg.setSortId(rule.getSortId());
if(s.getConfigValue()!=null){
log.info("返回值:{}", JSONObject.toJSONString(s));
if (("兜底指标").equals(rule.getRuleType())){
......
......@@ -496,7 +496,8 @@
t2.end_time,
t2.score as score,
t2.duration as duration,
t3.avg_defence as def_score
t3.avg_defence as def_score,
t4.reception_status as receptionStatus
from
inspection_badge_recordings t1
left join inspection_conversation_batch t2 on t2.record_id=t1.id
......
......@@ -16,8 +16,8 @@
property="rules" ofType="cn.com.glsx.dj.mindworkplate.model.warning.Rule"
javaType="java.util.ArrayList">
<!-- 子表字段映射 -->
<id property="id" column="ruleId"/>
<result property="rule" column="ruleName"/>
<id property="id" column="id"/>
<result property="rule" column="rule"/>
</collection>
</resultMap>
<sql id="Base_Column_List" >
......@@ -27,19 +27,19 @@
type_code, type_name, description, sort_order, enabled, create_time
</sql>
<select id="findMonitorTypeDictList"
resultType="cn.com.glsx.dj.mindworkplate.model.MonitorTypeDict">
resultMap="BaseResultMap">
select
t1.type_code as typeCode,
t1.type_name as typeName,
t2.id as ruleId,
t2.rule as ruleName
t1.type_code as type_code,
t1.type_name as type_name,
t2.id as id,
t2.rule as rule
from monitor_type_dict t1
left join early_warning_rule t2 on t1.type_code = t2.monitor_type_dict_id
where t1.enabled = 1 and t2.deleted_flag ='N'
<if test="bussinessType!=null">
and t2.business_type = #{bussinessType}
</if>
order by t1.sort_order
order by t1.sort_order,t2.sort_id
</select>
<select id="findMerchantIdsByUUidAndType" resultType="java.lang.Integer">
select merchant_id from merchant_monitor_type_dict where uuid = #{uuid} and type_code = #{typeCode}
......
......@@ -27,6 +27,8 @@
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
<result column="field_name" property="fieldName" jdbcType="VARCHAR" />
<result column="sortOrder" property="sortOrder" jdbcType="INTEGER" />
<result column="sort_id" property="sortId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="MsgResultMap" type="cn.com.glsx.dj.mindworkplate.model.warning.WarningMsg" >
<result column="staff_id" property="staffId" jdbcType="VARCHAR" />
......@@ -67,8 +69,9 @@
</select>
<select id="selectByTypeAndMetricType"
resultMap="BaseResultMap">
SELECT t1.*,t2.field_name FROM early_warning_rule t1
SELECT t1.*,t2.field_name,t3.sort_order as sortOrder FROM early_warning_rule t1
LEFT JOIN early_warning_rule_condition t2 ON t1.id=t2.rule_id
left join monitor_type_dict t3 on t1.monitor_type_dict_id=t3.type_code
where strategy_flag=1 and t1.deleted_flag='N'
<if test="monitorType!=null">
and monitor_type_dict_id=#{monitorType}
......
......@@ -136,8 +136,9 @@ public class EarlyWarningTest extends BaseServiceTest{
@Test
public void findMonitorListPage() throws ParseException {
MonitorFilterRequest request=new MonitorFilterRequest();
request.setStartDate("2024-11-01");
request.setEndDate("2024-11-18");
request.setStartDate("2025-11-01");
request.setEndDate("2025-12-31");
request.setBusinessType(1);
List<StoreItemResponse> monitorListPage = monitoringService.findMonitorListPage(request);
System.out.println("aa"+JSONObject.toJSONString(monitorListPage));
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!