feat: 增殖站放流数据统计
This commit is contained in:
parent
c5a270ecd5
commit
afa40d0372
@ -42,6 +42,12 @@ public class FbStationController {
|
|||||||
return ResponseResult.successData(fbStationService.getOverviewKendoListCust(dataSourceRequest));
|
return ResponseResult.successData(fbStationService.getOverviewKendoListCust(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/qgc/getFbStaticsData")
|
||||||
|
@Operation(summary = "增殖站放流数据统计")
|
||||||
|
public ResponseResult getQgcFbStaticsData(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(fbStationService.getQgcFbStaticsData(dataSourceRequest));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/rpimnr/qgc/year/GetYearRpStatistics")
|
@GetMapping("/rpimnr/qgc/year/GetYearRpStatistics")
|
||||||
@Operation(summary = "全过程放流统计总数,根据基地流域分组")
|
@Operation(summary = "全过程放流统计总数,根据基地流域分组")
|
||||||
public ResponseResult getYearRpStatistics(@Parameter(description = "年份") @RequestParam("year") String year) {
|
public ResponseResult getYearRpStatistics(@Parameter(description = "年份") @RequestParam("year") String year) {
|
||||||
|
|||||||
@ -0,0 +1,35 @@
|
|||||||
|
package com.yfd.platform.qgc_env.fb.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "增殖站放流统计结果")
|
||||||
|
public class FbStationStaticsDataVo {
|
||||||
|
|
||||||
|
@Schema(description = "流域编码")
|
||||||
|
private String hbrvcd;
|
||||||
|
|
||||||
|
@Schema(description = "流域名称")
|
||||||
|
private String hbrvcdName;
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类种数")
|
||||||
|
private Integer ftp;
|
||||||
|
|
||||||
|
@Schema(description = "放流数量")
|
||||||
|
private Long fcnt;
|
||||||
|
|
||||||
|
@Schema(description = "增殖站数量")
|
||||||
|
private Integer stcdCnt;
|
||||||
|
|
||||||
|
@Schema(description = "增殖站编码列表")
|
||||||
|
private List<String> stcdList;
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package com.yfd.platform.qgc_env.fb.entity.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "增殖站放流统计明细")
|
||||||
|
public class FbStationStaticsRawVo {
|
||||||
|
|
||||||
|
@Schema(description = "流域编码")
|
||||||
|
private String hbrvcd;
|
||||||
|
|
||||||
|
@Schema(description = "流域名称")
|
||||||
|
private String hbrvcdName;
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "增殖站编码")
|
||||||
|
private String stcd;
|
||||||
|
|
||||||
|
@Schema(description = "增殖站名称")
|
||||||
|
private String stnm;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类编码")
|
||||||
|
private String ftp;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类名称")
|
||||||
|
private String ftpName;
|
||||||
|
|
||||||
|
@Schema(description = "放流数量")
|
||||||
|
private Long fcnt;
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@ package com.yfd.platform.qgc_env.fb.service;
|
|||||||
|
|
||||||
import com.yfd.platform.common.DataSourceRequest;
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
import com.yfd.platform.common.DataSourceResult;
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsDataVo;
|
||||||
import com.yfd.platform.qgc_env.fb.entity.vo.YearRpStatisticsVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.YearRpStatisticsVo;
|
||||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
||||||
|
|
||||||
@ -13,6 +14,8 @@ public interface FbStationService {
|
|||||||
|
|
||||||
DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
|
DataSourceResult<FbStationStaticsDataVo> getQgcFbStaticsData(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FbStationOverviewSecondVo> getOverviewSecond(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbStationOverviewSecondVo> getOverviewSecond(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FbStationOverviewSecondVo> getQgcOverviewSecond(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbStationOverviewSecondVo> getQgcOverviewSecond(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -9,6 +9,8 @@ import com.yfd.platform.common.DataSourceResult;
|
|||||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbFtpStatisticsVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbFtpStatisticsVo;
|
||||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
||||||
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsDataVo;
|
||||||
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsRawVo;
|
||||||
import com.yfd.platform.qgc_env.fb.entity.vo.YearRpStatisticsVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.YearRpStatisticsVo;
|
||||||
import com.yfd.platform.qgc_env.fb.service.FbStationService;
|
import com.yfd.platform.qgc_env.fb.service.FbStationService;
|
||||||
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
import com.yfd.platform.utils.QgcQueryWrapperUtil;
|
||||||
@ -56,6 +58,79 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<FbStationStaticsDataVo> getQgcFbStaticsData(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
String baseId = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "baseId");
|
||||||
|
String startTime = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "startTime");
|
||||||
|
String endTime = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "endTime");
|
||||||
|
String hbrvcd = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "hbrvcd");
|
||||||
|
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String sql = buildQgcFbStaticsDataSql(
|
||||||
|
baseId,
|
||||||
|
hbrvcd,
|
||||||
|
parseDateTime(startTime),
|
||||||
|
parseDateTime(endTime),
|
||||||
|
paramMap
|
||||||
|
);
|
||||||
|
List<FbStationStaticsRawVo> rows = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
null, sql, paramMap, FbStationStaticsRawVo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
DataSourceResult<FbStationStaticsDataVo> result = new DataSourceResult<>();
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
if (CollUtil.isEmpty(rows)) {
|
||||||
|
result.setData(Collections.emptyList());
|
||||||
|
result.setTotal(0);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, List<FbStationStaticsRawVo>> grouped = rows.stream()
|
||||||
|
.filter(item -> StrUtil.isNotBlank(item.getHbrvcd()))
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
FbStationStaticsRawVo::getHbrvcd,
|
||||||
|
LinkedHashMap::new,
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
|
||||||
|
List<FbStationStaticsDataVo> data = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, List<FbStationStaticsRawVo>> entry : grouped.entrySet()) {
|
||||||
|
List<FbStationStaticsRawVo> value = entry.getValue();
|
||||||
|
if (CollUtil.isEmpty(value)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FbStationStaticsRawVo first = value.get(0);
|
||||||
|
Set<String> stcdSet = value.stream()
|
||||||
|
.map(FbStationStaticsRawVo::getStcd)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||||
|
|
||||||
|
FbStationStaticsDataVo vo = new FbStationStaticsDataVo();
|
||||||
|
vo.setHbrvcd(entry.getKey());
|
||||||
|
vo.setHbrvcdName(first.getHbrvcdName());
|
||||||
|
vo.setBaseId(first.getBaseId());
|
||||||
|
vo.setBaseName(first.getBaseName());
|
||||||
|
vo.setFtp((int) value.stream()
|
||||||
|
.map(FbStationStaticsRawVo::getFtp)
|
||||||
|
.filter(StrUtil::isNotBlank)
|
||||||
|
.distinct()
|
||||||
|
.count());
|
||||||
|
vo.setFcnt(value.stream()
|
||||||
|
.map(FbStationStaticsRawVo::getFcnt)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.mapToLong(Long::longValue)
|
||||||
|
.sum());
|
||||||
|
vo.setStcdList(new ArrayList<>(stcdSet));
|
||||||
|
vo.setStcdCnt(stcdSet.size());
|
||||||
|
data.add(vo);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.setData(data);
|
||||||
|
result.setTotal(data.size());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
@ -285,6 +360,13 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
return new BigDecimal(String.valueOf(value));
|
return new BigDecimal(String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Date parseDateTime(String value) {
|
||||||
|
if (StrUtil.isBlank(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return DateUtil.parse(value.trim(), "yyyy-MM-dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
|
||||||
private String buildYearRpStatisticsSql(String year, Map<String, Object> paramMap) {
|
private String buildYearRpStatisticsSql(String year, Map<String, Object> paramMap) {
|
||||||
StringBuilder sql = new StringBuilder();
|
StringBuilder sql = new StringBuilder();
|
||||||
sql.append("SELECT stat.BASE_ID AS baseId, ")
|
sql.append("SELECT stat.BASE_ID AS baseId, ")
|
||||||
@ -331,6 +413,60 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
return sql.toString();
|
return sql.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildQgcFbStaticsDataSql(String baseId,
|
||||||
|
String hbrvcd,
|
||||||
|
Date startDate,
|
||||||
|
Date endDate,
|
||||||
|
Map<String, Object> paramMap) {
|
||||||
|
String fishNameExpr = buildFishNameExpr("fish.FTP");
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT fb.HBRVCD AS hbrvcd, ")
|
||||||
|
.append("NVL(hbrv.HBRVNM, fb.HBRVCD) AS hbrvcdName, ")
|
||||||
|
.append("fb.BASE_ID AS baseId, ")
|
||||||
|
.append("hb.BASENAME AS baseName, ")
|
||||||
|
.append("fb.STCD AS stcd, ")
|
||||||
|
.append("fb.STNM AS stnm, ")
|
||||||
|
.append("fish.FTP AS ftp, ")
|
||||||
|
.append(fishNameExpr).append(" AS ftpName, ")
|
||||||
|
.append("fish.FCNT AS fcnt ")
|
||||||
|
.append("FROM SD_ENGFR_R run ")
|
||||||
|
.append("INNER JOIN SD_RPIMNFISH_R fish ON run.ID = fish.RPIMN_ID ")
|
||||||
|
.append(" AND NVL(fish.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND fish.FTP IS NOT NULL ")
|
||||||
|
.append("INNER JOIN SD_FBRD_B_H fb ON fb.STCD = run.RSTCD ")
|
||||||
|
.append("LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = fb.BASE_ID ")
|
||||||
|
.append(" AND NVL(hb.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND NVL(hb.ENABLED, 1) = 1 ")
|
||||||
|
.append("LEFT JOIN SD_HBRV_DIC hbrv ON hbrv.HBRVCD = fb.HBRVCD ")
|
||||||
|
.append(" AND hbrv.BASEID = fb.BASE_ID ")
|
||||||
|
.append(" AND NVL(hbrv.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND NVL(hbrv.ENABLED, 1) = 1 ")
|
||||||
|
.append(buildFishJoinSql("fish.FTP", "fb.HBRVCD"))
|
||||||
|
.append("WHERE NVL(run.IS_DELETED, 0) = 0 ");
|
||||||
|
if (StrUtil.isNotBlank(baseId)) {
|
||||||
|
paramMap.put("fbStaticsBaseId", baseId.trim());
|
||||||
|
sql.append("AND fb.BASE_ID = #{map.fbStaticsBaseId} ");
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(hbrvcd)) {
|
||||||
|
paramMap.put("fbStaticsHbrvcd", hbrvcd.trim());
|
||||||
|
sql.append("AND fb.HBRVCD = #{map.fbStaticsHbrvcd} ");
|
||||||
|
}
|
||||||
|
if (startDate != null) {
|
||||||
|
paramMap.put("fbStaticsStartDate", startDate);
|
||||||
|
sql.append("AND run.TM >= #{map.fbStaticsStartDate} ");
|
||||||
|
}
|
||||||
|
if (endDate != null) {
|
||||||
|
paramMap.put("fbStaticsEndDate", endDate);
|
||||||
|
sql.append("AND run.TM <= #{map.fbStaticsEndDate} ");
|
||||||
|
}
|
||||||
|
sql.append("ORDER BY NVL(hbrv.ORDER_INDEX, 9999), ")
|
||||||
|
.append("NVL(hb.ORDER_INDEX, 9999), ")
|
||||||
|
.append("NVL(fb.ORDER_INDEX, 9999), ")
|
||||||
|
.append("fb.STCD, ")
|
||||||
|
.append(fishNameExpr);
|
||||||
|
return sql.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataSourceResult<FbStationOverviewSecondVo> getQgcOverviewSecond(DataSourceRequest dataSourceRequest) {
|
public DataSourceResult<FbStationOverviewSecondVo> getQgcOverviewSecond(DataSourceRequest dataSourceRequest) {
|
||||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user