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 + * 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} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtAuthProcessor.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtAuthProcessor.java index 7330d1e3ae..b16637127f 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtAuthProcessor.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtAuthProcessor.java @@ -20,6 +20,7 @@ public class ExtAppJwtAuthProcessor extends ExtAppAuthProcessor { @Autowired private ExtAppJwtTokenUtils jwtTokenUtils; + @Override public ExternalAppAuthResultDTO auth(String appId, String token, Long ts) { String secret; if (StringUtils.isBlank(secret = getTokenByAppId(appId))) { diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index cf8bd2ffc6..0598e6e43d 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -266,6 +266,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe * @author wxz * @date 2021.08.30 17:12:15 */ + @Override public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input) { List platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN); platforms.stream().forEach(p -> { 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..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 @@ -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; @@ -52,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; @@ -226,7 +228,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 +239,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 +284,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()) { //差集 @@ -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 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/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index 9ec1029422..4c1344b816 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 @@ -2871,7 +2871,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()); 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 3f7252aab5..f6a2f2b5b2 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 @@ -273,6 +273,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/PatrolRoutineWorkServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java index f431272c8e..5512389278 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/PatrolRoutineWorkServiceImpl.java @@ -107,8 +107,8 @@ public class PatrolRoutineWorkServiceImpl extends BaseServiceImpl> mapResult = adminOpenFeignClient.dictTree(DictTypeEnum.PATROL_WORK_TYPE.getCode()); 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 218784f968..3df76059d4 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, String agencyId) { // 1.查询分布