处理实时数据加载慢问题

This commit is contained in:
wanggeng 2021-08-17 11:14:43 +08:00
parent 975cd48215
commit d038ae066d
7 changed files with 98 additions and 42 deletions

View File

@ -11,16 +11,21 @@ import com.cm.tenlion.pollutantdata.pojo.bos.datareal.DataRealBO;
import com.cm.tenlion.pollutantdata.pojo.dtos.datareal.DataRealDTO; import com.cm.tenlion.pollutantdata.pojo.dtos.datareal.DataRealDTO;
import com.cm.tenlion.pollutantdata.pojo.dtos.datareal.EnterprisePollDTO; import com.cm.tenlion.pollutantdata.pojo.dtos.datareal.EnterprisePollDTO;
import com.cm.tenlion.pollutantdata.pojo.pos.datareal.DataRealPO; import com.cm.tenlion.pollutantdata.pojo.pos.datareal.DataRealPO;
import com.cm.tenlion.pollutantdata.pojo.pos.enterprise.EnterprisePO;
import com.cm.tenlion.pollutantdata.pojo.pos.instrument.InstrumentPO;
import com.cm.tenlion.pollutantdata.pojo.pos.poll.PollPO;
import com.cm.tenlion.pollutantdata.pojo.vos.datareal.DataRealVO; import com.cm.tenlion.pollutantdata.pojo.vos.datareal.DataRealVO;
import com.cm.tenlion.pollutantdata.service.datareal.IDataRealService; import com.cm.tenlion.pollutantdata.service.datareal.IDataRealService;
import com.cm.tenlion.pollutantdata.service.enterprise.IEnterpriseService;
import com.cm.tenlion.pollutantdata.service.instrument.IInstrumentService;
import com.cm.tenlion.pollutantdata.service.poll.IPollService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
/** /**
* @ClassName: DataMinuteServiceImpl * @ClassName: DataMinuteServiceImpl
@ -34,6 +39,12 @@ public class DataRealServiceImpl extends AbstractService implements IDataRealSer
@Autowired @Autowired
private IDataRealDao dataMinuteDao; private IDataRealDao dataMinuteDao;
@Autowired
private IEnterpriseService enterpriseService;
@Autowired
private IInstrumentService instrumentService;
@Autowired
private IPollService pollService;
@Override @Override
public void save(DataRealVO dataRealVO) throws Exception { public void save(DataRealVO dataRealVO) throws Exception {
@ -146,7 +157,43 @@ public class DataRealServiceImpl extends AbstractService implements IDataRealSer
@Override @Override
public List<DataRealDTO> list(Map<String, Object> params) { public List<DataRealDTO> list(Map<String, Object> params) {
return dataMinuteDao.list(params); List<DataRealDTO> dataRealDTOs = dataMinuteDao.list(params);
Set<String> enterpriseIdSet = new HashSet<>();
Set<String> instrumentIdSet = new HashSet<>();
for (DataRealDTO dataRealDTO : dataRealDTOs) {
enterpriseIdSet.add(dataRealDTO.getEnterpriseId());
instrumentIdSet.add(dataRealDTO.getInstrumentId());
}
List<EnterprisePO> enterprisePOs = enterpriseService.listPO(new ArrayList<>(enterpriseIdSet));
List<InstrumentPO> instrumentPOs = instrumentService.listPO(new ArrayList<>(instrumentIdSet));
List<PollPO> pollPOs = pollService.listPO(new HashMap<>());
for (DataRealDTO dataRealDTO : dataRealDTOs) {
for (EnterprisePO enterprisePO : enterprisePOs) {
if (StringUtils.equals(dataRealDTO.getEnterpriseId(), enterprisePO.getEnterpriseId())) {
dataRealDTO.setEnterpriseName(enterprisePO.getEnterpriseName());
break;
}
}
for (InstrumentPO instrumentPO : instrumentPOs) {
if (StringUtils.equals(dataRealDTO.getInstrumentId(), instrumentPO.getInstrumentId())) {
dataRealDTO.setInstrumentName(instrumentPO.getInstrumentName());
break;
}
}
for (PollPO pollPO : pollPOs) {
if (StringUtils.equals(dataRealDTO.getPollId(), pollPO.getPollNo()) ||
StringUtils.equals(dataRealDTO.getPollId(), pollPO.getPollNoOld())) {
dataRealDTO.setPollName(pollPO.getPollName());
break;
}
}
}
return dataRealDTOs;
} }
@Override @Override

View File

@ -169,6 +169,14 @@ public interface IEnterpriseService {
*/ */
List<EnterprisePO> listPO(Map<String, Object> params); List<EnterprisePO> listPO(Map<String, Object> params);
/**
* 污染企业列表
*
* @param enterpriseIds
* @return
*/
List<EnterprisePO> listPO(List<String> enterpriseIds);
/** /**
* 污染企业分页列表 * 污染企业分页列表
* *

View File

@ -173,6 +173,13 @@ public class EnterpriseServiceImpl extends AbstractService implements IEnterpris
return enterpriseDao.listPO(params); return enterpriseDao.listPO(params);
} }
@Override
public List<EnterprisePO> listPO(List<String> enterpriseIds) {
Map<String, Object> params = getHashMap(2);
params.put("enterpriseIds", enterpriseIds);
return listPO(params);
}
@Override @Override
public SuccessResultList<List<EnterpriseDTO>> listPage(ListPage page) { public SuccessResultList<List<EnterpriseDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows()); PageHelper.startPage(page.getPage(), page.getRows());

View File

@ -177,6 +177,14 @@ public interface IInstrumentService {
*/ */
List<InstrumentPO> listPO(Map<String, Object> params); List<InstrumentPO> listPO(Map<String, Object> params);
/**
* 数采仪列表
*
* @param instrumentIds
* @return
*/
List<InstrumentPO> listPO(List<String> instrumentIds);
/** /**
* 数采仪分页列表 * 数采仪分页列表
* *

View File

@ -1,21 +1,19 @@
package com.cm.tenlion.pollutantdata.service.instrument.impl; package com.cm.tenlion.pollutantdata.service.instrument.impl;
import com.cm.common.utils.ArrayListUtil;
import com.cm.tenlion.pollutantdata.dao.instrument.IInstrumentDao;
import com.cm.tenlion.pollutantdata.manager.InstrumentManager;
import com.cm.tenlion.pollutantdata.pojo.OnlineInstrument;
import com.cm.tenlion.pollutantdata.pojo.bos.instrument.InstrumentBO;
import com.cm.tenlion.pollutantdata.pojo.dtos.collector.CollectorDTO;
import com.cm.tenlion.pollutantdata.pojo.dtos.instrument.InstrumentDTO;
import com.cm.tenlion.pollutantdata.pojo.pos.instrument.InstrumentPO;
import com.cm.tenlion.pollutantdata.pojo.vos.instrument.InstrumentVO;
import com.cm.tenlion.pollutantdata.service.instrument.IInstrumentService;
import com.cm.common.base.AbstractService; import com.cm.common.base.AbstractService;
import com.cm.common.exception.SearchException; import com.cm.common.exception.SearchException;
import com.cm.common.pojo.ListPage; import com.cm.common.pojo.ListPage;
import com.cm.common.result.SuccessResultList; import com.cm.common.result.SuccessResultList;
import com.cm.common.utils.HashMapUtil; import com.cm.common.utils.HashMapUtil;
import com.cm.common.utils.UUIDUtil; import com.cm.common.utils.UUIDUtil;
import com.cm.tenlion.pollutantdata.dao.instrument.IInstrumentDao;
import com.cm.tenlion.pollutantdata.manager.InstrumentManager;
import com.cm.tenlion.pollutantdata.pojo.OnlineInstrument;
import com.cm.tenlion.pollutantdata.pojo.bos.instrument.InstrumentBO;
import com.cm.tenlion.pollutantdata.pojo.dtos.instrument.InstrumentDTO;
import com.cm.tenlion.pollutantdata.pojo.pos.instrument.InstrumentPO;
import com.cm.tenlion.pollutantdata.pojo.vos.instrument.InstrumentVO;
import com.cm.tenlion.pollutantdata.service.instrument.IInstrumentService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -175,6 +173,13 @@ public class InstrumentServiceImpl extends AbstractService implements IInstrumen
return instrumentDao.listPO(params); return instrumentDao.listPO(params);
} }
@Override
public List<InstrumentPO> listPO(List<String> instrumentIds) {
Map<String, Object> params = getHashMap(2);
params.put("instrumentIds", instrumentIds);
return listPO(params);
}
@Override @Override
public SuccessResultList<List<InstrumentDTO>> listPage(ListPage page) { public SuccessResultList<List<InstrumentDTO>> listPage(ListPage page) {
PageHelper.startPage(page.getPage(), page.getRows()); PageHelper.startPage(page.getPage(), page.getRows());

View File

@ -22,11 +22,11 @@ spring:
max-request-size: 1GB max-request-size: 1GB
datasource: datasource:
druid: druid:
url: jdbc:mysql://192.168.0.151:3306/db_pollutant_data?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC url: jdbc:mysql://106.12.218.237:8668/db_pollutant_data?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC
db-type: mysql db-type: mysql
driver-class-name: com.mysql.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
username: root username: wanggeng
password: root password: TSkj@0471.123
initial-size: 2 initial-size: 2
min-idle: 2 min-idle: 2
max-active: 10 max-active: 10
@ -57,11 +57,11 @@ spring:
# 安全 # 安全
security: security:
oauth2: oauth2:
oauth-server: http://192.168.0.152:7001/usercenter oauth-server: http://106.12.218.237:8001/usercenter
oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url} oauth-logout: ${security.oauth2.oauth-server}/logout?redirect_uri=${server.url}
client: client:
client-id: 2a347bba1dc54def83a47493c7578ae2 client-id: deb4f0137c4a4b76804acda58714b3bc
client-secret: TEdsOHlnTnc4T2JwTXM3alZldzRSM1ROKzhaQkZaQ24vSWJxREd0TWVLMG1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== client-secret: U20yemhHQmJNWjc5QTZFcXlYaE50OXRFVlRVeCt3RmlnRnFpSXAraVJ6QW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg==
user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize
access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token
grant-type: authorization_code grant-type: authorization_code
@ -75,7 +75,7 @@ security:
api-path: api-path:
user-center: ${security.oauth2.oauth-server} user-center: ${security.oauth2.oauth-server}
inspection: http://124.67.110.246:8081/inspection inspection: http://106.12.218.237:8081/inspection
system: system:
# 预警通知上限 # 预警通知上限
alarm-notice-limit: 5 alarm-notice-limit: 5
@ -102,7 +102,7 @@ swagger:
# 文件上传管理 # 文件上传管理
file: file:
# 文件的保存路径 # 文件的保存路径
upload-path: /tenlion/projects/uploadFiles/ upload-path: /Users/wanggeng/Desktop/UploadFiles/
# 图片类型 # 图片类型
image-types: png,jpg,jpeg,gif,blob image-types: png,jpg,jpeg,gif,blob
# 视频类型 # 视频类型

View File

@ -243,11 +243,8 @@
SELECT SELECT
t1.data_id, t1.data_id,
t1.enterprise_id, t1.enterprise_id,
jt1.enterprise_name,
t1.instrument_id, t1.instrument_id,
jt2.instrument_name,
t1.poll_id, t1.poll_id,
jt3.poll_name,
t1.sample_time, t1.sample_time,
t1.flag, t1.flag,
t1.rtd, t1.rtd,
@ -261,22 +258,6 @@
LEFT(t1.gmt_create, 19) gmt_create LEFT(t1.gmt_create, 19) gmt_create
FROM FROM
pollute_data_real t1 pollute_data_real t1
LEFT JOIN
pollute_enterprise jt1
ON
t1.enterprise_id = jt1.enterprise_id
AND
jt1.is_delete = 0
LEFT JOIN
pollute_instrument jt2
ON
t1.instrument_id = jt2.instrument_id
AND
jt2.is_delete = 0
LEFT JOIN
pollute_poll jt3
ON
(t1.poll_id = jt3.poll_no OR t1.poll_id = jt3.poll_no_old)
WHERE WHERE
1 = 1 1 = 1
<if test="keywords != null and keywords != ''"> <if test="keywords != null and keywords != ''">
@ -314,7 +295,7 @@
AND AND
LEFT(t1.gmt_create, 10) = #{day} LEFT(t1.gmt_create, 10) = #{day}
</if> </if>
<if test="descOrderBy != null and descOrderBy = 'gmtCreate'"> <if test="descOrderBy != null and descOrderBy == 'gmtCreate'">
ORDER BY ORDER BY
t1.gmt_create DESC t1.gmt_create DESC
</if> </if>