|
|
@ -1,15 +1,24 @@ |
|
|
|
package com.epmet.service.org.impl; |
|
|
|
|
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.dao.org.StatsCustomerAgencyDao; |
|
|
|
import com.epmet.dto.org.result.CustomerAreaCodeResultDTO; |
|
|
|
import com.epmet.dto.org.result.OrgStaffDTO; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity; |
|
|
|
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; |
|
|
|
import com.epmet.entity.org.CustomerAgencyEntity; |
|
|
|
import com.epmet.entity.org.CustomerGridEntity; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerAgencyService; |
|
|
|
import com.epmet.service.evaluationindex.screen.ScreenCustomerGridService; |
|
|
|
import com.epmet.service.org.CustomerAgencyService; |
|
|
|
import com.epmet.service.org.CustomerGridService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
@ -21,6 +30,12 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private StatsCustomerAgencyDao customerAgencyDao; |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerAgencyService screenCustomerAgencyService; |
|
|
|
@Autowired |
|
|
|
private ScreenCustomerGridService screenCustomerGridService; |
|
|
|
@Autowired |
|
|
|
private CustomerGridService customerGridService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerAgencyEntity> listAgenciesByCreateTime(Date statsStartTime, Date statsEndTime) { |
|
|
@ -103,4 +118,172 @@ public class CustomerAgencyServiceImpl implements CustomerAgencyService { |
|
|
|
resultList.addAll(gridStaffIds); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<CustomerAgencyEntity> queryAgencyListByCustomerId(String customerId) { |
|
|
|
return customerAgencyDao.queryAgencyListByCustomerId(customerId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据组织id查询基本信息 |
|
|
|
* |
|
|
|
* @param agencyId |
|
|
|
* @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public CustomerAgencyEntity getAgencyById(String agencyId) { |
|
|
|
return customerAgencyDao.selectById(agencyId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询部门所属组织信息 |
|
|
|
* |
|
|
|
* @param deptId |
|
|
|
* @return com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public CustomerAgencyEntity getAgencyByDeptId(String deptId) { |
|
|
|
return customerAgencyDao.selectByDeptId(deptId); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 将孔村、榆山、锦水3个街道的组织插入到gov-org库的customer_agency |
|
|
|
* |
|
|
|
* @param fromCustomerId |
|
|
|
* @param toCustomerId |
|
|
|
* @return Result<XxxxDO> |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void sysAgencyInfo(String fromCustomerId, String toCustomerId) { |
|
|
|
// 1、查询出平阴县组织信息
|
|
|
|
CustomerAgencyEntity pingYin = customerAgencyDao.selecByAreaCode(toCustomerId, "370124"); |
|
|
|
// 2、查询出街道
|
|
|
|
ScreenCustomerAgencyEntity street = screenCustomerAgencyService.getRootAgency(fromCustomerId); |
|
|
|
CustomerAgencyEntity insertStreetEntity = new CustomerAgencyEntity(); |
|
|
|
insertStreetEntity.setCustomerId(pingYin.getCustomerId()); |
|
|
|
insertStreetEntity.setPid(pingYin.getId()); |
|
|
|
if(!StringUtils.isEmpty(pingYin.getPids())){ |
|
|
|
insertStreetEntity.setPids(pingYin.getPids().concat(StrConstant.COLON).concat(pingYin.getId())); |
|
|
|
}else{ |
|
|
|
insertStreetEntity.setPids(pingYin.getId()); |
|
|
|
} |
|
|
|
insertStreetEntity.setAllParentName(pingYin.getOrganizationName()); |
|
|
|
insertStreetEntity.setOrganizationName(street.getAgencyName()); |
|
|
|
insertStreetEntity.setLevel("street"); |
|
|
|
insertStreetEntity.setAreaCode(street.getAreaCode()); |
|
|
|
insertStreetEntity.setSyncFlag("0"); |
|
|
|
insertStreetEntity.setTotalUser(0); |
|
|
|
insertStreetEntity.setProvince("山东省"); |
|
|
|
insertStreetEntity.setCity("济南市"); |
|
|
|
insertStreetEntity.setDistrict(pingYin.getOrganizationName()); |
|
|
|
insertStreetEntity.setStreet(street.getAgencyName()); |
|
|
|
insertStreetEntity.setCommunity(StrConstant.EPMETY_STR); |
|
|
|
insertStreetEntity.setParentAreaCode(pingYin.getAreaCode()); |
|
|
|
insertStreetEntity.setId(street.getAgencyId()); |
|
|
|
// 3、插入街道
|
|
|
|
if (null == customerAgencyDao.selectById(insertStreetEntity.getId())) { |
|
|
|
customerAgencyDao.insert(insertStreetEntity); |
|
|
|
} else { |
|
|
|
customerAgencyDao.updateById(insertStreetEntity); |
|
|
|
} |
|
|
|
// 3.1、街道的直属网格
|
|
|
|
this.insertCustomerGrid(street.getCustomerId(),street.getAgencyId(),insertStreetEntity); |
|
|
|
|
|
|
|
if ("2fe0065f70ca0e23ce4c26fca5f1d933".equals(fromCustomerId)) { |
|
|
|
List<ScreenCustomerAgencyEntity> kcCommunityList = screenCustomerAgencyService.selectKcCommunity(fromCustomerId); |
|
|
|
for(ScreenCustomerAgencyEntity kcCommunity:kcCommunityList){ |
|
|
|
CustomerAgencyEntity insertCommunityEntity = new CustomerAgencyEntity(); |
|
|
|
insertCommunityEntity.setCustomerId(pingYin.getCustomerId()); |
|
|
|
insertCommunityEntity.setPid(insertStreetEntity.getId()); |
|
|
|
insertCommunityEntity.setPids(insertStreetEntity.getPids().concat(StrConstant.COLON).concat(insertStreetEntity.getId())); |
|
|
|
insertCommunityEntity.setAllParentName(insertStreetEntity.getAllParentName().concat(StrConstant.HYPHEN).concat(insertStreetEntity.getOrganizationName())); |
|
|
|
insertCommunityEntity.setOrganizationName(kcCommunity.getAgencyName()); |
|
|
|
insertCommunityEntity.setLevel("community"); |
|
|
|
insertCommunityEntity.setAreaCode(kcCommunity.getAreaCode()); |
|
|
|
insertCommunityEntity.setSyncFlag(NumConstant.ZERO_STR); |
|
|
|
insertCommunityEntity.setTotalUser(NumConstant.ZERO); |
|
|
|
insertCommunityEntity.setProvince("山东省"); |
|
|
|
insertCommunityEntity.setCity("济南市"); |
|
|
|
insertCommunityEntity.setDistrict(pingYin.getOrganizationName()); |
|
|
|
insertCommunityEntity.setStreet(insertStreetEntity.getOrganizationName()); |
|
|
|
insertCommunityEntity.setCommunity(kcCommunity.getAgencyName()); |
|
|
|
insertCommunityEntity.setParentAreaCode(insertStreetEntity.getAreaCode()); |
|
|
|
insertCommunityEntity.setId(kcCommunity.getAgencyId()); |
|
|
|
CustomerAgencyEntity customerAgencyEntity=customerAgencyDao.selectById(insertCommunityEntity.getId()); |
|
|
|
if(null==customerAgencyEntity){ |
|
|
|
// 4、插入社区
|
|
|
|
customerAgencyDao.insert(insertCommunityEntity); |
|
|
|
}else{ |
|
|
|
customerAgencyDao.updateById(insertCommunityEntity); |
|
|
|
} |
|
|
|
// 4.1插入社区下的直属网格
|
|
|
|
this.insertCustomerGrid(kcCommunity.getCustomerId(),kcCommunity.getAgencyId(),insertCommunityEntity); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 4、查询出社区
|
|
|
|
List<ScreenCustomerAgencyEntity> communityList = screenCustomerAgencyService.getByPid(fromCustomerId,street.getAgencyId()); |
|
|
|
for(ScreenCustomerAgencyEntity community:communityList){ |
|
|
|
CustomerAgencyEntity insertCommunityEntity = new CustomerAgencyEntity(); |
|
|
|
insertCommunityEntity.setCustomerId(pingYin.getCustomerId()); |
|
|
|
insertCommunityEntity.setPid(insertStreetEntity.getId()); |
|
|
|
insertCommunityEntity.setPids(insertStreetEntity.getPids().concat(StrConstant.COLON).concat(insertStreetEntity.getId())); |
|
|
|
insertCommunityEntity.setAllParentName(insertStreetEntity.getAllParentName().concat(StrConstant.HYPHEN).concat(insertStreetEntity.getOrganizationName())); |
|
|
|
insertCommunityEntity.setOrganizationName(community.getAgencyName()); |
|
|
|
insertCommunityEntity.setLevel("community"); |
|
|
|
insertCommunityEntity.setAreaCode(community.getAreaCode()); |
|
|
|
insertCommunityEntity.setSyncFlag(NumConstant.ZERO_STR); |
|
|
|
insertCommunityEntity.setTotalUser(NumConstant.ZERO); |
|
|
|
insertCommunityEntity.setProvince("山东省"); |
|
|
|
insertCommunityEntity.setCity("济南市"); |
|
|
|
insertCommunityEntity.setDistrict(pingYin.getOrganizationName()); |
|
|
|
insertCommunityEntity.setStreet(insertStreetEntity.getOrganizationName()); |
|
|
|
insertCommunityEntity.setCommunity(community.getAgencyName()); |
|
|
|
insertCommunityEntity.setParentAreaCode(insertStreetEntity.getAreaCode()); |
|
|
|
insertCommunityEntity.setId(community.getAgencyId()); |
|
|
|
CustomerAgencyEntity customerAgencyEntity=customerAgencyDao.selectById(insertCommunityEntity.getId()); |
|
|
|
if(null==customerAgencyEntity){ |
|
|
|
customerAgencyDao.insert(insertCommunityEntity); |
|
|
|
}else{ |
|
|
|
customerAgencyDao.updateById(insertCommunityEntity); |
|
|
|
} |
|
|
|
// 4.1插入社区下的直属网格
|
|
|
|
this.insertCustomerGrid(community.getCustomerId(),community.getAgencyId(),insertCommunityEntity); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return void |
|
|
|
* @param customerId 孔村、榆山、锦水的客户id |
|
|
|
* @param agencyId 孔村、榆山、锦水的组织id |
|
|
|
* @param parentCustomerEntity 在平阴客户里,网格所属组织信息 |
|
|
|
* @author yinzuomei |
|
|
|
* @description 将3个街道的网格,插入到gov-org.customer_grid库 |
|
|
|
* @Date 2021/7/7 9:54 |
|
|
|
**/ |
|
|
|
private void insertCustomerGrid(String customerId, String agencyId, CustomerAgencyEntity parentCustomerEntity) { |
|
|
|
List<ScreenCustomerGridEntity> gridEntityList = screenCustomerGridService.selectEntityByAgencyId(customerId, agencyId); |
|
|
|
for (ScreenCustomerGridEntity gridEntity : gridEntityList) { |
|
|
|
CustomerGridEntity insertGrid = new CustomerGridEntity(); |
|
|
|
insertGrid.setId(gridEntity.getGridId()); |
|
|
|
insertGrid.setCustomerId(parentCustomerEntity.getCustomerId()); |
|
|
|
insertGrid.setGridName(gridEntity.getGridName()); |
|
|
|
insertGrid.setAreaCode(gridEntity.getAreaCode()); |
|
|
|
insertGrid.setSyncFlag(NumConstant.ZERO_STR); |
|
|
|
insertGrid.setManageDistrict(gridEntity.getGridName()); |
|
|
|
insertGrid.setTotalUser(NumConstant.ZERO); |
|
|
|
insertGrid.setPid(gridEntity.getParentAgencyId()); |
|
|
|
if(StringUtils.isEmpty(parentCustomerEntity.getPids())){ |
|
|
|
insertGrid.setPids(insertGrid.getPid()); |
|
|
|
}else{ |
|
|
|
insertGrid.setPids(parentCustomerEntity.getPids().concat(StrConstant.COLON).concat(insertGrid.getPid())); |
|
|
|
} |
|
|
|
if (null == customerGridService.selectById(insertGrid.getId())) { |
|
|
|
customerGridService.insert(insertGrid); |
|
|
|
} else { |
|
|
|
customerGridService.updateById(insertGrid); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|