lisai 2022-07-22 12:19:58 +08:00
parent 46395a31ba
commit 303fb35ae9
12 changed files with 282 additions and 68 deletions

View File

@ -65,6 +65,11 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId> <artifactId>spring-boot-starter-cache</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<!-- Sa-Token 权限认证, 在线文档http://sa-token.dev33.cn/ --> <!-- Sa-Token 权限认证, 在线文档http://sa-token.dev33.cn/ -->

View File

@ -1,20 +1,23 @@
package com.whdc.zhdbaqapi.controller; 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.baomidou.mybatisplus.core.metadata.IPage;
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
import com.whdc.zhdbaqapi.model.dto.IntegerIdDto; import com.whdc.zhdbaqapi.model.dto.IntegerIdDto;
import com.whdc.zhdbaqapi.model.dto.StationCodeDto; import com.whdc.zhdbaqapi.model.dto.StationCodeDto;
import com.whdc.zhdbaqapi.model.entity.DeviceInfo; import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
import com.whdc.zhdbaqapi.service.IDeviceInfoService; import com.whdc.zhdbaqapi.service.IDeviceInfoService;
import com.whdc.zhdbaqapi.utils.ResultJson; import com.whdc.zhdbaqapi.utils.ResultJson;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@ -25,6 +28,7 @@ import java.util.List;
@Api(tags = "设备信息 - Controller") @Api(tags = "设备信息 - Controller")
@RestController @RestController
@RequestMapping("/v1/deviceInfo") @RequestMapping("/v1/deviceInfo")
@Slf4j
public class DeviceInfoController { public class DeviceInfoController {
@Autowired @Autowired
@ -71,4 +75,14 @@ public class DeviceInfoController {
public ResultJson<IPage<DeviceInfo>> page(@RequestBody FindDeviceDto findDto) { public ResultJson<IPage<DeviceInfo>> page(@RequestBody FindDeviceDto findDto) {
return ResultJson.ok(iDeviceInfoService.page(findDto)); return ResultJson.ok(iDeviceInfoService.page(findDto));
} }
@ApiOperation(value = "Excel数据导入")
@PostMapping("/imp")
public ResultJson<DeviceInfoImpVo> imp(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception {
if(file == null){
return ResultJson.error("无效文件");
}
return ResultJson.ok(iDeviceInfoService.imp(file.getInputStream()));
}
} }

View File

@ -8,6 +8,7 @@ import com.whdc.zhdbaqapi.model.entity.SysUser;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* @author * @author
@ -32,4 +33,19 @@ public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> {
* @return * @return
*/ */
IPage<DeviceInfo> page(@Param("page") IPage<SysUser> page, @Param("obj") FindDeviceDto findDto); IPage<DeviceInfo> page(@Param("page") IPage<SysUser> page, @Param("obj") FindDeviceDto findDto);
/**
* stationCode
*
* @param scs
* @return
*/
List<DeviceInfo> listBySC(Set<String> scs);
/**
* station_code
* @param stationCode
* @return
*/
DeviceInfo checkValidStationCode(String stationCode);
} }

View File

@ -12,6 +12,6 @@ public class FindDeviceDto extends FindPageDto {
@ApiModelProperty(value = "站点编码", dataType = "java.lang.String") @ApiModelProperty(value = "站点编码", dataType = "java.lang.String")
private String deviceId; private String deviceId;
@ApiModelProperty(value = "测头编码", dataType = "java.lang.String") @ApiModelProperty(value = "测点编号", dataType = "java.lang.String")
private String stationCode; private String stationCode;
} }

View File

@ -15,8 +15,8 @@ import java.io.Serializable;
public class StationCodeDto implements Serializable { public class StationCodeDto implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiParam(value = "测头编码", example = "") @ApiParam(value = "测点编号", example = "")
@ApiModelProperty(value = "测头编码", dataType = "java.lang.String") @ApiModelProperty(value = "测点编号", dataType = "java.lang.String")
@NotBlank(message = "测头编码") @NotBlank(message = "测点编号")
private String stationCode; private String stationCode;
} }

View File

@ -1,5 +1,6 @@
package com.whdc.zhdbaqapi.model.entity; package com.whdc.zhdbaqapi.model.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
@ -41,11 +42,12 @@ public class DeviceInfo implements Serializable {
private Integer id; private Integer id;
/** /**
* *
*/ */
@ApiParam(value = "测头编码") @ApiParam(value = "测点编号")
@ApiModelProperty(value = "测头编码", dataType = "java.lang.String", required = true) @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true)
@NotEmpty(message = "测头编码必填") @Excel(name = "测点编号")
@NotEmpty(message = "测点编号必填")
@TableField("STATION_CODE") @TableField("STATION_CODE")
private String stationCode; private String stationCode;
@ -54,6 +56,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "测站编码MCU") @ApiParam(value = "测站编码MCU")
@ApiModelProperty(value = "测站编码MCU", dataType = "java.lang.String") @ApiModelProperty(value = "测站编码MCU", dataType = "java.lang.String")
@Excel(name = "测站编码MCU")
@NotEmpty(message = "测站编码MCU必填") @NotEmpty(message = "测站编码MCU必填")
@TableField("DEVICE_ID") @TableField("DEVICE_ID")
private String deviceId; private String deviceId;
@ -63,6 +66,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "通道号") @ApiParam(value = "通道号")
@ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true) @ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true)
@Excel(name = "通道号")
@NotNull(message = "通道号必填") @NotNull(message = "通道号必填")
@Max(message = "通道号最大值 7", value = 7) @Max(message = "通道号最大值 7", value = 7)
@Min(message = "通道号最小值 0", value = 0) @Min(message = "通道号最小值 0", value = 0)
@ -72,9 +76,10 @@ public class DeviceInfo implements Serializable {
/** /**
* (K) * (K)
*/ */
@ApiParam(value = "温度率定系娄(K)") @ApiParam(value = "温度率定系娄K")
@ApiModelProperty(value = "温度率定系娄(K)", dataType = "java.math.BigDecimal", required = true) @ApiModelProperty(value = "温度率定系娄K", dataType = "java.math.BigDecimal", required = true)
@NotNull(message = "温度率定系娄(K)必填") @Excel(name = "温度率定系娄K")
@NotNull(message = "温度率定系娄K必填")
@TableField("TEMPERATURE_K") @TableField("TEMPERATURE_K")
private BigDecimal temperatureK; private BigDecimal temperatureK;
@ -83,6 +88,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "初始温度读数") @ApiParam(value = "初始温度读数")
@ApiModelProperty(value = "初始温度读数", dataType = "java.lang.Double", required = true) @ApiModelProperty(value = "初始温度读数", dataType = "java.lang.Double", required = true)
@Excel(name = "初始温度读数")
@NotNull(message = "初始温度读数必填") @NotNull(message = "初始温度读数必填")
@TableField("START_TEMPERATURE") @TableField("START_TEMPERATURE")
private BigDecimal startTemperature; private BigDecimal startTemperature;
@ -90,9 +96,10 @@ public class DeviceInfo implements Serializable {
/** /**
* (G) * (G)
*/ */
@ApiParam(value = "率定系数(G)") @ApiParam(value = "率定系数G")
@ApiModelProperty(value = "率定系数(G)", dataType = "java.math.BigDecimal", required = true) @ApiModelProperty(value = "率定系数G", dataType = "java.math.BigDecimal", required = true)
@NotNull(message = "率定系数(G)必填") @Excel(name = "率定系数G")
@NotNull(message = "率定系数G必填")
@TableField("CALIBRATION_COEFFICIENT") @TableField("CALIBRATION_COEFFICIENT")
private BigDecimal calibrationCoefficient; private BigDecimal calibrationCoefficient;
@ -101,6 +108,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "初始读数") @ApiParam(value = "初始读数")
@ApiModelProperty(value = "初始读数", notes = "单位是“模数”, 乘 1000 后开方得到频率值", dataType = "java.math.BigDecimal", required = true) @ApiModelProperty(value = "初始读数", notes = "单位是“模数”, 乘 1000 后开方得到频率值", dataType = "java.math.BigDecimal", required = true)
@Excel(name = "初始读数")
@NotNull(message = "初始读数必填") @NotNull(message = "初始读数必填")
@TableField("INITIAL_READING") @TableField("INITIAL_READING")
private BigDecimal initialReading; private BigDecimal initialReading;
@ -110,6 +118,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "项目名称") @ApiParam(value = "项目名称")
@ApiModelProperty(value = "项目名称", dataType = "java.lang.String") @ApiModelProperty(value = "项目名称", dataType = "java.lang.String")
@Excel(name = "工程或项目名称")
@TableField("PROJECT_NAME") @TableField("PROJECT_NAME")
private String projectName; private String projectName;
@ -118,6 +127,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "备注") @ApiParam(value = "备注")
@ApiModelProperty(value = "备注", dataType = "java.lang.String") @ApiModelProperty(value = "备注", dataType = "java.lang.String")
@Excel(name = "备注")
@TableField("REMARK") @TableField("REMARK")
private String remark; private String remark;
@ -126,6 +136,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "监理工程师") @ApiParam(value = "监理工程师")
@ApiModelProperty(value = "监理工程师", dataType = "java.lang.String") @ApiModelProperty(value = "监理工程师", dataType = "java.lang.String")
@Excel(name = "监理工程师")
@TableField("SUPERVISOR") @TableField("SUPERVISOR")
private String supervisor; private String supervisor;
@ -160,6 +171,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "埋设示意图") @ApiParam(value = "埋设示意图")
@ApiModelProperty(value = "埋设示意图", dataType = "java.lang.String") @ApiModelProperty(value = "埋设示意图", dataType = "java.lang.String")
@Excel(name = "埋设示意图说明")
@TableField("SKETCH_MAP") @TableField("SKETCH_MAP")
private String sketchMap; private String sketchMap;
@ -169,6 +181,7 @@ public class DeviceInfo implements Serializable {
@ApiParam(value = "日期") @ApiParam(value = "日期")
@ApiModelProperty(value = "日期", dataType = "java.util.Date") @ApiModelProperty(value = "日期", dataType = "java.util.Date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Excel(name = "日期")
@TableField("CREATE_DATE") @TableField("CREATE_DATE")
private Date createDate; private Date createDate;
@ -177,6 +190,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "埋设及填表人") @ApiParam(value = "埋设及填表人")
@ApiModelProperty(value = "埋设及填表人", dataType = "java.lang.String") @ApiModelProperty(value = "埋设及填表人", dataType = "java.lang.String")
@Excel(name = "埋设及填表人")
@TableField("BURIED_PERSONNEL") @TableField("BURIED_PERSONNEL")
private String buriedPersonnel; private String buriedPersonnel;
@ -185,6 +199,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "校验人") @ApiParam(value = "校验人")
@ApiModelProperty(value = "校验人", dataType = "java.lang.String") @ApiModelProperty(value = "校验人", dataType = "java.lang.String")
@Excel(name = "校验人")
@TableField("CHECK_PERSONNEL") @TableField("CHECK_PERSONNEL")
private String checkPersonnel; private String checkPersonnel;
@ -193,6 +208,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "技术负责人") @ApiParam(value = "技术负责人")
@ApiModelProperty(value = "技术负责人", dataType = "java.lang.String") @ApiModelProperty(value = "技术负责人", dataType = "java.lang.String")
@Excel(name = "技术负责人")
@TableField("TECHNICAL_DIRECTOR") @TableField("TECHNICAL_DIRECTOR")
private String technicalDirector; private String technicalDirector;
@ -201,6 +217,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "下游水位m") @ApiParam(value = "下游水位m")
@ApiModelProperty(value = "下游水位m", dataType = "java.lang.Double") @ApiModelProperty(value = "下游水位m", dataType = "java.lang.Double")
@Excel(name = "下游水位")
@TableField("TAILWATER_LEVEL") @TableField("TAILWATER_LEVEL")
private Double tailwaterLevel; private Double tailwaterLevel;
@ -209,22 +226,25 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "上游水位m") @ApiParam(value = "上游水位m")
@ApiModelProperty(value = "上游水位m", dataType = "java.lang.Double") @ApiModelProperty(value = "上游水位m", dataType = "java.lang.Double")
@Excel(name = "上游水位")
@TableField("HEADWATER_LEVEL") @TableField("HEADWATER_LEVEL")
private Double headwaterLevel; private Double headwaterLevel;
/** /**
* ( *
*/ */
@ApiParam(value = "天气(℃)") @ApiParam(value = "天气")
@ApiModelProperty(value = "天气(℃)", dataType = "java.lang.Double") @ApiModelProperty(value = "天气", dataType = "java.lang.String")
@Excel(name = "天气")
@TableField("WEATHER") @TableField("WEATHER")
private Double weather; private String weather;
/** /**
* *
*/ */
@ApiParam(value = "气压") @ApiParam(value = "气压")
@ApiModelProperty(value = "气压", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "气压", dataType = "java.math.BigDecimal")
@Excel(name = "气压")
@TableField("AIR_PRESSURE") @TableField("AIR_PRESSURE")
private BigDecimal airPressure; private BigDecimal airPressure;
@ -233,6 +253,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "气温") @ApiParam(value = "气温")
@ApiModelProperty(value = "气温", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "气温", dataType = "java.math.BigDecimal")
@Excel(name = "气温")
@TableField("AIR_TEMPERATURE") @TableField("AIR_TEMPERATURE")
private BigDecimal airTemperature; private BigDecimal airTemperature;
@ -241,79 +262,89 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "埋设日期") @ApiParam(value = "埋设日期")
@ApiModelProperty(value = "埋设日期", dataType = "java.util.Date") @ApiModelProperty(value = "埋设日期", dataType = "java.util.Date")
@Excel(name = "埋设日期")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@TableField("EMBEDDING_DATE") @TableField("EMBEDDING_DATE")
private Date embeddingDate; private Date embeddingDate;
/** /**
* * Hz,kHz
*/ */
@ApiParam(value = "埋设完毕读数") @ApiParam(value = "埋设完毕读数Hz,kHz")
@ApiModelProperty(value = "埋设完毕读数", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "埋设完毕读数Hz,kHz", dataType = "java.lang.String")
@Excel(name = "埋设完毕读数Hz,kHz")
@TableField("EMBEDDING_FINISH_READING") @TableField("EMBEDDING_FINISH_READING")
private BigDecimal embeddingFinishReading; private String embeddingFinishReading;
/** /**
* * Hz,kHz
*/ */
@ApiParam(value = "零压读数") @ApiParam(value = "零压读数Hz,kHz")
@ApiModelProperty(value = "零压读数", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "零压读数Hz,kHz", dataType = "java.math.BigDecimal")
@Excel(name = "零压读数Hz,kHz")
@TableField("ZERO_PRESSURE_READINGS") @TableField("ZERO_PRESSURE_READINGS")
private BigDecimal zeroPressureReadings; private BigDecimal zeroPressureReadings;
/** /**
* * Hz,kHz
*/ */
@ApiParam(value = "就位后读数") @ApiParam(value = "就位后读数Hz,kHz")
@ApiModelProperty(value = "就位后读数", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "就位后读数Hz,kHz", dataType = "java.math.BigDecimal")
@Excel(name = "就位后读数Hz,kHz")
@TableField("END_READINGS") @TableField("END_READINGS")
private BigDecimal endReadings; private BigDecimal endReadings;
/** /**
* * Hz,kHz
*/ */
@ApiParam(value = "入孔前读数") @ApiParam(value = "入孔前读数Hz,kHz")
@ApiModelProperty(value = "入孔前读数", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "入孔前读数Hz,kHz", dataType = "java.lang.String")
@Excel(name = "入孔前读数Hz,kHz")
@TableField("START_READINGS") @TableField("START_READINGS")
private BigDecimal startReadings; private String startReadings;
/** /**
* *
*/ */
@ApiParam(value = "孔内水深") @ApiParam(value = "孔内水深")
@ApiModelProperty(value = "孔内水深", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "孔内水深", dataType = "java.math.BigDecimal")
@Excel(name = "孔内水深")
@TableField("DRAFT") @TableField("DRAFT")
private BigDecimal draft; private BigDecimal draft;
/** /**
* * Hz,kHz
*/ */
@ApiParam(value = "现场室内读数") @ApiParam(value = "现场室内读数Hz,kHz")
@ApiModelProperty(value = "现场室内读数", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "现场室内读数Hz,kHz", dataType = "java.math.BigDecimal")
@Excel(name = "现场室内读数Hz,kHz")
@TableField("READINGS") @TableField("READINGS")
private BigDecimal readings; private BigDecimal readings;
/** /**
* * m
*/ */
@ApiParam(value = "大坝轴距") @ApiParam(value = "坝轴距m")
@ApiModelProperty(value = "大坝轴距", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "坝轴距m", dataType = "java.math.BigDecimal")
@Excel(name = "坝轴距m")
@TableField("DAM_WHEELBASE") @TableField("DAM_WHEELBASE")
private BigDecimal damWheelbase; private BigDecimal damWheelbase;
/** /**
* * m
*/ */
@ApiParam(value = "柱号") @ApiParam(value = "桩号m")
@ApiModelProperty(value = "柱号", dataType = "java.lang.String") @ApiModelProperty(value = "桩号m", dataType = "java.lang.String")
@Excel(name = "桩号m")
@TableField("COLUMN_NO") @TableField("COLUMN_NO")
private String columnNo; private String columnNo;
/** /**
* * m
*/ */
@ApiParam(value = "埋设高程") @ApiParam(value = "埋设高程m")
@ApiModelProperty(value = "埋设高程", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "埋设高程m", dataType = "java.math.BigDecimal")
@Excel(name = "埋设高程m")
@TableField("EMBEDDING_ELEVATION") @TableField("EMBEDDING_ELEVATION")
private BigDecimal embeddingElevation; private BigDecimal embeddingElevation;
@ -322,14 +353,16 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "电缆长度标记") @ApiParam(value = "电缆长度标记")
@ApiModelProperty(value = "电缆长度标记", dataType = "java.lang.String") @ApiModelProperty(value = "电缆长度标记", dataType = "java.lang.String")
@Excel(name = "电缆长度标记m")
@TableField("CABLE_LENGTH_MARK") @TableField("CABLE_LENGTH_MARK")
private String cableLengthMark; private String cableLengthMark;
/** /**
* * m
*/ */
@ApiParam(value = "电缆长度") @ApiParam(value = "电缆长度m")
@ApiModelProperty(value = "电缆长度", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "电缆长度m", dataType = "java.math.BigDecimal")
@Excel(name = "电缆长度m")
@TableField("CABLE_LENGTH") @TableField("CABLE_LENGTH")
private BigDecimal cableLength; private BigDecimal cableLength;
@ -337,23 +370,26 @@ public class DeviceInfo implements Serializable {
* *
*/ */
@ApiParam(value = "测头内阻") @ApiParam(value = "测头内阻")
@ApiModelProperty(value = "测头内阻", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "测头内阻", dataType = "java.lang.String")
@Excel(name = "测头内阻")
@TableField("RESISTANCE") @TableField("RESISTANCE")
private BigDecimal resistance; private String resistance;
/** /**
* *
*/ */
@ApiParam(value = "量程") @ApiParam(value = "量程")
@ApiModelProperty(value = "量程", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "量程", dataType = "java.math.BigDecimal")
@Excel(name = "量程")
@TableField("RANGE") @TableField("RANGE")
private BigDecimal range; private BigDecimal range;
/** /**
* * Kkpa/Hz,kHz
*/ */
@ApiParam(value = "传感器系数") @ApiParam(value = "传感器系数Kkpa/Hz,kHz")
@ApiModelProperty(value = "传感器系数", dataType = "java.math.BigDecimal") @ApiModelProperty(value = "传感器系数Kkpa/Hz,kHz", dataType = "java.math.BigDecimal")
@Excel(name = "传感器系数Kkpa/Hz,kHz")
@TableField("SENSOR_COEFFICIENT") @TableField("SENSOR_COEFFICIENT")
private BigDecimal sensorCoefficient; private BigDecimal sensorCoefficient;
@ -362,6 +398,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "生产厂家") @ApiParam(value = "生产厂家")
@ApiModelProperty(value = "生产厂家", dataType = "java.lang.String") @ApiModelProperty(value = "生产厂家", dataType = "java.lang.String")
@Excel(name = "生产厂家")
@TableField("MANUFACTURER") @TableField("MANUFACTURER")
private String manufacturer; private String manufacturer;
@ -370,6 +407,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "测头编号") @ApiParam(value = "测头编号")
@ApiModelProperty(value = "测头编号", dataType = "java.lang.String") @ApiModelProperty(value = "测头编号", dataType = "java.lang.String")
@Excel(name = "测头编号")
@TableField("MEASURING_PROBE_NO") @TableField("MEASURING_PROBE_NO")
private String measuringProbeNo; private String measuringProbeNo;
@ -378,6 +416,7 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "稳定水位") @ApiParam(value = "稳定水位")
@ApiModelProperty(value = "稳定水位", dataType = "java.lang.Double") @ApiModelProperty(value = "稳定水位", dataType = "java.lang.Double")
@Excel(name = "稳定水位")
@TableField("STEADY_WATER_LEVEL") @TableField("STEADY_WATER_LEVEL")
private Double steadyWaterLevel; private Double steadyWaterLevel;
@ -386,22 +425,25 @@ public class DeviceInfo implements Serializable {
*/ */
@ApiParam(value = "初见水位") @ApiParam(value = "初见水位")
@ApiModelProperty(value = "初见水位", dataType = "java.lang.Double") @ApiModelProperty(value = "初见水位", dataType = "java.lang.Double")
@Excel(name = "初见水位")
@TableField("INITIAL_WATER_LEVEL") @TableField("INITIAL_WATER_LEVEL")
private Double initialWaterLevel; private Double initialWaterLevel;
/** /**
* *
*/ */
@ApiParam(value = "钻孔直径") @ApiParam(value = "钻孔直径mm")
@ApiModelProperty(value = "钻孔直径", dataType = "java.lang.String") @ApiModelProperty(value = "钻孔直径mm", dataType = "java.lang.String")
@Excel(name = "钻孔直径mm")
@TableField("DRILLING_SIZE") @TableField("DRILLING_SIZE")
private String drillingSize; private String drillingSize;
/** /**
* *
*/ */
@ApiParam(value = "转孔编号") @ApiParam(value = "钻孔编号")
@ApiModelProperty(value = "转孔编号", dataType = "java.lang.String") @ApiModelProperty(value = "钻孔编号", dataType = "java.lang.String")
@Excel(name = "钻孔编号")
@TableField("DRILLING_NO") @TableField("DRILLING_NO")
private String drillingNo; private String drillingNo;

View File

@ -94,11 +94,11 @@ public class DeviceDataVo {
/** /**
* *
*/ */
@ApiParam(value = "测头编码") @ApiParam(value = "测点编号")
@ApiModelProperty(value = "测头编码", dataType = "java.lang.String", required = true) @ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true)
@NotEmpty(message = "测头编码必填") @NotEmpty(message = "测点编号必填")
private String stationCode; private String stationCode;
/** /**

View File

@ -0,0 +1,33 @@
package com.whdc.zhdbaqapi.model.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author
* @date 2022-07-22 11:42
*/
@Data
@Accessors(chain = true) // chain = true 实现链式调用
@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性
public class DeviceInfoImpVo {
@ApiModelProperty("成功读取记录条数")
private int load;
@ApiModelProperty("成功入库记录条数")
private int success;
@ApiModelProperty("入库失败记录条数")
private int fail;
@ApiModelProperty("入库失败记录")
private List<DeviceInfo> err;
@ApiModelProperty("消息")
private String msg;
}

View File

@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
import com.whdc.zhdbaqapi.model.entity.DeviceInfo; import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
@ -39,4 +41,12 @@ public interface IDeviceInfoService extends IService<DeviceInfo> {
* @return * @return
*/ */
IPage<DeviceInfo> page(FindDeviceDto findDto); IPage<DeviceInfo> page(FindDeviceDto findDto);
/**
*
*
* @param file
* @return
*/
DeviceInfoImpVo imp(InputStream file);
} }

View File

@ -115,7 +115,7 @@ public class DeviceDataServiceImpl extends ServiceImpl<DeviceDataMapper, DeviceD
List<CklatRecord> rows = getRemoteData(deviceId, di.getChannelNum(), lasttm); List<CklatRecord> rows = getRemoteData(deviceId, di.getChannelNum(), lasttm);
if (rows == null || rows.isEmpty()) { if (rows == null || rows.isEmpty()) {
log.debug("没有取到数据 " + deviceId); log.debug("没有取到数据 " + deviceId + ", " + di.getChannelNum());
continue; continue;
} }

View File

@ -1,19 +1,25 @@
package com.whdc.zhdbaqapi.service.impl; package com.whdc.zhdbaqapi.service.impl;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.whdc.zhdbaqapi.constant.Constants; import com.whdc.zhdbaqapi.constant.Constants;
import com.whdc.zhdbaqapi.exception.MyException;
import com.whdc.zhdbaqapi.mapper.DeviceInfoMapper; import com.whdc.zhdbaqapi.mapper.DeviceInfoMapper;
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto; import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
import com.whdc.zhdbaqapi.model.entity.DeviceInfo; import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
import com.whdc.zhdbaqapi.service.IDeviceInfoService; import com.whdc.zhdbaqapi.service.IDeviceInfoService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.*;
import java.util.List;
/** /**
* @author * @author
@ -30,6 +36,15 @@ public class DeviceInfoServiceimpl extends ServiceImpl<DeviceInfoMapper, DeviceI
@CacheEvict(Constants.CACHE_NAME) @CacheEvict(Constants.CACHE_NAME)
public boolean restore(Integer id) { public boolean restore(Integer id) {
DeviceInfo entity = baseMapper.selectById(id); DeviceInfo entity = baseMapper.selectById(id);
if (entity == null) {
return false;
}
if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) {
throw new MyException(entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
}
entity.setDel(0); entity.setDel(0);
return super.updateById(entity); return super.updateById(entity);
} }
@ -50,6 +65,71 @@ public class DeviceInfoServiceimpl extends ServiceImpl<DeviceInfoMapper, DeviceI
return baseMapper.page(findDto.getPage(), findDto); return baseMapper.page(findDto.getPage(), findDto);
} }
@Override
@Transactional
public DeviceInfoImpVo imp(InputStream file) {
ImportParams params = new ImportParams();
params.setHeadRows(1);
try {
List<DeviceInfo> list = ExcelImportUtil.importExcel(file, DeviceInfo.class, params);
if (list == null || list.isEmpty()) {
return new DeviceInfoImpVo().setLoad(0).setSuccess(0).setFail(0).setMsg("没有读取有有效数据");
}
List<DeviceInfo> err = new ArrayList<>();
List<DeviceInfo> impList = new ArrayList<>();
Set<String> scs = new HashSet<>();
Map<String, DeviceInfo> chkMap = new HashMap<>();
for (DeviceInfo di : list) {
if (StringUtils.isBlank(di.getStationCode())) {
err.add(di);
} else {
scs.add(di.getStationCode());
}
}
if (scs.isEmpty() || err.size() == list.size()) {
return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("没有读取到有效的测点编号");
}
if (scs.size() != list.size()) {
return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("有重复的测点编号,请检查后再导入");
}
List<DeviceInfo> chkscs = baseMapper.listBySC(scs);
if (chkscs.size() == scs.size()) {
return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在");
}
for (DeviceInfo dbdi : chkscs) {
chkMap.put(dbdi.getStationCode(), dbdi);
}
for (DeviceInfo di : list) {
if (chkMap.containsKey(di.getStationCode())) {
err.add(di);
} else {
impList.add(di);
}
}
if (impList.isEmpty()) {
return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在");
}
if (super.saveBatch(impList)) {
return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(impList.size()).setFail(err.size()).setErr(err).setMsg("成功");
} else {
return new DeviceInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("失败");
}
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new MyException("导入异常!" + e.getMessage());
}
}
@Override @Override
@CacheEvict(Constants.CACHE_NAME) @CacheEvict(Constants.CACHE_NAME)
public boolean save(DeviceInfo entity) { public boolean save(DeviceInfo entity) {

View File

@ -32,4 +32,18 @@
</if> </if>
</select> </select>
<select id="listBySC" resultType="com.whdc.zhdbaqapi.model.entity.DeviceInfo">
SELECT ID, STATION_CODE FROM DEVICE_INFO
WHERE DEL = 0
AND STATION_CODE IN
<foreach collection="scs" item="sc" index="index" open="(" close=")" separator=",">
#{sc}
</foreach>
</select>
<select id="checkValidStationCode" resultType="com.whdc.zhdbaqapi.model.entity.DeviceInfo">
SELECT ID, STATION_CODE FROM DEVICE_INFO
WHERE DEL = 0
AND STATION_CODE = #{stationCode}
</select>
</mapper> </mapper>