feat: (全过程)增殖站二级页面: 过程图-鱼苗
This commit is contained in:
parent
159f24eaf7
commit
d964cf6d20
@ -140,4 +140,10 @@ public class FbStationController {
|
||||
@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(fbStationService.getFishhatchrecrFishKendoListCust(type, dataSourceRequest));
|
||||
}
|
||||
|
||||
@PostMapping("/fishbreedr/fish/GetKendoListCust")
|
||||
@Operation(summary = "(全过程)增殖站二级页面: 过程图-鱼苗")
|
||||
public ResponseResult getFishbreedrFishKendoListCust(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||
return ResponseResult.successData(fbStationService.getFishbreedrFishKendoListCust(dataSourceRequest));
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package com.yfd.platform.qgc_env.fb.entity.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FishbreedRVo {
|
||||
|
||||
private String tm;
|
||||
|
||||
private String ftp;
|
||||
|
||||
private String ftpName;
|
||||
|
||||
private String counts;
|
||||
}
|
||||
@ -60,4 +60,6 @@ public interface FbStationService {
|
||||
DataSourceResult<FbStationOverviewSecondVo> getQgcOverviewSecond(DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<TableVo> getFishhatchrecrFishKendoListCust(Integer type, DataSourceRequest dataSourceRequest);
|
||||
|
||||
DataSourceResult<TableVo> getFishbreedrFishKendoListCust(DataSourceRequest dataSourceRequest);
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import com.yfd.platform.qgc_env.fb.entity.vo.FbStInfoResultVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationOverviewSecondVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsDataVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FbStationStaticsRawVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FishbreedRVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.FishhatchrecRVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.HeadColunmsVo;
|
||||
import com.yfd.platform.qgc_env.fb.entity.vo.TableVo;
|
||||
@ -4336,4 +4337,239 @@ public class FbStationServiceImpl implements FbStationService {
|
||||
tableVo.setTotal(total);
|
||||
return tableVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSourceResult<TableVo> getFishbreedrFishKendoListCust(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceResult<TableVo> dataSourceResult = new DataSourceResult<>();
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT tm,\n")
|
||||
.append("LISTAGG(TO_CHAR(ftp), ',') WITHIN GROUP (ORDER BY ftp) AS ftp,\n")
|
||||
.append("LISTAGG(TO_CHAR(NAME), ',') WITHIN GROUP (ORDER BY ftp) AS ftpName,\n")
|
||||
.append("LISTAGG(counts, ',') WITHIN GROUP (ORDER BY ftp) AS counts\n")
|
||||
.append("FROM (\n")
|
||||
.append("SELECT \n")
|
||||
.append("to_CHAR(tm,'YYYY-MM') AS tm, ftp, CASE WHEN NAME IS NULL THEN TO_NCHAR(ftp) ELSE NAME END AS NAME, CASE WHEN SUM(counts) IS NULL THEN '-' ELSE TO_CHAR(SUM(counts)) END AS counts\n")
|
||||
.append("FROM (\n")
|
||||
.append("SELECT\n")
|
||||
.append("\ttm,\n")
|
||||
.append("\tCASE WHEN ZY_FISH_ID IS NULL THEN ftp ELSE ZY_FISH_ID END AS ftp,\n")
|
||||
.append("\tCASE WHEN NAME IS NULL THEN TO_NCHAR(ftp) ELSE NAME END AS NAME,\n")
|
||||
.append("\tcounts\n")
|
||||
.append("FROM\n")
|
||||
.append("\t(\n")
|
||||
.append("\tSELECT\n")
|
||||
.append("\t\tstcd,\n")
|
||||
.append("\t\tftp AS ftp,\n")
|
||||
.append("\t\tcounts AS counts,\n")
|
||||
.append("\t\ttm AS tm\n")
|
||||
.append("\tFROM\n")
|
||||
.append("\t\tSD_FBFISHBREED_R\n")
|
||||
.append("\tWHERE\n")
|
||||
.append("\t\tNVL(is_deleted, 0) = 0 ");
|
||||
|
||||
appendFishbreedrFishFilterConditions(sql, dataSourceRequest, paramMap);
|
||||
|
||||
sql.append(") t\n")
|
||||
.append("LEFT JOIN SD_FBRD_B_H s ON\n")
|
||||
.append("\tt.stcd = s.STCD\n")
|
||||
.append("LEFT JOIN V_SD_FISHDICTORY_B f ON\n")
|
||||
.append("\tt.FTP = f.FISH_ID\n")
|
||||
.append("\tAND (s.HBRVCD = f.RVCD\n")
|
||||
.append("\t\tOR f.RVCD = 'ZY')\n")
|
||||
.append(") GROUP BY to_CHAR(tm,'YYYY-MM'), ftp, NAME\n")
|
||||
.append(") GROUP BY tm\n")
|
||||
.append("ORDER BY TM DESC");
|
||||
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest == null ? null : dataSourceRequest.toDevRequest();
|
||||
Page<?> page = loadOptions == null ? null : QgcQueryWrapperUtil.buildPage(loadOptions, loadOptions.getSkip(), loadOptions.getTake());
|
||||
List<FishbreedRVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||
page, sql.toString(), paramMap, FishbreedRVo.class
|
||||
);
|
||||
|
||||
long total = page != null ? page.getTotal() : list.size();
|
||||
TableVo tableVo = buildFishbreedrFishTableVo(list, total);
|
||||
dataSourceResult.setData(Collections.singletonList(tableVo));
|
||||
dataSourceResult.setTotal(total);
|
||||
dataSourceResult.setAggregates(new HashMap<>());
|
||||
return dataSourceResult;
|
||||
}
|
||||
|
||||
private void appendFishbreedrFishFilterConditions(StringBuilder sql,
|
||||
DataSourceRequest dataSourceRequest,
|
||||
Map<String, Object> paramMap) {
|
||||
if (dataSourceRequest == null || dataSourceRequest.getFilter() == null) {
|
||||
return;
|
||||
}
|
||||
String filterSql = buildFishbreedrFishFilterCondition(dataSourceRequest.getFilter(), paramMap, new int[]{0});
|
||||
if (StrUtil.isNotBlank(filterSql)) {
|
||||
sql.append(" AND ").append(filterSql).append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private String buildFishbreedrFishFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
if (filter == null) {
|
||||
return "";
|
||||
}
|
||||
if (StrUtil.isNotBlank(filter.getField())) {
|
||||
return buildFishbreedrFishLeafCondition(filter, paramMap, indexHolder);
|
||||
}
|
||||
if (CollUtil.isEmpty(filter.getFilters())) {
|
||||
return "";
|
||||
}
|
||||
List<String> conditions = new ArrayList<>();
|
||||
for (DataSourceRequest.FilterDescriptor child : filter.getFilters()) {
|
||||
String childSql = buildFishbreedrFishFilterCondition(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 buildFishbreedrFishLeafCondition(DataSourceRequest.FilterDescriptor filter,
|
||||
Map<String, Object> paramMap,
|
||||
int[] indexHolder) {
|
||||
String field = filter.getField();
|
||||
String column = mapFishbreedrFishColumn(field);
|
||||
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 = normalizeQgcBsmfRValues(value);
|
||||
if (values.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
List<String> placeholders = new ArrayList<>();
|
||||
for (Object item : values) {
|
||||
String key = "breedFishP" + indexHolder[0]++;
|
||||
paramMap.put(key, item);
|
||||
placeholders.add("#{map." + key + "}");
|
||||
}
|
||||
return column + " IN (" + String.join(", ", placeholders) + ")";
|
||||
}
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
String key = "breedFishP" + indexHolder[0]++;
|
||||
Object normalizedValue = normalizeFishbreedrFishValue(field, 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 "contains" -> {
|
||||
paramMap.put(key, "%" + normalizedValue + "%");
|
||||
yield column + " 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 + "}";
|
||||
}
|
||||
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 + "}";
|
||||
}
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
private String mapFishbreedrFishColumn(String field) {
|
||||
return switch (field) {
|
||||
case "stcd" -> "t.STCD";
|
||||
case "ftp" -> "t.FTP";
|
||||
case "counts" -> "t.COUNTS";
|
||||
case "tm" -> "t.TM";
|
||||
case "rstcd" -> "s.RSTCD";
|
||||
case "baseId" -> "s.BASE_ID";
|
||||
case "hbrvcd" -> "s.HBRVCD";
|
||||
default -> "";
|
||||
};
|
||||
}
|
||||
|
||||
private Object normalizeFishbreedrFishValue(String field, Object value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if ("tm".equalsIgnoreCase(field) && value instanceof String text) {
|
||||
return parseDateTimeSafely(text);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private TableVo buildFishbreedrFishTableVo(List<FishbreedRVo> list, long total) {
|
||||
TableVo tableVo = new TableVo();
|
||||
List<Map<String, Object>> resultData = new ArrayList<>();
|
||||
List<HeadColunmsVo> columns = new ArrayList<>();
|
||||
Map<String, String> fishMap = new LinkedHashMap<>();
|
||||
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
for (FishbreedRVo vo : list) {
|
||||
Map<String, Object> rowMap = new LinkedHashMap<>();
|
||||
rowMap.put("tm", vo.getTm());
|
||||
|
||||
List<String> ftpList = splitCsv(vo.getFtp());
|
||||
List<String> ftpNameList = splitCsv(vo.getFtpName());
|
||||
List<String> countsList = splitCsv(vo.getCounts());
|
||||
|
||||
int size = Math.min(ftpList.size(), Math.min(ftpNameList.size(), countsList.size()));
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
String ftp = ftpList.get(i);
|
||||
String ftpName = ftpNameList.get(i);
|
||||
String countStr = countsList.get(i);
|
||||
rowMap.put(ftp, "-".equals(countStr) ? null : countStr);
|
||||
fishMap.putIfAbsent(ftp, ftpName);
|
||||
}
|
||||
resultData.add(rowMap);
|
||||
}
|
||||
}
|
||||
|
||||
columns.add(new HeadColunmsVo("tm", "时间", true, "tm", false, new ArrayList<>())
|
||||
.setDataType("date")
|
||||
.setDataFormat("yyyy-MM"));
|
||||
for (Map.Entry<String, String> entry : fishMap.entrySet()) {
|
||||
columns.add(new HeadColunmsVo(entry.getKey(), entry.getValue() + "(尾)", true, entry.getKey(), false, new ArrayList<>()));
|
||||
}
|
||||
|
||||
tableVo.setColumns(columns);
|
||||
tableVo.setDataSource(resultData);
|
||||
tableVo.setTotal(total);
|
||||
return tableVo;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user