feat: 全过程放流统计总数,根据基地流域分组
This commit is contained in:
parent
6f81e82002
commit
c5a270ecd5
@ -3,12 +3,15 @@ package com.yfd.platform.qgc_env.fb.controller;
|
|||||||
import com.yfd.platform.common.DataSourceRequest;
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
import com.yfd.platform.config.ResponseResult;
|
import com.yfd.platform.config.ResponseResult;
|
||||||
import com.yfd.platform.qgc_env.fb.service.FbStationService;
|
import com.yfd.platform.qgc_env.fb.service.FbStationService;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@ -38,4 +41,10 @@ public class FbStationController {
|
|||||||
public ResponseResult getOverviewKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
public ResponseResult getOverviewKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
return ResponseResult.successData(fbStationService.getOverviewKendoListCust(dataSourceRequest));
|
return ResponseResult.successData(fbStationService.getOverviewKendoListCust(dataSourceRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/rpimnr/qgc/year/GetYearRpStatistics")
|
||||||
|
@Operation(summary = "全过程放流统计总数,根据基地流域分组")
|
||||||
|
public ResponseResult getYearRpStatistics(@Parameter(description = "年份") @RequestParam("year") String year) {
|
||||||
|
return ResponseResult.successData(fbStationService.getYearRpStatistics(year));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,24 @@
|
|||||||
|
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 FbFtpStatisticsVo {
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类编码")
|
||||||
|
private String ftp;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类名称")
|
||||||
|
private String fishName;
|
||||||
|
|
||||||
|
@Schema(description = "数量")
|
||||||
|
private Integer fcnt;
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
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 YearRpStatisticsVo {
|
||||||
|
|
||||||
|
@Schema(description = "放流总数")
|
||||||
|
private Integer fpCount;
|
||||||
|
|
||||||
|
@Schema(description = "基地编码")
|
||||||
|
private String baseId;
|
||||||
|
|
||||||
|
@Schema(description = "基地名称")
|
||||||
|
private String baseName;
|
||||||
|
|
||||||
|
@Schema(description = "鱼类分组统计")
|
||||||
|
private List<FbFtpStatisticsVo> fpFtpStatitcsVos;
|
||||||
|
}
|
||||||
@ -2,10 +2,15 @@ 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.YearRpStatisticsVo;
|
||||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface FbStationService {
|
public interface FbStationService {
|
||||||
|
|
||||||
|
List<YearRpStatisticsVo> getYearRpStatistics(String year);
|
||||||
|
|
||||||
DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbStationOverviewSecondVo> getOverviewKendoListCust(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
DataSourceResult<FbStationOverviewSecondVo> getOverviewSecond(DataSourceRequest dataSourceRequest);
|
DataSourceResult<FbStationOverviewSecondVo> getOverviewSecond(DataSourceRequest dataSourceRequest);
|
||||||
|
|||||||
@ -7,22 +7,18 @@ import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
|||||||
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.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.FbStationOverviewSecondVo;
|
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
||||||
|
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;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.Collections;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class FbStationServiceImpl implements FbStationService {
|
public class FbStationServiceImpl implements FbStationService {
|
||||||
@ -30,6 +26,36 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
@Resource
|
@Resource
|
||||||
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
|
private MicroservicDynamicSQLMapper microservicDynamicSQLMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<YearRpStatisticsVo> getYearRpStatistics(String year) {
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
String sql = buildYearRpStatisticsSql(year, paramMap);
|
||||||
|
List<FbFtpStatisticsVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
null, sql, paramMap, FbFtpStatisticsVo.class
|
||||||
|
);
|
||||||
|
if (CollUtil.isEmpty(list)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
Map<String, List<FbFtpStatisticsVo>> grouped = list.stream()
|
||||||
|
.filter(item -> StrUtil.isNotBlank(item.getBaseId()))
|
||||||
|
.collect(Collectors.groupingBy(FbFtpStatisticsVo::getBaseId, LinkedHashMap::new, Collectors.toList()));
|
||||||
|
List<YearRpStatisticsVo> result = new ArrayList<>();
|
||||||
|
for (Map.Entry<String, List<FbFtpStatisticsVo>> entry : grouped.entrySet()) {
|
||||||
|
YearRpStatisticsVo vo = new YearRpStatisticsVo();
|
||||||
|
vo.setBaseId(entry.getKey());
|
||||||
|
vo.setBaseName(entry.getValue().get(0).getBaseName());
|
||||||
|
int count = entry.getValue().stream()
|
||||||
|
.map(FbFtpStatisticsVo::getFcnt)
|
||||||
|
.filter(java.util.Objects::nonNull)
|
||||||
|
.mapToInt(Integer::intValue)
|
||||||
|
.sum();
|
||||||
|
vo.setFpCount(count);
|
||||||
|
vo.setFpFtpStatitcsVos(entry.getValue());
|
||||||
|
result.add(vo);
|
||||||
|
}
|
||||||
|
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();
|
||||||
@ -259,6 +285,52 @@ public class FbStationServiceImpl implements FbStationService {
|
|||||||
return new BigDecimal(String.valueOf(value));
|
return new BigDecimal(String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildYearRpStatisticsSql(String year, Map<String, Object> paramMap) {
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT stat.BASE_ID AS baseId, ")
|
||||||
|
.append(" stat.BASE_NAME AS baseName, ")
|
||||||
|
.append(" stat.FTP AS ftp, ")
|
||||||
|
.append(" stat.FISH_NAME AS fishName, ")
|
||||||
|
.append(" stat.FCNT AS fcnt ")
|
||||||
|
.append("FROM ( ")
|
||||||
|
.append(" SELECT src.BASE_ID, ")
|
||||||
|
.append(" src.BASE_NAME, ")
|
||||||
|
.append(" src.FTP, ")
|
||||||
|
.append(" src.FISH_NAME, ")
|
||||||
|
.append(" SUM(src.FCNT) AS FCNT ")
|
||||||
|
.append(" FROM ( ")
|
||||||
|
.append(" SELECT run.STCD, ")
|
||||||
|
.append(" run.TM, ")
|
||||||
|
.append(" fish.FTP, ")
|
||||||
|
.append(" fish.FCNT, ")
|
||||||
|
.append(" fb.BASE_ID, ")
|
||||||
|
.append(" hb.BASENAME AS BASE_NAME, ")
|
||||||
|
.append(" dict.NAME AS FISH_NAME ")
|
||||||
|
.append(" FROM SD_ENGFR_R run ")
|
||||||
|
.append(" INNER JOIN SD_RPIMNFISH_R fish ON run.ID = fish.RPIMN_ID ")
|
||||||
|
.append(" INNER JOIN SD_FBRD_B_H fb ON run.RSTCD = fb.STCD ")
|
||||||
|
.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 V_SD_FISHDICTORY_B dict ON fish.FTP = dict.FISH_ID ")
|
||||||
|
.append(" AND (fb.HBRVCD = dict.RVCD OR dict.RVCD = 'ZY') ")
|
||||||
|
.append(" WHERE NVL(run.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND NVL(fish.IS_DELETED, 0) = 0 ");
|
||||||
|
if (StrUtil.isNotBlank(year)) {
|
||||||
|
paramMap.put("yearRpStatisticsYear", year.trim());
|
||||||
|
sql.append("AND TO_CHAR(run.TM, 'YYYY') = #{map.yearRpStatisticsYear} ");
|
||||||
|
}
|
||||||
|
sql.append(" ) src ")
|
||||||
|
.append(" GROUP BY src.BASE_ID, src.BASE_NAME, src.FTP, src.FISH_NAME ")
|
||||||
|
.append(") stat ")
|
||||||
|
.append("LEFT JOIN SD_HYDROBASE hbSort ON stat.BASE_ID = hbSort.BASEID ")
|
||||||
|
.append(" AND NVL(hbSort.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND NVL(hbSort.ENABLED, 1) = 1 ")
|
||||||
|
.append("WHERE stat.FISH_NAME IS NOT NULL ")
|
||||||
|
.append("ORDER BY hbSort.ORDER_INDEX");
|
||||||
|
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