diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java index ffa44d0..2a706f4 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java @@ -6,7 +6,6 @@ import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest; import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest; import com.newfiber.termite.domain.request.TermiteInfoQueryRequest; -import com.newfiber.termite.domain.request.TermiteInfoSaveRequest; import com.newfiber.termite.domain.response.DataUpResponse; import com.newfiber.termite.domain.response.TermiteInfoResponse; import java.util.List; @@ -20,10 +19,6 @@ List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request); - void insertMonitorDevice(@Param("request")TermiteInfoSaveRequest request); - - void removeMonitorDevice(@Param("id")String id); - String querynewphoto(@Param("sn")String sn); void updateModlefirstData(@Param("sn")String sn,@Param("newphoto")String newphoto); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java index ffa44d0..2a706f4 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java @@ -6,7 +6,6 @@ import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest; import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest; import com.newfiber.termite.domain.request.TermiteInfoQueryRequest; -import com.newfiber.termite.domain.request.TermiteInfoSaveRequest; import com.newfiber.termite.domain.response.DataUpResponse; import com.newfiber.termite.domain.response.TermiteInfoResponse; import java.util.List; @@ -20,10 +19,6 @@ List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request); - void insertMonitorDevice(@Param("request")TermiteInfoSaveRequest request); - - void removeMonitorDevice(@Param("id")String id); - String querynewphoto(@Param("sn")String sn); void updateModlefirstData(@Param("sn")String sn,@Param("newphoto")String newphoto); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java index b1f5f0e..51515d8 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java @@ -32,7 +32,7 @@ * @param request 新增参数 * @return 结果 */ - boolean insert(DeviceInfoBatchSaveRequest request); + List insert(DeviceInfoBatchSaveRequest request); /** * 修改设备信息 diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java index ffa44d0..2a706f4 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java @@ -6,7 +6,6 @@ import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest; import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest; import com.newfiber.termite.domain.request.TermiteInfoQueryRequest; -import com.newfiber.termite.domain.request.TermiteInfoSaveRequest; import com.newfiber.termite.domain.response.DataUpResponse; import com.newfiber.termite.domain.response.TermiteInfoResponse; import java.util.List; @@ -20,10 +19,6 @@ List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request); - void insertMonitorDevice(@Param("request")TermiteInfoSaveRequest request); - - void removeMonitorDevice(@Param("id")String id); - String querynewphoto(@Param("sn")String sn); void updateModlefirstData(@Param("sn")String sn,@Param("newphoto")String newphoto); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java index b1f5f0e..51515d8 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java @@ -32,7 +32,7 @@ * @param request 新增参数 * @return 结果 */ - boolean insert(DeviceInfoBatchSaveRequest request); + List insert(DeviceInfoBatchSaveRequest request); /** * 修改设备信息 diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java index 7883b4f..5f55ef1 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java @@ -1,5 +1,6 @@ package com.newfiber.termite.service; +import com.newfiber.common.core.web.page.PageResult; import com.newfiber.termite.domain.dto.PhotoIdentifyDto; import com.newfiber.termite.domain.dto.SnAlarmStatisticDto; import com.newfiber.termite.domain.dto.TermiteDataUpRequest; @@ -30,7 +31,7 @@ boolean updateMonitorDevice(DeviceInfoUpdateRequest request); - List queryhistoryData(TermiteHistoryQueryRequest request); + PageResult> queryhistoryData(TermiteHistoryQueryRequest request); boolean insertMonitorDevice(TermiteInfoSaveRequest request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java index ffa44d0..2a706f4 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java @@ -6,7 +6,6 @@ import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest; import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest; import com.newfiber.termite.domain.request.TermiteInfoQueryRequest; -import com.newfiber.termite.domain.request.TermiteInfoSaveRequest; import com.newfiber.termite.domain.response.DataUpResponse; import com.newfiber.termite.domain.response.TermiteInfoResponse; import java.util.List; @@ -20,10 +19,6 @@ List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request); - void insertMonitorDevice(@Param("request")TermiteInfoSaveRequest request); - - void removeMonitorDevice(@Param("id")String id); - String querynewphoto(@Param("sn")String sn); void updateModlefirstData(@Param("sn")String sn,@Param("newphoto")String newphoto); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java index b1f5f0e..51515d8 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java @@ -32,7 +32,7 @@ * @param request 新增参数 * @return 结果 */ - boolean insert(DeviceInfoBatchSaveRequest request); + List insert(DeviceInfoBatchSaveRequest request); /** * 修改设备信息 diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java index 7883b4f..5f55ef1 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java @@ -1,5 +1,6 @@ package com.newfiber.termite.service; +import com.newfiber.common.core.web.page.PageResult; import com.newfiber.termite.domain.dto.PhotoIdentifyDto; import com.newfiber.termite.domain.dto.SnAlarmStatisticDto; import com.newfiber.termite.domain.dto.TermiteDataUpRequest; @@ -30,7 +31,7 @@ boolean updateMonitorDevice(DeviceInfoUpdateRequest request); - List queryhistoryData(TermiteHistoryQueryRequest request); + PageResult> queryhistoryData(TermiteHistoryQueryRequest request); boolean insertMonitorDevice(TermiteInfoSaveRequest request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java index 8fc56e5..063d4e7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java @@ -12,12 +12,17 @@ import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest; import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest; import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest; +import com.newfiber.termite.enums.EDeviceCategory; import com.newfiber.termite.enums.EDeviceSyncState; import com.newfiber.termite.mapper.DeviceInfoMapper; import com.newfiber.termite.service.IDeviceInfoService; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; +import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -46,19 +51,31 @@ } @Override - public boolean insert(DeviceInfoBatchSaveRequest request) { - if(CollectionUtils.isNotEmpty(request.getDeviceInfoImportRequestList())){ - return true; + public List insert(DeviceInfoBatchSaveRequest request) { + if(CollectionUtils.isEmpty(request.getDeviceInfoImportRequestList())){ + return Collections.emptyList(); } + + Map> deviceCountMap = request.getDeviceInfoImportRequestList().stream().collect(Collectors.groupingBy(DeviceInfoImportRequest::getSn)); + for(Entry> entry : deviceCountMap.entrySet()){ + if(entry.getValue().size() > 1){ + throw new ServiceException(String.format("站点重复:%s", entry.getKey())); + } + } + List deviceInfoList = new ArrayList<>(); for(DeviceInfoImportRequest infoImportRequest : request.getDeviceInfoImportRequestList()){ + if(null != selectDetail(infoImportRequest.getSn(), request.getProjectCode())){ + throw new ServiceException(String.format("站点已存在:%s", infoImportRequest.getSn())); + } DeviceInfo deviceInfo = new DeviceInfo(); BeanUtils.copyProperties(infoImportRequest, deviceInfo); deviceInfo.setProjectCode(request.getProjectCode()); deviceInfo.setCategory("project"); deviceInfoList.add(deviceInfo); } - return saveBatch(deviceInfoList); + saveBatch(deviceInfoList); + return deviceInfoList; } @Override @@ -76,7 +93,7 @@ set(StringUtils.isNotBlank(termiteDateUpRequest.getVoltage()), "voltage", termiteDateUpRequest.getVoltage()). set(StringUtils.isNotBlank(termiteDateUpRequest.getTemperature()), "temperature", termiteDateUpRequest.getTemperature()). set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()). - set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()). + set(StringUtils.isNotBlank(termiteDateUpRequest.getAp()), "ap", termiteDateUpRequest.getAp()). set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()). set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()). set("sync_state", EDeviceSyncState.success.getCode()). @@ -89,7 +106,7 @@ public boolean update(DeviceInfoStateSyncRequest deviceInfoStateSyncRequest) { TermiteDataUpRequest termiteDataUpRequest = new TermiteDataUpRequest(); BeanUtils.copyProperties(deviceInfoStateSyncRequest, termiteDataUpRequest); - termiteDataUpRequest.setAP(deviceInfoStateSyncRequest.getAp()); + termiteDataUpRequest.setAp(deviceInfoStateSyncRequest.getAp()); return update(termiteDataUpRequest); } @@ -120,6 +137,7 @@ @Override public DeviceInfo selectDetail(String sn) { DeviceInfoQueryRequest request = new DeviceInfoQueryRequest(); + request.setCategory(EDeviceCategory.project.getCode()); request.setSn(sn); List deviceInfoList = selectList(request); if(CollectionUtils.isNotEmpty(deviceInfoList)){ @@ -128,6 +146,18 @@ return null; } + public DeviceInfo selectDetail(String sn, String projectCode) { + DeviceInfoQueryRequest request = new DeviceInfoQueryRequest(); + request.setCategory(EDeviceCategory.project.getCode()); + request.setSn(sn); + request.setProjectCode(projectCode); + List deviceInfoList = selectList(request); + if(CollectionUtils.isNotEmpty(deviceInfoList)){ + return deviceInfoList.get(0); + } + return null; + } + @Override public List selectPage(DeviceInfoQueryRequest request) { return deviceInfoMapper.selectByCondition(request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java index ffa44d0..2a706f4 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java @@ -6,7 +6,6 @@ import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest; import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest; import com.newfiber.termite.domain.request.TermiteInfoQueryRequest; -import com.newfiber.termite.domain.request.TermiteInfoSaveRequest; import com.newfiber.termite.domain.response.DataUpResponse; import com.newfiber.termite.domain.response.TermiteInfoResponse; import java.util.List; @@ -20,10 +19,6 @@ List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request); - void insertMonitorDevice(@Param("request")TermiteInfoSaveRequest request); - - void removeMonitorDevice(@Param("id")String id); - String querynewphoto(@Param("sn")String sn); void updateModlefirstData(@Param("sn")String sn,@Param("newphoto")String newphoto); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java index b1f5f0e..51515d8 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java @@ -32,7 +32,7 @@ * @param request 新增参数 * @return 结果 */ - boolean insert(DeviceInfoBatchSaveRequest request); + List insert(DeviceInfoBatchSaveRequest request); /** * 修改设备信息 diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java index 7883b4f..5f55ef1 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java @@ -1,5 +1,6 @@ package com.newfiber.termite.service; +import com.newfiber.common.core.web.page.PageResult; import com.newfiber.termite.domain.dto.PhotoIdentifyDto; import com.newfiber.termite.domain.dto.SnAlarmStatisticDto; import com.newfiber.termite.domain.dto.TermiteDataUpRequest; @@ -30,7 +31,7 @@ boolean updateMonitorDevice(DeviceInfoUpdateRequest request); - List queryhistoryData(TermiteHistoryQueryRequest request); + PageResult> queryhistoryData(TermiteHistoryQueryRequest request); boolean insertMonitorDevice(TermiteInfoSaveRequest request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java index 8fc56e5..063d4e7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java @@ -12,12 +12,17 @@ import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest; import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest; import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest; +import com.newfiber.termite.enums.EDeviceCategory; import com.newfiber.termite.enums.EDeviceSyncState; import com.newfiber.termite.mapper.DeviceInfoMapper; import com.newfiber.termite.service.IDeviceInfoService; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; +import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -46,19 +51,31 @@ } @Override - public boolean insert(DeviceInfoBatchSaveRequest request) { - if(CollectionUtils.isNotEmpty(request.getDeviceInfoImportRequestList())){ - return true; + public List insert(DeviceInfoBatchSaveRequest request) { + if(CollectionUtils.isEmpty(request.getDeviceInfoImportRequestList())){ + return Collections.emptyList(); } + + Map> deviceCountMap = request.getDeviceInfoImportRequestList().stream().collect(Collectors.groupingBy(DeviceInfoImportRequest::getSn)); + for(Entry> entry : deviceCountMap.entrySet()){ + if(entry.getValue().size() > 1){ + throw new ServiceException(String.format("站点重复:%s", entry.getKey())); + } + } + List deviceInfoList = new ArrayList<>(); for(DeviceInfoImportRequest infoImportRequest : request.getDeviceInfoImportRequestList()){ + if(null != selectDetail(infoImportRequest.getSn(), request.getProjectCode())){ + throw new ServiceException(String.format("站点已存在:%s", infoImportRequest.getSn())); + } DeviceInfo deviceInfo = new DeviceInfo(); BeanUtils.copyProperties(infoImportRequest, deviceInfo); deviceInfo.setProjectCode(request.getProjectCode()); deviceInfo.setCategory("project"); deviceInfoList.add(deviceInfo); } - return saveBatch(deviceInfoList); + saveBatch(deviceInfoList); + return deviceInfoList; } @Override @@ -76,7 +93,7 @@ set(StringUtils.isNotBlank(termiteDateUpRequest.getVoltage()), "voltage", termiteDateUpRequest.getVoltage()). set(StringUtils.isNotBlank(termiteDateUpRequest.getTemperature()), "temperature", termiteDateUpRequest.getTemperature()). set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()). - set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()). + set(StringUtils.isNotBlank(termiteDateUpRequest.getAp()), "ap", termiteDateUpRequest.getAp()). set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()). set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()). set("sync_state", EDeviceSyncState.success.getCode()). @@ -89,7 +106,7 @@ public boolean update(DeviceInfoStateSyncRequest deviceInfoStateSyncRequest) { TermiteDataUpRequest termiteDataUpRequest = new TermiteDataUpRequest(); BeanUtils.copyProperties(deviceInfoStateSyncRequest, termiteDataUpRequest); - termiteDataUpRequest.setAP(deviceInfoStateSyncRequest.getAp()); + termiteDataUpRequest.setAp(deviceInfoStateSyncRequest.getAp()); return update(termiteDataUpRequest); } @@ -120,6 +137,7 @@ @Override public DeviceInfo selectDetail(String sn) { DeviceInfoQueryRequest request = new DeviceInfoQueryRequest(); + request.setCategory(EDeviceCategory.project.getCode()); request.setSn(sn); List deviceInfoList = selectList(request); if(CollectionUtils.isNotEmpty(deviceInfoList)){ @@ -128,6 +146,18 @@ return null; } + public DeviceInfo selectDetail(String sn, String projectCode) { + DeviceInfoQueryRequest request = new DeviceInfoQueryRequest(); + request.setCategory(EDeviceCategory.project.getCode()); + request.setSn(sn); + request.setProjectCode(projectCode); + List deviceInfoList = selectList(request); + if(CollectionUtils.isNotEmpty(deviceInfoList)){ + return deviceInfoList.get(0); + } + return null; + } + @Override public List selectPage(DeviceInfoQueryRequest request) { return deviceInfoMapper.selectByCondition(request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java index 9880812..ed03fb7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java @@ -2,11 +2,15 @@ import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ReflectUtil; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.newfiber.common.core.enums.EBoolean; +import com.newfiber.common.core.web.page.PageDomain; +import com.newfiber.common.core.web.page.PageResult; +import com.newfiber.common.core.web.page.PageSupport; import com.newfiber.common.core.web.service.BaseServiceImpl; import com.newfiber.termite.config.JingchuResourceConfig; import com.newfiber.termite.domain.DeviceInfo; @@ -41,6 +45,7 @@ import com.newfiber.termite.service.jingchu.IJingchuDeviceConfigService; import com.newfiber.termite.service.jingchu.IJingchuProjectConfigService; import com.newfiber.termite.util.CosUtil; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -50,6 +55,7 @@ import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -94,29 +100,29 @@ private final ExecutorService jingchuExecutorService = Executors.newFixedThreadPool(4); @Transactional(rollbackFor = Exception.class) - public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image) throws Exception{ + public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image){ String date = DateUtil.formatDateTime(new Date()); log.info("站点{}在{}时刻上传数据", termiteDateUpRequest.getSn(), date); String url = CosUtil.putFile(image); - // 保存历史数据 - DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); - BeanUtils.copyProperties(termiteDateUpRequest, deviceMonitoringData); - deviceMonitoringData.setRtpitcu(url); - deviceMonitoringData.setYesnoant(EExistsAnt.False.getCode()); - deviceMonitoringData.setDruing(EDrugFlag.False.getCode()); - deviceMonitoringData.setUptime(new Date()); - deviceMonitoringData.setDate(DateUtil.formatDateTime(new Date())); - deviceMonitoringDataService.save(deviceMonitoringData); - - mongoTemplate.save(deviceMonitoringData, termiteDateUpRequest.getSn()); - // 保存实时数据 deviceMonitoringDataRealtimeService.deleteBySn(termiteDateUpRequest.getSn()); DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime(); - BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime); + BeanUtils.copyProperties(termiteDateUpRequest, deviceMonitoringDataRealtime); + deviceMonitoringDataRealtime.setRtpitcu(url); + deviceMonitoringDataRealtime.setYesnoant(EExistsAnt.False.getCode()); + deviceMonitoringDataRealtime.setDruing(EDrugFlag.False.getCode()); + deviceMonitoringDataRealtime.setUptime(new Date()); + deviceMonitoringDataRealtime.setDate(DateUtil.formatDateTime(new Date())); deviceMonitoringDataRealtimeService.save(deviceMonitoringDataRealtime); + mongoTemplate.save(deviceMonitoringDataRealtime, termiteDateUpRequest.getSn()); + + // 保存历史数据 + DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); + BeanUtils.copyProperties(deviceMonitoringDataRealtime, deviceMonitoringData); + deviceMonitoringDataService.save(deviceMonitoringData); + // 返回是否投药、加热 DeviceMonitoringData lastDrugingDeviceMonitoringData = deviceMonitoringDataService.lastDruging(termiteDateUpRequest.getSn()); DeviceMonitoringData lastHeatingDeviceMonitoringData = deviceMonitoringDataService.lastHeating(termiteDateUpRequest.getSn()); @@ -226,20 +232,36 @@ @Override public boolean updateMonitorData(TermiteInfoUpdateyRequest request){ - // TODO - DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); - BeanUtils.copyProperties(request, deviceMonitoringData); + DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime(); + BeanUtils.copyProperties(request, deviceMonitoringDataRealtime); + + Query updateQuery = new Query().addCriteria(Criteria.where("sn").is(request.getSn())). + addCriteria(Criteria.where("_id").is(request.getId())); + Update update = new Update(); + for(Field field : ReflectUtil.getFields(request.getClass())){ + if("id".equals(field.getName())){ + continue; + } + Object fieldValue = ReflectUtil.getFieldValue(request, field); + if(null != fieldValue){ + update.set(field.getName(), fieldValue); + } + } + if(EDrugFlag.True.getCode().equals(request.getDruing())){ - deviceMonitoringData.setDruingDatetime(new Date()); + deviceMonitoringDataRealtime.setDruingDatetime(new Date()); + update.set("druingDatetime", new Date()); } if(EHeatingFlag.True.getCode().equals(request.getHeating())){ - deviceMonitoringData.setHeatingDatetime(new Date()); + deviceMonitoringDataRealtime.setHeatingDatetime(new Date()); + update.set("heatingDatetime", new Date()); } - deviceMonitoringDataService.updateById(deviceMonitoringData); - - DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime(); - BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime); deviceMonitoringDataRealtimeService.updateById(deviceMonitoringDataRealtime); + mongoTemplate.updateMulti(updateQuery, update, deviceMonitoringDataRealtime.getSn()); + + DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); + BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime); + deviceMonitoringDataService.updateById(deviceMonitoringData); // 更新第一次报警时间 DeviceInfo deviceInfo = deviceInfoService.selectDetail(request.getSn()); @@ -268,19 +290,63 @@ } @Override - public List queryhistoryData(TermiteHistoryQueryRequest request){ - // TODO - return termiteMapper.queryhistoryData(request); + public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ + DeviceInfo deviceInfo = deviceInfoService.selectDetail(request.getSn()); + + Query query = new Query().with(Sort.by(Sort.Direction.DESC, "date")); + Criteria criteria = new Criteria(); + + if (null != request.getStarttime()) { + criteria.andOperator(Criteria.where("tt").gte(request.getStarttime())); + } + if (null != request.getEndtime()) { + criteria.andOperator(Criteria.where("tt").lte(request.getEndtime())); + } + if (null != request.getYesnoant()) { + criteria.andOperator(Criteria.where("yesnoant").lte(request.getYesnoant())); + } + if (null != request.getIdencolle()) { + criteria.andOperator(Criteria.where("idencolle").lte(request.getIdencolle())); + } + if (null != request.getDruing()) { + criteria.andOperator(Criteria.where("druing").lte(request.getDruing())); + } + + Long countNum = mongoTemplate.count(query, request.getSn()); + + PageDomain pageDomain = PageSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + query.skip((pageNum - 1) * pageSize).limit(pageSize); + + List responseList = new ArrayList<>(); + List deviceMonitoringDataRealtimeList = mongoTemplate.find(query, DeviceMonitoringDataRealtime.class, request.getSn()); + for(DeviceMonitoringDataRealtime realtime : deviceMonitoringDataRealtimeList){ + TermiteInfoResponse response = new TermiteInfoResponse(); + BeanUtils.copyProperties(realtime, response); + response.setLocation(deviceInfo.getLocation()); + responseList.add(response); + } + + return new PageResult<>(responseList, countNum); +// return PageSupport.pageResult(termiteMapper.queryhistoryData(request)); } @Override public boolean insertMonitorDevice(TermiteInfoSaveRequest request){ - termiteMapper.insertMonitorDevice(request); + DeviceInfo deviceInfo = new DeviceInfo(); + BeanUtils.copyProperties(request, deviceInfo); + deviceInfoService.save(deviceInfo); + if(!mongoTemplate.collectionExists(request.getSn())){ + mongoTemplate.createCollection(request.getSn()); + } + return true; } + @Override public boolean removeMonitorDevice(String id){ - termiteMapper.removeMonitorDevice(id); + deviceInfoService.delete(id); return true; } @@ -290,6 +356,7 @@ termiteMapper.updateModlefirstData(sn,newphoto); return true; } + @Override public UnitInfoDto queryUnitdata(){ return termiteMapper.queryUnitdata(); @@ -350,7 +417,13 @@ } List deviceMonitoringDataList = deviceMonitoringDataService.selectList(deviceInfo.getSn()); - mongoTemplate.save(deviceMonitoringDataList, deviceInfo.getSn()); + for(DeviceMonitoringData deviceMonitoringData : deviceMonitoringDataList){ + + Query query = new Query().addCriteria(Criteria.where("date").is(deviceMonitoringData.getDate())); + if(!mongoTemplate.exists(query, deviceInfo.getSn())){ + mongoTemplate.save(deviceMonitoringDataList, deviceInfo.getSn()); + } + } } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java index 18f9974..2cd61be 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/DeviceInfoController.java @@ -71,12 +71,11 @@ } @PostMapping("/importExcel") - public Result importExcel(MultipartFile file, String projectCode) throws Exception{ + public Result> importExcel(MultipartFile file, String projectCode) throws Exception{ ExcelUtil util = new ExcelUtil<>(DeviceInfoImportRequest.class); List deviceInfoImportRequestList = util.importExcel(file.getInputStream()); DeviceInfoBatchSaveRequest batchSaveRequest = new DeviceInfoBatchSaveRequest(projectCode, deviceInfoImportRequestList); - deviceInfoService.insert(batchSaveRequest); - return success(); + return success(deviceInfoService.insert(batchSaveRequest)); } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java index 42de836..ad441f7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/TermiteController.java @@ -56,7 +56,6 @@ //@RequiresPermissions("business:warningBriefing:list") @ApiOperation(value = "白蚁防治数据接收", position = 60) public Result termiteDataup(TermiteDataUpRequest dataDto, MultipartFile image) throws Exception{ - return success(termiteService.termiteDataup(dataDto,image)); } @@ -123,9 +122,9 @@ @PostMapping("/queryhistoryData") @ApiOperation(value = "查询历史数据", position = 60) public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ - startPage(); - List list =termiteService.queryhistoryData(request); - return pageResult(list); +// startPage(); + PageResult> result =termiteService.queryhistoryData(request); + return result; } /** diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java index 03256ae..7cfa48e 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringData.java @@ -1,15 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data @@ -25,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java index 01d7449..aa66656 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/DeviceMonitoringDataRealtime.java @@ -1,14 +1,20 @@ package com.newfiber.termite.domain; +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.newfiber.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import com.fasterxml.jackson.annotation.JsonFormat; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.data.mongodb.core.mapping.Field; +import org.springframework.data.mongodb.core.mapping.MongoId; /** * 白蚁防治数据对象 ter_device_monitoring_data_realtime @@ -24,6 +30,14 @@ private static final long serialVersionUID = 1L; + @MongoId + @Field("_id") + @JsonSerialize(using = ToStringSerializer.class) + @ApiModelProperty(value = "主键id") + @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + /** * 设备编码 */ @@ -90,5 +104,55 @@ @ApiModelProperty(value = "上传时间") private Date uptime; + // DB Property + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "软件版本") + private String software; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "硬件版本") + private String hardware; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "电压") + private String voltage; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "温度") + private String temperature; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "信号质量") + private String rssi; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "中继名称") + private String ap; + + /** + * + */ + @TableField(exist = false) + @ApiModelProperty(value = "摄像头") + private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java index 638a9ac..c0c5df0 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/dto/TermiteDataUpRequest.java @@ -1,9 +1,8 @@ package com.newfiber.termite.domain.dto; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteDataUpRequest { @@ -37,4 +36,14 @@ @ApiModelProperty(value = "", hidden = true) private Date lastPicTime; + @ApiModelProperty(value = "中继名称") + private String ap; + + public String getAp() { + return AP; + } + + public void setAp(String ap) { + this.ap = ap; + } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java index b2c5411..2cb9cef 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteHistoryQueryRequest.java @@ -2,16 +2,13 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; -import java.util.Date; - @Data public class TermiteHistoryQueryRequest { - @ApiModelProperty(value = "主键id") - private String id; - - @ApiModelProperty(value = "设备编码") + @NotBlank(message = "请选择站点") + @ApiModelProperty(value = "站点编码") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") @@ -28,13 +25,4 @@ @ApiModelProperty(value = "结束时间") private String endtime; - - @ApiModelProperty(value = "信号质量") - private String rssi; - - @ApiModelProperty(value = "中继名称") - private String AP; - - @ApiModelProperty(value = "温度") - private String camera; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java index 0ca888b..22323a3 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoQueryRequest.java @@ -1,7 +1,5 @@ package com.newfiber.termite.domain.request; -import com.newfiber.common.core.enums.EBoolean; -import com.newfiber.common.security.utils.SecurityUtils; import io.swagger.annotations.ApiModelProperty; import java.util.Set; import lombok.Data; @@ -27,6 +25,9 @@ @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + @ApiModelProperty(value = "排序字段") + private String orderBy; + @ApiModelProperty(value = "项目编码") private Set projectCodeList; } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java index 1454f94..aaf6f83 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoSaveRequest.java @@ -1,12 +1,15 @@ package com.newfiber.termite.domain.request; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data public class TermiteInfoSaveRequest { @ApiModelProperty(value = "分类(生产 production | 项目 project)") private String category; + + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "设备地址") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java index e204b34..94e78d7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/TermiteInfoUpdateyRequest.java @@ -2,6 +2,7 @@ import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; @Data @@ -10,6 +11,7 @@ @ApiModelProperty(value = "设备id") private Long id; + @NotBlank(message = "请填写站点编号") @ApiModelProperty(value = "设备编号") private String sn; @ApiModelProperty(value = "有无白蚁 1有 2无") diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java index f46e241..2dbfe35 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/request/deviceInfo/DeviceInfoImportRequest.java @@ -44,7 +44,6 @@ /** * 经纬度 */ - @Excel(name = "经度") @ApiModelProperty(value = "经纬度") private String lonandlat; diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java index 43ad981..9720b15 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/TermiteInfoResponse.java @@ -1,16 +1,16 @@ package com.newfiber.termite.domain.response; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; @Data public class TermiteInfoResponse { @ApiModelProperty(value = "数据id") - private String id; + private Long id; @ApiModelProperty(value = "数据id") private String deviceId; @ApiModelProperty(value = "设备编号") @@ -44,11 +44,17 @@ @ApiModelProperty(value = "上传时间") private Date uptime; - + @ApiModelProperty(value = "状态") + private String status; @ApiModelProperty(value = "项目编码") private String projectCode; @ApiModelProperty(value = "项目编码") private String projectName; + + /** 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java new file mode 100644 index 0000000..f553825 --- /dev/null +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/enums/EDeviceCategory.java @@ -0,0 +1,21 @@ +package com.newfiber.termite.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + */ +@Getter +@AllArgsConstructor +public enum EDeviceCategory { + /** + * 分类(生产 production | 项目 project) + */ + production("production", "生产"), + project("project", "项目"), + ; + + private final String code; + + private final String value; +} diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java index ffa44d0..2a706f4 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/mapper/TermiteMapper.java @@ -6,7 +6,6 @@ import com.newfiber.termite.domain.request.DeviceInfoUpdateRequest; import com.newfiber.termite.domain.request.TermiteHistoryQueryRequest; import com.newfiber.termite.domain.request.TermiteInfoQueryRequest; -import com.newfiber.termite.domain.request.TermiteInfoSaveRequest; import com.newfiber.termite.domain.response.DataUpResponse; import com.newfiber.termite.domain.response.TermiteInfoResponse; import java.util.List; @@ -20,10 +19,6 @@ List queryhistoryData(@Param("request")TermiteHistoryQueryRequest request); - void insertMonitorDevice(@Param("request")TermiteInfoSaveRequest request); - - void removeMonitorDevice(@Param("id")String id); - String querynewphoto(@Param("sn")String sn); void updateModlefirstData(@Param("sn")String sn,@Param("newphoto")String newphoto); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java index b1f5f0e..51515d8 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IDeviceInfoService.java @@ -32,7 +32,7 @@ * @param request 新增参数 * @return 结果 */ - boolean insert(DeviceInfoBatchSaveRequest request); + List insert(DeviceInfoBatchSaveRequest request); /** * 修改设备信息 diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java index 7883b4f..5f55ef1 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/ITermiteService.java @@ -1,5 +1,6 @@ package com.newfiber.termite.service; +import com.newfiber.common.core.web.page.PageResult; import com.newfiber.termite.domain.dto.PhotoIdentifyDto; import com.newfiber.termite.domain.dto.SnAlarmStatisticDto; import com.newfiber.termite.domain.dto.TermiteDataUpRequest; @@ -30,7 +31,7 @@ boolean updateMonitorDevice(DeviceInfoUpdateRequest request); - List queryhistoryData(TermiteHistoryQueryRequest request); + PageResult> queryhistoryData(TermiteHistoryQueryRequest request); boolean insertMonitorDevice(TermiteInfoSaveRequest request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java index 8fc56e5..063d4e7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/DeviceInfoServiceImpl.java @@ -12,12 +12,17 @@ import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoSaveRequest; import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoStateSyncRequest; import com.newfiber.termite.domain.request.deviceInfo.DeviceInfoUpdateRequest; +import com.newfiber.termite.enums.EDeviceCategory; import com.newfiber.termite.enums.EDeviceSyncState; import com.newfiber.termite.mapper.DeviceInfoMapper; import com.newfiber.termite.service.IDeviceInfoService; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; +import java.util.stream.Collectors; import javax.annotation.Resource; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -46,19 +51,31 @@ } @Override - public boolean insert(DeviceInfoBatchSaveRequest request) { - if(CollectionUtils.isNotEmpty(request.getDeviceInfoImportRequestList())){ - return true; + public List insert(DeviceInfoBatchSaveRequest request) { + if(CollectionUtils.isEmpty(request.getDeviceInfoImportRequestList())){ + return Collections.emptyList(); } + + Map> deviceCountMap = request.getDeviceInfoImportRequestList().stream().collect(Collectors.groupingBy(DeviceInfoImportRequest::getSn)); + for(Entry> entry : deviceCountMap.entrySet()){ + if(entry.getValue().size() > 1){ + throw new ServiceException(String.format("站点重复:%s", entry.getKey())); + } + } + List deviceInfoList = new ArrayList<>(); for(DeviceInfoImportRequest infoImportRequest : request.getDeviceInfoImportRequestList()){ + if(null != selectDetail(infoImportRequest.getSn(), request.getProjectCode())){ + throw new ServiceException(String.format("站点已存在:%s", infoImportRequest.getSn())); + } DeviceInfo deviceInfo = new DeviceInfo(); BeanUtils.copyProperties(infoImportRequest, deviceInfo); deviceInfo.setProjectCode(request.getProjectCode()); deviceInfo.setCategory("project"); deviceInfoList.add(deviceInfo); } - return saveBatch(deviceInfoList); + saveBatch(deviceInfoList); + return deviceInfoList; } @Override @@ -76,7 +93,7 @@ set(StringUtils.isNotBlank(termiteDateUpRequest.getVoltage()), "voltage", termiteDateUpRequest.getVoltage()). set(StringUtils.isNotBlank(termiteDateUpRequest.getTemperature()), "temperature", termiteDateUpRequest.getTemperature()). set(StringUtils.isNotBlank(termiteDateUpRequest.getRssi()), "rssi", termiteDateUpRequest.getRssi()). - set(StringUtils.isNotBlank(termiteDateUpRequest.getAP()), "ap", termiteDateUpRequest.getAP()). + set(StringUtils.isNotBlank(termiteDateUpRequest.getAp()), "ap", termiteDateUpRequest.getAp()). set(StringUtils.isNotBlank(termiteDateUpRequest.getCamera()), "camera", termiteDateUpRequest.getCamera()). set(null != termiteDateUpRequest.getLastPicTime(), "last_pic_time", termiteDateUpRequest.getLastPicTime()). set("sync_state", EDeviceSyncState.success.getCode()). @@ -89,7 +106,7 @@ public boolean update(DeviceInfoStateSyncRequest deviceInfoStateSyncRequest) { TermiteDataUpRequest termiteDataUpRequest = new TermiteDataUpRequest(); BeanUtils.copyProperties(deviceInfoStateSyncRequest, termiteDataUpRequest); - termiteDataUpRequest.setAP(deviceInfoStateSyncRequest.getAp()); + termiteDataUpRequest.setAp(deviceInfoStateSyncRequest.getAp()); return update(termiteDataUpRequest); } @@ -120,6 +137,7 @@ @Override public DeviceInfo selectDetail(String sn) { DeviceInfoQueryRequest request = new DeviceInfoQueryRequest(); + request.setCategory(EDeviceCategory.project.getCode()); request.setSn(sn); List deviceInfoList = selectList(request); if(CollectionUtils.isNotEmpty(deviceInfoList)){ @@ -128,6 +146,18 @@ return null; } + public DeviceInfo selectDetail(String sn, String projectCode) { + DeviceInfoQueryRequest request = new DeviceInfoQueryRequest(); + request.setCategory(EDeviceCategory.project.getCode()); + request.setSn(sn); + request.setProjectCode(projectCode); + List deviceInfoList = selectList(request); + if(CollectionUtils.isNotEmpty(deviceInfoList)){ + return deviceInfoList.get(0); + } + return null; + } + @Override public List selectPage(DeviceInfoQueryRequest request) { return deviceInfoMapper.selectByCondition(request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java index 9880812..ed03fb7 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/TermiteServiceImpl.java @@ -2,11 +2,15 @@ import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.ReflectUtil; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.newfiber.common.core.enums.EBoolean; +import com.newfiber.common.core.web.page.PageDomain; +import com.newfiber.common.core.web.page.PageResult; +import com.newfiber.common.core.web.page.PageSupport; import com.newfiber.common.core.web.service.BaseServiceImpl; import com.newfiber.termite.config.JingchuResourceConfig; import com.newfiber.termite.domain.DeviceInfo; @@ -41,6 +45,7 @@ import com.newfiber.termite.service.jingchu.IJingchuDeviceConfigService; import com.newfiber.termite.service.jingchu.IJingchuProjectConfigService; import com.newfiber.termite.util.CosUtil; +import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -50,6 +55,7 @@ import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; +import org.springframework.data.domain.Sort; import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Query; @@ -94,29 +100,29 @@ private final ExecutorService jingchuExecutorService = Executors.newFixedThreadPool(4); @Transactional(rollbackFor = Exception.class) - public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image) throws Exception{ + public DataUpResponse termiteDataup(TermiteDataUpRequest termiteDateUpRequest, MultipartFile image){ String date = DateUtil.formatDateTime(new Date()); log.info("站点{}在{}时刻上传数据", termiteDateUpRequest.getSn(), date); String url = CosUtil.putFile(image); - // 保存历史数据 - DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); - BeanUtils.copyProperties(termiteDateUpRequest, deviceMonitoringData); - deviceMonitoringData.setRtpitcu(url); - deviceMonitoringData.setYesnoant(EExistsAnt.False.getCode()); - deviceMonitoringData.setDruing(EDrugFlag.False.getCode()); - deviceMonitoringData.setUptime(new Date()); - deviceMonitoringData.setDate(DateUtil.formatDateTime(new Date())); - deviceMonitoringDataService.save(deviceMonitoringData); - - mongoTemplate.save(deviceMonitoringData, termiteDateUpRequest.getSn()); - // 保存实时数据 deviceMonitoringDataRealtimeService.deleteBySn(termiteDateUpRequest.getSn()); DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime(); - BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime); + BeanUtils.copyProperties(termiteDateUpRequest, deviceMonitoringDataRealtime); + deviceMonitoringDataRealtime.setRtpitcu(url); + deviceMonitoringDataRealtime.setYesnoant(EExistsAnt.False.getCode()); + deviceMonitoringDataRealtime.setDruing(EDrugFlag.False.getCode()); + deviceMonitoringDataRealtime.setUptime(new Date()); + deviceMonitoringDataRealtime.setDate(DateUtil.formatDateTime(new Date())); deviceMonitoringDataRealtimeService.save(deviceMonitoringDataRealtime); + mongoTemplate.save(deviceMonitoringDataRealtime, termiteDateUpRequest.getSn()); + + // 保存历史数据 + DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); + BeanUtils.copyProperties(deviceMonitoringDataRealtime, deviceMonitoringData); + deviceMonitoringDataService.save(deviceMonitoringData); + // 返回是否投药、加热 DeviceMonitoringData lastDrugingDeviceMonitoringData = deviceMonitoringDataService.lastDruging(termiteDateUpRequest.getSn()); DeviceMonitoringData lastHeatingDeviceMonitoringData = deviceMonitoringDataService.lastHeating(termiteDateUpRequest.getSn()); @@ -226,20 +232,36 @@ @Override public boolean updateMonitorData(TermiteInfoUpdateyRequest request){ - // TODO - DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); - BeanUtils.copyProperties(request, deviceMonitoringData); + DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime(); + BeanUtils.copyProperties(request, deviceMonitoringDataRealtime); + + Query updateQuery = new Query().addCriteria(Criteria.where("sn").is(request.getSn())). + addCriteria(Criteria.where("_id").is(request.getId())); + Update update = new Update(); + for(Field field : ReflectUtil.getFields(request.getClass())){ + if("id".equals(field.getName())){ + continue; + } + Object fieldValue = ReflectUtil.getFieldValue(request, field); + if(null != fieldValue){ + update.set(field.getName(), fieldValue); + } + } + if(EDrugFlag.True.getCode().equals(request.getDruing())){ - deviceMonitoringData.setDruingDatetime(new Date()); + deviceMonitoringDataRealtime.setDruingDatetime(new Date()); + update.set("druingDatetime", new Date()); } if(EHeatingFlag.True.getCode().equals(request.getHeating())){ - deviceMonitoringData.setHeatingDatetime(new Date()); + deviceMonitoringDataRealtime.setHeatingDatetime(new Date()); + update.set("heatingDatetime", new Date()); } - deviceMonitoringDataService.updateById(deviceMonitoringData); - - DeviceMonitoringDataRealtime deviceMonitoringDataRealtime = new DeviceMonitoringDataRealtime(); - BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime); deviceMonitoringDataRealtimeService.updateById(deviceMonitoringDataRealtime); + mongoTemplate.updateMulti(updateQuery, update, deviceMonitoringDataRealtime.getSn()); + + DeviceMonitoringData deviceMonitoringData = new DeviceMonitoringData(); + BeanUtils.copyProperties(deviceMonitoringData, deviceMonitoringDataRealtime); + deviceMonitoringDataService.updateById(deviceMonitoringData); // 更新第一次报警时间 DeviceInfo deviceInfo = deviceInfoService.selectDetail(request.getSn()); @@ -268,19 +290,63 @@ } @Override - public List queryhistoryData(TermiteHistoryQueryRequest request){ - // TODO - return termiteMapper.queryhistoryData(request); + public PageResult> queryhistoryData(TermiteHistoryQueryRequest request){ + DeviceInfo deviceInfo = deviceInfoService.selectDetail(request.getSn()); + + Query query = new Query().with(Sort.by(Sort.Direction.DESC, "date")); + Criteria criteria = new Criteria(); + + if (null != request.getStarttime()) { + criteria.andOperator(Criteria.where("tt").gte(request.getStarttime())); + } + if (null != request.getEndtime()) { + criteria.andOperator(Criteria.where("tt").lte(request.getEndtime())); + } + if (null != request.getYesnoant()) { + criteria.andOperator(Criteria.where("yesnoant").lte(request.getYesnoant())); + } + if (null != request.getIdencolle()) { + criteria.andOperator(Criteria.where("idencolle").lte(request.getIdencolle())); + } + if (null != request.getDruing()) { + criteria.andOperator(Criteria.where("druing").lte(request.getDruing())); + } + + Long countNum = mongoTemplate.count(query, request.getSn()); + + PageDomain pageDomain = PageSupport.buildPageRequest(); + Integer pageNum = pageDomain.getPageNum(); + Integer pageSize = pageDomain.getPageSize(); + query.skip((pageNum - 1) * pageSize).limit(pageSize); + + List responseList = new ArrayList<>(); + List deviceMonitoringDataRealtimeList = mongoTemplate.find(query, DeviceMonitoringDataRealtime.class, request.getSn()); + for(DeviceMonitoringDataRealtime realtime : deviceMonitoringDataRealtimeList){ + TermiteInfoResponse response = new TermiteInfoResponse(); + BeanUtils.copyProperties(realtime, response); + response.setLocation(deviceInfo.getLocation()); + responseList.add(response); + } + + return new PageResult<>(responseList, countNum); +// return PageSupport.pageResult(termiteMapper.queryhistoryData(request)); } @Override public boolean insertMonitorDevice(TermiteInfoSaveRequest request){ - termiteMapper.insertMonitorDevice(request); + DeviceInfo deviceInfo = new DeviceInfo(); + BeanUtils.copyProperties(request, deviceInfo); + deviceInfoService.save(deviceInfo); + if(!mongoTemplate.collectionExists(request.getSn())){ + mongoTemplate.createCollection(request.getSn()); + } + return true; } + @Override public boolean removeMonitorDevice(String id){ - termiteMapper.removeMonitorDevice(id); + deviceInfoService.delete(id); return true; } @@ -290,6 +356,7 @@ termiteMapper.updateModlefirstData(sn,newphoto); return true; } + @Override public UnitInfoDto queryUnitdata(){ return termiteMapper.queryUnitdata(); @@ -350,7 +417,13 @@ } List deviceMonitoringDataList = deviceMonitoringDataService.selectList(deviceInfo.getSn()); - mongoTemplate.save(deviceMonitoringDataList, deviceInfo.getSn()); + for(DeviceMonitoringData deviceMonitoringData : deviceMonitoringDataList){ + + Query query = new Query().addCriteria(Criteria.where("date").is(deviceMonitoringData.getDate())); + if(!mongoTemplate.exists(query, deviceInfo.getSn())){ + mongoTemplate.save(deviceMonitoringDataList, deviceInfo.getSn()); + } + } } } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/resources/mapper/termite/TermiteMapper.xml b/newfiber-termites/newfiber-termites-dataup/src/main/resources/mapper/termite/TermiteMapper.xml index 3be846e..276400d 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/resources/mapper/termite/TermiteMapper.xml +++ b/newfiber-termites/newfiber-termites-dataup/src/main/resources/mapper/termite/TermiteMapper.xml @@ -22,13 +22,15 @@ tb.heating, tb.heating_datetime, tb.uptime, + ta.status, ta.project_code as projectCode, - th.project_name as projectName + th.project_name as projectName, + ta.create_time as createTime FROM `ter_device_info` ta left join ter_project_info th on ta.project_code =th.project_code LEFT JOIN ter_device_monitoring_data_realtime tb ON ta.sn = tb.sn - where 1=1 + where 1=1 and ta.del_flag = 0 and ta.sn like concat('%',#{request.sn},'%') @@ -60,7 +62,15 @@ - order by -tb.yesnoant desc, ta.create_time desc + + + order by ${request.orderBy} + + + order by -tb.yesnoant desc, tb.uptime desc + + + @@ -110,24 +120,6 @@ ORDER BY date desc - - - - - INSERT INTO `ter_device_info` ( `sn`, `location`, `lonandlat`,`project_code`, `category` ) - VALUES - ( #{request.sn}, #{request.location}, #{request.lonandlat},#{request.projectCode} ,#{request.category}); - - - - UPDATE `ter_device_info` - SET - `del_flag` = '1' - WHERE - `id` = #{id}; - - -