1、bug修复
parent
f04f74209c
commit
d2195d9088
|
|
@ -42,6 +42,22 @@ import java.util.stream.Collectors;
|
|||
@Component
|
||||
@AllArgsConstructor
|
||||
public class AlarmRecordQueryExe {
|
||||
/** FindS支持的完整告警类型,下拉选项不依赖当前企业是否已经产生对应告警。 */
|
||||
private static final List<OptionCO> ALARM_TYPE_OPTIONS = Collections.unmodifiableList(java.util.Arrays.asList(
|
||||
new OptionCO("闯入报警", "CROSS_IN"),
|
||||
new OptionCO("离开报警", "CROSS_OUT"),
|
||||
new OptionCO("滞留报警", "RETENTION"),
|
||||
new OptionCO("聚集报警", "CLUSTER"),
|
||||
new OptionCO("超员报警", "CROWDED"),
|
||||
new OptionCO("缺员报警", "LACKED"),
|
||||
new OptionCO("静止报警", "STATIC"),
|
||||
new OptionCO("停留报警", "STAY"),
|
||||
new OptionCO("超速报警", "OVER_SPEED"),
|
||||
new OptionCO("碰撞报警", "CRASH"),
|
||||
new OptionCO("低电量报警", "LOW_BATTERY"),
|
||||
new OptionCO("SOS报警", "SOS")
|
||||
));
|
||||
|
||||
private final AlarmRecordRepository alarmRecordRepository;
|
||||
private final AlarmRecordTargetRepository alarmRecordTargetRepository;
|
||||
private final AlarmRecordCoConvertor alarmRecordCoConvertor;
|
||||
|
|
@ -128,19 +144,7 @@ public class AlarmRecordQueryExe {
|
|||
}
|
||||
|
||||
public List<OptionCO> listAlarmTypeOptions() {
|
||||
SSOUser user = AuthContext.getCurrentUser();
|
||||
Long corpinfoId = user == null ? null : user.getCompanyId();
|
||||
// 只返回当前企业告警记录中实际出现过的编码,名称使用FindS确定的编码映射。
|
||||
List<AlarmTypeStatDO> rows = alarmRecordRepository.listBiAlarmType(corpinfoId);
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return rows.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(row -> StringUtils.hasText(row.getAlarmCode()))
|
||||
.map(row -> new OptionCO(alarmNameOf(row.getAlarmCode()),
|
||||
row.getAlarmCode()))
|
||||
.collect(Collectors.toList());
|
||||
return ALARM_TYPE_OPTIONS;
|
||||
}
|
||||
|
||||
private OptionCO mapCompanyOption(CompanyOptionDO dataObject) {
|
||||
|
|
@ -157,7 +161,10 @@ public class AlarmRecordQueryExe {
|
|||
row.setTargetList(targetList);
|
||||
row.setPersonnelName(defaultIfBlank(row.getFirstStaffNameSnapshot(), firstTargetName(targetList)));
|
||||
row.setCompanyName(row.getCorpinfoName());
|
||||
row.setAlarmTypeName(defaultIfBlank(row.getAlarmName(), alarmNameOf(row.getAlarmCode())));
|
||||
// 返回前统一以FindS告警编码为准,避免数据库中的围栏名称被当作告警名称展示。
|
||||
String alarmName = defaultIfBlank(alarmLabelOf(row.getAlarmCode()), row.getAlarmName());
|
||||
row.setAlarmName(alarmName);
|
||||
row.setAlarmTypeName(alarmName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -273,6 +280,11 @@ public class AlarmRecordQueryExe {
|
|||
}
|
||||
|
||||
private String alarmNameOf(String alarmCode) {
|
||||
String alarmLabel = alarmLabelOf(alarmCode);
|
||||
return StringUtils.hasText(alarmLabel) ? alarmLabel : alarmCode;
|
||||
}
|
||||
|
||||
private String alarmLabelOf(String alarmCode) {
|
||||
if ("CROSS_IN".equals(alarmCode)) {
|
||||
return "闯入报警";
|
||||
}
|
||||
|
|
@ -309,7 +321,7 @@ public class AlarmRecordQueryExe {
|
|||
if ("SOS".equals(alarmCode)) {
|
||||
return "SOS报警";
|
||||
}
|
||||
return alarmCode;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String alarmTypeNameOf(String alarmCode, String alarmName) {
|
||||
|
|
|
|||
|
|
@ -96,36 +96,61 @@
|
|||
|
||||
<select id="listCompanyStats"
|
||||
resultType="com.zcloud.personnel.positioning.persistence.dataobject.AlarmRuleCompanyStatDO">
|
||||
SELECT <include refid="mappedCompanyId"/> AS corpinfo_id,
|
||||
<include refid="mappedCompanyName"/> AS corpinfo_name,
|
||||
SELECT corp.id AS corpinfo_id,
|
||||
corp.corp_name AS corpinfo_name,
|
||||
COALESCE(stat.config_count, 0) AS config_count,
|
||||
COALESCE(stat.enabled_count, 0) AS enabled_count,
|
||||
stat.last_sync_time
|
||||
FROM corp_info corp
|
||||
LEFT JOIN (
|
||||
SELECT mapped_rule.corpinfo_id,
|
||||
COUNT(1) AS config_count,
|
||||
SUM(CASE WHEN ar.enable = 1 OR ar.rule_status = 'ENABLED' THEN 1 ELSE 0 END) AS enabled_count,
|
||||
COALESCE(MAX(ar.last_sync_time), MAX(ar.update_time)) AS last_sync_time
|
||||
SUM(CASE WHEN mapped_rule.enable = 1 OR mapped_rule.rule_status = 'ENABLED'
|
||||
THEN 1 ELSE 0 END) AS enabled_count,
|
||||
COALESCE(MAX(mapped_rule.last_sync_time), MAX(mapped_rule.update_time)) AS last_sync_time
|
||||
FROM (
|
||||
SELECT ar.id, ar.enable, ar.rule_status, ar.last_sync_time, ar.update_time,
|
||||
ar.org_code,
|
||||
COALESCE(NULLIF(ar.corpinfo_id, 0), rule_fence.corpinfo_id) AS corpinfo_id
|
||||
FROM alarm_rule ar
|
||||
<include refid="mappedCompanyJoin"/>
|
||||
LEFT JOIN (
|
||||
SELECT rel.rule_id, MIN(f.corpinfo_id) AS corpinfo_id
|
||||
FROM alarm_rule_fence_rel rel
|
||||
INNER JOIN fence f ON f.id = rel.fence_id
|
||||
WHERE (rel.delete_enum IS NULL OR rel.delete_enum = 'FALSE')
|
||||
AND (f.delete_enum IS NULL OR f.delete_enum = 'FALSE')
|
||||
AND f.corpinfo_id IS NOT NULL AND f.corpinfo_id != 0
|
||||
GROUP BY rel.rule_id
|
||||
HAVING COUNT(DISTINCT f.corpinfo_id) = 1
|
||||
) rule_fence ON rule_fence.rule_id = ar.id
|
||||
WHERE (ar.delete_enum IS NULL OR ar.delete_enum = 'FALSE')
|
||||
AND <include refid="mappedCompanyId"/> IS NOT NULL
|
||||
<if test="params.eqCorpinfoId != null and params.eqCorpinfoId != ''">
|
||||
AND <include refid="mappedCompanyId"/> = #{params.eqCorpinfoId}
|
||||
</if>
|
||||
<if test="params.companyGroupOrgCode != null and params.companyGroupOrgCode != ''">
|
||||
AND ar.org_code = #{params.companyGroupOrgCode}
|
||||
</if>
|
||||
<if test="params.likeCorpinfoName != null and params.likeCorpinfoName != ''">
|
||||
AND <include refid="mappedCompanyName"/> LIKE CONCAT('%', #{params.likeCorpinfoName}, '%')
|
||||
</if>
|
||||
<if test="params.likeContactName != null and params.likeContactName != ''">
|
||||
AND (corp.contacts LIKE CONCAT('%', #{params.likeContactName}, '%')
|
||||
OR corp.lr_name LIKE CONCAT('%', #{params.likeContactName}, '%'))
|
||||
</if>
|
||||
<if test="params.eqRuleStatus != null and params.eqRuleStatus != ''">
|
||||
AND ar.rule_status = #{params.eqRuleStatus}
|
||||
</if>
|
||||
<if test="params.eqEnable != null">
|
||||
AND ar.enable = #{params.eqEnable}
|
||||
</if>
|
||||
GROUP BY <include refid="mappedCompanyId"/>, <include refid="mappedCompanyName"/>
|
||||
ORDER BY COALESCE(MAX(ar.last_sync_time), MAX(ar.update_time)) DESC
|
||||
) mapped_rule
|
||||
WHERE mapped_rule.corpinfo_id IS NOT NULL
|
||||
GROUP BY mapped_rule.corpinfo_id
|
||||
) stat ON stat.corpinfo_id = corp.id
|
||||
WHERE (corp.delete_enum IS NULL OR corp.delete_enum = 'FALSE')
|
||||
<if test="params.eqCorpinfoId != null and params.eqCorpinfoId != ''">
|
||||
AND corp.id = #{params.eqCorpinfoId}
|
||||
</if>
|
||||
<if test="params.likeCorpinfoName != null and params.likeCorpinfoName != ''">
|
||||
AND corp.corp_name LIKE CONCAT('%', #{params.likeCorpinfoName}, '%')
|
||||
</if>
|
||||
<if test="params.likeContactName != null and params.likeContactName != ''">
|
||||
AND (corp.contacts LIKE CONCAT('%', #{params.likeContactName}, '%')
|
||||
OR corp.lr_name LIKE CONCAT('%', #{params.likeContactName}, '%'))
|
||||
</if>
|
||||
ORDER BY COALESCE(stat.config_count, 0) DESC,
|
||||
corp.corp_order ASC,
|
||||
corp.create_time DESC, corp.id ASC
|
||||
</select>
|
||||
|
||||
<select id="listCompanyOptions"
|
||||
|
|
|
|||
|
|
@ -97,24 +97,32 @@
|
|||
|
||||
<select id="listCompanyStats"
|
||||
resultType="com.zcloud.personnel.positioning.persistence.dataobject.FenceCompanyStatDO">
|
||||
SELECT <include refid="mappedCompanyId"/> AS corpinfo_id,
|
||||
<include refid="mappedCompanyName"/> AS corpinfo_name,
|
||||
SELECT corp.id AS corpinfo_id,
|
||||
corp.corp_name AS corpinfo_name,
|
||||
COALESCE(stat.fence_count, 0) AS fence_count,
|
||||
COALESCE(stat.enabled_count, 0) AS enabled_count,
|
||||
stat.last_sync_time
|
||||
FROM corp_info corp
|
||||
LEFT JOIN (
|
||||
SELECT f.corpinfo_id,
|
||||
COUNT(1) AS fence_count,
|
||||
SUM(CASE WHEN f.status = 'ENABLED' THEN 1 ELSE 0 END) AS enabled_count,
|
||||
COALESCE(MAX(f.last_sync_time), MAX(f.update_time)) AS last_sync_time
|
||||
FROM fence f
|
||||
<include refid="mappedCompanyJoin"/>
|
||||
WHERE f.delete_enum = 'FALSE'
|
||||
WHERE (f.delete_enum IS NULL OR f.delete_enum = 'FALSE')
|
||||
AND f.fence_scope IN ('ELECTRONIC', 'WORK_AREA')
|
||||
AND <include refid="mappedCompanyId"/> IS NOT NULL
|
||||
GROUP BY f.corpinfo_id
|
||||
) stat ON stat.corpinfo_id = corp.id
|
||||
WHERE (corp.delete_enum IS NULL OR corp.delete_enum = 'FALSE')
|
||||
<if test="params.eqCorpinfoId != null and params.eqCorpinfoId != ''">
|
||||
AND <include refid="mappedCompanyId"/> = #{params.eqCorpinfoId}
|
||||
AND corp.id = #{params.eqCorpinfoId}
|
||||
</if>
|
||||
<if test="params.likeCorpinfoName != null and params.likeCorpinfoName != ''">
|
||||
AND <include refid="mappedCompanyName"/> LIKE CONCAT('%', #{params.likeCorpinfoName}, '%')
|
||||
AND corp.corp_name LIKE CONCAT('%', #{params.likeCorpinfoName}, '%')
|
||||
</if>
|
||||
GROUP BY <include refid="mappedCompanyId"/>, <include refid="mappedCompanyName"/>
|
||||
ORDER BY COALESCE(MAX(f.last_sync_time), MAX(f.update_time)) DESC
|
||||
ORDER BY COALESCE(stat.fence_count, 0) DESC,
|
||||
corp.corp_order ASC,
|
||||
corp.create_time DESC, corp.id ASC
|
||||
</select>
|
||||
|
||||
<select id="listCompanyOptions"
|
||||
|
|
|
|||
|
|
@ -41,17 +41,56 @@
|
|||
|
||||
<select id="listCardCompanyStats"
|
||||
resultType="com.zcloud.personnel.positioning.persistence.dataobject.TerminalCardCompanyStatDO">
|
||||
SELECT <include refid="mappedCompanyId"/> AS corpinfo_id,
|
||||
<include refid="mappedCompanyName"/> AS corpinfo_name,
|
||||
SELECT corp.id AS corpinfo_id,
|
||||
corp.corp_name AS corpinfo_name,
|
||||
stat.org_code,
|
||||
stat.org_name,
|
||||
COALESCE(NULLIF(corp.contacts, ''), NULLIF(corp.lr_name, '')) AS contact_name,
|
||||
COALESCE(stat.card_count, 0) AS card_count,
|
||||
COALESCE(stat.enabled_count, 0) AS enabled_count,
|
||||
stat.last_sync_time
|
||||
FROM corp_info corp
|
||||
LEFT JOIN (
|
||||
SELECT t.corpinfo_id,
|
||||
MAX(NULLIF(t.org_code, '')) AS org_code,
|
||||
MAX(NULLIF(t.org_name, '')) AS org_name,
|
||||
COALESCE(MAX(NULLIF(corp.contacts, '')), MAX(NULLIF(corp.lr_name, ''))) AS contact_name,
|
||||
COUNT(1) AS card_count,
|
||||
SUM(CASE WHEN t.enable = 1 THEN 1 ELSE 0 END) AS enabled_count,
|
||||
MAX(t.last_sync_time) AS last_sync_time
|
||||
<include refid="cardCompanyJoinAndWhere"/>
|
||||
GROUP BY <include refid="mappedCompanyId"/>, <include refid="mappedCompanyName"/>
|
||||
ORDER BY MAX(t.last_sync_time) DESC, MAX(t.update_time) DESC
|
||||
FROM terminal t
|
||||
WHERE (t.delete_enum IS NULL OR t.delete_enum = 'FALSE')
|
||||
AND t.device_type = 'CARD'
|
||||
<if test="params.eqEnable != null">
|
||||
AND t.enable = #{params.eqEnable}
|
||||
</if>
|
||||
GROUP BY t.corpinfo_id
|
||||
) stat ON stat.corpinfo_id = corp.id
|
||||
WHERE (corp.delete_enum IS NULL OR corp.delete_enum = 'FALSE')
|
||||
<if test="params.eqCorpinfoId != null">
|
||||
AND corp.id = #{params.eqCorpinfoId}
|
||||
</if>
|
||||
<if test="params.likeCorpinfoName != null and params.likeCorpinfoName != ''">
|
||||
AND (corp.corp_name LIKE CONCAT('%', #{params.likeCorpinfoName}, '%')
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM terminal search_t
|
||||
WHERE search_t.corpinfo_id = corp.id
|
||||
AND (search_t.delete_enum IS NULL OR search_t.delete_enum = 'FALSE')
|
||||
AND search_t.device_type = 'CARD'
|
||||
AND (search_t.corpinfo_name LIKE CONCAT('%', #{params.likeCorpinfoName}, '%')
|
||||
OR search_t.org_name LIKE CONCAT('%', #{params.likeCorpinfoName}, '%'))
|
||||
<if test="params.eqEnable != null">
|
||||
AND search_t.enable = #{params.eqEnable}
|
||||
</if>
|
||||
))
|
||||
</if>
|
||||
<if test="params.likeContactName != null and params.likeContactName != ''">
|
||||
AND (corp.contacts LIKE CONCAT('%', #{params.likeContactName}, '%')
|
||||
OR corp.lr_name LIKE CONCAT('%', #{params.likeContactName}, '%'))
|
||||
</if>
|
||||
ORDER BY COALESCE(stat.card_count, 0) DESC,
|
||||
corp.corp_order ASC,
|
||||
corp.create_time DESC, corp.id ASC
|
||||
</select>
|
||||
|
||||
<sql id="cardDetailSelect">
|
||||
|
|
|
|||
Loading…
Reference in New Issue