|  | @ -1,26 +1,27 @@ | 
			
		
	
		
		
			
				
					|  |  | package com.epmet.service.impl; |  |  | package com.epmet.service.impl; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.NumConstant; |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.exception.EpmetErrorCode; |  |  | import com.epmet.commons.tools.exception.EpmetErrorCode; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.exception.EpmetException; |  |  | import com.epmet.commons.tools.exception.EpmetException; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.exception.RenException; |  |  | import com.epmet.commons.tools.exception.RenException; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.commons.tools.redis.common.CustomerOrgRedis; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.commons.tools.redis.common.bean.GridInfoCache; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.ConvertUtils; |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.CpUserDetailRedis; |  |  | import com.epmet.commons.tools.utils.CpUserDetailRedis; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.utils.Result; |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.constant.UserConstant; |  |  | import com.epmet.constant.UserConstant; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dao.UserDao; |  |  | import com.epmet.dao.*; | 
			
				
				
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.UserResiInfoDao; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.UserRoleDao; |  |  |  | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dao.UserWechatDao; |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					|  |  | import com.epmet.dto.*; |  |  | import com.epmet.dto.*; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.form.*; |  |  | import com.epmet.dto.form.*; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.*; |  |  | import com.epmet.dto.result.*; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.entity.UserBaseInfoEntity; |  |  | import com.epmet.entity.*; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.entity.UserEntity; |  |  | import com.epmet.feign.EpmetHeartOpenFeignClient; | 
			
				
				
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.UserWechatEntity; |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  | import com.epmet.feign.EpmetPointOpenFeignClient; |  |  | import com.epmet.feign.EpmetPointOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.GovOrgFeignClient; |  |  | import com.epmet.feign.GovOrgFeignClient; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.redis.UserBaseInfoRedis; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.IcResiUserService; |  |  | import com.epmet.service.IcResiUserService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.UserBaseInfoService; |  |  | import com.epmet.service.UserBaseInfoService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.UserService; |  |  | import com.epmet.service.UserService; | 
			
		
	
	
		
		
			
				
					|  | @ -31,6 +32,7 @@ import org.slf4j.Logger; | 
			
		
	
		
		
			
				
					|  |  | import org.slf4j.LoggerFactory; |  |  | import org.slf4j.LoggerFactory; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.beans.factory.annotation.Autowired; |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.stereotype.Service; |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import org.springframework.transaction.annotation.Transactional; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import java.util.ArrayList; |  |  | import java.util.ArrayList; | 
			
		
	
		
		
			
				
					|  |  | import java.util.Arrays; |  |  | import java.util.Arrays; | 
			
		
	
	
		
		
			
				
					|  | @ -63,6 +65,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem | 
			
		
	
		
		
			
				
					|  |  |     private UserResiInfoDao userResiInfoDao; |  |  |     private UserResiInfoDao userResiInfoDao; | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private IcResiUserService icResiUserService; |  |  |     private IcResiUserService icResiUserService; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private RegisterRelationDao registerRelationDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private EpmetHeartOpenFeignClient epmetHeartOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private ResiUserBadgeDao resiUserBadgeDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private UserBadgeCertificateRecordDao userBadgeCertificateRecordDao; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private UserBaseInfoRedis userBaseInfoRedis; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class); |  |  |     private static final Logger log = LoggerFactory.getLogger(UserServiceImpl.class); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -417,4 +429,79 @@ public class UserServiceImpl extends BaseServiceImpl<UserDao, UserEntity> implem | 
			
		
	
		
		
			
				
					|  |  |         return result; |  |  |         return result; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * 居民端-修改注册网格 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param formDTO | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public void modifyRegGrid(ModifyRegGridFormDTO formDTO) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         GridInfoCache newGridInfo= CustomerOrgRedis.getGridInfo(formDTO.getGridId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (null == newGridInfo) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询当前网格信息异常", "服务器开小差了..."); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //修改register_relation表
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //原始注册记录
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LambdaQueryWrapper<RegisterRelationEntity> wrapper=new LambdaQueryWrapper(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         wrapper.eq(RegisterRelationEntity::getCustomerId,formDTO.getCustomerId()) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 .eq(RegisterRelationEntity::getUserId,formDTO.getUserId()) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 .eq(RegisterRelationEntity::getFirstRegister, NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         RegisterRelationEntity originReg=registerRelationDao.selectOne(wrapper); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(null==originReg){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:查询用户原始注册网格记录异常", "服务器开小差了..."); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //1、删除废弃网格的
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         registerRelationDao.deleteById(originReg.getId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2、当前选择的网格,是否有记录,有更新没有删除
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LambdaQueryWrapper<RegisterRelationEntity> query=new LambdaQueryWrapper(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         query.eq(RegisterRelationEntity::getCustomerId,formDTO.getCustomerId()) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 .eq(RegisterRelationEntity::getUserId,formDTO.getUserId()) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 .eq(RegisterRelationEntity::getGridId, formDTO.getGridId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         RegisterRelationEntity nowReg=registerRelationDao.selectOne(query); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (null != nowReg) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             nowReg.setFirstRegister(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             nowReg.setRegister(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             nowReg.setParticipation(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             registerRelationDao.updateById(nowReg); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             RegisterRelationEntity insert=new RegisterRelationEntity(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             insert.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             insert.setGridId(formDTO.getGridId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             insert.setUserId(formDTO.getUserId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             insert.setFirstRegister(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             insert.setRegister(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             insert.setParticipation(NumConstant.ONE_STR); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             registerRelationDao.insert(insert); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //2、修改历史徽章表
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LambdaUpdateWrapper<UserBadgeCertificateRecordEntity> recUpdate=new LambdaUpdateWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         recUpdate.set(UserBadgeCertificateRecordEntity::getGridId,newGridInfo.getId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         recUpdate.eq(UserBadgeCertificateRecordEntity::getCustomerId,formDTO.getCustomerId()) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                  .eq(UserBadgeCertificateRecordEntity::getUserId,formDTO.getUserId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         userBadgeCertificateRecordDao.update(null,recUpdate); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LambdaUpdateWrapper<ResiUserBadgeEntity> badgeUpdate=new LambdaUpdateWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         badgeUpdate.set(ResiUserBadgeEntity::getGridId,newGridInfo.getId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         badgeUpdate.eq(ResiUserBadgeEntity::getCustomerId,formDTO.getCustomerId()) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 .eq(ResiUserBadgeEntity::getUserId,formDTO.getUserId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         resiUserBadgeDao.update(null,badgeUpdate); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //3、修改支援者信息表
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         VolunteerInfoDTO volunteerInfoDTO=new VolunteerInfoDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         volunteerInfoDTO.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         volunteerInfoDTO.setUserId(formDTO.getUserId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         volunteerInfoDTO.setGridId(newGridInfo.getId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         volunteerInfoDTO.setPid(newGridInfo.getPid()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         volunteerInfoDTO.setPids(newGridInfo.getPids()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         volunteerInfoDTO.setGridName(newGridInfo.getGridName()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         Result volunteerRes=epmetHeartOpenFeignClient.modifyVolunteerGrid(volunteerInfoDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (!volunteerRes.success()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "居民端_修改注册网格:修改用户志愿者信息异常", "服务器开小差了..."); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //4、删除用户缓存信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         userBaseInfoRedis.clearUserCache(Arrays.asList(formDTO.getUserId())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |