From c35a8ab56ba2242190c09edf02264f00d5c227fa Mon Sep 17 00:00:00 2001 From: lisai Date: Fri, 22 Jul 2022 22:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AD=97=E6=AE=B5=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zhdbaqapi/component/ScheduledTask.java | 6 ++- .../controller/DeviceInfoController.java | 5 +- .../zhdbaqapi/model/entity/DeviceInfo.java | 18 +++---- .../service/impl/DeviceInfoServiceimpl.java | 52 +++++++++++-------- 4 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java b/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java index a06ec87..45b84b9 100644 --- a/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java +++ b/src/main/java/com/whdc/zhdbaqapi/component/ScheduledTask.java @@ -17,6 +17,10 @@ public class ScheduledTask { @Scheduled(fixedDelay = 60000) public void scheduledTask() { - iDeviceDataService.syncData(); + String OS = System.getProperty("os.name").toLowerCase(); + // 简单粗暴的判断,在 linux 环境下运行时,为生成环境 + if (OS.contains("linux")) { + iDeviceDataService.syncData(); + } } } diff --git a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java index 8d1b913..c1a624f 100644 --- a/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java +++ b/src/main/java/com/whdc/zhdbaqapi/controller/DeviceInfoController.java @@ -1,7 +1,5 @@ package com.whdc.zhdbaqapi.controller; -import cn.afterturn.easypoi.excel.ExcelImportUtil; -import cn.afterturn.easypoi.excel.entity.ImportParams; import com.baomidou.mybatisplus.core.metadata.IPage; import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; import com.whdc.zhdbaqapi.model.dto.IntegerIdDto; @@ -14,7 +12,6 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -79,7 +76,7 @@ public class DeviceInfoController { @ApiOperation(value = "Excel数据导入") @PostMapping("/imp") public ResultJson imp(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception { - if(file == null){ + if (file == null) { return ResultJson.error("无效文件"); } diff --git a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java index 5b40fc3..7e7f66e 100644 --- a/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java +++ b/src/main/java/com/whdc/zhdbaqapi/model/entity/DeviceInfo.java @@ -37,7 +37,7 @@ public class DeviceInfo implements Serializable { * 主键id */ @ApiParam(value = "主键id") - @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer") + @ApiModelProperty(value = "主键id", dataType = "java.lang.Integer", position = 1) @TableId(value = "ID", type = IdType.AUTO) private Integer id; @@ -45,7 +45,7 @@ public class DeviceInfo implements Serializable { * 测点编号 */ @ApiParam(value = "测点编号") - @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true) + @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true, position = 2) @Excel(name = "测点编号") @NotEmpty(message = "测点编号必填") @TableField("STATION_CODE") @@ -55,7 +55,7 @@ public class DeviceInfo implements Serializable { * 测站编码(MCU) */ @ApiParam(value = "测站编码(MCU)") - @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String") + @ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String", required = true, position = 3) @Excel(name = "测站编码(MCU)") @NotEmpty(message = "测站编码(MCU)必填") @TableField("DEVICE_ID") @@ -65,7 +65,7 @@ public class DeviceInfo implements Serializable { * 通道号 */ @ApiParam(value = "通道号") - @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true) + @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true, position = 4) @Excel(name = "通道号") @NotNull(message = "通道号必填") @Max(message = "通道号最大值 7", value = 7) @@ -77,7 +77,7 @@ public class DeviceInfo implements Serializable { * 温度率定系娄(K) */ @ApiParam(value = "温度率定系娄(K)") - @ApiModelProperty(value = "温度率定系娄(K)", dataType = "java.math.BigDecimal", required = true) + @ApiModelProperty(value = "温度率定系娄(K)", dataType = "java.math.BigDecimal", required = true, position = 5) @Excel(name = "温度率定系娄(K)") @NotNull(message = "温度率定系娄(K)必填") @TableField("TEMPERATURE_K") @@ -87,7 +87,7 @@ public class DeviceInfo implements Serializable { * 初始温度读数 */ @ApiParam(value = "初始温度读数") - @ApiModelProperty(value = "初始温度读数", dataType = "java.lang.Double", required = true) + @ApiModelProperty(value = "初始温度读数", dataType = "java.lang.Double", required = true, position = 6) @Excel(name = "初始温度读数") @NotNull(message = "初始温度读数必填") @TableField("START_TEMPERATURE") @@ -97,7 +97,7 @@ public class DeviceInfo implements Serializable { * 率定系数(G) */ @ApiParam(value = "率定系数(G)") - @ApiModelProperty(value = "率定系数(G)", dataType = "java.math.BigDecimal", required = true) + @ApiModelProperty(value = "率定系数(G)", dataType = "java.math.BigDecimal", required = true, position = 7) @Excel(name = "率定系数(G)") @NotNull(message = "率定系数(G)必填") @TableField("CALIBRATION_COEFFICIENT") @@ -107,7 +107,7 @@ public class DeviceInfo implements Serializable { * 初始读数。单位是“模数”, 乘 1000 后开方得到频率值 */ @ApiParam(value = "初始读数") - @ApiModelProperty(value = "初始读数", notes = "单位是“模数”, 乘 1000 后开方得到频率值", dataType = "java.math.BigDecimal", required = true) + @ApiModelProperty(value = "初始读数", notes = "单位是“模数”, 乘 1000 后开方得到频率值", dataType = "java.math.BigDecimal", required = true, position = 8) @Excel(name = "初始读数") @NotNull(message = "初始读数必填") @TableField("INITIAL_READING") @@ -117,7 +117,7 @@ public class DeviceInfo implements Serializable { * 项目名称 */ @ApiParam(value = "项目名称") - @ApiModelProperty(value = "项目名称", dataType = "java.lang.String") + @ApiModelProperty(value = "项目名称", dataType = "java.lang.String", position = 9) @Excel(name = "工程或项目名称") @TableField("PROJECT_NAME") private String projectName; diff --git a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java b/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java index 0e7d006..c7ad067 100644 --- a/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java +++ b/src/main/java/com/whdc/zhdbaqapi/service/impl/DeviceInfoServiceimpl.java @@ -32,6 +32,36 @@ public class DeviceInfoServiceimpl extends ServiceImpl