From b7a585a0752de61ceb53fbed724f950ee7e1a839 Mon Sep 17 00:00:00 2001 From: lizhenzhen Date: Thu, 10 Oct 2024 18:29:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Eshapshot=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/bean/vo/SnapshotPutDoubleParam.java | 11 ++++++++ .../base/bean/vo/SnapshotPutIntParam.java | 11 ++++++++ .../beagle/base/common/util/SnapshotUtil.java | 28 ++++++++++++++++--- .../base/controller/SnapshotController.java | 14 ++++++++++ .../beagle/base/service/SnapshotService.java | 10 ++++--- .../service/impl/SnapshotServiceImpl.java | 16 ++++++++--- 6 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/beagle/base/bean/vo/SnapshotPutDoubleParam.java create mode 100644 src/main/java/com/beagle/base/bean/vo/SnapshotPutIntParam.java diff --git a/src/main/java/com/beagle/base/bean/vo/SnapshotPutDoubleParam.java b/src/main/java/com/beagle/base/bean/vo/SnapshotPutDoubleParam.java new file mode 100644 index 0000000..bc852e8 --- /dev/null +++ b/src/main/java/com/beagle/base/bean/vo/SnapshotPutDoubleParam.java @@ -0,0 +1,11 @@ +package com.beagle.base.bean.vo; + +import com.rtdb.model.DoubleData; +import lombok.Data; + +import java.util.List; + +@Data +public class SnapshotPutDoubleParam { + private List doubleDataList; +} diff --git a/src/main/java/com/beagle/base/bean/vo/SnapshotPutIntParam.java b/src/main/java/com/beagle/base/bean/vo/SnapshotPutIntParam.java new file mode 100644 index 0000000..2e4894d --- /dev/null +++ b/src/main/java/com/beagle/base/bean/vo/SnapshotPutIntParam.java @@ -0,0 +1,11 @@ +package com.beagle.base.bean.vo; + +import com.rtdb.model.IntData; +import lombok.Data; + +import java.util.List; + +@Data +public class SnapshotPutIntParam { + private List intDataList; +} diff --git a/src/main/java/com/beagle/base/common/util/SnapshotUtil.java b/src/main/java/com/beagle/base/common/util/SnapshotUtil.java index 6b684f3..0009d5f 100644 --- a/src/main/java/com/beagle/base/common/util/SnapshotUtil.java +++ b/src/main/java/com/beagle/base/common/util/SnapshotUtil.java @@ -2,11 +2,9 @@ package com.beagle.base.common.util; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson2.JSON; -import com.beagle.base.bean.vo.SnapshotBlobParam; -import com.beagle.base.bean.vo.SnapshotCoorParam; -import com.beagle.base.bean.vo.SnapshotDoubleParam; -import com.beagle.base.bean.vo.SnapshotIntParam; +import com.beagle.base.bean.vo.*; import com.rtdb.model.*; +import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; @@ -69,4 +67,26 @@ public class SnapshotUtil { return res; } } + + public static Integer putIntSnapshots(SnapshotPutIntParam param) { + Integer count = 0; + try { + count = CommonUtil.getSnapshotImpl().putIntSnapshots(param.getIntDataList()); + return count; + }catch (Exception e) { + log.error("base 获取putIntSnapshots接口异常,请求参数为:{}", JSON.toJSONString(param), e); + return count; + } + } + + public static Integer putDoubleSnapshots(SnapshotPutDoubleParam param) { + Integer count = 0; + try { + count = CommonUtil.getSnapshotImpl().putDoubleSnapshots(param.getDoubleDataList()); + return count; + }catch (Exception e) { + log.error("base 获取putDoubleSnapshots接口异常,请求参数为:{}", JSON.toJSONString(param), e); + return count; + } + } } diff --git a/src/main/java/com/beagle/base/controller/SnapshotController.java b/src/main/java/com/beagle/base/controller/SnapshotController.java index b57e0dc..24e4b35 100644 --- a/src/main/java/com/beagle/base/controller/SnapshotController.java +++ b/src/main/java/com/beagle/base/controller/SnapshotController.java @@ -11,6 +11,7 @@ import com.rtdb.model.IntData; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import io.swagger.models.auth.In; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -57,4 +58,17 @@ public class SnapshotController { return new Response<>(snapshotService.getCoorSnapshots(param)); } + @ApiOperationSupport(order = 5) + @ApiOperation(value = "批量写入开关量、模拟量快照数值") + @PostMapping("/putIntSnapshots") + public Response putIntSnapshots(@RequestBody @ApiParam(value = "入参") @Validated SnapshotPutIntParam param) { + return new Response<>(snapshotService.putIntSnapshots(param)); + } + + @ApiOperationSupport(order = 6) + @ApiOperation(value = "批量插入标签点类型为双精度浮点型的快照值") + @PostMapping("/putDoubleSnapshots") + public Response putDoubleSnapshots(@RequestBody @ApiParam(value = "入参") @Validated SnapshotPutDoubleParam param) { + return new Response<>(snapshotService.putDoubleSnapshots(param)); + } } diff --git a/src/main/java/com/beagle/base/service/SnapshotService.java b/src/main/java/com/beagle/base/service/SnapshotService.java index 5fbcb99..26d9cda 100644 --- a/src/main/java/com/beagle/base/service/SnapshotService.java +++ b/src/main/java/com/beagle/base/service/SnapshotService.java @@ -1,9 +1,6 @@ package com.beagle.base.service; -import com.beagle.base.bean.vo.SnapshotBlobParam; -import com.beagle.base.bean.vo.SnapshotCoorParam; -import com.beagle.base.bean.vo.SnapshotDoubleParam; -import com.beagle.base.bean.vo.SnapshotIntParam; +import com.beagle.base.bean.vo.*; import com.rtdb.model.BlobData; import com.rtdb.model.CoorData; import com.rtdb.model.DoubleData; @@ -23,4 +20,9 @@ public interface SnapshotService { List getBlobSnapshots(SnapshotBlobParam param); List getCoorSnapshots(SnapshotCoorParam param); + + Integer putIntSnapshots(SnapshotPutIntParam param); + + Integer putDoubleSnapshots(SnapshotPutDoubleParam param); + } diff --git a/src/main/java/com/beagle/base/service/impl/SnapshotServiceImpl.java b/src/main/java/com/beagle/base/service/impl/SnapshotServiceImpl.java index 30219f9..458d95d 100644 --- a/src/main/java/com/beagle/base/service/impl/SnapshotServiceImpl.java +++ b/src/main/java/com/beagle/base/service/impl/SnapshotServiceImpl.java @@ -1,10 +1,7 @@ package com.beagle.base.service.impl; -import com.beagle.base.bean.vo.SnapshotBlobParam; -import com.beagle.base.bean.vo.SnapshotCoorParam; -import com.beagle.base.bean.vo.SnapshotDoubleParam; -import com.beagle.base.bean.vo.SnapshotIntParam; +import com.beagle.base.bean.vo.*; import com.beagle.base.common.util.SnapshotUtil; import com.beagle.base.service.SnapshotService; import com.rtdb.model.BlobData; @@ -41,6 +38,17 @@ public class SnapshotServiceImpl implements SnapshotService { @Override public List getCoorSnapshots(SnapshotCoorParam param) { return SnapshotUtil.getCoorSnapshots(param); + } + + @Override + public Integer putIntSnapshots(SnapshotPutIntParam param) { + return SnapshotUtil.putIntSnapshots(param); + } + + @Override + public Integer putDoubleSnapshots(SnapshotPutDoubleParam param) { + return SnapshotUtil.putDoubleSnapshots(param); } } + -- 2.26.0