From a36e920d9a40c564af5a73faf55ad7313811ca11 Mon Sep 17 00:00:00 2001 From: bai <1643359946@qq.com> Date: Mon, 4 Sep 2023 22:58:46 +0800 Subject: [PATCH] =?UTF-8?q?2023=E5=B9=B49=E6=9C=884=E6=97=A5=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=B0=83=E7=94=A8=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E5=AE=9A=E6=97=B6=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=9C=AA=E4=B8=8A=E7=BA=BF=E7=9B=B4=E6=92=AD=E9=97=B4=EF=BC=8C?= =?UTF-8?q?=E5=90=8C=E6=97=B6=E7=82=B9=E5=87=BB=E6=8C=89=E9=92=AE=E6=8B=89?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/httpController.java | 31 ++++++++++++---- .../RefreshLiveServer.java | 35 +++++++++++++++++++ 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/httpinterface/controller/httpController.java b/jeecg-module-main/src/main/java/org/jeecg/modules/httpinterface/controller/httpController.java index 84979c15..ac7df41b 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/httpinterface/controller/httpController.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/httpinterface/controller/httpController.java @@ -5,10 +5,12 @@ import cn.hutool.core.net.url.UrlBuilder; import cn.hutool.core.util.CharsetUtil; import cn.hutool.crypto.SecureUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.google.common.collect.Maps; import com.xkcoding.http.HttpUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.compress.utils.Lists; import org.apache.commons.lang.StringUtils; import org.jeecg.common.api.vo.Result; import org.jeecg.common.aspect.annotation.AutoLog; @@ -24,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.Arrays; import java.util.List; +import java.util.Map; /** * @Description: 对外部访问接口 @@ -44,6 +47,9 @@ public class httpController extends JeecgController { @ApiOperation(value="T_BKS-抓取-通过id查询", notes="T_BKS-抓取-通过id查询") @GetMapping(value = "/runAvyApiByIds") public Result runAvyApiByIds(String ids,String type){ + Result res = Result.OK("操作成功"); + List> resultList = Lists.newArrayList(); + res.setResult(resultList); if(StringUtils.isNotBlank(ids)){ List idList = Arrays.asList(ids.split(",")); QueryWrapper qw = new QueryWrapper<>(); @@ -66,12 +72,20 @@ public class httpController extends JeecgController { .addQuery("data", hex) .build(); log.info("访问奥威亚接口地址"+buildUrl); + Map rm = Maps.newHashMap(); + resultList.add(rm); + rm.put("xm",x.getXm()); + rm.put("jsmc",x.getJsmc()); + rm.put("url",buildUrl); try{ - - String res = HttpUtil.get(buildUrl); - log.info("奥威亚返回接口内容:" + res);//live_setParam_ret=ok + String resText = HttpUtil.get(buildUrl); + log.info("奥威亚返回接口内容:" + resText);//live_setParam_ret=ok + rm.put("resText",resText); +// res.setResult(rm); } catch (Exception e){ log.error(e.getMessage(),e); + rm.put("resText",e.getMessage()); +// res.setResult(rm); } //解析,决定最后返回结果 }); @@ -79,20 +93,23 @@ public class httpController extends JeecgController { return Result.ok("操作失败"); } //URL url = new URL("www.hutool.cn") - return Result.ok("操作成功"); + return res; } public static void main(String[] args) { String hex = Convert.toHex("live_setParam_enable=1", CharsetUtil.CHARSET_UTF_8);//开始 //String hex = Convert.toHex("live_setParam_enable=0", CharsetUtil.CHARSET_UTF_8);//停止 + String ip = "10.68.100.46"; + String user = "admin"; + String pwd = "admin"; String buildUrl = UrlBuilder.create() .setScheme("http") - .setHost("10.68.100.2") + .setHost(ip) .addPath("/cgi-bin") .addPath("/plat.cgi") .addQuery("action", "9") - .addQuery("user", "admin") - .addQuery("pwsd", SecureUtil.md5("admin")) + .addQuery("user", user) + .addQuery("pwsd", SecureUtil.md5(pwd)) .addQuery("command", "1") .addQuery("data", hex) .build(); diff --git a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java index 8b5fd6a6..2b22686d 100644 --- a/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java +++ b/jeecg-module-main/src/main/java/org/jeecg/modules/kc/grab/SynchronizationService/RefreshLiveServer.java @@ -1,5 +1,9 @@ package org.jeecg.modules.kc.grab.SynchronizationService; +import cn.hutool.core.convert.Convert; +import cn.hutool.core.net.url.UrlBuilder; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.crypto.SecureUtil; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.beust.jcommander.internal.Sets; import com.google.common.collect.Maps; @@ -53,6 +57,37 @@ public class RefreshLiveServer extends BaseSync { // liveOnMap.put(x.getId(),false); outList.add(x.getId()); log.error(e.getMessage(),e); + //打开推送开关 + //访问。汇总结果 + //http://${ip}/cgi-bin/plat.cgi?action=9&user=${user}&pwsd=${getMd5Str(pwd)}&command=1 + String hex = Convert.toHex("live_setParam_enable=1", CharsetUtil.CHARSET_UTF_8); + String buildUrl = UrlBuilder.create() + .setScheme("http") + .setHost(x.getIp()) + .addPath("/cgi-bin") + .addPath("/plat.cgi") + .addQuery("action", "9") + .addQuery("user", x.getUser()) + .addQuery("pwsd", SecureUtil.md5(x.getMima())) + .addQuery("command", "1") + .addQuery("data", hex) + .build(); + log.info("访问奥威亚接口地址"+buildUrl); + Map rm = Maps.newHashMap(); + rm.put("xm",x.getXm()); + rm.put("jsmc",x.getJsmc()); + rm.put("url",buildUrl); + try{ + String resText = HttpUtil.get(buildUrl); + log.info("奥威亚返回接口内容:" + resText);//live_setParam_ret=ok + rm.put("resText",resText); +// res.setResult(rm); + } catch (Exception e2){ + log.error(e2.getMessage(),e2); + rm.put("resText",e2.getMessage()); +// res.setResult(rm); + } + } }); if(!onList.isEmpty()){