From f3d3ff04f6f9402a121b3eaa997f0ea6d4bd7a31 Mon Sep 17 00:00:00 2001 From: xjm Date: Mon, 19 Aug 2024 16:29:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=97=E5=8E=8B,=E6=B8=97=E6=B5=81,=E4=BD=8D?= =?UTF-8?q?=E7=A7=BB=E6=96=B0=E5=A2=9E=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xyt/controller/OsmoticFlowDeviceController.java | 6 ++++-- .../xyt/controller/OsmoticPressDeviceController.java | 6 +++++- .../xyt/controller/OsmoticShiftDeviceController.java | 10 ++++++++++ .../gunshi/project/xyt/model/OsmoticFlowDevice.java | 9 +++++++++ .../gunshi/project/xyt/model/OsmoticPressDevice.java | 8 ++++++++ .../gunshi/project/xyt/model/OsmoticShiftDevice.java | 11 +++++++++++ 6 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gunshi/project/xyt/controller/OsmoticFlowDeviceController.java b/src/main/java/com/gunshi/project/xyt/controller/OsmoticFlowDeviceController.java index 97e3df3..5be173a 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/OsmoticFlowDeviceController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/OsmoticFlowDeviceController.java @@ -20,6 +20,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.io.Serializable; +import java.util.Date; import java.util.List; import java.util.Objects; @@ -47,7 +48,7 @@ public class OsmoticFlowDeviceController extends AbstractCommonFileController{ throw new IllegalArgumentException("当前编号已存在"); } - + dto.setCreateTime(new Date()); boolean result = service.save(dto); if (result){ fileService.saveFile(dto.getFiles(), getGroupId(), dto.getProfileCode()); @@ -61,7 +62,7 @@ public class OsmoticFlowDeviceController extends AbstractCommonFileController{ if (Objects.isNull(service.getById(dto.getStationCode()))) { throw new IllegalArgumentException("当前数据不存在"); } - + dto.setCreateTime(null); boolean result = service.updateById(dto); if (result){ fileService.saveFile(dto.getFiles(), getGroupId(), dto.getProfileCode()); @@ -94,6 +95,7 @@ public class OsmoticFlowDeviceController extends AbstractCommonFileController{ if (ObjectUtils.isNotNull(page.getDeviceCode())) { query.like(OsmoticFlowDevice::getDeviceName, page.getDeviceCode()); } + query.orderByDesc(OsmoticFlowDevice::getCreateTime); Page data = service.page(page.getPageSo().toPage(), query); data.getRecords().forEach(o -> o.setFiles( diff --git a/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressDeviceController.java b/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressDeviceController.java index 4239d1c..727bf42 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressDeviceController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/OsmoticPressDeviceController.java @@ -20,6 +20,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.io.Serializable; +import java.util.Date; import java.util.List; import java.util.Objects; @@ -45,7 +46,7 @@ public class OsmoticPressDeviceController extends AbstractCommonFileController{ if (Objects.nonNull(service.getById(dto.getStationCode()))) { throw new IllegalArgumentException("当前编号已存在"); } - + dto.setCreateTime(new Date()); boolean result = service.save(dto); if (result){ fileService.saveFile(dto.getFiles(), getGroupId(), dto.getStationCode()); @@ -59,6 +60,7 @@ public class OsmoticPressDeviceController extends AbstractCommonFileController{ if (Objects.isNull(service.getById(dto.getStationCode()))) { throw new IllegalArgumentException("当前数据不存在"); } + dto.setCreateTime(null); boolean result = service.updateById(dto); if (result){ fileService.saveFile(dto.getFiles(), getGroupId(), dto.getStationCode()); @@ -93,6 +95,8 @@ public class OsmoticPressDeviceController extends AbstractCommonFileController{ query.like(OsmoticPressDevice::getDeviceName, page.getDeviceCode()); } + query.orderByDesc(OsmoticPressDevice::getCreateTime); + Page data = service.page(page.getPageSo().toPage(), query); data.getRecords().forEach(o -> o.setFiles( fileService.getFiles(getGroupId(),o.getStationCode()) diff --git a/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftDeviceController.java b/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftDeviceController.java index 083c06d..e4c57ea 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftDeviceController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/OsmoticShiftDeviceController.java @@ -14,7 +14,9 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.io.Serializable; +import java.util.Date; import java.util.List; +import java.util.Objects; /** * 描述: 位移监测记录表 @@ -33,6 +35,10 @@ public class OsmoticShiftDeviceController { @Operation(summary = "新增") @PostMapping("/insert") public R insert(@Validated(Insert.class) @RequestBody OsmoticShiftDevice dto) { + if (Objects.nonNull(service.getById(dto.getStationCode()))) { + throw new IllegalArgumentException("当前编号已存在"); + } + dto.setCreateTime(new Date()); boolean result = service.save(dto); return R.ok(result ? dto : null); } @@ -40,6 +46,10 @@ public class OsmoticShiftDeviceController { @Operation(summary = "修改") @PostMapping("/update") public R update(@Validated(Update.class) @RequestBody OsmoticShiftDevice dto) { + if (Objects.isNull(service.getById(dto.getStationCode()))) { + throw new IllegalArgumentException("当前数据不存在"); + } + dto.setCreateTime(null); boolean result = service.updateById(dto); return R.ok(result ? dto : null); } diff --git a/src/main/java/com/gunshi/project/xyt/model/OsmoticFlowDevice.java b/src/main/java/com/gunshi/project/xyt/model/OsmoticFlowDevice.java index 05f9cb3..af0999a 100644 --- a/src/main/java/com/gunshi/project/xyt/model/OsmoticFlowDevice.java +++ b/src/main/java/com/gunshi/project/xyt/model/OsmoticFlowDevice.java @@ -185,6 +185,15 @@ public class OsmoticFlowDevice implements Serializable { // @Size(max = 0,message = "纬度最大长度要小于 0") private String lttd; + /** + * 创建时间 + */ + @TableField(value="create_time") + @Schema(description="创建时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date createTime; + + @TableField(exist = false) @Schema(description = "文件集合") private List files; diff --git a/src/main/java/com/gunshi/project/xyt/model/OsmoticPressDevice.java b/src/main/java/com/gunshi/project/xyt/model/OsmoticPressDevice.java index ba80563..d21d02f 100644 --- a/src/main/java/com/gunshi/project/xyt/model/OsmoticPressDevice.java +++ b/src/main/java/com/gunshi/project/xyt/model/OsmoticPressDevice.java @@ -193,6 +193,14 @@ public class OsmoticPressDevice implements Serializable { // @Size(max = 0,message = "纬度最大长度要小于 0") private String lttd; + /** + * 创建时间 + */ + @TableField(value="create_time") + @Schema(description="创建时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date createTime; + @TableField(exist = false) @Schema(description = "文件集合") diff --git a/src/main/java/com/gunshi/project/xyt/model/OsmoticShiftDevice.java b/src/main/java/com/gunshi/project/xyt/model/OsmoticShiftDevice.java index ba92c2a..aba1f5e 100644 --- a/src/main/java/com/gunshi/project/xyt/model/OsmoticShiftDevice.java +++ b/src/main/java/com/gunshi/project/xyt/model/OsmoticShiftDevice.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gunshi.core.dateformat.DateFormatString; import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Update; import io.swagger.v3.oas.annotations.media.Schema; @@ -14,6 +16,7 @@ import lombok.Data; import java.io.Serializable; import java.math.BigDecimal; +import java.util.Date; /** * 描述: 位移设备表 @@ -73,4 +76,12 @@ public class OsmoticShiftDevice implements Serializable { @TableField(value="lttd") @Schema(description="纬度") private BigDecimal lttd; + + /** + * 创建时间 + */ + @TableField(value="create_time") + @Schema(description="创建时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + private Date createTime; }