From ccb95c5c5c0bb39aa6ce846321b0d2ab0b02f802 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 21 Dec 2021 17:14:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=201.=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E6=BC=8F=E6=8E=89=E7=9A=84=E5=8E=86=E5=8F=B2grid?= =?UTF-8?q?=EF=BC=8Cagency,department=E7=BB=B4=E5=BA=A6=E5=88=B0=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=E8=A1=A8=EF=BC=8C=E6=9F=A5=E6=BC=8F=E8=A1=A5=E7=BC=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/DimController.java | 57 +++++++++++++++++ .../epmet/dao/org/CustomerDepartmentDao.java | 1 + .../com/epmet/dao/org/CustomerGridDao.java | 2 +- .../epmet/dao/org/StatsCustomerAgencyDao.java | 1 + .../com/epmet/service/StatsDimService.java | 18 ++++++ .../epmet/service/impl/EIDimServiceImpl.java | 6 +- .../service/impl/StatsDimServiceImpl.java | 62 +++++++++++++++++-- .../service/org/CustomerAgencyService.java | 9 ++- .../org/CustomerDepartmentService.java | 2 +- .../service/org/CustomerGridService.java | 2 +- .../org/impl/CustomerAgencyServiceImpl.java | 17 ++++- .../impl/CustomerDepartmentServiceImpl.java | 4 +- .../org/impl/CustomerGridServiceImpl.java | 4 +- .../epmet/service/stats/DimAgencyService.java | 21 +++++++ .../service/stats/DimDepartmentService.java | 7 +++ .../epmet/service/stats/DimGridService.java | 8 +++ .../stats/impl/DimAgencyServiceImpl.java | 12 ++++ .../stats/impl/DimDepartmentServiceImpl.java | 11 ++++ .../stats/impl/DimGridServiceImpl.java | 12 ++++ .../mapper/org/CustomerDepartmentDao.xml | 3 + .../resources/mapper/org/CustomerGridDao.xml | 3 + .../mapper/org/StatsCustomerAgencyDao.xml | 3 + 22 files changed, 247 insertions(+), 18 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java index 68dedbd4a0..3f9aa180a6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DimController.java @@ -1,18 +1,26 @@ package com.epmet.controller; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.AgencySubDeptTreeDto; import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.service.StatsDimService; import com.epmet.service.stats.*; +import com.sun.org.apache.xpath.internal.operations.Bool; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.HashMap; import java.util.List; +@Slf4j @RestController @RequestMapping("dim") public class DimController { @@ -272,4 +280,53 @@ public class DimController { return new Result().ok(partyMemberService.statsPartyMember(customerIdAndDateIdFormDTO)); } + /** + * 同步客户相关的维度:agency,department,grid + * 用来补充其他系统传递过来的,旧有的数据 + * @param customerId + * @return + */ + @PostMapping("/customer-related-dims/sync") + public Result syncCustomerRelatedDims(@RequestParam("customer-id") String customerId) { + if (StringUtils.isBlank(customerId)) { + String errorMsg = "【同步客户相关的维度】请传递客户ID"; + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), errorMsg); + } + + boolean syncAgencySuccess = true; + boolean syncGridSuccess = true; + boolean syncDepartmentSuccess = true; + + // 一.同步agency + try { + statsDimService.syncCustomerAgencyDims(customerId); + } catch (Exception e) { + syncAgencySuccess = false; + log.error("【同步客户相关维度】同步agency失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + // 二.同步grid + try { + statsDimService.syncCustomerGridDims(customerId); + } catch (Exception e) { + syncGridSuccess = false; + log.error("【同步客户相关维度】同步grid失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + // 三.同步department + try { + statsDimService.syncCustomerDepartmentDims(customerId); + } catch (Exception e) { + syncDepartmentSuccess = false; + log.error("【同步客户相关维度】同步department失败:{}", ExceptionUtils.getErrorStackTrace(e)); + } + + // 构造结果 + HashMap r = new HashMap<>(); + r.put("syncAgencySuccess", syncAgencySuccess); + r.put("syncGridSuccess", syncGridSuccess); + r.put("syncDepartmentSuccess", syncDepartmentSuccess); + + return new Result().ok(r); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java index 8db5a46efb..a3cb1286a2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java @@ -35,6 +35,7 @@ import java.util.List; public interface CustomerDepartmentDao extends BaseDao { List listDepartmentsByCreatedTime( + @Param("customerId") String customerId, @Param("createdTimeFrom") Date createdTimeFrom, @Param("createdTimeTo") Date createdTimeTo); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java index 688807259e..1677dc8f76 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java @@ -49,7 +49,7 @@ public interface CustomerGridDao extends BaseDao { * @param end * @return */ - List listGridsByCreateTime(@Param("start") Date start, @Param("end") Date end); + List listGridsByCreateTime(@Param("customerId") String customerId, @Param("start") Date start, @Param("end") Date end); /** * @Description 查询机关下的网格总数 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java index a16f40e204..7f2ed28d1e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java @@ -19,6 +19,7 @@ public interface StatsCustomerAgencyDao extends BaseDao { List listAllEntities(); List listAgenciesByCreateTime( + @Param("customerId") String customerId, @Param("statsStartTime") Date statsStartTime, @Param("statsEndTime") Date statsEndTime); List selectAllAgency(); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java index 0bdac4cb04..9e9a37de5a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/StatsDimService.java @@ -12,4 +12,22 @@ public interface StatsDimService { void initDepartmentDim(); void customerInitProjectCategory(); + + /** + * 同步客户的组织维度 + * @param customerId + */ + void syncCustomerAgencyDims(String customerId); + + /** + * 同步客户的网格维度 + * @param customerId + */ + void syncCustomerGridDims(String customerId); + + /** + * 同步客户的部门维度 + * @param customerId + */ + void syncCustomerDepartmentDims(String customerId); } 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 696b6fb221..c67213d6d2 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 @@ -83,7 +83,7 @@ public class EIDimServiceImpl implements EIDimService { startTime = e.getCreatedTime(); } - return originCustomerAgencyService.listAgenciesByCreateTime(startTime, endTime); + return originCustomerAgencyService.listAgenciesByCreateTime(null, startTime, endTime); } @Override @@ -125,7 +125,7 @@ public class EIDimServiceImpl implements EIDimService { startTime = lastAddDept.getCreatedTime(); } - return originCustomerDepartmentService.listDepartmentsByCreatedTime(startTime, endTime); + return originCustomerDepartmentService.listDepartmentsByCreatedTime(null, startTime, endTime); } @Override @@ -179,6 +179,6 @@ public class EIDimServiceImpl implements EIDimService { startTime = lastAddGrid.getCreatedTime(); } - return customerGridService.listGridsByCreateTime(startTime, endTime); + return customerGridService.listGridsByCreateTime(null, startTime, endTime); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java index d81f5afb89..d9081c7c6f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.service.impl; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.RobotConstant; import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; import com.epmet.entity.crm.CustomerEntity; @@ -78,10 +79,10 @@ public class StatsDimServiceImpl implements StatsDimService { Date now = new Date(); if (lastDimEntity == null) { // 首次初始化 - grids = customerGridService.listGridsByCreateTime(null, now); + grids = customerGridService.listGridsByCreateTime(null, null, now); } else { Date lastInitTime = lastDimEntity.getCreatedTime(); - grids = customerGridService.listGridsByCreateTime(lastInitTime, now); + grids = customerGridService.listGridsByCreateTime(null, lastInitTime, now); } return convertCustomerGrid2GridDim(grids, now); @@ -127,7 +128,7 @@ public class StatsDimServiceImpl implements StatsDimService { * @param initTime 创建时间会用来作为下一次查询的输入条件,因此必须和本次初始化查询的endTime一致 * @return */ - private List convertCustomerGrid2GridDim(List grids, Date initTime) { + public List convertCustomerGrid2GridDim(List grids, Date initTime) { return grids.stream().map(grid -> { DimGridEntity dimGrid = new DimGridEntity(); dimGrid.setAgencyId(grid.getPid()); @@ -168,7 +169,7 @@ public class StatsDimServiceImpl implements StatsDimService { lastInitTime = latestCreatedAgencyDim.getCreatedTime(); } - return customerAgencyService.listAgenciesByCreateTime(lastInitTime, endDate); + return customerAgencyService.listAgenciesByCreateTime(null, lastInitTime, endDate); } /** @@ -268,7 +269,7 @@ public class StatsDimServiceImpl implements StatsDimService { if (lastCreatedDeptDim != null) { lastInitTime = lastCreatedDeptDim.getCreatedTime(); } - return departmentService.listDepartmentsByCreatedTime(lastInitTime, now); + return departmentService.listDepartmentsByCreatedTime(null, lastInitTime, now); } public List listUpdatedDepartments(Date initTime) { @@ -321,4 +322,55 @@ public class StatsDimServiceImpl implements StatsDimService { } return new ArrayList<>(); } + + @Override + public void syncCustomerAgencyDims(String customerId) { + // 1.列出现有的agency 维度id列表 + List dimAgencyIds = dimAgencyService.listAgencyIds(customerId); + + // 2.查询业务表的agency列表 + Date endDate = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); + List bizAgencies = customerAgencyService.listAgenciesByCreateTime(customerId, null, endDate); + + // 3.将没有同步过来的插入到dim表。创建和更新时间存为今天凌晨 + for (CustomerAgencyEntity bizAgency : bizAgencies) { + if (!dimAgencyIds.contains(bizAgency.getId())) { + dimAgencyService.initAgencyAllDim(bizAgency, endDate); + dimAgencyService.initAgencySelfDim(bizAgency, endDate); + } + } + } + + @Override + public void syncCustomerGridDims(String customerId) { + // 1.列出现有的grid维度id列表 + List dimGridIds = dimGridService.listGridIds(customerId); + + // 2.查询业务表的grid列表 + // 时间截止到今天凌晨,防止把今天的数据同步过来,影响定时任务查询,漏掉其他客户的数据 + Date endDate = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); + List bizGrids = customerGridService.listGridsByCreateTime(customerId, null, endDate); + + // 3.将没有同步过来的插入到dim表。创建和更新时间存为今天凌晨 + List grids2insert = bizGrids.stream().filter(bg -> !dimGridIds.contains(bg.getId())).collect(Collectors.toList()); + List dimGridEntities = convertCustomerGrid2GridDim(grids2insert, endDate); + + dimGridEntities.forEach(g -> dimGridService.insert(g)); + } + + @Override + public void syncCustomerDepartmentDims(String customerId) { + // 1.列出现有的grid维度id列表 + List dimDeptIds = dimDepartmentService.listDepartmentIds(customerId); + + // 2.查询业务表的grid列表 + // 时间截止到今天凌晨,防止把今天的数据同步过来,影响定时任务查询,漏掉其他客户的数据 + Date endDate = DateUtils.integrate(new Date(), DateUtils.DATE_PATTERN); + List bizDepts = departmentService.listDepartmentsByCreatedTime(customerId, null, endDate); + + List depts2insert = bizDepts.stream().filter(bd -> !dimDeptIds.contains(bd.getId())).collect(Collectors.toList()); + + // 3.将没有同步过来的插入到dim表。创建和更新时间存为今天凌晨 + dimDepartmentService.initDepartmentDims(depts2insert, new ArrayList<>(), endDate); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java index 156b7294a9..4a47055e82 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java @@ -10,7 +10,7 @@ import java.util.Date; import java.util.List; public interface CustomerAgencyService { - List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime); + List listAgenciesByCreateTime(String customerId, Date statsStartTime, Date statsEndTime); List listAgenciesByUpdatedTime(Date updatedTime, Date now); @@ -66,4 +66,11 @@ public interface CustomerAgencyService { * @Description 批量查询客户组织基础信息 **/ List getAgencyBaseInfo(GridBaseInfoFormDTO formDTO); + + /** + * 列出agencyId列表 + * @param customerId + * @return + */ + List listAgencyIds(String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java index f7d5900682..45650a3864 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java @@ -7,7 +7,7 @@ import java.util.List; public interface CustomerDepartmentService { - List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo); + List listDepartmentsByCreatedTime(String customerId, Date createdTimeFrom, Date createdTimeTo); List listDepartmentsByUpdatedTime(Date startTime, Date endTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java index f6131f2906..d4aedd0ba2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java @@ -23,7 +23,7 @@ public interface CustomerGridService extends BaseService { * @return * @Param("start") Date start, @Param("end") Date end */ - List listGridsByCreateTime(Date start, Date end); + List listGridsByCreateTime(String customerId, Date start, Date end); /** * @Description 查询机关下有多少网格 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java index 3e06682b15..af86e32a74 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.service.org.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -25,6 +26,7 @@ import org.springframework.util.StringUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Service @DataSource(DataSourceConstant.GOV_ORG) @@ -40,8 +42,8 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { private CustomerGridService customerGridService; @Override - public List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) { - return customerAgencyDao.listAgenciesByCreateTime(statsStartTime, statsEndTime); + public List listAgenciesByCreateTime(String customerId, Date statsStartTime, Date statsEndTime) { + return customerAgencyDao.listAgenciesByCreateTime(customerId, statsStartTime, statsEndTime); } @Override @@ -283,4 +285,15 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { return customerAgencyDao.getAgencyBaseInfo(formDTO); } + @Override + public List listAgencyIds(String customerId) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(CustomerAgencyEntity::getCustomerId, customerId); + query.select(CustomerAgencyEntity::getId); + + return customerAgencyDao.selectObjs(query) + .stream() + .map(o -> o.toString()) + .collect(Collectors.toList()); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java index 0a7a4e380a..2427d025dc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java @@ -25,8 +25,8 @@ public class CustomerDepartmentServiceImpl implements CustomerDepartmentService * @return */ @Override - public List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) { - return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo); + public List listDepartmentsByCreatedTime(String customerId, Date createdTimeFrom, Date createdTimeTo) { + return departmentDao.listDepartmentsByCreatedTime(customerId, createdTimeFrom, createdTimeTo); } @Override diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java index 76376efd82..956c5990bc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java @@ -34,8 +34,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl listGridsByCreateTime(Date start, Date end) { - return baseDao.listGridsByCreateTime(start, end); + public List listGridsByCreateTime(String customerId, Date start, Date end) { + return baseDao.listGridsByCreateTime(customerId, start, end); } /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java index e22b42c609..47e8ead12d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java @@ -187,4 +187,25 @@ public interface DimAgencyService extends BaseService { * @return java.util.List */ List getAgencyByLevel(String customerId, String level); + + /** + * 查询agency维度已存在的id列表 + * @param customerId + * @return + */ + List listAgencyIds(String customerId); + + /** + * 初始化agency all 维度(all区分于self) + * @param agency + * @param initTime + */ + void initAgencyAllDim(CustomerAgencyEntity agency, Date initTime); + + /** + * 初始化agency self 维度(self区分于all) + * @param agency + * @param initTime + */ + void initAgencySelfDim(CustomerAgencyEntity agency, Date initTime); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java index c1d5478153..3fae407d7c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java @@ -120,4 +120,11 @@ public interface DimDepartmentService extends BaseService { */ List getDistrictDepByCustomer(String customerId); + /** + * 查询部门维度id列表 + * @param customerId + * @return + */ + List listDepartmentIds(String customerId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java index f98f0dd75a..3702b09ceb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java @@ -148,4 +148,12 @@ public interface DimGridService extends BaseService { * @date 2020.09.20 13:01 **/ List getGridAttributes(String customerId,List gridIds); + + /** + * 查询网格维度ID列表 + * @param customerId + * @return + */ + List listGridIds(String customerId); + } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index 99e6ba794c..90c8a46324 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.stats.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -47,6 +48,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 机关维度 @@ -158,6 +160,7 @@ public class DimAgencyServiceImpl extends BaseServiceImpl listAgencyIds(String customerId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(DimAgencyEntity::getCustomerId, customerId); + queryWrapper.select(DimAgencyEntity::getId); + + return baseDao.selectObjs(queryWrapper).stream().map(o -> o.toString()).collect(Collectors.toList()); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java index 28d1026a17..47e474c4aa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.stats.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -43,6 +44,7 @@ import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 客户部门维度 @@ -169,4 +171,13 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl getDistrictDepByCustomer(String customerId) { return baseDao.getDistrictDepByCustomer(customerId); } + + @Override + public List listDepartmentIds(String customerId) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(DimDepartmentEntity::getCustomerId, customerId); + query.select(DimDepartmentEntity::getId); + + return baseDao.selectObjs(query).stream().map(d -> d.toString()).collect(Collectors.toList()); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java index df149feb02..0a0fb86ecf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.stats.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -45,6 +46,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.stream.Collectors; /** * 客户网格维度 @@ -193,4 +195,14 @@ public class DimGridServiceImpl extends BaseServiceImpl listGridIds(String customerId) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(DimGridEntity::getCustomerId, customerId); + query.select(DimGridEntity::getId); + + return baseDao.selectObjs(query).stream().map(o -> o.toString()).collect(Collectors.toList()); + } + } \ 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 0e373b7d3d..1df3ef3a1a 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 @@ -13,6 +13,9 @@ dept.AGENCY_ID = ca.id and ca.DEL_FLAG='0') dept.DEL_FLAG = 0 + + AND dept.CUSTOMER_ID = #{customerId} + AND dept.CREATED_TIME >= #{createdTimeFrom} 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 5b39b9e9a1..587b75120e 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 @@ -10,6 +10,9 @@ DEL_FLAG = 0 AND SYNC_FLAG='1' + + AND CUSTOMER_ID = #{customerId} + AND CREATED_TIME >= #{start} 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 b43eea7bb1..aa337955ad 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 @@ -17,6 +17,9 @@ DEL_FLAG = 0 AND SYNC_FLAG='1' + + AND CUSTOMER_ID = #{customerId} + AND CREATED_TIME >= #{statsStartTime}