|
@ -25,6 +25,7 @@ import com.epmet.commons.tools.utils.DateUtils; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
import com.epmet.constant.OrgSourceTypeConstant; |
|
|
import com.epmet.constant.OrgSourceTypeConstant; |
|
|
import com.epmet.constant.ScreenConstant; |
|
|
import com.epmet.constant.ScreenConstant; |
|
|
|
|
|
import com.epmet.dao.evaluationindex.screen.DimLastSyncRecordDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; |
|
|
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; |
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
@ -34,6 +35,7 @@ import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; |
|
|
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO; |
|
|
import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO; |
|
|
import com.epmet.dto.extract.result.OrgNameResultDTO; |
|
|
import com.epmet.dto.extract.result.OrgNameResultDTO; |
|
|
import com.epmet.dto.screen.result.TreeResultDTO; |
|
|
import com.epmet.dto.screen.result.TreeResultDTO; |
|
|
|
|
|
import com.epmet.entity.evaluationindex.screen.DimLastSyncRecordEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
import com.epmet.entity.org.CustomerAgencyEntity; |
|
|
import com.epmet.entity.org.CustomerAgencyEntity; |
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; |
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; |
|
@ -63,6 +65,8 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto |
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
private ScreenCustomerAgencyDao screenCustomerAgencyDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ScreenCustomerGridDao screenCustomerGridDao; |
|
|
private ScreenCustomerGridDao screenCustomerGridDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DimLastSyncRecordDao dimLastSyncRecordDao; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Description 根据agencyId,查询所有子级agencyId,【当机关的级别为 community时,所有子级为gridId】 |
|
|
* @Description 根据agencyId,查询所有子级agencyId,【当机关的级别为 community时,所有子级为gridId】 |
|
@ -116,12 +120,12 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto |
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Override |
|
|
@Override |
|
|
public void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update) { |
|
|
public void initAgencies(List<CustomerAgencyEntity> agencies2Add, List<CustomerAgencyEntity> agencies2Update, Date statsEndTime) { |
|
|
String dateEndTime = DateUtils.format(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
String dateEndTime = DateUtils.format(new Date(), DateUtils.DATE_PATTERN_YYYYMMDD); |
|
|
if (!CollectionUtils.isEmpty(agencies2Add)) { |
|
|
if (!CollectionUtils.isEmpty(agencies2Add)) { |
|
|
// 添加
|
|
|
// 添加
|
|
|
for (CustomerAgencyEntity e : agencies2Add) { |
|
|
for (CustomerAgencyEntity e : agencies2Add) { |
|
|
addAgency(e, dateEndTime); |
|
|
addOrUpdateAgency(e, dateEndTime); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -137,11 +141,11 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto |
|
|
exists.setDataEndTime(dateEndTime); |
|
|
exists.setDataEndTime(dateEndTime); |
|
|
exists.setAreaCode(e.getAreaCode()); |
|
|
exists.setAreaCode(e.getAreaCode()); |
|
|
//如果没有区划 则默认暂时不显示
|
|
|
//如果没有区划 则默认暂时不显示
|
|
|
if (StringUtils.isEmpty(e.getAreaCode())) { |
|
|
//if (StringUtils.isEmpty(e.getAreaCode())) {
|
|
|
exists.setIsDisplay(NumConstant.ZERO_STR); |
|
|
// exists.setIsDisplay(NumConstant.ZERO_STR);
|
|
|
} else { |
|
|
//} else {
|
|
|
exists.setIsDisplay(NumConstant.ONE_STR); |
|
|
// exists.setIsDisplay(NumConstant.ONE_STR);
|
|
|
} |
|
|
//}
|
|
|
exists.setAllParentNames(e.getAllParentName()); |
|
|
exists.setAllParentNames(e.getAllParentName()); |
|
|
exists.setParentAreaCode(e.getParentAreaCode()); |
|
|
exists.setParentAreaCode(e.getParentAreaCode()); |
|
|
exists.setCode(e.getCode()); |
|
|
exists.setCode(e.getCode()); |
|
@ -156,6 +160,19 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 保存同步记录
|
|
|
|
|
|
Date lastSyncEndTime = dimLastSyncRecordDao.getDimLastSyncEndTime("agency"); |
|
|
|
|
|
if (lastSyncEndTime == null) { |
|
|
|
|
|
// 首次初始化,没有上次执行记录,插入一条
|
|
|
|
|
|
DimLastSyncRecordEntity insertRecord = new DimLastSyncRecordEntity(); |
|
|
|
|
|
insertRecord.setSubject("agency"); |
|
|
|
|
|
insertRecord.setLastSyncTime(statsEndTime); |
|
|
|
|
|
dimLastSyncRecordDao.insert(insertRecord); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 更新
|
|
|
|
|
|
dimLastSyncRecordDao.updateLastSyncEndTime("agency", statsEndTime); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -231,31 +248,62 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 添加agency |
|
|
* 添加或者更新agency,防止情况:业务表中有数据被抽取过来,且这条数据已经由其他操作推到维度库了 |
|
|
* @param e |
|
|
* @param e |
|
|
*/ |
|
|
*/ |
|
|
private void addAgency(CustomerAgencyEntity e, String dateEndTime) { |
|
|
private void addOrUpdateAgency(CustomerAgencyEntity e, String dateEndTime) { |
|
|
ScreenCustomerAgencyEntity cae = new ScreenCustomerAgencyEntity(); |
|
|
|
|
|
cae.setAgencyId(e.getId()); |
|
|
LambdaQueryWrapper<ScreenCustomerAgencyEntity> query = new LambdaQueryWrapper<>(); |
|
|
cae.setAgencyName(e.getOrganizationName()); |
|
|
query.eq(ScreenCustomerAgencyEntity::getCustomerId, e.getCustomerId()); |
|
|
cae.setAllParentNames(e.getAllParentName()); |
|
|
query.eq(ScreenCustomerAgencyEntity::getAgencyId, e.getId()); |
|
|
cae.setAreaCode(e.getAreaCode()); |
|
|
ScreenCustomerAgencyEntity existsOne = screenCustomerAgencyDao.selectOne(query); |
|
|
//cae.setAreaMarks(e);
|
|
|
if (existsOne != null) { |
|
|
//如果没有区划 则默认暂时不显示
|
|
|
// 已经存在
|
|
|
if (StringUtils.isEmpty(e.getAreaCode())) { |
|
|
existsOne.setAgencyId(e.getId()); |
|
|
cae.setIsDisplay(NumConstant.ZERO_STR); |
|
|
existsOne.setAgencyName(e.getOrganizationName()); |
|
|
|
|
|
existsOne.setAllParentNames(e.getAllParentName()); |
|
|
|
|
|
existsOne.setAreaCode(e.getAreaCode()); |
|
|
|
|
|
//cae.setAreaMarks(e);
|
|
|
|
|
|
//如果没有区划 则默认暂时不显示
|
|
|
|
|
|
//if (StringUtils.isEmpty(e.getAreaCode())) {
|
|
|
|
|
|
// existsOne.setIsDisplay(NumConstant.ZERO_STR);
|
|
|
|
|
|
//} else {
|
|
|
|
|
|
// existsOne.setIsDisplay(NumConstant.ONE_STR);
|
|
|
|
|
|
//}
|
|
|
|
|
|
existsOne.setCustomerId(e.getCustomerId()); |
|
|
|
|
|
existsOne.setDataEndTime(dateEndTime); |
|
|
|
|
|
existsOne.setLevel(e.getLevel()); |
|
|
|
|
|
existsOne.setPid(e.getPid()); |
|
|
|
|
|
existsOne.setPids(e.getPids()); |
|
|
|
|
|
existsOne.setSourceType(OrgSourceTypeConstant.INTERNAL); |
|
|
|
|
|
existsOne.setParentAreaCode(e.getParentAreaCode()); |
|
|
|
|
|
existsOne.setCode(e.getCode()); |
|
|
|
|
|
screenCustomerAgencyDao.updateById(existsOne); |
|
|
|
|
|
return; |
|
|
} else { |
|
|
} else { |
|
|
cae.setIsDisplay(NumConstant.ONE_STR); |
|
|
// 不存在,需要添加
|
|
|
|
|
|
ScreenCustomerAgencyEntity cae = new ScreenCustomerAgencyEntity(); |
|
|
|
|
|
cae.setAgencyId(e.getId()); |
|
|
|
|
|
cae.setAgencyName(e.getOrganizationName()); |
|
|
|
|
|
cae.setAllParentNames(e.getAllParentName()); |
|
|
|
|
|
cae.setAreaCode(e.getAreaCode()); |
|
|
|
|
|
//cae.setAreaMarks(e);
|
|
|
|
|
|
//如果没有区划 则默认暂时不显示
|
|
|
|
|
|
if (StringUtils.isEmpty(e.getAreaCode())) { |
|
|
|
|
|
cae.setIsDisplay(NumConstant.ZERO_STR); |
|
|
|
|
|
} else { |
|
|
|
|
|
cae.setIsDisplay(NumConstant.ONE_STR); |
|
|
|
|
|
} |
|
|
|
|
|
cae.setCustomerId(e.getCustomerId()); |
|
|
|
|
|
cae.setDataEndTime(dateEndTime); |
|
|
|
|
|
cae.setLevel(e.getLevel()); |
|
|
|
|
|
cae.setPid(e.getPid()); |
|
|
|
|
|
cae.setPids(e.getPids()); |
|
|
|
|
|
cae.setSourceType(OrgSourceTypeConstant.INTERNAL); |
|
|
|
|
|
cae.setParentAreaCode(e.getParentAreaCode()); |
|
|
|
|
|
cae.setCode(e.getCode()); |
|
|
|
|
|
screenCustomerAgencyDao.insert(cae); |
|
|
} |
|
|
} |
|
|
cae.setCustomerId(e.getCustomerId()); |
|
|
|
|
|
cae.setDataEndTime(dateEndTime); |
|
|
|
|
|
cae.setLevel(e.getLevel()); |
|
|
|
|
|
cae.setPid(e.getPid()); |
|
|
|
|
|
cae.setPids(e.getPids()); |
|
|
|
|
|
cae.setSourceType(OrgSourceTypeConstant.INTERNAL); |
|
|
|
|
|
cae.setParentAreaCode(e.getParentAreaCode()); |
|
|
|
|
|
cae.setCode(e.getCode()); |
|
|
|
|
|
screenCustomerAgencyDao.insert(cae); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -355,4 +403,8 @@ public class ScreenCustomerAgencyServiceImpl extends BaseServiceImpl<ScreenCusto |
|
|
return baseDao.getParentAgencyId(agencyId); |
|
|
return baseDao.getParentAgencyId(agencyId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Date getDimLastSyncTime() { |
|
|
|
|
|
return dimLastSyncRecordDao.getDimLastSyncEndTime("agency"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |