Browse Source

新增:index库的screen_customer_agency,screen_customer_dept,screen_customer_grid的初始化

dev_shibei_match
wxz 5 years ago
parent
commit
56e386fe3f
  1. 11
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/OrgSourceTypeConstant.java
  2. 48
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/EIDimController.java
  3. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  4. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java
  5. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java
  8. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java
  9. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/EIDimService.java
  10. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java
  11. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerDeptService.java
  12. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java
  13. 73
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java
  14. 55
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerDeptServiceImpl.java
  15. 55
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java
  16. 155
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java
  17. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java
  18. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.4__screen_org_add_source_col.sql
  19. 81
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  20. 72
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml
  21. 72
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml

11
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/OrgSourceTypeConstant.java

@ -0,0 +1,11 @@
package com.epmet.constant;
public interface OrgSourceTypeConstant {
// 外部
String EXTERNAL = "external";
// 内部
String INTERNAL = "internal";
}

48
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/EIDimController.java

@ -0,0 +1,48 @@
package com.epmet.controller;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.service.EIDimService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* epmet_evaluation_index库的维度controller
*/
@RestController
@RequestMapping("eidim")
public class EIDimController {
Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private EIDimService eiDimService;
@PostMapping("init-all")
public Result initAll() {
try {
//eiDimService.initAgencies();
} catch (Exception e) {
logger.error("初始化epmet_evaluation_index的agency维度失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
try {
//eiDimService.initDepartments();
} catch (Exception e) {
logger.error("初始化epmet_evaluation_index的department维度失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
try {
eiDimService.initGrids();
} catch (Exception e) {
logger.error("初始化epmet_evaluation_index的grids维度失败:{}", ExceptionUtils.getErrorStackTrace(e));
}
return new Result();
}
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -119,4 +119,10 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @date 2020/9/22 4:48 下午
*/
List<TreeResultDTO> selectSubAgencyList(@Param("pids") String pids);
ScreenCustomerAgencyEntity getLastAddedAgency();
ScreenCustomerAgencyEntity getLastUpdatedAgency();
ScreenCustomerAgencyEntity selectByAgencyId(String agencyId);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java

@ -86,4 +86,14 @@ public interface ScreenCustomerDeptDao extends BaseDao<ScreenCustomerDeptEntity>
* @Date 16:57 2020-09-03
**/
List<ScreenCustomerDeptEntity> selectListDeptInfo(@Param("customerId")String customerId);
/**
* 查询最后一次添加的部门
* @return
*/
ScreenCustomerDeptEntity getLastAddDept();
ScreenCustomerDeptEntity getLastUpdateDept();
ScreenCustomerDeptEntity selectByDeptId(String deptId);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java

@ -122,4 +122,10 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
* @date 2020/9/22 2:16 下午
*/
List<String> selectGridIdByAgencyId(@Param("agencyId")String agencyId);
ScreenCustomerGridEntity getLastAddGrid();
ScreenCustomerGridEntity getLastUpdateGrid();
ScreenCustomerGridEntity getByGridId(String gridId);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerAgencyEntity.java

@ -93,6 +93,8 @@ public class ScreenCustomerAgencyEntity extends BaseEpmetEntity {
*/
private String areaCode;
private String sourceType;
/**
* 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增)
*/

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerDeptEntity.java

@ -75,4 +75,6 @@ public class ScreenCustomerDeptEntity extends BaseEpmetEntity {
*/
private String dataEndTime;
private String sourceType;
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenCustomerGridEntity.java

@ -79,4 +79,6 @@ public class ScreenCustomerGridEntity extends BaseEpmetEntity {
* 所有上级ID用英文逗号分开(8.26新增)
*/
private String allParentIds;
private String sourceType;
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/EIDimService.java

@ -0,0 +1,13 @@
package com.epmet.service;
import org.springframework.stereotype.Service;
/**
* epmet_evaluation_index 维度的service
*/
@Service
public interface EIDimService {
void initAgencies();
void initDepartments();
void initGrids();
}

9
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerAgencyService.java

@ -17,6 +17,10 @@
package com.epmet.service.evaluationindex.screen;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import java.util.List;
import java.util.Map;
/**
@ -38,4 +42,9 @@ public interface ScreenCustomerAgencyService{
*/
Map<String,Object> selectAllSubAgencyId(String agencyId, String customerId);
ScreenCustomerAgencyEntity getLastAddedAgency();
ScreenCustomerAgencyEntity getLastUpdatedAgency();
void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update);
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerDeptService.java

@ -19,6 +19,9 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
import java.util.List;
/**
* 部门信息
@ -28,4 +31,14 @@ import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
*/
public interface ScreenCustomerDeptService extends BaseService<ScreenCustomerDeptEntity> {
/**
* 最后一次添加的部门
* @return
*/
ScreenCustomerDeptEntity getLastAddDept();
ScreenCustomerDeptEntity getLastUpdateDept();
void addAndUpdateDepartments(List<CustomerDepartmentEntity> depts2Add, List<CustomerDepartmentEntity> depts2Update);
}

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCustomerGridService.java

@ -20,6 +20,9 @@ package com.epmet.service.evaluationindex.screen;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
import java.util.List;
/**
* 网格(党支部)信息
@ -29,4 +32,8 @@ import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
*/
public interface ScreenCustomerGridService extends BaseService<ScreenCustomerGridEntity> {
ScreenCustomerGridEntity getLastAddGrid();
ScreenCustomerGridEntity getLastUpdateGrid();
void addAndUpdateGrids(List<CustomerGridEntity> grids2Add, List<CustomerGridEntity> grids2Update);
}

73
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerAgencyServiceImpl.java

@ -18,20 +18,22 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.screen.result.TreeResultDTO;
import com.epmet.constant.ScreenConstant;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 组织机构信息
@ -86,4 +88,67 @@ public class ScreenCustomerAgencyServiceImpl implements ScreenCustomerAgencyServ
}
return result;
}
@Override
public ScreenCustomerAgencyEntity getLastAddedAgency() {
return screenCustomerAgencyDao.getLastAddedAgency();
}
@Override
public ScreenCustomerAgencyEntity getLastUpdatedAgency() {
return screenCustomerAgencyDao.getLastUpdatedAgency();
}
@Transactional(rollbackFor = Exception.class)
@Override
public void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update) {
String dateEndTime = DateUtils.format(new Date(), "YYYYmmdd");
if (!CollectionUtils.isEmpty(agencies2Add)) {
// 添加
for (CustomerAgencyEntity e : agencies2Add) {
addAgency(e, dateEndTime);
}
}
if (!CollectionUtils.isEmpty(agencies2Update)) {
// 更新
for (CustomerAgencyEntity e : agencies2Update) {
ScreenCustomerAgencyEntity exists = screenCustomerAgencyDao.selectByAgencyId(e.getId());
if (exists != null) {
exists.setAgencyName(e.getOrganizationName());
exists.setPids(e.getPids());
exists.setPid(e.getPid());
exists.setLevel(e.getLevel());
exists.setDataEndTime(dateEndTime);
exists.setAreaCode(e.getAreaCode());
exists.setAllParentNames(e.getAllParentName());
updateAgency(exists);
}
}
}
}
private void updateAgency(ScreenCustomerAgencyEntity exists) {
screenCustomerAgencyDao.updateById(exists);
}
/**
* 添加agency
* @param e
*/
private void addAgency(CustomerAgencyEntity e, String dateEndTime) {
ScreenCustomerAgencyEntity cae = new ScreenCustomerAgencyEntity();
cae.setAgencyId(e.getId());
cae.setAgencyName(e.getOrganizationName());
cae.setAllParentNames(e.getAllParentName());
cae.setAreaCode(e.getAreaCode());
//cae.setAreaMarks(e);
cae.setCustomerId(e.getCustomerId());
cae.setDataEndTime(dateEndTime);
cae.setLevel(e.getLevel());
cae.setPid(e.getPid());
cae.setPids(e.getPids());
cae.setSourceType(OrgSourceTypeConstant.INTERNAL);
screenCustomerAgencyDao.insert(cae);
}
}

55
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerDeptServiceImpl.java

@ -18,10 +18,18 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerDeptDao;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* 部门信息
@ -32,5 +40,52 @@ import org.springframework.stereotype.Service;
@Service
public class ScreenCustomerDeptServiceImpl extends BaseServiceImpl<ScreenCustomerDeptDao, ScreenCustomerDeptEntity> implements ScreenCustomerDeptService {
@Autowired
private ScreenCustomerDeptDao screenCustomerDeptDao;
@Override
public ScreenCustomerDeptEntity getLastAddDept() {
return screenCustomerDeptDao.getLastAddDept();
}
@Override
public ScreenCustomerDeptEntity getLastUpdateDept() {
return screenCustomerDeptDao.getLastUpdateDept();
}
/**
* 添加/更新部门列表
* @param depts2Add
* @param depts2Update
*/
@Transactional(rollbackFor = Exception.class)
public void addAndUpdateDepartments(List<CustomerDepartmentEntity> depts2Add, List<CustomerDepartmentEntity> depts2Update) {
String dateStr = DateUtils.format(new Date(), "YYYYmmdd");
for (CustomerDepartmentEntity dept : depts2Add) {
ScreenCustomerDeptEntity e = screenCustomerDeptDao.selectByDeptId(dept.getId());
if (e == null) {
e = new ScreenCustomerDeptEntity();
e.setCustomerId(dept.getCustomerId());
e.setDataEndTime(dateStr);
e.setDeptId(dept.getId());
e.setDeptName(dept.getDepartmentName());
e.setParentAgencyId(dept.getAgencyId());
e.setSourceType(OrgSourceTypeConstant.INTERNAL);
screenCustomerDeptDao.insert(e);
}
}
for (CustomerDepartmentEntity dept : depts2Update) {
ScreenCustomerDeptEntity e = screenCustomerDeptDao.selectByDeptId(dept.getId());
if (e != null) {
// 不是新增的
e.setParentAgencyId(dept.getAgencyId());
e.setDeptName(dept.getDepartmentName());
e.setDataEndTime(dateStr);
e.setCustomerId(dept.getCustomerId());
screenCustomerDeptDao.updateById(e);
}
}
}
}

55
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCustomerGridServiceImpl.java

@ -18,11 +18,21 @@
package com.epmet.service.evaluationindex.screen.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgSourceTypeConstant;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
/**
* 网格(党支部)信息
@ -30,8 +40,53 @@ import org.springframework.stereotype.Service;
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-22
*/
@DataSource(DataSourceConstant.EVALUATION_INDEX)
@Service
public class ScreenCustomerGridServiceImpl extends BaseServiceImpl<ScreenCustomerGridDao, ScreenCustomerGridEntity> implements ScreenCustomerGridService {
@Autowired
private ScreenCustomerGridDao screenCustomerGridDao;
@Override
public ScreenCustomerGridEntity getLastAddGrid() {
return screenCustomerGridDao.getLastAddGrid();
}
@Override
public ScreenCustomerGridEntity getLastUpdateGrid() {
return screenCustomerGridDao.getLastUpdateGrid();
}
@Transactional(rollbackFor = Exception.class)
@Override
public void addAndUpdateGrids(List<CustomerGridEntity> grids2Add, List<CustomerGridEntity> grids2Update) {
String dateStr = DateUtils.format(new Date(), "YYYYmmdd");
for (CustomerGridEntity grid : grids2Add) {
ScreenCustomerGridEntity screenGrid = screenCustomerGridDao.getByGridId(grid.getId());
if (screenGrid == null) {
ScreenCustomerGridEntity insertOne = new ScreenCustomerGridEntity();
insertOne.setAllParentIds(grid.getPids());
insertOne.setCustomerId(grid.getCustomerId());
insertOne.setDataEndTime(dateStr);
insertOne.setGridId(grid.getId());
insertOne.setGridName(grid.getGridName());
insertOne.setParentAgencyId(grid.getPid());
insertOne.setSourceType(OrgSourceTypeConstant.INTERNAL);
screenCustomerGridDao.insert(insertOne);
}
}
for (CustomerGridEntity grid : grids2Update) {
ScreenCustomerGridEntity screenGrid = screenCustomerGridDao.getByGridId(grid.getId());
if (screenGrid != null) {
//说明之前已经插入了该数据
screenGrid.setParentAgencyId(grid.getPid());
screenGrid.setAllParentIds(grid.getPid());
screenGrid.setCustomerId(grid.getCustomerId());
screenGrid.setDataEndTime(dateStr);
screenGrid.setGridName(grid.getGridName());
screenCustomerGridDao.updateById(screenGrid);
}
}
}
}

155
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/EIDimServiceImpl.java

@ -0,0 +1,155 @@
package com.epmet.service.impl;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.org.CustomerAgencyEntity;
import com.epmet.entity.org.CustomerDepartmentEntity;
import com.epmet.entity.org.CustomerGridEntity;
import com.epmet.service.EIDimService;
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService;
import com.epmet.service.evaluationindex.screen.ScreenCustomerDeptService;
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService;
import com.epmet.service.org.CustomerAgencyService;
import com.epmet.service.org.CustomerDepartmentService;
import com.epmet.service.org.CustomerGridService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Service
public class EIDimServiceImpl implements EIDimService {
@Autowired
private ScreenCustomerAgencyService screenCustomerAgencyService;
@Autowired
private ScreenCustomerDeptService screenCustomerDeptService;
@Autowired
private ScreenCustomerGridService screenCustomerGridService;
@Autowired
private CustomerAgencyService originCustomerAgencyService;
@Autowired
private CustomerDepartmentService originCustomerDepartmentService;
@Autowired
private CustomerGridService customerGridService;
@Override
public void initAgencies() {
List<CustomerAgencyEntity> agencies2Add = listAgencies2Add();
List<CustomerAgencyEntity> agencies2Update = listAgencies2Update();
screenCustomerAgencyService.initAgencies(agencies2Add, agencies2Update);
}
/**
* 查询可更新的单位
* @return
*/
private List<CustomerAgencyEntity> listAgencies2Update() {
ScreenCustomerAgencyEntity e = screenCustomerAgencyService.getLastUpdatedAgency();
if (e != null) {
// 说明不是第一次初始化
Date startTime = e.getUpdatedTime();
Date endTime = new Date();
return originCustomerAgencyService.listAgenciesByUpdatedTime(startTime, endTime);
}
return new ArrayList<>();
}
/**
* 查询可增加的单位
* @return
*/
private List<CustomerAgencyEntity> listAgencies2Add() {
ScreenCustomerAgencyEntity e = screenCustomerAgencyService.getLastAddedAgency();
Date endTime = new Date();
Date startTime = null;
if (e != null) {
startTime = e.getCreatedTime();
}
return originCustomerAgencyService.listAgenciesByCreateTime(startTime, endTime);
}
@Override
public void initDepartments() {
List<CustomerDepartmentEntity> depts2Add = listDepts2Add();
List<CustomerDepartmentEntity> depts2Update = listDepts2Update();
screenCustomerDeptService.addAndUpdateDepartments(depts2Add, depts2Update);
}
/**
* 查询需要更新的部门列表
* @return
*/
private List<CustomerDepartmentEntity> listDepts2Update() {
ScreenCustomerDeptEntity lastUpdateDept = screenCustomerDeptService.getLastUpdateDept();
if (lastUpdateDept != null) {
// 不是第一次初始化
Date endTime = new Date();
Date startTime = lastUpdateDept.getUpdatedTime();
return originCustomerDepartmentService.listDepartmentsByUpdatedTime(startTime, endTime);
}
return new ArrayList<>();
}
/**
* 查询需要新增的部门列表
* @return
*/
private List<CustomerDepartmentEntity> listDepts2Add() {
ScreenCustomerDeptEntity lastAddDept = screenCustomerDeptService.getLastAddDept();
Date startTime = null;
Date endTime = new Date();
if (lastAddDept != null) {
startTime = lastAddDept.getCreatedTime();
}
return originCustomerDepartmentService.listDepartmentsByCreatedTime(startTime, endTime);
}
@Override
public void initGrids() {
List<CustomerGridEntity> grids2Add = listGrids2Add();
List<CustomerGridEntity> grids2Update =listGrids2Update();
screenCustomerGridService.addAndUpdateGrids(grids2Add, grids2Update);
}
private List<CustomerGridEntity> listGrids2Update() {
ScreenCustomerGridEntity lastUpdateGrid = screenCustomerGridService.getLastUpdateGrid();
if (lastUpdateGrid != null) {
Date endTime = new Date();
Date startTime = lastUpdateGrid.getUpdatedTime();
return customerGridService.listUpdatedGridsByUpdateTime(startTime, endTime);
}
return new ArrayList();
}
private List<CustomerGridEntity> listGrids2Add() {
ScreenCustomerGridEntity lastAddGrid = screenCustomerGridService.getLastAddGrid();
Date endTime = new Date();
Date startTime = null;
if (lastAddGrid != null) {
startTime = lastAddGrid.getCreatedTime();
}
return customerGridService.listGridsByCreateTime(startTime, endTime);
}
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/org/CustomerDepartmentService.java

@ -9,5 +9,5 @@ public interface CustomerDepartmentService {
List<CustomerDepartmentEntity> listDepartmentsByCreatedTime(Date createdTimeFrom, Date createdTimeTo);
List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(Date createdTime, Date initTime);
List<CustomerDepartmentEntity> listDepartmentsByUpdatedTime(Date startTime, Date endTime);
}

3
epmet-module/data-statistical/data-statistical-server/src/main/resources/db/migration/V0.0.4__screen_org_add_source_col.sql

@ -0,0 +1,3 @@
alter table screen_customer_agency add column SOURCE_TYPE varchar(20) default 'external' after AREA_CODE;
alter table screen_customer_dept add column SOURCE_TYPE varchar(20) default 'external' after DEPT_MARK;
alter table screen_customer_grid add column SOURCE_TYPE varchar(20) default 'external' after PARTY_MARK;

81
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -162,4 +162,85 @@
AND pids = #{pids}
ORDER BY created_time DESC
</select>
<select id="getLastAddedAgency"
resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
select id,
customer_id,
agency_id,
agency_name,
pid,
pids,
all_parent_names,
area_marks,
center_mark,
party_mark,
level,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time
from screen_customer_agency sca
where sca.del_flag = 0
and sca.source_type='internal'
order by sca.CREATED_TIME desc
limit 1
</select>
<select id="getLastUpdatedAgency"
resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
select id,
customer_id,
agency_id,
agency_name,
pid,
pids,
all_parent_names,
area_marks,
center_mark,
party_mark,
level,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time
from screen_customer_agency sca
where sca.del_flag=0
and sca.source_type='internal'
order by sca.UPDATED_TIME desc
limit 1
</select>
<select id="selectByAgencyId"
resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
select id,
customer_id,
agency_id,
agency_name,
pid,
pids,
all_parent_names,
area_marks,
center_mark,
party_mark,
level,
area_code,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time
from screen_customer_agency sca
where sca.AGENCY_ID = #{agencyId}
</select>
</mapper>

72
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml

@ -91,4 +91,76 @@
DEL_FLAG = '0'
AND CUSTOMER_ID =#{customerId}
</select>
<select id="getLastAddDept" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
select id,
customer_id,
dept_id,
dept_name,
parent_agency_id,
area_marks,
center_mark,
dept_mark,
source_type,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time
from screen_customer_dept
where DEL_FLAG = 0
and SOURCE_TYPE = 'internal'
order by CREATED_TIME desc
limit 1
</select>
<select id="getLastUpdateDept" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
select id,
customer_id,
dept_id,
dept_name,
parent_agency_id,
area_marks,
center_mark,
dept_mark,
source_type,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time
from screen_customer_dept
where DEL_FLAG = 0
and SOURCE_TYPE = 'internal'
order by UPDATED_TIME desc
limit 1
</select>
<select id="selectByDeptId"
resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
select id,
customer_id,
dept_id,
dept_name,
parent_agency_id,
area_marks,
center_mark,
dept_mark,
source_type,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time
from screen_customer_dept
where DEPT_ID = #{deptId}
</select>
</mapper>

72
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml

@ -145,4 +145,76 @@
AND parent_agency_id = #{agencyId}
ORDER BY created_time DESC
</select>
<select id="getLastAddGrid" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity">
select id,
customer_id,
grid_id,
grid_name,
parent_agency_id,
area_marks,
center_mark,
party_mark,
source_type,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time,
all_parent_ids
from screen_customer_grid
where DEL_FLAG = 0 and SOURCE_TYPE='internal'
order by CREATED_TIME desc
limit 1
</select>
<select id="getLastUpdateGrid"
resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity">
select id,
customer_id,
grid_id,
grid_name,
parent_agency_id,
area_marks,
center_mark,
party_mark,
source_type,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time,
all_parent_ids
from screen_customer_grid
where DEL_FLAG = 0 and SOURCE_TYPE='internal'
order by UPDATED_TIME desc
limit 1
</select>
<select id="getByGridId" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity">
select id,
customer_id,
grid_id,
grid_name,
parent_agency_id,
area_marks,
center_mark,
party_mark,
source_type,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time,
data_end_time,
all_parent_ids
from screen_customer_grid
where DEL_FLAG = 0
and GRID_ID = #{gridId}
</select>
</mapper>

Loading…
Cancel
Save