diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java index bfe699c25e..f3618f4e06 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java @@ -43,4 +43,6 @@ public interface CustomerDao extends BaseDao { List listValidCustomersByCreateTime( @Param("createTimeFrom") Date createTimeFrom, @Param("createTimeTo") Date createTimeTo); + + List listValidCustomersByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } 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 2b9b4705ab..8db5a46efb 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 @@ -38,4 +38,5 @@ public interface CustomerDepartmentDao extends BaseDao @Param("createdTimeFrom") Date createdTimeFrom, @Param("createdTimeTo") Date createdTimeTo); + List listDepartmentsByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } \ No newline at end of file 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 faccf553a2..9f26b8b98d 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 @@ -59,4 +59,12 @@ public interface CustomerGridDao extends BaseDao { * @author zxc */ List getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * 根据更新时间查询列表 + * @param startTime + * @param endTime + * @return + */ + List listUpdatedGridsByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } \ No newline at end of file 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 b3de9cfd02..eb02051e91 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 @@ -20,4 +20,6 @@ public interface StatsCustomerAgencyDao extends BaseDao { List selectAllAgency(); List selectSubAgencyByPid(@Param("pid")String pid); + + List listAgenciesByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java index 419a54ef2c..8788232a7b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java @@ -124,4 +124,6 @@ public interface DimAgencyDao extends BaseDao { String getPidByAgencyId(@Param("agencyId") String agencyId); DimAgencyEntity getLatestCreatedAgencyDimEntity(); + + DimAgencyEntity getLatestUpdatedAgencyDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java index 1834b73ffc..8bd2c3cf8d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java @@ -47,4 +47,6 @@ public interface DimCustomerDao extends BaseDao { void insertOne(DimCustomerEntity dim); DimCustomerEntity getLatestCreatedDimEntity(); + + DimCustomerEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java index 5098869983..0b58bc2220 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java @@ -42,4 +42,6 @@ public interface DimDepartmentDao extends BaseDao { List getDepartmentListByCustomerId(@Param("customerId") String customerId); DimDepartmentEntity getLatestCreatedDimEntity(); + + DimDepartmentEntity getLatestUpdatedDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java index 669e8a08a0..c1671131b1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java @@ -58,4 +58,6 @@ public interface DimGridDao extends BaseDao { * @author zxc */ List selectSubAgencyId(@Param("formDTO")List formDTO); + + DimGridEntity getLastUpdatedGridDim(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java index e562a08365..dbc2cc03f9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java @@ -9,4 +9,5 @@ public interface CustomerService { List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo); + List listValidCustomersByUpdatedTime(Date updatedTime, Date initTime); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java index 3db2f197bd..056df4e50e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java @@ -22,4 +22,9 @@ public class CustomerServiceImpl implements CustomerService { public List listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) { return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo); } + + @Override + public List listValidCustomersByUpdatedTime(Date startTime, Date endTime) { + return customerDao.listValidCustomersByUpdateTime(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 dde7d9f14e..5c09458416 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,8 +1,6 @@ package com.epmet.service.impl; -import com.epmet.commons.tools.utils.DateUtils; import com.epmet.constant.RobotConstant; -import com.epmet.constant.StatsSubject; import com.epmet.entity.crm.CustomerEntity; import com.epmet.entity.org.CustomerAgencyEntity; import com.epmet.entity.org.CustomerDepartmentEntity; @@ -18,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -54,6 +53,17 @@ public class StatsDimServiceImpl implements StatsDimService { @Override public void initGridDim() { + List newDimGrids = getNewDimGrids(); + List changedGrids = getChangedGrids(); + + dimGridService.initGridDims(newDimGrids, changedGrids); + } + + /** + * 初始化新建网格 + * @return + */ + public List getNewDimGrids() { DimGridEntity lastDimEntity = dimGridService.getLastCreatedGridDim(); List grids; Date now = new Date(); @@ -65,10 +75,36 @@ public class StatsDimServiceImpl implements StatsDimService { grids = customerGridService.listGridsByCreateTime(lastInitTime, now); } - List gridDims = convertCustomerGrid2GridDim(grids, now); - if (!CollectionUtils.isEmpty(gridDims)) { - dimGridService.initGridDims(gridDims); + return convertCustomerGrid2GridDim(grids, now); + } + + /** + * 初始化变更的网格 + * @return + */ + public List getChangedGrids() { + DimGridEntity lastUpdatedGridDim = dimGridService.getLastUpdatedGridDim(); + + List updatedGrids; + Date now = new Date(); + if (lastUpdatedGridDim != null) { + Date lastInitTime = lastUpdatedGridDim.getUpdatedTime(); + updatedGrids = customerGridService.listUpdatedGridsByUpdateTime(lastInitTime, now); + ArrayList dimGrids = new ArrayList<>(); + for (CustomerGridEntity updatedGrid : updatedGrids) { + DimGridEntity dimGrid = dimGridService.selectById(updatedGrid.getId()); + if (dimGrid != null) { + dimGrid.setGridName(updatedGrid.getGridName()); + dimGrid.setUpdatedTime(now); + dimGrid.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); + dimGrids.add(dimGrid); + } + } + + return dimGrids; } + + return new ArrayList<>(); } /** @@ -98,19 +134,41 @@ public class StatsDimServiceImpl implements StatsDimService { */ @Override public void initAgencyDim() { + Date now = new Date(); + List agencies2Add = listAgencies2Add(now); + List agencies2Update = listAgencies2Update(now); + dimAgencyService.initAgencyDims(agencies2Add, agencies2Update, now); + } + + /** + * 查询需要添加的机关ç + * @return + */ + public List listAgencies2Add(Date endDate) { DimAgencyEntity latestCreatedAgencyDim = dimAgencyService.getLatestCreatedAgencyDimEntity(); - Date now = new Date(); Date lastInitTime = null; if (latestCreatedAgencyDim != null) { lastInitTime = latestCreatedAgencyDim.getCreatedTime(); } - List agencies = customerAgencyService.listAgenciesByCreateTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(agencies)) { - dimAgencyService.initAgencyDims(agencies, now); + return customerAgencyService.listAgenciesByCreateTime(lastInitTime, endDate); + } + + /** + * 查询需要更新的机关 + * @return + */ + public List listAgencies2Update(Date endDate) { + DimAgencyEntity latestUpdatedAgencyDim = dimAgencyService.getLatestUpdatedAgencyDimEntity(); + + if (latestUpdatedAgencyDim != null) { + // 不是首次初始化,可以更新 + Date updatedTime = latestUpdatedAgencyDim.getUpdatedTime(); + return customerAgencyService.listAgenciesByUpdatedTime(updatedTime, endDate); } + return new ArrayList<>(); } /** @@ -118,24 +176,59 @@ public class StatsDimServiceImpl implements StatsDimService { */ @Override public void initCustomerDim() { + Date now = new Date(); + List newCustomers = listNewCustomers(now); + List updatedCustomers = listUpdatedCustomers(now); +// System.out.println(666); + dimCustomerService.initCustomerDims(newCustomers, updatedCustomers, now); + } + + /** + * 查询新增的客户列表 + * @param initTime + * @return + */ + public List listNewCustomers(Date initTime) { DimCustomerEntity lastCreateDim = dimCustomerService.getLatestCreatedDimEntity(); - Date now = new Date(); Date lastInitTime = null; if (lastCreateDim != null) { lastInitTime = lastCreateDim.getCreatedTime(); } - List customers = customerService.listValidCustomersByCreateTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(customers)) { - dimCustomerService.initCustomerDims(customers, now); + List customers = customerService.listValidCustomersByCreateTime(lastInitTime, initTime); + + return customers; + } + + /** + * 查询更新的客户列表 + * @param initTime + * @return + */ + public List listUpdatedCustomers(Date initTime) { + DimCustomerEntity lastCreatedDim = dimCustomerService.getLatestUpdatedDimEntity(); + if (lastCreatedDim != null) { + // 说明不是首次初始化 + List customers = customerService.listValidCustomersByUpdatedTime(lastCreatedDim.getUpdatedTime(), initTime); + return customers; } + return new ArrayList<>(); } + /** + * 初始化部门维度 + */ @Override public void initDepartmentDim() { + Date now = new Date(); + List newDepartments = listNewDepartments(now); + List updatedDepartments = listUpdatedDepartments(now); + dimDepartmentService.initDepartmentDims(newDepartments, updatedDepartments, now); + } + public List listNewDepartments(Date initTime) { DimDepartmentEntity lastCreatedDeptDim = dimDepartmentService.getLatestCreatedDimEntity(); Date now = new Date(); @@ -144,10 +237,14 @@ public class StatsDimServiceImpl implements StatsDimService { if (lastCreatedDeptDim != null) { lastInitTime = lastCreatedDeptDim.getCreatedTime(); } + return departmentService.listDepartmentsByCreatedTime(lastInitTime, now); + } - List departments = departmentService.listDepartmentsByCreatedTime(lastInitTime, now); - if (!CollectionUtils.isEmpty(departments)) { - dimDepartmentService.initDepartmentDims(departments, now); + public List listUpdatedDepartments(Date initTime) { + DimDepartmentEntity lastUpdatedDeptDim = dimDepartmentService.getLatestUpdatedDimEntity(); + if (lastUpdatedDeptDim != null) { + return departmentService.listDepartmentsByUpdatedTime(lastUpdatedDeptDim.getCreatedTime(), initTime); } + return new ArrayList<>(); } } 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 034499e955..96669f2ae9 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 @@ -7,4 +7,6 @@ import java.util.List; public interface CustomerAgencyService { List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime); + + List listAgenciesByUpdatedTime(Date updatedTime, Date now); } 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 1aa2c2f7db..15178715ed 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 @@ -8,4 +8,6 @@ import java.util.List; public interface CustomerDepartmentService { List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo); + + List listDepartmentsByUpdatedTime(Date createdTime, Date initTime); } 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 00b46e8b75..b2b7a5b129 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 @@ -32,4 +32,12 @@ public interface CustomerGridService { * @author zxc */ List getCustomerGridIdList(String customerId, String dateId); + + /** + * 根据更新时间查询变更过的网格列表 + * @param lastInitTime + * @param now + * @return + */ + List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now); } 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 2912ca0cca..4813309176 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 @@ -22,4 +22,9 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { public List listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) { return customerAgencyDao.listAgenciesByCreateTime(statsStartTime, statsEndTime); } + + @Override + public List listAgenciesByUpdatedTime(Date startTime, Date endTime) { + return customerAgencyDao.listAgenciesByUpdatedTime(startTime, endTime); + } } 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 ac430a3abd..0a7a4e380a 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 @@ -28,4 +28,9 @@ public class CustomerDepartmentServiceImpl implements CustomerDepartmentService public List listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) { return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo); } + + @Override + public List listDepartmentsByUpdatedTime(Date startTime, Date endTime) { + return departmentDao.listDepartmentsByUpdatedTime(startTime, endTime); + } } 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 fc95a3de29..5bab5596a7 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 @@ -46,4 +46,9 @@ public class CustomerGridServiceImpl implements CustomerGridService { public List getCustomerGridIdList(String customerId, String dateId) { return customerGridDao.getCustomerGridIdList(customerId, dateId); } + + @Override + public List listUpdatedGridsByUpdateTime(Date lastInitTime, Date now) { + return customerGridDao.listUpdatedGridsByUpdateTime(lastInitTime, now); + } } 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 df58489fd0..aad2cae314 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 @@ -107,9 +107,8 @@ public interface DimAgencyService extends BaseService { /** * 初始化机关维度 - * @param agencies */ - void initAgencyDims(List agencies, Date initTime); + void initAgencyDims(List agencies2Add, List agencies2Update, Date initTime); /** * @Description 查询所有机关以及它下级机关的信息 @@ -175,4 +174,6 @@ public interface DimAgencyService extends BaseService { String getPidByAgencyId(String agencyId); DimAgencyEntity getLatestCreatedAgencyDimEntity(); + + DimAgencyEntity getLatestUpdatedAgencyDimEntity(); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java index d3562d01db..9d53593957 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java @@ -110,9 +110,10 @@ public interface DimCustomerService extends BaseService { /** * 添加客户维度 - * @param customers */ - void initCustomerDims(List customers, Date initTime); + void initCustomerDims(List newCustomers, List updatedCustomers, Date initTime); DimCustomerEntity getLatestCreatedDimEntity(); + + DimCustomerEntity getLatestUpdatedDimEntity(); } \ 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 fe839ac0c9..767d5b8ffe 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 @@ -95,7 +95,7 @@ public interface DimDepartmentService extends BaseService { */ void delete(String[] ids); - void initDepartmentDims(List departments, Date initTime); + void initDepartmentDims(List newDepartments, List updatedDepartments, Date initTime); /** * desc: 根据客户Id获取 部门数据 @@ -108,4 +108,6 @@ public interface DimDepartmentService extends BaseService { List getDepartmentListByCustomerId(String customerId); DimDepartmentEntity getLatestCreatedDimEntity(); + + DimDepartmentEntity getLatestUpdatedDimEntity(); } \ 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 312659eb96..b937efdf9e 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 @@ -101,9 +101,8 @@ public interface DimGridService extends BaseService { /** * 初始化网格维度 - * @param gridDims */ - void initGridDims(List gridDims); + void initGridDims(List newDimGrids, List changedGrids); /** * desc: 根据客户Id获取 该客户下所有的网格数据 @@ -128,4 +127,6 @@ public interface DimGridService extends BaseService { * @author zxc */ List selectSubAgencyId(List formDTO); + + DimGridEntity getLastUpdatedGridDim(); } \ 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 0d21b5525f..d40987c1bc 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 @@ -123,12 +123,25 @@ public class DimAgencyServiceImpl extends BaseServiceImpl agencies, Date initTime) { - for (CustomerAgencyEntity agency : agencies) { + public void initAgencyDims(List agencies2Add, List agencies2Update, Date initTime) { + // 添加新增的机关维度 + for (CustomerAgencyEntity agency : agencies2Add) { initAgencyAllDim(agency, initTime); initAgencySelfDim(agency, initTime); } + // 更新变更过的机关维度 + for (CustomerAgencyEntity agency : agencies2Update) { + DimAgencyEntity existsDimAgency = baseDao.selectById(agency.getId()); + if (existsDimAgency != null) { + //说明是已存在的,不是新增的 + existsDimAgency.setAgencyName(agency.getOrganizationName()); + existsDimAgency.setUpdatedTime(initTime); + existsDimAgency.setUpdatedBy(RobotConstant.DIMENSION_ROBOT); + baseDao.updateById(existsDimAgency); + } + } + lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_AGENCY); } @@ -255,4 +268,9 @@ public class DimAgencyServiceImpl extends BaseServiceImpl customers, Date initTime) { - for (CustomerEntity customer : customers) { + public void initCustomerDims(List newCustomers, List updatedCustomers, Date initTime) { + // 添加新增的客户维度 + for (CustomerEntity customer : newCustomers) { DimCustomerEntity dim = new DimCustomerEntity(); dim.setCustomerName(customer.getCustomerName()); dim.setCreatedBy(RobotConstant.DIMENSION_ROBOT); @@ -131,6 +132,18 @@ public class DimCustomerServiceImpl extends BaseServiceImpl departments, Date initTime) { - for (CustomerDepartmentEntity department : departments) { + public void initDepartmentDims(List newDepartments, List updatedDepartments, Date initTime) { + // 新增科室初始化 + for (CustomerDepartmentEntity department : newDepartments) { DimDepartmentEntity dim = new DimDepartmentEntity(); dim.setAgencyId(department.getAgencyId()); dim.setCustomerId(department.getCustomerId()); @@ -122,6 +123,18 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl gridDims) { - for (DimGridEntity gridDim : gridDims) { - baseDao.insert(gridDim); + public void initGridDims(List newDimGrids, List changedGrids) { + for (DimGridEntity newGridDim : newDimGrids) { + baseDao.insert(newGridDim); + } + + for (DimGridEntity updatedGridDim : changedGrids) { + baseDao.updateById(updatedGridDim); } lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_GRID); @@ -156,4 +159,9 @@ public class DimGridServiceImpl extends BaseServiceImpl selectSubAgencyId(List formDTO) { return baseDao.selectSubAgencyId(formDTO); } + + @Override + public DimGridEntity getLastUpdatedGridDim() { + return baseDao.getLastUpdatedGridDim(); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml index 0aac258069..382edefac3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml @@ -41,4 +41,27 @@ CONVERT ( c.CUSTOMER_NAME USING gbk ) ASC + + 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 6d3bc43ce3..365ae56b8a 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 @@ -16,4 +16,24 @@ + + + \ 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 6a5253e473..48c5176a78 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 @@ -47,4 +47,25 @@ AND customer_id = #{customerId} AND DATE_FORMAT( created_time, '%Y%m%d' ) #{dateId} + \ No newline at end of file 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 3e22e1b5c3..268782eb3d 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 @@ -75,4 +75,29 @@ grid.ID + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml index 74c52efaa6..dedf82d8fe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml @@ -277,4 +277,25 @@ LIMIT 1 + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml index 7b8ad49e3c..13bc6a3e01 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml @@ -25,4 +25,19 @@ ORDER BY CREATED_TIME DESC LIMIT 1 + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml index 68de10bef6..4f0a68ed28 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml @@ -35,4 +35,21 @@ ORDER BY CREATED_TIME DESC LIMIT 1 + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml index 783230dc55..eef43456f7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml @@ -52,4 +52,21 @@ + + \ No newline at end of file