feat: 水生生态调查概况
This commit is contained in:
parent
5bf3cf0ee9
commit
acaa7344d0
@ -32,4 +32,10 @@ public class WeFishController {
|
||||
public ResponseResult getQgcFishStaticsYearList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(weFishService.getQgcFishStaticsYearList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/we/fisht/statics/GetKendoListCust")
|
||||
@Operation(summary = "水生生态调查概况")
|
||||
public ResponseResult getQgcWeFishStatics(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(weFishService.getQgcWeFishStatics(dataSourceRequest));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.yfd.platform.qgc_env.wte.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@Schema(description = "水生生态调查概况")
|
||||
public class WeStaticsVo {
|
||||
|
||||
@Schema(description = "调查批次数量")
|
||||
private Long dcpcCount;
|
||||
|
||||
@Schema(description = "调查断面数量")
|
||||
private Long stcdCount;
|
||||
|
||||
@Schema(description = "调查鱼类数量")
|
||||
private Long ftpCount;
|
||||
|
||||
@Schema(description = "调查鱼类总数")
|
||||
private Long fcntSum;
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.yfd.platform.qgc_env.wte.service;
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo;
|
||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -12,4 +13,6 @@ public interface WeFishService {
|
||||
DataSourceResult<WeFishTQgcVo> getQgcWeFishTKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<Map<String, List<String>>> getQgcFishStaticsYearList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<WeStaticsVo> getQgcWeFishStatics(DataSourceRequest dataSourceRequest);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import com.yfd.platform.common.GroupingInfo;
|
||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeFishTQgcVo;
|
||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeRvcdYearVo;
|
||||
import com.yfd.platform.qgc_env.wte.entity.vo.WeStaticsVo;
|
||||
import com.yfd.platform.qgc_env.wte.service.WeFishService;
|
||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -19,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
@ -115,6 +117,34 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<WeStaticsVo> getQgcWeFishStatics(DataSourceRequest dataSourceRequest) {
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
DataSourceRequest.FilterDescriptor filter = dataSourceRequest == null ? null : dataSourceRequest.getFilter();
|
||||
|
||||
String baseId = getFirstWeFishFilterText(filter, "baseId");
|
||||
String hbrvcd = getFirstWeFishFilterText(filter, "hbrvcd");
|
||||
String yr = getFirstWeFishFilterText(filter, "yr");
|
||||
List<String> rstcdList = getWeFishFilterTexts(filter, "rstcd");
|
||||
|
||||
String sql = buildWeFishStaticsSql(baseId, hbrvcd, yr, rstcdList, paramMap);
|
||||
Map<String, Object> row = microservicDynamicSQLMapper.getOneBySql(sql, paramMap);
|
||||
WeStaticsVo vo = buildWeFishStaticsVo(row);
|
||||
if (vo == null) {
|
||||
vo = new WeStaticsVo();
|
||||
}
|
||||
vo.setDcpcCount(vo.getDcpcCount() == null ? 0L : vo.getDcpcCount());
|
||||
vo.setStcdCount(vo.getStcdCount() == null ? 0L : vo.getStcdCount());
|
||||
vo.setFtpCount(vo.getFtpCount() == null ? 0L : vo.getFtpCount());
|
||||
vo.setFcntSum(vo.getFcntSum() == null ? 0L : vo.getFcntSum());
|
||||
|
||||
DataSourceResult<WeStaticsVo> result = new DataSourceResult<>();
|
||||
result.setData(Collections.singletonList(vo));
|
||||
result.setTotal(1L);
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildWeFishQgcGroupSql(String baseSql, GroupingInfo[] groupInfos) {
|
||||
if (groupInfos == null || groupInfos.length == 0) {
|
||||
return baseSql;
|
||||
@ -250,6 +280,67 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
private String buildWeFishStaticsSql(String baseId,
|
||||
String hbrvcd,
|
||||
String yr,
|
||||
List<String> rstcdList,
|
||||
Map<String, Object> paramMap) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ")
|
||||
.append("COUNT(DISTINCT we.DCPC) AS dcpcCount, ")
|
||||
.append("COUNT(DISTINCT we.STCD) AS stcdCount, ")
|
||||
.append("COUNT(DISTINCT fish.FTP) AS ftpCount, ")
|
||||
.append("NVL(SUM(NVL(fish.FCNT, 0)), 0) AS fcntSum ")
|
||||
.append("FROM SD_WE_B_H section ")
|
||||
.append("INNER JOIN SD_WE_R we ON section.STCD = we.STCD ")
|
||||
.append(" AND NVL(we.IS_DELETED, 0) = 0 ")
|
||||
.append(" AND NVL(we.STATUS, 1) = 1 ")
|
||||
.append("LEFT JOIN SD_WEFISH_R fish ON fish.WER_ID = we.ID ")
|
||||
.append(" AND NVL(fish.IS_DELETED, 0) = 0 ")
|
||||
.append("WHERE NVL(section.USFL, 0) = 1 ");
|
||||
|
||||
if (StrUtil.isNotBlank(baseId)) {
|
||||
paramMap.put("weStaticsBaseId", baseId);
|
||||
sql.append("AND section.BASE_ID = #{map.weStaticsBaseId} ");
|
||||
}
|
||||
if (StrUtil.isNotBlank(hbrvcd)) {
|
||||
paramMap.put("weStaticsHbrvcd", hbrvcd);
|
||||
sql.append("AND section.HBRVCD = #{map.weStaticsHbrvcd} ");
|
||||
}
|
||||
if (StrUtil.isNotBlank(yr)) {
|
||||
paramMap.put("weStaticsYr", yr);
|
||||
sql.append("AND TO_CHAR(we.TM, 'yyyy') = #{map.weStaticsYr} ");
|
||||
}
|
||||
if (CollUtil.isNotEmpty(rstcdList)) {
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
int index = 0;
|
||||
for (String rstcd : rstcdList) {
|
||||
if (StrUtil.isBlank(rstcd)) {
|
||||
continue;
|
||||
}
|
||||
String key = "weStaticsRstcd" + index++;
|
||||
paramMap.put(key, rstcd);
|
||||
placeholders.add("#{map." + key + "}");
|
||||
}
|
||||
if (CollUtil.isNotEmpty(placeholders)) {
|
||||
sql.append("AND section.RSTCD IN (").append(String.join(", ", placeholders)).append(") ");
|
||||
}
|
||||
}
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
private WeStaticsVo buildWeFishStaticsVo(Map<String, Object> row) {
|
||||
if (row == null || row.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
WeStaticsVo vo = new WeStaticsVo();
|
||||
vo.setDcpcCount(toWeFishLongValue(firstPresentWeFishValue(row, "DCPCCOUNT", "dcpcCount")));
|
||||
vo.setStcdCount(toWeFishLongValue(firstPresentWeFishValue(row, "STCDCOUNT", "stcdCount")));
|
||||
vo.setFtpCount(toWeFishLongValue(firstPresentWeFishValue(row, "FTPCOUNT", "ftpCount")));
|
||||
vo.setFcntSum(toWeFishLongValue(firstPresentWeFishValue(row, "FCNTSUM", "fcntSum")));
|
||||
return vo;
|
||||
}
|
||||
|
||||
private String buildWeFishQgcDetailSql() {
|
||||
return "SELECT " +
|
||||
"section.STCD AS stcd, " +
|
||||
@ -570,6 +661,32 @@ public class WeFishServiceImpl implements WeFishService {
|
||||
}
|
||||
}
|
||||
|
||||
private Object firstPresentWeFishValue(Map<String, Object> row, String... keys) {
|
||||
if (row == null || keys == null) {
|
||||
return null;
|
||||
}
|
||||
for (String key : keys) {
|
||||
if (key != null && row.containsKey(key)) {
|
||||
return row.get(key);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Long toWeFishLongValue(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Number number) {
|
||||
return number.longValue();
|
||||
}
|
||||
try {
|
||||
return Long.parseLong(String.valueOf(value).trim());
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getFirstWeFishFilterText(DataSourceRequest.FilterDescriptor filter, String fieldName) {
|
||||
List<String> values = getWeFishFilterTexts(filter, fieldName);
|
||||
return CollUtil.isEmpty(values) ? null : values.get(0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user