|
@@ -33,6 +33,8 @@ import org.springblade.manager.service.ProfilerOffsetService;
|
|
|
import org.springblade.manager.mapper.ProfilerOffsetMapper;
|
|
import org.springblade.manager.mapper.ProfilerOffsetMapper;
|
|
|
import org.springblade.manager.service.ProfilerStandardSectionBeanService;
|
|
import org.springblade.manager.service.ProfilerStandardSectionBeanService;
|
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
import org.springblade.resource.feign.NewIOSSClient;
|
|
|
|
|
+import org.springframework.dao.DataAccessException;
|
|
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -65,8 +67,8 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
private ProfilerDataService dataService;
|
|
private ProfilerDataService dataService;
|
|
|
@Resource
|
|
@Resource
|
|
|
private ProfilerStandardSectionBeanService beanService;
|
|
private ProfilerStandardSectionBeanService beanService;
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public ProfilerResult save(ProfilerSaveDTO save, MultipartFile file) {
|
|
public ProfilerResult save(ProfilerSaveDTO save, MultipartFile file) {
|
|
@@ -215,21 +217,67 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Scheduled(cron = "0 0 20 ? * FRI")
|
|
@Scheduled(cron = "0 0 20 ? * FRI")
|
|
|
public void push() {
|
|
public void push() {
|
|
|
- //测试地址 http://192.168.100.1:18010/prod-api/data/openapi/v1/push
|
|
|
|
|
- String baseUrl = "http://192.168.100.1:18010/prod-api";
|
|
|
|
|
String url = "/data/openapi/v1/push";
|
|
String url = "/data/openapi/v1/push";
|
|
|
- //第三方提供的key
|
|
|
|
|
- String clientKey = "tunnel-overBreak-1013";
|
|
|
|
|
- String secret = "73c6e839-bc38-fd04-7e2e-e49c6ccc4b41";
|
|
|
|
|
- //推送接口 应用id
|
|
|
|
|
- String protocolApiId = "1977938405343174658";
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //从系统参数中获取配置信息
|
|
|
|
|
+ String sql = "select param_value from blade_param where param_key = 'profiler.isPush' and is_deleted = 0";
|
|
|
|
|
+ Integer isPush = jdbcTemplate.queryForObject(sql, Integer.class);
|
|
|
|
|
+ //判断是否上传数据
|
|
|
|
|
+ if(isPush != null && isPush == 0){
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //从系统参数中获取配置信息
|
|
|
|
|
+ String baseUrl = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.baseUrl' and is_deleted = 0";
|
|
|
|
|
+ baseUrl = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
|
+ } catch (DataAccessException e) {
|
|
|
|
|
+ log.error("系统参数未找到 profiler.baseUrl");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String clientKey = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.clientKey' and is_deleted = 0";
|
|
|
|
|
+ //第三方提供的key
|
|
|
|
|
+ clientKey = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
|
+ } catch (DataAccessException e) {
|
|
|
|
|
+ log.error("系统参数未找到 profiler.clientKey");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String secret = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.secret' and is_deleted = 0";
|
|
|
|
|
+ //第三方提供的key
|
|
|
|
|
+ secret = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
|
+ } catch (DataAccessException e) {
|
|
|
|
|
+ log.error("系统参数未找到 profiler.secret");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String protocolApiId = null;
|
|
|
|
|
+ try {
|
|
|
|
|
+ sql = "select param_value from blade_param where param_key = 'profiler.protocolApiId' and is_deleted = 0";
|
|
|
|
|
+ //第三方提供的key
|
|
|
|
|
+ protocolApiId = jdbcTemplate.queryForObject(sql, String.class);
|
|
|
|
|
+ } catch (DataAccessException e) {
|
|
|
|
|
+ log.error("系统参数未找到 profiler.protocolApiId");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(StringUtil.isBlank(baseUrl) || StringUtil.isBlank(clientKey) || StringUtil.isBlank(secret) || StringUtil.isBlank(protocolApiId)){
|
|
|
|
|
+ log.error("系统参数未找到配置项");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//当前时间戳
|
|
//当前时间戳
|
|
|
String secTimestamp = String.valueOf(System.currentTimeMillis());
|
|
String secTimestamp = String.valueOf(System.currentTimeMillis());
|
|
|
|
|
|
|
|
//获取数据
|
|
//获取数据
|
|
|
List<ProfilerOffset> list = this.list(Wrappers.<ProfilerOffset>lambdaQuery().eq(ProfilerOffset::getPush, 0));
|
|
List<ProfilerOffset> list = this.list(Wrappers.<ProfilerOffset>lambdaQuery().eq(ProfilerOffset::getPush, 0));
|
|
|
log.info("开始推送断面仪数据------{}", DateTime.now());
|
|
log.info("开始推送断面仪数据------{}", DateTime.now());
|
|
|
- list.forEach(f -> {
|
|
|
|
|
|
|
+ for (ProfilerOffset f : list) {
|
|
|
//随机字符串 每次推送都是唯一的
|
|
//随机字符串 每次推送都是唯一的
|
|
|
String secNonce = UUID.randomUUID().toString();
|
|
String secNonce = UUID.randomUUID().toString();
|
|
|
//获取测量断面
|
|
//获取测量断面
|
|
@@ -280,7 +328,7 @@ public class ProfilerOffsetServiceImpl extends ServiceImpl<ProfilerOffsetMapper,
|
|
|
} catch (HttpException e) {
|
|
} catch (HttpException e) {
|
|
|
f.setPush(2);
|
|
f.setPush(2);
|
|
|
}
|
|
}
|
|
|
- });
|
|
|
|
|
|
|
+ }
|
|
|
log.info("推送完成------{}", DateTime.now());
|
|
log.info("推送完成------{}", DateTime.now());
|
|
|
this.updateBatchById(list);
|
|
this.updateBatchById(list);
|
|
|
}
|
|
}
|