@ -6,6 +6,7 @@ import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.alibaba.fastjson.JSON ;
import com.dingtalk.api.request.OapiRobotSendRequest ;
import com.epmet.commons.dynamic.datasource.annotation.DataSource ;
import com.epmet.commons.tools.constant.Constant ;
import com.epmet.commons.tools.constant.DingDingRobotConstant ;
import com.epmet.commons.tools.constant.NumConstant ;
import com.epmet.commons.tools.constant.StrConstant ;
@ -23,6 +24,7 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.redis.common.bean.BuildingInfoCache ;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache ;
import com.epmet.commons.tools.security.dto.TokenDto ;
import com.epmet.commons.tools.utils.ConvertUtils ;
import com.epmet.commons.tools.utils.HttpClientManager ;
import com.epmet.commons.tools.utils.Result ;
import com.epmet.dataaggre.constant.DataSourceConstant ;
@ -250,41 +252,6 @@ public class GovOrgServiceImpl implements GovOrgService {
return result ;
}
public static void main ( String [ ] args ) {
List < NextAreaCodeResultDTO > allList = new ArrayList < > ( ) ;
NextAreaCodeResultDTO m1 = new NextAreaCodeResultDTO ( ) ;
m1 . setAreaCode ( "1" ) ;
m1 . setAreaName ( "a" ) ;
allList . add ( m1 ) ;
NextAreaCodeResultDTO m2 = new NextAreaCodeResultDTO ( ) ;
m2 . setAreaCode ( "2" ) ;
m2 . setAreaName ( "b" ) ;
allList . add ( m2 ) ;
NextAreaCodeResultDTO m3 = new NextAreaCodeResultDTO ( ) ;
m3 . setAreaCode ( "3" ) ;
m3 . setAreaName ( "c" ) ;
allList . add ( m3 ) ;
List < String > stringList = new ArrayList < > ( ) ;
stringList . add ( "1" ) ;
stringList . add ( "2" ) ;
Iterator < NextAreaCodeResultDTO > iterator = allList . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
NextAreaCodeResultDTO next = iterator . next ( ) ;
for ( String usedAreaCode : stringList ) {
if ( next . getAreaCode ( ) . equals ( usedAreaCode ) ) {
iterator . remove ( ) ;
}
}
}
System . out . println ( JSON . toJSONString ( allList , true ) ) ;
}
/ * *
* @param staffId
* @Author sun
@ -642,8 +609,46 @@ public class GovOrgServiceImpl implements GovOrgService {
* @date 2021 / 11 / 5 2 : 54 下午
* /
@Override
public CustomerAgencyEntity getAgencyInfo ( String agencyId ) {
return customerAgencyDao . selectById ( agencyId ) ;
public CustomerAgencyDTO getAgencyInfo ( String agencyId ) {
CustomerAgencyEntity customerAgencyEntity = customerAgencyDao . selectById ( agencyId ) ;
CustomerAgencyDTO res = ConvertUtils . sourceToTarget ( customerAgencyEntity , CustomerAgencyDTO . class ) ;
//设置行政地区编码全路径
if ( StringUtils . isNotBlank ( res . getAreaCode ( ) ) & & StringUtils . isNotBlank ( res . getParentAreaCode ( ) ) ) {
res . setAreaCodePath ( queryAreaCodePath ( res ) ) ;
}
return res ;
}
private List < String > queryAreaCodePath ( CustomerAgencyDTO customerAgencyEntity ) {
List < String > areaCodePath = new ArrayList < > ( ) ;
switch ( customerAgencyEntity . getLevel ( ) ) {
case Constant . COMMUNITY :
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) . substring ( NumConstant . ZERO , NumConstant . TWO ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) . substring ( NumConstant . ZERO , NumConstant . FOUR ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) . substring ( NumConstant . ZERO , NumConstant . SIX ) ) ;
areaCodePath . add ( customerAgencyEntity . getParentAreaCode ( ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) ) ;
break ;
case Constant . STREET :
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) . substring ( NumConstant . ZERO , NumConstant . TWO ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) . substring ( NumConstant . ZERO , NumConstant . FOUR ) ) ;
areaCodePath . add ( customerAgencyEntity . getParentAreaCode ( ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) ) ;
break ;
case Constant . DISTRICT :
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) . substring ( NumConstant . ZERO , NumConstant . TWO ) ) ;
areaCodePath . add ( customerAgencyEntity . getParentAreaCode ( ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) ) ;
break ;
case Constant . CITY :
areaCodePath . add ( customerAgencyEntity . getParentAreaCode ( ) ) ;
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) ) ;
break ;
case Constant . PROVINCE :
areaCodePath . add ( customerAgencyEntity . getAreaCode ( ) ) ;
break ;
}
return areaCodePath ;
}
/ * *