@ -53,10 +53,7 @@ import com.epmet.commons.tools.utils.*;
import com.epmet.constant.IcPlatformConstant ;
import com.epmet.constant.IcResiUserConstant ;
import com.epmet.constant.UserConstant ;
import com.epmet.dao.IcPartyMemberDao ;
import com.epmet.dao.IcResiUserDao ;
import com.epmet.dao.IcVolunteerDao ;
import com.epmet.dao.UserBaseInfoDao ;
import com.epmet.dao.* ;
import com.epmet.dto.* ;
import com.epmet.dto.form.* ;
import com.epmet.dto.form.demand.UserDemandNameQueryFormDTO ;
@ -160,6 +157,10 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
private EpmetUserOpenFeignClient epmetUserOpenFeignClient ;
@Autowired
private DistributedLock distributedLock ;
@Resource
private IcUserChangeRecordDao icUserChangeRecordDao ;
@Resource
private IcUserChangeDetailedDao icUserChangeDetailedDao ;
@ -3351,4 +3352,178 @@ public class IcResiUserServiceImpl extends BaseServiceImpl<IcResiUserDao, IcResi
List < IcResiNonDynamicResultDTO > list = baseDao . selectList ( query ) . stream ( ) . map ( ( e ) - > ConvertUtils . sourceToTarget ( e , IcResiNonDynamicResultDTO . class ) ) . collect ( Collectors . toList ( ) ) ;
return new PageData < IcResiNonDynamicResultDTO > ( list , new PageInfo < > ( list ) . getTotal ( ) , pageSize ) ;
}
@Override
public PageData < SearchByNameResultDTO > icUserStatisList ( UserChartFormDTO formDTO ) {
PageHelper . startPage ( formDTO . getPageNo ( ) , formDTO . getPageSize ( ) , formDTO . getIsPage ( ) ) ;
//1.判断入参是否有值,没有值则赋值当前工作人员缓存中所属组织信息
if ( StringUtils . isEmpty ( formDTO . getOrgId ( ) ) ) {
//2.获取工作人员缓存信息
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis . getStaffInfo ( formDTO . getCustomerId ( ) , formDTO . getUserId ( ) ) ;
if ( null = = staffInfo ) {
throw new EpmetException ( String . format ( "查询工作人员%s缓存信息失败..." , formDTO . getUserId ( ) ) ) ;
}
formDTO . setOrgId ( staffInfo . getAgencyId ( ) ) ;
formDTO . setOrgType ( "agency" ) ;
}
//获取无效组织网格Id列表
if ( "agency" . equals ( formDTO . getOrgType ( ) ) ) {
//查询组织数据时排除掉当前组织及下级无效组织列表
Result < DelAgencyGridIdResultDTO > result = govOrgOpenFeignClient . getDelAgencyGridIdList ( formDTO . getOrgId ( ) ) ;
if ( ! result . success ( ) ) {
throw new EpmetException ( String . format ( "获取当前组织及下级已删除组织、网格列表失败,组织Id->%s" , formDTO . getUserId ( ) ) ) ;
}
formDTO . setAgencyIdList ( result . getData ( ) . getAgencyIdList ( ) ) ;
formDTO . setGridIdList ( result . getData ( ) . getGridIdList ( ) ) ;
}
//2.按条件查询业务数据
List < SearchByNameResultDTO > list = baseDao . icUserStatisList ( formDTO ) ;
if ( CollectionUtils . isEmpty ( list ) ) {
return new PageData < SearchByNameResultDTO > ( new ArrayList < > ( ) , NumConstant . ZERO ) ;
}
//3.封装数据
//查询小区,楼号,网格
Result < List < AllGridsByUserIdResultDTO > > gridResult = govOrgOpenFeignClient . getGridListByGridIds ( list . stream ( ) . map ( SearchByNameResultDTO : : getGridId ) . collect ( Collectors . toList ( ) ) ) ;
if ( ! gridResult . success ( ) ) {
throw new RenException ( gridResult . getCode ( ) , gridResult . getMsg ( ) ) ;
}
Map < String , String > gridMap = gridResult . getData ( ) . stream ( ) . collect ( Collectors . toMap ( AllGridsByUserIdResultDTO : : getGridId , AllGridsByUserIdResultDTO : : getGridName ) ) ;
Result < List < IcNeighborHoodDTO > > neighborHoodResult = govOrgOpenFeignClient . getListByIds ( list . stream ( ) . map ( SearchByNameResultDTO : : getNeighborHoodId ) . collect ( Collectors . toList ( ) ) ) ;
if ( ! neighborHoodResult . success ( ) ) {
throw new RenException ( neighborHoodResult . getCode ( ) , neighborHoodResult . getMsg ( ) ) ;
}
Map < String , String > neighborHoodMap = neighborHoodResult . getData ( ) . stream ( ) . collect ( Collectors . toMap ( IcNeighborHoodDTO : : getId , IcNeighborHoodDTO : : getNeighborHoodName ) ) ;
Result < List < BuildingResultDTO > > buildResult = govOrgOpenFeignClient . buildingListByIds ( list . stream ( ) . map ( SearchByNameResultDTO : : getBuildId ) . collect ( Collectors . toList ( ) ) ) ;
if ( ! buildResult . success ( ) ) {
throw new RenException ( buildResult . getCode ( ) , buildResult . getMsg ( ) ) ;
}
Map < String , String > buildMap = buildResult . getData ( ) . stream ( ) . collect ( Collectors . toMap ( BuildingResultDTO : : getBuildingId , BuildingResultDTO : : getBuildingName ) ) ;
AtomicInteger i = new AtomicInteger ( NumConstant . ONE ) ;
list . forEach ( item - > {
item . setGridName ( gridMap . get ( item . getGridId ( ) ) ) ;
item . setNeighborHoodName ( neighborHoodMap . get ( item . getNeighborHoodId ( ) ) ) ;
item . setBuildNum ( buildMap . get ( item . getBuildId ( ) ) ) ;
item . setSort ( i . getAndIncrement ( ) ) ;
} ) ;
PageInfo < SearchByNameResultDTO > pageInfo = new PageInfo < > ( list ) ;
return new PageData < > ( list , pageInfo . getTotal ( ) ) ;
}
/ * *
* 更新育龄妇女状态定时任务
*
* @Param
* @Return
* @Author zhaoqifeng
* @Date 2022 / 9 / 8 15 : 45
* /
@Override
@Transactional ( rollbackFor = Exception . class )
public void updateYlfn ( ) {
//获取育龄妇女配置
Result < List < YlfnValueResultDTO > > value = operCustomizeOpenFeignClient . getYlfnValue ( ) ;
if ( ! value . success ( ) ) {
throw new EpmetException ( value . getCode ( ) , value . getMsg ( ) ) ;
}
value . getData ( ) . forEach ( item - > {
//查询客户下的非育龄妇女的女性居民
LambdaQueryWrapper < IcResiUserEntity > wrapper = new LambdaQueryWrapper < > ( ) ;
wrapper . eq ( IcResiUserEntity : : getCustomerId , item . getCustomerId ( ) ) ;
wrapper . eq ( IcResiUserEntity : : getGender , NumConstant . TWO_STR ) ;
wrapper . eq ( IcResiUserEntity : : getStatus , NumConstant . ZERO_STR ) ;
List < IcResiUserEntity > list = baseDao . selectList ( wrapper ) ;
if ( CollectionUtils . isNotEmpty ( list ) ) {
list . forEach ( user - > {
IdCardRegexUtils pares = IdCardRegexUtils . parse ( user . getIdCard ( ) ) ;
if ( null ! = pares & & NumConstant . ONE_STR . equals ( pares . getTypeEnum ( ) . getType ( ) ) ) {
if ( ! NumConstant . ONE_STR . equals ( user . getIsYlfn ( ) ) ) {
//将不是育龄妇女的变为育龄妇女
if ( pares . getParsedResult ( ) . getAge ( ) > = item . getMin ( ) & & pares . getParsedResult ( ) . getAge ( ) < = item . getMax ( ) ) {
//更新育龄妇女状态
IcResiUserEntity icResiUserEntity = new IcResiUserEntity ( ) ;
icResiUserEntity . setId ( user . getId ( ) ) ;
icResiUserEntity . setIsYlfn ( NumConstant . ONE_STR ) ;
baseDao . updateById ( icResiUserEntity ) ;
//添加居民变更记录
IcUserChangeRecordEntity record = new IcUserChangeRecordEntity ( ) ;
record . setCustomerId ( user . getCustomerId ( ) ) ;
record . setOperatorId ( "APP_USER" ) ;
record . setOperatorName ( "自动匹配" ) ;
record . setIcUserId ( user . getId ( ) ) ;
record . setIcUserName ( user . getName ( ) ) ;
record . setType ( "category" ) ;
record . setTypeName ( "类别" ) ;
record . setBeforeChangeName ( "育龄妇女:否;" ) ;
record . setAfterChangeName ( "育龄妇女:是;" ) ;
record . setChangeTime ( new Date ( ) ) ;
icUserChangeRecordDao . insert ( record ) ;
//添加变更明细
IcUserChangeDetailedEntity detail = new IcUserChangeDetailedEntity ( ) ;
detail . setCustomerId ( user . getCustomerId ( ) ) ;
detail . setIcUserChangeRecordId ( record . getId ( ) ) ;
detail . setPids ( user . getPids ( ) ) ;
detail . setAgencyId ( user . getAgencyId ( ) ) ;
detail . setGridId ( user . getGridId ( ) ) ;
detail . setNeighborHoodId ( user . getVillageId ( ) ) ;
detail . setBuildingId ( user . getBuildId ( ) ) ;
detail . setBuildingUnitId ( user . getUnitId ( ) ) ;
detail . setHouseId ( user . getHomeId ( ) ) ;
detail . setIcUserId ( user . getId ( ) ) ;
detail . setType ( "category" ) ;
detail . setTypeName ( "类别" ) ;
detail . setFieldName ( "IS_YLFN" ) ;
detail . setValue ( NumConstant . ONE ) ;
icUserChangeDetailedDao . insert ( detail ) ;
}
} else {
//将是育龄妇女的变为非育龄妇女
if ( pares . getParsedResult ( ) . getAge ( ) < item . getMin ( ) | | pares . getParsedResult ( ) . getAge ( ) > item . getMax ( ) ) {
//更新育龄妇女状态
IcResiUserEntity icResiUserEntity = new IcResiUserEntity ( ) ;
icResiUserEntity . setId ( user . getId ( ) ) ;
icResiUserEntity . setIsYlfn ( NumConstant . ZERO_STR ) ;
baseDao . updateById ( icResiUserEntity ) ;
//添加居民变更记录
IcUserChangeRecordEntity record = new IcUserChangeRecordEntity ( ) ;
record . setCustomerId ( user . getCustomerId ( ) ) ;
record . setOperatorId ( "APP_USER" ) ;
record . setOperatorName ( "自动匹配" ) ;
record . setIcUserId ( user . getId ( ) ) ;
record . setIcUserName ( user . getName ( ) ) ;
record . setType ( "category" ) ;
record . setTypeName ( "类别" ) ;
record . setBeforeChangeName ( "育龄妇女:是;" ) ;
record . setAfterChangeName ( "育龄妇女:否;" ) ;
record . setChangeTime ( new Date ( ) ) ;
icUserChangeRecordDao . insert ( record ) ;
//添加变更明细
IcUserChangeDetailedEntity detail = new IcUserChangeDetailedEntity ( ) ;
detail . setCustomerId ( user . getCustomerId ( ) ) ;
detail . setIcUserChangeRecordId ( record . getId ( ) ) ;
detail . setPids ( user . getPids ( ) ) ;
detail . setAgencyId ( user . getAgencyId ( ) ) ;
detail . setGridId ( user . getGridId ( ) ) ;
detail . setNeighborHoodId ( user . getVillageId ( ) ) ;
detail . setBuildingId ( user . getBuildId ( ) ) ;
detail . setBuildingUnitId ( user . getUnitId ( ) ) ;
detail . setHouseId ( user . getHomeId ( ) ) ;
detail . setIcUserId ( user . getId ( ) ) ;
detail . setType ( "category" ) ;
detail . setTypeName ( "类别" ) ;
detail . setFieldName ( "IS_YLFN" ) ;
detail . setValue ( NumConstant . ONE_NEG ) ;
icUserChangeDetailedDao . insert ( detail ) ;
}
}
}
} ) ;
}
} ) ;
}
}