|
|
@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.UserConstant; |
|
|
|
import com.epmet.constant.UserCustomerConstant; |
|
|
|
import com.epmet.dao.*; |
|
|
|
import com.epmet.dto.CustomerGridDTO; |
|
|
@ -38,12 +39,10 @@ import com.epmet.dto.result.UserResiInfoResultDTO; |
|
|
|
import com.epmet.dto.result.UserRoleResultDTO; |
|
|
|
import com.epmet.entity.RegisterRelationEntity; |
|
|
|
import com.epmet.entity.UserCustomerEntity; |
|
|
|
import com.epmet.entity.UserWechatEntity; |
|
|
|
import com.epmet.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.service.GridVisitedService; |
|
|
|
import com.epmet.service.RegisterRelationService; |
|
|
|
import com.epmet.util.ModuleConstant; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
@ -61,13 +60,15 @@ import java.util.*; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelationDao, RegisterRelationEntity> implements RegisterRelationService { |
|
|
|
// private static ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
|
|
|
|
// .setNameFormat("registerRelationService-pool-%d").build();
|
|
|
|
// private static final ExecutorService threadPool = new ThreadPoolExecutor(2, 3,
|
|
|
|
// 0L, TimeUnit.MILLISECONDS,
|
|
|
|
// new ArrayBlockingQueue(1), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(RegisterRelationServiceImpl.class); |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserWechatDao userWechatDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserResiInfoDao userResiInfoDao; |
|
|
|
|
|
|
@ -159,7 +160,6 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio |
|
|
|
final String gridId = enterGridFormDTO.getGridId(); |
|
|
|
|
|
|
|
//查询用户微信关系表
|
|
|
|
// List<UserWechatEntity> strangerWechatInfo = userWechatDao.selectByUserId(enterGridFormDTO.getUserId());
|
|
|
|
UserBaseInfoResultDTO strangerInfo = userBaseInfoDao.selectListByUserIdList(enterGridFormDTO.getUserId()); |
|
|
|
if(null != strangerInfo){ |
|
|
|
resultObj.setNickname(strangerInfo.getNickname()); |
|
|
@ -176,6 +176,18 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio |
|
|
|
wrapper.eq(UserCustomerConstant.USER_ID,enterGridFormDTO.getUserId()); |
|
|
|
wrapper.eq(FieldConstant.DEL_FLAG,NumConstant.ZERO_STR); |
|
|
|
|
|
|
|
//3.获取权限
|
|
|
|
// Future<Boolean> futureUserRole = threadPool.submit(() -> {
|
|
|
|
//
|
|
|
|
// return true;
|
|
|
|
// });
|
|
|
|
setUserRoleList(enterGridFormDTO, resultObj); |
|
|
|
setGridName(resultObj, gridId); |
|
|
|
//setUserRoleList(enterGridFormDTO, resultObj);
|
|
|
|
//setGridName(resultObj, gridId);
|
|
|
|
|
|
|
|
//4.去网格表中查询网格对应的名称
|
|
|
|
//Future<Boolean> futureGridName = threadPool.submit(() -> setGridName(resultObj, gridId));
|
|
|
|
|
|
|
|
//1.查找用户注册关系表,如果没有表示当前用户为陌生人(拉取用户微信表信息),如果有表示当前用户已经进行居民认证
|
|
|
|
if(null == registerRecords || registerRecords.size() <= 0){ |
|
|
@ -231,11 +243,6 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio |
|
|
|
}else{ |
|
|
|
log.warn("不存在不同客户不同网格下用户注册记录数据,可能因为居民注册时没有成功记录register_relation信息"); |
|
|
|
//如果不存在不同客户不同网格数据,说明在居民注册时没有成功记录register_relation信息
|
|
|
|
//UserResiRegisterVisitDTO userResiRegisterVisitDTO = new UserResiRegisterVisitDTO();
|
|
|
|
//userResiRegisterVisitDTO.setDelFlag(NumConstant.ZERO);
|
|
|
|
//userResiRegisterVisitDTO.setUserId(enterGridFormDTO.getUserId());
|
|
|
|
//List<UserResiRegisterVisitDTO> UserResiRegisterVisitRecord =
|
|
|
|
// userResiRegisterVisitDao.selectUserResiRegisterVisit(userResiRegisterVisitDTO);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -259,61 +266,80 @@ public class RegisterRelationServiceImpl extends BaseServiceImpl<RegisterRelatio |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//3.获取权限
|
|
|
|
UserRoleFormDTO userRoleFormDTO = new UserRoleFormDTO(); |
|
|
|
userRoleFormDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
userRoleFormDTO.setCustomerId(enterGridFormDTO.getCustomerId()); |
|
|
|
userRoleFormDTO.setGridId(enterGridFormDTO.getGridId()); |
|
|
|
List<UserRoleResultDTO> roleList = userRoleDao.getUserRoleInfo(userRoleFormDTO); |
|
|
|
List<String> roleListString = new ArrayList<>(); |
|
|
|
for(UserRoleResultDTO role : roleList){ |
|
|
|
roleListString.add(role.getRoleKey()); |
|
|
|
|
|
|
|
|
|
|
|
result.setData(resultObj); |
|
|
|
|
|
|
|
VisitedFormDTO visitedFormDTO = setShowNameAndBuildVistedRecord(enterGridFormDTO, resultObj, strangerInfo); |
|
|
|
|
|
|
|
|
|
|
|
if(!gridVisitedService.saveVisitedRecord(visitedFormDTO).success()){ |
|
|
|
log.warn(ModuleConstant.SAVE_VISITED_RECORD_FAILURE); |
|
|
|
} |
|
|
|
resultObj.setUserRoleList(roleListString); |
|
|
|
// try {
|
|
|
|
// futureUserRole.get();
|
|
|
|
// } catch (Exception e) {
|
|
|
|
// log.error("thread get result exception",e);
|
|
|
|
// }
|
|
|
|
|
|
|
|
//4.去网格表中查询网格对应的名称
|
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置showName 并返回构建的 访问记录DTO |
|
|
|
*/ |
|
|
|
private VisitedFormDTO setShowNameAndBuildVistedRecord(EnterGridFormDTO enterGridFormDTO, UserInfoOnEnterGridResultDTO resultObj, UserBaseInfoResultDTO strangerInfo) { |
|
|
|
VisitedFormDTO visitedFormDTO = new VisitedFormDTO(); |
|
|
|
visitedFormDTO.setGridId(enterGridFormDTO.getGridId()); |
|
|
|
visitedFormDTO.setCustomerId(enterGridFormDTO.getCustomerId()); |
|
|
|
visitedFormDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
visitedFormDTO.setIsReg(NumConstant.ZERO_STR); |
|
|
|
resultObj.setUserStreetName(StrConstant.EPMETY_STR); |
|
|
|
if (strangerInfo != null){ |
|
|
|
if (StringUtils.isNotBlank(strangerInfo.getStreet()) && StringUtils.isNotBlank(strangerInfo.getSurname())){ |
|
|
|
String gender = null; |
|
|
|
if (NumConstant.ONE_STR.equals(strangerInfo.getGender())) { |
|
|
|
gender = UserConstant.MAN; |
|
|
|
} else if (NumConstant.TWO_STR.equals(strangerInfo.getGender())) { |
|
|
|
gender = UserConstant.WOMAN; |
|
|
|
} else { |
|
|
|
gender = UserConstant.MAN_WOMAN; |
|
|
|
} |
|
|
|
String leaderName = strangerInfo.getStreet().concat(StrConstant.HYPHEN).concat(strangerInfo.getSurname()).concat(gender); |
|
|
|
resultObj.setUserStreetName(leaderName); |
|
|
|
visitedFormDTO.setIsReg(NumConstant.ONE_STR); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return visitedFormDTO; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean setGridName(UserInfoOnEnterGridResultDTO resultObj, String gridId) { |
|
|
|
CustomerGridFormDTO customerGridFormDTO = new CustomerGridFormDTO(); |
|
|
|
customerGridFormDTO.setGridId(gridId); |
|
|
|
Result<CustomerGridDTO> gridDTOResult = |
|
|
|
govOrgFeignClient.getCustomerGridByGridId(customerGridFormDTO); |
|
|
|
Result<CustomerGridDTO> gridDTOResult = govOrgFeignClient.getGridBaseInfoByGridId(customerGridFormDTO); |
|
|
|
if(gridDTOResult.success() && null != gridDTOResult.getData()){ |
|
|
|
resultObj.setCurrentGridName(gridDTOResult.getData().getGridName()); |
|
|
|
}else{ |
|
|
|
//查询网格名称失败
|
|
|
|
log.warn(String.format("查找网格信息失败,网格Id:【%s】",gridId)); |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/*Result<CustomerDTO> customerResult = |
|
|
|
operCrmFeignClient.get(enterGridFormDTO.getCustomerId()); |
|
|
|
if(customerResult.success() && null != customerResult.getData() && StringUtils.isNotBlank(customerResult.getData().getCustomerName())){ |
|
|
|
resultObj.setCurrentCustomerName(customerResult.getData().getCustomerName()); |
|
|
|
}else{ |
|
|
|
log.warn(ModuleConstant.CUSTOMER_INFO_NOT_FOUND); |
|
|
|
}*/ |
|
|
|
|
|
|
|
result.setData(resultObj); |
|
|
|
|
|
|
|
VisitedFormDTO visitedFormDTO = new VisitedFormDTO(); |
|
|
|
visitedFormDTO.setGridId(enterGridFormDTO.getGridId()); |
|
|
|
visitedFormDTO.setCustomerId(enterGridFormDTO.getCustomerId()); |
|
|
|
visitedFormDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
UserResiInfoFormDTO userResiParam = new UserResiInfoFormDTO(); |
|
|
|
userResiParam.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
userResiParam.setCustomerId(enterGridFormDTO.getCustomerId()); |
|
|
|
UserResiInfoResultDTO resiResult = |
|
|
|
userResiInfoDao.selectUserResiInfoDTO(userResiParam); |
|
|
|
if(null == resiResult){ |
|
|
|
visitedFormDTO.setIsReg(NumConstant.ZERO_STR); |
|
|
|
resultObj.setUserStreetName(ModuleConstant.EMPTY_STR); |
|
|
|
}else{ |
|
|
|
visitedFormDTO.setIsReg(NumConstant.ONE_STR); |
|
|
|
resultObj.setUserStreetName(resiResult.getShowName()); |
|
|
|
} |
|
|
|
if(!gridVisitedService.saveVisitedRecord(visitedFormDTO).success()){ |
|
|
|
log.warn(ModuleConstant.SAVE_VISITED_RECORD_FAILURE); |
|
|
|
private boolean setUserRoleList(EnterGridFormDTO enterGridFormDTO, UserInfoOnEnterGridResultDTO resultObj) { |
|
|
|
UserRoleFormDTO userRoleFormDTO = new UserRoleFormDTO(); |
|
|
|
userRoleFormDTO.setUserId(enterGridFormDTO.getUserId()); |
|
|
|
userRoleFormDTO.setCustomerId(enterGridFormDTO.getCustomerId()); |
|
|
|
userRoleFormDTO.setGridId(enterGridFormDTO.getGridId()); |
|
|
|
List<UserRoleResultDTO> roleList = userRoleDao.getUserRoleInfo(userRoleFormDTO); |
|
|
|
List<String> roleListString = new ArrayList<>(); |
|
|
|
for(UserRoleResultDTO role : roleList){ |
|
|
|
roleListString.add(role.getRoleKey()); |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
resultObj.setUserRoleList(roleListString); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|