|
@@ -7,11 +7,13 @@ import com.ruoyi.common.core.domain.BaseEntity;
|
|
|
import com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
import io.swagger.annotations.ApiModel;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
-import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
|
-import org.apache.commons.lang3.builder.ToStringStyle;
|
|
|
+import lombok.Data;
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 日统计数据对象 twin_calc_day
|
|
@@ -20,7 +22,36 @@ import java.util.Date;
|
|
|
* @date 2024-05-22
|
|
|
*/
|
|
|
@ApiModel(value = "ITwinCalcDay", description = "日统计数据")
|
|
|
+@Data
|
|
|
+@NoArgsConstructor
|
|
|
public class TwinCalcDay extends BaseEntity {
|
|
|
+ public TwinCalcDay(Date date) {
|
|
|
+ this.time = date;
|
|
|
+ this.length = BigDecimal.ZERO;
|
|
|
+ this.weight = BigDecimal.ZERO;
|
|
|
+ this.kwh = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ this.lengthA = BigDecimal.ZERO;
|
|
|
+ this.weightA = BigDecimal.ZERO;
|
|
|
+ this.kwhA = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ this.lengthB = BigDecimal.ZERO;
|
|
|
+ this.weightB = BigDecimal.ZERO;
|
|
|
+ this.kwhB = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ this.alarm = 0L;
|
|
|
+ this.openTimeA = BigDecimal.ZERO;
|
|
|
+ this.openTimeB = BigDecimal.ZERO;
|
|
|
+ this.closeTimeA = BigDecimal.ZERO;
|
|
|
+ this.closeTimeB = BigDecimal.ZERO;
|
|
|
+ this.stop1A = 0L;
|
|
|
+ this.stop1B = 0L;
|
|
|
+ this.stop2A = 0L;
|
|
|
+ this.stop2B = 0L;
|
|
|
+ this.stop3A = 0L;
|
|
|
+ this.stop3B = 0L;
|
|
|
+ }
|
|
|
+
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
/**
|
|
@@ -35,7 +66,12 @@ public class TwinCalcDay extends BaseEntity {
|
|
|
@Excel(name = "时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
|
@ApiModelProperty("时间")
|
|
|
private Date time;
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 设备ID
|
|
|
+ */
|
|
|
+ @Excel(name = "设备ID")
|
|
|
+ @ApiModelProperty("设备ID")
|
|
|
+ private Long deviceId;
|
|
|
/**
|
|
|
* 总米长
|
|
|
*/
|
|
@@ -244,271 +280,66 @@ public class TwinCalcDay extends BaseEntity {
|
|
|
this.efficiency = Tools.calcPercent(totalOpenTime, totalCloseTime);
|
|
|
}
|
|
|
|
|
|
- public void setId(Long id) {
|
|
|
- this.id = id;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getId() {
|
|
|
- return id;
|
|
|
- }
|
|
|
-
|
|
|
- public void setTime(Date time) {
|
|
|
- this.time = time;
|
|
|
- }
|
|
|
-
|
|
|
- public Date getTime() {
|
|
|
- return time;
|
|
|
- }
|
|
|
-
|
|
|
- public void setLength(BigDecimal length) {
|
|
|
- this.length = length;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getLength() {
|
|
|
- return length;
|
|
|
- }
|
|
|
-
|
|
|
- public void setWeight(BigDecimal weight) {
|
|
|
- this.weight = weight;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getWeight() {
|
|
|
- return weight;
|
|
|
- }
|
|
|
-
|
|
|
- public void setEfficiency(BigDecimal efficiency) {
|
|
|
- this.efficiency = efficiency;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getEfficiency() {
|
|
|
- return efficiency;
|
|
|
- }
|
|
|
-
|
|
|
- public void setKwh(BigDecimal kwh) {
|
|
|
- this.kwh = kwh;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getKwh() {
|
|
|
- return kwh;
|
|
|
- }
|
|
|
-
|
|
|
- public void setAlarm(Long alarm) {
|
|
|
- this.alarm = alarm;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getAlarm() {
|
|
|
- return alarm;
|
|
|
- }
|
|
|
-
|
|
|
- public void setLengthA(BigDecimal lengthA) {
|
|
|
- this.lengthA = lengthA;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getLengthA() {
|
|
|
- return lengthA;
|
|
|
- }
|
|
|
-
|
|
|
- public void setWeightA(BigDecimal weightA) {
|
|
|
- this.weightA = weightA;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getWeightA() {
|
|
|
- return weightA;
|
|
|
- }
|
|
|
-
|
|
|
- public void setEfficiencyA(BigDecimal efficiencyA) {
|
|
|
- this.efficiencyA = efficiencyA;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getEfficiencyA() {
|
|
|
- return efficiencyA;
|
|
|
- }
|
|
|
-
|
|
|
- public void setOpenTimeA(BigDecimal openTimeA) {
|
|
|
- this.openTimeA = openTimeA;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getOpenTimeA() {
|
|
|
- return openTimeA;
|
|
|
- }
|
|
|
-
|
|
|
- public void setCloseTimeA(BigDecimal closeTimeA) {
|
|
|
- this.closeTimeA = closeTimeA;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getCloseTimeA() {
|
|
|
- return closeTimeA;
|
|
|
- }
|
|
|
-
|
|
|
- public void setKwhA(BigDecimal kwhA) {
|
|
|
- this.kwhA = kwhA;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getKwhA() {
|
|
|
- return kwhA;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStop1A(Long stop1A) {
|
|
|
- this.stop1A = stop1A;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getStop1A() {
|
|
|
- return stop1A;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStop2A(Long stop2A) {
|
|
|
- this.stop2A = stop2A;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getStop2A() {
|
|
|
- return stop2A;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStop3A(Long stop3A) {
|
|
|
- this.stop3A = stop3A;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getStop3A() {
|
|
|
- return stop3A;
|
|
|
- }
|
|
|
-
|
|
|
- public void setLengthB(BigDecimal lengthB) {
|
|
|
- this.lengthB = lengthB;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getLengthB() {
|
|
|
- return lengthB;
|
|
|
- }
|
|
|
-
|
|
|
- public void setWeightB(BigDecimal weightB) {
|
|
|
- this.weightB = weightB;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getWeightB() {
|
|
|
- return weightB;
|
|
|
- }
|
|
|
-
|
|
|
- public void setEfficiencyB(BigDecimal efficiencyB) {
|
|
|
- this.efficiencyB = efficiencyB;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getEfficiencyB() {
|
|
|
- return efficiencyB;
|
|
|
- }
|
|
|
-
|
|
|
- public void setOpenTimeB(BigDecimal openTimeB) {
|
|
|
- this.openTimeB = openTimeB;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getOpenTimeB() {
|
|
|
- return openTimeB;
|
|
|
- }
|
|
|
-
|
|
|
- public void setCloseTimeB(BigDecimal closeTimeB) {
|
|
|
- this.closeTimeB = closeTimeB;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getCloseTimeB() {
|
|
|
- return closeTimeB;
|
|
|
- }
|
|
|
-
|
|
|
- public void setKwhB(BigDecimal kwhB) {
|
|
|
- this.kwhB = kwhB;
|
|
|
- }
|
|
|
-
|
|
|
- public BigDecimal getKwhB() {
|
|
|
- return kwhB;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStop1B(Long stop1B) {
|
|
|
- this.stop1B = stop1B;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getStop1B() {
|
|
|
- return stop1B;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStop2B(Long stop2B) {
|
|
|
- this.stop2B = stop2B;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getStop2B() {
|
|
|
- return stop2B;
|
|
|
- }
|
|
|
-
|
|
|
- public void setStop3B(Long stop3B) {
|
|
|
- this.stop3B = stop3B;
|
|
|
- }
|
|
|
-
|
|
|
- public Long getStop3B() {
|
|
|
- return stop3B;
|
|
|
- }
|
|
|
-
|
|
|
- public void setCreatedBy(String createdBy) {
|
|
|
- this.createdBy = createdBy;
|
|
|
- }
|
|
|
-
|
|
|
- public String getCreatedBy() {
|
|
|
- return createdBy;
|
|
|
- }
|
|
|
-
|
|
|
- public void setCreatedTime(Date createdTime) {
|
|
|
- this.createdTime = createdTime;
|
|
|
- }
|
|
|
-
|
|
|
- public Date getCreatedTime() {
|
|
|
- return createdTime;
|
|
|
- }
|
|
|
-
|
|
|
- public void setUpdatedBy(String updatedBy) {
|
|
|
- this.updatedBy = updatedBy;
|
|
|
- }
|
|
|
-
|
|
|
- public String getUpdatedBy() {
|
|
|
- return updatedBy;
|
|
|
- }
|
|
|
-
|
|
|
- public void setUpdatedTime(Date updatedTime) {
|
|
|
- this.updatedTime = updatedTime;
|
|
|
- }
|
|
|
-
|
|
|
- public Date getUpdatedTime() {
|
|
|
- return updatedTime;
|
|
|
+ /**
|
|
|
+ * 计算产量数据
|
|
|
+ *
|
|
|
+ * @param hours 1小时统计数据
|
|
|
+ */
|
|
|
+ public void calcHours(List<TwinCalcHour> hours) {
|
|
|
+ hours.forEach(hour -> {
|
|
|
+ this.length = length.add(hour.getLength());
|
|
|
+ this.weight = weight.add(hour.getWeight());
|
|
|
+ this.kwh = kwh.add(hour.getKwh());
|
|
|
+
|
|
|
+ if (hour.getHour() >= 7 && hour.getHour() < 19) {
|
|
|
+ //A班
|
|
|
+ this.lengthA = lengthA.add(hour.getLength());
|
|
|
+ this.weightA = weightA.add(hour.getWeight());
|
|
|
+ this.kwhA = kwhA.add(hour.getKwh());
|
|
|
+ } else {
|
|
|
+ //B班
|
|
|
+ this.lengthB = lengthB.add(hour.getLength());
|
|
|
+ this.weightB = weightB.add(hour.getWeight());
|
|
|
+ this.kwhB = kwhB.add(hour.getKwh());
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public String toString() {
|
|
|
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
|
|
- .append("id", getId())
|
|
|
- .append("time", getTime())
|
|
|
- .append("length", getLength())
|
|
|
- .append("weight", getWeight())
|
|
|
- .append("efficiency", getEfficiency())
|
|
|
- .append("kwh", getKwh())
|
|
|
- .append("alarm", getAlarm())
|
|
|
- .append("lengthA", getLengthA())
|
|
|
- .append("weightA", getWeightA())
|
|
|
- .append("efficiencyA", getEfficiencyA())
|
|
|
- .append("openTimeA", getOpenTimeA())
|
|
|
- .append("closeTimeA", getCloseTimeA())
|
|
|
- .append("kwhA", getKwhA())
|
|
|
- .append("stop1A", getStop1A())
|
|
|
- .append("stop2A", getStop2A())
|
|
|
- .append("stop3A", getStop3A())
|
|
|
- .append("lengthB", getLengthB())
|
|
|
- .append("weightB", getWeightB())
|
|
|
- .append("efficiencyB", getEfficiencyB())
|
|
|
- .append("openTimeB", getOpenTimeB())
|
|
|
- .append("closeTimeB", getCloseTimeB())
|
|
|
- .append("kwhB", getKwhB())
|
|
|
- .append("stop1B", getStop1B())
|
|
|
- .append("stop2B", getStop2B())
|
|
|
- .append("stop3B", getStop3B())
|
|
|
- .append("createdBy", getCreatedBy())
|
|
|
- .append("createdTime", getCreatedTime())
|
|
|
- .append("updatedBy", getUpdatedBy())
|
|
|
- .append("updatedTime", getUpdatedTime())
|
|
|
- .append("remark", getRemark())
|
|
|
- .toString();
|
|
|
+ /**
|
|
|
+ * 计算天统计数据
|
|
|
+ *
|
|
|
+ * @param days 天数据
|
|
|
+ */
|
|
|
+ public void calcDays(List<TwinCalcDay> days) {
|
|
|
+ days.forEach(day -> {
|
|
|
+ this.weight = weight.add(day.getWeight());
|
|
|
+ this.weightA = weightA.add(day.getWeightA());
|
|
|
+ this.weightB = weightA.add(day.getWeightB());
|
|
|
+
|
|
|
+ this.kwh = kwh.add(day.getKwh());
|
|
|
+ this.kwhA = kwhA.add(day.getKwh());
|
|
|
+ this.kwhB = kwhB.add(day.getKwh());
|
|
|
+
|
|
|
+ this.stop1A += day.getStop1A();
|
|
|
+ this.stop1B += day.getStop1B();
|
|
|
+ this.stop2A += day.getStop2A();
|
|
|
+ this.stop2B += day.getStop2B();
|
|
|
+ this.stop3A += day.getStop3A();
|
|
|
+ this.stop3B += day.getStop3B();
|
|
|
+
|
|
|
+ this.alarm += day.getAlarm();
|
|
|
+
|
|
|
+ this.closeTimeA = closeTimeA.add(day.getCloseTimeA());
|
|
|
+ this.closeTimeB = closeTimeB.add(day.getCloseTimeB());
|
|
|
+ this.openTimeA = openTimeA.add(day.getOpenTimeA());
|
|
|
+ this.openTimeB = openTimeB.add(day.getOpenTimeB());
|
|
|
+ });
|
|
|
+ BigDecimal teamTimeA = this.openTimeA.add(this.closeTimeA);
|
|
|
+ BigDecimal teamTimeB = this.openTimeB.add(this.closeTimeB);
|
|
|
+ BigDecimal totalTeamTime = teamTimeA.add(teamTimeB);
|
|
|
+ BigDecimal totalOpenTime = this.openTimeA.add(openTimeB);
|
|
|
+ this.efficiencyA = openTimeA.divide(teamTimeA, 2, RoundingMode.HALF_UP);
|
|
|
+ this.efficiencyB = openTimeB.divide(teamTimeB, 2, RoundingMode.HALF_UP);
|
|
|
+ this.efficiency = totalOpenTime.divide(totalTeamTime, 2, RoundingMode.HALF_UP);
|
|
|
}
|
|
|
}
|