This commit is contained in:
lu7213 committed 2026-08-13 02:26:24 -04:00
1 parent cf9c801b93
commit f0b438eb6c
8 files changed
+158 -89

No files matched your search

@@ -41,7 +41,9 @@ import java.util.zip.GZIPInputStream;
public class HttpHelper {
private String proxyHost;
private Integer proxyPort;
private CloseableHttpClient httpsClient = null;
private CloseableHttpClient httpClient = null;
public String getProxyHost() {
return proxyHost;
}
@@ -57,7 +59,20 @@ public class HttpHelper {
public void setProxyPort(Integer proxyPort) {
this.proxyPort = proxyPort;
}
public void closeClient(){
try {
if (httpsClient != null) {
httpsClient.close();
httpsClient = null;
}
if (httpClient != null) {
httpClient.close();
httpClient = null;
}
}catch (Exception e){
log.error(e.getMessage(),e);
}
}
public static void main(String[] args) throws Exception {
BigDecimal decimal = new BigDecimal("1").divide(new BigDecimal(100));
@@ -444,13 +459,19 @@ public class HttpHelper {
* @return
*/
public String getlHttpResult(String url, String method, Map<String, Object> headers, Map<String, Object> params) throws Exception {
CloseableHttpClient httpClient = null;
CloseableHttpClient tempClient = null;
if (url.startsWith("https")) {
httpClient = getHttpsClient();
if(httpsClient == null){
httpsClient = getHttpsClient();
}
tempClient = httpsClient;
} else {
httpClient = getHttpClient();
if(httpClient == null) {
httpClient = getHttpClient();
}
tempClient = httpClient;
}
CloseableHttpResponse response = this.send(httpClient, url, method, headers, params);
CloseableHttpResponse response = this.send(tempClient, url, method, headers, params);
if (method.toLowerCase().equals("options")) {
return response.getStatusLine().getStatusCode() + "";
} else {
@@ -466,24 +487,36 @@ public class HttpHelper {
}
public String getlHttpResultCode(String url, String method, Map<String, Object> headers, Map<String, Object> params) throws Exception {
CloseableHttpClient httpClient = null;
CloseableHttpClient tempClient = null;
if (url.startsWith("https")) {
httpClient = getHttpsClient();
if(httpsClient == null){
httpsClient = getHttpsClient();
}
tempClient = httpsClient;
} else {
httpClient = getHttpClient();
if(httpClient == null) {
httpClient = getHttpClient();
}
tempClient = httpClient;
}
CloseableHttpResponse response = this.send(httpClient, url, method, headers, params);
CloseableHttpResponse response = this.send(tempClient, url, method, headers, params);
return response.getStatusLine().getStatusCode() + "";
}
public Boolean testHttp(String url, String method, Map<String, Object> headers, Map<String, Object> params) throws Exception {
CloseableHttpClient httpClient = null;
CloseableHttpClient tempClient = null;
if (url.startsWith("https")) {
httpClient = getHttpsClient();
if(httpsClient == null){
httpsClient = getHttpsClient();
}
tempClient = httpsClient;
} else {
httpClient = getHttpClient();
if(httpClient == null) {
httpClient = getHttpClient();
}
tempClient = httpClient;
}
CloseableHttpResponse response = this.send(httpClient, url, method, headers, params);
CloseableHttpResponse response = this.send(tempClient, url, method, headers, params);
boolean result = response.getStatusLine().getStatusCode() == 200;
response.close();
return result;
@@ -494,11 +527,17 @@ public class HttpHelper {
}
public String playLoad(String method, String url, Map<String, Object> headersMap, Object data, String contentType, String charset) throws Exception {
CloseableHttpClient httpClient = null;
CloseableHttpClient tempClient = null;
if (url.startsWith("https")) {
httpClient = getHttpsClient();
if(httpsClient == null){
httpsClient = getHttpsClient();
}
tempClient = httpsClient;
} else {
httpClient = getHttpClient();
if(httpClient == null) {
httpClient = getHttpClient();
}
tempClient = httpClient;
}
String result = null;
HttpEntityEnclosingRequestBase httpEntityEnclosingRequestBase = null;
@@ -532,7 +571,7 @@ public class HttpHelper {
CloseableHttpResponse response = null;
try {
// 由客户端执行(发送)Post请求
response = (CloseableHttpResponse) httpClient.execute(httpEntityEnclosingRequestBase);
response = (CloseableHttpResponse) tempClient.execute(httpEntityEnclosingRequestBase);
// 从响应模型中获取响应实体
HttpEntity responseEntity = response.getEntity();
System.out.println("响应状态为:" + response.getStatusLine());
@@ -9,6 +9,7 @@ ruoyi:
- /system/file/uploadImage
- /ec/device-api/report
- /ec/device-api/heartbeat
- /system/global/close-http-client
# 名称
name: RuoYi
# 版本
@@ -1,98 +1,92 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.select.Ids;
import com.ruoyi.common.select.SelectItem;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.select.Ids;
import com.ruoyi.common.select.SelectItem;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.Apps;
import com.ruoyi.system.domain.AppsPlus;
import com.ruoyi.system.service.IAppsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 应用管理Controller
*
*
* @author luqj
* @date 2025-11-25
*/
@RestController
@RequestMapping("/system/apps")
public class AppsController extends BaseController
{
public class AppsController extends BaseController {
@Autowired
private IAppsService appsService;
@PreAuthorize("@ss.hasPermi('system:apps:getByIds')")
@PostMapping("/getByIds")
public AjaxResult getByIds(@RequestBody Ids ids)
{
List<AppsPlus> list = appsService.getByIds(ids.getLongIds(),false,AppsPlus::getName,AppsPlus::getId);
public AjaxResult getByIds(@RequestBody Ids ids) {
List<AppsPlus> list = appsService.getByIds(ids.getLongIds(), false, AppsPlus::getName, AppsPlus::getId);
return AjaxResult.success(list);
}
@PreAuthorize("@ss.hasPermi('system:apps:user-getByIds')")
@PostMapping("/user/getByIds")
public AjaxResult userGetByIds(@RequestBody Ids ids)
{
List<AppsPlus> list = appsService.getByIds(ids.getLongIds(),true,AppsPlus::getName,AppsPlus::getUserId,AppsPlus::getId);
public AjaxResult userGetByIds(@RequestBody Ids ids) {
List<AppsPlus> list = appsService.getByIds(ids.getLongIds(), true, AppsPlus::getName, AppsPlus::getUserId, AppsPlus::getId);
return AjaxResult.success(list);
}
@PreAuthorize("@ss.hasPermi('system:apps:select')")
@GetMapping("/select")
public AjaxResult select(String keyword)
{
List<SelectItem> list = appsService.select(keyword,false);
public AjaxResult select(String keyword) {
List<SelectItem> list = appsService.select(keyword, false);
return AjaxResult.success(list);
}
@PreAuthorize("@ss.hasPermi('system:apps:user-select')")
@GetMapping("/user/select")
public AjaxResult userSelect(String keyword)
{
List<SelectItem> list = appsService.select(keyword,true);
public AjaxResult userSelect(String keyword) {
List<SelectItem> list = appsService.select(keyword, true);
return AjaxResult.success(list);
}
/**
* 查询应用管理列表
*/
@PreAuthorize("@ss.hasPermi('system:apps:list')")
@GetMapping("/list")
public TableDataInfo list(Apps apps)
{
public TableDataInfo list(Apps apps) {
startPage();
List<Apps> list = appsService.selectAppsList(apps,false);
List<Apps> list = appsService.selectAppsList(apps, false);
return getDataTable(list);
}
/**
* 查询应用管理列表
*/
@PreAuthorize("@ss.hasPermi('system:apps:user-list')")
@GetMapping("/user/list")
public TableDataInfo userList(Apps apps)
{
/**
* 查询应用管理列表
*/
@PreAuthorize("@ss.hasPermi('system:apps:user-list')")
@GetMapping("/user/list")
public TableDataInfo userList(Apps apps) {
startPage();
List<Apps> list = appsService.selectAppsList(apps,true);
List<Apps> list = appsService.selectAppsList(apps, true);
return getDataTable(list);
}
/**
/**
* 导出应用管理列表
*/
@PreAuthorize("@ss.hasPermi('system:apps:export')")
@Log(title = "应用管理", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(Apps apps)
{
List<Apps> list = appsService.selectAppsList(apps,false);
public AjaxResult export(Apps apps) {
List<Apps> list = appsService.selectAppsList(apps, false);
ExcelUtil<Apps> util = new ExcelUtil<Apps>(Apps.class);
return util.exportExcel(list, "apps");
}
@@ -102,74 +96,73 @@ public class AppsController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('system:apps:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(appsService.selectAppsById(id,false));
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(appsService.selectAppsById(id, false));
}
/**
* 获取应用管理详细信息
*/
@PreAuthorize("@ss.hasPermi('system:apps:user-query')")
@GetMapping(value = "/user/{id}")
public AjaxResult userGetInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(appsService.selectAppsById(id,true));
public AjaxResult userGetInfo(@PathVariable("id") Long id) {
return AjaxResult.success(appsService.selectAppsById(id, true));
}
/**
* 新增应用管理
*/
@PreAuthorize("@ss.hasPermi('system:apps:add')")
@Log(title = "应用管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody Apps apps)
{
return toAjax(appsService.insertApps(apps,false));
public AjaxResult add(@RequestBody Apps apps) {
return toAjax(appsService.insertApps(apps, false));
}
/**
* 新增应用管理
*/
@PreAuthorize("@ss.hasPermi('system:apps:user-add')")
@Log(title = "应用管理", businessType = BusinessType.INSERT)
@PostMapping("/user")
public AjaxResult userAdd(@RequestBody Apps apps)
{
return toAjax(appsService.insertApps(apps,true));
public AjaxResult userAdd(@RequestBody Apps apps) {
return toAjax(appsService.insertApps(apps, true));
}
/**
* 修改应用管理
*/
@PreAuthorize("@ss.hasPermi('system:apps:edit')")
@Log(title = "应用管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody Apps apps)
{
return toAjax(appsService.updateApps(apps,false));
public AjaxResult edit(@RequestBody Apps apps) {
return toAjax(appsService.updateApps(apps, false));
}
@PreAuthorize("@ss.hasPermi('system:apps:user-edit')")
@Log(title = "应用管理", businessType = BusinessType.UPDATE)
@PutMapping("/user")
public AjaxResult userEdit(@RequestBody Apps apps)
{
return toAjax(appsService.updateApps(apps,true));
public AjaxResult userEdit(@RequestBody Apps apps) {
return toAjax(appsService.updateApps(apps, true));
}
/**
* 删除应用管理
*/
@PreAuthorize("@ss.hasPermi('system:apps:remove')")
@Log(title = "应用管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(appsService.deleteAppsByIds(ids,false));
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(appsService.deleteAppsByIds(ids, false));
}
/**
* 删除应用管理
*/
@PreAuthorize("@ss.hasPermi('system:apps:user-remove')")
@Log(title = "应用管理", businessType = BusinessType.DELETE)
@DeleteMapping("/user/{ids}")
public AjaxResult userRemove(@PathVariable Long[] ids)
{
return toAjax(appsService.deleteAppsByIds(ids,true));
public AjaxResult userRemove(@PathVariable Long[] ids) {
return toAjax(appsService.deleteAppsByIds(ids, true));
}
}
@@ -0,0 +1,26 @@
package com.ruoyi.system.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service.IDmPlayerTaskGroupService;
import com.ruoyi.system.service.IDmPlayerentService;
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;
//
@RestController
@RequestMapping("/system/global")
public class GlobalController {
@Autowired
private IDmPlayerentService dmPlayerentService;
@Autowired
private IDmPlayerTaskGroupService dmPlayerTaskGroupService;
@GetMapping(value = "/close-http-client")
public AjaxResult closeHttpClient() {
dmPlayerentService.closeHttpClient();
dmPlayerTaskGroupService.closeHttpClient();
return AjaxResult.success(true);
}
}
@@ -90,4 +90,6 @@ public interface IDmPlayerTaskGroupService extends IService<DmPlayerTaskGroupPlu
<T> List<T> countByGroupBy(String select, String where, String groupby, Class<T> tClass);
boolean operate(DmGroupOperateVo vo);
void closeHttpClient();
}
@@ -71,7 +71,7 @@ public interface IDmPlayerentService extends IService<DmPlayerentPlus>
List<DmPlayerentPlus> getByIds(List<Long> ids, SFunction<DmPlayerentPlus, ?>... columns);
DmPlayerentPlus getById(Long id, SFunction<DmPlayerentPlus, ?>... columns);
void closeHttpClient();
Map<Long, DmPlayerentPlus> getMapByIds(List<Long> ids, SFunction<DmPlayerentPlus, ?>... columns);
List<DmPlayerentPlus> getByIds(List<Long> ids);
@@ -160,6 +160,11 @@ public class DmPlayerTaskGroupServiceImpl extends ServiceImpl<DmPlayerTaskGroupM
return false;
}
@Override
public void closeHttpClient() {
this.httpHelper.closeClient();
}
/**
* 查询大漠任务组
*
@@ -87,7 +87,10 @@ public class DmPlayerentServiceImpl extends ServiceImpl<DmPlayerentMapper, DmPla
}
return map;
}
@Override
public void closeHttpClient() {
this.httpHelper.closeClient();
}
@Override
public Map<Long, DmPlayerentPlus> getMapByIds(List<Long> ids) {
List<DmPlayerentPlus> list = this.getByIds(ids);