feat: 亲鱼档案管理记录列表
This commit is contained in:
parent
9137742fdd
commit
916ff18be4
@ -65,6 +65,12 @@ public class FbStationController {
|
||||
return ResponseResult.successData(fbStationService.getYearRpStatistics(year));
|
||||
}
|
||||
|
||||
@PostMapping("/bsmfr/GetKendoListCust")
|
||||
@Operation(summary = "亲鱼档案管理记录列表")
|
||||
public ResponseResult getBsmfRKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(fbStationService.getBsmfRList(dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/bsmfr/qgc/GetKendoListCust")
|
||||
@Operation(summary = "(全过程)增殖站二级页面: 亲鱼选配与培育->亲鱼信息")
|
||||
public ResponseResult getBsmfrQgcKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
|
||||
@ -0,0 +1,82 @@
|
||||
package com.yfd.platform.qgc_env.fb.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 亲鱼档案管理记录 VO
|
||||
*/
|
||||
@Data
|
||||
public class FbBsmfRVo {
|
||||
|
||||
/** 主键 */
|
||||
private String id;
|
||||
|
||||
/** 设施编码 */
|
||||
private String stcd;
|
||||
|
||||
/** 引进日期 */
|
||||
private Date tm;
|
||||
|
||||
/** 鱼种类 */
|
||||
private String ftp;
|
||||
|
||||
/** 鱼类名称 */
|
||||
private String ftpName;
|
||||
|
||||
/** 亲鱼来源 */
|
||||
private String bssr;
|
||||
|
||||
/** 亲鱼来源名称 */
|
||||
private String bssrName;
|
||||
|
||||
/** 全长(cm) */
|
||||
private BigDecimal length;
|
||||
|
||||
/** 体重(g) */
|
||||
private BigDecimal weight;
|
||||
|
||||
/** 鱼龄 */
|
||||
private BigDecimal age;
|
||||
|
||||
/** 性别:1=雄鱼 2=雌鱼 */
|
||||
private Integer sex;
|
||||
|
||||
/** 性别名称 */
|
||||
private String sexName;
|
||||
|
||||
/** 标记编号 */
|
||||
private String signnum;
|
||||
|
||||
/** 记录人 */
|
||||
private String recorder;
|
||||
|
||||
/** 数量 */
|
||||
private Long value;
|
||||
|
||||
/** 附件ID */
|
||||
private String fid;
|
||||
|
||||
/** 创建人 */
|
||||
private String recordUser;
|
||||
|
||||
/** 创建时间 */
|
||||
private Date recordTime;
|
||||
|
||||
/** 更新人 */
|
||||
private String modifyUser;
|
||||
|
||||
/** 更新时间 */
|
||||
private Date modifyTime;
|
||||
|
||||
/** 是否已删除 */
|
||||
private Integer isDeleted;
|
||||
|
||||
/** 删除人 */
|
||||
private String deleteUser;
|
||||
|
||||
/** 删除时间 */
|
||||
private Date deleteTime;
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.yfd.platform.qgc_env.fb.service;
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
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.FbBsmfRQgcVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishTableVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbEngFishVo;
|
||||
@ -84,4 +85,9 @@ public interface FbStationService {
|
||||
* 获取增殖站各阶段数据状态(选配/繁殖/培育/防治)
|
||||
*/
|
||||
List<BreedStageVO> getBreedStageList(String stcd);
|
||||
|
||||
/**
|
||||
* 亲鱼档案管理记录列表
|
||||
*/
|
||||
DataSourceResult<FbBsmfRVo> getBsmfRList(DataSourceRequest dataSourceRequest);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import com.yfd.platform.common.GroupHelper;
|
||||
import com.yfd.platform.common.GroupingInfo;
|
||||
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.FbBsmfRQgcVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishHeadColumnVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbBsmfRFishSummaryVo;
|
||||
@ -5110,4 +5111,355 @@ public class FbStationServiceImpl implements FbStationService {
|
||||
this.fcnt = fcnt;
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 亲鱼档案管理记录列表 ====================
|
||||
|
||||
@Override
|
||||
public DataSourceResult<FbBsmfRVo> getBsmfRList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
GroupingInfo[] groups = loadOptions == null ? null : loadOptions.getGroup();
|
||||
if (groups != null && groups.length > 0) {
|
||||
return queryBsmfRGroupList(dataSourceRequest, loadOptions, groups);
|
||||
}
|
||||
return queryBsmfRDetailList(dataSourceRequest, loadOptions);
|
||||
}
|
||||
|
||||
private DataSourceResult<FbBsmfRVo> queryBsmfRDetailList(DataSourceRequest dataSourceRequest,
|
||||
DataSourceLoadOptionsBase loadOptions) {
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ")
|
||||
.append(buildBsmfRDetailSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
|
||||
.append(" FROM (")
|
||||
.append(buildBsmfRCoreSql())
|
||||
.append(") t WHERE 1 = 1 ");
|
||||
|
||||
String filterSql = buildBsmfRFilterCondition(
|
||||
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||
paramMap,
|
||||
new int[]{0}
|
||||
);
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql).append(" ");
|
||||
}
|
||||
sql.append(buildBsmfROrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||
|
||||
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<FbBsmfRVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page, sql.toString(), paramMap, FbBsmfRVo.class
|
||||
);
|
||||
DataSourceResult<FbBsmfRVo> 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<FbBsmfRVo> queryBsmfRGroupList(DataSourceRequest dataSourceRequest,
|
||||
DataSourceLoadOptionsBase loadOptions,
|
||||
GroupingInfo[] groupInfos) {
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT * FROM (")
|
||||
.append(buildBsmfRCoreSql())
|
||||
.append(") t WHERE 1 = 1 ");
|
||||
|
||||
String filterSql = buildBsmfRFilterCondition(
|
||||
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||
paramMap,
|
||||
new int[]{0}
|
||||
);
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql).append(" ");
|
||||
}
|
||||
String groupedSql = buildBsmfRGroupSql(sql.toString(),
|
||||
dataSourceRequest == null ? null : dataSourceRequest.getGroup());
|
||||
List<Map<String, Object>> rows= microservicDynamicSQLMapper.pageAllList(
|
||||
null, groupedSql, paramMap
|
||||
);
|
||||
|
||||
DataSourceResult<FbBsmfRVo> result = new DataSourceResult<>();
|
||||
if (Boolean.TRUE.equals(dataSourceRequest == null ? false : dataSourceRequest.getGroupResultFlat())) {
|
||||
result.setData((List<FbBsmfRVo>) (List<?>) new GroupHelper().faltGroup(
|
||||
rows,
|
||||
groupInfos == null ? Collections.emptyList() : Arrays.asList(groupInfos)
|
||||
));
|
||||
} else {
|
||||
result.setData((List<FbBsmfRVo>) (List<?>) new GroupHelper().group(
|
||||
rows,
|
||||
groupInfos == null ? Collections.emptyList() : Arrays.asList(groupInfos)
|
||||
));
|
||||
}
|
||||
result.setTotal(rows.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
private String buildBsmfRCoreSql() {
|
||||
return "SELECT rec.ID AS id, "
|
||||
+ "rec.STCD AS stcd, "
|
||||
+ "rec.TM AS tm, "
|
||||
+ "rec.FTP AS ftp, "
|
||||
+ "CAST(NULL AS VARCHAR2(255)) AS ftpName, "
|
||||
+ "rec.BSSR AS bssr, "
|
||||
+ "rec.BSSR AS bssrName, "
|
||||
+ "rec.LENGTH AS length, "
|
||||
+ "rec.WEIGHT AS weight, "
|
||||
+ "rec.AGE AS age, "
|
||||
+ "rec.SEX AS sex, "
|
||||
+ "CASE WHEN rec.SEX = 1 THEN '雄鱼' WHEN rec.SEX = 2 THEN '雌鱼' ELSE NULL END AS sexName, "
|
||||
+ "rec.SIGNNUM AS signnum, "
|
||||
+ "rec.RECORDER AS recorder, "
|
||||
+ "rec.VALUE AS value, "
|
||||
+ "rec.FID AS fid, "
|
||||
+ "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_FBBSMF_R rec "
|
||||
+ "WHERE NVL(rec.IS_DELETED, 0) = 0";
|
||||
}
|
||||
|
||||
private String buildBsmfRDetailSelectSql(List<String> select) {
|
||||
List<String> fields = CollUtil.isEmpty(select)
|
||||
? List.of("id", "stcd", "tm", "ftp", "ftpName", "bssr", "bssrName", "length", "weight", "age",
|
||||
"sex", "sexName", "signnum", "recorder", "value", "fid", "recordUser", "recordTime",
|
||||
"modifyUser", "modifyTime", "isDeleted", "deleteUser", "deleteTime")
|
||||
: select;
|
||||
List<String> selectParts = new ArrayList<>();
|
||||
for (String field : fields) {
|
||||
String column = mapBsmfRColumn(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 buildBsmfRFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isNotBlank(filter.getField())) {
|
||||
return buildBsmfRLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||
return "";
|
||||
}
|
||||
List<String> conditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String childSql = buildBsmfRFilterCondition(child, paramMap, indexHolder);
|
||||
if (StrUtil.isNotBlank(childSql)) {
|
||||
conditions.add("(" + childSql + ")");
|
||||
}
|
||||
}
|
||||
if (conditions.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
String logic = "or".equalsIgnoreCase(filter.getLogic()) ? " OR " : " AND ";
|
||||
return String.join(logic, conditions);
|
||||
}
|
||||
|
||||
private String buildBsmfRLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String column = mapBsmfRColumn(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 = normalizeBsmfRValues(value);
|
||||
if (values.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
for (Object item : values) {
|
||||
String key = "bsmfP" + indexHolder[0]++;
|
||||
paramMap.put(key, normalizeBsmfRValue(filter.getField(), item));
|
||||
placeholders.add("#{map." + key + "}");
|
||||
}
|
||||
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||
}
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
String key = "bsmfP" + indexHolder[0]++;
|
||||
Object normalizedValue = normalizeBsmfRValue(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 buildBsmfROrderBySql(List<DataSourceRequest.SortDescriptor> sortDescriptors) {
|
||||
if (CollUtil.isEmpty(sortDescriptors)) {
|
||||
return " ORDER BY t.tm DESC, t.recordTime DESC";
|
||||
}
|
||||
List<String> parts = new ArrayList<>();
|
||||
for (DataSourceRequest.SortDescriptor descriptor : sortDescriptors) {
|
||||
String column = mapBsmfRColumn(descriptor.getField());
|
||||
if (StrUtil.isBlank(column)) {
|
||||
continue;
|
||||
}
|
||||
String direction = "desc".equalsIgnoreCase(descriptor.getDir()) ? "DESC" : "ASC";
|
||||
parts.add(column + " " + direction);
|
||||
}
|
||||
if (parts.isEmpty()) {
|
||||
return " ORDER BY t.tm DESC, t.recordTime DESC";
|
||||
}
|
||||
return " ORDER BY " + String.join(", ", parts);
|
||||
}
|
||||
|
||||
private String buildBsmfRGroupSql(String baseSql, List<DataSourceRequest.GroupDescriptor> groups) {
|
||||
if (CollUtil.isEmpty(groups)) {
|
||||
return baseSql;
|
||||
}
|
||||
List<DataSourceRequest.GroupDescriptor> validGroups = groups.stream()
|
||||
.filter(group -> StrUtil.isNotBlank(mapBsmfRColumn(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(", ");
|
||||
String field = groupFields.get(i);
|
||||
sql.append("t.").append(field).append(" AS ").append(field);
|
||||
}
|
||||
sql.append(", COUNT(1) AS \"aggregates.count\" FROM (").append(baseSql).append(") t ");
|
||||
sql.append("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 mapBsmfRColumn(String field) {
|
||||
return switch (field) {
|
||||
case "id" -> "t.id";
|
||||
case "stcd" -> "t.stcd";
|
||||
case "tm" -> "t.tm";
|
||||
case "ftp" -> "t.ftp";
|
||||
case "ftpName" -> "t.ftpName";
|
||||
case "bssr" -> "t.bssr";
|
||||
case "bssrName" -> "t.bssrName";
|
||||
case "length" -> "t.length";
|
||||
case "weight" -> "t.weight";
|
||||
case "age" -> "t.age";
|
||||
case "sex" -> "t.sex";
|
||||
case "sexName" -> "t.sexName";
|
||||
case "signnum" -> "t.signnum";
|
||||
case "recorder" -> "t.recorder";
|
||||
case "value" -> "t.value";
|
||||
case "fid" -> "t.fid";
|
||||
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> normalizeBsmfRValues(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 normalizeBsmfRValue(String field, Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (Set.of("tm", "recordTime", "modifyTime", "deleteTime").contains(field) && value instanceof String text) {
|
||||
return parseDateTimeSafely(text);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user