feat: 查询水生生态断面有数据的年份
This commit is contained in:
parent
04614d9d89
commit
78c93eeb02
@ -5,6 +5,8 @@ import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
@ -49,6 +51,20 @@ public interface MicroservicDynamicSQLMapper<T> {
|
||||
return convertList(allList, resultType);
|
||||
}
|
||||
|
||||
default List<String> getSingleColumnList(String sql, Map<String, Object> paramMap) {
|
||||
List<Map<String, Object>> rows = getAllList(sql, paramMap);
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> result = new ArrayList<>(rows.size());
|
||||
for (Map<String, Object> row : rows) {
|
||||
// 获取第一个值并转为字符串
|
||||
Object firstValue = row.values().iterator().next();
|
||||
result.add(firstValue == null ? null : firstValue.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Select({"select count(1) count from ${sql} and ${ew.sqlSegment}"})
|
||||
Integer count(@Param("select") String select, @Param("sql") String sql, @Param("ew") QueryWrapper queryWrapper);
|
||||
|
||||
|
||||
@ -161,4 +161,10 @@ public class WeFishController {
|
||||
public ResponseResult getWeDefaultData(@RequestParam("stcd") String stcd) {
|
||||
return ResponseResult.successData(weFishService.getWeDefaultData(stcd));
|
||||
}
|
||||
|
||||
@GetMapping("/we/wer/getWeYr")
|
||||
@Operation(summary = "查询水生生态断面有数据的年份")
|
||||
public ResponseResult getWeYr(@RequestParam("stcd") String stcd) {
|
||||
return ResponseResult.successData(weFishService.getWeYr(stcd));
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,4 +56,6 @@ public interface WeFishService {
|
||||
DataSourceResult<WeTeSpecialAnimalVo> getTeSpecialAnimalList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
List<WeDefaultDataVo> getWeDefaultData(String stcd);
|
||||
|
||||
DataSourceResult getWeYr(String stcd);
|
||||
}
|
||||
|
||||
@ -1154,6 +1154,28 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return oneBySqlWithResultType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult getWeYr(String stcd) {
|
||||
DataSourceResult dataSourceResult = new DataSourceResult();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT TO_CHAR(TM, 'yyyy') AS yr FROM SD_WE_R ")
|
||||
.append("WHERE NVL(IS_DELETED, 0) = 0 AND NVL(STATUS, 1) = 1 ");
|
||||
if (StrUtil.isNotBlank(stcd)) {
|
||||
sql.append("AND STCD = #{map.stcd} ");
|
||||
}
|
||||
sql.append("GROUP BY TO_CHAR(TM, 'yyyy') ")
|
||||
.append("ORDER BY TO_CHAR(TM, 'yyyy') DESC");
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
if (StrUtil.isNotBlank(stcd)) {
|
||||
paramMap.put("stcd", stcd);
|
||||
}
|
||||
List<String> yrList = microservicDynamicSQLMapper.getSingleColumnList(sql.toString(), paramMap);
|
||||
dataSourceResult.setData(yrList);
|
||||
dataSourceResult.setTotal(yrList == null ? 0L : yrList.size());
|
||||
return dataSourceResult;
|
||||
}
|
||||
|
||||
private String buildWeFishQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) {
|
||||
if (groupInfos == null || groupInfos.length == 0) {
|
||||
return baseSql;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user