From 69a561066510031ecfd0a3a9d09604934e5c16fd Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 24 Dec 2021 23:12:40 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=86=B0=E5=B1=B1=E4=B8=80=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/BaseGridDailyworkServiceImpl.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java index 2f29c8d240..a5abd04f86 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java @@ -155,19 +155,14 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl Date: Mon, 27 Dec 2021 15:38:30 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=94=99=E8=AF=AF=20?= =?UTF-8?q?=E7=AB=8B=E5=8D=B3=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opendata/service/impl/BaseGridDailyworkServiceImpl.java | 3 --- .../com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java index a5abd04f86..b435a3ccc8 100644 --- a/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java +++ b/epmet-module/open-data-worker/open-data-worker-server/src/main/java/com/epmet/opendata/service/impl/BaseGridDailyworkServiceImpl.java @@ -35,7 +35,6 @@ import com.epmet.opendata.entity.BaseGridDailyworkEntity; import com.epmet.opendata.service.BaseGridDailyworkService; import com.epmet.opendata.service.ExDeptService; import com.epmet.opendata.service.ExUserService; -import com.epmet.opendata.service.UserPatrolDetailService; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; @@ -60,8 +59,6 @@ public class BaseGridDailyworkServiceImpl extends BaseServiceImpl> mapResult = adminOpenFeignClient.dictTree(DictTypeEnum.PATROL_WORK_TYPE.getCode()); From 8d2d25be2e49e7c6c3ecc5548e3e7d3db21486cc Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 27 Dec 2021 17:54:19 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IssueVoteStatisticalServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java index b78896b90c..410be46673 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java @@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; @@ -226,7 +227,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl data = issueSatisfactionDetailDao.evaluationList(formDTO); - if (data.size() == NumConstant.ZERO || data == null) { + if (data == null || data.size() == NumConstant.ZERO ) { return new ArrayList<>(); } //获取头像和昵称 eg:山东路168号-周先生 @@ -237,14 +238,13 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl resultList = data.stream().flatMap(evaluation -> userResiInfoList.stream().filter(user -> + return data.stream().flatMap(evaluation -> userResiInfoList.stream().filter(user -> evaluation.getUserId().equals(user.getUserId())).map(userInfo -> { EvaluationListResultDTO resultDTO = ConvertUtils.sourceToTarget(evaluation, EvaluationListResultDTO.class); - resultDTO.setUserNickName(null == userInfo.getShowName() ? "" : userInfo.getShowName()); - resultDTO.setUserHeadPhoto(null == userInfo.getHeadPhoto() ? "" : userInfo.getHeadPhoto()); + resultDTO.setUserNickName(null == userInfo.getShowName() ? StrConstant.EPMETY_STR : userInfo.getShowName()); + resultDTO.setUserHeadPhoto(null == userInfo.getHeadPhoto() ? StrConstant.EPMETY_STR : userInfo.getHeadPhoto()); return resultDTO; })).collect(Collectors.toList()); - return resultList; } /** @@ -283,7 +283,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl statisticalList = baseDao.selectListByIds(ids); if (null != statisticalList && statisticalList.size() > NumConstant.ZERO) { - List statisiticalIds = statisticalList.stream().map(vote -> vote.getIssueId()).collect(Collectors.toList()); + List statisiticalIds = statisticalList.stream().map(IssueVoteStatisticalDTO::getIssueId).collect(Collectors.toList()); if (ids.size() > statisiticalIds.size()) { //差集 From ddf2ac2ff8520e5f2adc98e179aef537e182230a Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 27 Dec 2021 17:54:52 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java index 410be46673..5ee3f6c8d8 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java @@ -563,7 +563,7 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl Date: Mon, 27 Dec 2021 18:02:59 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=89=AB=E6=8F=8F?= =?UTF-8?q?=E5=87=BA=E7=9A=84=20=E9=AB=98=E7=BA=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/epmettduck/impl/PrUserProjectServiceImpl.java | 4 ++-- .../dataaggre/service/impl/QuestionnaireServiceImpl.java | 1 + .../com/epmet/utils/externalapp/ExtAppJwtAuthProcessor.java | 1 + .../epmet/service/impl/ComponentVerifyTicketServiceImpl.java | 1 + .../com/epmet/service/impl/BlockChainUploadServiceImpl.java | 5 +++-- .../java/com/epmet/service/impl/ResiEventServiceImpl.java | 3 ++- .../notice/service/impl/NoticeCommentServiceImpl.java | 3 ++- .../com/epmet/handler/ExcelDiceAddressListHandlerImpl.java | 1 + .../java/com/epmet/service/impl/VolunteerServiceImpl.java | 2 +- 9 files changed, 14 insertions(+), 7 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java index a77e2be2ad..a2bf983121 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java @@ -410,7 +410,7 @@ public class PrUserProjectServiceImpl extends BaseServiceImpl platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN); platforms.stream().forEach(p -> { diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java index 9a8837f120..c3afaa5341 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/BlockChainUploadServiceImpl.java @@ -34,12 +34,13 @@ public class BlockChainUploadServiceImpl implements BlockChainUploadService { * @param processEntity 处理进展entity * @param assignedStaffEntities 指派给的工作人员entity */ + @Override public void send2BlockChain(ProjectEntity projectEntity, ProjectProcessEntity processEntity, List assignedStaffEntities, String projectStaffId) { if (true) { return; } - + // 1.项目主信息 BlockChainProjectFormDTO project = null; @@ -131,7 +132,7 @@ public class BlockChainUploadServiceImpl implements BlockChainUploadService { handledStaff.setOrgIdPath(handledStaffEntity.getOrgIdPath()); handledStaff.setProjectId(handledStaffEntity.getProjectId()); } - + if (project == null) { // 处理 BlockChainProcessProjectFormDTO processForm = new BlockChainProcessProjectFormDTO(); diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java index ab54bfd340..a64b74ee99 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ResiEventServiceImpl.java @@ -233,6 +233,7 @@ public class ResiEventServiceImpl extends BaseServiceImpl wordList, List imageList) { if (imageList.size() != NumConstant.ZERO) { wordList.forEach(word -> { @@ -286,4 +287,4 @@ public class NoticeCommentServiceImpl extends BaseServiceImpl getList(String dict) { List list = new ArrayList<>(); Map dictMap = new HashMap<>(); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java index edc1149e6f..715c280a55 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/VolunteerServiceImpl.java @@ -17,7 +17,6 @@ import com.epmet.feign.EpmetHeartOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.VolunteerService; -import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -54,6 +53,7 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve * @param customerId * @return */ + @Override public VolunteerDistributionResultDTO getVolunteerDistributionAndLegends(String customerId) { // 1.查询分布 From b86dffd87ab95f5dc5852fdf4504eb448ae987c2 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 27 Dec 2021 18:10:32 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=9A=82=E6=97=B6=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E5=90=8E=E7=BB=AD=E9=87=8D=E5=86=99=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IssueVoteStatisticalServiceImpl.java | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java index 5ee3f6c8d8..449f52eb50 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueVoteStatisticalServiceImpl.java @@ -53,6 +53,7 @@ import com.epmet.service.IssueVoteDetailService; import com.epmet.service.IssueVoteStatisticalService; import com.epmet.utils.ModuleConstants; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -325,16 +326,19 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl collect = notExistedIds.stream().map(issueId -> { - IssueVoteStatisticalDTO dto = new IssueVoteStatisticalDTO(); - dto.setIssueId(issueId); - dto.setSupportCount(NumConstant.ZERO); - dto.setOppositionCount(NumConstant.ZERO); - dto.setVotableCount(Optional.ofNullable(votableCountMap.get(issueGridMap.get(issueId))).orElse(NumConstant.ZERO)); - dto.setCreatedBy(ModuleConstants.CREATED_BY_SYSTEM);dto.setUpdatedBy(ModuleConstants.CREATED_BY_SYSTEM); - return dto; - }).collect(Collectors.toList()); - if(!CollectionUtils.isEmpty(collect)) toInsert.addAll(collect);} + List collect = notExistedIds.stream().map(issueId -> { + IssueVoteStatisticalDTO dto = new IssueVoteStatisticalDTO(); + dto.setIssueId(issueId); + dto.setSupportCount(NumConstant.ZERO); + dto.setOppositionCount(NumConstant.ZERO); + dto.setVotableCount(Optional.ofNullable(votableCountMap.get(issueGridMap.get(issueId))).orElse(NumConstant.ZERO)); + dto.setCreatedBy(ModuleConstants.CREATED_BY_SYSTEM);dto.setUpdatedBy(ModuleConstants.CREATED_BY_SYSTEM); + return dto; + }).collect(Collectors.toList()); + if(!CollectionUtils.isEmpty(collect)) { + toInsert.addAll(collect); + } + } /* List summaryList = issueVoteDetailDao.getVotingSummaryList(notExistedIds); @@ -427,8 +431,11 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl listToUpdate = new ArrayList<>(); setVotableCountsAndUpdateCache(listToUpdate,issues,votableCountMap); - // listToUpdate批量更新 - baseDao.updateBatchByIssueId(listToUpdate); + // listToUpdate批量更新 todo 暂时解决下 分批插入 + if (CollectionUtils.isNotEmpty(listToUpdate)) { + ListUtils.partition(listToUpdate, NumConstant.ONE_HUNDRED) + .forEach(part -> baseDao.updateBatchByIssueId(part)); + } } }else{ @@ -550,8 +557,12 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl Date: Tue, 28 Dec 2021 09:02:17 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E5=88=A4=E6=96=AD=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E4=B8=8B=E6=98=AF=E4=B8=8D=E6=98=AF=E5=AD=98=E5=9C=A8=E4=B8=80?= =?UTF-8?q?=E7=BA=A7=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/service/impl/ProjectServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 6cafe080f3..f5c931b8a3 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -2869,7 +2869,7 @@ public class ProjectServiceImpl extends BaseServiceImpl> listResult = govIssueOpenFeignClient.selectCategoryOneLevelListByCustomerId(tokenDto); - if (!listResult.success()){ + if (!listResult.success() && CollectionUtils.isNotEmpty(listResult.getData())){ throw new EpmetException("查询1级分类列表失败..."); } List projectCategoryByDateDTOS = baseDao.selectProjectCategoryByDate(formDTO.getStartDate(),formDTO.getEndDate(), formDTO.getOrgId(), listResult.getData().get(NumConstant.ZERO).getCodeLength()); From 1498870a887014c952f4f381bccf1a45a03defb7 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 28 Dec 2021 17:16:51 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E6=8C=87?= =?UTF-8?q?=E6=A0=87=E5=BA=93=E7=BB=B4=E5=BA=A6=E5=90=8C=E6=AD=A5=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=8C=E6=96=B0=E5=A2=9E=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=EF=BC=8C=E5=AD=98=E5=9C=A8=E7=9A=84=E8=AF=9D=E5=88=99=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/DimLastSyncRecordDao.java | 48 ++++++ .../screen/DimLastSyncRecordEntity.java | 51 +++++++ .../screen/ScreenCustomerDeptEntity.java | 5 + .../screen/ScreenCustomerGridEntity.java | 5 + .../screen/ScreenCustomerAgencyService.java | 10 +- .../screen/ScreenCustomerDeptService.java | 8 +- .../screen/ScreenCustomerGridService.java | 9 +- .../impl/ScreenCustomerAgencyServiceImpl.java | 108 ++++++++++---- .../impl/ScreenCustomerDeptServiceImpl.java | 43 +++++- .../impl/ScreenCustomerGridServiceImpl.java | 64 ++++++-- .../epmet/service/impl/EIDimServiceImpl.java | 138 +++++++++--------- .../V0.0.27__create_indexdimsyncrecord.sql | 15 ++ .../screen/DimLastSyncRecordDao.xml | 31 ++++ .../mapper/org/CustomerDepartmentDao.xml | 6 +- .../resources/mapper/org/CustomerGridDao.xml | 1 + .../mapper/org/StatsCustomerAgencyDao.xml | 5 +- 16 files changed, 427 insertions(+), 120 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/DimLastSyncRecordDao.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/DimLastSyncRecordEntity.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__create_indexdimsyncrecord.sql create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/DimLastSyncRecordDao.xml diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/DimLastSyncRecordDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/DimLastSyncRecordDao.java new file mode 100644 index 0000000000..cdcdeda243 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/DimLastSyncRecordDao.java @@ -0,0 +1,48 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao.evaluationindex.screen; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-12-28 + */ +@Mapper +public interface DimLastSyncRecordDao extends BaseDao { + /** + * 查询最后一次同步时间 + * @return + */ + Date getDimLastSyncEndTime(@Param("subject") String subject); + + /** + * 更新最后一次同步时间 + * @param subject + * @param statsEndTime + * @return + */ + int updateLastSyncEndTime(@Param("subject") String subject, @Param("statsEndTime") Date statsEndTime); +} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/DimLastSyncRecordEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/DimLastSyncRecordEntity.java new file mode 100644 index 0000000000..d53db62b22 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/DimLastSyncRecordEntity.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity.evaluationindex.screen; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-12-28 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("dim_last_sync_record") +public class DimLastSyncRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 主体。agency:机关,department:部门,grid:网格 + */ + private String subject; + + /** + * 最后一次同步时间 + */ + private Date lastSyncTime; + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java index d8adca7a34..c0c78ebb24 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java @@ -87,4 +87,9 @@ public class ScreenCustomerDeptEntity extends BaseEpmetEntity { * desc: 是否参与上级计算yes:参与;no:不参与 add 01.14 */ private String upToCal; + + /** + * desc: 是否显示 1显示 0不显示 + */ + private String isDisplay; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java index cf6c373dca..aa566d645d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java @@ -97,4 +97,9 @@ public class ScreenCustomerGridEntity extends BaseEpmetEntity { * 地区码 */ private String code; + + /** + * desc: 是否显示 1显示 0不显示 + */ + private String isDisplay; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java index 9a46990c1d..a249907314 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java @@ -17,6 +17,7 @@ package com.epmet.service.evaluationindex.screen; +import cn.hutool.db.DaoTemplate; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; @@ -27,6 +28,7 @@ import com.epmet.dto.extract.result.OrgNameResultDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.org.CustomerAgencyEntity; +import java.util.Date; import java.util.List; import java.util.Map; @@ -61,7 +63,7 @@ public interface ScreenCustomerAgencyService extends BaseService agencies2Add, List agencies2Update); + void initAgencies(List agencies2Add, List agencies2Update, Date statsEndTime); /** * @Description 查询下一级机关的ID【即以agencyId为pid的agency】 @@ -164,4 +166,10 @@ public interface ScreenCustomerAgencyService extends BaseService depts2Add, List depts2Update); + void addAndUpdateDepartments(List depts2Add, List depts2Update, Date syncEndTime); + /** + * 查询上次同步的截止时间 + * @return + */ + Date getLastSyncEndTime(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java index bf701b81d3..e7e08d78b2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java @@ -27,6 +27,7 @@ import com.epmet.dto.screen.ScreenProjectGridDailyDTO; import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity; +import java.util.Date; import java.util.List; import java.util.Map; @@ -41,7 +42,7 @@ public interface ScreenCustomerGridService extends BaseService grids2Add, List grids2Update); + void addAndUpdateGrids(List grids2Add, List grids2Update, Date syncEndTime); /** * @Description 查询客户下所有网格ID @@ -129,4 +130,10 @@ public interface ScreenCustomerGridService extends BaseService getGridList(String customerId); + + /** + * 查询上次同步截止时间 + * @return + */ + Date getLastSyncEndTime(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java index 7a0b1a5415..249c5bceb0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java @@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.OrgSourceTypeConstant; import com.epmet.constant.ScreenConstant; +import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.dto.CustomerAgencyDTO; @@ -34,6 +35,7 @@ import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO; import com.epmet.dto.extract.result.OrgNameResultDTO; import com.epmet.dto.screen.result.TreeResultDTO; +import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; @@ -63,6 +65,8 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl agencies2Add, List agencies2Update) { + public void initAgencies(List agencies2Add, List agencies2Update, Date statsEndTime) { String dateEndTime = DateUtils.format(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD); if (!CollectionUtils.isEmpty(agencies2Add)) { // 添加 for (CustomerAgencyEntity e : agencies2Add) { - addAgency(e, dateEndTime); + addOrUpdateAgency(e, dateEndTime); } } @@ -137,11 +141,11 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl query = new LambdaQueryWrapper<>(); + query.eq(ScreenCustomerAgencyEntity::getCustomerId, e.getCustomerId()); + query.eq(ScreenCustomerAgencyEntity::getAgencyId, e.getId()); + ScreenCustomerAgencyEntity existsOne = screenCustomerAgencyDao.selectOne(query); + if (existsOne != null) { + // 已经存在 + existsOne.setAgencyId(e.getId()); + existsOne.setAgencyName(e.getOrganizationName()); + existsOne.setAllParentNames(e.getAllParentName()); + existsOne.setAreaCode(e.getAreaCode()); + //cae.setAreaMarks(e); + //如果没有区划 则默认暂时不显示 + //if (StringUtils.isEmpty(e.getAreaCode())) { + // existsOne.setIsDisplay(NumConstant.ZERO_STR); + //} else { + // existsOne.setIsDisplay(NumConstant.ONE_STR); + //} + existsOne.setCustomerId(e.getCustomerId()); + existsOne.setDataEndTime(dateEndTime); + existsOne.setLevel(e.getLevel()); + existsOne.setPid(e.getPid()); + existsOne.setPids(e.getPids()); + existsOne.setSourceType(OrgSourceTypeConstant.INTERNAL); + existsOne.setParentAreaCode(e.getParentAreaCode()); + existsOne.setCode(e.getCode()); + screenCustomerAgencyDao.updateById(existsOne); + return; } else { - cae.setIsDisplay(NumConstant.ONE_STR); + // 不存在,需要添加 + ScreenCustomerAgencyEntity cae = new ScreenCustomerAgencyEntity(); + cae.setAgencyId(e.getId()); + cae.setAgencyName(e.getOrganizationName()); + cae.setAllParentNames(e.getAllParentName()); + cae.setAreaCode(e.getAreaCode()); + //cae.setAreaMarks(e); + //如果没有区划 则默认暂时不显示 + if (StringUtils.isEmpty(e.getAreaCode())) { + cae.setIsDisplay(NumConstant.ZERO_STR); + } else { + cae.setIsDisplay(NumConstant.ONE_STR); + } + cae.setCustomerId(e.getCustomerId()); + cae.setDataEndTime(dateEndTime); + cae.setLevel(e.getLevel()); + cae.setPid(e.getPid()); + cae.setPids(e.getPids()); + cae.setSourceType(OrgSourceTypeConstant.INTERNAL); + cae.setParentAreaCode(e.getParentAreaCode()); + cae.setCode(e.getCode()); + screenCustomerAgencyDao.insert(cae); } - cae.setCustomerId(e.getCustomerId()); - cae.setDataEndTime(dateEndTime); - cae.setLevel(e.getLevel()); - cae.setPid(e.getPid()); - cae.setPids(e.getPids()); - cae.setSourceType(OrgSourceTypeConstant.INTERNAL); - cae.setParentAreaCode(e.getParentAreaCode()); - cae.setCode(e.getCode()); - screenCustomerAgencyDao.insert(cae); } /** @@ -355,4 +403,8 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl depts2Add, List depts2Update) { + public void addAndUpdateDepartments(List depts2Add, List depts2Update, Date syncEndTime) { String dateStr = DateUtils.format(new Date(), "YYYYmmdd"); for (CustomerDepartmentEntity dept : depts2Add) { ScreenCustomerDeptEntity e = screenCustomerDeptDao.selectByDeptId(dept.getId()); @@ -77,7 +84,22 @@ public class ScreenCustomerDeptServiceImpl extends BaseServiceImpl lastSyncRecordQuery = new LambdaQueryWrapper<>(); + lastSyncRecordQuery.eq(DimLastSyncRecordEntity::getSubject, "department"); + + DimLastSyncRecordEntity syncRecord = dimLastSyncRecordDao.selectOne(lastSyncRecordQuery); + if (syncRecord != null) { + dimLastSyncRecordDao.updateLastSyncEndTime("department", syncEndTime); + } else { + syncRecord = new DimLastSyncRecordEntity(); + syncRecord.setSubject("department"); + syncRecord.setLastSyncTime(syncEndTime); + dimLastSyncRecordDao.insert(syncRecord); + } + } + @Override + public Date getLastSyncEndTime() { + return dimLastSyncRecordDao.getDimLastSyncEndTime("department"); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java index 33fffebc37..fc7048f8e0 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java @@ -22,16 +22,19 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.DataSourceConstant; import com.epmet.constant.OrgSourceTypeConstant; +import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.dto.extract.form.*; import com.epmet.dto.extract.result.GridInfoResultDTO; import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; import com.epmet.dto.screen.ScreenCustomerGridDTO; import com.epmet.dto.screen.ScreenProjectGridDailyDTO; +import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerGridEntity; import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; @@ -57,6 +60,8 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl grids2Add, List grids2Update) { + public void addAndUpdateGrids(List grids2Add, List grids2Update, Date syncEndTime) { String dateStr = DateUtils.format(new Date(), "YYYYmmdd"); for (CustomerGridEntity grid : grids2Add) { ScreenCustomerGridEntity screenGrid = screenCustomerGridDao.getByGridId(grid.getId()); if (screenGrid == null) { - ScreenCustomerGridEntity insertOne = new ScreenCustomerGridEntity(); - insertOne.setAllParentIds(grid.getPids()); - insertOne.setCustomerId(grid.getCustomerId()); - insertOne.setDataEndTime(dateStr); - insertOne.setGridId(grid.getId()); - insertOne.setGridName(grid.getGridName()); - insertOne.setParentAgencyId(grid.getPid()); - insertOne.setSourceType(OrgSourceTypeConstant.INTERNAL); - insertOne.setAreaCode(grid.getAreaCode()); - insertOne.setCode(grid.getCode()); - screenCustomerGridDao.insert(insertOne); + screenGrid = new ScreenCustomerGridEntity(); + screenGrid.setAllParentIds(grid.getPids()); + screenGrid.setCustomerId(grid.getCustomerId()); + screenGrid.setDataEndTime(dateStr); + screenGrid.setGridId(grid.getId()); + screenGrid.setGridName(grid.getGridName()); + screenGrid.setParentAgencyId(grid.getPid()); + screenGrid.setSourceType(OrgSourceTypeConstant.INTERNAL); + screenGrid.setAreaCode(grid.getAreaCode()); + screenGrid.setCode(grid.getCode()); + //如果没有区划 则默认暂时不显示 + if (StringUtils.isEmpty(grid.getAreaCode())) { + screenGrid.setIsDisplay(NumConstant.ZERO_STR); + } else { + screenGrid.setIsDisplay(NumConstant.ONE_STR); + } + screenCustomerGridDao.insert(screenGrid); + } else { + screenGrid.setAllParentIds(grid.getPids()); + screenGrid.setCustomerId(grid.getCustomerId()); + screenGrid.setDataEndTime(dateStr); + screenGrid.setGridId(grid.getId()); + screenGrid.setGridName(grid.getGridName()); + screenGrid.setParentAgencyId(grid.getPid()); + screenGrid.setSourceType(OrgSourceTypeConstant.INTERNAL); + screenGrid.setAreaCode(grid.getAreaCode()); + screenGrid.setCode(grid.getCode()); + screenCustomerGridDao.updateById(screenGrid); } } @@ -109,6 +131,19 @@ public class ScreenCustomerGridServiceImpl extends BaseServiceImpl list = baseDao.selectList(wrapper); return ConvertUtils.sourceToTarget(list, ScreenCustomerGridDTO.class).stream().collect(Collectors.toMap(ScreenCustomerGridDTO::getGridId, Function.identity())); } + + @Override + public Date getLastSyncEndTime() { + return dimLastSyncRecordDao.getDimLastSyncEndTime("grid"); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java index c67213d6d2..47cb0e6d2a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java @@ -2,9 +2,6 @@ package com.epmet.service.impl; import com.epmet.dto.screen.ScreenProjectGridDailyDTO; import com.epmet.dto.screen.form.GridCenterPointForm; -import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; -import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; -import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.entity.org.CustomerDepartmentEntity; import com.epmet.entity.org.CustomerGridEntity; @@ -45,10 +42,11 @@ public class EIDimServiceImpl implements EIDimService { @Override public void initAgencies() { - List agencies2Add = listAgencies2Add(); - List agencies2Update = listAgencies2Update(); + Date statsEndTime = new Date();//DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); + List agencies2Add = listAgencies2Add(statsEndTime); + List agencies2Update = listAgencies2Update(statsEndTime); - screenCustomerAgencyService.initAgencies(agencies2Add, agencies2Update); + screenCustomerAgencyService.initAgencies(agencies2Add, agencies2Update, statsEndTime); } /** @@ -56,17 +54,9 @@ public class EIDimServiceImpl implements EIDimService { * * @return */ - private List listAgencies2Update() { - ScreenCustomerAgencyEntity e = screenCustomerAgencyService.getLastUpdatedAgency(); - - if (e != null) { - // 说明不是第一次初始化 - Date startTime = e.getUpdatedTime(); - Date endTime = new Date(); - return originCustomerAgencyService.listAgenciesByUpdatedTime(startTime, endTime); - } - - return new ArrayList<>(); + private List listAgencies2Update(Date endTime) { + Date startTime = screenCustomerAgencyService.getDimLastSyncTime(); + return originCustomerAgencyService.listAgenciesByUpdatedTime(startTime, endTime); } /** @@ -74,23 +64,17 @@ public class EIDimServiceImpl implements EIDimService { * * @return */ - private List listAgencies2Add() { - ScreenCustomerAgencyEntity e = screenCustomerAgencyService.getLastAddedAgency(); - - Date endTime = new Date(); - Date startTime = null; - if (e != null) { - startTime = e.getCreatedTime(); - } - + private List listAgencies2Add(Date endTime) { + Date startTime = screenCustomerAgencyService.getDimLastSyncTime(); return originCustomerAgencyService.listAgenciesByCreateTime(null, startTime, endTime); } @Override public void initDepartments() { - List depts2Add = listDepts2Add(); - List depts2Update = listDepts2Update(); - screenCustomerDeptService.addAndUpdateDepartments(depts2Add, depts2Update); + Date syncEndTime = new Date();//DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); + List depts2Add = listDepts2Add(syncEndTime); + List depts2Update = listDepts2Update(syncEndTime); + screenCustomerDeptService.addAndUpdateDepartments(depts2Add, depts2Update, syncEndTime); } /** @@ -98,17 +82,19 @@ public class EIDimServiceImpl implements EIDimService { * * @return */ - private List listDepts2Update() { - ScreenCustomerDeptEntity lastUpdateDept = screenCustomerDeptService.getLastUpdateDept(); - - if (lastUpdateDept != null) { - // 不是第一次初始化 - Date endTime = new Date(); - Date startTime = lastUpdateDept.getUpdatedTime(); - return originCustomerDepartmentService.listDepartmentsByUpdatedTime(startTime, endTime); - } - - return new ArrayList<>(); + private List listDepts2Update(Date syncEndTime) { + //ScreenCustomerDeptEntity lastUpdateDept = screenCustomerDeptService.getLastUpdateDept(); + // + //if (lastUpdateDept != null) { + // // 不是第一次初始化 + // Date endTime = new Date(); + // Date startTime = lastUpdateDept.getUpdatedTime(); + // return originCustomerDepartmentService.listDepartmentsByUpdatedTime(startTime, endTime); + //} + //return new ArrayList<>(); + + Date lastSyncEndTime = screenCustomerDeptService.getLastSyncEndTime(); + return originCustomerDepartmentService.listDepartmentsByUpdatedTime(lastSyncEndTime, syncEndTime); } /** @@ -116,23 +102,25 @@ public class EIDimServiceImpl implements EIDimService { * * @return */ - private List listDepts2Add() { - ScreenCustomerDeptEntity lastAddDept = screenCustomerDeptService.getLastAddDept(); - - Date startTime = null; - Date endTime = new Date(); - if (lastAddDept != null) { - startTime = lastAddDept.getCreatedTime(); - } - - return originCustomerDepartmentService.listDepartmentsByCreatedTime(null, startTime, endTime); + private List listDepts2Add(Date syncEndTime) { + //ScreenCustomerDeptEntity lastAddDept = screenCustomerDeptService.getLastAddDept(); + // + //Date startTime = null; + //Date endTime = new Date(); + //if (lastAddDept != null) { + // startTime = lastAddDept.getCreatedTime(); + //} + + Date startTime = screenCustomerDeptService.getLastSyncEndTime(); + return originCustomerDepartmentService.listDepartmentsByCreatedTime(null, startTime, syncEndTime); } @Override public void initGrids() { - List grids2Add = listGrids2Add(); - List grids2Update = listGrids2Update(); - screenCustomerGridService.addAndUpdateGrids(grids2Add, grids2Update); + Date syncEndTime = new Date();//DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); + List grids2Add = listGrids2Add(syncEndTime); + List grids2Update = listGrids2Update(syncEndTime); + screenCustomerGridService.addAndUpdateGrids(grids2Add, grids2Update, syncEndTime); } @Override @@ -159,26 +147,32 @@ public class EIDimServiceImpl implements EIDimService { return result; } - private List listGrids2Update() { - ScreenCustomerGridEntity lastUpdateGrid = screenCustomerGridService.getLastUpdateGrid(); - if (lastUpdateGrid != null) { - Date endTime = new Date(); - Date startTime = lastUpdateGrid.getUpdatedTime(); - return customerGridService.listUpdatedGridsByUpdateTime(startTime, endTime); - } - - return new ArrayList(); + private List listGrids2Update(Date syncEndTime) { + //ScreenCustomerGridEntity lastUpdateGrid = screenCustomerGridService.getLastUpdateGrid(); + //if (lastUpdateGrid != null) { + // Date endTime = new Date(); + // Date startTime = lastUpdateGrid.getUpdatedTime(); + // return customerGridService.listUpdatedGridsByUpdateTime(startTime, endTime); + //} + // + //return new ArrayList(); + + Date lastSyncEndTime = screenCustomerGridService.getLastSyncEndTime(); + return customerGridService.listUpdatedGridsByUpdateTime(lastSyncEndTime, syncEndTime); } - private List listGrids2Add() { - ScreenCustomerGridEntity lastAddGrid = screenCustomerGridService.getLastAddGrid(); - - Date endTime = new Date(); - Date startTime = null; - if (lastAddGrid != null) { - startTime = lastAddGrid.getCreatedTime(); - } - - return customerGridService.listGridsByCreateTime(null, startTime, endTime); + private List listGrids2Add(Date syncEndTime) { + //ScreenCustomerGridEntity lastAddGrid = screenCustomerGridService.getLastAddGrid(); + // + //Date endTime = new Date(); + //Date startTime = null; + //if (lastAddGrid != null) { + // startTime = lastAddGrid.getCreatedTime(); + //} + // + //return customerGridService.listGridsByCreateTime(null, startTime, endTime); + + Date lastSyncEndTime = screenCustomerGridService.getLastSyncEndTime(); + return customerGridService.listGridsByCreateTime(null, lastSyncEndTime, syncEndTime); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__create_indexdimsyncrecord.sql b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__create_indexdimsyncrecord.sql new file mode 100644 index 0000000000..7e5acdfbf5 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.27__create_indexdimsyncrecord.sql @@ -0,0 +1,15 @@ +create table dim_last_sync_record +( + `ID` varchar(64) primary key comment '主键', + `SUBJECT` varchar(32) not null comment '主体。agency:机关,department:部门,grid:网格', + `LAST_SYNC_TIME` datetime not null comment '最后一次同步时间', + `DEL_FLAG` char(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除;1已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(64) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(64) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间' +) default character set utf8mb4 engine InnoDB; + +create unique index dim_last_sync_record_SUBJECT_uindex + on dim_last_sync_record (SUBJECT); \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/DimLastSyncRecordDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/DimLastSyncRecordDao.xml new file mode 100644 index 0000000000..0f574a4702 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/DimLastSyncRecordDao.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + update dim_last_sync_record + set LAST_SYNC_TIME = #{statsEndTime} + where SUBJECT = #{subject} + and DEL_FLAG = '0' + + + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml index 1df3ef3a1a..2ba0e21b5a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml @@ -44,7 +44,9 @@ from customer_department cd LEFT JOIN customer_agency ca ON ( cd.AGENCY_ID = ca.id and ca.DEL_FLAG='0') - where cd.UPDATED_TIME > #{startTime} - and cd.UPDATED_TIME #{endTime} + where + cd.CREATED_TIME #{startTime} + and cd.UPDATED_TIME >= #{startTime} + and cd.UPDATED_TIME #{endTime} \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml index 587b75120e..4ebde89821 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml @@ -71,6 +71,7 @@ pids FROM customer_grid WHERE SYNC_FLAG='1' + AND CREATED_TIME #{startTime} AND UPDATED_TIME >= #{startTime} AND UPDATED_TIME #{endTime} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml index aa337955ad..fa5da30046 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml @@ -102,9 +102,10 @@ district, PARENT_AREA_CODE as parentAreaCode from customer_agency - where SYNC_FLAG='1' + where SYNC_FLAG='1' + AND CREATED_TIME #{startTime} AND UPDATED_TIME >= #{startTime} - and UPDATED_TIME #{endTime} + AND UPDATED_TIME #{endTime}