|
|
@ -24,14 +24,20 @@ import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.RegisterRelationDao; |
|
|
|
import com.epmet.dao.UserResiInfoDao; |
|
|
|
import com.epmet.dao.UserRoleDao; |
|
|
|
import com.epmet.dao.UserWechatDao; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
|
import com.epmet.dto.RegisterRelationDTO; |
|
|
|
import com.epmet.dto.UserResiInfoDTO; |
|
|
|
import com.epmet.dto.UserResiRegisterVisitDTO; |
|
|
|
import com.epmet.dto.form.CustomerGridFormDTO; |
|
|
|
import com.epmet.dto.form.EnterGridFormDTO; |
|
|
|
import com.epmet.dto.form.UserResiInfoFormDTO; |
|
|
|
import com.epmet.dto.form.UserRoleFormDTO; |
|
|
|
import com.epmet.dto.result.UserInfoOnEnterGridResultDTO; |
|
|
|
import com.epmet.dto.result.UserRoleResultDTO; |
|
|
|
import com.epmet.entity.RegisterRelationEntity; |
|
|
|
import com.epmet.entity.UserWechatEntity; |
|
|
|
import com.epmet.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.redis.RegisterRelationRedis; |
|
|
|
import com.epmet.service.RegisterRelationService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@ -39,9 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 注册关系表 用于统计客户网格的注册居民数 |
|
|
@ -64,6 +68,12 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio |
|
|
|
@Autowired |
|
|
|
private UserRoleDao userRoleDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GovOrgFeignClient govOrgFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserResiRegisterVisitDao userResiRegisterVisitDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<RegisterRelationDTO> page(Map<String, Object> params) { |
|
|
|
IPage<RegisterRelationEntity> page = baseDao.selectPage( |
|
|
@ -126,16 +136,105 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio |
|
|
|
@Override |
|
|
|
public Result<UserInfoOnEnterGridResultDTO> getUserInfoAndRoles(EnterGridFormDTO enterGridFormDTO) { |
|
|
|
|
|
|
|
//1.查找用户注册关系表,如果没有表示当前用户为陌生人(拉取用户微信表信息),如果有表示当前用户已经进行居民认证
|
|
|
|
|
|
|
|
//2.根据居民认证的网格、客户进行统计
|
|
|
|
|
|
|
|
//3.去网格表中查询网格对应的名称
|
|
|
|
|
|
|
|
Result<UserInfoOnEnterGridResultDTO> result = new Result<>(); |
|
|
|
UserInfoOnEnterGridResultDTO resultObj = new UserInfoOnEnterGridResultDTO(); |
|
|
|
final String customerId = enterGridFormDTO.getCustomerId(); |
|
|
|
final String gridId = enterGridFormDTO.getGridId(); |
|
|
|
|
|
|
|
//查询用户微信关系表
|
|
|
|
List<UserWechatEntity> strangerWechatInfo = userWechatDao.selectByUserId(enterGridFormDTO.getUserId()); |
|
|
|
if(null != strangerWechatInfo && strangerWechatInfo.size() > 0){ |
|
|
|
resultObj.setNickname(strangerWechatInfo.get(0).getNickname()); |
|
|
|
resultObj.setUserHeadPhoto(strangerWechatInfo.get(0).getHeadImgUrl()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
List<RegisterRelationEntity> registerRecords = baseDao.getListByUserId(enterGridFormDTO.getUserId()); |
|
|
|
//1.查找用户注册关系表,如果没有表示当前用户为陌生人(拉取用户微信表信息),如果有表示当前用户已经进行居民认证
|
|
|
|
if(null == registerRecords || registerRecords.size() <= 0){ |
|
|
|
//当前用户尚未注册过居民信息
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
//2.根据居民认证的网格、客户进行统计
|
|
|
|
RegisterRelationEntity registerRelationToSave = new RegisterRelationEntity(); |
|
|
|
|
|
|
|
registerRelationToSave.setCustomerId(customerId); |
|
|
|
registerRelationToSave.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
registerRelationToSave.setGridId(gridId); |
|
|
|
|
|
|
|
|
|
|
|
Optional<RegisterRelationEntity> registerRecordWithSameCustAndGrid = |
|
|
|
registerRecords.stream().filter(obj -> customerId.equals(obj.getCustomerId()) && gridId.equals(obj.getGridId())).findFirst(); |
|
|
|
|
|
|
|
//是否存在相同客户相同网格的注册记录
|
|
|
|
if(!registerRecordWithSameCustAndGrid.isPresent()){ |
|
|
|
Optional<RegisterRelationEntity> registerRecordWithSameCustAndDiffGrid = |
|
|
|
registerRecords.stream().filter(obj -> customerId.equals(obj.getCustomerId()) && !gridId.equals(obj.getGridId())).findAny(); |
|
|
|
|
|
|
|
if(registerRecordWithSameCustAndDiffGrid.isPresent()){ |
|
|
|
//存在相同客户不同网格的注册记录
|
|
|
|
//参与用户
|
|
|
|
registerRelationToSave.setFirstRegister("0"); |
|
|
|
registerRelationToSave.setRegister("0"); |
|
|
|
registerRelationToSave.setParticipation("1"); |
|
|
|
|
|
|
|
baseDao.insert(registerRelationToSave); |
|
|
|
}else{ |
|
|
|
//不存在相同客户不同网格的注册记录
|
|
|
|
Optional<RegisterRelationEntity> registerRecordWithDiffCustAndGrid = |
|
|
|
registerRecords.stream().filter(obj -> !customerId.equals(obj.getCustomerId()) && !gridId.equals(obj.getGridId())).findAny(); |
|
|
|
if(registerRecordWithDiffCustAndGrid.isPresent()){ |
|
|
|
//如果存在不同客户不同网格的注册信息
|
|
|
|
//注册用户 参与用户
|
|
|
|
registerRelationToSave.setFirstRegister("0"); |
|
|
|
registerRelationToSave.setRegister("1"); |
|
|
|
registerRelationToSave.setParticipation("1"); |
|
|
|
|
|
|
|
baseDao.insert(registerRelationToSave); |
|
|
|
}else{ |
|
|
|
|
|
|
|
//如果不存在不同客户不同网格数据,说明在居民注册时没有成功记录register_relation信息
|
|
|
|
UserResiRegisterVisitDTO userResiRegisterVisitDTO = new UserResiRegisterVisitDTO(); |
|
|
|
userResiRegisterVisitDTO.setDelFlag(0); |
|
|
|
userResiRegisterVisitDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
List<UserResiRegisterVisitDTO> UserResiRegisterVisitRecord = |
|
|
|
userResiRegisterVisitDao.selectUserResiRegisterVisit(userResiRegisterVisitDTO); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UserResiInfoFormDTO userResiInfoFormDTO = new UserResiInfoFormDTO(); |
|
|
|
userResiInfoFormDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
UserResiInfoDTO userResiInfo = userResiInfoDao.selectUserResiInfoDTO(userResiInfoFormDTO); |
|
|
|
resultObj.setNickname(userResiInfo.getSurname() + userResiInfo.getName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//3.获取权限
|
|
|
|
UserRoleFormDTO userRoleFormDTO = new UserRoleFormDTO(); |
|
|
|
userRoleFormDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
userRoleFormDTO.setCustomerId(enterGridFormDTO.getCustomerId()); |
|
|
|
List<UserRoleResultDTO> roleList = userRoleDao.getUserRoleInfo(userRoleFormDTO); |
|
|
|
List<String> roleListString = new ArrayList<>(); |
|
|
|
for(UserRoleResultDTO role : roleList){ |
|
|
|
roleListString.add(role.getRoleKey()); |
|
|
|
} |
|
|
|
resultObj.setUserRoleList(roleListString); |
|
|
|
|
|
|
|
//4.去网格表中查询网格对应的名称
|
|
|
|
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO(); |
|
|
|
customerGridFormDTO.setGridId(gridId); |
|
|
|
Result<CustomerGridDTO> gridDTOResult = |
|
|
|
govOrgFeignClient.getCustomerGridByGridId(customerGridFormDTO); |
|
|
|
if(gridDTOResult.success()){ |
|
|
|
resultObj.setCurrentGridName(gridDTOResult.getData().getGridName()); |
|
|
|
}else{ |
|
|
|
//查询网格名称失败
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.setData(resultObj); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
} |