新增定时任务和治理数据最新时间记录
This commit is contained in:
@@ -0,0 +1,62 @@
|
|||||||
|
package com.njcn.csdevice.job;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import com.njcn.csdevice.service.IRStatIntegrityDService;
|
||||||
|
import com.njcn.csdevice.service.IRStatOnlineRateDService;
|
||||||
|
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author xy
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@EnableScheduling
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class DayDataJob {
|
||||||
|
|
||||||
|
private final IRStatIntegrityDService statIntegrityDService;
|
||||||
|
private final IRStatOnlineRateDService statOnlineRateDService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每天1点计算治理设备的完整性
|
||||||
|
*
|
||||||
|
* @date 2025/7/1
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 1 * * ?")
|
||||||
|
public void lineIntegrityJob() {
|
||||||
|
StatisticsDataParam param = new StatisticsDataParam();
|
||||||
|
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||||
|
LocalDateTime start = yesterday.atStartOfDay();
|
||||||
|
LocalDateTime end = yesterday.atTime(23, 59, 59);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN);
|
||||||
|
param.setStartTime(start.format(formatter));
|
||||||
|
param.setEndTime(end.format(formatter));
|
||||||
|
statIntegrityDService.addData(param);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每天2点计算治理设备的在线率
|
||||||
|
*
|
||||||
|
* @date 2025/7/1
|
||||||
|
*/
|
||||||
|
@Scheduled(cron = "0 0 2 * * ?")
|
||||||
|
public void devOnlineRateJob() {
|
||||||
|
StatisticsDataParam param = new StatisticsDataParam();
|
||||||
|
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||||
|
LocalDateTime start = yesterday.atStartOfDay();
|
||||||
|
LocalDateTime end = yesterday.atTime(23, 59, 59);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN);
|
||||||
|
param.setStartTime(start.format(formatter));
|
||||||
|
param.setEndTime(end.format(formatter));
|
||||||
|
statOnlineRateDService.addData(param);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -391,17 +391,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
List<CsDataSet> dataSet = new ArrayList<>();
|
List<CsDataSet> dataSet = new ArrayList<>();
|
||||||
//治理监测点
|
//治理监测点
|
||||||
if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())){
|
if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||||
// select
|
|
||||||
// t1.id
|
|
||||||
// from
|
|
||||||
// cs_dev_model_relation t0
|
|
||||||
// left join cs_dev_model t1 on
|
|
||||||
// t0.model_id = t1.id
|
|
||||||
// where
|
|
||||||
// t0.status="1" and
|
|
||||||
// t0.dev_id = #{devId} and t1.`type` = #{type}
|
|
||||||
modelId = csDevModelRelationService.getModelByType(deviceId,0);
|
modelId = csDevModelRelationService.getModelByType(deviceId,0);
|
||||||
//select * from cs_data_set where pid = modelId and clDev = 0
|
|
||||||
dataSet = csDataSetService.findDataSetByModelId(modelId,0);
|
dataSet = csDataSetService.findDataSetByModelId(modelId,0);
|
||||||
}
|
}
|
||||||
//电网侧监测点
|
//电网侧监测点
|
||||||
@@ -447,6 +437,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
|||||||
addDataSet(dataSetList, item, "最新数据", "rt");
|
addDataSet(dataSetList, item, "最新数据", "rt");
|
||||||
addDataSet(dataSetList, item, "历史统计数据", "history");
|
addDataSet(dataSetList, item, "历史统计数据", "history");
|
||||||
addDataSet(dataSetList, item, "历史趋势", "trenddata");
|
addDataSet(dataSetList, item, "历史趋势", "trenddata");
|
||||||
|
addDataSet(dataSetList, item, "模块数据", "moduleData");
|
||||||
if (isPortableDevice) {
|
if (isPortableDevice) {
|
||||||
// 便携式设备特有的数据集
|
// 便携式设备特有的数据集
|
||||||
addDataSet(dataSetList, item, "实时数据", "realtimedata");
|
addDataSet(dataSetList, item, "实时数据", "realtimedata");
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.njcn.csharmonic.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.github.jeffreyning.mybatisplus.anno.MppMultiId;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 治理设备模块运行状态记录表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2025-07-03
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@TableName("cs_line_latest_data")
|
||||||
|
public class CsLineLatestData implements Serializable{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监测点id
|
||||||
|
*/
|
||||||
|
@MppMultiId(value = "line_id")
|
||||||
|
private String lineId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 最新数据时间
|
||||||
|
*/
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime timeId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.njcn.csharmonic.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
|
import com.njcn.common.pojo.response.HttpResult;
|
||||||
|
import com.njcn.common.utils.HttpResultUtil;
|
||||||
|
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsLineLatestData;
|
||||||
|
import com.njcn.csharmonic.service.ICsLineLatestDataService;
|
||||||
|
import com.njcn.web.controller.BaseController;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 治理设备模块运行状态记录表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2025-07-03
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csLineLatestData")
|
||||||
|
@Api(tags = "暂降事件")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsLineLatestDataController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsLineLatestDataService csLineLatestDataService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/add")
|
||||||
|
@ApiOperation("新增")
|
||||||
|
@ApiImplicitParam(name = "csLineLatestData", value = "实体", required = true)
|
||||||
|
public HttpResult<String> addData(@RequestBody CsLineLatestData csLineLatestData) {
|
||||||
|
String methodDescribe = getMethodDescribe("addData");
|
||||||
|
csLineLatestDataService.addData(csLineLatestData);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/list")
|
||||||
|
@ApiOperation("查询")
|
||||||
|
@ApiImplicitParam(name = "csEventUserQueryParam", value = "暂降事件查询参数", required = true)
|
||||||
|
public HttpResult<List<CsLineLatestData>> listData(@RequestBody CsEventUserQueryParam csEventUserQueryParam) {
|
||||||
|
String methodDescribe = getMethodDescribe("queryEventList");
|
||||||
|
List<CsLineLatestData> list = csLineLatestDataService.list();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.njcn.csharmonic.mapper;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.base.MppBaseMapper;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsLineLatestData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 治理设备模块运行状态记录表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2025-07-03
|
||||||
|
*/
|
||||||
|
public interface CsLineLatestDataMapper extends MppBaseMapper<CsLineLatestData> {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.njcn.csharmonic.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsLineLatestData;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 治理设备模块运行状态记录表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2025-07-03
|
||||||
|
*/
|
||||||
|
public interface ICsLineLatestDataService extends IService<CsLineLatestData> {
|
||||||
|
|
||||||
|
void addData(CsLineLatestData csLineLatestData);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.njcn.csharmonic.service.impl;
|
||||||
|
|
||||||
|
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||||
|
import com.njcn.csharmonic.mapper.CsLineLatestDataMapper;
|
||||||
|
import com.njcn.csharmonic.pojo.po.CsLineLatestData;
|
||||||
|
import com.njcn.csharmonic.service.ICsLineLatestDataService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 治理设备模块运行状态记录表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xy
|
||||||
|
* @since 2025-07-03
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CsLineLatestDataServiceImpl extends MppServiceImpl<CsLineLatestDataMapper, CsLineLatestData> implements ICsLineLatestDataService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addData(CsLineLatestData csLineLatestData) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user