feat: 亲鱼培育方式列表

This commit is contained in:
tangwei 2026-07-30 09:25:17 +08:00
parent e92f43339c
commit a1d1b2abf4
4 changed files with 358 additions and 0 deletions

View File

@ -77,6 +77,12 @@ public class FbStationController {
return ResponseResult.successData(fbStationService.getBsdeathRList(dataSourceRequest));
}
@PostMapping("/bsctmob/GetKendoListCust")
@Operation(summary = "亲鱼培育方式列表")
public ResponseResult getBsctmoBKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
return ResponseResult.successData(fbStationService.getBsctmoBList(dataSourceRequest));
}
@PostMapping("/bsmfr/qgc/GetKendoListCust")
@Operation(summary = "(全过程)增殖站二级页面: 亲鱼选配与培育->亲鱼信息")
public ResponseResult getBsmfrQgcKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {

View File

@ -0,0 +1,76 @@
package com.yfd.platform.qgc_env.fb.entity.vo;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 亲鱼培育方式 VO
*/
@Data
public class FbBsctmoBVo {
/** 主键 */
private String id;
/** 设施编码 */
private String stcd;
/** 鱼池编号 */
private String fpnum;
/** 鱼池名称 */
private String fpName;
/** 鱼种类 */
private String ftp;
/** 鱼类名称 */
private String ftpName;
/** 数量(尾) */
private Long value;
/** 全长(cm) */
private BigDecimal length;
/** 体重(g) */
private BigDecimal weight;
/** 培育方式1=流水单养 2=流水混养 3=静水 4=循环水 */
private Integer ctmo;
/** 培育方式名称 */
private String ctmoName;
/** 放养密度 */
private String skds;
/** 体重范围值 */
private String fwgh;
/** 记录人 */
private String recorder;
/** 创建人 */
private String recordUser;
/** 创建时间 */
private Date recordTime;
/** 更新人 */
private String modifyUser;
/** 更新时间 */
private Date modifyTime;
/** 是否已删除 */
private Integer isDeleted;
/** 删除人 */
private String deleteUser;
/** 删除时间 */
private Date deleteTime;
}

View File

@ -5,6 +5,7 @@ import com.yfd.platform.common.DataSourceResult;
import com.yfd.platform.qgc_env.fb.entity.vo.BreedStageVO;
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRVo;
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsdeathRVo;
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsctmoBVo;
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.FbEngFishVo;
@ -96,4 +97,9 @@ public interface FbStationService {
* 亲鱼死亡记录列表
*/
DataSourceResult<FbBsdeathRVo> getBsdeathRList(DataSourceRequest dataSourceRequest);
/**
* 亲鱼培育方式列表
*/
DataSourceResult<FbBsctmoBVo> getBsctmoBList(DataSourceRequest dataSourceRequest);
}

View File

@ -14,6 +14,7 @@ import com.yfd.platform.common.MicroservicDynamicSQLMapper;
import com.yfd.platform.qgc_env.fb.entity.vo.BreedStageVO;
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRVo;
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsdeathRVo;
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsctmoBVo;
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;
@ -1982,6 +1983,23 @@ public class FbStationServiceImpl implements FbStationService {
return result;
}
private String buildQgcMsfbrdmCoreSql1(Date startTime, Date endTime, Map<String, Object> paramMap) {
StringBuilder sql = new StringBuilder();
sql.append(" SELECT\n" +
" a.ID, a.STCD, a.TM,\n" +
" CASE WHEN ZY_FISH_ID IS NULL THEN TO_CHAR(a.FTP) ELSE TO_CHAR(ZY_FISH_ID) END AS ftp,CASE WHEN c.NAME IS NULL THEN TO_CHAR(a.FTP) ELSE TO_CHAR(c.NAME) END AS ftpName,\n" +
" a.BSSR, a.AGE, a.SEX, a.SIGNNUM, a.RECORDER, a.VALUE, a.FID,\n" +
" a.RECORD_USER, a.RECORD_TIME, a.MODIFY_USER, a.MODIFY_TIME,\n" +
" a.IS_DELETED, a.DELETE_USER, a.DELETE_TIME,\n" +
" a.LENGTH, a.WEIGHT\n" +
" FROM SD_FBBSMF_R a\n" +
" INNER JOIN V_MS_STBPRP_T b\n" +
" ON a.stcd = b.STCD AND b.STTP_CODE = 'FB' AND b.IS_DELETED = 0\n" +
" LEFT JOIN V_SD_FISHDICTORY_B c\n" +
" ON a.FTP = c.FISH_ID AND (b.HBRVCD = c.RVCD OR c.RVCD = 'ZY')");
return sql.toString();
}
private String buildQgcMsfbrdmCoreSql(Date startTime, Date endTime, Map<String, Object> paramMap) {
Integer year = startTime == null ? null : Integer.parseInt(DateUtil.format(startTime, "yyyy"));
String ftpCodeExpr = "COALESCE(TO_CHAR(NVL(relRv.ZY_FISH_ID, relRv.FISH_ID)), " +
@ -5812,4 +5830,256 @@ public class FbStationServiceImpl implements FbStationService {
}
return value;
}
// ==================== 亲鱼培育方式列表 ====================
@Override
public DataSourceResult<FbBsctmoBVo> getBsctmoBList(DataSourceRequest dataSourceRequest) {
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
GroupingInfo[] groups = loadOptions == null ? null : loadOptions.getGroup();
if (groups != null && groups.length > 0) {
return queryBsctmoBGroupList(dataSourceRequest, loadOptions, groups);
}
return queryBsctmoBDetailList(dataSourceRequest, loadOptions);
}
private DataSourceResult<FbBsctmoBVo> queryBsctmoBDetailList(DataSourceRequest dataSourceRequest,
DataSourceLoadOptionsBase loadOptions) {
Map<String, Object> paramMap = new HashMap<>();
StringBuilder sql = new StringBuilder();
sql.append("SELECT ")
.append(buildBsctmoBDetailSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
.append(" FROM (")
.append(buildBsctmoBCoreSql())
.append(") t WHERE 1 = 1 ");
String filterSql = buildBsctmoBFilterCondition(
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
paramMap, new int[]{0});
if (StrUtil.isNotBlank(filterSql)) {
sql.append(" AND ").append(filterSql).append(" ");
}
sql.append(buildBsctmoBOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
List<FbBsctmoBVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
page, sql.toString(), paramMap, FbBsctmoBVo.class);
DataSourceResult<FbBsctmoBVo> result = new DataSourceResult<>();
result.setData(list);
result.setTotal(page != null ? page.getTotal() : list.size());
result.setAggregates(new HashMap<>());
return result;
}
@SuppressWarnings({"rawtypes", "unchecked"})
private DataSourceResult<FbBsctmoBVo> queryBsctmoBGroupList(DataSourceRequest dataSourceRequest,
DataSourceLoadOptionsBase loadOptions,
GroupingInfo[] groupInfos) {
Map<String, Object> paramMap = new HashMap<>();
StringBuilder sql = new StringBuilder();
sql.append("SELECT * FROM (")
.append(buildBsctmoBCoreSql())
.append(") t WHERE 1 = 1 ");
String filterSql = buildBsctmoBFilterCondition(
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
paramMap, new int[]{0});
if (StrUtil.isNotBlank(filterSql)) {
sql.append(" AND ").append(filterSql).append(" ");
}
String groupedSql = buildBsctmoBGroupSql(sql.toString(),
dataSourceRequest == null ? null : dataSourceRequest.getGroup());
List<Map<String, Object>> rows = microservicDynamicSQLMapper.pageAllList(
null, groupedSql, paramMap);
DataSourceResult<FbBsctmoBVo> result = new DataSourceResult<>();
if (Boolean.TRUE.equals(dataSourceRequest == null ? false : dataSourceRequest.getGroupResultFlat())) {
result.setData((List<FbBsctmoBVo>) (List<?>) new GroupHelper().faltGroup(
rows, groupInfos == null ? Collections.emptyList() : Arrays.asList(groupInfos)));
} else {
result.setData((List<FbBsctmoBVo>) (List<?>) new GroupHelper().group(
rows, groupInfos == null ? Collections.emptyList() : Arrays.asList(groupInfos)));
}
result.setTotal(rows.size());
result.setAggregates(new HashMap<>());
return result;
}
private String buildBsctmoBCoreSql() {
return "SELECT rec.ID AS id, "
+ "rec.STCD AS stcd, "
+ "rec.FPNUM AS fpnum, "
+ "CAST(NULL AS VARCHAR2(255)) AS fpName, "
+ "rec.FTP AS ftp, "
+ "CAST(NULL AS VARCHAR2(255)) AS ftpName, "
+ "rec.VALUE AS value, "
+ "rec.LENGTH AS length, "
+ "rec.WEIGHT AS weight, "
+ "rec.CTMO AS ctmo, "
+ "CASE WHEN rec.CTMO = 1 THEN '流水单养培育' WHEN rec.CTMO = 2 THEN '流水混养培育' WHEN rec.CTMO = 3 THEN '静水培育' WHEN rec.CTMO = 4 THEN '循环水培育' ELSE NULL END AS ctmoName, "
+ "rec.SKDS AS skds, "
+ "rec.FWGH AS fwgh, "
+ "rec.RECORDER AS recorder, "
+ "rec.RECORD_USER AS recordUser, "
+ "rec.RECORD_TIME AS recordTime, "
+ "rec.MODIFY_USER AS modifyUser, "
+ "rec.MODIFY_TIME AS modifyTime, "
+ "rec.IS_DELETED AS isDeleted, "
+ "rec.DELETE_USER AS deleteUser, "
+ "rec.DELETE_TIME AS deleteTime "
+ "FROM SD_FBBSCTMO_B rec "
+ "WHERE NVL(rec.IS_DELETED, 0) = 0";
}
private String buildBsctmoBDetailSelectSql(List<String> select) {
List<String> fields = CollUtil.isEmpty(select)
? List.of("id", "stcd", "fpnum", "fpName", "ftp", "ftpName", "value", "length", "weight",
"ctmo", "ctmoName", "skds", "fwgh", "recorder", "recordUser", "recordTime",
"modifyUser", "modifyTime", "isDeleted", "deleteUser", "deleteTime")
: select;
List<String> selectParts = new ArrayList<>();
for (String field : fields) {
String column = mapBsctmoBColumn(field);
if (StrUtil.isNotBlank(column)) {
selectParts.add(column + " AS " + field);
}
}
if (selectParts.isEmpty()) {
selectParts.add("t.id AS id");
}
return String.join(", ", selectParts);
}
private String buildBsctmoBFilterCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap,
int[] indexHolder) {
if (filter == null) return "";
if (StrUtil.isNotBlank(filter.getField())) return buildBsctmoBLeafCondition(filter, paramMap, indexHolder);
if (CollUtil.isEmpty(filter.getFilters())) return "";
List<String> conditions = new ArrayList<>();
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
String childSql = buildBsctmoBFilterCondition(child, paramMap, indexHolder);
if (StrUtil.isNotBlank(childSql)) conditions.add("(" + childSql + ")");
}
if (conditions.isEmpty()) return "";
return String.join("or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ", conditions);
}
private String buildBsctmoBLeafCondition(DataSourceRequest.FilterDescriptor filter,
Map<String, Object> paramMap,
int[] indexHolder) {
String column = mapBsctmoBColumn(filter.getField());
if (StrUtil.isBlank(column)) return "";
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
Object value = filter.getValue();
if ("isnull".equals(operator)) return column + " IS NULL";
if ("isnotnull".equals(operator)) return column + " IS NOT NULL";
if ("in".equals(operator)) {
List<Object> values = normalizeBsctmoBValues(value);
if (values.isEmpty()) return "";
List<String> placeholders = new ArrayList<>();
for (Object item : values) {
String key = "bctP" + indexHolder[0]++;
paramMap.put(key, normalizeBsctmoBValue(filter.getField(), item));
placeholders.add("#{map." + key + "}");
}
return column + " IN (" + String.join(", ", placeholders) + ")";
}
if (value == null) return "";
String key = "bctP" + indexHolder[0]++;
Object normalizedValue = normalizeBsctmoBValue(filter.getField(), value);
return switch (operator) {
case "eq" -> { paramMap.put(key, normalizedValue); yield column + " = #{map." + key + "}"; }
case "neq" -> { paramMap.put(key, normalizedValue); yield column + " <> #{map." + key + "}"; }
case "gt" -> { paramMap.put(key, normalizedValue); yield column + " > #{map." + key + "}"; }
case "gte" -> { paramMap.put(key, normalizedValue); yield column + " >= #{map." + key + "}"; }
case "lt" -> { paramMap.put(key, normalizedValue); yield column + " < #{map." + key + "}"; }
case "lte" -> { paramMap.put(key, normalizedValue); yield column + " <= #{map." + key + "}"; }
case "contains" -> { paramMap.put(key, "%" + normalizedValue + "%"); yield column + " LIKE #{map." + key + "}"; }
case "doesnotcontain" -> { paramMap.put(key, "%" + normalizedValue + "%"); yield column + " NOT LIKE #{map." + key + "}"; }
case "startswith" -> { paramMap.put(key, normalizedValue + "%"); yield column + " LIKE #{map." + key + "}"; }
case "endswith" -> { paramMap.put(key, "%" + normalizedValue); yield column + " LIKE #{map." + key + "}"; }
default -> "";
};
}
private String buildBsctmoBOrderBySql(List<DataSourceRequest.SortDescriptor> sortDescriptors) {
if (CollUtil.isEmpty(sortDescriptors)) return " ORDER BY t.id DESC";
List<String> parts = new ArrayList<>();
for (DataSourceRequest.SortDescriptor descriptor : sortDescriptors) {
String column = mapBsctmoBColumn(descriptor.getField());
if (StrUtil.isBlank(column)) continue;
parts.add(column + ("desc".equalsIgnoreCase(descriptor.getDir()) ? " DESC" : " ASC"));
}
if (parts.isEmpty()) return " ORDER BY t.id DESC";
return " ORDER BY " + String.join(", ", parts);
}
private String buildBsctmoBGroupSql(String baseSql, List<DataSourceRequest.GroupDescriptor> groups) {
if (CollUtil.isEmpty(groups)) return baseSql;
List<DataSourceRequest.GroupDescriptor> validGroups = groups.stream()
.filter(group -> StrUtil.isNotBlank(mapBsctmoBColumn(group.getField()))).toList();
if (validGroups.isEmpty()) return baseSql;
List<String> groupFields = validGroups.stream().map(DataSourceRequest.GroupDescriptor::getField).toList();
StringBuilder sql = new StringBuilder("SELECT ");
for (int i = 0; i < groupFields.size(); i++) {
if (i > 0) sql.append(", ");
sql.append("t.").append(groupFields.get(i)).append(" AS ").append(groupFields.get(i));
}
sql.append(", COUNT(1) AS \"aggregates.count\" FROM (").append(baseSql).append(") t GROUP BY ");
for (int i = 0; i < groupFields.size(); i++) {
if (i > 0) sql.append(", ");
sql.append("t.").append(groupFields.get(i));
}
return sql.toString();
}
private String mapBsctmoBColumn(String field) {
return switch (field) {
case "id" -> "t.id";
case "stcd" -> "t.stcd";
case "fpnum" -> "t.fpnum";
case "fpName" -> "t.fpName";
case "ftp" -> "t.ftp";
case "ftpName" -> "t.ftpName";
case "value" -> "t.value";
case "length" -> "t.length";
case "weight" -> "t.weight";
case "ctmo" -> "t.ctmo";
case "ctmoName" -> "t.ctmoName";
case "skds" -> "t.skds";
case "fwgh" -> "t.fwgh";
case "recorder" -> "t.recorder";
case "recordUser" -> "t.recordUser";
case "recordTime" -> "t.recordTime";
case "modifyUser" -> "t.modifyUser";
case "modifyTime" -> "t.modifyTime";
case "isDeleted" -> "t.isDeleted";
case "deleteUser" -> "t.deleteUser";
case "deleteTime" -> "t.deleteTime";
default -> "";
};
}
private List<Object> normalizeBsctmoBValues(Object value) {
List<Object> values = new ArrayList<>();
if (value == null) return values;
if (value instanceof Collection<?> collection) { values.addAll(collection); return values; }
if (value instanceof Object[] array) { values.addAll(Arrays.asList(array)); return values; }
String text = String.valueOf(value).trim();
if (text.startsWith("[") && text.endsWith("]")) text = text.substring(1, text.length() - 1);
if (text.contains(",")) {
for (String item : text.split(",")) {
String trimmed = StrUtil.trim(item);
if (StrUtil.isNotBlank(trimmed)) values.add(trimmed);
}
return values;
}
values.add(value);
return values;
}
private Object normalizeBsctmoBValue(String field, Object value) {
if (value == null) return null;
if (Set.of("recordTime", "modifyTime", "deleteTime").contains(field) && value instanceof String text) {
return parseDateTimeSafely(text);
}
return value;
}
}