新增设备点位数据转换公式字段
This commit is contained in:
@ -1,9 +1,12 @@
|
|||||||
package com.xzzn.ems.domain;
|
package com.xzzn.ems.domain;
|
||||||
|
|
||||||
|
import com.xzzn.common.annotation.Excel;
|
||||||
import com.xzzn.common.core.domain.BaseEntity;
|
import com.xzzn.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.xzzn.common.annotation.Excel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点位匹配对象 ems_point_match
|
* 点位匹配对象 ems_point_match
|
||||||
@ -78,6 +81,20 @@ public class EmsPointMatch extends BaseEntity
|
|||||||
@Excel(name = "设备唯一标识符")
|
@Excel(name = "设备唯一标识符")
|
||||||
private String deviceId;
|
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)
|
public void setId(Long id)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -232,6 +249,35 @@ public class EmsPointMatch extends BaseEntity
|
|||||||
this.deviceId = deviceId;
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
@ -256,6 +302,9 @@ public class EmsPointMatch extends BaseEntity
|
|||||||
.append("remark", getRemark())
|
.append("remark", getRemark())
|
||||||
.append("isAlarm", getIsAlarm())
|
.append("isAlarm", getIsAlarm())
|
||||||
.append("deviceId", getDeviceId())
|
.append("deviceId", getDeviceId())
|
||||||
|
.append("a", getA())
|
||||||
|
.append("k", getK())
|
||||||
|
.append("b", getB())
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package com.xzzn.ems.domain.vo;
|
|||||||
import com.xzzn.common.annotation.Excel;
|
import com.xzzn.common.annotation.Excel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点位清单导出参数
|
* 点位清单导出参数
|
||||||
@ -46,6 +47,18 @@ public class DevicePointMatchExportVo implements Serializable {
|
|||||||
@Excel(name = "寄存器地址")
|
@Excel(name = "寄存器地址")
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
|
/** 二次项系数 */
|
||||||
|
@Excel(name = "a")
|
||||||
|
private BigDecimal a;
|
||||||
|
|
||||||
|
/** 一次项系数 */
|
||||||
|
@Excel(name = "k")
|
||||||
|
private BigDecimal k;
|
||||||
|
|
||||||
|
/** 常量 */
|
||||||
|
@Excel(name = "b")
|
||||||
|
private BigDecimal b;
|
||||||
|
|
||||||
public String getPointName() {
|
public String getPointName() {
|
||||||
return pointName;
|
return pointName;
|
||||||
}
|
}
|
||||||
@ -118,4 +131,27 @@ public class DevicePointMatchExportVo implements Serializable {
|
|||||||
this.ipAddress = ipAddress;
|
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 com.xzzn.common.annotation.Excel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点位清单上传参数
|
* 点位清单上传参数
|
||||||
@ -46,6 +47,18 @@ public class DevicePointMatchVo implements Serializable {
|
|||||||
@Excel(name = "寄存器地址")
|
@Excel(name = "寄存器地址")
|
||||||
private String ipAddress;
|
private String ipAddress;
|
||||||
|
|
||||||
|
/** 二次项系数 */
|
||||||
|
@Excel(name = "a")
|
||||||
|
private BigDecimal a;
|
||||||
|
|
||||||
|
/** 一次项系数 */
|
||||||
|
@Excel(name = "k")
|
||||||
|
private BigDecimal k;
|
||||||
|
|
||||||
|
/** 常量 */
|
||||||
|
@Excel(name = "b")
|
||||||
|
private BigDecimal b;
|
||||||
|
|
||||||
/** 错误信息 */
|
/** 错误信息 */
|
||||||
@Excel(name = "错误信息")
|
@Excel(name = "错误信息")
|
||||||
private String errorMsg;
|
private String errorMsg;
|
||||||
@ -122,6 +135,30 @@ public class DevicePointMatchVo implements Serializable {
|
|||||||
this.ipAddress = ipAddress;
|
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() {
|
public String getErrorMsg() {
|
||||||
return errorMsg;
|
return errorMsg;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1174,7 +1174,8 @@ public class DeviceDataProcessServiceImpl extends AbstractBatteryDataProcessor i
|
|||||||
}
|
}
|
||||||
redisCache.setCacheObject(redisKey, yestLastTotalRevenue, 1, TimeUnit.DAYS);
|
redisCache.setCacheObject(redisKey, yestLastTotalRevenue, 1, TimeUnit.DAYS);
|
||||||
} else {
|
} else {
|
||||||
yestLastTotalRevenue = (BigDecimal) cacheObject;
|
log.info("从redis获取昨日总收益cacheObject:{}", cacheObject);
|
||||||
|
yestLastTotalRevenue = new BigDecimal(cacheObject.toString());
|
||||||
}
|
}
|
||||||
return yestLastTotalRevenue;
|
return yestLastTotalRevenue;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,13 +78,12 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService {
|
|||||||
if (!CollectionUtils.isEmpty(pointEnumMatchList)) {
|
if (!CollectionUtils.isEmpty(pointEnumMatchList)) {
|
||||||
String enumName = pointEnumMatchList.stream().map(EmsPointEnumMatch::getEnumName).filter(StringUtils::isNotBlank).collect(Collectors.joining(SEPARATOR));
|
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));
|
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.setMatchFieldEnum(enumName);
|
||||||
devicePointMatch.setDataEnum(dataEnumCode);
|
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;
|
return devicePointMatchExportVos;
|
||||||
@ -154,7 +153,7 @@ public class EmsPointMatchServiceImpl implements IEmsPointMatchService {
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public List<DevicePointMatchVo> importDataByDevice(ImportPointDataRequest request, String operName) {
|
public List<DevicePointMatchVo> importDataByDevice(ImportPointDataRequest request, String operName) {
|
||||||
ExcelUtil<DevicePointMatchVo> util = new ExcelUtil<>(DevicePointMatchVo.class);
|
ExcelUtil<DevicePointMatchVo> util = new ExcelUtil<>(DevicePointMatchVo.class);
|
||||||
List<DevicePointMatchVo> pointMatchList = new ArrayList<>();
|
List<DevicePointMatchVo> pointMatchList;
|
||||||
MultipartFile file = request.getFile();
|
MultipartFile file = request.getFile();
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
throw new ServiceException("点位清单文件不能为空");
|
throw new ServiceException("点位清单文件不能为空");
|
||||||
|
|||||||
@ -26,10 +26,13 @@
|
|||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="isAlarm" column="is_alarm" />
|
<result property="isAlarm" column="is_alarm" />
|
||||||
<result property="deviceId" column="device_id" />
|
<result property="deviceId" column="device_id" />
|
||||||
|
<result property="a" column="a" />
|
||||||
|
<result property="k" column="k" />
|
||||||
|
<result property="b" column="b" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectEmsPointMatchVo">
|
<sql id="selectEmsPointMatchVo">
|
||||||
select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, is_alarm, device_id from ems_point_match
|
select id, point_name, match_table, match_field, site_id, device_category, data_point, data_point_name, data_device, data_unit, ip_address, ip_port, data_type, need_diff_device_id, create_by, create_time, update_by, update_time, remark, is_alarm, device_id, a, k, b from ems_point_match
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectEmsPointMatchList" parameterType="EmsPointMatch" resultMap="EmsPointMatchResult">
|
<select id="selectEmsPointMatchList" parameterType="EmsPointMatch" resultMap="EmsPointMatchResult">
|
||||||
@ -79,6 +82,9 @@
|
|||||||
<if test="remark != null">remark,</if>
|
<if test="remark != null">remark,</if>
|
||||||
<if test="isAlarm != null">is_alarm,</if>
|
<if test="isAlarm != null">is_alarm,</if>
|
||||||
<if test="deviceId != null">device_id,</if>
|
<if test="deviceId != null">device_id,</if>
|
||||||
|
<if test="a != null">a,</if>
|
||||||
|
<if test="k != null">k,</if>
|
||||||
|
<if test="b != null">b,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="pointName != null">#{pointName},</if>
|
<if test="pointName != null">#{pointName},</if>
|
||||||
@ -101,6 +107,9 @@
|
|||||||
<if test="remark != null">#{remark},</if>
|
<if test="remark != null">#{remark},</if>
|
||||||
<if test="isAlarm != null">#{isAlarm},</if>
|
<if test="isAlarm != null">#{isAlarm},</if>
|
||||||
<if test="deviceId != null">#{deviceId},</if>
|
<if test="deviceId != null">#{deviceId},</if>
|
||||||
|
<if test="a != null">#{a},</if>
|
||||||
|
<if test="k != null">#{k},</if>
|
||||||
|
<if test="b != null">#{b},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
@ -127,6 +136,9 @@
|
|||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
<if test="isAlarm != null">is_alarm = #{isAlarm},</if>
|
<if test="isAlarm != null">is_alarm = #{isAlarm},</if>
|
||||||
<if test="deviceId != null">device_id = #{deviceId},</if>
|
<if test="deviceId != null">device_id = #{deviceId},</if>
|
||||||
|
<if test="a != null">a = #{a},</if>
|
||||||
|
<if test="k != null">k = #{k},</if>
|
||||||
|
<if test="b != null">b = #{b},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
@ -522,7 +534,8 @@
|
|||||||
data_point_name as dataPointName,
|
data_point_name as dataPointName,
|
||||||
data_unit as dataUnit,
|
data_unit as dataUnit,
|
||||||
is_alarm as isAlarm,
|
is_alarm as isAlarm,
|
||||||
ip_address as ipAddress
|
ip_address as ipAddress,
|
||||||
|
a, k, b
|
||||||
from
|
from
|
||||||
ems_point_match
|
ems_point_match
|
||||||
<where>
|
<where>
|
||||||
|
|||||||
Reference in New Issue
Block a user