|
|
@ -4,7 +4,10 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
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.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.HttpClientManager; |
|
|
@ -13,6 +16,7 @@ import com.epmet.dto.PaCustomerDTO; |
|
|
|
import com.epmet.dto.form.LatestGridInfoFormDTO; |
|
|
|
import com.epmet.dto.result.AllGridsByUserIdResultDTO; |
|
|
|
import com.epmet.dto.result.LatestGridInfoResultDTO; |
|
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.modules.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.modules.feign.GovOrgFeignClient; |
|
|
@ -25,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -116,26 +121,59 @@ public class ResiMineGridServiceImpl implements ResiMineGridService { |
|
|
|
JSONObject toResult = JSON.parseObject(data); |
|
|
|
Result mapToResult = ConvertUtils.mapToEntity(toResult, Result.class); |
|
|
|
if (null != toResult.get("code")) { |
|
|
|
mapToResult.setCode(((Integer) toResult.get("code")).intValue()); |
|
|
|
mapToResult.setCode((Integer) toResult.get("code")); |
|
|
|
} |
|
|
|
if (!mapToResult.success()) { |
|
|
|
logger.error(String.format("根据appId查询客户信息失败,对应appId->" + formDTO.getAppId())); |
|
|
|
throw new RenException(mapToResult.getMsg()); |
|
|
|
} |
|
|
|
Object PublicCustomerResultDTO = mapToResult.getData(); |
|
|
|
JSONObject json = JSON.parseObject(PublicCustomerResultDTO.toString()); |
|
|
|
Map<String, Object> map = (Map) json.get("customer"); |
|
|
|
Object publicCustomerResultDTO = mapToResult.getData(); |
|
|
|
JSONObject json = JSON.parseObject(publicCustomerResultDTO.toString()); |
|
|
|
Map map = (Map) json.get("customer"); |
|
|
|
PaCustomerDTO customer = ConvertUtils.mapToEntity(map, PaCustomerDTO.class); |
|
|
|
logger.info("小程序登陆third服务获取客户用户信息PaCustomerDTO->" + customer); |
|
|
|
|
|
|
|
//2.调用epmet-user服务,根据客户Id和用户Id查询最后一次访问记录
|
|
|
|
LatestGridInfoResultDTO result = null; |
|
|
|
formDTO.setCustomerId(customer.getId()); |
|
|
|
Result<LatestGridInfoResultDTO> userResult = epmetUserOpenFeignClient.latestGridInfo(formDTO); |
|
|
|
Result<List<LatestGridInfoResultDTO>> userResult = epmetUserOpenFeignClient.latestGridList(formDTO); |
|
|
|
if (!userResult.success()) { |
|
|
|
logger.error(String.format("居民端获取用户最近访问网格失败,接口入参客户Id->%s,appId->%s,调用epmet-user-server服务返回->%s", formDTO.getCustomerId(), formDTO.getAppId(), JSON.toJSONString(userResult))); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
return userResult.getData(); |
|
|
|
for (LatestGridInfoResultDTO girdInfo : userResult.getData()) { |
|
|
|
try { |
|
|
|
GridInfoCache grid = CustomerOrgRedis.getGridInfo(girdInfo.getGridId()); |
|
|
|
if (grid == null) { |
|
|
|
logger.warn("latestGridInfo get gridInfo return null,gridId:{}", girdInfo.getGridId()); |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
Integer abandonFlag = grid.getAbandonFlag(); |
|
|
|
if (NumConstant.ONE == abandonFlag) { |
|
|
|
logger.warn("latestGridInfo gridId:{} has abandoned", girdInfo.getGridId()); |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
result = girdInfo; |
|
|
|
//匹配到了未弃用的网格 跳出
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.warn("latestGridInfo get gridInfo exception,gridId:{}", girdInfo.getGridId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 查询注册网格的弃用状态
|
|
|
|
Result<List<UserBaseInfoResultDTO>> userBaseInfo = epmetUserOpenFeignClient.queryUserBaseInfo(Arrays.asList(formDTO.getUserId())); |
|
|
|
if (!userBaseInfo.success()){ |
|
|
|
throw new EpmetException("查询用户基本信息失败"); |
|
|
|
} |
|
|
|
GridInfoCache grid = CustomerOrgRedis.getGridInfo(userBaseInfo.getData().get(NumConstant.ZERO).getRegisteredGridId()); |
|
|
|
if (grid != null) { |
|
|
|
result.setRegisterGridStatus(grid.getAbandonFlag().compareTo(NumConstant.ONE) == NumConstant.ZERO ? true : false); |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|