|
|
@ -14,6 +14,7 @@ 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.core.redis.RedisCache; |
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil; |
|
|
|
import com.ruoyi.common.utils.uuid.IdUtils; |
|
|
|
import com.ruoyi.system.service.ISysConfigService; |
|
|
|
import com.zc.business.controller.DcNmcController; |
|
|
@ -29,14 +30,19 @@ import com.zc.common.core.httpclient.request.RequestParams; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import okhttp3.*; |
|
|
|
import org.apache.poi.ss.SpreadsheetVersion; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.PostMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
import java.lang.reflect.Field; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.ZoneId; |
|
|
@ -76,6 +82,30 @@ public class ExternalInterfaceMonitoringTask extends BaseController { |
|
|
|
@GetMapping("/list") |
|
|
|
public TableDataInfo list(ExternalInterfaceMonitoring externalInterfaceMonitoring) { |
|
|
|
startPage(); |
|
|
|
List<ExternalInterfaceMonitoring> list = selectExternal(externalInterfaceMonitoring); |
|
|
|
return getDataTable(list); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 外部接口监测数据导出 |
|
|
|
*/ |
|
|
|
@PostMapping("/export") |
|
|
|
public void export(HttpServletResponse response, ExternalInterfaceMonitoring externalInterfaceMonitoring) throws UnsupportedEncodingException { |
|
|
|
List<ExternalInterfaceMonitoring> list = selectExternal(externalInterfaceMonitoring); |
|
|
|
list.forEach(external -> { |
|
|
|
external.setOperationStatusName(external.getOperationStatus().equals(UniversalEnum.ONE.getNumber()) ? "成功" : "失败"); |
|
|
|
external.setInterfaceOwnershipName(Arrays.stream(InterfaceOwnershipEnum.values()) |
|
|
|
.filter(interfaceOwnershipEnum -> interfaceOwnershipEnum.getCode().equals(external.getInterfaceOwnership())) |
|
|
|
.findFirst() |
|
|
|
.map(InterfaceOwnershipEnum::getOwnershipName) |
|
|
|
.orElse(UniversalEnum.OTHER.getValue())); |
|
|
|
}); |
|
|
|
ExcelUtil<ExternalInterfaceMonitoring> util = new ExcelUtil<>(ExternalInterfaceMonitoring.class); |
|
|
|
resetCellMaxTextLength(); |
|
|
|
util.exportExcel(response, list, "外部接口监测数据"); |
|
|
|
} |
|
|
|
|
|
|
|
public List<ExternalInterfaceMonitoring> selectExternal(ExternalInterfaceMonitoring externalInterfaceMonitoring) { |
|
|
|
LambdaQueryWrapper<ExternalInterfaceMonitoring> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
if (externalInterfaceMonitoring.getInterfaceOwnership() != null) { |
|
|
|
lambdaQueryWrapper.eq(ExternalInterfaceMonitoring::getInterfaceOwnership, externalInterfaceMonitoring.getInterfaceOwnership()); |
|
|
@ -86,9 +116,15 @@ public class ExternalInterfaceMonitoringTask extends BaseController { |
|
|
|
if (externalInterfaceMonitoring.getInterfaceName() != null) { |
|
|
|
lambdaQueryWrapper.like(ExternalInterfaceMonitoring::getInterfaceName, externalInterfaceMonitoring.getInterfaceName()); |
|
|
|
} |
|
|
|
if (externalInterfaceMonitoring.getStartTime() != null && externalInterfaceMonitoring.getEndTime() != null) { |
|
|
|
lambdaQueryWrapper.between( |
|
|
|
ExternalInterfaceMonitoring::getOperationTime, |
|
|
|
externalInterfaceMonitoring.getStartTime(), |
|
|
|
externalInterfaceMonitoring.getEndTime() |
|
|
|
); |
|
|
|
} |
|
|
|
lambdaQueryWrapper.orderByDesc(ExternalInterfaceMonitoring::getOperationTime); |
|
|
|
List<ExternalInterfaceMonitoring> list = externalInterfaceMonitoringMapper.selectList(lambdaQueryWrapper); |
|
|
|
return getDataTable(list); |
|
|
|
return externalInterfaceMonitoringMapper.selectList(lambdaQueryWrapper); |
|
|
|
} |
|
|
|
|
|
|
|
@Scheduled(cron = "0 0/15 * * * ?") |
|
|
@ -842,4 +878,25 @@ public class ExternalInterfaceMonitoringTask extends BaseController { |
|
|
|
voiceBroadcastingToken = JSONObject.parseObject(response.body().string()).getString("accessToken"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 利用反射,修改单元格最大长度 |
|
|
|
*/ |
|
|
|
public static void resetCellMaxTextLength() { |
|
|
|
SpreadsheetVersion excel2007 = SpreadsheetVersion.EXCEL2007; |
|
|
|
if (Integer.MAX_VALUE != excel2007.getMaxTextLength()) { |
|
|
|
Field field; |
|
|
|
try { |
|
|
|
// SpreadsheetVersion.EXCEL2007的_maxTextLength变量
|
|
|
|
field = excel2007.getClass().getDeclaredField("_maxTextLength"); |
|
|
|
// 关闭反射机制的安全检查,可以提高性能
|
|
|
|
field.setAccessible(true); |
|
|
|
// 重新设置这个变量属性值
|
|
|
|
field.set(excel2007, Integer.MAX_VALUE); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|