From 1498870a887014c952f4f381bccf1a45a03defb7 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 28 Dec 2021 17:16:51 +0800 Subject: [PATCH 01/19] =?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} From 0412c9e5e87d3eef26af067250c0909aa50a02ff Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 28 Dec 2021 19:19:34 +0800 Subject: [PATCH 02/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E5=90=8C=E6=AD=A5=EF=BC=8Cinternal&external?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/impl/ScreenCustomerAgencyServiceImpl.java | 2 +- .../screen/impl/ScreenCustomerDeptServiceImpl.java | 2 +- .../screen/impl/ScreenCustomerGridServiceImpl.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 249c5bceb0..9873b0ab93 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 @@ -275,7 +275,7 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl Date: Wed, 29 Dec 2021 16:26:56 +0800 Subject: [PATCH 03/19] =?UTF-8?q?=E6=89=80=E6=9C=89=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/govproject/ProjectDao.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml index 0282677e40..d2cc49d64a 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govproject/ProjectDao.xml @@ -4,7 +4,7 @@ + + + + + + \ No newline at end of file diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDailyDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDailyDao.xml index dcad30689c..bcbe6a5a4d 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDailyDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteStatisticalDailyDao.xml @@ -280,4 +280,13 @@ id = #{item.id} + + + + DELETE FROM issue_vote_statistical_daily + WHERE CUSTOMER_ID = #{customerId} + AND STATISTICAL_DATE = #{dateId} + LIMIT 1000 + + \ No newline at end of file From 54fb04fe11bc0abecf143ce170dc20fcceac034e Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 29 Dec 2021 16:51:35 +0800 Subject: [PATCH 05/19] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E8=B0=83=E6=95=B4?= 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 36caece989..f5cd7251c9 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 @@ -219,6 +219,12 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl polyLine = getPolyLine(startDate, endDate); + String today = LocalDate.now().toString(); + if (today.equals(endDate)){ + PolyLineDTO polyLineDTO = issueVoteDetailDao.polyLineData(issueId.getIssueId(), endDate); + polyLine.get(polyLine.size() - NumConstant.ONE).setSupportIncrement(polyLineDTO.getSupportIncrement()); + polyLine.get(polyLine.size() - NumConstant.ONE).setOppositionIncrement(polyLineDTO.getOppositionIncrement()); + } if (CollectionUtils.isEmpty(polyLineDTOS)){ votingTrendResultDTO.setPolyLine(polyLine); return votingTrendResultDTO; @@ -231,12 +237,6 @@ public class IssueVoteStatisticalServiceImpl extends BaseServiceImpl Date: Wed, 29 Dec 2021 17:08:53 +0800 Subject: [PATCH 06/19] =?UTF-8?q?job=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-module/epmet-job/epmet-job-server/pom.xml | 6 ++++++ .../main/java/com/epmet/feign/GovIssueFeignClient.java | 3 ++- .../epmet/feign/impl/GovIssueFeignClientFallBack.java | 5 +++-- .../service/IssueVotingDailyStatisticalTaskService.java | 3 ++- .../impl/IssueVotingDailyStatisticalTaskServiceImpl.java | 5 +++-- .../java/com/epmet/task/DailyStatisticalVoteTask.java | 9 ++++++++- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/epmet-module/epmet-job/epmet-job-server/pom.xml b/epmet-module/epmet-job/epmet-job-server/pom.xml index 4ebf4f1fd3..a2632d820f 100644 --- a/epmet-module/epmet-job/epmet-job-server/pom.xml +++ b/epmet-module/epmet-job/epmet-job-server/pom.xml @@ -90,6 +90,12 @@ 2.0.0 compile + + com.epmet + gov-issue-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/GovIssueFeignClient.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/GovIssueFeignClient.java index 4c091c1c6a..3731ecf8e6 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/GovIssueFeignClient.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/GovIssueFeignClient.java @@ -2,6 +2,7 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.DailyStatisticalVoteJob; import com.epmet.feign.impl.GovIssueFeignClientFallBack; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -22,7 +23,7 @@ public interface GovIssueFeignClient { * @date 2020.05.20 15:39 **/ @PostMapping(value = "gov/issue/issuevotestatisticaldaily/dailystatisticalvotejob") - Result dailyStatisticalVoteJob(); + Result dailyStatisticalVoteJob(DailyStatisticalVoteJob form); /** * @Description 将所有表决中的投票数从缓存同步到数据库,要进行数据对比,若数据一致无需更新 diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/GovIssueFeignClientFallBack.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/GovIssueFeignClientFallBack.java index 0267ca347f..7623db9dab 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/GovIssueFeignClientFallBack.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/GovIssueFeignClientFallBack.java @@ -3,6 +3,7 @@ package com.epmet.feign.impl; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.DailyStatisticalVoteJob; import com.epmet.feign.GovIssueFeignClient; import org.springframework.stereotype.Component; @@ -15,8 +16,8 @@ import org.springframework.stereotype.Component; @Component public class GovIssueFeignClientFallBack implements GovIssueFeignClient { @Override - public Result dailyStatisticalVoteJob() { - return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "dailyStatisticalVoteJob"); + public Result dailyStatisticalVoteJob(DailyStatisticalVoteJob form) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ISSUE_SERVER, "dailyStatisticalVoteJob",form); } @Override diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IssueVotingDailyStatisticalTaskService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IssueVotingDailyStatisticalTaskService.java index 0b72ddc1b2..3d14b1be08 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IssueVotingDailyStatisticalTaskService.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IssueVotingDailyStatisticalTaskService.java @@ -2,6 +2,7 @@ package com.epmet.service; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.DailyStatisticalVoteJob; /** * @Description 生成议题表决日统计数定时任务 @@ -10,6 +11,6 @@ import com.epmet.commons.tools.utils.Result; */ public interface IssueVotingDailyStatisticalTaskService { - Result issueVotingDailyStatistical(); + Result issueVotingDailyStatistical(DailyStatisticalVoteJob form); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IssueVotingDailyStatisticalTaskServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IssueVotingDailyStatisticalTaskServiceImpl.java index eb31c97810..504dc46994 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IssueVotingDailyStatisticalTaskServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IssueVotingDailyStatisticalTaskServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.DailyStatisticalVoteJob; import com.epmet.feign.GovIssueFeignClient; import com.epmet.service.IssueVotingDailyStatisticalTaskService; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +19,7 @@ public class IssueVotingDailyStatisticalTaskServiceImpl implements IssueVotingDa private GovIssueFeignClient govIssueFeignClient; @Override - public Result issueVotingDailyStatistical() { - return govIssueFeignClient.dailyStatisticalVoteJob(); + public Result issueVotingDailyStatistical(DailyStatisticalVoteJob form) { + return govIssueFeignClient.dailyStatisticalVoteJob(form); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DailyStatisticalVoteTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DailyStatisticalVoteTask.java index 1c33869895..41302d5305 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DailyStatisticalVoteTask.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/DailyStatisticalVoteTask.java @@ -1,7 +1,10 @@ package com.epmet.task; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.DailyStatisticalVoteJob; import com.epmet.service.IssueVotingDailyStatisticalTaskService; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,7 +27,11 @@ public class DailyStatisticalVoteTask implements ITask{ @Override public void run(String params) { logger.debug("dailyStatisticalVoteTask定时任务正在执行,参数为:{}", params); - Result result=issueVotingDailyStatisticalTaskService.issueVotingDailyStatistical(); + DailyStatisticalVoteJob form = new DailyStatisticalVoteJob(); + if (StringUtils.isNotBlank(params)) { + form = JSON.parseObject(params, DailyStatisticalVoteJob.class); + } + Result result=issueVotingDailyStatisticalTaskService.issueVotingDailyStatistical(form); if(result.success()){ logger.debug("dailyStatisticalVoteTask定时任务正在执行定时任务执行成功"); }else{ From bbb97fa7d76a1d0fc142e8674b01d6dca6b422fc Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 29 Dec 2021 17:52:16 +0800 Subject: [PATCH 07/19] emm --- .../com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java | 3 ++- .../epmet/controller/IssueVoteStatisticalDailyController.java | 2 +- .../src/main/resources/mapper/IssueVoteDetailDao.xml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java index 60199aa0fd..7bb45f5a4e 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/result/DailyStatisticalVoteJobResultDTO.java @@ -4,6 +4,7 @@ import com.epmet.commons.tools.constant.NumConstant; import lombok.Data; import java.io.Serializable; +import java.util.Date; /** * @Author zxc @@ -20,7 +21,7 @@ public class DailyStatisticalVoteJobResultDTO implements Serializable { /** * 统计日期 */ - private String statisticalDate; + private Date statisticalDate; /** * 到该日的总赞成数 diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueVoteStatisticalDailyController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueVoteStatisticalDailyController.java index 108e477862..1d4128ace9 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueVoteStatisticalDailyController.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueVoteStatisticalDailyController.java @@ -100,7 +100,7 @@ public class IssueVoteStatisticalDailyController { * @date 2020.05.20 15:39 **/ @PostMapping(value = "dailystatisticalvotejob") - public Result dailyStatisticalVoteJob(DailyStatisticalVoteJob form){ + public Result dailyStatisticalVoteJob(@RequestBody DailyStatisticalVoteJob form){ // issueVoteStatisticalDailyService.countVotingDailyStatistic(); issueVoteStatisticalDailyService.countVotingDailyStatisticNew(form); return new Result(); diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml index d501921aa5..def42fc563 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueVoteDetailDao.xml @@ -199,7 +199,7 @@ COUNT(CASE WHEN vd.ATTITUDE = 'opposition' THEN 1 END) AS oppositionIncrement, COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportCount, COUNT(CASE WHEN vd.ATTITUDE = 'support' THEN 1 END) AS supportIncrement, - #{dateId} AS statisticalDate + str_to_date(#{dateId},'%Y-%m-%d') AS statisticalDate FROM issue_vote_detail vd WHERE vd.DEL_FLAG = '0' AND vd.CUSTOMER_ID = #{customerId} From 85289f3115ff581957d91eaa7bbae0beb84a6a5b Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 30 Dec 2021 13:52:27 +0800 Subject: [PATCH 08/19] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gov-issue-server/src/main/resources/mapper/IssueDao.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml index a65070fd4a..9e5e5e583d 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml +++ b/epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueDao.xml @@ -645,7 +645,7 @@ From 9c99e653fff4177a06916f11aa07ead7bb254f16 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 30 Dec 2021 15:40:19 +0800 Subject: [PATCH 14/19] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8A=BD=E5=8F=96=20=E6=97=A5=E5=BF=97=E6=8E=92=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/FactOriginExtractController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java index 8d86caed9c..cf3ce5abf5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginExtractController.java @@ -7,6 +7,7 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.service.evaluationindex.extract.todata.*; import com.epmet.service.stats.DimCustomerService; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -23,6 +24,7 @@ import java.util.List; * @author yinzuomei@elink-cn.com * @date 2020/9/15 11:06 */ +@Slf4j @RestController @RequestMapping("factorigin") public class FactOriginExtractController { @@ -95,6 +97,7 @@ public class FactOriginExtractController { @PostMapping("project") public Result projectData(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { + long start = System.currentTimeMillis(); if (StringUtils.isNotBlank(extractOriginFormDTO.getCustomerId())) { List daysBetween; if (StringUtils.isBlank(extractOriginFormDTO.getDateId())) { @@ -115,6 +118,7 @@ public class FactOriginExtractController { projectExtractService.saveOriginProjectDaily(dto); }); } + log.info("projectData end,cost:{}",System.currentTimeMillis() - start); return new Result(); } From 698b859bb852ae14673e05b61bb8c76438a4ed2c Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 30 Dec 2021 16:25:27 +0800 Subject: [PATCH 15/19] dbupdate --- .../src/main/java/com/epmet/redis/IssueVoteDetailRedis.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java index 79068b4124..580b6a0f76 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueVoteDetailRedis.java @@ -262,6 +262,11 @@ public class IssueVoteDetailRedis { formDTO.setIssueId(issueId); formDTO.setGridId(issue.getGridId()); voteCache = issueVoteDetailService.selectIssueVotingDetail(formDTO); + IssueVoteStatisticalDTO dto = ConvertUtils.sourceToTarget(voteCache, IssueVoteStatisticalDTO.class); + dto.setVotableCount(voteCache.getShouldVoteCount()); + dto.setSupportCount(voteCache.getSupportAmount()); + dto.setOppositionCount(voteCache.getOppositionAmount()); + issueVoteStatisticalDao.updateBtIssueId(dto); }else { // 状态是关闭,转议题的,直接从结果表查询 voteCache = issueVoteStatisticalDao.selectVoteDetail(issueId); From 7a88c5ac39249d3e29dcf670bcad1b07d440f8be Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Thu, 30 Dec 2021 17:23:57 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=8A=BD=E5=8F=96?= =?UTF-8?q?=E6=95=88=E7=8E=87=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProjectExtractServiceImpl.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java index 3c860e4d37..5ee0d941bd 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java @@ -127,17 +127,30 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { //获取项目信息 List projectList = projectService.getProjectInfo(customerId, dateString, projectId); factOriginProjectMainDailyService.deleteByDate(customerId, dateString,projectId); + List issueList = new ArrayList<>(); + List topicList = new ArrayList<>(); if (!CollectionUtils.isEmpty(projectList)) { Map projectEventMap = projectService.getEventList(customerId); //提取议题ID List issueIds = projectList.stream().filter(item -> ProjectConstant.ISSUE.equals(item.getOrigin())).map(ProjectDTO::getOriginId).collect(Collectors.toList()); - //获取议题信息 - List issueList = issueService.getIssueInfoByIds(issueIds); - //提取话题ID - List topicIds = issueList.stream().map(IssueDTO::getSourceId).collect(Collectors.toList()); - //获取话题信息 - List topicList = topicService.getTopicByIds(topicIds); + if(CollectionUtils.isNotEmpty(issueIds)) { + //批次数量 + int batchCount = 200; + //获取议题信息 + + for (int i = 0; i < issueIds.size(); i += batchCount) { + int lastIndex = Math.min(i + batchCount, issueIds.size()); + issueList.addAll(issueService.getIssueInfoByIds(issueIds.subList(i, lastIndex))); + } + //提取话题ID + List topicIds = issueList.stream().map(IssueDTO::getSourceId).collect(Collectors.toList()); + //获取话题信息 + for (int i = 0; i < topicIds.size(); i += batchCount) { + int lastIndex = Math.min(i + batchCount, topicIds.size()); + topicList.addAll(topicService.getTopicByIds(topicIds.subList(i, lastIndex))); + } + } //获取网格认证党员 List partyMemberList = partyMemberService.getPartyMemberByCustomer(customerId); //生成DTO From aaa6d179e44fe386024b90bd4fe8ae4c2e9c0088 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 30 Dec 2021 17:39:28 +0800 Subject: [PATCH 17/19] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=BC=98=E5=8C=96=20?= =?UTF-8?q?=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProjectExtractServiceImpl.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java index 5ee0d941bd..6db4bc6c4c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java @@ -38,6 +38,7 @@ import com.epmet.util.DimIdGenerator; import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -134,21 +135,17 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { //提取议题ID List issueIds = projectList.stream().filter(item -> ProjectConstant.ISSUE.equals(item.getOrigin())).map(ProjectDTO::getOriginId).collect(Collectors.toList()); - if(CollectionUtils.isNotEmpty(issueIds)) { - //批次数量 - int batchCount = 200; + if (CollectionUtils.isNotEmpty(issueIds)) { + //分批次获取 //获取议题信息 - - for (int i = 0; i < issueIds.size(); i += batchCount) { - int lastIndex = Math.min(i + batchCount, issueIds.size()); - issueList.addAll(issueService.getIssueInfoByIds(issueIds.subList(i, lastIndex))); - } + List> partition = ListUtils.partition(issueIds, NumConstant.FIFTY); + partition.forEach(part -> issueList.addAll(issueService.getIssueInfoByIds(part))); //提取话题ID List topicIds = issueList.stream().map(IssueDTO::getSourceId).collect(Collectors.toList()); - //获取话题信息 - for (int i = 0; i < topicIds.size(); i += batchCount) { - int lastIndex = Math.min(i + batchCount, topicIds.size()); - topicList.addAll(topicService.getTopicByIds(topicIds.subList(i, lastIndex))); + if (CollectionUtils.isNotEmpty(topicIds)) { + //获取话题信息 + List> topicPart = ListUtils.partition(topicIds, NumConstant.FIFTY); + topicPart.forEach(part -> topicList.addAll(topicService.getTopicByIds(part))); } } //获取网格认证党员 From fdceeece40d827082e991b069a40c23a15233793 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 30 Dec 2021 17:40:24 +0800 Subject: [PATCH 18/19] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BF=97=E6=84=BF=E8=80=85=E4=BF=A1=E6=81=AF=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=EF=BC=8C=E5=BC=82=E6=AD=A5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/EpmetHeartOpenFeignClient.java | 8 + .../EpmetHeartOpenFeignClientFallback.java | 5 + .../controller/ResiVolunteerController.java | 14 + .../epmet/service/VolunteerInfoService.java | 7 + .../impl/VolunteerInfoServiceImpl.java | 7 + .../service/impl/VolunteerServiceImpl.java | 241 ++++++++++-------- 6 files changed, 172 insertions(+), 110 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java index 4bad8f25d7..b75ac8e39b 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/EpmetHeartOpenFeignClient.java @@ -66,4 +66,12 @@ public interface EpmetHeartOpenFeignClient { */ @PostMapping("/heart/resi/volunteer/page") Result> queryVolunteerPage(@RequestBody VolunteerCommonFormDTO input); + + /** + * 查询志愿者数量 + * @param input + * @return + */ + @PostMapping("/heart/resi/volunteer/count") + Result getVolunteerCount(@RequestBody VolunteerCommonFormDTO input); } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java index 27c2c9bdc8..5271fb57e0 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/feign/fallback/EpmetHeartOpenFeignClientFallback.java @@ -60,4 +60,9 @@ public class EpmetHeartOpenFeignClientFallback implements EpmetHeartOpenFeignCli public Result> queryVolunteerPage(VolunteerCommonFormDTO input) { return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "queryVolunteerPage", input); } + + @Override + public Result getVolunteerCount(VolunteerCommonFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_HEART_SERVER, "getVolunteerCount", input); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java index e1d18e5536..6205fb524a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/ResiVolunteerController.java @@ -144,4 +144,18 @@ public class ResiVolunteerController { List l = volunteerInfoService.queryVolunteerPage(customerId, pageNo, pageSize); return new Result>().ok(l); } + + /** + * 查询志愿者数量 + * @param input + * @return + */ + @PostMapping("count") + public Result getVolunteerCount(@RequestBody VolunteerCommonFormDTO input) { + ValidatorUtils.validateEntity(input, VolunteerCommonFormDTO.VolunteerPage.class); + String customerId = input.getCustomerId(); + + Integer volunteerCount = volunteerInfoService.getVolunteerCount(customerId); + return new Result().ok(volunteerCount); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java index 6a84fb67a1..4fa082f5e3 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/VolunteerInfoService.java @@ -97,4 +97,11 @@ public interface VolunteerInfoService extends BaseService { List queryListVolunteer(String customerId,String userRealName); List queryVolunteerPage(String customerId, Integer pageNo, Integer pageSize); + + /** + * 查询志愿者数量 + * @param customerId + * @return + */ + Integer getVolunteerCount(String customerId); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java index ac87cc6b4c..9d1e7a9240 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/VolunteerInfoServiceImpl.java @@ -278,4 +278,11 @@ public class VolunteerInfoServiceImpl extends BaseServiceImpl query = new LambdaQueryWrapper<>(); + query.eq(VolunteerInfoEntity::getCustomerId, customerId); + return baseDao.selectCount(query); + } } 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 2d5e776c8f..238b70cc41 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 @@ -2,6 +2,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.dao.IcResiUserDao; import com.epmet.dao.UserBaseInfoDao; @@ -16,7 +17,6 @@ import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.service.VolunteerService; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -24,6 +24,8 @@ import org.springframework.stereotype.Service; import com.google.common.collect.Lists; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.stream.Collectors; /** @@ -94,135 +96,154 @@ public class VolunteerServiceImpl implements VolunteerService, ResultDataResolve * @return */ public VolunteerDistributionResultDTO getVolunteerDistribution(String customerId) { - //epmetHeartOpenFeignClient.queryVolunteerPage() + VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO(); + + // 1.==========分页查询出所有志愿者列表========== + + String vcErrorMsg = "【志愿者分布】查询志愿者总数出错"; + VolunteerCommonFormDTO volunteerCountForm = new VolunteerCommonFormDTO(); + volunteerCountForm.setCustomerId(customerId); + Integer volunteerCount = getResultDataOrThrowsException(epmetHeartOpenFeignClient.getVolunteerCount(volunteerCountForm), + ServiceConstant.EPMET_HEART_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + vcErrorMsg, + vcErrorMsg); + + if (volunteerCount == null || volunteerCount == 0) { + // 没得志愿者,直接返回 + return r; + } - // 1.分页查询出所有志愿者列表 - int pageNo = 1; + // 计算页数 int pageSize = 200; + int pageCount = volunteerCount / pageSize; + int lastPageItems = volunteerCount % pageSize; + pageCount = lastPageItems > 0 ? ++pageCount : pageCount; - // 志愿者epmet user id + // 志愿者epmet user id 集合 List volunteerEpmetUserIds = new ArrayList<>(); // 分页查询志愿者的epmet user id - while (true) { - - VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO(); - volunteerForm.setCustomerId(customerId); - volunteerForm.setPageNo(pageNo); - volunteerForm.setPageSize(pageSize); - - String errorMsg = "【志愿者分布】分页查询志愿者列表失败"; - List volunteerPage = getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm), - ServiceConstant.EPMET_HEART_SERVER, - EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), - errorMsg, - errorMsg); - - // 将本页userId添加到总集中去 - volunteerEpmetUserIds.addAll(volunteerPage.stream().map(v -> v.getUserId()).collect(Collectors.toSet())); - - if (volunteerPage.size() < pageSize) { - // 说明是最后一页了 - break; - } - - pageNo++; + List>> volsPageFutures = new ArrayList<>(); + + for (int pageNo = 1 ; pageNo <= pageCount ; pageNo ++) { + + int pageNoTemp = pageNo; + CompletableFuture> future = CompletableFuture.supplyAsync(() -> { + return listVolunteersByPage(customerId, pageNoTemp, pageSize) + .stream() + .map(v -> v.getUserId()) + .collect(Collectors.toSet()); + }); + + volsPageFutures.add(future); } - - VolunteerDistributionResultDTO r = new VolunteerDistributionResultDTO(); - + // 阻塞,等待子线程返回结果,然后添加到志愿者userId集合中去 + for (CompletableFuture> future : volsPageFutures) { + try { + volunteerEpmetUserIds.addAll(future.get()); + } catch (InterruptedException e) { + log.error("【志愿者分布】异步获取志愿者userId列表被中断:{}", ExceptionUtils.getErrorStackTrace(e)); + } catch (ExecutionException e) { + log.error("【志愿者分布】异步获取志愿者userId列表失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + } + log.info("【志愿者分布】查询到志愿者userId公{}个", volunteerEpmetUserIds.size()); - // 2.填充ic居民信息 + // 2.==========异步填充ic居民信息========== + List>> volResiInfoFutures = new ArrayList<>(); + + // 将所有的userId按100固定分割成多个部分,循环用每个部分去查询,然后填充 List> volunteerEpmetUserIdParts = Lists.partition(volunteerEpmetUserIds, 100); - for (List volunteerEpmetUserIdPart : volunteerEpmetUserIdParts) { - List icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart); + for (List volunteerEpmetUserIdPart : volunteerEpmetUserIdParts) { - // 填充志愿者类型 - for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) { - // 将志愿者类型列表字符串,切割放到set中 - Set volunteerTypes = new HashSet(); - String volunteerCategoriesStr = icResiInfo.getVolunteerCategoriesStr(); - - if (StringUtils.isNotEmpty(volunteerCategoriesStr)) { - String[] vTypes = volunteerCategoriesStr.split(","); - if (vTypes != null && vTypes.length > 0) { - volunteerTypes.addAll(Arrays.asList(vTypes)); - } - icResiInfo.setVolunteerCategories(volunteerTypes); - } else { - icResiInfo.setVolunteerCategories(new HashSet<>()); - } + log.info("【志愿者分布】查询ic居民信息,切割后,本组的userId个数:{}", volunteerEpmetUserIdPart.size()); - // 填充建筑坐标 - String msg = "【志愿者分布】查询楼栋信息失败"; - IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()), - ServiceConstant.GOV_ORG_SERVER, - EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + CompletableFuture> future = CompletableFuture.supplyAsync(() -> { + return listIcResiInfosByUserIds(volunteerEpmetUserIdPart); + }); - icResiInfo.setEpmetUserId(icResiInfo.getEpmetUserId()); - icResiInfo.setIcResiUserId(icResiInfo.getIcResiUserId()); - Optional.of(building).ifPresent(b -> { - icResiInfo.setLongitude(b.getLongitude()); - icResiInfo.setLatitude(b.getLatitude()); - }); + volResiInfoFutures.add(future); + } + // 阻塞的,获取各个子线程计算结果 + for (CompletableFuture> volResiInfoFuture : volResiInfoFutures) { + try { + List distributions = volResiInfoFuture.get(); + r.getDistributions().addAll(distributions); + } catch (InterruptedException e) { + log.error("【志愿者分布】异步获取志愿者的居民信息被中断:{}", ExceptionUtils.getErrorStackTrace(e)); + } catch (ExecutionException e) { + log.error("【志愿者分布】异步获取志愿者的居民信息失败:{}", ExceptionUtils.getErrorStackTrace(e)); } - r.getDistributions().addAll(icResiInfos); } - - // 就有代码,稳定之后可以删掉 - //for (String volunteerEpmetUserId : volunteerEpmetUserIds) { - // - // VolunteerDistributionResultDTO.Distribution distribution = new VolunteerDistributionResultDTO.Distribution(); - // - // ResiUserBaseInfoResultDTO userBaseInfo = userBaseInfoDao.selecUserBaseInfoByUserId(volunteerEpmetUserId); - // if (userBaseInfo == null || StringUtils.isBlank(userBaseInfo.getIdNum())){ - // log.warn("getVolunteerDistribution selecUserBaseInfoByUserId return null or idCard is null,volunteerEpmetUserId:{}", volunteerEpmetUserId); - // continue; - // } - // //使用身份证号查询ic resi信息 - // IcResiUserDTO icResiUserInfo = icResiUserDao.selectIdByIdCard(customerId, userBaseInfo.getIdNum(), null); - // if (icResiUserInfo == null) { - // continue; - // } - // - // // 查询志愿者类别 - // List volunteerCategories = icResiUserDao.selectVolunteerByUserId(icResiUserInfo.getId()); - // //if (CollectionUtils.isEmpty(volunteerCategories)) { - // // // 此人没有志愿者信息 - // // continue; - // //} - // - // // 将志愿者类型列表字符串,切割放到set中 - // Set volunteerTypes = new HashSet(); - // for (String vTypesString : volunteerCategories) { - // String[] vTypes = vTypesString.split(","); - // if (vTypes != null && vTypes.length > 0) { - // volunteerTypes.addAll(Arrays.asList(vTypes)); - // } - // } - // - // - // String msg = "【志愿者分布】查询楼栋信息失败"; - // IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiUserInfo.getBuildId()), - // ServiceConstant.GOV_ORG_SERVER, - // EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); - // - // distribution.setVolunteerCategories(volunteerTypes); - // distribution.setEpmetUserId(userBaseInfo.getUserId()); - // distribution.setIcResiUserId(icResiUserInfo.getId()); - // Optional.of(building).ifPresent(b -> { - // distribution.setLongitude(b.getLongitude()); - // distribution.setLatitude(b.getLatitude()); - // }); - // - // r.getDistributions().add(distribution); - //} return r; } + /** + * userId列表批量获取他们对应的志愿者信息 + * @param volunteerEpmetUserIdPart + * @return + */ + private List listIcResiInfosByUserIds(List volunteerEpmetUserIdPart) { + List icResiInfos = icResiUserDao.listIcResiInfosByUserIds(volunteerEpmetUserIdPart); + + // 填充志愿者类型 + for (VolunteerDistributionResultDTO.Distribution icResiInfo : icResiInfos) { + // 将志愿者类型列表字符串,切割放到set中 + Set volunteerTypes = new HashSet(); + String volunteerCategoriesStr = icResiInfo.getVolunteerCategoriesStr(); + + if (StringUtils.isNotEmpty(volunteerCategoriesStr)) { + String[] vTypes = volunteerCategoriesStr.split(","); + if (vTypes != null && vTypes.length > 0) { + volunteerTypes.addAll(Arrays.asList(vTypes)); + } + icResiInfo.setVolunteerCategories(volunteerTypes); + } else { + icResiInfo.setVolunteerCategories(new HashSet<>()); + } + + // 填充建筑坐标 + String msg = "【志愿者分布】查询楼栋信息失败"; + IcBuildingDTO building = getResultDataOrThrowsException(govOrgOpenFeignClient.getBuildingById(icResiInfo.getBuildingId()), + ServiceConstant.GOV_ORG_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), msg, msg); + + icResiInfo.setEpmetUserId(icResiInfo.getEpmetUserId()); + icResiInfo.setIcResiUserId(icResiInfo.getIcResiUserId()); + Optional.of(building).ifPresent(b -> { + icResiInfo.setLongitude(b.getLongitude()); + icResiInfo.setLatitude(b.getLatitude()); + }); + + } + + return icResiInfos; + } + + /** + * 分页查询志愿者列表 + * @param customerId + * @param pageNo + * @param pageSize + * @return + */ + private List listVolunteersByPage(String customerId, Integer pageNo, Integer pageSize) { + VolunteerCommonFormDTO volunteerForm = new VolunteerCommonFormDTO(); + volunteerForm.setCustomerId(customerId); + volunteerForm.setPageNo(pageNo); + volunteerForm.setPageSize(pageSize); + + String errorMsg = "【志愿者分布】分页查询志愿者列表失败"; + return getResultDataOrThrowsException(epmetHeartOpenFeignClient.queryVolunteerPage(volunteerForm), + ServiceConstant.EPMET_HEART_SERVER, + EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), + errorMsg, + errorMsg); + } } From e99b34a4d1725e1fe708083140e2ba553615a8c5 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 30 Dec 2021 18:27:12 +0800 Subject: [PATCH 19/19] =?UTF-8?q?=E5=AD=98=E4=B8=AA=E5=8D=8A=E5=B0=8F?= =?UTF-8?q?=E6=97=B6=E5=90=A7=20=E8=AE=A9=E4=BB=96=E8=BF=9E=E7=BB=AD?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E6=97=B6=20=E5=88=AB=E5=86=8D=E9=80=A0?= =?UTF-8?q?=E6=88=91=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/CustomerAgencyServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index a1024cead5..a6972b1dcc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -1133,7 +1133,7 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl