feat: 鱼类调查装置详情数据&获取鱼种类信息
This commit is contained in:
parent
725384f093
commit
51f5e9959b
@ -1,8 +1,10 @@
|
||||
package com.yfd.platform.qgc_env.fpr.controller;
|
||||
|
||||
import com.yfd.platform.common.DataSourceRequest;
|
||||
import com.yfd.platform.common.DataSourceResult;
|
||||
import com.yfd.platform.config.ResponseResult;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.ao.FprdRunDataAo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprdDetailVo;
|
||||
import com.yfd.platform.qgc_eng.eq.service.EngEqDataService;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprFtpChangeInfoVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprdRunDataInfoVo;
|
||||
@ -64,6 +66,20 @@ public class FprMonitorController {
|
||||
return ResponseResult.successData(result);
|
||||
}
|
||||
|
||||
@PostMapping("/sdFprdR/GetKendoListCust")
|
||||
@Operation(summary = "鱼类调查装置详情数据")
|
||||
public ResponseResult getFprdDetailList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<FprdDetailVo> result = fprMonitorService.getFprdDetailList(dataSourceRequest);
|
||||
return ResponseResult.successData(result);
|
||||
}
|
||||
|
||||
@PostMapping("/sdFprdR/getFishInfo")
|
||||
@Operation(summary = "获取鱼种类信息")
|
||||
public ResponseResult getFishInfo() {
|
||||
List<String> result = fprMonitorService.getFishInfo();
|
||||
return ResponseResult.successData(result);
|
||||
}
|
||||
|
||||
@PostMapping("/wbsb/GetKendoList")
|
||||
@Operation(summary = "查询基地/基地流域树数据")
|
||||
public ResponseResult getWbsbList(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.yfd.platform.qgc_env.fpr.entity.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Schema(description = "鱼类调查装置详情数据")
|
||||
public class FprdDetailVo {
|
||||
|
||||
@Schema(description = "调查鱼类装置编码")
|
||||
private String stcd;
|
||||
|
||||
@Schema(description = "调查鱼类装置名称")
|
||||
private String stnm;
|
||||
|
||||
@Schema(description = "监测时间")
|
||||
private Date tm;
|
||||
|
||||
@Schema(description = "监测视频文件ID")
|
||||
private String fid;
|
||||
|
||||
@Schema(description = "鱼类名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "鱼类数量")
|
||||
private Long num;
|
||||
|
||||
@Schema(description = "鱼尺寸")
|
||||
private BigDecimal fsz;
|
||||
|
||||
@Schema(description = "鱼重量")
|
||||
private BigDecimal weight;
|
||||
}
|
||||
@ -6,6 +6,7 @@ import com.yfd.platform.qgc_env.fpr.entity.vo.FprFtpChangeInfoVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.ao.FprdRunDataAo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprFishDicVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprMsstbprptVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprdDetailVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprdRunDataInfoVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprZyFishDicVo;
|
||||
|
||||
@ -22,4 +23,8 @@ public interface FprMonitorService {
|
||||
FprdRunDataInfoVo getFprdRunDataInfo(FprdRunDataAo ao);
|
||||
|
||||
List<FprFtpChangeInfoVo> getFtpChangeInfo(FprdRunDataAo ao);
|
||||
|
||||
DataSourceResult<FprdDetailVo> getFprdDetailList(DataSourceRequest dataSourceRequest);
|
||||
|
||||
List<String> getFishInfo();
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.yfd.platform.qgc_env.fpr.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.yfd.platform.common.DataSourceLoadOptionsBase;
|
||||
@ -16,6 +17,7 @@ import com.yfd.platform.qgc_env.fpr.entity.ao.FprdRunDataAo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprFishDicVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprFtpChangeInfoVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprMsstbprptVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprdDetailVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprdRunDataInfoVo;
|
||||
import com.yfd.platform.qgc_env.fpr.entity.vo.FprZyFishDicVo;
|
||||
import com.yfd.platform.qgc_env.fpr.service.FprMonitorService;
|
||||
@ -25,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -76,6 +79,53 @@ public class FprMonitorServiceImpl implements FprMonitorService {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<FprdDetailVo> getFprdDetailList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
String filterSql = buildFprdDetailFilterCondition(
|
||||
dataSourceRequest == null ? null : dataSourceRequest.getFilter(),
|
||||
paramMap,
|
||||
new int[]{0}
|
||||
);
|
||||
|
||||
StringBuilder sql = new StringBuilder("SELECT ")
|
||||
.append(buildFprdDetailSelectSql(dataSourceRequest == null ? null : dataSourceRequest.getSelect()))
|
||||
.append(" FROM (")
|
||||
.append(buildFprdDetailBaseSql())
|
||||
.append(") t WHERE 1 = 1 ");
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql).append(" ");
|
||||
}
|
||||
sql.append(buildFprdDetailOrderBySql(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||
|
||||
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<FprdDetailVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page, sql.toString(), paramMap, FprdDetailVo.class
|
||||
);
|
||||
|
||||
DataSourceResult<FprdDetailVo> result = new DataSourceResult<>();
|
||||
result.setData(list);
|
||||
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||
result.setAggregates(new HashMap<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFishInfo() {
|
||||
List<Map<String, Object>> rows = microservicDynamicSQLMapper.getAllList(
|
||||
"SELECT DISTINCT NAME AS name FROM SD_FPRDFISH_R " +
|
||||
"WHERE NVL(IS_DELETED, 0) = 0 AND NAME IS NOT NULL " +
|
||||
"ORDER BY NAME",
|
||||
null
|
||||
);
|
||||
return rows.stream()
|
||||
.map(row -> row.get("NAME"))
|
||||
.filter(java.util.Objects::nonNull)
|
||||
.map(String::valueOf)
|
||||
.toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<FprMsstbprptVo> getMsstbprptList(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
@ -430,6 +480,171 @@ public class FprMonitorServiceImpl implements FprMonitorService {
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
private String buildFprdDetailBaseSql() {
|
||||
return "SELECT " +
|
||||
"run.STCD AS stcd, " +
|
||||
"base.STNM AS stnm, " +
|
||||
"run.TM AS tm, " +
|
||||
"run.FLPTH AS fid, " +
|
||||
"fish.NAME AS name, " +
|
||||
"fish.NUM AS num, " +
|
||||
"fish.FSZ AS fsz, " +
|
||||
"fish.WEIGHT AS weight " +
|
||||
"FROM SD_FPRD_R run " +
|
||||
"INNER JOIN SD_FPRD_B_H base ON run.STCD = base.STCD " +
|
||||
" AND base.STTP = 'FPRD' " +
|
||||
" AND NVL(base.IS_DELETED, 0) = 0 " +
|
||||
"INNER JOIN SD_FPRDFISH_R fish ON run.ID = fish.FPRDR_ID " +
|
||||
" AND NVL(fish.IS_DELETED, 0) = 0 " +
|
||||
"WHERE NVL(run.IS_DELETED, 0) = 0 ";
|
||||
}
|
||||
|
||||
private String buildFprdDetailSelectSql(List<String> selectFields) {
|
||||
LinkedHashMap<String, String> columnMap = new LinkedHashMap<>();
|
||||
columnMap.put("stcd", "t.stcd AS stcd");
|
||||
columnMap.put("stnm", "t.stnm AS stnm");
|
||||
columnMap.put("tm", "t.tm AS tm");
|
||||
columnMap.put("fid", "t.fid AS fid");
|
||||
columnMap.put("name", "t.name AS name");
|
||||
columnMap.put("num", "t.num AS num");
|
||||
columnMap.put("fsz", "t.fsz AS fsz");
|
||||
columnMap.put("weight", "t.weight AS weight");
|
||||
if (CollUtil.isEmpty(selectFields)) {
|
||||
return String.join(", ", columnMap.values());
|
||||
}
|
||||
List<String> columns = new ArrayList<>();
|
||||
for (String field : selectFields) {
|
||||
String column = columnMap.get(field);
|
||||
if (StrUtil.isNotBlank(column)) {
|
||||
columns.add(column);
|
||||
}
|
||||
}
|
||||
return columns.isEmpty() ? String.join(", ", columnMap.values()) : String.join(", ", columns);
|
||||
}
|
||||
|
||||
private String buildFprdDetailFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isNotBlank(filter.getField())) {
|
||||
return buildFprdDetailLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||
return "";
|
||||
}
|
||||
List<String> conditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String childSql = buildFprdDetailFilterCondition(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 buildFprdDetailLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String field = filter.getField();
|
||||
Object value = filter.getValue();
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
String key = "fprdDetailP" + indexHolder[0]++;
|
||||
return switch (field) {
|
||||
case "stcd" -> {
|
||||
paramMap.put(key, String.valueOf(value));
|
||||
yield "t.stcd = #{map." + key + "}";
|
||||
}
|
||||
case "name" -> {
|
||||
paramMap.put(key, "%" + value + "%");
|
||||
yield "t.name LIKE #{map." + key + "}";
|
||||
}
|
||||
case "startTime" -> {
|
||||
Date date = parseFprdDate(value);
|
||||
if (date == null) {
|
||||
yield "";
|
||||
}
|
||||
paramMap.put(key, date);
|
||||
yield "t.tm >= #{map." + key + "}";
|
||||
}
|
||||
case "endTime" -> {
|
||||
Date date = parseFprdDate(value);
|
||||
if (date == null) {
|
||||
yield "";
|
||||
}
|
||||
paramMap.put(key, date);
|
||||
yield "t.tm <= #{map." + key + "}";
|
||||
}
|
||||
case "tm" -> {
|
||||
Date date = parseFprdDate(value);
|
||||
if (date == null) {
|
||||
yield "";
|
||||
}
|
||||
paramMap.put(key, date);
|
||||
String operator = StrUtil.blankToDefault(filter.getOperator(), "eq").toLowerCase();
|
||||
yield switch (operator) {
|
||||
case "gte" -> "t.tm >= #{map." + key + "}";
|
||||
case "lte" -> "t.tm <= #{map." + key + "}";
|
||||
case "gt" -> "t.tm > #{map." + key + "}";
|
||||
case "lt" -> "t.tm < #{map." + key + "}";
|
||||
default -> "t.tm = #{map." + key + "}";
|
||||
};
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
private String buildFprdDetailOrderBySql(List<DataSourceRequest.SortDescriptor> sorts) {
|
||||
if (CollUtil.isEmpty(sorts)) {
|
||||
return " ORDER BY t.tm DESC";
|
||||
}
|
||||
List<String> orderParts = new ArrayList<>();
|
||||
for (DataSourceRequest.SortDescriptor sort : sorts) {
|
||||
String column = switch (sort.getField()) {
|
||||
case "stcd" -> "t.stcd";
|
||||
case "stnm" -> "t.stnm";
|
||||
case "tm" -> "t.tm";
|
||||
case "name" -> "t.name";
|
||||
case "num" -> "t.num";
|
||||
case "fsz" -> "t.fsz";
|
||||
case "weight" -> "t.weight";
|
||||
default -> "";
|
||||
};
|
||||
if (StrUtil.isBlank(column)) {
|
||||
continue;
|
||||
}
|
||||
orderParts.add(column + ("desc".equalsIgnoreCase(sort.getDir()) ? " DESC" : " ASC"));
|
||||
}
|
||||
return orderParts.isEmpty() ? " ORDER BY t.tm DESC" : " ORDER BY " + String.join(", ", orderParts);
|
||||
}
|
||||
|
||||
private Date parseFprdDate(Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (value instanceof Date date) {
|
||||
return date;
|
||||
}
|
||||
String text = String.valueOf(value);
|
||||
if (StrUtil.isBlank(text)) {
|
||||
return null;
|
||||
}
|
||||
if (text.length() == 10) {
|
||||
return DateUtil.parse(text, "yyyy-MM-dd");
|
||||
}
|
||||
if (text.length() == 16) {
|
||||
return DateUtil.parse(text, "yyyy-MM-dd HH:mm");
|
||||
}
|
||||
return DateUtil.parse(text, "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
|
||||
private void validateFprdRunDataAo(FprdRunDataAo ao) {
|
||||
if (ao == null) {
|
||||
throw new BizException("请求参数不能为空.");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user