fix: 优化接口慢问题
This commit is contained in:
parent
ac1498b4b2
commit
777571930c
@ -198,7 +198,7 @@ public class SdFbrdBH implements Serializable {
|
||||
/**
|
||||
* 增殖放流工艺
|
||||
*/
|
||||
private BigDecimal zzflgy;
|
||||
private String zzflgy;
|
||||
|
||||
/**
|
||||
* 增殖放流鱼种描述
|
||||
@ -259,7 +259,7 @@ public class SdFbrdBH implements Serializable {
|
||||
/**
|
||||
* 植被覆盖类型
|
||||
*/
|
||||
private BigDecimal vlsr;
|
||||
private String vlsr;
|
||||
|
||||
/**
|
||||
* 植被覆盖调查时间
|
||||
|
||||
@ -218,4 +218,12 @@ public class SdOpinfoBH implements Serializable {
|
||||
@TableField("DELETE_TIME")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date deleteTime;
|
||||
|
||||
/** 所属站类全路径(非数据库字段) */
|
||||
@TableField(exist = false)
|
||||
private String sttpFullPath;
|
||||
|
||||
/** 所属站类层级(非数据库字段) */
|
||||
@TableField(exist = false)
|
||||
private Integer sttpTreeLevel;
|
||||
}
|
||||
|
||||
@ -266,6 +266,10 @@ public class MsThreedRoamMServiceImpl extends ServiceImpl<MsThreedRoamMMapper, M
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
|
||||
/** 时间缩放系数 */
|
||||
private static final BigDecimal TIME_SCALE = new BigDecimal("0.2");
|
||||
|
||||
@Override
|
||||
public MsThreedRoamBVO getThreedRoamData(DataSourceRequest dataSourceRequest) {
|
||||
DataSourceLoadOptionsBase loadOptions = dataSourceRequest.toDevRequest();
|
||||
@ -282,22 +286,34 @@ public class MsThreedRoamMServiceImpl extends ServiceImpl<MsThreedRoamMMapper, M
|
||||
wrapper.orderByAsc("ORDER_INDEX");
|
||||
List<MsThreedRoamEntity> threedRoamList = msThreedRoamMapper.selectList(wrapper);
|
||||
|
||||
BigDecimal totalTime = BigDecimal.ZERO;
|
||||
List<Object> lists = new ArrayList<>();
|
||||
String baseCode = "";
|
||||
if (CollUtil.isEmpty(threedRoamList)) {
|
||||
MsThreedRoamBVO empty = new MsThreedRoamBVO();
|
||||
empty.setList(Collections.emptyList());
|
||||
empty.setTotalTime(BigDecimal.ZERO);
|
||||
empty.setCode("");
|
||||
empty.setMilestoneList(Collections.emptyList());
|
||||
return empty;
|
||||
}
|
||||
|
||||
int size = threedRoamList.size();
|
||||
// 每条记录输出4个元素(总时间+经度+纬度+高程),预分配避免扩容
|
||||
List<Object> lists = new ArrayList<>(size * 4);
|
||||
List<String[]> milestoneList = new ArrayList<>();
|
||||
List<String> stcdList = new ArrayList<>();
|
||||
// HashSet O(1) 去重,避免 ArrayList.contains() 的 O(n) 查找
|
||||
Set<String> stcdSet = new HashSet<>();
|
||||
|
||||
BigDecimal totalTime = BigDecimal.ZERO;
|
||||
String baseCode = "";
|
||||
|
||||
for (MsThreedRoamEntity detail : threedRoamList) {
|
||||
totalTime = totalTime.add(detail.getTime().multiply(new BigDecimal("0.2")));
|
||||
totalTime = totalTime.add(detail.getTime().multiply(TIME_SCALE));
|
||||
lists.add(totalTime);
|
||||
lists.add(detail.getLgtd());
|
||||
lists.add(detail.getLttd());
|
||||
lists.add(detail.getDtmel());
|
||||
baseCode = detail.getCode();
|
||||
|
||||
if (StrUtil.isNotBlank(detail.getStcd()) && !stcdList.contains(detail.getStnm())) {
|
||||
stcdList.add(detail.getStnm());
|
||||
if (StrUtil.isNotBlank(detail.getStcd()) && stcdSet.add(detail.getStnm())) {
|
||||
milestoneList.add(new String[]{detail.getStnm(), totalTime.toString()});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user