21 changed files with 692 additions and 5 deletions
@ -0,0 +1,11 @@ |
|||
package com.epmet.constant; |
|||
|
|||
public interface OrgSourceTypeConstant { |
|||
|
|||
// 外部
|
|||
String EXTERNAL = "external"; |
|||
|
|||
// 内部
|
|||
String INTERNAL = "internal"; |
|||
|
|||
} |
@ -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(); |
|||
} |
|||
|
|||
} |
@ -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(); |
|||
} |
@ -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); |
|||
} |
|||
} |
@ -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; |
Loading…
Reference in new issue