新增设备点位数据转换公式字段
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
package com.xzzn.ems.domain;
|
||||
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
import com.xzzn.common.core.domain.BaseEntity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 点位匹配对象 ems_point_match
|
||||
@ -78,6 +81,20 @@ public class EmsPointMatch extends BaseEntity
|
||||
@Excel(name = "设备唯一标识符")
|
||||
private String deviceId;
|
||||
|
||||
/** 设备点位数据转换公式:二次函数(f(x) = Ax² + Kx + B) */
|
||||
/** 二次项系数 */
|
||||
@Excel(name = "二次项系数")
|
||||
private BigDecimal a;
|
||||
|
||||
/** 一次项系数 */
|
||||
@Excel(name = "一次项系数")
|
||||
private BigDecimal k;
|
||||
|
||||
/** 常量 */
|
||||
@Excel(name = "常量")
|
||||
private BigDecimal b;
|
||||
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
@ -232,6 +249,35 @@ public class EmsPointMatch extends BaseEntity
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public BigDecimal getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public void setA(BigDecimal a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public BigDecimal getK() {
|
||||
return k;
|
||||
}
|
||||
|
||||
public void setK(BigDecimal k) {
|
||||
this.k = k;
|
||||
}
|
||||
|
||||
public BigDecimal getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(BigDecimal b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
/** 二次函数公式转换点位数据: A * value² + K * value + B */
|
||||
public int convert(BigDecimal value) {
|
||||
return a.multiply(value.pow(2)).add(k.multiply(value)).add(b).intValueExact();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
@ -256,6 +302,9 @@ public class EmsPointMatch extends BaseEntity
|
||||
.append("remark", getRemark())
|
||||
.append("isAlarm", getIsAlarm())
|
||||
.append("deviceId", getDeviceId())
|
||||
.append("a", getA())
|
||||
.append("k", getK())
|
||||
.append("b", getB())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xzzn.ems.domain.vo;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 点位清单导出参数
|
||||
@ -46,6 +47,18 @@ public class DevicePointMatchExportVo implements Serializable {
|
||||
@Excel(name = "寄存器地址")
|
||||
private String ipAddress;
|
||||
|
||||
/** 二次项系数 */
|
||||
@Excel(name = "a")
|
||||
private BigDecimal a;
|
||||
|
||||
/** 一次项系数 */
|
||||
@Excel(name = "k")
|
||||
private BigDecimal k;
|
||||
|
||||
/** 常量 */
|
||||
@Excel(name = "b")
|
||||
private BigDecimal b;
|
||||
|
||||
public String getPointName() {
|
||||
return pointName;
|
||||
}
|
||||
@ -118,4 +131,27 @@ public class DevicePointMatchExportVo implements Serializable {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public BigDecimal getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public void setA(BigDecimal a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public BigDecimal getK() {
|
||||
return k;
|
||||
}
|
||||
|
||||
public void setK(BigDecimal k) {
|
||||
this.k = k;
|
||||
}
|
||||
|
||||
public BigDecimal getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(BigDecimal b) {
|
||||
this.b = b;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.xzzn.ems.domain.vo;
|
||||
import com.xzzn.common.annotation.Excel;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 点位清单上传参数
|
||||
@ -46,6 +47,18 @@ public class DevicePointMatchVo implements Serializable {
|
||||
@Excel(name = "寄存器地址")
|
||||
private String ipAddress;
|
||||
|
||||
/** 二次项系数 */
|
||||
@Excel(name = "a")
|
||||
private BigDecimal a;
|
||||
|
||||
/** 一次项系数 */
|
||||
@Excel(name = "k")
|
||||
private BigDecimal k;
|
||||
|
||||
/** 常量 */
|
||||
@Excel(name = "b")
|
||||
private BigDecimal b;
|
||||
|
||||
/** 错误信息 */
|
||||
@Excel(name = "错误信息")
|
||||
private String errorMsg;
|
||||
@ -122,6 +135,30 @@ public class DevicePointMatchVo implements Serializable {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public BigDecimal getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public void setA(BigDecimal a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public BigDecimal getK() {
|
||||
return k;
|
||||
}
|
||||
|
||||
public void setK(BigDecimal k) {
|
||||
this.k = k;
|
||||
}
|
||||
|
||||
public BigDecimal getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void setB(BigDecimal b) {
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public String getErrorMsg() {
|
||||
return errorMsg;
|
||||
}
|
||||
|
||||
@ -1174,7 +1174,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
|
||||
}
|
||||
redisCache.setCacheObject(redisKey, yestLastTotalRevenue, 1, TimeUnit.DAYS);
|
||||
} else {
|
||||
yestLastTotalRevenue = (BigDecimal) cacheObject;
|
||||
log.info("从redis获取昨日总收益cacheObject:{}", cacheObject);
|
||||
yestLastTotalRevenue = new BigDecimal(cacheObject.toString());
|
||||
}
|
||||
return yestLastTotalRevenue;
|
||||
}
|
||||
|
||||
@ -78,13 +78,12 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService {
|
||||
if (!CollectionUtils.isEmpty(pointEnumMatchList)) {
|
||||
String enumName = pointEnumMatchList.stream().map(EmsPointEnumMatch::getEnumName).filter(StringUtils::isNotBlank).collect(Collectors.joining(SEPARATOR));
|
||||
String dataEnumCode = pointEnumMatchList.stream().map(EmsPointEnumMatch::getDataEnumCode).filter(StringUtils::isNotBlank).collect(Collectors.joining(SEPARATOR));
|
||||
// List<String> dataEnumCode = pointEnumMatchList.stream().map(EmsPointEnumMatch::getDataEnumCode).collect(Collectors.toList());
|
||||
|
||||
// devicePointMatch.setMatchFieldEnum(StringUtils.join(enumName, SEPARATOR));
|
||||
// devicePointMatch.setDataEnum(StringUtils.join(dataEnumCode, SEPARATOR));
|
||||
devicePointMatch.setMatchFieldEnum(enumName);
|
||||
devicePointMatch.setDataEnum(dataEnumCode);
|
||||
}
|
||||
devicePointMatch.setA(devicePointMatch.getA() == null ? devicePointMatch.getA() : devicePointMatch.getA().stripTrailingZeros());
|
||||
devicePointMatch.setK(devicePointMatch.getK() == null ? devicePointMatch.getK() : devicePointMatch.getK().stripTrailingZeros());
|
||||
devicePointMatch.setB(devicePointMatch.getB() == null ? devicePointMatch.getB() : devicePointMatch.getB().stripTrailingZeros());
|
||||
}
|
||||
|
||||
return devicePointMatchExportVos;
|
||||
@ -154,7 +153,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<DevicePointMatchVo> importDataByDevice(ImportPointDataRequest request, String operName) {
|
||||
ExcelUtil<DevicePointMatchVo> util = new ExcelUtil<>(DevicePointMatchVo.class);
|
||||
List<DevicePointMatchVo> pointMatchList = new ArrayList<>();
|
||||
List<DevicePointMatchVo> pointMatchList;
|
||||
MultipartFile file = request.getFile();
|
||||
if (file.isEmpty()) {
|
||||
throw new ServiceException("点位清单文件不能为空");
|
||||
|
||||
Reference in New Issue
Block a user