Browse Source

修改:客户、机关、部门、维度初始化,增加"修改"之后的数据的维度初始化,按照创建时间修改

dev_shibei_match
wxz 5 years ago
parent
commit
ce08601023
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/crm/CustomerDao.java
  2. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerDepartmentDao.java
  3. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/CustomerGridDao.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/org/StatsCustomerAgencyDao.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimAgencyDao.java
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimCustomerDao.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimDepartmentDao.java
  8. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/DimGridDao.java
  9. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java
  10. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/impl/CustomerServiceImpl.java
  11. 129
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/StatsDimServiceImpl.java
  12. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerAgencyService.java
  13. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java
  14. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerGridService.java
  15. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerAgencyServiceImpl.java
  16. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerDepartmentServiceImpl.java
  17. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/impl/CustomerGridServiceImpl.java
  18. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimAgencyService.java
  19. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimCustomerService.java
  20. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimDepartmentService.java
  21. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/DimGridService.java
  22. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java
  23. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java
  24. 22
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java
  25. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java
  26. 23
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/crm/CustomerDao.xml
  27. 20
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml
  28. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerGridDao.xml
  29. 25
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml
  30. 21
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml
  31. 15
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimCustomerDao.xml
  32. 17
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimDepartmentDao.xml
  33. 17
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml

2
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<CustomerEntity> {
List<CustomerEntity> listValidCustomersByCreateTime(
@Param("createTimeFrom") Date createTimeFrom,
@Param("createTimeTo") Date createTimeTo);
List<CustomerEntity> listValidCustomersByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

1
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<CustomerDepartmentEntity>
@Param("createdTimeFrom") Date createdTimeFrom,
@Param("createdTimeTo") Date createdTimeTo);
List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

8
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<CustomerGridEntity> {
* @author zxc
*/
List<GridIdListByCustomerResultDTO> getCustomerGridIdList(@Param("customerId") String customerId, @Param("dateId") String dateId);
/**
* 根据更新时间查询列表
* @param startTime
* @param endTime
* @return
*/
List<CustomerGridEntity> listUpdatedGridsByUpdateTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

2
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<CustomerAgencyEntity> {
List<AgencySubTreeDto> selectAllAgency();
List<AgencySubTreeDto> selectSubAgencyByPid(@Param("pid")String pid);
List<CustomerAgencyEntity> listAgenciesByUpdatedTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}

2
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<DimAgencyEntity> {
String getPidByAgencyId(@Param("agencyId") String agencyId);
DimAgencyEntity getLatestCreatedAgencyDimEntity();
DimAgencyEntity getLatestUpdatedAgencyDimEntity();
}

2
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<DimCustomerEntity> {
void insertOne(DimCustomerEntity dim);
DimCustomerEntity getLatestCreatedDimEntity();
DimCustomerEntity getLatestUpdatedDimEntity();
}

2
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<DimDepartmentEntity> {
List<DimDepartmentEntity> getDepartmentListByCustomerId(@Param("customerId") String customerId);
DimDepartmentEntity getLatestCreatedDimEntity();
DimDepartmentEntity getLatestUpdatedDimEntity();
}

2
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<DimGridEntity> {
* @author zxc
*/
List<SubAgencyIdResultDTO> selectSubAgencyId(@Param("formDTO")List<AgencyDTO> formDTO);
DimGridEntity getLastUpdatedGridDim();
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/crm/CustomerService.java

@ -9,4 +9,5 @@ public interface CustomerService {
List<CustomerEntity> listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo);
List<CustomerEntity> listValidCustomersByUpdatedTime(Date updatedTime, Date initTime);
}

5
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<CustomerEntity> listValidCustomersByCreateTime(Date createTimeFrom, Date createTimeTo) {
return customerDao.listValidCustomersByCreateTime(createTimeFrom, createTimeTo);
}
@Override
public List<CustomerEntity> listValidCustomersByUpdatedTime(Date startTime, Date endTime) {
return customerDao.listValidCustomersByUpdateTime(startTime, endTime);
}
}

129
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<DimGridEntity> newDimGrids = getNewDimGrids();
List<DimGridEntity> changedGrids = getChangedGrids();
dimGridService.initGridDims(newDimGrids, changedGrids);
}
/**
* 初始化新建网格
* @return
*/
public List<DimGridEntity> getNewDimGrids() {
DimGridEntity lastDimEntity = dimGridService.getLastCreatedGridDim();
List<CustomerGridEntity> grids;
Date now = new Date();
@ -65,10 +75,36 @@ public class StatsDimServiceImpl implements StatsDimService {
grids = customerGridService.listGridsByCreateTime(lastInitTime, now);
}
List<DimGridEntity> gridDims = convertCustomerGrid2GridDim(grids, now);
if (!CollectionUtils.isEmpty(gridDims)) {
dimGridService.initGridDims(gridDims);
return convertCustomerGrid2GridDim(grids, now);
}
/**
* 初始化变更的网格
* @return
*/
public List<DimGridEntity> getChangedGrids() {
DimGridEntity lastUpdatedGridDim = dimGridService.getLastUpdatedGridDim();
List<CustomerGridEntity> updatedGrids;
Date now = new Date();
if (lastUpdatedGridDim != null) {
Date lastInitTime = lastUpdatedGridDim.getUpdatedTime();
updatedGrids = customerGridService.listUpdatedGridsByUpdateTime(lastInitTime, now);
ArrayList<DimGridEntity> 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<CustomerAgencyEntity> agencies2Add = listAgencies2Add(now);
List<CustomerAgencyEntity> agencies2Update = listAgencies2Update(now);
dimAgencyService.initAgencyDims(agencies2Add, agencies2Update, now);
}
/**
* 查询需要添加的机关ç
* @return
*/
public List<CustomerAgencyEntity> listAgencies2Add(Date endDate) {
DimAgencyEntity latestCreatedAgencyDim = dimAgencyService.getLatestCreatedAgencyDimEntity();
Date now = new Date();
Date lastInitTime = null;
if (latestCreatedAgencyDim != null) {
lastInitTime = latestCreatedAgencyDim.getCreatedTime();
}
List<CustomerAgencyEntity> agencies = customerAgencyService.listAgenciesByCreateTime(lastInitTime, now);
if (!CollectionUtils.isEmpty(agencies)) {
dimAgencyService.initAgencyDims(agencies, now);
return customerAgencyService.listAgenciesByCreateTime(lastInitTime, endDate);
}
/**
* 查询需要更新的机关
* @return
*/
public List<CustomerAgencyEntity> 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<CustomerEntity> newCustomers = listNewCustomers(now);
List<CustomerEntity> updatedCustomers = listUpdatedCustomers(now);
// System.out.println(666);
dimCustomerService.initCustomerDims(newCustomers, updatedCustomers, now);
}
/**
* 查询新增的客户列表
* @param initTime
* @return
*/
public List<CustomerEntity> listNewCustomers(Date initTime) {
DimCustomerEntity lastCreateDim = dimCustomerService.getLatestCreatedDimEntity();
Date now = new Date();
Date lastInitTime = null;
if (lastCreateDim != null) {
lastInitTime = lastCreateDim.getCreatedTime();
}
List<CustomerEntity> customers = customerService.listValidCustomersByCreateTime(lastInitTime, now);
if (!CollectionUtils.isEmpty(customers)) {
dimCustomerService.initCustomerDims(customers, now);
List<CustomerEntity> customers = customerService.listValidCustomersByCreateTime(lastInitTime, initTime);
return customers;
}
/**
* 查询更新的客户列表
* @param initTime
* @return
*/
public List<CustomerEntity> listUpdatedCustomers(Date initTime) {
DimCustomerEntity lastCreatedDim = dimCustomerService.getLatestUpdatedDimEntity();
if (lastCreatedDim != null) {
// 说明不是首次初始化
List<CustomerEntity> customers = customerService.listValidCustomersByUpdatedTime(lastCreatedDim.getUpdatedTime(), initTime);
return customers;
}
return new ArrayList<>();
}
/**
* 初始化部门维度
*/
@Override
public void initDepartmentDim() {
Date now = new Date();
List<CustomerDepartmentEntity> newDepartments = listNewDepartments(now);
List<CustomerDepartmentEntity> updatedDepartments = listUpdatedDepartments(now);
dimDepartmentService.initDepartmentDims(newDepartments, updatedDepartments, now);
}
public List<CustomerDepartmentEntity> 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<CustomerDepartmentEntity> departments = departmentService.listDepartmentsByCreatedTime(lastInitTime, now);
if (!CollectionUtils.isEmpty(departments)) {
dimDepartmentService.initDepartmentDims(departments, now);
public List<CustomerDepartmentEntity> listUpdatedDepartments(Date initTime) {
DimDepartmentEntity lastUpdatedDeptDim = dimDepartmentService.getLatestUpdatedDimEntity();
if (lastUpdatedDeptDim != null) {
return departmentService.listDepartmentsByUpdatedTime(lastUpdatedDeptDim.getCreatedTime(), initTime);
}
return new ArrayList<>();
}
}

2
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<CustomerAgencyEntity> listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime);
List<CustomerAgencyEntity> listAgenciesByUpdatedTime(Date updatedTime, Date now);
}

2
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<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo);
List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(Date createdTime, Date initTime);
}

8
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<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String dateId);
/**
* 根据更新时间查询变更过的网格列表
* @param lastInitTime
* @param now
* @return
*/
List<CustomerGridEntity> listUpdatedGridsByUpdateTime(Date lastInitTime, Date now);
}

5
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<CustomerAgencyEntity> listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) {
return customerAgencyDao.listAgenciesByCreateTime(statsStartTime, statsEndTime);
}
@Override
public List<CustomerAgencyEntity> listAgenciesByUpdatedTime(Date startTime, Date endTime) {
return customerAgencyDao.listAgenciesByUpdatedTime(startTime, endTime);
}
}

5
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<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo) {
return departmentDao.listDepartmentsByCreatedTime(createdTimeFrom, createdTimeTo);
}
@Override
public List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(Date startTime, Date endTime) {
return departmentDao.listDepartmentsByUpdatedTime(startTime, endTime);
}
}

5
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<GridIdListByCustomerResultDTO> getCustomerGridIdList(String customerId, String dateId) {
return customerGridDao.getCustomerGridIdList(customerId, dateId);
}
@Override
public List<CustomerGridEntity> listUpdatedGridsByUpdateTime(Date lastInitTime, Date now) {
return customerGridDao.listUpdatedGridsByUpdateTime(lastInitTime, now);
}
}

5
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<DimAgencyEntity> {
/**
* 初始化机关维度
* @param agencies
*/
void initAgencyDims(List<CustomerAgencyEntity> agencies, Date initTime);
void initAgencyDims(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update, Date initTime);
/**
* @Description 查询所有机关以及它下级机关的信息
@ -175,4 +174,6 @@ public interface DimAgencyService extends BaseService<DimAgencyEntity> {
String getPidByAgencyId(String agencyId);
DimAgencyEntity getLatestCreatedAgencyDimEntity();
DimAgencyEntity getLatestUpdatedAgencyDimEntity();
}

5
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<DimCustomerEntity> {
/**
* 添加客户维度
* @param customers
*/
void initCustomerDims(List<CustomerEntity> customers, Date initTime);
void initCustomerDims(List<CustomerEntity> newCustomers, List<CustomerEntity> updatedCustomers, Date initTime);
DimCustomerEntity getLatestCreatedDimEntity();
DimCustomerEntity getLatestUpdatedDimEntity();
}

4
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<DimDepartmentEntity> {
*/
void delete(String[] ids);
void initDepartmentDims(List<CustomerDepartmentEntity> departments, Date initTime);
void initDepartmentDims(List<CustomerDepartmentEntity> newDepartments, List<CustomerDepartmentEntity> updatedDepartments, Date initTime);
/**
* desc: 根据客户Id获取 部门数据
@ -108,4 +108,6 @@ public interface DimDepartmentService extends BaseService<DimDepartmentEntity> {
List<DimDepartmentEntity> getDepartmentListByCustomerId(String customerId);
DimDepartmentEntity getLatestCreatedDimEntity();
DimDepartmentEntity getLatestUpdatedDimEntity();
}

5
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<DimGridEntity> {
/**
* 初始化网格维度
* @param gridDims
*/
void initGridDims(List<DimGridEntity> gridDims);
void initGridDims(List<DimGridEntity> newDimGrids, List<DimGridEntity> changedGrids);
/**
* desc: 根据客户Id获取 该客户下所有的网格数据
@ -128,4 +127,6 @@ public interface DimGridService extends BaseService<DimGridEntity> {
* @author zxc
*/
List<SubAgencyIdResultDTO> selectSubAgencyId(List<AgencyDTO> formDTO);
DimGridEntity getLastUpdatedGridDim();
}

22
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<DimAgencyDao, DimAgenc
@Transactional(rollbackFor = Exception.class)
@Override
public void initAgencyDims(List<CustomerAgencyEntity> agencies, Date initTime) {
for (CustomerAgencyEntity agency : agencies) {
public void initAgencyDims(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> 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<DimAgencyDao, DimAgenc
return baseDao.getLatestCreatedAgencyDimEntity();
}
@Override
public DimAgencyEntity getLatestUpdatedAgencyDimEntity() {
return baseDao.getLatestUpdatedAgencyDimEntity();
}
}

22
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimCustomerServiceImpl.java

@ -120,8 +120,9 @@ public class DimCustomerServiceImpl extends BaseServiceImpl<DimCustomerDao, DimC
@Transactional(rollbackFor = Exception.class)
@Override
public void initCustomerDims(List<CustomerEntity> customers, Date initTime) {
for (CustomerEntity customer : customers) {
public void initCustomerDims(List<CustomerEntity> newCustomers, List<CustomerEntity> 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<DimCustomerDao, DimC
dim.setUpdatedTime(initTime);
baseDao.insert(dim);
}
// 更新已存在的客户维度
for (CustomerEntity updatedCustomer : updatedCustomers) {
DimCustomerEntity existsCustomerDim = baseDao.selectById(updatedCustomer.getId());
if (existsCustomerDim != null) {
existsCustomerDim.setCustomerName(updatedCustomer.getCustomerName());
existsCustomerDim.setUpdatedBy(RobotConstant.DIMENSION_ROBOT);
existsCustomerDim.setUpdatedTime(initTime);
baseDao.updateById(existsCustomerDim);
}
}
lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_CUSTOMER);
}
@ -138,4 +151,9 @@ public class DimCustomerServiceImpl extends BaseServiceImpl<DimCustomerDao, DimC
public DimCustomerEntity getLatestCreatedDimEntity() {
return baseDao.getLatestCreatedDimEntity();
}
@Override
public DimCustomerEntity getLatestUpdatedDimEntity() {
return baseDao.getLatestUpdatedDimEntity();
}
}

22
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimDepartmentServiceImpl.java

@ -109,8 +109,9 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl<DimDepartmentDao,
@Transactional(rollbackFor = Exception.class)
@Override
public void initDepartmentDims(List<CustomerDepartmentEntity> departments, Date initTime) {
for (CustomerDepartmentEntity department : departments) {
public void initDepartmentDims(List<CustomerDepartmentEntity> newDepartments, List<CustomerDepartmentEntity> 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<DimDepartmentDao,
dim.setUpdatedTime(initTime);
baseDao.insert(dim);
}
// 修改科室初始化
for (CustomerDepartmentEntity updatedDepartment : updatedDepartments) {
DimDepartmentEntity dimDepartment = baseDao.selectById(updatedDepartment.getId());
if (dimDepartment != null) {
dimDepartment.setDepartmentName(updatedDepartment.getDepartmentName());
dimDepartment.setUpdatedBy(RobotConstant.DIMENSION_ROBOT);
dimDepartment.setUpdatedTime(initTime);
baseDao.updateById(dimDepartment);
}
}
lastExecRecordDao.updateExecTimeBySubject(new Date(), StatsSubject.DIM_DEPARTMENT);
}
@ -137,4 +150,9 @@ public class DimDepartmentServiceImpl extends BaseServiceImpl<DimDepartmentDao,
public DimDepartmentEntity getLatestCreatedDimEntity() {
return baseDao.getLatestCreatedDimEntity();
}
@Override
public DimDepartmentEntity getLatestUpdatedDimEntity() {
return baseDao.getLatestUpdatedDimEntity();
}
}

16
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimGridServiceImpl.java

@ -117,13 +117,16 @@ public class DimGridServiceImpl extends BaseServiceImpl<DimGridDao, DimGridEntit
/**
* 初始化网格维度
* @param gridDims
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void initGridDims(List<DimGridEntity> gridDims) {
for (DimGridEntity gridDim : gridDims) {
baseDao.insert(gridDim);
public void initGridDims(List<DimGridEntity> newDimGrids, List<DimGridEntity> 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<DimGridDao, DimGridEntit
public List<SubAgencyIdResultDTO> selectSubAgencyId(List<AgencyDTO> formDTO) {
return baseDao.selectSubAgencyId(formDTO);
}
@Override
public DimGridEntity getLastUpdatedGridDim() {
return baseDao.getLastUpdatedGridDim();
}
}

23
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
</select>
<select id="listValidCustomersByUpdateTime" resultType="com.epmet.entity.crm.CustomerEntity">
select id,
customer_name,
title,
organization_number,
organization_img,
validity_time,
customer_admin,
customer_password,
organization_levels,
logo,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
organization_level
from customer
where UPDATED_TIME >= #{startTime}
and UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>
</mapper>

20
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/CustomerDepartmentDao.xml

@ -16,4 +16,24 @@
</if>
</where>
</select>
<select id="listDepartmentsByUpdatedTime" resultType="com.epmet.entity.org.CustomerDepartmentEntity">
select
id,
customer_id,
agency_id,
department_name,
department_duty,
total_user,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from customer_department
where UPDATED_TIME > #{startTime}
and UPDATED_TIME <![CDATA[<=]]> #{endTime}
</select>
</mapper>

21
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' ) <![CDATA[ <= ]]> #{dateId}
</select>
<select id="listUpdatedGridsByUpdateTime" resultType="com.epmet.entity.org.CustomerGridEntity">
SELECT id,
customer_id,
grid_name,
longitude,
latitude,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
manage_district,
total_user,
pid,
pids
FROM customer_grid
WHERE UPDATED_TIME >= #{startTime}
AND UPDATED_TIME <![CDATA[<]]> #{endTime}
</select>
</mapper>

25
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/org/StatsCustomerAgencyDao.xml

@ -75,4 +75,29 @@
grid.ID
</select>
<select id="listAgenciesByUpdatedTime" resultType="com.epmet.entity.org.CustomerAgencyEntity">
select
id,
customer_id,
pid,
pids,
all_parent_name,
organization_name,
level,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
total_user,
province,
city,
district
from customer_agency
where UPDATED_TIME >= #{startTime}
and UPDATED_TIME <![CDATA[<=]]> #{endTime}
</select>
</mapper>

21
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimAgencyDao.xml

@ -277,4 +277,25 @@
LIMIT 1
</select>
<!-- 最后一次更新的时间-->
<select id="getLatestUpdatedAgencyDimEntity" resultType="com.epmet.entity.stats.DimAgencyEntity">
select id,
agency_name,
customer_id,
pid,
pids,
all_parent_name,
level,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
agency_dim_type
from dim_agency
order by UPDATED_TIME desc
limit 1
</select>
</mapper>

15
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
</select>
<select id="getLatestUpdatedDimEntity" resultType="com.epmet.entity.stats.DimCustomerEntity">
select
id,
customer_name,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_customer
order by UPDATED_TIME desc
limit 1;
</select>
</mapper>

17
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
</select>
<select id="getLatestUpdatedDimEntity" resultType="com.epmet.entity.stats.DimDepartmentEntity">
select
id,
department_name,
agency_id,
customer_id,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_department
order by UPDATED_TIME desc
limit 1
</select>
</mapper>

17
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/DimGridDao.xml

@ -52,4 +52,21 @@
</foreach>
</select>
<select id="getLastUpdatedGridDim" resultType="com.epmet.entity.stats.DimGridEntity">
select id,
grid_name,
customer_id,
agency_id,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from dim_grid
order by UPDATED_TIME desc
limit 1;
</select>
</mapper>
Loading…
Cancel
Save