2
0

fix: 修复omada上云问题

This commit is contained in:
caiyuchao
2025-01-20 11:39:58 +08:00
parent 6c10050fe7
commit d17153ed50
10 changed files with 40 additions and 17 deletions

View File

@@ -20,7 +20,6 @@ import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
import org.wfc.common.log.annotation.Log;
import org.wfc.common.log.enums.BusinessType;
//import org.wfc.common.security.annotation.RequiresPermissions;
import org.wfc.common.security.utils.SecurityUtils;
import org.wfc.job.domain.SysJob;
import org.wfc.job.service.ISysJobService;
@@ -176,9 +175,9 @@ public class SysJobController extends BaseController
{
SysJob sysJob = jobService.selectJobById(job.getJobId());
if (sysJob != null && sysJob.getInvokeTarget().contains("omadaTask")) {
R<Boolean> omadaResult = omadaTask.testOmadaApi();
if (omadaResult.getCode() != 200) {
return error(omadaResult.getMsg());
R<String> omadaResult = omadaTask.testOmadaApi();
if (!"success".equals(omadaResult.getData())) {
return error(omadaResult.getData());
}
}

View File

@@ -30,8 +30,8 @@ public class OmadaTask {
log.info("wifi定时任务执行成功, 耗时:{} 毫秒", endTime - startTime);
}
public R<Boolean> testOmadaApi() {
return remoteUserService.deviceJob();
public R<String> testOmadaApi() {
return remoteUserService.testJob();
}
public R<Boolean> initJob() {

View File

@@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.wfc.common.core.domain.R;
import org.wfc.common.core.web.controller.BaseController;
import org.wfc.common.core.web.domain.AjaxResult;
import org.wfc.common.core.web.page.TableDataInfo;
@@ -80,4 +81,9 @@ public class SysDeviceController extends BaseController {
public AjaxResult settingJob() {
return toAjax(sysDeviceService.settingJob());
}
@PostMapping("/testJob")
public R<String> testJob() {
return R.ok(sysDeviceService.testJob());
}
}

View File

@@ -16,4 +16,6 @@ public interface ISysDeviceService extends IService<SysDevice> {
boolean deviceJob();
boolean settingJob();
String testJob();
}

View File

@@ -53,8 +53,10 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
private static final String REDIS_ACCESS_TOKEN = "wfc-api-omada:access-token";
private static final String REDIS_REFRESH_TOKEN = "wfc-api-omada:refresh-token";
private static final int OMADA_ERROR_CODE = -44112;
private static final int OMADA_SUCCESS_CODE = 0;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean deviceJob() {
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(1, 1000);
if (siteList.getBody() == null) {
@@ -92,6 +94,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
return true;
}
@Override
public boolean settingJob() {
// 启用Omada历史记录保留
ResponseEntity<OperationResponseHistoryRetentionOpenApiVo> dataRetentionRes = omadaHistoryDataRetentionApi.getDataRetention();
@@ -115,4 +118,12 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
return true;
}
@Override
public String testJob() {
ResponseEntity<OperationResponseGridVoSiteSummaryInfo> siteList = omadaSiteApi.getSiteList(1, 1000);
if (siteList.getBody() != null && siteList.getBody().getErrorCode() == OMADA_SUCCESS_CODE) {
return "success";
}
return siteList.getBody().getMsg();
}
}