feat: 视频监控设备统计查询
This commit is contained in:
parent
b3406a0246
commit
7d230273e8
@ -63,6 +63,7 @@ public class SecurityConfig {
|
|||||||
.requestMatchers("/wt/**").permitAll()
|
.requestMatchers("/wt/**").permitAll()
|
||||||
.requestMatchers("/zq/**").permitAll()
|
.requestMatchers("/zq/**").permitAll()
|
||||||
.requestMatchers("/wq/**").permitAll()
|
.requestMatchers("/wq/**").permitAll()
|
||||||
|
.requestMatchers("/vd/**").permitAll()
|
||||||
.requestMatchers("/fp/**").permitAll()
|
.requestMatchers("/fp/**").permitAll()
|
||||||
.requestMatchers("/fh/**").permitAll()
|
.requestMatchers("/fh/**").permitAll()
|
||||||
.requestMatchers("/data/**").permitAll()
|
.requestMatchers("/data/**").permitAll()
|
||||||
|
|||||||
@ -84,6 +84,14 @@ public class SwaggerConfig {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public GroupedOpenApi groupEnvVDApi() {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("3.3.1 全过程-生态环保数据服务-过鱼设施-过鱼监测")
|
||||||
|
.packagesToScan("com.yfd.platform.qgc_env.vd.controller")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public GroupedOpenApi groupEnvFHApi() {
|
public GroupedOpenApi groupEnvFHApi() {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.yfd.platform.qgc_env.vd.controller;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.config.ResponseResult;
|
||||||
|
import com.yfd.platform.qgc_env.vd.service.VdMonitorService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/vd")
|
||||||
|
@Tag(name = "视频监控模块")
|
||||||
|
@Validated
|
||||||
|
public class VdMonitorController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private VdMonitorService vdMonitorService;
|
||||||
|
|
||||||
|
@PostMapping("/vmsstbprpt/GetKendoList")
|
||||||
|
@Operation(summary = "视频监控设备统计查询")
|
||||||
|
public ResponseResult getVmsstbprptList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(vdMonitorService.getVmsstbprptList(dataSourceRequest));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
package com.yfd.platform.qgc_env.vd.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "视频监控设备分组统计")
|
||||||
|
public class VdVmsstbprptVo implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "站类编码")
|
||||||
|
private String sttpCode;
|
||||||
|
|
||||||
|
@Schema(description = "站类值")
|
||||||
|
private String sttpCodeValue;
|
||||||
|
|
||||||
|
@Schema(description = "站类扩展")
|
||||||
|
private Object sttpCodeExt;
|
||||||
|
|
||||||
|
@Schema(description = "站类数量")
|
||||||
|
private Integer countSttpCode;
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.yfd.platform.qgc_env.vd.service;
|
||||||
|
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.qgc_env.vd.entity.vo.VdVmsstbprptVo;
|
||||||
|
|
||||||
|
public interface VdMonitorService {
|
||||||
|
|
||||||
|
DataSourceResult<VdVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
|
}
|
||||||
@ -0,0 +1,233 @@
|
|||||||
|
package com.yfd.platform.qgc_env.vd.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
||||||
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.common.GroupHelper;
|
||||||
|
import com.yfd.platform.common.GroupingInfo;
|
||||||
|
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||||
|
import com.yfd.platform.qgc_env.vd.entity.vo.VdVmsstbprptVo;
|
||||||
|
import com.yfd.platform.qgc_env.vd.service.VdMonitorService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class VdMonitorServiceImpl implements VdMonitorService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<VdVmsstbprptVo> getVmsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
GroupingInfo[] groups = loadOptions == null ? null : loadOptions.getGroup();
|
||||||
|
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT t.STTP_CODE AS sttpCode, COUNT(1) AS COUNT_STTPCODE ")
|
||||||
|
.append("FROM (")
|
||||||
|
.append(buildUnionBaseSql())
|
||||||
|
.append(") t ")
|
||||||
|
.append("WHERE 1 = 1 ");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String filterSql = buildFilterCondition(dataSourceRequest == null ? null : dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||||
|
if (StrUtil.isNotBlank(filterSql)) {
|
||||||
|
sql.append(" AND ").append(filterSql).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
sql.append(" GROUP BY t.STTP_CODE ");
|
||||||
|
sql.append(buildOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getGroup()));
|
||||||
|
|
||||||
|
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(null, sql.toString(), paramMap);
|
||||||
|
DataSourceResult<VdVmsstbprptVo> result = new DataSourceResult<>();
|
||||||
|
if (groups != null && groups.length > 0) {
|
||||||
|
if (Boolean.TRUE.equals(dataSourceRequest.getGroupResultFlat())) {
|
||||||
|
result.setData((List<VdVmsstbprptVo>) (List<?>) new GroupHelper().faltGroup(rows, Arrays.asList(groups)));
|
||||||
|
result.setTotal((long) rows.size());
|
||||||
|
} else {
|
||||||
|
result.setData((List<VdVmsstbprptVo>) (List<?>) new GroupHelper().group(rows, Arrays.asList(groups)));
|
||||||
|
result.setTotal((long) rows.size());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<VdVmsstbprptVo> data = new ArrayList<>();
|
||||||
|
for (Map<String, Object> row : rows) {
|
||||||
|
VdVmsstbprptVo vo = new VdVmsstbprptVo();
|
||||||
|
Object sttpCode = row.get("STTPCODE");
|
||||||
|
Object count = row.get("COUNT_STTPCODE");
|
||||||
|
vo.setSttpCode(sttpCode == null ? null : sttpCode.toString());
|
||||||
|
vo.setSttpCodeValue(sttpCode == null ? null : sttpCode.toString());
|
||||||
|
vo.setSttpCodeExt(null);
|
||||||
|
vo.setCountSttpCode(count == null ? 0 : Integer.parseInt(count.toString()));
|
||||||
|
data.add(vo);
|
||||||
|
}
|
||||||
|
result.setData(data);
|
||||||
|
result.setTotal((long) data.size());
|
||||||
|
}
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildUnionBaseSql() {
|
||||||
|
return "SELECT vd.STCD, vd.STTP AS STTP_CODE, sttp.STTP_NAME, sttp.FULL_PATH " +
|
||||||
|
"FROM SD_VDINFO_B vd " +
|
||||||
|
"LEFT JOIN SD_STTP_B sttp ON sttp.STTP_CODE = vd.STTP " +
|
||||||
|
" AND NVL(sttp.IS_DELETED, 0) = 0 AND NVL(sttp.ENABLE, 1) = 1 " +
|
||||||
|
"WHERE NVL(vd.USFL, 1) = 1 AND vd.STTP = 'VD_FP' " +
|
||||||
|
"UNION ALL " +
|
||||||
|
"SELECT sonar.STCD, sonar.STTP AS STTP_CODE, sttp.STTP_NAME, sttp.FULL_PATH " +
|
||||||
|
"FROM SD_SONAR_B_H sonar " +
|
||||||
|
"LEFT JOIN SD_STTP_B sttp ON sttp.STTP_CODE = sonar.STTP " +
|
||||||
|
" AND NVL(sttp.IS_DELETED, 0) = 0 AND NVL(sttp.ENABLE, 1) = 1 " +
|
||||||
|
"WHERE NVL(sonar.IS_DELETED, 0) = 0 AND sonar.STTP IN ('VD_WVD', 'VD_SN') ";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
if (filter == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(filter.getField())) {
|
||||||
|
return buildLeafCondition(filter, paramMap, indexHolder);
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> conditions = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||||
|
String childSql = buildFilterCondition(child, paramMap, indexHolder);
|
||||||
|
if (StrUtil.isNotBlank(childSql)) {
|
||||||
|
conditions.add("(" + childSql + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (conditions.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ";
|
||||||
|
return String.join(logic, conditions);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
int[] indexHolder) {
|
||||||
|
String column = mapColumn(filter.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||||
|
Object value = filter.getValue();
|
||||||
|
if ("isnull".equals(operator)) {
|
||||||
|
return column + " IS NULL";
|
||||||
|
}
|
||||||
|
if ("isnotnull".equals(operator)) {
|
||||||
|
return column + " IS NOT NULL";
|
||||||
|
}
|
||||||
|
if ("in".equals(operator)) {
|
||||||
|
List<Object> values = normalizeValues(value);
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (Object item : values) {
|
||||||
|
String paramKey = "vdParam" + indexHolder[0]++;
|
||||||
|
paramMap.put(paramKey, item);
|
||||||
|
placeholders.add("#{map." + paramKey + "}");
|
||||||
|
}
|
||||||
|
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||||
|
}
|
||||||
|
if (value == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String paramKey = "vdParam" + indexHolder[0]++;
|
||||||
|
return switch (operator) {
|
||||||
|
case "eq" -> {
|
||||||
|
paramMap.put(paramKey, value);
|
||||||
|
yield column + " = #{map." + paramKey + "}";
|
||||||
|
}
|
||||||
|
case "neq" -> {
|
||||||
|
paramMap.put(paramKey, value);
|
||||||
|
yield column + " <> #{map." + paramKey + "}";
|
||||||
|
}
|
||||||
|
case "contains" -> {
|
||||||
|
paramMap.put(paramKey, "%" + value + "%");
|
||||||
|
yield column + " LIKE #{map." + paramKey + "}";
|
||||||
|
}
|
||||||
|
case "startswith" -> {
|
||||||
|
paramMap.put(paramKey, value + "%");
|
||||||
|
yield column + " LIKE #{map." + paramKey + "}";
|
||||||
|
}
|
||||||
|
case "endswith" -> {
|
||||||
|
paramMap.put(paramKey, "%" + value);
|
||||||
|
yield column + " LIKE #{map." + paramKey + "}";
|
||||||
|
}
|
||||||
|
default -> "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Object> normalizeValues(Object value) {
|
||||||
|
List<Object> values = new ArrayList<>();
|
||||||
|
if (value instanceof List<?> list) {
|
||||||
|
for (Object item : list) {
|
||||||
|
if (item != null) {
|
||||||
|
values.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
if (value instanceof Object[] array) {
|
||||||
|
for (Object item : array) {
|
||||||
|
if (item != null) {
|
||||||
|
values.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
if (value != null) {
|
||||||
|
values.add(value);
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapColumn(String field) {
|
||||||
|
if (StrUtil.isBlank(field)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return switch (field) {
|
||||||
|
case "sttpCode" -> "t.STTP_CODE";
|
||||||
|
case "sttpName" -> "t.STTP_NAME";
|
||||||
|
case "sttpFullPath" -> "t.FULL_PATH";
|
||||||
|
case "stcd" -> "t.STCD";
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildOrderBySql(List<DataSourceRequest.GroupDescriptor> groups) {
|
||||||
|
if (CollUtil.isEmpty(groups)) {
|
||||||
|
return " ORDER BY t.STTP_CODE ASC";
|
||||||
|
}
|
||||||
|
List<String> orderItems = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.GroupDescriptor group : groups) {
|
||||||
|
if (group == null || StrUtil.isBlank(group.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String column = mapColumn(group.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String direction = "desc".equalsIgnoreCase(group.getDir()) ? "DESC" : "ASC";
|
||||||
|
orderItems.add(column + " " + direction);
|
||||||
|
}
|
||||||
|
if (orderItems.isEmpty()) {
|
||||||
|
return " ORDER BY t.STTP_CODE ASC";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orderItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user