feat: 增殖站鱼种完成情况统计
This commit is contained in:
parent
72677ee0e5
commit
64ef59380d
@ -85,6 +85,12 @@ public class FbStationController {
|
||||
return ResponseResult.successData(fbStationService.getFbFlDataKendoListCust(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/fishType/GetKendoListCust")
|
||||
@Operation(summary = "增殖站鱼种完成情况统计")
|
||||
public ResponseResult getFishTypeKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(fbStationService.getFishTypeKendoListCust(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/msfbrdm/GetKendoListCust")
|
||||
@Operation(summary = "鱼类增殖站运行情况统计列表")
|
||||
public ResponseResult getMsfbrdmKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
package com.yfd.platform.qgc_env.fb.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FbFishTypeFinishVo {
|
||||
|
||||
private String stcd;
|
||||
|
||||
private Integer finished;
|
||||
|
||||
private Integer unfinished;
|
||||
}
|
||||
@ -5,6 +5,7 @@ import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRQgcVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishTableVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbFlDataVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbFishTypeFinishVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbRelatedYrVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbMsfbrdmQgcVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbResearchVo;
|
||||
@ -26,6 +27,8 @@ public interface FbStationService {
|
||||
|
||||
DataSourceResult<FbFlDataVo> getFbFlDataKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<FbFishTypeFinishVo> getFishTypeKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<FbMsfbrdmQgcVo> getMsfbrdmKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<FbMsfbrdmQgcVo> getQgcMsfbrdmKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
|
||||
@ -15,6 +15,7 @@ import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRQgcVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishHeadColumnVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishSummaryVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishTableVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbFishTypeFinishVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbFtpStatisticsVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbFlDataVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbMsfbrdmQgcVo;
|
||||
@ -83,6 +84,38 @@ public class FbStationServiceImpl implements FbStationService {
|
||||
return queryFbFlDataDetailList(dataSourceRequest, loadOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<FbFishTypeFinishVo> getFishTypeKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
String rstcdFilter = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "rstcd");
|
||||
String stcd = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "stcd");
|
||||
String startTime = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "startTime");
|
||||
String endTime = loadOptions == null ? null : QgcQueryWrapperUtil.getFilterFieldValue(loadOptions, "endTime");
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String sql = buildFishTypeFinishSql(
|
||||
stcd,
|
||||
parseFishTypeFilterValues(rstcdFilter),
|
||||
parseFishTypeDate(startTime),
|
||||
parseFishTypeDate(endTime),
|
||||
paramMap
|
||||
) + buildFishTypeOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort());
|
||||
|
||||
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<FbFishTypeFinishVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page,
|
||||
sql,
|
||||
paramMap,
|
||||
FbFishTypeFinishVo.class
|
||||
);
|
||||
|
||||
DataSourceResult<FbFishTypeFinishVo> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<Map<String, Object>> getMsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
@ -807,6 +840,126 @@ public class FbStationServiceImpl implements FbStationService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildFishTypeFinishSql(String stcd,
|
||||
List<String> rstcdList,
|
||||
Date startTime,
|
||||
Date endTime,
|
||||
Map<String, Object> paramMap) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT temp.stcd AS stcd, ")
|
||||
.append("SUM(CASE WHEN temp.bftp IS NOT NULL THEN 1 ELSE 0 END) AS finished, ")
|
||||
.append("SUM(CASE WHEN temp.aftp IS NOT NULL THEN 1 ELSE 0 END) AS unfinished ")
|
||||
.append("FROM ( ")
|
||||
.append("SELECT a.RSTCD AS stcd, a.FTP AS aftp, b.FTP AS bftp ")
|
||||
.append("FROM ( ")
|
||||
.append("SELECT jhr.RSTCD, jhrs.FTP ")
|
||||
.append("FROM SD_ENGFRPLAN_B jhr ")
|
||||
.append("JOIN SD_ENGFRPLANDET_B jhrs ON jhr.ID = jhrs.RPJH_ID ")
|
||||
.append("WHERE NVL(jhr.IS_DELETED, 0) = 0 AND NVL(jhrs.IS_DELETED, 0) = 0 ");
|
||||
appendFishTypeFilterSql(sql, "jhr", stcd, rstcdList, startTime, endTime, true, paramMap);
|
||||
sql.append("GROUP BY jhr.RSTCD, jhrs.FTP ")
|
||||
.append(") a ")
|
||||
.append("LEFT JOIN ( ")
|
||||
.append("SELECT imnr.RSTCD, imnrs.FTP ")
|
||||
.append("FROM SD_ENGFR_R imnr ")
|
||||
.append("JOIN SD_RPIMNFISH_R imnrs ON imnr.ID = imnrs.RPIMN_ID ")
|
||||
.append("WHERE NVL(imnr.IS_DELETED, 0) = 0 AND NVL(imnrs.IS_DELETED, 0) = 0 ");
|
||||
appendFishTypeFilterSql(sql, "imnr", stcd, rstcdList, startTime, endTime, false, paramMap);
|
||||
sql.append("GROUP BY imnr.RSTCD, imnrs.FTP ")
|
||||
.append(") b ON a.RSTCD = b.RSTCD AND a.FTP = b.FTP ")
|
||||
.append(") temp ")
|
||||
.append("GROUP BY temp.stcd");
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
private void appendFishTypeFilterSql(StringBuilder sql,
|
||||
String alias,
|
||||
String stcd,
|
||||
List<String> rstcdList,
|
||||
Date startTime,
|
||||
Date endTime,
|
||||
boolean planSide,
|
||||
Map<String, Object> paramMap) {
|
||||
if (StrUtil.isNotBlank(stcd)) {
|
||||
String key = "fishType" + alias + "Stcd";
|
||||
paramMap.put(key, stcd.trim());
|
||||
sql.append(" AND ").append(alias).append(".RSTCD = #{map.").append(key).append("} ");
|
||||
}
|
||||
if (CollUtil.isNotEmpty(rstcdList)) {
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
for (int i = 0; i < rstcdList.size(); i++) {
|
||||
String key = "fishType" + alias + "Rstcd" + i;
|
||||
paramMap.put(key, rstcdList.get(i));
|
||||
placeholders.add("#{map." + key + "}");
|
||||
}
|
||||
sql.append(" AND ").append(alias).append(".STCD IN (").append(String.join(", ", placeholders)).append(") ");
|
||||
}
|
||||
if (startTime != null) {
|
||||
String key = "fishType" + alias + "StartTime";
|
||||
paramMap.put(key, startTime);
|
||||
sql.append(" AND ").append(alias).append(planSide ? ".PLANSD" : ".TM")
|
||||
.append(" >= #{map.").append(key).append("} ");
|
||||
}
|
||||
if (endTime != null) {
|
||||
String key = "fishType" + alias + "EndTime";
|
||||
paramMap.put(key, endTime);
|
||||
sql.append(" AND ").append(alias).append(planSide ? ".PLANED" : ".TM")
|
||||
.append(" <= #{map.").append(key).append("} ");
|
||||
}
|
||||
}
|
||||
|
||||
private String buildFishTypeOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) {
|
||||
if (CollUtil.isEmpty(sorts)) {
|
||||
return " ORDER BY stcd ASC";
|
||||
}
|
||||
List<String> orderByParts = new ArrayList<>();
|
||||
for (DataSourceRequest.SortDescriptor sort : sorts) {
|
||||
if (sort == null || StrUtil.isBlank(sort.getField())) {
|
||||
continue;
|
||||
}
|
||||
String column = switch (sort.getField()) {
|
||||
case "stcd" -> "stcd";
|
||||
case "finished" -> "finished";
|
||||
case "unfinished" -> "unfinished";
|
||||
default -> null;
|
||||
};
|
||||
if (StrUtil.isBlank(column)) {
|
||||
continue;
|
||||
}
|
||||
String direction = "desc".equalsIgnoreCase(sort.getDir()) ? "DESC" : "ASC";
|
||||
orderByParts.add(column + " " + direction);
|
||||
}
|
||||
if (orderByParts.isEmpty()) {
|
||||
return " ORDER BY stcd ASC";
|
||||
}
|
||||
return " ORDER BY " + String.join(", ", orderByParts);
|
||||
}
|
||||
|
||||
private List<String> parseFishTypeFilterValues(String rawValue) {
|
||||
if (StrUtil.isBlank(rawValue)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Arrays.stream(rawValue.replace("[", "")
|
||||
.replace("]", "")
|
||||
.replace("\"", "")
|
||||
.split(","))
|
||||
.map(String::trim)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.distinct()
|
||||
.toList();
|
||||
}
|
||||
|
||||
private Date parseFishTypeDate(String value) {
|
||||
if (StrUtil.isBlank(value)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return DateUtil.parse(value.trim());
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String buildOverviewStationListSql(String baseId,
|
||||
List<String> stcdList,
|
||||
Map<String, Object> paramMap) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user