增加渗流设备及其数据计算
parent
f871f315d5
commit
7d3047eb5c
|
|
@ -1,6 +1,7 @@
|
|||
package com.whdc.zhdbaqapi.component;
|
||||
|
||||
import com.whdc.zhdbaqapi.service.IDeviceDataService;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceSLDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -14,7 +15,8 @@ public class ScheduledTask {
|
|||
|
||||
@Autowired
|
||||
private IDeviceDataService iDeviceDataService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceSLDataService iDeviceSLDataService;
|
||||
@Scheduled(fixedDelay = 60000)
|
||||
public void scheduledTask() {
|
||||
String OS = System.getProperty("os.name").toLowerCase();
|
||||
|
|
@ -22,6 +24,7 @@ public class ScheduledTask {
|
|||
// 简单粗暴的判断,在 linux 环境下运行时,为生成环境
|
||||
if (OS.contains("linux")) {
|
||||
iDeviceDataService.syncData();
|
||||
iDeviceSLDataService.syncData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.whdc.zhdbaqapi.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceDataVo;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceDataService;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceSLDataService;
|
||||
import com.whdc.zhdbaqapi.utils.ResultJson;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 0:47
|
||||
*/
|
||||
@Api(tags = "设备数据 - Controller")
|
||||
@RestController
|
||||
@RequestMapping("/v1/deviceSLData")
|
||||
public class DeviceSLDataController {
|
||||
@Autowired
|
||||
private IDeviceSLDataService iDeviceSLDataService;
|
||||
|
||||
@ApiOperation(value = "分页查询")
|
||||
@PostMapping(value = "/page")
|
||||
public ResultJson<IPage<DeviceDataVo>> page(@RequestBody FindDeviceDto findDto) {
|
||||
return ResultJson.ok(iDeviceSLDataService.page(findDto));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
package com.whdc.zhdbaqapi.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.dto.IntegerIdDto;
|
||||
import com.whdc.zhdbaqapi.model.dto.StationCodeDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceSLInfoService;
|
||||
import com.whdc.zhdbaqapi.utils.ResultJson;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:58
|
||||
*/
|
||||
@Api(tags = "设备信息 - Controller")
|
||||
@RestController
|
||||
@RequestMapping("/v1/deviceSLInfo")
|
||||
@Slf4j
|
||||
public class DeviceSLInfoController {
|
||||
|
||||
@Autowired
|
||||
private IDeviceSLInfoService iDeviceSLInfoService;
|
||||
|
||||
@ApiOperation(value = "获取单个对象")
|
||||
@PostMapping("/get")
|
||||
public ResultJson<DeviceInfo> get(@RequestBody @Validated IntegerIdDto idDto) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.get(idDto.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增")
|
||||
@PostMapping("/save")
|
||||
public ResultJson<Boolean> save(@RequestBody @Validated DeviceSLInfo bean) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.save(bean));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除")
|
||||
@PostMapping("/del")
|
||||
public ResultJson<Boolean> del(@RequestBody @Validated IntegerIdDto bean) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.removeById(bean.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改")
|
||||
@PostMapping("/edit")
|
||||
public ResultJson<Boolean> edit(@RequestBody @Validated DeviceSLInfo bean) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.updateById(bean));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "恢复")
|
||||
@PostMapping("/restore")
|
||||
public ResultJson<Boolean> edit(@RequestBody @Validated IntegerIdDto bean) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.restore(bean.getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "列表查询")
|
||||
@PostMapping(value = "/list")
|
||||
public ResultJson<List<DeviceInfo>> list(@RequestBody StationCodeDto dto) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.list(dto.getStationCode()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询")
|
||||
@PostMapping(value = "/page")
|
||||
public ResultJson<IPage<DeviceInfo>> page(@RequestBody FindDeviceDto findDto) {
|
||||
return ResultJson.ok(iDeviceSLInfoService.page(findDto));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "Excel数据导入")
|
||||
@PostMapping("/imp")
|
||||
public ResultJson<DeviceInfoImpVo> imp(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception {
|
||||
if (file == null) {
|
||||
return ResultJson.error("无效文件");
|
||||
}
|
||||
|
||||
return ResultJson.ok(iDeviceSLInfoService.imp(file.getInputStream()));
|
||||
}
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ public class SysUserController {
|
|||
@ApiOperation(value = "token注册")
|
||||
@PostMapping("registerByToken")
|
||||
public ResultJson<SaTokenInfo> registerByToken(@RequestBody @Validated ForeignTokenDto dto) throws InvocationTargetException, IllegalAccessException {
|
||||
String jstr = HttpUtil.get("http://220.203.2.194:20042/sys/loginByToken?token=" + dto.getToken());
|
||||
String jstr = HttpUtil.get("http://172.20.1.210:30042/sys/loginByToken?token=" + dto.getToken());
|
||||
System.out.println("=======================");
|
||||
System.out.println(dto.getToken());
|
||||
System.out.println(jstr);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.whdc.zhdbaqapi.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceData;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLData;
|
||||
import com.whdc.zhdbaqapi.model.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:40
|
||||
*/
|
||||
public interface DeviceSLDataMapper extends BaseMapper<DeviceSLData> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceSLData> page(@Param("page") IPage<SysUser> page, @Param("obj") FindDeviceDto findDto);
|
||||
|
||||
void clearByDeviceId(@Param("deviceId") String deviceId, @Param("channelNum") Integer channelNum);
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.whdc.zhdbaqapi.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo;
|
||||
import com.whdc.zhdbaqapi.model.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:40
|
||||
*/
|
||||
public interface DeviceSLInfoMapper extends BaseMapper<DeviceSLInfo> {
|
||||
|
||||
/**
|
||||
* TODO: SKETCH_MAP 的数据类型是 text,不知道为啥非要 IFNULL(SKETCH_MAP, '') SKETCH_MAP 这样处理一下才能正常查询到结果
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
DeviceSLInfo get(Integer id);
|
||||
|
||||
/**
|
||||
* 返回查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DeviceSLInfo> list(String stationCode);
|
||||
|
||||
List<DeviceSLInfo> listAll();
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceSLInfo> page(@Param("page") IPage<SysUser> page, @Param("obj") FindDeviceDto findDto);
|
||||
|
||||
/**
|
||||
* 按 stationCode 查询
|
||||
*
|
||||
* @param scs
|
||||
* @return
|
||||
*/
|
||||
List<DeviceSLInfo> listBySC(Set<String> scs);
|
||||
|
||||
/**
|
||||
* 检查 station_code 是否有效
|
||||
*
|
||||
* @param stationCode
|
||||
* @return
|
||||
*/
|
||||
DeviceSLInfo checkValidStationCode(String stationCode);
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.whdc.zhdbaqapi.model.entity;
|
||||
|
||||
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.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:28
|
||||
*/
|
||||
@Data
|
||||
@TableName("DEVICE_SL_DATA")
|
||||
@Accessors(chain = true) // chain = true 实现链式调用
|
||||
@ApiModel(value = "DEVICE_SL_DATA 对象", description = "设备数据")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性
|
||||
public class DeviceSLData {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiParam(value = "主键id")
|
||||
@ApiModelProperty(value = "主键id", dataType = "java.lang.Integer")
|
||||
@TableId(value = "ID", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 堰上水头
|
||||
*/
|
||||
@ApiParam(value = "堰上水头")
|
||||
@ApiModelProperty(value = "堰上水头", dataType = "java.math.BigDecimal")
|
||||
@TableField("DATA")
|
||||
private BigDecimal l;
|
||||
|
||||
/**
|
||||
* 流量
|
||||
*/
|
||||
@ApiParam(value = "流量")
|
||||
@ApiModelProperty(value = "流量", dataType = "java.math.BigDecimal")
|
||||
@TableField("Q")
|
||||
private BigDecimal q;
|
||||
/**
|
||||
* 入库时间
|
||||
*/
|
||||
@ApiParam(value = "入库时间")
|
||||
@ApiModelProperty(value = "入库时间", dataType = "java.lang.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("CREATETIME")
|
||||
private Date createtime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiParam(value = "")
|
||||
@ApiModelProperty(value = "", dataType = "java.math.BigDecimal")
|
||||
@TableField("DATA_C")
|
||||
private BigDecimal dataC;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiParam(value = "")
|
||||
@ApiModelProperty(value = "", dataType = "java.math.BigDecimal")
|
||||
@TableField("DATA_B")
|
||||
private BigDecimal dataB;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiParam(value = "")
|
||||
@ApiModelProperty(value = "", dataType = "java.math.BigDecimal")
|
||||
@TableField("DATA_A")
|
||||
private BigDecimal dataA;
|
||||
|
||||
/**
|
||||
* 通道号
|
||||
*/
|
||||
@ApiParam(value = "通道号")
|
||||
@ApiModelProperty(value = "通道号", dataType = "java.lang.Integer")
|
||||
@TableField("CHANNEL_NUM")
|
||||
private Integer channelNum;
|
||||
|
||||
/**
|
||||
* 数据时间
|
||||
*/
|
||||
@ApiParam(value = "数据时间")
|
||||
@ApiModelProperty(value = "数据时间", dataType = "java.lang.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("TIMESTAMP")
|
||||
private Date timestamp;
|
||||
|
||||
/**
|
||||
* 测站编码(MCU)
|
||||
*/
|
||||
@ApiParam(value = "测站编码(MCU)")
|
||||
@ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String")
|
||||
@TableField("DEVICE_ID")
|
||||
private String deviceId;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,445 @@
|
|||
package com.whdc.zhdbaqapi.model.entity;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
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.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:26
|
||||
*/
|
||||
@Data
|
||||
@TableName("DEVICE_SL_INFO")
|
||||
@Accessors(chain = true) // chain = true 实现链式调用
|
||||
@ApiModel(value = "DEVICE_SL 对象", description = "渗流设备信息")
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性
|
||||
public class DeviceSLInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String FORMULA_ZHIXIAN = "直线"; //Delta(L) = G*(R1-R0)
|
||||
public static final String FORMULA_DUOXIANGSHI = "多项式"; //Delta(L) = A*R0*R0+B*R0+C-(A*R1*R1+B*R1+C)
|
||||
public static final BigDecimal G = BigDecimal.valueOf(-0.044333);
|
||||
public static final BigDecimal A = BigDecimal.valueOf(0.0000001374906702);
|
||||
public static final BigDecimal B = BigDecimal.valueOf(0.0422409953153613);
|
||||
public static final BigDecimal C = BigDecimal.valueOf(-184.94391862590900);
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiParam(value = "主键id")
|
||||
@ApiModelProperty(value = "主键id", dataType = "java.lang.Integer")
|
||||
@TableId(value = "ID", type = IdType.AUTO)
|
||||
protected Integer id;
|
||||
|
||||
//region ====================必填信息====================
|
||||
/**
|
||||
* 测点编号
|
||||
*/
|
||||
@ApiParam(value = "测点编号")
|
||||
@ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true)
|
||||
@Excel(name = "测点编号")
|
||||
@NotEmpty(message = "测点编号必填")
|
||||
@TableField("STATION_CODE")
|
||||
protected String stationCode;
|
||||
|
||||
/**
|
||||
* 测站编码(MCU)
|
||||
*/
|
||||
@ApiParam(value = "测站编码(MCU)")
|
||||
@ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String", required = true)
|
||||
@Excel(name = "测站编码(MCU)")
|
||||
@NotEmpty(message = "测站编码(MCU)必填")
|
||||
@TableField("DEVICE_ID")
|
||||
protected String deviceId;
|
||||
|
||||
/**
|
||||
* 通道号
|
||||
*/
|
||||
@ApiParam(value = "通道号")
|
||||
@ApiModelProperty(value = "通道号", dataType = "java.lang.Integer", required = true)
|
||||
@Excel(name = "通道号")
|
||||
@NotNull(message = "通道号必填")
|
||||
@Max(message = "通道号最大值 7", value = 7)
|
||||
@Min(message = "通道号最小值 0", value = 0)
|
||||
@TableField("CHANNEL_NUM")
|
||||
protected Integer channelNum;
|
||||
|
||||
/**
|
||||
* 仪器编号
|
||||
*/
|
||||
@ApiParam(value = "仪器编号")
|
||||
@ApiModelProperty(value = "仪器编号", dataType = "java.lang.String", required = true)
|
||||
@Excel(name = "仪器编号")
|
||||
@TableField("PROBE_SERIAL")
|
||||
private String probeSerial;
|
||||
|
||||
/**
|
||||
* 零位读数
|
||||
* data_c
|
||||
*/
|
||||
@ApiParam(value = "零位读数")
|
||||
@ApiModelProperty(value = "零位读数", dataType = "java.math.BigDecimal", required = true)
|
||||
@Excel(name = "零位读数")
|
||||
@TableField("READING0")
|
||||
private BigDecimal reading0;
|
||||
|
||||
@ApiParam(value = "公式")
|
||||
@ApiModelProperty(value = "公式", dataType = "java.lang.String", required = true)
|
||||
@TableField("FORMULA")
|
||||
private String formula;
|
||||
|
||||
/**
|
||||
* 零点高度(mm)
|
||||
*/
|
||||
@ApiParam(value = "零点高度(mm)")
|
||||
@ApiModelProperty(value = "零点高度(mm)", dataType = "java.math.BigDecimal", required = true)
|
||||
@Excel(name = "零点高度(mm)")
|
||||
@TableField("ZERO_POINT_HEIGHT")
|
||||
private BigDecimal zeroPointHeight;
|
||||
|
||||
/**
|
||||
* 最大堰上水头(m)
|
||||
*/
|
||||
@ApiParam(value = "最大堰上水头(m)")
|
||||
@ApiModelProperty(value = "最大堰上水头(m)", dataType = "java.math.BigDecimal", required = true)
|
||||
@Excel(name = "最大堰上水头(m)")
|
||||
@TableField("MAX_H")
|
||||
private BigDecimal maxH;
|
||||
|
||||
//endregion
|
||||
|
||||
//region ====================设备读数信息====================
|
||||
/**
|
||||
* 安装时温度(℃)
|
||||
* data_b
|
||||
*/
|
||||
@ApiParam(value = "安装时温度(℃)")
|
||||
@ApiModelProperty(value = "安装时温度(℃)", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "安装时温度(℃)")
|
||||
@TableField("TEMPERATURE0")
|
||||
private BigDecimal temperature0;
|
||||
|
||||
/**
|
||||
* 温度(℃)
|
||||
* data_b
|
||||
*/
|
||||
@ApiParam(value = "温度(℃)")
|
||||
@ApiModelProperty(value = "温度(℃)", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "温度(℃)")
|
||||
@TableField("TEMPERATURE1")
|
||||
private BigDecimal temperature1;
|
||||
|
||||
/**
|
||||
* 仪器测值
|
||||
*/
|
||||
@ApiParam(value = "仪器测值")
|
||||
@ApiModelProperty(value = "仪器测值", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "仪器测值")
|
||||
@TableField("DEVICE_MEASURE")
|
||||
private BigDecimal deviceMeasure;
|
||||
|
||||
/**
|
||||
* 埋设后测值
|
||||
*/
|
||||
@ApiParam(value = "埋设后测值")
|
||||
@ApiModelProperty(value = "埋设后测值", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "埋设后测值")
|
||||
@TableField("DEVICE_MEASURE_AFTER")
|
||||
private BigDecimal deviceMeasureAfter;
|
||||
//endregion
|
||||
|
||||
//region ====================安装信息====================
|
||||
/**
|
||||
* 安装高程
|
||||
*/
|
||||
@ApiParam(value = "安装高程")
|
||||
@ApiModelProperty(value = "安装高程", dataType = "java.lang.Double")
|
||||
@TableField("INSTALLATION_POSITION_Z")
|
||||
protected Double installationPositionZ;
|
||||
|
||||
/**
|
||||
* 安装纬度
|
||||
*/
|
||||
@ApiParam(value = "安装纬度")
|
||||
@ApiModelProperty(value = "安装纬度", dataType = "java.lang.Double")
|
||||
@TableField("INSTALLATION_POSITION_Y")
|
||||
protected Double installationPositionY;
|
||||
|
||||
/**
|
||||
* 安装经度
|
||||
*/
|
||||
@ApiParam(value = "安装经度")
|
||||
@ApiModelProperty(value = "安装经度", dataType = "java.lang.Double")
|
||||
@TableField("INSTALLATION_POSITION_X")
|
||||
protected Double installationPositionX;
|
||||
|
||||
/**
|
||||
* 下游水位(m)
|
||||
*/
|
||||
@ApiParam(value = "下游水位(m)")
|
||||
@ApiModelProperty(value = "下游水位(m)", dataType = "java.lang.Double")
|
||||
@Excel(name = "下游水位")
|
||||
@TableField("TAILWATER_LEVEL")
|
||||
private Double tailWaterLevel;
|
||||
|
||||
/**
|
||||
* 上游水位(m)
|
||||
*/
|
||||
@ApiParam(value = "上游水位(m)")
|
||||
@ApiModelProperty(value = "上游水位(m)", dataType = "java.lang.Double")
|
||||
@Excel(name = "上游水位")
|
||||
@TableField("HEADWATER_LEVEL")
|
||||
private Double headwaterLevel;
|
||||
|
||||
/**
|
||||
* 天气
|
||||
*/
|
||||
@ApiParam(value = "天气")
|
||||
@ApiModelProperty(value = "天气", dataType = "java.lang.String")
|
||||
@Excel(name = "天气")
|
||||
@TableField("WEATHER")
|
||||
private String weather;
|
||||
|
||||
/**
|
||||
* 气温
|
||||
*/
|
||||
@ApiParam(value = "气温")
|
||||
@ApiModelProperty(value = "气温", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "气温")
|
||||
@TableField("AIR_TEMPERATURE")
|
||||
private BigDecimal airTemperature;
|
||||
//endregion
|
||||
|
||||
//region ====================工程信息====================
|
||||
/**
|
||||
* 工程部位
|
||||
*/
|
||||
@ApiParam(value = "工程部位")
|
||||
@ApiModelProperty(value = "工程部位", dataType = "java.lang.String")
|
||||
@Excel(name = "工程部位")
|
||||
@TableField("PROJECT_LOCATION")
|
||||
private String projectLocation;
|
||||
|
||||
/**
|
||||
* 项目名称
|
||||
*/
|
||||
@ApiParam(value = "项目名称")
|
||||
@ApiModelProperty(value = "项目名称", dataType = "java.lang.String")
|
||||
@Excel(name = "工程或项目名称")
|
||||
@TableField("PROJECT_NAME")
|
||||
private String projectName;
|
||||
|
||||
|
||||
/**
|
||||
* 生产厂家
|
||||
*/
|
||||
@ApiParam(value = "生产厂家")
|
||||
@ApiModelProperty(value = "生产厂家", dataType = "java.lang.String")
|
||||
@Excel(name = "生产厂家")
|
||||
@TableField("MANUFACTURER")
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* 站型
|
||||
*/
|
||||
@ApiParam(value = "站型")
|
||||
@ApiModelProperty(value = "站型", dataType = "java.lang.String")
|
||||
@Excel(name = "站型")
|
||||
@TableField("STATION_TYPE")
|
||||
private String stationType;
|
||||
|
||||
/**
|
||||
* 堰型
|
||||
*/
|
||||
@ApiParam(value = "堰型")
|
||||
@ApiModelProperty(value = "堰型", dataType = "java.lang.String")
|
||||
@Excel(name = "堰型")
|
||||
@TableField("STANK_TYPE")
|
||||
private String stankType;
|
||||
|
||||
/**
|
||||
* 堰板材料
|
||||
*/
|
||||
@ApiParam(value = "堰板材料")
|
||||
@ApiModelProperty(value = "堰板材料", dataType = "java.lang.String")
|
||||
@Excel(name = "堰板材料")
|
||||
@TableField("STANK_MATERIAL")
|
||||
private String stankMaterial;
|
||||
|
||||
/**
|
||||
* 堰口至堰槽底距离(mm)
|
||||
*/
|
||||
@ApiParam(value = "堰口至堰槽底距离(mm)")
|
||||
@ApiModelProperty(value = "堰口至堰槽底距离(mm)", dataType = "java.lang.String")
|
||||
@Excel(name = "堰口至堰槽底距离(mm)")
|
||||
@TableField("STANK_TOP_TO_BOTTOM_DISTANCE")
|
||||
private String stankTopToBottomDistance;
|
||||
|
||||
/**
|
||||
* 堰槽尺寸(mm*mm*mm)
|
||||
*/
|
||||
@ApiParam(value = "堰槽尺寸(mm*mm*mm)")
|
||||
@ApiModelProperty(value = "堰槽尺寸(mm*mm*mm)", dataType = "java.lang.String")
|
||||
@Excel(name = "堰槽尺寸(mm*mm*mm)")
|
||||
@TableField("STANK_SIZE")
|
||||
private String stankSize;
|
||||
|
||||
/**
|
||||
* 水尺(传感器)形式
|
||||
*/
|
||||
@ApiParam(value = "水尺(传感器)形式")
|
||||
@ApiModelProperty(value = "水尺(传感器)形式", dataType = "java.lang.String")
|
||||
@Excel(name = "水尺(传感器)形式")
|
||||
@TableField("RULER_TYPE")
|
||||
private String rulerType;
|
||||
|
||||
/**
|
||||
* 水尺(测针)位置
|
||||
*/
|
||||
@ApiParam(value = "水尺(测针)位置")
|
||||
@ApiModelProperty(value = "水尺(测针)位置", dataType = "java.lang.String")
|
||||
@Excel(name = "水尺(测针)位置")
|
||||
@TableField("RULER_POSITION")
|
||||
private String rulerPosition;
|
||||
|
||||
/**
|
||||
* 温度系数(mm/℃)
|
||||
*/
|
||||
@ApiParam(value = "温度系数(mm/℃)")
|
||||
@ApiModelProperty(value = "温度系数(mm/℃)", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "温度系数(mm/℃)")
|
||||
@TableField("TEMPERATURE_MOD")
|
||||
private BigDecimal temperatureMod;
|
||||
|
||||
/**
|
||||
* 量测(mm)
|
||||
*/
|
||||
@ApiParam(value = "量测(mm)")
|
||||
@ApiModelProperty(value = "量测(mm)", dataType = "java.math.BigDecimal")
|
||||
@Excel(name = "量测(mm)")
|
||||
@TableField("MEASURE")
|
||||
private BigDecimal measure;
|
||||
|
||||
/**
|
||||
* 埋设示意图
|
||||
*/
|
||||
@ApiParam(value = "埋设示意图")
|
||||
@ApiModelProperty(value = "埋设示意图", dataType = "java.lang.String")
|
||||
@TableField(value = "SKETCH_MAP")
|
||||
protected String sketchMap;
|
||||
//endregion
|
||||
|
||||
//region ====================人员信息====================
|
||||
/**
|
||||
* 技术负责人
|
||||
*/
|
||||
@ApiParam(value = "技术负责人")
|
||||
@ApiModelProperty(value = "技术负责人", dataType = "java.lang.String")
|
||||
@Excel(name = "技术负责人")
|
||||
@TableField("DIRECTOR")
|
||||
protected String director;
|
||||
|
||||
/**
|
||||
* 校验人
|
||||
*/
|
||||
@ApiParam(value = "校验人")
|
||||
@ApiModelProperty(value = "校验人", dataType = "java.lang.String")
|
||||
@Excel(name = "校验人")
|
||||
@TableField("VERIFIER")
|
||||
protected String verifier;
|
||||
|
||||
/**
|
||||
* 埋设及填表人
|
||||
*/
|
||||
@ApiParam(value = "埋设及填表人")
|
||||
@ApiModelProperty(value = "埋设及填表人", dataType = "java.lang.String")
|
||||
@Excel(name = "埋设及填表人")
|
||||
@TableField("OPERATOR")
|
||||
protected String operator;
|
||||
|
||||
/**
|
||||
* 监理工程师
|
||||
*/
|
||||
@ApiParam(value = "监理工程师")
|
||||
@ApiModelProperty(value = "监理工程师", dataType = "java.lang.String")
|
||||
@Excel(name = "监理工程师")
|
||||
@TableField("SUPERVISOR")
|
||||
private String supervisor;
|
||||
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
@ApiParam(value = "日期")
|
||||
@ApiModelProperty(value = "日期", dataType = "java.util.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
|
||||
@Excel(name = "日期")
|
||||
@TableField("INSTALL_DATE")
|
||||
protected Date installDate;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ApiParam(value = "备注")
|
||||
@ApiModelProperty(value = "备注", dataType = "java.lang.String")
|
||||
@Excel(name = "备注")
|
||||
@TableField("REMARK")
|
||||
private String remark;
|
||||
//endregion
|
||||
|
||||
//region ====================计算用字段,可能不展示====================
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@ApiParam(value = "修改时间")
|
||||
@ApiModelProperty(value = "修改时间", dataType = "java.util.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("MODIFICATION_TIME")
|
||||
private Date modificationTime;
|
||||
|
||||
/**
|
||||
* 最后数据同步时间
|
||||
*/
|
||||
@ApiParam(value = "最后数据同步时间")
|
||||
@ApiModelProperty(value = "最后数据同步时间", dataType = "java.util.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("LATEST_REPORTING_TIME")
|
||||
private Date latestReportingTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@ApiParam(value = "修改时间")
|
||||
@ApiModelProperty(value = "修改时间", dataType = "java.util.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
@TableField("CREATE_TIME")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 0:删除 1 已逻辑删除
|
||||
*/
|
||||
@ApiParam(value = "0:删除 1 已逻辑删除")
|
||||
@ApiModelProperty(value = "0:删除 1 已逻辑删除", dataType = "java.lang.Integer")
|
||||
@TableField("DEL")
|
||||
private Integer del;
|
||||
|
||||
@Excel(name = "埋设示意图说明", type = 2, savePath = "img")
|
||||
@TableField(exist = false)
|
||||
private String picPath;
|
||||
//endregion
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
package com.whdc.zhdbaqapi.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 0:42
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true) // chain = true 实现链式调用
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性
|
||||
public class DeviceSLDataVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@ApiParam(value = "主键id")
|
||||
@ApiModelProperty(value = "主键id", dataType = "java.lang.Integer")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 入库时间
|
||||
*/
|
||||
@ApiParam(value = "入库时间")
|
||||
@ApiModelProperty(value = "入库时间", dataType = "java.lang.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createtime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiParam(value = "")
|
||||
@ApiModelProperty(value = "", dataType = "java.math.BigDecimal")
|
||||
private BigDecimal dataC;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiParam(value = "")
|
||||
@ApiModelProperty(value = "", dataType = "java.math.BigDecimal")
|
||||
private BigDecimal dataB;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ApiParam(value = "")
|
||||
@ApiModelProperty(value = "", dataType = "java.math.BigDecimal")
|
||||
private BigDecimal dataA;
|
||||
|
||||
/**
|
||||
* 通道号
|
||||
*/
|
||||
@ApiParam(value = "通道号")
|
||||
@ApiModelProperty(value = "通道号", dataType = "java.lang.Integer")
|
||||
private Integer channelNum;
|
||||
|
||||
/**
|
||||
* 数据时间
|
||||
*/
|
||||
@ApiParam(value = "数据时间")
|
||||
@ApiModelProperty(value = "数据时间", dataType = "java.lang.Date")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date timestamp;
|
||||
|
||||
/**
|
||||
* 测站编码(MCU)
|
||||
*/
|
||||
@ApiParam(value = "测站编码(MCU)")
|
||||
@ApiModelProperty(value = "测站编码(MCU)", dataType = "java.lang.String")
|
||||
private String deviceId;
|
||||
|
||||
|
||||
/**
|
||||
* 测点编号
|
||||
*/
|
||||
@ApiParam(value = "测点编号")
|
||||
@ApiModelProperty(value = "测点编号", dataType = "java.lang.String", required = true)
|
||||
@NotEmpty(message = "测点编号必填")
|
||||
private String stationCode;
|
||||
|
||||
/**
|
||||
* 计算值
|
||||
*/
|
||||
@ApiParam(value = "计算值")
|
||||
@ApiModelProperty(value = "计算值", dataType = "java.math.BigDecimal")
|
||||
private BigDecimal data;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.whdc.zhdbaqapi.model.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 11:42
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true) // chain = true 实现链式调用
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL) // 表示序列化非null属性
|
||||
public class DeviceSLInfoImpVo {
|
||||
@ApiModelProperty("成功读取记录条数")
|
||||
private int load;
|
||||
|
||||
@ApiModelProperty("成功入库记录条数")
|
||||
private int success;
|
||||
|
||||
@ApiModelProperty("入库失败记录条数")
|
||||
private int fail;
|
||||
|
||||
@ApiModelProperty("入库失败记录")
|
||||
private List<DeviceSLInfo> err;
|
||||
|
||||
@ApiModelProperty("消息")
|
||||
private String msg;
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.whdc.zhdbaqapi.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLData;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceSLDataVo;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 0:45
|
||||
*/
|
||||
public interface IDeviceSLDataService extends IService<DeviceSLData> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceSLDataVo> page(FindDeviceDto findDto);
|
||||
|
||||
/**
|
||||
* 同步数据
|
||||
*/
|
||||
void syncData();
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.whdc.zhdbaqapi.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceSLInfoImpVo;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:47
|
||||
*/
|
||||
public interface IDeviceSLInfoService extends IService<DeviceSLInfo> {
|
||||
|
||||
DeviceSLInfo get(Integer id);
|
||||
|
||||
/**
|
||||
* 恢复
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean restore(Integer id);
|
||||
|
||||
/**
|
||||
* 返回查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DeviceSLInfo> list(String stationCode);
|
||||
|
||||
List<DeviceSLInfo> listAll();
|
||||
|
||||
boolean updateByIdInternal(DeviceSLInfo entity);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param findDto
|
||||
* @return
|
||||
*/
|
||||
IPage<DeviceSLInfo> page(FindDeviceDto findDto);
|
||||
|
||||
/**
|
||||
* 导入
|
||||
*
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
DeviceSLInfoImpVo imp(InputStream file);
|
||||
|
||||
void clearCache();
|
||||
}
|
||||
|
|
@ -95,6 +95,7 @@ public class DeviceInfoServiceimpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|||
entity.setLatestReportingTime(new Date(defaultTimeStamp));
|
||||
deviceDataMapper.clearByDeviceId(entity.getDeviceId(), entity.getChannelNum());
|
||||
}
|
||||
redisTemplate.delete(Constants.CACHE_NAME);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +107,7 @@ public class DeviceInfoServiceimpl extends ServiceImpl<DeviceInfoMapper, DeviceI
|
|||
throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
}
|
||||
entity.setModificationTime(new Date());
|
||||
|
||||
redisTemplate.delete(Constants.CACHE_NAME);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,190 @@
|
|||
package com.whdc.zhdbaqapi.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.whdc.zhdbaqapi.mapper.DeviceSLDataMapper;
|
||||
import com.whdc.zhdbaqapi.model.cklat.CklatQueryDto;
|
||||
import com.whdc.zhdbaqapi.model.cklat.CklatRecord;
|
||||
import com.whdc.zhdbaqapi.model.cklat.CklatResult;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLData;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceSLDataVo;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceSLDataService;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceSLInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-22 0:46
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Configuration
|
||||
public class DeviceSLDataServiceImpl extends ServiceImpl<DeviceSLDataMapper, DeviceSLData> implements IDeviceSLDataService {
|
||||
|
||||
|
||||
@Value("${cklat_data_api}")
|
||||
private String cklat_data_api;
|
||||
|
||||
@Value("${o_z_modulus}")
|
||||
private Double o_z_modulus;
|
||||
|
||||
@Autowired
|
||||
private IDeviceSLInfoService iDeviceSLInfoService;
|
||||
|
||||
@Autowired
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
// private static ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public IPage<DeviceSLDataVo> page(FindDeviceDto findDto) {
|
||||
return baseMapper.page(findDto.getPage(), findDto);
|
||||
}
|
||||
|
||||
|
||||
public List<CklatRecord> getRemoteData(String deviceId, Integer channelNum, Date tm) {
|
||||
try {
|
||||
CklatQueryDto query = new CklatQueryDto()
|
||||
.setDeviceId(deviceId)
|
||||
.setStartTimestamp(tm)
|
||||
.setChannelNum(channelNum);
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
HttpEntity<String> request = new HttpEntity<String>(JSON.toJSONString(query), headers);
|
||||
|
||||
ResponseEntity<CklatResult> result = restTemplate.postForEntity(cklat_data_api, request, CklatResult.class);
|
||||
|
||||
CklatResult ret = result.getBody();
|
||||
|
||||
if (ret != null && "success".equals(ret.getStatus())) {
|
||||
return ret.getRows();
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncData() {
|
||||
List<DeviceSLInfo> list = iDeviceSLInfoService.listAll();
|
||||
boolean changeDi = false;
|
||||
|
||||
for (DeviceSLInfo di : list) {
|
||||
String deviceId = di.getDeviceId();
|
||||
Date lasttm = di.getLatestReportingTime();
|
||||
Calendar c = Calendar.getInstance();
|
||||
|
||||
if (lasttm == null) {
|
||||
c.add(Calendar.DATE, -31); // 取近 31 天的数据
|
||||
} else {
|
||||
c.setTime(lasttm);
|
||||
c.add(Calendar.SECOND, 1); // 传最后数据时间,会一直拉到最后一条记录,所以这里加了一秒
|
||||
}
|
||||
|
||||
lasttm = c.getTime();
|
||||
|
||||
List<CklatRecord> rows = getRemoteData(deviceId, di.getChannelNum(), lasttm);
|
||||
|
||||
if (rows == null || rows.isEmpty()) {
|
||||
log.debug("没有取到数据 " + deviceId + ", " + di.getChannelNum());
|
||||
continue;
|
||||
}
|
||||
|
||||
int cnt = 0;
|
||||
|
||||
for (CklatRecord record : rows) {
|
||||
// 数据量不大,逐条插入,避免部分数据错误导致批量插入失败
|
||||
try {
|
||||
DeviceSLData dd = new DeviceSLData()
|
||||
.setDeviceId(record.getDeviceId())
|
||||
.setChannelNum(record.getChannelNum())
|
||||
.setTimestamp(record.getTimestamp())
|
||||
.setDataA(record.getDataA())
|
||||
.setDataB(record.getDataB())
|
||||
.setDataC(record.getDataC());
|
||||
|
||||
String formula = di.getFormula();
|
||||
BigDecimal R0 = di.getReading0();// initialReading 初始读数
|
||||
BigDecimal R1 = record.getDataC();// initialReading 初始读数
|
||||
BigDecimal G = DeviceSLInfo.G; // calibrationCoefficient 率定系数(G)
|
||||
|
||||
if (R0 == null || formula == null) {
|
||||
log.debug("参数数据不完整");
|
||||
} else {
|
||||
BigDecimal L;
|
||||
if (formula.equals(DeviceSLInfo.FORMULA_ZHIXIAN)) {
|
||||
//Delta(L) = G*(R1-R0)
|
||||
L = G.multiply(R1.subtract(R0));
|
||||
} else if (formula.equals(DeviceSLInfo.FORMULA_DUOXIANGSHI)) {
|
||||
//Delta(L) = A*R0*R0+B*R0+C-(A*R1*R1+B*R1+C)
|
||||
BigDecimal A = DeviceSLInfo.A.multiply(R0.multiply(R0));
|
||||
BigDecimal B = DeviceSLInfo.B.multiply(R0);
|
||||
BigDecimal D = DeviceSLInfo.A.multiply(R1.multiply(R1));
|
||||
BigDecimal E = DeviceSLInfo.B.multiply(R1);
|
||||
L = A.add(B).add(DeviceSLInfo.C).subtract(D).subtract(E);
|
||||
} else {
|
||||
L = null;
|
||||
}
|
||||
|
||||
dd.setL(L);
|
||||
|
||||
BigDecimal Q; //单位L/s
|
||||
//Q=1343∗H^2.47
|
||||
//H=h+P
|
||||
BigDecimal P = di.getZeroPointHeight();//单位mm
|
||||
BigDecimal h = L; //单位m?
|
||||
BigDecimal H = h.add(P); //单位m
|
||||
BigDecimal maxH = di.getMaxH(); //单位m
|
||||
if (H.doubleValue() > maxH.doubleValue()) {
|
||||
Q = new BigDecimal(1343).multiply(BigDecimal.valueOf(Math.pow(maxH.doubleValue(), 2.47)));
|
||||
} else {
|
||||
Q = new BigDecimal(1343).multiply(BigDecimal.valueOf(Math.pow(H.doubleValue(), 2.47)));
|
||||
}
|
||||
dd.setQ(Q);
|
||||
}
|
||||
|
||||
if (super.save(dd)) {
|
||||
cnt += 1;
|
||||
|
||||
di.setLatestReportingTime(dd.getTimestamp());
|
||||
iDeviceSLInfoService.updateByIdInternal(di);
|
||||
changeDi = true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("拉取 " + rows.size() + " 保存 " + cnt);
|
||||
}
|
||||
|
||||
if (changeDi) {
|
||||
iDeviceSLInfoService.clearCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
package com.whdc.zhdbaqapi.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.whdc.zhdbaqapi.constant.Constants;
|
||||
import com.whdc.zhdbaqapi.exception.MyException;
|
||||
import com.whdc.zhdbaqapi.mapper.DeviceDataMapper;
|
||||
import com.whdc.zhdbaqapi.mapper.DeviceSLInfoMapper;
|
||||
import com.whdc.zhdbaqapi.model.dto.FindDeviceDto;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceInfo;
|
||||
import com.whdc.zhdbaqapi.model.entity.DeviceSLInfo;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceInfoImpVo;
|
||||
import com.whdc.zhdbaqapi.model.vo.DeviceSLInfoImpVo;
|
||||
import com.whdc.zhdbaqapi.service.IDeviceSLInfoService;
|
||||
import com.whdc.zhdbaqapi.utils.DataUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author 李赛
|
||||
* @date 2022-07-21 23:47
|
||||
*/
|
||||
@Service
|
||||
public class DeviceSLInfoServiceimpl extends ServiceImpl<DeviceSLInfoMapper, DeviceSLInfo> implements IDeviceSLInfoService {
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
@Autowired
|
||||
private DeviceDataMapper deviceDataMapper;
|
||||
|
||||
private static long defaultTimeStamp;
|
||||
|
||||
static {
|
||||
try {
|
||||
defaultTimeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("2022-07-01 00:00:00").getTime();
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceSLInfo get(Integer id) {
|
||||
DeviceSLInfo ret = baseMapper.get(id);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean save(DeviceSLInfo entity) {
|
||||
if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) {
|
||||
throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
}
|
||||
|
||||
entity.setCreateTime(new Date());
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean updateById(DeviceSLInfo entity) {
|
||||
DeviceSLInfo old = baseMapper.checkValidStationCode(entity.getStationCode());
|
||||
if (old == null) {
|
||||
throw new MyException("stationCode=" + entity.getStationCode() + " 没有找到");
|
||||
}
|
||||
if (old != null && !old.getId().equals(entity.getId())) {
|
||||
throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
}
|
||||
entity.setModificationTime(new Date());
|
||||
System.out.println("==============================");
|
||||
System.out.println(old.getChannelNum());
|
||||
System.out.println(entity.getChannelNum());
|
||||
System.out.println("==============================");
|
||||
if (
|
||||
!old.getChannelNum().equals(entity.getChannelNum())
|
||||
|| !old.getStationCode().equals(entity.getStationCode())
|
||||
|| !old.getReading0().equals(entity.getReading0())
|
||||
) {
|
||||
entity.setLatestReportingTime(new Date(defaultTimeStamp));
|
||||
deviceDataMapper.clearByDeviceId(entity.getDeviceId(), entity.getChannelNum());
|
||||
}
|
||||
redisTemplate.delete(Constants.CACHE_NAME);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean updateByIdInternal(DeviceSLInfo entity) {
|
||||
DeviceSLInfo old = baseMapper.checkValidStationCode(entity.getStationCode());
|
||||
if (old != null && !old.getId().equals(entity.getId())) {
|
||||
throw new MyException("stationCode=" + entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
}
|
||||
entity.setModificationTime(new Date());
|
||||
redisTemplate.delete(Constants.CACHE_NAME);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean removeById(Serializable id) {
|
||||
DeviceSLInfo entity = baseMapper.selectById(id);
|
||||
entity.setDel(1);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(Constants.CACHE_NAME)
|
||||
public boolean restore(Integer id) {
|
||||
DeviceSLInfo entity = baseMapper.selectById(id);
|
||||
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (baseMapper.checkValidStationCode(entity.getStationCode()) != null) {
|
||||
throw new MyException(entity.getStationCode() + " 已被其他有效数据使用,不能恢复");
|
||||
}
|
||||
|
||||
entity.setDel(0);
|
||||
return super.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceSLInfo> list(String stationCode) {
|
||||
return baseMapper.list(stationCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(Constants.CACHE_NAME)
|
||||
public List<DeviceSLInfo> listAll() {
|
||||
return baseMapper.listAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<DeviceSLInfo> page(FindDeviceDto findDto) {
|
||||
return baseMapper.page(findDto.getPage(), findDto);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DeviceSLInfoImpVo imp(InputStream file) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(false);
|
||||
try {
|
||||
List<DeviceSLInfo> list = ExcelImportUtil.importExcel(file, DeviceSLInfo.class, params);
|
||||
|
||||
if (list == null || list.isEmpty()) {
|
||||
return new DeviceSLInfoImpVo().setLoad(0).setSuccess(0).setFail(0).setMsg("没有读取有有效数据");
|
||||
}
|
||||
|
||||
List<DeviceSLInfo> err = new ArrayList<>();
|
||||
List<DeviceSLInfo> impList = new ArrayList<>();
|
||||
Set<String> scs = new HashSet<>();
|
||||
Map<String, DeviceSLInfo> chkMap = new HashMap<>();
|
||||
|
||||
for (DeviceSLInfo di : list) {
|
||||
if (StringUtils.isBlank(di.getStationCode())) {
|
||||
err.add(di);
|
||||
} else {
|
||||
scs.add(di.getStationCode());
|
||||
}
|
||||
}
|
||||
|
||||
if (scs.isEmpty() || err.size() == list.size()) {
|
||||
return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("没有读取到有效的测点编号");
|
||||
}
|
||||
|
||||
if (scs.size() != list.size()) {
|
||||
return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("有重复的测点编号,请检查后再导入");
|
||||
}
|
||||
|
||||
List<DeviceSLInfo> chkscs = baseMapper.listBySC(scs);
|
||||
if (chkscs.size() == scs.size()) {
|
||||
return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在");
|
||||
}
|
||||
|
||||
for (DeviceSLInfo dbdi : chkscs) {
|
||||
chkMap.put(dbdi.getStationCode(), dbdi);
|
||||
}
|
||||
|
||||
for (DeviceSLInfo di : list) {
|
||||
if (chkMap.containsKey(di.getStationCode())) {
|
||||
err.add(di);
|
||||
} else {
|
||||
if (StringUtils.isNotBlank(di.getPicPath())) {
|
||||
String filepath = System.getProperty("user.dir") + "/" + di.getPicPath();
|
||||
di.setSketchMap(DataUtils.File2Base64(filepath));
|
||||
DataUtils.DelFile(filepath);
|
||||
}
|
||||
|
||||
impList.add(di);
|
||||
}
|
||||
}
|
||||
|
||||
if (impList.isEmpty()) {
|
||||
return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("测点编号全部已存在");
|
||||
}
|
||||
|
||||
if (super.saveBatch(impList)) {
|
||||
clearCache();
|
||||
|
||||
return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(impList.size()).setFail(err.size()).setErr(err).setMsg("成功");
|
||||
} else {
|
||||
return new DeviceSLInfoImpVo().setLoad(list.size()).setSuccess(0).setFail(err.size()).setErr(err).setMsg("失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new MyException("导入异常!" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearCache() {
|
||||
Set<String> keys = redisTemplate.keys(Constants.CACHE_NAME + "*");
|
||||
for (String k : keys) {
|
||||
redisTemplate.delete(k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.whdc.zhdbaqapi.mapper.DeviceSLDataMapper">
|
||||
|
||||
<select id="page" resultType="com.whdc.zhdbaqapi.model.vo.DeviceSLDataVo">
|
||||
SELECT D.*, I.STATION_CODE FROM DEVICE_SL_DATA D
|
||||
LEFT JOIN DEVICE_SL_INFO I ON D.DEVICE_ID = I.DEVICE_ID AND D.CHANNEL_NUM = I.CHANNEL_NUM AND I.DEL = 0
|
||||
WHERE 1=1
|
||||
<if test="obj.deviceId != null and obj.deviceId != '' ">
|
||||
AND D.DEVICE_ID LIKE CONCAT('%', #{obj.deviceId}, '%')
|
||||
</if>
|
||||
<if test="obj.stationCode != null and obj.stationCode != '' ">
|
||||
AND I.STATION_CODE LIKE CONCAT('%', #{obj.stationCode}, '%')
|
||||
</if>
|
||||
<if test="obj.stm != null and obj.stm != '' ">
|
||||
AND D.TIMESTAMP >= #{obj.stm}
|
||||
</if>
|
||||
<if test="obj.etm != null and obj.etm != '' ">
|
||||
AND D.TIMESTAMP < #{obj.etm}
|
||||
</if>
|
||||
|
||||
ORDER BY D.TIMESTAMP DESC
|
||||
</select>
|
||||
|
||||
<delete id="clearByDeviceId">
|
||||
delete from dam_safe.device_sl_data where device_id=#{deviceId} and channel_num=#{channelNum}
|
||||
</delete>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.whdc.zhdbaqapi.mapper.DeviceSLInfoMapper">
|
||||
|
||||
<select id="get" resultType="com.whdc.zhdbaqapi.model.entity.DeviceSLInfo">
|
||||
SELECT *
|
||||
FROM DEVICE_SL_INFO WHERE ID=#{id}
|
||||
</select>
|
||||
|
||||
<select id="list" resultType="com.whdc.zhdbaqapi.model.entity.DeviceSLInfo">
|
||||
SELECT ID, DEVICE_ID, STATION_CODE, CHANNEL_NUM FROM DEVICE_SL_INFO
|
||||
WHERE DEL = 0
|
||||
<if test="obj.deviceId != null and obj.deviceId != '' ">
|
||||
AND DEVICE_ID LIKE CONCAT('%', #{obj.deviceId}, '%')
|
||||
</if>
|
||||
<if test="obj.stationCode != null and obj.stationCode != '' ">
|
||||
AND STATION_CODE LIKE CONCAT('%', #{obj.stationCode}, '%')
|
||||
</if>
|
||||
|
||||
</select>
|
||||
|
||||
<select id="listAll" resultType="com.whdc.zhdbaqapi.model.entity.DeviceSLInfo">
|
||||
SELECT *
|
||||
FROM DEVICE_SL_INFO
|
||||
WHERE DEL = 0
|
||||
</select>
|
||||
|
||||
<select id="page" resultType="com.whdc.zhdbaqapi.model.entity.DeviceSLInfo">
|
||||
SELECT *
|
||||
FROM DEVICE_SL_INFO
|
||||
WHERE DEL = 0
|
||||
<if test="obj.deviceId != null and obj.deviceId != '' ">
|
||||
AND DEVICE_ID LIKE CONCAT('%', #{obj.deviceId}, '%')
|
||||
</if>
|
||||
<if test="obj.stationCode != null and obj.stationCode != '' ">
|
||||
AND STATION_CODE LIKE CONCAT('%', #{obj.stationCode}, '%')
|
||||
</if>
|
||||
|
||||
ORDER BY STATION_CODE ASC
|
||||
</select>
|
||||
|
||||
<select id="listBySC" resultType="com.whdc.zhdbaqapi.model.entity.DeviceSLInfo">
|
||||
SELECT ID, STATION_CODE FROM DEVICE_SL_INFO
|
||||
WHERE DEL = 0
|
||||
AND STATION_CODE IN
|
||||
<foreach collection="scs" item="sc" index="index" open="(" close=")" separator=",">
|
||||
#{sc}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="checkValidStationCode" resultType="com.whdc.zhdbaqapi.model.entity.DeviceSLInfo">
|
||||
SELECT * FROM DEVICE_SL_INFO
|
||||
WHERE DEL = 0
|
||||
AND STATION_CODE = #{stationCode}
|
||||
LIMIT 1
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue