1.终端周期检测定时任务

2.监测点超标统计定时任务
This commit is contained in:
xy
2024-06-26 11:22:53 +08:00
parent 5c36e2e4f4
commit 16e90de9eb
7 changed files with 21 additions and 21 deletions

View File

@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping;
@FeignClient(value = ServerInfo.SUPERVISION, path = "/onlineMonitor", fallbackFactory = LineWarningFeignClientFallbackFactory.class) @FeignClient(value = ServerInfo.SUPERVISION, path = "/onlineMonitor", fallbackFactory = LineWarningFeignClientFallbackFactory.class)
public interface LineWarningFeignClient { public interface LineWarningFeignClient {
@PostMapping("/add") @PostMapping("/heBeiNorthAdd")
HttpResult<String> add(); HttpResult<String> heBeiNorthAdd();
} }

View File

@@ -10,9 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* @author denghuajun * @author xy
* @version 1.0.0
* @date 2022/3/16
*/ */
@Slf4j @Slf4j
@Component @Component
@@ -28,8 +26,8 @@ public class LineWarningFeignClientFallbackFactory implements FallbackFactory<Li
Enum<?> finalExceptionEnum = exceptionEnum; Enum<?> finalExceptionEnum = exceptionEnum;
return new LineWarningFeignClient() { return new LineWarningFeignClient() {
@Override @Override
public HttpResult<String> add() { public HttpResult<String> heBeiNorthAdd() {
log.error("{}异常,降级处理,异常为:{}", "新增终端检测数据", throwable.toString()); log.error("{}异常,降级处理,异常为:{}", "新增在线监测数据(冀北-按月统计累计超标天数)", throwable.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
}; };

View File

@@ -53,7 +53,7 @@ public class OnlineParam extends BaseParam implements Serializable {
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class ReportParam extends OnlineParam { public static class ReportParam extends OnlineParam {
@ApiModelProperty(name = "type", value = "0:预警单 1:告警单") @ApiModelProperty(name = "type", value = "1:预警单 2:告警单")
private Integer type; private Integer type;
@ApiModelProperty(name = "issueDetail", value = "问题描述") @ApiModelProperty(name = "issueDetail", value = "问题描述")

View File

@@ -13,14 +13,12 @@ import com.njcn.supervision.service.device.ILineWarningService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@@ -55,9 +53,13 @@ public class LineWarningController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/heBeiNorthAdd") @PostMapping("/heBeiNorthAdd")
@ApiOperation("新增在线监测数据(冀北-按月统计累计超标天数)") @ApiOperation("新增在线监测数据(冀北-按月统计累计超标天数)")
public HttpResult<String> heBeiNorthAdd() { @ApiImplicitParams({
@ApiImplicitParam(name = "startTime", value = "开始时间"),
@ApiImplicitParam(name = "endTime", value = "结束时间")
})
public HttpResult<String> heBeiNorthAdd(@RequestParam(value = "startTime",required = false) String startTime, @RequestParam(value = "endTime",required = false) String endTime) {
String methodDescribe = getMethodDescribe("heBeiNorthAdd"); String methodDescribe = getMethodDescribe("heBeiNorthAdd");
lineWarningService.addHeBeiNorthLineWarning(); lineWarningService.addHeBeiNorthLineWarning(startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }

View File

@@ -26,7 +26,7 @@ public interface ILineWarningService extends IService<LineWarning> {
/** /**
* 每日统计当前月各监测点各指标累计超标天数 * 每日统计当前月各监测点各指标累计超标天数
*/ */
void addHeBeiNorthLineWarning(); void addHeBeiNorthLineWarning(String startTime, String endTime);
/** /**
* 获取在线监测的数据列表 * 获取在线监测的数据列表

View File

@@ -131,18 +131,18 @@ public class LineWarningServiceImpl extends MppServiceImpl<LineWarningMapper, Li
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addHeBeiNorthLineWarning() { public void addHeBeiNorthLineWarning(String startTime, String endTime) {
List<LineWarning> result = new ArrayList<>(); List<LineWarning> result = new ArrayList<>();
//获取指标集合(8个指标,包含总指标) //获取指标集合(8个指标)
List<DictData> dataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.INDICATOR_TYPE.getCode()).getData(); List<DictData> dataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.INDICATOR_TYPE.getCode()).getData();
Map<String, DictData> targetMap = dataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity())); Map<String, DictData> targetMap = dataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity()));
//获取监测点和部门表关系 //获取监测点和部门表关系
List<DeptLine> deptLines = deptLineFeignClient.getAllData().getData(); List<DeptLine> deptLines = deptLineFeignClient.getAllData().getData();
Map<String, List<DeptLine>> deptLineMap = deptLines.stream().collect(Collectors.groupingBy(DeptLine::getLineId)); Map<String, List<DeptLine>> deptLineMap = deptLines.stream().collect(Collectors.groupingBy(DeptLine::getLineId));
//获取监测点按时间统计越限天数 //获取监测点按时间统计越限天数
LocalDate firstDayOfMonth = LocalDate.now().minusDays(1).with(TemporalAdjusters.firstDayOfMonth()); LocalDate firstDayOfMonth = Objects.isNull(startTime)?LocalDate.now().minusDays(1).with(TemporalAdjusters.firstDayOfMonth()):LocalDate.parse(startTime);
String date = DateUtil.format(firstDayOfMonth.atStartOfDay(), DatePattern.NORM_DATE_PATTERN); String date = Objects.isNull(startTime)?DateUtil.format(firstDayOfMonth.atStartOfDay(), DatePattern.NORM_DATE_PATTERN):startTime;
String endDate = DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN); String endDate = Objects.isNull(endTime)?DateUtil.format(LocalDateTime.now().minusDays(1), DatePattern.NORM_DATE_PATTERN):endTime;
RStatLimitQueryParam rStatLimitQueryParam = new RStatLimitQueryParam(null,date,endDate); RStatLimitQueryParam rStatLimitQueryParam = new RStatLimitQueryParam(null,date,endDate);
List<RStatLimitTargetVO> limitTarget = limitRateDClient.monitorOverLimitDays(rStatLimitQueryParam).getData(); List<RStatLimitTargetVO> limitTarget = limitRateDClient.monitorOverLimitDays(rStatLimitQueryParam).getData();
//按各指标统计越限天数 //按各指标统计越限天数

View File

@@ -16,6 +16,6 @@ public class LineWarningTaskRunner implements TimerTaskRunner {
@Override @Override
public void action(String date) { public void action(String date) {
lineWarningFeignClient.add(); lineWarningFeignClient.heBeiNorthAdd();
} }
} }