Commit 30b905cb by zhouhaibao

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

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