[bug]成工院虚仿平台对接的统计数据同步服务bug
This commit is contained in:
parent
bef6dda6b2
commit
6187e6d667
@ -10,7 +10,6 @@ import club.joylink.rtss.services.user.UserSimulationRecordService;
|
||||
import club.joylink.rtss.simulation.cbtc.SimulationService;
|
||||
import club.joylink.rtss.simulation.vo.SimulationInfoVO;
|
||||
import club.joylink.rtss.util.EncryptUtil;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.simulationUsage.SimulationUsageRecordQueryVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO;
|
||||
import java.util.HashMap;
|
||||
@ -18,6 +17,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import javax.annotation.PostConstruct;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -66,6 +66,7 @@ public class CgyStatsService {
|
||||
cgyViews.forEach(cgyView -> {
|
||||
CgyStatsBO bo = new CgyStatsBO(cgyView.getAppId(), cgyView.getAppSecret(),
|
||||
cgyView.getFunctionId());
|
||||
bo.setChange(new AtomicBoolean(true));
|
||||
bo.setView(new AtomicLong(cgyView.getViewCount()));
|
||||
makeCache(bo);
|
||||
appStatsMap.put(cgyView.getAppId(), bo);
|
||||
@ -84,11 +85,18 @@ public class CgyStatsService {
|
||||
}
|
||||
//同步汇总数据
|
||||
Map<String, Object> body = new HashMap<>();
|
||||
body.put("appId", appId);
|
||||
body.put("app_id", appId);
|
||||
body.put("timestamp", System.currentTimeMillis());
|
||||
body.put("view", statsBO.getView().get());
|
||||
body.put("visitor", statsBO.getVisitor().get());
|
||||
body.put("user", statsBO.getUserSet().size());
|
||||
String sb = "app_id=" + body.get("app_id") + "&"
|
||||
+ "timestamp=" + body.get("timestamp") + "&"
|
||||
+ "user=" + body.get("user") + "&"
|
||||
+ "view=" + body.get("view") + "&"
|
||||
+ "visitor=" + body.get("visitor") + "&"
|
||||
+ "app_secret=" + statsBO.getAppSecret();
|
||||
body.put("sign", EncryptUtil.md5(sb).toLowerCase());
|
||||
//扩展字段
|
||||
body.put("duration", statsBO.getDuration().get());
|
||||
SimulationInfoQueryVO queryVO = new SimulationInfoQueryVO();
|
||||
@ -96,26 +104,12 @@ public class CgyStatsService {
|
||||
List<SimulationInfoVO> sims = simulationService.listAllSimulation(queryVO);
|
||||
body.put("onlineUser", sims.size());
|
||||
|
||||
String sb = "appId="
|
||||
+ body.get("appId") + "&"
|
||||
+ "timestamp="
|
||||
+ body.get("timestamp") + "&"
|
||||
+ "user="
|
||||
+ body.get("user") + "&"
|
||||
+ "view="
|
||||
+ body.get("view") + "&"
|
||||
+ "visitor="
|
||||
+ body.get("visitor") + "&"
|
||||
+ "app_secret="
|
||||
+ statsBO.getAppSecret();
|
||||
body.put("sign", EncryptUtil.md5(sb).toLowerCase());
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> httpEntity = new HttpEntity<>(JsonUtils.writeValueAsString(body),
|
||||
httpHeaders);
|
||||
|
||||
HttpEntity<Map<String, Object>> httpEntity = new HttpEntity<>(body, httpHeaders);
|
||||
Map<String, String> resBody = restTemplate.postForObject(
|
||||
"/api/applicationCenter/openapi/summary", httpEntity, Map.class);
|
||||
"https://common-dev.educloudxr.com/api/applicationCenter/openapi/summary", httpEntity,
|
||||
Map.class);
|
||||
if (resBody != null && Objects.equals(resBody.get("code"), "100001")) {
|
||||
log.error(String.format("成工院虚仿平台同步数据失败:[%s][%s]", resBody.get("msg"),
|
||||
resBody.get("data")));
|
||||
|
Loading…
Reference in New Issue
Block a user