From d038ae066d4d7e6400bbd841cfe5164dfcecd556 Mon Sep 17 00:00:00 2001 From: wanggeng <450292408@qq.com> Date: Tue, 17 Aug 2021 11:14:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=AE=9E=E6=97=B6=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8A=A0=E8=BD=BD=E6=85=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datareal/impl/DataRealServiceImpl.java | 55 +++++++++++++++++-- .../enterprise/IEnterpriseService.java | 8 +++ .../impl/EnterpriseServiceImpl.java | 7 +++ .../instrument/IInstrumentService.java | 8 +++ .../impl/InstrumentServiceImpl.java | 25 +++++---- src/main/resources/application-test.yml | 16 +++--- .../mapper/datareal/datareal-mapper.xml | 21 +------ 7 files changed, 98 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/cm/tenlion/pollutantdata/service/datareal/impl/DataRealServiceImpl.java b/src/main/java/com/cm/tenlion/pollutantdata/service/datareal/impl/DataRealServiceImpl.java index b12110f..ac01b7c 100644 --- a/src/main/java/com/cm/tenlion/pollutantdata/service/datareal/impl/DataRealServiceImpl.java +++ b/src/main/java/com/cm/tenlion/pollutantdata/service/datareal/impl/DataRealServiceImpl.java @@ -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.EnterprisePollDTO; 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.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.PageInfo; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @ClassName: DataMinuteServiceImpl @@ -34,6 +39,12 @@ public class DataRealServiceImpl extends AbstractService implements IDataRealSer @Autowired private IDataRealDao dataMinuteDao; + @Autowired + private IEnterpriseService enterpriseService; + @Autowired + private IInstrumentService instrumentService; + @Autowired + private IPollService pollService; @Override public void save(DataRealVO dataRealVO) throws Exception { @@ -146,7 +157,43 @@ public class DataRealServiceImpl extends AbstractService implements IDataRealSer @Override public List list(Map params) { - return dataMinuteDao.list(params); + List dataRealDTOs = dataMinuteDao.list(params); + + Set enterpriseIdSet = new HashSet<>(); + Set instrumentIdSet = new HashSet<>(); + + for (DataRealDTO dataRealDTO : dataRealDTOs) { + enterpriseIdSet.add(dataRealDTO.getEnterpriseId()); + instrumentIdSet.add(dataRealDTO.getInstrumentId()); + } + + List enterprisePOs = enterpriseService.listPO(new ArrayList<>(enterpriseIdSet)); + List instrumentPOs = instrumentService.listPO(new ArrayList<>(instrumentIdSet)); + List 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 diff --git a/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/IEnterpriseService.java b/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/IEnterpriseService.java index fd2f9a2..e2ae987 100644 --- a/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/IEnterpriseService.java +++ b/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/IEnterpriseService.java @@ -169,6 +169,14 @@ public interface IEnterpriseService { */ List listPO(Map params); + /** + * 污染企业列表 + * + * @param enterpriseIds + * @return + */ + List listPO(List enterpriseIds); + /** * 污染企业分页列表 * diff --git a/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/impl/EnterpriseServiceImpl.java b/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/impl/EnterpriseServiceImpl.java index fa70484..fb3c185 100644 --- a/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/impl/EnterpriseServiceImpl.java +++ b/src/main/java/com/cm/tenlion/pollutantdata/service/enterprise/impl/EnterpriseServiceImpl.java @@ -173,6 +173,13 @@ public class EnterpriseServiceImpl extends AbstractService implements IEnterpris return enterpriseDao.listPO(params); } + @Override + public List listPO(List enterpriseIds) { + Map params = getHashMap(2); + params.put("enterpriseIds", enterpriseIds); + return listPO(params); + } + @Override public SuccessResultList> listPage(ListPage page) { PageHelper.startPage(page.getPage(), page.getRows()); diff --git a/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/IInstrumentService.java b/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/IInstrumentService.java index 5cc3695..93cdbfe 100644 --- a/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/IInstrumentService.java +++ b/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/IInstrumentService.java @@ -177,6 +177,14 @@ public interface IInstrumentService { */ List listPO(Map params); + /** + * 数采仪列表 + * + * @param instrumentIds + * @return + */ + List listPO(List instrumentIds); + /** * 数采仪分页列表 * diff --git a/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/impl/InstrumentServiceImpl.java b/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/impl/InstrumentServiceImpl.java index ab13b1b..120305d 100644 --- a/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/impl/InstrumentServiceImpl.java +++ b/src/main/java/com/cm/tenlion/pollutantdata/service/instrument/impl/InstrumentServiceImpl.java @@ -1,21 +1,19 @@ 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.exception.SearchException; import com.cm.common.pojo.ListPage; import com.cm.common.result.SuccessResultList; import com.cm.common.utils.HashMapUtil; 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.PageInfo; import org.apache.commons.lang3.StringUtils; @@ -175,6 +173,13 @@ public class InstrumentServiceImpl extends AbstractService implements IInstrumen return instrumentDao.listPO(params); } + @Override + public List listPO(List instrumentIds) { + Map params = getHashMap(2); + params.put("instrumentIds", instrumentIds); + return listPO(params); + } + @Override public SuccessResultList> listPage(ListPage page) { PageHelper.startPage(page.getPage(), page.getRows()); diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index 9e73da0..b5f7175 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -22,11 +22,11 @@ spring: max-request-size: 1GB datasource: 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 driver-class-name: com.mysql.jdbc.Driver - username: root - password: root + username: wanggeng + password: TSkj@0471.123 initial-size: 2 min-idle: 2 max-active: 10 @@ -57,11 +57,11 @@ spring: # 安全 security: 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} client: - client-id: 2a347bba1dc54def83a47493c7578ae2 - client-secret: TEdsOHlnTnc4T2JwTXM3alZldzRSM1ROKzhaQkZaQ24vSWJxREd0TWVLMG1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== + client-id: deb4f0137c4a4b76804acda58714b3bc + client-secret: U20yemhHQmJNWjc5QTZFcXlYaE50OXRFVlRVeCt3RmlnRnFpSXAraVJ6QW1ac2wwZTJHWk5NbXh3L3h3U2c4Rg== user-authorization-uri: ${security.oauth2.oauth-server}/oauth_client/authorize access-token-uri: ${security.oauth2.oauth-server}/oauth_client/token grant-type: authorization_code @@ -75,7 +75,7 @@ security: api-path: user-center: ${security.oauth2.oauth-server} - inspection: http://124.67.110.246:8081/inspection + inspection: http://106.12.218.237:8081/inspection system: # 预警通知上限 alarm-notice-limit: 5 @@ -102,7 +102,7 @@ swagger: # 文件上传管理 file: # 文件的保存路径 - upload-path: /tenlion/projects/uploadFiles/ + upload-path: /Users/wanggeng/Desktop/UploadFiles/ # 图片类型 image-types: png,jpg,jpeg,gif,blob # 视频类型 diff --git a/src/main/resources/mybatis/mapper/datareal/datareal-mapper.xml b/src/main/resources/mybatis/mapper/datareal/datareal-mapper.xml index ebba601..4b7163e 100644 --- a/src/main/resources/mybatis/mapper/datareal/datareal-mapper.xml +++ b/src/main/resources/mybatis/mapper/datareal/datareal-mapper.xml @@ -243,11 +243,8 @@ SELECT t1.data_id, t1.enterprise_id, - jt1.enterprise_name, t1.instrument_id, - jt2.instrument_name, t1.poll_id, - jt3.poll_name, t1.sample_time, t1.flag, t1.rtd, @@ -261,22 +258,6 @@ LEFT(t1.gmt_create, 19) gmt_create FROM 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 1 = 1 @@ -314,7 +295,7 @@ AND LEFT(t1.gmt_create, 10) = #{day} - + ORDER BY t1.gmt_create DESC