1.入库添加集合数量
2.同步监测点、装置状态
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package com.njcn.migration.read.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.migration.read.service.ISyncStatusService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/syncStatus")
|
||||
@Api(tags = "同步状态")
|
||||
@AllArgsConstructor
|
||||
public class SyncStatusController extends BaseController {
|
||||
|
||||
private final ISyncStatusService syncStatusService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/syncDevStatus")
|
||||
@ApiOperation("同步装置状态")
|
||||
public HttpResult<String> syncDevStatus(){
|
||||
String methodDescribe = getMethodDescribe("syncDevStatus");
|
||||
syncStatusService.syncDevStatus();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/syncLineStatus")
|
||||
@ApiOperation("同步监测点状态")
|
||||
public HttpResult<String> syncLineStatus(){
|
||||
String methodDescribe = getMethodDescribe("syncLineStatus");
|
||||
syncStatusService.syncLineStatus();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,8 +45,8 @@ public class MigrationInfluxDBJob {
|
||||
public void InfluxDBJob() {
|
||||
// 获取当前时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
// 减去一个小时
|
||||
LocalDateTime oneHourAgo = now.minusHours(1);
|
||||
// 减去2个小时
|
||||
LocalDateTime oneHourAgo = now.minusHours(2);
|
||||
// 将分钟和秒设置为0
|
||||
LocalDateTime result = oneHourAgo.truncatedTo(ChronoUnit.HOURS);
|
||||
// 加上59分钟59秒
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.migration.read.job;
|
||||
|
||||
import com.njcn.migration.read.service.ISyncStatusService;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/1/18 10:15【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class SyncStatusJob {
|
||||
|
||||
private final ISyncStatusService syncStatusService;
|
||||
|
||||
@Scheduled(cron="0 0/10 * * * ?")
|
||||
public void syncRunFlag() {
|
||||
System.out.println("--------------------------------装置、监测点运行状态同步------------------------------------");
|
||||
syncStatusService.syncDevStatus();
|
||||
syncStatusService.syncLineStatus();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.migration.read.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.po.mysql.Device;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2022-01-04
|
||||
*/
|
||||
public interface DeviceMapper extends BaseMapper<Device> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.migration.read.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.po.mysql.LineDetail;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author cdf
|
||||
* @since 2022-01-04
|
||||
*/
|
||||
public interface LineDetailMapper extends BaseMapper<LineDetail> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.njcn.migration.read.service;
|
||||
|
||||
public interface ISyncStatusService {
|
||||
|
||||
void syncDevStatus();
|
||||
|
||||
void syncLineStatus();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.migration.read.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.api.SyncStatusFeignClient;
|
||||
import com.njcn.migration.read.mapper.DeviceMapper;
|
||||
import com.njcn.migration.read.mapper.LineDetailMapper;
|
||||
import com.njcn.migration.read.service.ISyncStatusService;
|
||||
import com.njcn.po.mysql.Device;
|
||||
import com.njcn.po.mysql.LineDetail;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class SyncStatusServiceImpl implements ISyncStatusService {
|
||||
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final LineDetailMapper lineDetailMapper;
|
||||
private final SyncStatusFeignClient syncStatusFeignClient;
|
||||
|
||||
@Override
|
||||
public void syncDevStatus() {
|
||||
Wrapper<Device> wrapper = new QueryWrapper<>();
|
||||
List<Device> list = deviceMapper.selectList(wrapper);
|
||||
if (!list.isEmpty()) {
|
||||
//调用修改程序
|
||||
syncStatusFeignClient.syncDevStatusUpdate(list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncLineStatus() {
|
||||
Wrapper<LineDetail> wrapper = new QueryWrapper<>();
|
||||
List<LineDetail> list = lineDetailMapper.selectList(wrapper);
|
||||
if (!list.isEmpty()) {
|
||||
//调用修改程序
|
||||
syncStatusFeignClient.syncLineStatusUpdate(list);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user