feat: 珍稀植物园运行数据-弹窗
This commit is contained in:
parent
aaaa6ad735
commit
31295520a8
@ -40,4 +40,10 @@ public class VpConstructionController {
|
|||||||
public ResponseResult getStInfoByStcd(@RequestParam String stcd) {
|
public ResponseResult getStInfoByStcd(@RequestParam String stcd) {
|
||||||
return ResponseResult.successData(vpConstructionService.getStInfoByStcd(stcd));
|
return ResponseResult.successData(vpConstructionService.getStInfoByStcd(stcd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/vpr/basinVpIntDetail")
|
||||||
|
@Operation(summary = "珍稀植物园运行数据-弹窗")
|
||||||
|
public ResponseResult basinVpIntDetail(@RequestBody DataSourceRequest dataSourceRequest) {
|
||||||
|
return ResponseResult.successData(vpConstructionService.basinVpIntDetail(dataSourceRequest));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.yfd.platform.qgc_env.vap.service;
|
|||||||
|
|
||||||
import com.yfd.platform.common.DataSourceRequest;
|
import com.yfd.platform.common.DataSourceRequest;
|
||||||
import com.yfd.platform.common.DataSourceResult;
|
import com.yfd.platform.common.DataSourceResult;
|
||||||
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinIntDetailVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpStInfoResultVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpStInfoResultVo;
|
||||||
|
|
||||||
public interface VpConstructionService {
|
public interface VpConstructionService {
|
||||||
@ -11,4 +12,6 @@ public interface VpConstructionService {
|
|||||||
DataSourceResult processVmsstbprptList(DataSourceRequest dataSourceRequest);
|
DataSourceResult processVmsstbprptList(DataSourceRequest dataSourceRequest);
|
||||||
|
|
||||||
VpStInfoResultVo getStInfoByStcd(String stcd);
|
VpStInfoResultVo getStInfoByStcd(String stcd);
|
||||||
|
|
||||||
|
DataSourceResult<VpBasinIntDetailVo> basinVpIntDetail(DataSourceRequest dataSourceRequest);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import com.yfd.platform.common.GroupHelper;
|
|||||||
import com.yfd.platform.common.GroupingInfo;
|
import com.yfd.platform.common.GroupingInfo;
|
||||||
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
import com.yfd.platform.common.MicroservicDynamicSQLMapper;
|
||||||
import com.yfd.platform.common.PageInfo;
|
import com.yfd.platform.common.PageInfo;
|
||||||
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpBasinIntDetailVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpConstructionSituationVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpConstructionSituationVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpStBaseInfoVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpStBaseInfoVo;
|
||||||
import com.yfd.platform.qgc_env.vap.entity.vo.VpStInfoResultVo;
|
import com.yfd.platform.qgc_env.vap.entity.vo.VpStInfoResultVo;
|
||||||
@ -150,6 +151,26 @@ public class VpConstructionServiceImpl implements VpConstructionService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataSourceResult<VpBasinIntDetailVo> basinVpIntDetail(DataSourceRequest dataSourceRequest) {
|
||||||
|
DataSourceResult<VpBasinIntDetailVo> result = new DataSourceResult<>();
|
||||||
|
Page<?> page = KendoUtil.getPage(dataSourceRequest);
|
||||||
|
Map<String, Object> paramMap = new HashMap<>();
|
||||||
|
StringBuilder sql = new StringBuilder(buildBasinVpIntDetailSql(paramMap,
|
||||||
|
dataSourceRequest == null ? null : dataSourceRequest.getFilter()));
|
||||||
|
sql.append(buildBasinVpIntDetailOrderBy(dataSourceRequest == null ? null : dataSourceRequest.getSort()));
|
||||||
|
List<VpBasinIntDetailVo> list = microservicDynamicSQLMapper.pageAllListWithResultType(
|
||||||
|
page,
|
||||||
|
sql.toString(),
|
||||||
|
paramMap,
|
||||||
|
VpBasinIntDetailVo.class
|
||||||
|
);
|
||||||
|
result.setData(list);
|
||||||
|
result.setTotal(page != null ? page.getTotal() : list.size());
|
||||||
|
result.setAggregates(new HashMap<>());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private String buildBaseSql(boolean botanicalGarden, boolean nationwide) {
|
private String buildBaseSql(boolean botanicalGarden, boolean nationwide) {
|
||||||
String baseIdExpr = botanicalGarden
|
String baseIdExpr = botanicalGarden
|
||||||
? "CASE WHEN vp.BASE_ID IS NULL THEN 'null' ELSE vp.BASE_ID END"
|
? "CASE WHEN vp.BASE_ID IS NULL THEN 'null' ELSE vp.BASE_ID END"
|
||||||
@ -528,6 +549,118 @@ public class VpConstructionServiceImpl implements VpConstructionService {
|
|||||||
"WHERE NVL(vp.IS_DELETED, 0) = 0 AND vp.STCD = #{map.stcd}";
|
"WHERE NVL(vp.IS_DELETED, 0) = 0 AND vp.STCD = #{map.stcd}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String buildBasinVpIntDetailSql(Map<String, Object> paramMap, DataSourceRequest.FilterDescriptor descriptor) {
|
||||||
|
StringBuilder sql = new StringBuilder();
|
||||||
|
sql.append("SELECT * FROM (")
|
||||||
|
.append(" SELECT vp.STNM AS stnm, ")
|
||||||
|
.append(" vp.BASE_ID AS baseId, ")
|
||||||
|
.append(" hb.BASENAME AS baseName, ")
|
||||||
|
.append(" vp.STCD AS stcd, ")
|
||||||
|
.append(" r.TYPE AS type, ")
|
||||||
|
.append(" r.TEUNT AS unit, ")
|
||||||
|
.append(" basic.NAME AS tetp, ")
|
||||||
|
.append(" SUM(r.TECNT) AS tecnt, ")
|
||||||
|
.append(" SUM(r.SURNUM) AS surnum, ")
|
||||||
|
.append(" SUM(r.TRANSPLANT) AS transplant, ")
|
||||||
|
.append(" SUM(r.PLANTASK) AS plantask, ")
|
||||||
|
.append(" CASE WHEN r.TYPE = 3 THEN CEIL(SUM(r.SURNUM)) || '/' || SUM(r.TRANSPLANT) ELSE '-' END AS treeNum, ")
|
||||||
|
.append(" CASE WHEN r.TYPE <> 3 THEN CEIL(SUM(r.SURNUM)) || '/' || SUM(r.TRANSPLANT) ELSE '-' END AS fgNum, ")
|
||||||
|
.append(" CASE WHEN SUM(r.TRANSPLANT) != 0 ")
|
||||||
|
.append(" THEN TO_CHAR(ROUND(SUM(r.SURNUM) / SUM(r.TRANSPLANT) * 100, 2)) ")
|
||||||
|
.append(" ELSE '-' END AS rate, ")
|
||||||
|
.append(" TO_CHAR(r.TM, 'YYYY') AS tm, ")
|
||||||
|
.append(" r.FID AS fid ")
|
||||||
|
.append(" FROM SD_VP_R r ")
|
||||||
|
.append(" LEFT JOIN SD_VPBASIC_B basic ON basic.ID = r.PLANT_ID ")
|
||||||
|
.append(" AND NVL(basic.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" AND NVL(basic.ENABLE, 1) = 1 ")
|
||||||
|
.append(" LEFT JOIN SD_VP_B_H vp ON vp.STCD = r.STCD ")
|
||||||
|
.append(" AND NVL(vp.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" LEFT JOIN SD_HYDROBASE hb ON hb.BASEID = vp.BASE_ID ")
|
||||||
|
.append(" AND NVL(hb.IS_DELETED, 0) = 0 ")
|
||||||
|
.append(" WHERE NVL(r.IS_DELETED, 0) = 0 ");
|
||||||
|
|
||||||
|
appendBasinVpIntDetailFilters(sql, paramMap, descriptor);
|
||||||
|
|
||||||
|
sql.append(" GROUP BY vp.STCD, vp.BASE_ID, TO_CHAR(r.TM, 'YYYY'), vp.STNM, hb.BASENAME, basic.NAME, r.TYPE, r.TEUNT, r.FID ")
|
||||||
|
.append(") t WHERE 1 = 1");
|
||||||
|
return sql.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendBasinVpIntDetailFilters(StringBuilder sql,
|
||||||
|
Map<String, Object> paramMap,
|
||||||
|
DataSourceRequest.FilterDescriptor descriptor) {
|
||||||
|
if (descriptor == null || CollectionUtils.isEmpty(descriptor.getFilters())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<Object> stcdValues = new ArrayList<>();
|
||||||
|
String tm = null;
|
||||||
|
for (DataSourceRequest.FilterDescriptor filter : descriptor.getFilters()) {
|
||||||
|
if (filter == null || StrUtil.isBlank(filter.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ("stcd".equals(filter.getField())) {
|
||||||
|
stcdValues.addAll(normalizeValues(filter.getValue()));
|
||||||
|
}
|
||||||
|
if ("tm".equals(filter.getField()) && filter.getValue() != null) {
|
||||||
|
tm = String.valueOf(filter.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!stcdValues.isEmpty()) {
|
||||||
|
List<String> placeholders = new ArrayList<>();
|
||||||
|
for (int i = 0; i < stcdValues.size(); i++) {
|
||||||
|
String key = "vpRunStcd" + i;
|
||||||
|
paramMap.put(key, stcdValues.get(i));
|
||||||
|
placeholders.add("#{map." + key + "}");
|
||||||
|
}
|
||||||
|
sql.append(" AND (r.STCD IN (").append(String.join(", ", placeholders)).append(")")
|
||||||
|
.append(" OR r.RSTCD IN (").append(String.join(", ", placeholders)).append("))");
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(tm)) {
|
||||||
|
paramMap.put("vpRunYear", tm);
|
||||||
|
sql.append(" AND TO_CHAR(r.TM, 'YYYY') = #{map.vpRunYear}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildBasinVpIntDetailOrderBy(List<DataSourceRequest.SortDescriptor> sorts) {
|
||||||
|
if (sorts == null || sorts.isEmpty()) {
|
||||||
|
return " ORDER BY tetp ASC, tm ASC";
|
||||||
|
}
|
||||||
|
Map<String, String> sortMap = new HashMap<>();
|
||||||
|
sortMap.put("stnm", "stnm");
|
||||||
|
sortMap.put("baseId", "baseId");
|
||||||
|
sortMap.put("baseName", "baseName");
|
||||||
|
sortMap.put("stcd", "stcd");
|
||||||
|
sortMap.put("type", "type");
|
||||||
|
sortMap.put("unit", "unit");
|
||||||
|
sortMap.put("tetp", "tetp");
|
||||||
|
sortMap.put("tecnt", "tecnt");
|
||||||
|
sortMap.put("surnum", "surnum");
|
||||||
|
sortMap.put("transplant", "transplant");
|
||||||
|
sortMap.put("plantask", "plantask");
|
||||||
|
sortMap.put("treeNum", "treeNum");
|
||||||
|
sortMap.put("fgNum", "fgNum");
|
||||||
|
sortMap.put("rate", "rate");
|
||||||
|
sortMap.put("tm", "tm");
|
||||||
|
sortMap.put("fid", "fid");
|
||||||
|
List<String> orderItems = new ArrayList<>();
|
||||||
|
for (DataSourceRequest.SortDescriptor sort : sorts) {
|
||||||
|
if (sort == null || StrUtil.isBlank(sort.getField())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String column = sortMap.get(sort.getField());
|
||||||
|
if (StrUtil.isBlank(column)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String dir = "desc".equalsIgnoreCase(sort.getDir()) ? "DESC" : "ASC";
|
||||||
|
orderItems.add(column + " " + dir);
|
||||||
|
}
|
||||||
|
if (orderItems.isEmpty()) {
|
||||||
|
return " ORDER BY tetp ASC, tm ASC";
|
||||||
|
}
|
||||||
|
return " ORDER BY " + String.join(", ", orderItems);
|
||||||
|
}
|
||||||
|
|
||||||
private String buildVmsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
private String buildVmsstbprptFilterCondition(DataSourceRequest.FilterDescriptor filter,
|
||||||
Map<String, Object> paramMap,
|
Map<String, Object> paramMap,
|
||||||
int[] indexHolder) {
|
int[] indexHolder) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user