新增网络质量查询功能,包括 NWQualityController 和 NWQualityService 实现,同时添加 VCS 配置文件和更新数据库查询条件。
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
111
src/main/java/com/bigdata/controller/NWQualityController.java
Normal file
111
src/main/java/com/bigdata/controller/NWQualityController.java
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
package com.bigdata.controller;
|
||||||
|
|
||||||
|
import com.bigdata.dto.NWQualityQueryRequest;
|
||||||
|
import com.bigdata.dto.RegionStatisticsDTO;
|
||||||
|
import com.bigdata.entity.NWQuality;
|
||||||
|
import com.bigdata.service.NWQualityService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问 Phoenix 中 NWQUALITY 表的接口
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class NWQualityController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NWQualityService nwQualityService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询网络质量数据,支持按运营商和时间范围筛选
|
||||||
|
* @param request 查询请求参数,包含 operator(运营商)和 startDate、endDate(时间范围)字段,均为可选
|
||||||
|
* @return 数据列表
|
||||||
|
*/
|
||||||
|
@PostMapping("/nwQuality")
|
||||||
|
public List<NWQuality> query(@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()) {
|
||||||
|
operator = request.getOperator().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
||||||
|
startDate = request.getStartDate().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
||||||
|
endDate = request.getEndDate().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按条件查询
|
||||||
|
List<NWQuality> list = nwQualityService.getByCondition(operator, startDate, endDate);
|
||||||
|
|
||||||
|
// 打印到控制台
|
||||||
|
System.out.println("====== nw_quality 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(时间范围)字段,均为可选
|
||||||
|
* @return 地区统计列表,包含地区名称、运营商和数量
|
||||||
|
*/
|
||||||
|
@PostMapping("/nwQuality/regionStatistics")
|
||||||
|
public List<RegionStatisticsDTO> getRegionStatistics(@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()) {
|
||||||
|
operator = request.getOperator().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getStartDate() != null && !request.getStartDate().trim().isEmpty()) {
|
||||||
|
startDate = request.getStartDate().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getEndDate() != null && !request.getEndDate().trim().isEmpty()) {
|
||||||
|
endDate = request.getEndDate().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按条件查询地区统计
|
||||||
|
List<RegionStatisticsDTO> result = nwQualityService.getRegionStatistics(operator, startDate, endDate);
|
||||||
|
|
||||||
|
// 打印到控制台
|
||||||
|
System.out.println("====== region statistics ======");
|
||||||
|
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 regions: " + result.size());
|
||||||
|
for (RegionStatisticsDTO dto : result) {
|
||||||
|
System.out.println("Region: " + dto.getRegion() +
|
||||||
|
", Operator: " + dto.getOperator() +
|
||||||
|
", Count: " + dto.getCount());
|
||||||
|
}
|
||||||
|
System.out.println("================================================");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.bigdata.service.impl;
|
||||||
|
|
||||||
|
import com.bigdata.dao.NWQualityMapper;
|
||||||
|
import com.bigdata.dto.RegionStatisticsDTO;
|
||||||
|
import com.bigdata.entity.NWQuality;
|
||||||
|
import com.bigdata.service.NWQualityService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class NWQualityServiceImpl implements NWQualityService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NWQualityMapper nwQualityMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<NWQuality> getByCondition(String operator, String startDate, String endDate) {
|
||||||
|
return nwQualityMapper.selectByCondition(operator, startDate, endDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RegionStatisticsDTO> getRegionStatistics(String operator, String startDate, String endDate) {
|
||||||
|
return nwQualityMapper.selectRegionStatistics(operator, startDate, endDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
AND "PROVINCE" LIKE CONCAT('%', #{operator})
|
AND "PROVINCE" LIKE CONCAT('%', #{operator})
|
||||||
</if>
|
</if>
|
||||||
<if test="startDate != null and startDate != ''">
|
<if test="startDate != null and startDate != ''">
|
||||||
AND "DAYTIME" >= TO_TIMESTAMP(CONCAT(#{startDate}, ' 00:00:00'), 'yyyy-MM-dd HH:mm:ss')
|
AND "DAYTIME" >= TO_NUMBER(CONCAT(REPLACE(#{startDate}, '-', ''), '000000'))
|
||||||
</if>
|
</if>
|
||||||
<if test="endDate != null and endDate != ''">
|
<if test="endDate != null and endDate != ''">
|
||||||
AND "DAYTIME" <= TO_TIMESTAMP(CONCAT(#{endDate}, ' 23:59:59'), 'yyyy-MM-dd HH:mm:ss')
|
AND "DAYTIME" <= TO_NUMBER(CONCAT(REPLACE(#{endDate}, '-', ''), '235959'))
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
ORDER BY "DAYTIME" DESC
|
ORDER BY "DAYTIME" DESC
|
||||||
@@ -61,10 +61,10 @@
|
|||||||
AND "PROVINCE" LIKE CONCAT('%', #{operator})
|
AND "PROVINCE" LIKE CONCAT('%', #{operator})
|
||||||
</if>
|
</if>
|
||||||
<if test="startDate != null and startDate != ''">
|
<if test="startDate != null and startDate != ''">
|
||||||
AND "DAYTIME" >= TO_TIMESTAMP(CONCAT(#{startDate}, ' 00:00:00'), 'yyyy-MM-dd HH:mm:ss')
|
AND "DAYTIME" >= TO_NUMBER(CONCAT(REPLACE(#{startDate}, '-', ''), '000000'))
|
||||||
</if>
|
</if>
|
||||||
<if test="endDate != null and endDate != ''">
|
<if test="endDate != null and endDate != ''">
|
||||||
AND "DAYTIME" <= TO_TIMESTAMP(CONCAT(#{endDate}, ' 23:59:59'), 'yyyy-MM-dd HH:mm:ss')
|
AND "DAYTIME" <= TO_NUMBER(CONCAT(REPLACE(#{endDate}, '-', ''), '235959'))
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
GROUP BY
|
GROUP BY
|
||||||
|
|||||||
Reference in New Issue
Block a user