2023年5月16日 后台调用奥威亚接口
This commit is contained in:
parent
bcac393816
commit
46a9be435e
|
@ -0,0 +1,78 @@
|
|||
package org.jeecg.modules.httpinterface.controller;
|
||||
|
||||
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.query.QueryWrapper;
|
||||
import com.xkcoding.http.HttpUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.kc.grab.exports.entity.TBks;
|
||||
import org.jeecg.modules.kc.grab.exports.service.ITBksService;
|
||||
import org.jeecg.modules.kc.jiaoshi.entity.KcZhihuijiaoshi;
|
||||
import org.jeecg.modules.kc.jiaoshi.service.IKcZhihuijiaoshiService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 对外部访问接口
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-04-10
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags="对外部访问接口")
|
||||
@RestController
|
||||
@RequestMapping("/httpinterface")
|
||||
public class httpController extends JeecgController<TBks, ITBksService> {
|
||||
|
||||
@Autowired
|
||||
private IKcZhihuijiaoshiService kcZhihuijiaoshiService;
|
||||
|
||||
@AutoLog(value = "对外部访问接口-通过IDS访问奥威亚接口")
|
||||
@ApiOperation(value="T_BKS-抓取-通过id查询", notes="T_BKS-抓取-通过id查询")
|
||||
@GetMapping(value = "/runAvyApiByIds")
|
||||
public Result<?> runAvyApiByIds(String ids,String type){
|
||||
if(StringUtils.isNotBlank(ids)){
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
QueryWrapper<KcZhihuijiaoshi> qw = new QueryWrapper<>();
|
||||
qw.in("id",idList);
|
||||
List<KcZhihuijiaoshi> list = kcZhihuijiaoshiService.list(qw);
|
||||
|
||||
list.forEach(x -> {
|
||||
//访问。汇总结果
|
||||
//http://${ip}/cgi-bin/plat.cgi?action=9&user=${user}&pwsd=${getMd5Str(pwd)}&command=1
|
||||
String hex = Convert.toHex("live_setParam_enable=" + type, CharsetUtil.CHARSET_UTF_8);
|
||||
String buildUrl = UrlBuilder.create()
|
||||
.setScheme("http")
|
||||
.setHost(x.getIp())
|
||||
.addPath("/cgi-bin")
|
||||
.addPath("/plat.cgi")
|
||||
.addQuery("action", "9")
|
||||
.addQuery("command", "1")
|
||||
.addQuery("user", x.getUser())
|
||||
.addQuery("pwsd", SecureUtil.md5(x.getMima()))
|
||||
.addQuery("data", hex)
|
||||
.build();
|
||||
String res = HttpUtil.get(buildUrl);
|
||||
log.info("奥威亚返回接口内容:" + res);
|
||||
//解析,决定最后返回结果
|
||||
});
|
||||
}else{
|
||||
return Result.ok("操作失败");
|
||||
}
|
||||
//URL url = new URL("www.hutool.cn")
|
||||
return Result.ok("操作成功");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue