修改项目1
This commit is contained in:
@@ -41,11 +41,12 @@ public class NWQualityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
||||||
startDate = request.getStartDate().trim();
|
// 转换为 yyyyMMdd 形式,便于与 DAYTIME 的日期部分比较
|
||||||
|
startDate = request.getStartDate().trim().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
||||||
endDate = request.getEndDate().trim();
|
endDate = request.getEndDate().trim().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按条件查询
|
// 按条件查询
|
||||||
@@ -62,6 +63,48 @@ public class NWQualityController {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询网络质量数据(支持 ALL 或指定运营商 + 时间范围),返回所有满足条件的数据
|
||||||
|
* operator 传 ALL(不区分大小写)或不传,则不过滤运营商
|
||||||
|
*/
|
||||||
|
@PostMapping("/nwQuality/all")
|
||||||
|
public List<NWQuality> queryAll(@RequestBody(required = false) NWQualityQueryRequest request) {
|
||||||
|
if (request == null) {
|
||||||
|
request = new NWQualityQueryRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
String operator = null;
|
||||||
|
String startDate = null;
|
||||||
|
String endDate = null;
|
||||||
|
|
||||||
|
if (request.getOperator() != null && !request.getOperator().trim().isEmpty()) {
|
||||||
|
String op = request.getOperator().trim();
|
||||||
|
// 传 ALL 时视为不过滤运营商
|
||||||
|
if (!"ALL".equalsIgnoreCase(op)) {
|
||||||
|
operator = op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
||||||
|
startDate = request.getStartDate().trim().replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
||||||
|
endDate = request.getEndDate().trim().replace("-", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NWQuality> list = nwQualityService.getByCondition(operator, startDate, endDate);
|
||||||
|
|
||||||
|
System.out.println("====== nw_quality all query ======");
|
||||||
|
System.out.println("Operator: " + (operator != null ? operator : "ALL"));
|
||||||
|
System.out.println("Start Date: " + (startDate != null ? startDate : "ALL"));
|
||||||
|
System.out.println("End Date: " + (endDate != null ? endDate : "ALL"));
|
||||||
|
System.out.println("Total records: " + list.size());
|
||||||
|
System.out.println("================================================");
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计各地区数量,支持按运营商和时间范围筛选
|
* 统计各地区数量,支持按运营商和时间范围筛选
|
||||||
* @param request 查询请求参数,包含 operator(运营商)和 startDate、endDate(时间范围)字段,均为可选
|
* @param request 查询请求参数,包含 operator(运营商)和 startDate、endDate(时间范围)字段,均为可选
|
||||||
@@ -83,11 +126,12 @@ public class NWQualityController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
||||||
startDate = request.getStartDate().trim();
|
// 转换为 yyyyMMdd 形式
|
||||||
|
startDate = request.getStartDate().trim().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
||||||
endDate = request.getEndDate().trim();
|
endDate = request.getEndDate().trim().replace("-", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按条件查询地区统计
|
// 按条件查询地区统计
|
||||||
|
|||||||
@@ -67,9 +67,9 @@
|
|||||||
SELECT
|
SELECT
|
||||||
"NETWORK_NAME" AS operator,
|
"NETWORK_NAME" AS operator,
|
||||||
CAST(COUNT(*) AS BIGINT) AS totalCount,
|
CAST(COUNT(*) AS BIGINT) AS totalCount,
|
||||||
CAST(SUM(CASE WHEN "PING_VALUE" IS NOT NULL AND "PING_VALUE" != '' THEN 1 ELSE 0 END) AS BIGINT) AS successCount,
|
CAST(SUM(CASE WHEN "PING_VALUE" = '11111' THEN 1 ELSE 0 END) AS BIGINT) AS successCount,
|
||||||
CAST(ROUND(
|
CAST(ROUND(
|
||||||
SUM(CASE WHEN "PING_VALUE" IS NOT NULL AND "PING_VALUE" != '' THEN 1 ELSE 0 END) * 100.0 / COUNT(*),
|
SUM(CASE WHEN "PING_VALUE" = '11111' THEN 1 ELSE 0 END) * 100.0 / COUNT(*),
|
||||||
2
|
2
|
||||||
) AS DOUBLE) AS connectionRate
|
) AS DOUBLE) AS connectionRate
|
||||||
FROM "DATACONNECTION"
|
FROM "DATACONNECTION"
|
||||||
@@ -91,9 +91,9 @@
|
|||||||
SELECT
|
SELECT
|
||||||
"NETWORK_NAME" AS operator,
|
"NETWORK_NAME" AS operator,
|
||||||
CAST(COUNT(*) AS BIGINT) AS totalCount,
|
CAST(COUNT(*) AS BIGINT) AS totalCount,
|
||||||
CAST(SUM(CASE WHEN "PING_VALUE" IS NOT NULL AND "PING_VALUE" != '' THEN 1 ELSE 0 END) AS BIGINT) AS successCount,
|
CAST(SUM(CASE WHEN "PING_VALUE" = '11111' THEN 1 ELSE 0 END) AS BIGINT) AS successCount,
|
||||||
CAST(ROUND(
|
CAST(ROUND(
|
||||||
SUM(CASE WHEN "PING_VALUE" IS NOT NULL AND "PING_VALUE" != '' THEN 1 ELSE 0 END) * 100.0 / COUNT(*),
|
SUM(CASE WHEN "PING_VALUE" = '11111' THEN 1 ELSE 0 END) * 100.0 / COUNT(*),
|
||||||
2
|
2
|
||||||
) AS DOUBLE) AS connectionRate
|
) AS DOUBLE) AS connectionRate
|
||||||
FROM "DATACONNECTION"
|
FROM "DATACONNECTION"
|
||||||
|
|||||||
@@ -2,11 +2,6 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
<mapper namespace="com.bigdata.dao.NWQualityMapper">
|
<mapper namespace="com.bigdata.dao.NWQualityMapper">
|
||||||
|
|
||||||
<!--
|
|
||||||
查询 Phoenix 表 NWQUALITY
|
|
||||||
表名在 Phoenix 中是大写,JDBC URL 中已指定 schema
|
|
||||||
-->
|
|
||||||
|
|
||||||
<!-- 按条件查询网络质量数据 -->
|
<!-- 按条件查询网络质量数据 -->
|
||||||
<select id="selectByCondition" resultType="com.bigdata.entity.NWQuality">
|
<select id="selectByCondition" resultType="com.bigdata.entity.NWQuality">
|
||||||
SELECT
|
SELECT
|
||||||
@@ -24,14 +19,16 @@
|
|||||||
"COMPANYMODEL" AS companyModel
|
"COMPANYMODEL" AS companyModel
|
||||||
FROM "NWQUALITY"
|
FROM "NWQUALITY"
|
||||||
<where>
|
<where>
|
||||||
|
<!-- 核心修正:OGNL表达式中用 and 替代 && -->
|
||||||
<if test="operator != null and operator != ''">
|
<if test="operator != null and operator != ''">
|
||||||
AND "PROVINCE" LIKE CONCAT('%', #{operator})
|
AND "NWOPERATOR" = #{operator}
|
||||||
</if>
|
</if>
|
||||||
|
<!-- DAYTIME 为 BIGINT(yyyyMMddHHmmss),按日期部分 yyyyMMdd 比较 -->
|
||||||
<if test="startDate != null and startDate != ''">
|
<if test="startDate != null and startDate != ''">
|
||||||
AND "DAYTIME" >= TO_NUMBER(CONCAT(REPLACE(#{startDate}, '-', ''), '000000'))
|
AND ("DAYTIME" / 1000000) >= TO_NUMBER(#{startDate})
|
||||||
</if>
|
</if>
|
||||||
<if test="endDate != null and endDate != ''">
|
<if test="endDate != null and endDate != ''">
|
||||||
AND "DAYTIME" <= TO_NUMBER(CONCAT(REPLACE(#{endDate}, '-', ''), '235959'))
|
AND ("DAYTIME" / 1000000) <= TO_NUMBER(#{endDate})
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
ORDER BY "DAYTIME" DESC
|
ORDER BY "DAYTIME" DESC
|
||||||
@@ -39,50 +36,46 @@
|
|||||||
|
|
||||||
<!-- 统计各地区数量 -->
|
<!-- 统计各地区数量 -->
|
||||||
<select id="selectRegionStatistics" resultType="com.bigdata.dto.RegionStatisticsDTO">
|
<select id="selectRegionStatistics" resultType="com.bigdata.dto.RegionStatisticsDTO">
|
||||||
|
<choose>
|
||||||
|
<when test="operator != null and operator != ''">
|
||||||
SELECT
|
SELECT
|
||||||
CASE
|
"PROVINCE" AS region,
|
||||||
WHEN "PROVINCE" LIKE '%电信%' THEN REPLACE("PROVINCE", '电信', '')
|
"NWOPERATOR" AS operator,
|
||||||
WHEN "PROVINCE" LIKE '%移动%' THEN REPLACE("PROVINCE", '移动', '')
|
|
||||||
WHEN "PROVINCE" LIKE '%联通%' THEN REPLACE("PROVINCE", '联通', '')
|
|
||||||
WHEN "PROVINCE" LIKE '%铁通%' THEN REPLACE("PROVINCE", '铁通', '')
|
|
||||||
ELSE "PROVINCE"
|
|
||||||
END AS region,
|
|
||||||
CASE
|
|
||||||
WHEN "PROVINCE" LIKE '%电信%' THEN '电信'
|
|
||||||
WHEN "PROVINCE" LIKE '%移动%' THEN '移动'
|
|
||||||
WHEN "PROVINCE" LIKE '%联通%' THEN '联通'
|
|
||||||
WHEN "PROVINCE" LIKE '%铁通%' THEN '铁通'
|
|
||||||
ELSE '未知'
|
|
||||||
END AS operator,
|
|
||||||
CAST(COUNT(*) AS BIGINT) AS count
|
CAST(COUNT(*) AS BIGINT) AS count
|
||||||
FROM "NWQUALITY"
|
FROM "NWQUALITY"
|
||||||
<where>
|
<where>
|
||||||
<if test="operator != null and operator != ''">
|
"NWOPERATOR" = #{operator}
|
||||||
AND "PROVINCE" LIKE CONCAT('%', #{operator})
|
|
||||||
</if>
|
|
||||||
<if test="startDate != null and startDate != ''">
|
<if test="startDate != null and startDate != ''">
|
||||||
AND "DAYTIME" >= TO_NUMBER(CONCAT(REPLACE(#{startDate}, '-', ''), '000000'))
|
AND ("DAYTIME" / 1000000) >= TO_NUMBER(#{startDate})
|
||||||
</if>
|
</if>
|
||||||
<if test="endDate != null and endDate != ''">
|
<if test="endDate != null and endDate != ''">
|
||||||
AND "DAYTIME" <= TO_NUMBER(CONCAT(REPLACE(#{endDate}, '-', ''), '235959'))
|
AND ("DAYTIME" / 1000000) <= TO_NUMBER(#{endDate})
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY
|
GROUP BY "PROVINCE", "NWOPERATOR"
|
||||||
CASE
|
|
||||||
WHEN "PROVINCE" LIKE '%电信%' THEN REPLACE("PROVINCE", '电信', '')
|
|
||||||
WHEN "PROVINCE" LIKE '%移动%' THEN REPLACE("PROVINCE", '移动', '')
|
|
||||||
WHEN "PROVINCE" LIKE '%联通%' THEN REPLACE("PROVINCE", '联通', '')
|
|
||||||
WHEN "PROVINCE" LIKE '%铁通%' THEN REPLACE("PROVINCE", '铁通', '')
|
|
||||||
ELSE "PROVINCE"
|
|
||||||
END,
|
|
||||||
CASE
|
|
||||||
WHEN "PROVINCE" LIKE '%电信%' THEN '电信'
|
|
||||||
WHEN "PROVINCE" LIKE '%移动%' THEN '移动'
|
|
||||||
WHEN "PROVINCE" LIKE '%联通%' THEN '联通'
|
|
||||||
WHEN "PROVINCE" LIKE '%铁通%' THEN '铁通'
|
|
||||||
ELSE '未知'
|
|
||||||
END
|
|
||||||
ORDER BY count DESC, region
|
ORDER BY count DESC, region
|
||||||
|
</when>
|
||||||
|
|
||||||
|
<otherwise>
|
||||||
|
SELECT
|
||||||
|
"PROVINCE" AS region,
|
||||||
|
"NWOPERATOR" AS operator,
|
||||||
|
CAST(COUNT(*) AS BIGINT) AS count
|
||||||
|
FROM "NWQUALITY"
|
||||||
|
<where>
|
||||||
|
"NWOPERATOR" IN ('CMCC','CUCC','CTCC')
|
||||||
|
<if test="startDate != null and startDate != ''">
|
||||||
|
AND ("DAYTIME" / 1000000) >= TO_NUMBER(#{startDate})
|
||||||
|
</if>
|
||||||
|
<if test="endDate != null and endDate != ''">
|
||||||
|
AND ("DAYTIME" / 1000000) <= TO_NUMBER(#{endDate})
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY "PROVINCE", "NWOPERATOR"
|
||||||
|
ORDER BY count DESC
|
||||||
|
LIMIT 10
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user