Browse Source

接口代码结构微调 性能暂无变化

dev_shibei_match
jianjun 4 years ago
parent
commit
ae6f195fab
  1. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java
  2. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java
  3. 134
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java
  4. 11
      epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml
  5. 4
      epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml

11
epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java

@ -39,4 +39,15 @@ public interface GovOrgFeignClient {
@PostMapping("/gov/org/customerstaffgrid/getgridstaffs")
Result<List<String>> getGridStaffs(@RequestBody CommonGridIdFormDTO gridIdFormDTO);
/**
* desc: 获取网格基础数据
*
* @param customerGridFormDTO
* @return com.epmet.commons.tools.utils.Result<com.epmet.dto.CustomerGridDTO>
* @author LiuJanJun
* @date 2021/4/19 11:19 上午
*/
@PostMapping("/gov/org/grid/getbaseinfo")
Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO);
}

5
epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java

@ -28,4 +28,9 @@ public class GovOrgFeignClientFallBack implements GovOrgFeignClient {
public Result<List<String>> getGridStaffs(CommonGridIdFormDTO gridIdFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridStaffs", gridIdFormDTO);
}
@Override
public Result<CustomerGridDTO> getGridBaseInfoByGridId(CustomerGridFormDTO customerGridFormDTO) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridBaseInfoByGridId", customerGridFormDTO);
}
}

134
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/RegisterRelationServiceImpl.java

@ -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;
}
/**

11
epmet-user/epmet-user-server/src/main/resources/mapper/RegisterRelationDao.xml

@ -20,8 +20,13 @@
</resultMap>
<select id="getListByUserId" parameterType="string" resultType="com.epmet.entity.RegisterRelationEntity">
SELECT *
SELECT
CUSTOMER_ID,
GRID_ID,
USER_ID,
FIRST_REGISTER,
REGISTER,
PARTICIPATION
FROM
register_relation
WHERE
@ -78,4 +83,4 @@
</select>
</mapper>
</mapper>

4
epmet-user/epmet-user-server/src/main/resources/mapper/UserBaseInfoDao.xml

@ -44,8 +44,8 @@
FROM
user_base_info ubi
WHERE
ubi.DEL_FLAG = '0'
AND ubi.USER_ID = #{userId}
ubi.USER_ID = #{userId}
AND ubi.DEL_FLAG = '0'
</select>
<!-- 根据用户id获取user_wechat表微信用户基本信息 -->

Loading…
Cancel
Save