From ccb95c5c5c0bb39aa6ce846321b0d2ab0b02f802 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 21 Dec 2021 17:14:22 +0800 Subject: [PATCH 1/4] =?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} From 0bcb12f84236171ae4e1ef84e77c1a9280c52c7a Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 23 Dec 2021 14:02:33 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=20/screen/index?= =?UTF-8?q?/advancedbranchrank=20report/screen/user/partypointrank=20user/?= =?UTF-8?q?userpointrank/withoutpartymember=20=E5=A2=9E=E5=8A=A0customerId?= =?UTF-8?q?=E5=8F=AF=E9=80=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/dto/form/AdvancedBranchRankFormDTO.java | 5 +++++ .../screen/dto/form/PartyPointRankFormDTO.java | 5 +++++ .../screen/dto/form/UserPointRankFormDTO.java | 4 ++++ .../resources/mapper/screen/ScreenIndexDataMonthlyDao.xml | 3 +++ .../resources/mapper/screen/ScreenPartyUserRankDataDao.xml | 6 ++++++ 5 files changed, 23 insertions(+) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AdvancedBranchRankFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AdvancedBranchRankFormDTO.java index a3116f7c96..4c0cc40b42 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AdvancedBranchRankFormDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AdvancedBranchRankFormDTO.java @@ -33,5 +33,10 @@ public class AdvancedBranchRankFormDTO implements Serializable { */ private String areaCode; + /** + * 客户ID + */ + private String customerId; + public interface AddUserInternalGroup {} } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/PartyPointRankFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/PartyPointRankFormDTO.java index a47f3e2cb1..fbca1af11d 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/PartyPointRankFormDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/PartyPointRankFormDTO.java @@ -36,5 +36,10 @@ public class PartyPointRankFormDTO implements Serializable { * */ private String monthId; + /** + * 客户ID + */ + private String customerId; + } diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/UserPointRankFormDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/UserPointRankFormDTO.java index 397f50aa7d..8ab170d826 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/UserPointRankFormDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/UserPointRankFormDTO.java @@ -36,5 +36,9 @@ public class UserPointRankFormDTO implements Serializable { * */ private String monthId; + /** + * 客户ID + */ + private String customerId; } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml index 9da7db0673..b41886353e 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml @@ -261,6 +261,9 @@ dm.del_flag = '0' AND rd.del_flag = '0' + + AND org.CUSTOMER_ID = #{customerId} + AND org.AREA_CODE LIKE concat(#{areaCode}, '%') diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyUserRankDataDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyUserRankDataDao.xml index 4e84fe035c..cdf670c98e 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyUserRankDataDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyUserRankDataDao.xml @@ -171,6 +171,9 @@ AND u.grid_id = #{orgId} + + u.CUSTOMER_ID = #{customerId} + ORDER BY u.point_total DESC,convert(u.user_name using gbk) ASC LIMIT #{topNum} @@ -212,6 +215,9 @@ AND u.grid_id = #{orgId} + + AND u.CUSTOMER_ID = #{customerId} + ORDER BY u.point_total DESC LIMIT #{topNum} From 5efb0bf3e1ad204f785e0d75c1d095532a1ea4c3 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Thu, 23 Dec 2021 14:16:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data-report-server/deploy/docker-compose-prod.yml | 2 +- epmet-module/data-report/data-report-server/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-report/data-report-server/deploy/docker-compose-prod.yml b/epmet-module/data-report/data-report-server/deploy/docker-compose-prod.yml index 0f4b2974ec..b883c42d9f 100644 --- a/epmet-module/data-report/data-report-server/deploy/docker-compose-prod.yml +++ b/epmet-module/data-report/data-report-server/deploy/docker-compose-prod.yml @@ -2,7 +2,7 @@ version: "3.7" services: data-report-server: container_name: data-report-server-prod - image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/data-report-server:0.3.195 + image: registry-vpc.cn-qingdao.aliyuncs.com/epmet-cloud-master/data-report-server:0.3.196 ports: - "8108:8108" network_mode: host # 使用现有网络 diff --git a/epmet-module/data-report/data-report-server/pom.xml b/epmet-module/data-report/data-report-server/pom.xml index 84e5f4d96f..6651fb7c7a 100644 --- a/epmet-module/data-report/data-report-server/pom.xml +++ b/epmet-module/data-report/data-report-server/pom.xml @@ -3,7 +3,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - 0.3.195 + 0.3.196 data-report-server From 4b0264ef65356a21b868e6df855b8ef254b32cd4 Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 23 Dec 2021 14:29:16 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8E=BB=E6=8E=89=20=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E8=B7=9F=E7=BB=84=E7=BB=87=E7=9A=84=E4=B8=AD=E5=BF=83=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/CustomerAgencyDao.xml | 36 +++---------------- 1 file changed, 4 insertions(+), 32 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index eeca702112..4e7660f651 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -315,22 +315,8 @@ agency.ORGANIZATION_NAME AS agencyName, agency.LEVEL AS level, agency.CUSTOMER_ID as customerId, - ( CASE WHEN agency.longitude is null THEN - ( SELECT longitude FROM customer_agency - WHERE del_flag = '0' AND customer_id = (SELECT customer_id FROM customer_agency WHERE id = agency.id) - ORDER BY pid ASC LIMIT 1 - ) - ELSE agency.longitude - END - ) longitude, - ( CASE WHEN agency.latitude is null THEN - ( SELECT latitude FROM customer_agency - WHERE del_flag = '0' AND customer_id = (SELECT customer_id FROM customer_agency WHERE id = agency.id) - ORDER BY pid ASC LIMIT 1 - ) - ELSE agency.latitude - END - ) latitude + agency.longitude, + agency.latitude FROM CUSTOMER_AGENCY agency WHERE @@ -415,22 +401,8 @@ ca.pids pids, ca.pid pid, ca.level level, - ( CASE WHEN ca.longitude is null THEN - ( SELECT longitude FROM customer_agency - WHERE del_flag = '0' AND customer_id = (SELECT customer_id FROM customer_agency WHERE id = ca.id) - ORDER BY pid ASC LIMIT 1 - ) - ELSE ca.longitude - END - ) longitude, - ( CASE WHEN ca.latitude is null THEN - ( SELECT latitude FROM customer_agency - WHERE del_flag = '0' AND customer_id = (SELECT customer_id FROM customer_agency WHERE id = ca.id) - ORDER BY pid ASC LIMIT 1 - ) - ELSE ca.latitude - END - ) latitude + ca.longitude, + ca.latitude FROM customer_agency ca INNER JOIN customer_staff_agency csa ON ca.id = csa.agency_id