Browse Source

20210303处理选矿数据(未测试)

recovery
zy_Java 4 years ago
parent
commit
14b12f1b2e
  1. 32
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/Message/BeneficiationMessageDto.java
  2. 31
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/Message/PendingMessage.java
  3. 2
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/WeightDto.java
  4. 11
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/Equipment.java
  5. 70
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/EquipmentExample.java
  6. 106
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/EquipmentType.java
  7. 681
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/EquipmentTypeExample.java
  8. 19
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/Record.java
  9. 90
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/RecordExample.java
  10. 12
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/ThresholdValue.java
  11. 48
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/ThresholdValueExample.java
  12. 39
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/MessageVo.java
  13. 14
      beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/ParameterVo.java
  14. 43
      beneficiation/src/main/java/com/ccsens/beneficiation/persist/dao/RecordDao.java
  15. 30
      beneficiation/src/main/java/com/ccsens/beneficiation/persist/mapper/EquipmentTypeMapper.java
  16. 14
      beneficiation/src/main/java/com/ccsens/beneficiation/rabbitMQ/RabbitController.java
  17. 12
      beneficiation/src/main/java/com/ccsens/beneficiation/service/IRecordService.java
  18. 204
      beneficiation/src/main/java/com/ccsens/beneficiation/service/ParameterService.java
  19. 191
      beneficiation/src/main/java/com/ccsens/beneficiation/service/RecordService.java
  20. 129
      beneficiation/src/main/resources/mapper_dao/RecordDao.xml
  21. 3
      beneficiation/src/main/resources/mapper_dao/WeightDao.xml
  22. 27
      beneficiation/src/main/resources/mapper_raw/EquipmentMapper.xml
  23. 258
      beneficiation/src/main/resources/mapper_raw/EquipmentTypeMapper.xml
  24. 41
      beneficiation/src/main/resources/mapper_raw/RecordMapper.xml
  25. 28
      beneficiation/src/main/resources/mapper_raw/ThresholdValueMapper.xml
  26. 41
      util/src/test/java/com/ccsens/util/OtherTest.java

32
beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/Message/BeneficiationMessageDto.java

@ -12,7 +12,7 @@ public class BeneficiationMessageDto {
*/ */
private String authId; private String authId;
/** /**
* 类型 0变频器 1皮带秤 2电磁阀 3流量计 4电耳 5每日称重信息 6界限值 7触碰界限值后更改记录 *
*/ */
private Byte type; private Byte type;
/** /**
@ -22,7 +22,7 @@ public class BeneficiationMessageDto {
/** /**
* 类型对应的值 * 类型对应的值
*/ */
private String value; private int value;
/** /**
* 版本号 * 版本号
*/ */
@ -32,32 +32,4 @@ public class BeneficiationMessageDto {
*/ */
private Long time = System.currentTimeMillis(); private Long time = System.currentTimeMillis();
public Byte getType(){
if(this.type != null){
return type;
}
switch (addr){
case 21:
return 0;
case 22:
return 1;
case 23:
return 2;
case 24:
return 3;
case 25:
return 4;
case 26:
return 5;
case 27:
case 28:
case 29:
return 6;
case 30: //触碰到的界限的信息()
return 7;
default:
return type;
}
}
} }

31
beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/Message/PendingMessage.java

@ -0,0 +1,31 @@
package com.ccsens.beneficiation.bean.dto.Message;
import lombok.Data;
/**
* @author
*/
@Data
public class PendingMessage {
/**
* 设备编号
*/
private String authId;
/**
* 寄存器地址
*/
private int addr;
/**
* 类型对应的值
*/
private String value;
/**
* 版本号
*/
private String version;
/**
* 时间
*/
private Long time = System.currentTimeMillis();
}

2
beneficiation/src/main/java/com/ccsens/beneficiation/bean/dto/WeightDto.java

@ -1,5 +1,6 @@
package com.ccsens.beneficiation.bean.dto; package com.ccsens.beneficiation.bean.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -46,6 +47,7 @@ public class WeightDto {
@ApiModel("查询重量累计") @ApiModel("查询重量累计")
public static class GetWeightTotal { public static class GetWeightTotal {
@ApiModelProperty("日期 为空则默认当前") @ApiModelProperty("日期 为空则默认当前")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date datetime; private Date datetime;
} }

11
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/Equipment.java

@ -10,8 +10,6 @@ public class Equipment implements Serializable {
private String authId; private String authId;
private String addr;
private String verion; private String verion;
private Long operator; private Long operator;
@ -48,14 +46,6 @@ public class Equipment implements Serializable {
this.authId = authId == null ? null : authId.trim(); this.authId = authId == null ? null : authId.trim();
} }
public String getAddr() {
return addr;
}
public void setAddr(String addr) {
this.addr = addr == null ? null : addr.trim();
}
public String getVerion() { public String getVerion() {
return verion; return verion;
} }
@ -105,7 +95,6 @@ public class Equipment implements Serializable {
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", type=").append(type); sb.append(", type=").append(type);
sb.append(", authId=").append(authId); sb.append(", authId=").append(authId);
sb.append(", addr=").append(addr);
sb.append(", verion=").append(verion); sb.append(", verion=").append(verion);
sb.append(", operator=").append(operator); sb.append(", operator=").append(operator);
sb.append(", createdAt=").append(createdAt); sb.append(", createdAt=").append(createdAt);

70
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/EquipmentExample.java

@ -295,76 +295,6 @@ public class EquipmentExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andAddrIsNull() {
addCriterion("addr is null");
return (Criteria) this;
}
public Criteria andAddrIsNotNull() {
addCriterion("addr is not null");
return (Criteria) this;
}
public Criteria andAddrEqualTo(String value) {
addCriterion("addr =", value, "addr");
return (Criteria) this;
}
public Criteria andAddrNotEqualTo(String value) {
addCriterion("addr <>", value, "addr");
return (Criteria) this;
}
public Criteria andAddrGreaterThan(String value) {
addCriterion("addr >", value, "addr");
return (Criteria) this;
}
public Criteria andAddrGreaterThanOrEqualTo(String value) {
addCriterion("addr >=", value, "addr");
return (Criteria) this;
}
public Criteria andAddrLessThan(String value) {
addCriterion("addr <", value, "addr");
return (Criteria) this;
}
public Criteria andAddrLessThanOrEqualTo(String value) {
addCriterion("addr <=", value, "addr");
return (Criteria) this;
}
public Criteria andAddrLike(String value) {
addCriterion("addr like", value, "addr");
return (Criteria) this;
}
public Criteria andAddrNotLike(String value) {
addCriterion("addr not like", value, "addr");
return (Criteria) this;
}
public Criteria andAddrIn(List<String> values) {
addCriterion("addr in", values, "addr");
return (Criteria) this;
}
public Criteria andAddrNotIn(List<String> values) {
addCriterion("addr not in", values, "addr");
return (Criteria) this;
}
public Criteria andAddrBetween(String value1, String value2) {
addCriterion("addr between", value1, value2, "addr");
return (Criteria) this;
}
public Criteria andAddrNotBetween(String value1, String value2) {
addCriterion("addr not between", value1, value2, "addr");
return (Criteria) this;
}
public Criteria andVerionIsNull() { public Criteria andVerionIsNull() {
addCriterion("verion is null"); addCriterion("verion is null");
return (Criteria) this; return (Criteria) this;

106
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/EquipmentType.java

@ -0,0 +1,106 @@
package com.ccsens.beneficiation.bean.po;
import java.io.Serializable;
import java.util.Date;
public class EquipmentType implements Serializable {
private Long id;
private Long equipmentId;
private Byte type;
private Integer addr;
private Long operator;
private Date createdAt;
private Date updatedAt;
private Byte recStatus;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getEquipmentId() {
return equipmentId;
}
public void setEquipmentId(Long equipmentId) {
this.equipmentId = equipmentId;
}
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
public Integer getAddr() {
return addr;
}
public void setAddr(Integer addr) {
this.addr = addr;
}
public Long getOperator() {
return operator;
}
public void setOperator(Long operator) {
this.operator = operator;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public Date getUpdatedAt() {
return updatedAt;
}
public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}
public Byte getRecStatus() {
return recStatus;
}
public void setRecStatus(Byte recStatus) {
this.recStatus = recStatus;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", equipmentId=").append(equipmentId);
sb.append(", type=").append(type);
sb.append(", addr=").append(addr);
sb.append(", operator=").append(operator);
sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus);
sb.append("]");
return sb.toString();
}
}

681
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/EquipmentTypeExample.java

@ -0,0 +1,681 @@
package com.ccsens.beneficiation.bean.po;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class EquipmentTypeExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public EquipmentTypeExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Long value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Long value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Long value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Long value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Long value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Long value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Long> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Long> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Long value1, Long value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Long value1, Long value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andEquipmentIdIsNull() {
addCriterion("equipment_id is null");
return (Criteria) this;
}
public Criteria andEquipmentIdIsNotNull() {
addCriterion("equipment_id is not null");
return (Criteria) this;
}
public Criteria andEquipmentIdEqualTo(Long value) {
addCriterion("equipment_id =", value, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdNotEqualTo(Long value) {
addCriterion("equipment_id <>", value, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdGreaterThan(Long value) {
addCriterion("equipment_id >", value, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdGreaterThanOrEqualTo(Long value) {
addCriterion("equipment_id >=", value, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdLessThan(Long value) {
addCriterion("equipment_id <", value, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdLessThanOrEqualTo(Long value) {
addCriterion("equipment_id <=", value, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdIn(List<Long> values) {
addCriterion("equipment_id in", values, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdNotIn(List<Long> values) {
addCriterion("equipment_id not in", values, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdBetween(Long value1, Long value2) {
addCriterion("equipment_id between", value1, value2, "equipmentId");
return (Criteria) this;
}
public Criteria andEquipmentIdNotBetween(Long value1, Long value2) {
addCriterion("equipment_id not between", value1, value2, "equipmentId");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Byte value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Byte value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Byte value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Byte value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Byte value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Byte value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Byte> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Byte> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Byte value1, Byte value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Byte value1, Byte value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andAddrIsNull() {
addCriterion("addr is null");
return (Criteria) this;
}
public Criteria andAddrIsNotNull() {
addCriterion("addr is not null");
return (Criteria) this;
}
public Criteria andAddrEqualTo(Integer value) {
addCriterion("addr =", value, "addr");
return (Criteria) this;
}
public Criteria andAddrNotEqualTo(Integer value) {
addCriterion("addr <>", value, "addr");
return (Criteria) this;
}
public Criteria andAddrGreaterThan(Integer value) {
addCriterion("addr >", value, "addr");
return (Criteria) this;
}
public Criteria andAddrGreaterThanOrEqualTo(Integer value) {
addCriterion("addr >=", value, "addr");
return (Criteria) this;
}
public Criteria andAddrLessThan(Integer value) {
addCriterion("addr <", value, "addr");
return (Criteria) this;
}
public Criteria andAddrLessThanOrEqualTo(Integer value) {
addCriterion("addr <=", value, "addr");
return (Criteria) this;
}
public Criteria andAddrIn(List<Integer> values) {
addCriterion("addr in", values, "addr");
return (Criteria) this;
}
public Criteria andAddrNotIn(List<Integer> values) {
addCriterion("addr not in", values, "addr");
return (Criteria) this;
}
public Criteria andAddrBetween(Integer value1, Integer value2) {
addCriterion("addr between", value1, value2, "addr");
return (Criteria) this;
}
public Criteria andAddrNotBetween(Integer value1, Integer value2) {
addCriterion("addr not between", value1, value2, "addr");
return (Criteria) this;
}
public Criteria andOperatorIsNull() {
addCriterion("operator is null");
return (Criteria) this;
}
public Criteria andOperatorIsNotNull() {
addCriterion("operator is not null");
return (Criteria) this;
}
public Criteria andOperatorEqualTo(Long value) {
addCriterion("operator =", value, "operator");
return (Criteria) this;
}
public Criteria andOperatorNotEqualTo(Long value) {
addCriterion("operator <>", value, "operator");
return (Criteria) this;
}
public Criteria andOperatorGreaterThan(Long value) {
addCriterion("operator >", value, "operator");
return (Criteria) this;
}
public Criteria andOperatorGreaterThanOrEqualTo(Long value) {
addCriterion("operator >=", value, "operator");
return (Criteria) this;
}
public Criteria andOperatorLessThan(Long value) {
addCriterion("operator <", value, "operator");
return (Criteria) this;
}
public Criteria andOperatorLessThanOrEqualTo(Long value) {
addCriterion("operator <=", value, "operator");
return (Criteria) this;
}
public Criteria andOperatorIn(List<Long> values) {
addCriterion("operator in", values, "operator");
return (Criteria) this;
}
public Criteria andOperatorNotIn(List<Long> values) {
addCriterion("operator not in", values, "operator");
return (Criteria) this;
}
public Criteria andOperatorBetween(Long value1, Long value2) {
addCriterion("operator between", value1, value2, "operator");
return (Criteria) this;
}
public Criteria andOperatorNotBetween(Long value1, Long value2) {
addCriterion("operator not between", value1, value2, "operator");
return (Criteria) this;
}
public Criteria andCreatedAtIsNull() {
addCriterion("created_at is null");
return (Criteria) this;
}
public Criteria andCreatedAtIsNotNull() {
addCriterion("created_at is not null");
return (Criteria) this;
}
public Criteria andCreatedAtEqualTo(Date value) {
addCriterion("created_at =", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotEqualTo(Date value) {
addCriterion("created_at <>", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtGreaterThan(Date value) {
addCriterion("created_at >", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtGreaterThanOrEqualTo(Date value) {
addCriterion("created_at >=", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtLessThan(Date value) {
addCriterion("created_at <", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtLessThanOrEqualTo(Date value) {
addCriterion("created_at <=", value, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtIn(List<Date> values) {
addCriterion("created_at in", values, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotIn(List<Date> values) {
addCriterion("created_at not in", values, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtBetween(Date value1, Date value2) {
addCriterion("created_at between", value1, value2, "createdAt");
return (Criteria) this;
}
public Criteria andCreatedAtNotBetween(Date value1, Date value2) {
addCriterion("created_at not between", value1, value2, "createdAt");
return (Criteria) this;
}
public Criteria andUpdatedAtIsNull() {
addCriterion("updated_at is null");
return (Criteria) this;
}
public Criteria andUpdatedAtIsNotNull() {
addCriterion("updated_at is not null");
return (Criteria) this;
}
public Criteria andUpdatedAtEqualTo(Date value) {
addCriterion("updated_at =", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotEqualTo(Date value) {
addCriterion("updated_at <>", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtGreaterThan(Date value) {
addCriterion("updated_at >", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtGreaterThanOrEqualTo(Date value) {
addCriterion("updated_at >=", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtLessThan(Date value) {
addCriterion("updated_at <", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtLessThanOrEqualTo(Date value) {
addCriterion("updated_at <=", value, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtIn(List<Date> values) {
addCriterion("updated_at in", values, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotIn(List<Date> values) {
addCriterion("updated_at not in", values, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtBetween(Date value1, Date value2) {
addCriterion("updated_at between", value1, value2, "updatedAt");
return (Criteria) this;
}
public Criteria andUpdatedAtNotBetween(Date value1, Date value2) {
addCriterion("updated_at not between", value1, value2, "updatedAt");
return (Criteria) this;
}
public Criteria andRecStatusIsNull() {
addCriterion("rec_status is null");
return (Criteria) this;
}
public Criteria andRecStatusIsNotNull() {
addCriterion("rec_status is not null");
return (Criteria) this;
}
public Criteria andRecStatusEqualTo(Byte value) {
addCriterion("rec_status =", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotEqualTo(Byte value) {
addCriterion("rec_status <>", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusGreaterThan(Byte value) {
addCriterion("rec_status >", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusGreaterThanOrEqualTo(Byte value) {
addCriterion("rec_status >=", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusLessThan(Byte value) {
addCriterion("rec_status <", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusLessThanOrEqualTo(Byte value) {
addCriterion("rec_status <=", value, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusIn(List<Byte> values) {
addCriterion("rec_status in", values, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotIn(List<Byte> values) {
addCriterion("rec_status not in", values, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusBetween(Byte value1, Byte value2) {
addCriterion("rec_status between", value1, value2, "recStatus");
return (Criteria) this;
}
public Criteria andRecStatusNotBetween(Byte value1, Byte value2) {
addCriterion("rec_status not between", value1, value2, "recStatus");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
}

19
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/Record.java

@ -8,7 +8,7 @@ public class Record implements Serializable {
private Long equipmentId; private Long equipmentId;
private String value; private Integer value;
private Date time; private Date time;
@ -20,6 +20,8 @@ public class Record implements Serializable {
private Byte recStatus; private Byte recStatus;
private Byte type;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public Long getId() { public Long getId() {
@ -38,12 +40,12 @@ public class Record implements Serializable {
this.equipmentId = equipmentId; this.equipmentId = equipmentId;
} }
public String getValue() { public Integer getValue() {
return value; return value;
} }
public void setValue(String value) { public void setValue(Integer value) {
this.value = value == null ? null : value.trim(); this.value = value;
} }
public Date getTime() { public Date getTime() {
@ -86,6 +88,14 @@ public class Record implements Serializable {
this.recStatus = recStatus; this.recStatus = recStatus;
} }
public Byte getType() {
return type;
}
public void setType(Byte type) {
this.type = type;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -100,6 +110,7 @@ public class Record implements Serializable {
sb.append(", createdAt=").append(createdAt); sb.append(", createdAt=").append(createdAt);
sb.append(", updatedAt=").append(updatedAt); sb.append(", updatedAt=").append(updatedAt);
sb.append(", recStatus=").append(recStatus); sb.append(", recStatus=").append(recStatus);
sb.append(", type=").append(type);
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }

90
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/RecordExample.java

@ -235,62 +235,52 @@ public class RecordExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueEqualTo(String value) { public Criteria andValueEqualTo(Integer value) {
addCriterion("value =", value, "value"); addCriterion("value =", value, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueNotEqualTo(String value) { public Criteria andValueNotEqualTo(Integer value) {
addCriterion("value <>", value, "value"); addCriterion("value <>", value, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueGreaterThan(String value) { public Criteria andValueGreaterThan(Integer value) {
addCriterion("value >", value, "value"); addCriterion("value >", value, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueGreaterThanOrEqualTo(String value) { public Criteria andValueGreaterThanOrEqualTo(Integer value) {
addCriterion("value >=", value, "value"); addCriterion("value >=", value, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueLessThan(String value) { public Criteria andValueLessThan(Integer value) {
addCriterion("value <", value, "value"); addCriterion("value <", value, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueLessThanOrEqualTo(String value) { public Criteria andValueLessThanOrEqualTo(Integer value) {
addCriterion("value <=", value, "value"); addCriterion("value <=", value, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueLike(String value) { public Criteria andValueIn(List<Integer> values) {
addCriterion("value like", value, "value");
return (Criteria) this;
}
public Criteria andValueNotLike(String value) {
addCriterion("value not like", value, "value");
return (Criteria) this;
}
public Criteria andValueIn(List<String> values) {
addCriterion("value in", values, "value"); addCriterion("value in", values, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueNotIn(List<String> values) { public Criteria andValueNotIn(List<Integer> values) {
addCriterion("value not in", values, "value"); addCriterion("value not in", values, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueBetween(String value1, String value2) { public Criteria andValueBetween(Integer value1, Integer value2) {
addCriterion("value between", value1, value2, "value"); addCriterion("value between", value1, value2, "value");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andValueNotBetween(String value1, String value2) { public Criteria andValueNotBetween(Integer value1, Integer value2) {
addCriterion("value not between", value1, value2, "value"); addCriterion("value not between", value1, value2, "value");
return (Criteria) this; return (Criteria) this;
} }
@ -594,6 +584,66 @@ public class RecordExample {
addCriterion("rec_status not between", value1, value2, "recStatus"); addCriterion("rec_status not between", value1, value2, "recStatus");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() {
addCriterion("type is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("type is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(Byte value) {
addCriterion("type =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(Byte value) {
addCriterion("type <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(Byte value) {
addCriterion("type >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(Byte value) {
addCriterion("type >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(Byte value) {
addCriterion("type <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(Byte value) {
addCriterion("type <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<Byte> values) {
addCriterion("type in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<Byte> values) {
addCriterion("type not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(Byte value1, Byte value2) {
addCriterion("type between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(Byte value1, Byte value2) {
addCriterion("type not between", value1, value2, "type");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

12
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/ThresholdValue.java

@ -6,7 +6,7 @@ import java.util.Date;
public class ThresholdValue implements Serializable { public class ThresholdValue implements Serializable {
private Long id; private Long id;
private Byte type; private Long equipmentId;
private Byte stages; private Byte stages;
@ -32,12 +32,12 @@ public class ThresholdValue implements Serializable {
this.id = id; this.id = id;
} }
public Byte getType() { public Long getEquipmentId() {
return type; return equipmentId;
} }
public void setType(Byte type) { public void setEquipmentId(Long equipmentId) {
this.type = type; this.equipmentId = equipmentId;
} }
public Byte getStages() { public Byte getStages() {
@ -103,7 +103,7 @@ public class ThresholdValue implements Serializable {
sb.append(" ["); sb.append(" [");
sb.append("Hash = ").append(hashCode()); sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", type=").append(type); sb.append(", equipmentId=").append(equipmentId);
sb.append(", stages=").append(stages); sb.append(", stages=").append(stages);
sb.append(", max=").append(max); sb.append(", max=").append(max);
sb.append(", min=").append(min); sb.append(", min=").append(min);

48
beneficiation/src/main/java/com/ccsens/beneficiation/bean/po/ThresholdValueExample.java

@ -165,63 +165,63 @@ public class ThresholdValueExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNull() { public Criteria andEquipmentIdIsNull() {
addCriterion("type is null"); addCriterion("equipment_id is null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIsNotNull() { public Criteria andEquipmentIdIsNotNull() {
addCriterion("type is not null"); addCriterion("equipment_id is not null");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeEqualTo(Byte value) { public Criteria andEquipmentIdEqualTo(Long value) {
addCriterion("type =", value, "type"); addCriterion("equipment_id =", value, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeNotEqualTo(Byte value) { public Criteria andEquipmentIdNotEqualTo(Long value) {
addCriterion("type <>", value, "type"); addCriterion("equipment_id <>", value, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeGreaterThan(Byte value) { public Criteria andEquipmentIdGreaterThan(Long value) {
addCriterion("type >", value, "type"); addCriterion("equipment_id >", value, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeGreaterThanOrEqualTo(Byte value) { public Criteria andEquipmentIdGreaterThanOrEqualTo(Long value) {
addCriterion("type >=", value, "type"); addCriterion("equipment_id >=", value, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeLessThan(Byte value) { public Criteria andEquipmentIdLessThan(Long value) {
addCriterion("type <", value, "type"); addCriterion("equipment_id <", value, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeLessThanOrEqualTo(Byte value) { public Criteria andEquipmentIdLessThanOrEqualTo(Long value) {
addCriterion("type <=", value, "type"); addCriterion("equipment_id <=", value, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeIn(List<Byte> values) { public Criteria andEquipmentIdIn(List<Long> values) {
addCriterion("type in", values, "type"); addCriterion("equipment_id in", values, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeNotIn(List<Byte> values) { public Criteria andEquipmentIdNotIn(List<Long> values) {
addCriterion("type not in", values, "type"); addCriterion("equipment_id not in", values, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeBetween(Byte value1, Byte value2) { public Criteria andEquipmentIdBetween(Long value1, Long value2) {
addCriterion("type between", value1, value2, "type"); addCriterion("equipment_id between", value1, value2, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTypeNotBetween(Byte value1, Byte value2) { public Criteria andEquipmentIdNotBetween(Long value1, Long value2) {
addCriterion("type not between", value1, value2, "type"); addCriterion("equipment_id not between", value1, value2, "equipmentId");
return (Criteria) this; return (Criteria) this;
} }

39
beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/MessageVo.java

@ -0,0 +1,39 @@
package com.ccsens.beneficiation.bean.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author
*/
@Data
public class MessageVo {
@Data
public static class AddrDispose{
private Long id;
private Integer startAddr;
private Integer endAddr;
private Integer contentNum;
private String contentLength;
}
@Data
public static class AchieveMessage{
private Integer addr;
private Integer value;
}
@Data
public static class EquipmentType{
//设备id
private Long id;
//设备类型
private Byte equipmentType;
//消息类型
private Byte messageType;
}
}

14
beneficiation/src/main/java/com/ccsens/beneficiation/bean/vo/ParameterVo.java

@ -44,6 +44,9 @@ public class ParameterVo {
private String key; private String key;
@ApiModelProperty("实时值") @ApiModelProperty("实时值")
private BigDecimal currentTimeValue; private BigDecimal currentTimeValue;
@ApiModelProperty("设定值")
private BigDecimal setTimeValue;
public TransducerValue(Long id, String type, String key, BigDecimal currentTimeValue) { public TransducerValue(Long id, String type, String key, BigDecimal currentTimeValue) {
this.id = id; this.id = id;
@ -105,7 +108,7 @@ public class ParameterVo {
private Long id; private Long id;
@ApiModelProperty("修改时用的类型") @ApiModelProperty("修改时用的类型")
private String type; private String type;
@ApiModelProperty("实时") @ApiModelProperty("key")
private String key; private String key;
@ApiModelProperty("实时值") @ApiModelProperty("实时值")
private BigDecimal currentTimeValue; private BigDecimal currentTimeValue;
@ -133,17 +136,20 @@ public class ParameterVo {
@ApiModel("阀值") @ApiModel("阀值")
public static class ThresholdValue{ public static class ThresholdValue{
@ApiModelProperty("id") @ApiModelProperty("id")
private Long id = 1L; private Long id;
@ApiModelProperty("修改时用的类型") @ApiModelProperty("修改时用的类型")
private String type; private String type;
@ApiModelProperty("key") @ApiModelProperty("key")
private String key; private String key;
@ApiModelProperty("最小") @ApiModelProperty("最小")
private BigDecimal minValue; private BigDecimal minValue;
@ApiModelProperty("最") @ApiModelProperty("最")
private BigDecimal maxValue; private BigDecimal maxValue;
public ThresholdValue(BigDecimal minValue, BigDecimal maxValue) { public ThresholdValue(Long id, String type, String key, BigDecimal minValue, BigDecimal maxValue) {
this.id = id;
this.type = type;
this.key = key;
this.minValue = minValue; this.minValue = minValue;
this.maxValue = maxValue; this.maxValue = maxValue;
} }

43
beneficiation/src/main/java/com/ccsens/beneficiation/persist/dao/RecordDao.java

@ -1,12 +1,55 @@
package com.ccsens.beneficiation.persist.dao; package com.ccsens.beneficiation.persist.dao;
import com.ccsens.beneficiation.bean.po.Record; import com.ccsens.beneficiation.bean.po.Record;
import com.ccsens.beneficiation.bean.vo.MessageVo;
import com.ccsens.beneficiation.bean.vo.ParameterVo;
import com.ccsens.beneficiation.persist.mapper.RecordMapper; import com.ccsens.beneficiation.persist.mapper.RecordMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public interface RecordDao extends RecordMapper { public interface RecordDao extends RecordMapper {
Record getByTypeAndAuthId(@Param("type") byte type,@Param("authId")String authId); Record getByTypeAndAuthId(@Param("type") byte type,@Param("authId")String authId);
/**
* 查找tall内的设备信息处理的配置信息
* @param startAddr 开始的addr
* @return 返回配置信息
*/
MessageVo.AddrDispose getByStartAddr(@Param("startAddr")int startAddr,@Param("project")byte project);
/**
* 根据addr查找设备和信息类型
* @param addr 寄存器地址
* @return 返回设备类型和消息类型
*/
MessageVo.EquipmentType getEquipmentTypeByAddr(@Param("addr")int addr);
/**
* 查询皮带秤和流量计的数据
* @return
*/
List<ParameterVo.BeltWeigher> queryBeltWeigher();
/**
* 查询变频器和电磁阀的数据
* @return
*/
List<ParameterVo.Transducer> queryTransducer();
/**
* 查询电耳的数据
* @return
*/
List<ParameterVo.Parameter> queryParameter();
/**
*
* @param equipmentId
* @param stages
* @return
*/
ParameterVo.ThresholdValue getThresholdValue(@Param("equipmentId")Long equipmentId, @Param("stages")int stages);
} }

30
beneficiation/src/main/java/com/ccsens/beneficiation/persist/mapper/EquipmentTypeMapper.java

@ -0,0 +1,30 @@
package com.ccsens.beneficiation.persist.mapper;
import com.ccsens.beneficiation.bean.po.EquipmentType;
import com.ccsens.beneficiation.bean.po.EquipmentTypeExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface EquipmentTypeMapper {
long countByExample(EquipmentTypeExample example);
int deleteByExample(EquipmentTypeExample example);
int deleteByPrimaryKey(Long id);
int insert(EquipmentType record);
int insertSelective(EquipmentType record);
List<EquipmentType> selectByExample(EquipmentTypeExample example);
EquipmentType selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") EquipmentType record, @Param("example") EquipmentTypeExample example);
int updateByExample(@Param("record") EquipmentType record, @Param("example") EquipmentTypeExample example);
int updateByPrimaryKeySelective(EquipmentType record);
int updateByPrimaryKey(EquipmentType record);
}

14
beneficiation/src/main/java/com/ccsens/beneficiation/rabbitMQ/RabbitController.java

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ccsens.beneficiation.bean.dto.Message.BeneficiationMessageDto; import com.ccsens.beneficiation.bean.dto.Message.BeneficiationMessageDto;
import com.ccsens.beneficiation.bean.vo.MessageVo;
import com.ccsens.beneficiation.service.IRecordService; import com.ccsens.beneficiation.service.IRecordService;
import com.ccsens.util.RedisUtil; import com.ccsens.util.RedisUtil;
import com.ccsens.util.bean.message.common.OutMessage; import com.ccsens.util.bean.message.common.OutMessage;
@ -26,9 +27,6 @@ import java.util.*;
@Component @Component
@RabbitListener(queues = RabbitMQConfig.BENEFICIATION) @RabbitListener(queues = RabbitMQConfig.BENEFICIATION)
public class RabbitController { public class RabbitController {
@Resource
private RedisUtil redisUtil;
@Resource @Resource
private IRecordService recordService; private IRecordService recordService;
@ -46,10 +44,18 @@ public class RabbitController {
if (CollectionUtil.isEmpty(messageSet)) { if (CollectionUtil.isEmpty(messageSet)) {
return; return;
} }
List<BeneficiationMessageDto> pendingMessage = new ArrayList<>();
messageSet.forEach(outMessage -> { messageSet.forEach(outMessage -> {
BeneficiationMessageDto carRecordMessageDto = JSONObject.parseObject(outMessage.getData(), BeneficiationMessageDto.class); BeneficiationMessageDto carRecordMessageDto = JSONObject.parseObject(outMessage.getData(), BeneficiationMessageDto.class);
recordService.processMessage(carRecordMessageDto); pendingMessage.add(carRecordMessageDto);
}); });
pendingMessage.sort(Comparator.comparingInt(BeneficiationMessageDto::getAddr));
log.info("接收到的list:{}",pendingMessage);
//处理下位机的信息
List<MessageVo.AchieveMessage> achieveMessages = recordService.processMessage(pendingMessage);
log.info("处理后的消息:{}",achieveMessages);
//根据业务处理保存消息
recordService.saveRecord(achieveMessages);
} catch (Exception e) { } catch (Exception e) {
log.error("消息JSON转换异常", e); log.error("消息JSON转换异常", e);

12
beneficiation/src/main/java/com/ccsens/beneficiation/service/IRecordService.java

@ -1,10 +1,20 @@
package com.ccsens.beneficiation.service; package com.ccsens.beneficiation.service;
import com.ccsens.beneficiation.bean.dto.Message.BeneficiationMessageDto; import com.ccsens.beneficiation.bean.dto.Message.BeneficiationMessageDto;
import com.ccsens.beneficiation.bean.vo.MessageVo;
import java.util.List;
public interface IRecordService { public interface IRecordService {
/** /**
* 处理消息消息 * 处理消息消息
*/ */
void processMessage(BeneficiationMessageDto carRecordMessageDto); List<MessageVo.AchieveMessage> processMessage(List<BeneficiationMessageDto> carRecordMessageDto);
/**
* 根据业务保存处理插件
* @param achieveMessages
*/
void saveRecord(List<MessageVo.AchieveMessage> achieveMessages);
} }

204
beneficiation/src/main/java/com/ccsens/beneficiation/service/ParameterService.java

@ -1,12 +1,16 @@
package com.ccsens.beneficiation.service; package com.ccsens.beneficiation.service;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ccsens.beneficiation.bean.dto.ParameterDto; import com.ccsens.beneficiation.bean.dto.ParameterDto;
import com.ccsens.beneficiation.bean.vo.ParameterVo; import com.ccsens.beneficiation.bean.vo.ParameterVo;
import com.ccsens.beneficiation.persist.dao.RecordDao;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -18,84 +22,140 @@ import java.util.List;
@Service @Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class ParameterService implements IParameterService{ public class ParameterService implements IParameterService{
@Resource
private RecordDao recordDao;
@Override @Override
public ParameterVo.QueryParameter queryParameter(Object param) { public ParameterVo.QueryParameter queryParameter(Object param) {
//查询电耳,皮带秤,流量计,电磁阀,变频器的数据
ParameterVo.QueryParameter parameterInfo = new ParameterVo.QueryParameter(); ParameterVo.QueryParameter parameterInfo = new ParameterVo.QueryParameter();
//查询皮带秤和流量计的数据
List<ParameterVo.BeltWeigher> beltWeighers = recordDao.queryBeltWeigher();
if(CollectionUtil.isNotEmpty(beltWeighers)){
beltWeighers.forEach(beltWeigher -> {
if(CollectionUtil.isNotEmpty(beltWeigher.getValues())){
int i = beltWeigher.getValues().size() <= 1 ? 0 : 1;
for (ParameterVo.BeltWeigherValue value : beltWeigher.getValues()) {
String a = i == 0 ? "" : Integer.toString(i);
value.setKey("实时/累计" + a);
i++;
}
}
});
}
parameterInfo.setBeltWeigher(beltWeighers);
//查询变频器和电磁阀
List<ParameterVo.Transducer> transducers = recordDao.queryTransducer();
if(CollectionUtil.isNotEmpty(transducers)){
transducers.forEach(transducer -> {
String type = "变频器".equalsIgnoreCase(transducer.getTitle()) ? "transducer" : "solenoidValue";
if(CollectionUtil.isNotEmpty(transducer.getValues())){
int i = transducer.getValues().size() <= 1 ? 0 : 1;
for (ParameterVo.TransducerValue value : transducer.getValues()) {
String a = i == 0 ? "" : Integer.toString(i);
value.setKey("实时/设置" + a);
value.setType(type + a);
i++;
}
}
});
}
parameterInfo.setTransducers(transducers);
//查询变频器和电磁阀
List<ParameterVo.Parameter> parameters = recordDao.queryParameter();
if(CollectionUtil.isNotEmpty(parameters)){
parameters.forEach(parameter -> {
if(CollectionUtil.isNotEmpty(parameter.getValues())){
int i = parameter.getValues().size() <= 1 ? 0 : 1;
for (ParameterVo.ParameterThreshold value : parameter.getValues()) {
String a = i == 0 ? "" : Integer.toString(i);
value.setKey("实时" + a);
value.setType("thresholdValue" + a);
//查询设备的阀值1
value.setThresholdValue1(recordDao.getThresholdValue(value.getId(),1));
//阀值2
value.setThresholdValue2(recordDao.getThresholdValue(value.getId(),2));
//阀值3
value.setThresholdValue3(recordDao.getThresholdValue(value.getId(),3));
i++;
}
}
});
}
parameterInfo.setParameter(parameters);
List<ParameterVo.TransducerValue> transducerValues = new ArrayList<>(); //
ParameterVo.TransducerValue transducer1 = new ParameterVo.TransducerValue(6L,"transducer1","实时/设置1", BigDecimal.valueOf(45)); // List<ParameterVo.TransducerValue> transducerValues = new ArrayList<>();
ParameterVo.TransducerValue transducer2 = new ParameterVo.TransducerValue(7L,"transducer2","实时/设置2", BigDecimal.valueOf(8)); // ParameterVo.TransducerValue transducer1 = new ParameterVo.TransducerValue(6L,"transducer1","实时/设置1", BigDecimal.valueOf(45));
ParameterVo.TransducerValue transducer3 = new ParameterVo.TransducerValue(8L,"transducer3","实时/设置3", BigDecimal.valueOf(67)); // ParameterVo.TransducerValue transducer2 = new ParameterVo.TransducerValue(7L,"transducer2","实时/设置2", BigDecimal.valueOf(8));
ParameterVo.TransducerValue transducer4 = new ParameterVo.TransducerValue(10L,"transducer4","实时/设置4", BigDecimal.valueOf(75)); // ParameterVo.TransducerValue transducer3 = new ParameterVo.TransducerValue(8L,"transducer3","实时/设置3", BigDecimal.valueOf(67));
transducerValues.add(transducer1); // ParameterVo.TransducerValue transducer4 = new ParameterVo.TransducerValue(10L,"transducer4","实时/设置4", BigDecimal.valueOf(75));
transducerValues.add(transducer2); // transducerValues.add(transducer1);
transducerValues.add(transducer3); // transducerValues.add(transducer2);
transducerValues.add(transducer4); // transducerValues.add(transducer3);
// transducerValues.add(transducer4);
List<ParameterVo.Transducer> transducers = new ArrayList<>(); //
ParameterVo.Transducer transducer = new ParameterVo.Transducer(); // List<ParameterVo.Transducer> transducers = new ArrayList<>();
transducer.setTitle("变频器"); // ParameterVo.Transducer transducer = new ParameterVo.Transducer();
transducer.setValues(transducerValues); // transducer.setTitle("变频器");
transducers.add(transducer); // transducer.setValues(transducerValues);
// transducers.add(transducer);
List<ParameterVo.TransducerValue> transducerValues1 = new ArrayList<>(); //
ParameterVo.TransducerValue transducer11 = new ParameterVo.TransducerValue(6L,"solenoidValue1","实时/设置1", BigDecimal.valueOf(45)); // List<ParameterVo.TransducerValue> transducerValues1 = new ArrayList<>();
ParameterVo.TransducerValue transducer21 = new ParameterVo.TransducerValue(7L,"solenoidValue2","实时/设置2", BigDecimal.valueOf(8)); // ParameterVo.TransducerValue transducer11 = new ParameterVo.TransducerValue(6L,"solenoidValue1","实时/设置1", BigDecimal.valueOf(45));
transducerValues1.add(transducer11); // ParameterVo.TransducerValue transducer21 = new ParameterVo.TransducerValue(7L,"solenoidValue2","实时/设置2", BigDecimal.valueOf(8));
transducerValues1.add(transducer21); // transducerValues1.add(transducer11);
// transducerValues1.add(transducer21);
List<ParameterVo.Transducer> transducers2 = new ArrayList<>(); //
ParameterVo.Transducer transducer12 = new ParameterVo.Transducer(); // ParameterVo.Transducer transducer12 = new ParameterVo.Transducer();
transducer12.setTitle("电磁阀"); // transducer12.setTitle("电磁阀");
transducer12.setValues(transducerValues); // transducer12.setValues(transducerValues1);
transducers2.add(transducer12); // transducers.add(transducer12);
//
parameterInfo.setTransducers(transducers2); // parameterInfo.setTransducers(transducers);
//
//
List<ParameterVo.BeltWeigher> beltWeighers1 = new ArrayList<>(); // List<ParameterVo.BeltWeigher> beltWeighers1 = new ArrayList<>();
ParameterVo.BeltWeigher beltWeigher1 = new ParameterVo.BeltWeigher(); // ParameterVo.BeltWeigher beltWeigher1 = new ParameterVo.BeltWeigher();
beltWeigher1.setTitle("皮带秤"); // beltWeigher1.setTitle("皮带秤");
List<ParameterVo.BeltWeigherValue> beltWeigherValueList1 = new ArrayList<>(); // List<ParameterVo.BeltWeigherValue> beltWeigherValueList1 = new ArrayList<>();
ParameterVo.BeltWeigherValue beltWeigher01 = new ParameterVo.BeltWeigherValue(1L,"实时/累计", BigDecimal.valueOf(12),BigDecimal.valueOf(1212)); // ParameterVo.BeltWeigherValue beltWeigher01 = new ParameterVo.BeltWeigherValue(1L,"实时/累计", BigDecimal.valueOf(12),BigDecimal.valueOf(1212));
beltWeigherValueList1.add(beltWeigher01); // beltWeigherValueList1.add(beltWeigher01);
beltWeigher1.setValues(beltWeigherValueList1); // beltWeigher1.setValues(beltWeigherValueList1);
beltWeighers1.add(beltWeigher1); // beltWeighers1.add(beltWeigher1);
parameterInfo.setBeltWeigher(beltWeighers1); //
//
List<ParameterVo.BeltWeigher> beltWeighers2 = new ArrayList<>(); // ParameterVo.BeltWeigher beltWeigher2 = new ParameterVo.BeltWeigher();
ParameterVo.BeltWeigher beltWeigher2 = new ParameterVo.BeltWeigher(); // beltWeigher2.setTitle("流量计");
beltWeigher2.setTitle("流量计"); // List<ParameterVo.BeltWeigherValue> beltWeigherValueList2 = new ArrayList<>();
List<ParameterVo.BeltWeigherValue> beltWeigherValueList2 = new ArrayList<>(); // ParameterVo.BeltWeigherValue beltWeigher02 = new ParameterVo.BeltWeigherValue(2L,"实时/累计", BigDecimal.valueOf(16),BigDecimal.valueOf(1524));
ParameterVo.BeltWeigherValue beltWeigher02 = new ParameterVo.BeltWeigherValue(2L,"实时/累计", BigDecimal.valueOf(16),BigDecimal.valueOf(1524)); // ParameterVo.BeltWeigherValue beltWeigher03 = new ParameterVo.BeltWeigherValue(3L,"实时/累计", BigDecimal.valueOf(5),BigDecimal.valueOf(232));
ParameterVo.BeltWeigherValue beltWeigher03 = new ParameterVo.BeltWeigherValue(3L,"实时/累计", BigDecimal.valueOf(5),BigDecimal.valueOf(232)); // beltWeigherValueList2.add(beltWeigher02);
beltWeigherValueList2.add(beltWeigher02); // beltWeigherValueList2.add(beltWeigher03);
beltWeigherValueList2.add(beltWeigher03); // beltWeigher2.setValues(beltWeigherValueList2);
beltWeigher2.setValues(beltWeigherValueList2); // beltWeighers1.add(beltWeigher2);
beltWeighers2.add(beltWeigher2); // parameterInfo.setBeltWeigher(beltWeighers1);
parameterInfo.setBeltWeigher(beltWeighers2); //
// List<ParameterVo.Parameter> parameters = new ArrayList<>();
// ParameterVo.Parameter parameter = new ParameterVo.Parameter();
List<ParameterVo.Parameter> parameters = new ArrayList<>(); // parameter.setTitle("电耳");
ParameterVo.Parameter parameter = new ParameterVo.Parameter(); // List<ParameterVo.ParameterThreshold> parameterThresholds = new ArrayList<>();
parameter.setTitle("电耳"); //
List<ParameterVo.ParameterThreshold> parameterThresholds = new ArrayList<>(); // ParameterVo.ParameterThreshold parameterThreshold1 = new ParameterVo.ParameterThreshold(11L,"electricEar1","实时",BigDecimal.valueOf(60),
// new ParameterVo.ThresholdValue(1L,"thresholdValue1","阀值1",BigDecimal.valueOf(20),BigDecimal.valueOf(60)),
ParameterVo.ParameterThreshold parameterThreshold1 = new ParameterVo.ParameterThreshold(11L,"实时","electricEar1",BigDecimal.valueOf(60), // new ParameterVo.ThresholdValue(2L,"thresholdValue2","阀值2",BigDecimal.valueOf(30),BigDecimal.valueOf(70)),
new ParameterVo.ThresholdValue(BigDecimal.valueOf(20),BigDecimal.valueOf(60)), // new ParameterVo.ThresholdValue(3L,"thresholdValue3","阀值3",BigDecimal.valueOf(40),BigDecimal.valueOf(80)));
new ParameterVo.ThresholdValue(BigDecimal.valueOf(30),BigDecimal.valueOf(70)), //
new ParameterVo.ThresholdValue(BigDecimal.valueOf(40),BigDecimal.valueOf(80))); // ParameterVo.ParameterThreshold parameterThreshold2 = new ParameterVo.ParameterThreshold(12L,"electricEar1","实时",BigDecimal.valueOf(65),
// new ParameterVo.ThresholdValue(4L,"thresholdValue1","阀值1",BigDecimal.valueOf(30),BigDecimal.valueOf(70)),
ParameterVo.ParameterThreshold parameterThreshold2 = new ParameterVo.ParameterThreshold(12L,"实时","electricEar1",BigDecimal.valueOf(65), // new ParameterVo.ThresholdValue(5L,"thresholdValue2","阀值2",BigDecimal.valueOf(40),BigDecimal.valueOf(80)),
new ParameterVo.ThresholdValue(BigDecimal.valueOf(30),BigDecimal.valueOf(70)), // new ParameterVo.ThresholdValue(6L,"thresholdValue3","阀值3",BigDecimal.valueOf(50),BigDecimal.valueOf(90)));
new ParameterVo.ThresholdValue(BigDecimal.valueOf(40),BigDecimal.valueOf(80)), // parameterThresholds.add(parameterThreshold1);
new ParameterVo.ThresholdValue(BigDecimal.valueOf(50),BigDecimal.valueOf(90))); // parameterThresholds.add(parameterThreshold2);
parameterThresholds.add(parameterThreshold1); // parameter.setValues(parameterThresholds);
parameterThresholds.add(parameterThreshold2); // parameters.add(parameter);
parameter.setValues(parameterThresholds); // parameterInfo.setParameter(parameters);
parameterInfo.setParameter(parameters);
return parameterInfo; return parameterInfo;
} }

191
beneficiation/src/main/java/com/ccsens/beneficiation/service/RecordService.java

@ -2,12 +2,12 @@ package com.ccsens.beneficiation.service;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import com.ccsens.beneficiation.bean.dto.Message.BeneficiationMessageDto; import com.ccsens.beneficiation.bean.dto.Message.BeneficiationMessageDto;
import com.ccsens.beneficiation.bean.po.*; import com.ccsens.beneficiation.bean.po.*;
import com.ccsens.beneficiation.bean.po.Record; import com.ccsens.beneficiation.bean.po.Record;
import com.ccsens.beneficiation.bean.vo.MessageVo;
import com.ccsens.beneficiation.persist.dao.RecordDao; import com.ccsens.beneficiation.persist.dao.RecordDao;
import com.ccsens.beneficiation.persist.mapper.AdjustRecordMapper;
import com.ccsens.beneficiation.persist.mapper.EquipmentMapper;
import com.ccsens.beneficiation.persist.mapper.ThresholdValueMapper; import com.ccsens.beneficiation.persist.mapper.ThresholdValueMapper;
import com.ccsens.beneficiation.persist.mapper.WeightMapper; import com.ccsens.beneficiation.persist.mapper.WeightMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -16,9 +16,13 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
/**
* @author
*/
@Slf4j @Slf4j
@Service @Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
@ -26,104 +30,137 @@ public class RecordService implements IRecordService{
@Resource @Resource
private RecordDao recordDao; private RecordDao recordDao;
@Resource @Resource
private EquipmentMapper equipmentMapper;
@Resource
private Snowflake snowflake; private Snowflake snowflake;
@Resource @Resource
private WeightMapper weightMapper; private WeightMapper weightMapper;
@Resource @Resource
private ThresholdValueMapper thresholdValueMapper; private ThresholdValueMapper thresholdValueMapper;
@Resource
private AdjustRecordMapper adjustRecordMapper;
/**
* 处理下位机消息
*/
@Override @Override
public void processMessage(BeneficiationMessageDto beneficiation) { public List<MessageVo.AchieveMessage> processMessage(List<BeneficiationMessageDto> messageDtoList) {
//查找设备。没有则添加一个 List<MessageVo.AchieveMessage> achieveMessages = new ArrayList<>();
Equipment equipment; log.info("");
EquipmentExample equipmentExample = new EquipmentExample(); int i = 0;
equipmentExample.createCriteria().andTypeEqualTo(beneficiation.getType()).andAuthIdEqualTo(beneficiation.getAuthId()); while (i < messageDtoList.size()){
List<Equipment> equipmentList = equipmentMapper.selectByExample(equipmentExample); BeneficiationMessageDto messageDto = messageDtoList.get(i);
if(CollectionUtil.isNotEmpty(equipmentList)){ //获取该设备的消息处理配置
equipment = equipmentList.get(0); MessageVo.AddrDispose addrDispose = recordDao.getByStartAddr(messageDto.getAddr(), (byte) 1);
}else { String[] split = addrDispose.getContentLength().split(",");
equipment = new Equipment(); if(split.length == 0){
equipment.setId(snowflake.nextId()); i++;
equipment.setType(beneficiation.getType()); continue;
equipment.setAuthId(beneficiation.getAuthId());
equipment.setVerion(beneficiation.getVersion());
equipmentMapper.insertSelective(equipment);
} }
//判断类型 for (String s : split) {
switch (beneficiation.getType()){ if(Integer.parseInt(s) == 0){
case 5: i++;
//称重信息 continue;
}
MessageVo.AchieveMessage achieveMessage = new MessageVo.AchieveMessage();
achieveMessage.setAddr(messageDto.getAddr());
int value = 0;
for (int j = 0; j < Integer.parseInt(s); j++) {
value += messageDtoList.get(i + j).getValue();
}
achieveMessage.setValue(value);
achieveMessages.add(achieveMessage);
i += Integer.parseInt(s);
}
}
return achieveMessages;
}
@Override
public void saveRecord(List<MessageVo.AchieveMessage> achieveMessages) {
if(CollectionUtil.isNotEmpty(achieveMessages)){
achieveMessages.forEach(achieveMessage -> {
//根据addr查找消息类型和设备类型
MessageVo.EquipmentType equipmentType = recordDao.getEquipmentTypeByAddr(achieveMessage.getAddr());
if(ObjectUtil.isNull(equipmentType)){
return;
}
log.info("每条数据都存入记录表");
saveRecord(achieveMessage.getValue(), equipmentType.getId(),equipmentType.getMessageType());
//皮带秤的累计值
if(equipmentType.getEquipmentType() == 4){
//累计值存入重量表
if(equipmentType.getMessageType() == 2){
log.info("保存皮带秤累计值");
Weight weight = new Weight(); Weight weight = new Weight();
weight.setId(snowflake.nextId()); weight.setId(snowflake.nextId());
weight.setEquipmentId(equipment.getId()); weight.setTime(new Date());
weight.setWeight(beneficiation.getValue()); weight.setEquipmentId(equipmentType.getId());
weight.setTime(new Date(beneficiation.getTime())); weight.setWeight(achieveMessage.getValue().toString());
weightMapper.insertSelective(weight); weightMapper.insertSelective(weight);
}
}
//阀值
Integer min;
Integer max;
switch (equipmentType.getMessageType()){
case 3:
case 8:
min = equipmentType.getMessageType() == 3 ? achieveMessage.getValue() : null;
max = equipmentType.getMessageType() == 8 ? achieveMessage.getValue() : null;
setThreshold(equipmentType.getId(), (byte) 1, min, max);
break; break;
case 6: case 4:
//添加界限值信息 case 9:
min = equipmentType.getMessageType() == 4 ? achieveMessage.getValue() : null;
max = equipmentType.getMessageType() == 9 ? achieveMessage.getValue() : null;
setThreshold(equipmentType.getId(), (byte) 2, min, max);
break; break;
case 7: case 5:
//查找界限值信息 case 10:
ThresholdValueExample thresholdValueExample = new ThresholdValueExample(); min = equipmentType.getMessageType() == 5 ? achieveMessage.getValue() : null;
thresholdValueExample.createCriteria().andTypeEqualTo(equipment.getType()).andStagesEqualTo(Byte.parseByte(beneficiation.getValue())); max = equipmentType.getMessageType() == 10 ? achieveMessage.getValue() : null;
List<ThresholdValue> thresholdValueList = thresholdValueMapper.selectByExample(thresholdValueExample);
if(CollectionUtil.isNotEmpty(thresholdValueList)){ setThreshold(equipmentType.getId(), (byte) 3, min, max);
//添加调整记录
AdjustRecord adjustRecord = new AdjustRecord();
adjustRecord.setId(snowflake.nextId());
adjustRecord.setMonitoringId(equipment.getId());
adjustRecord.setThresholdId(thresholdValueList.get(0).getId());
adjustRecordMapper.insertSelective(adjustRecord);
}
break; break;
default: default:
//否则是设备基本信息 break;
saveEquipmentRecord(beneficiation); }
});
} }
} }
private void saveEquipmentRecord(BeneficiationMessageDto beneficiation) { private void setThreshold(Long equipmentId, byte stages, Integer min, Integer max) {
//查找设备。没有则添加一个 ThresholdValue thresholdValue;
Long equipmentId; ThresholdValueExample thresholdValueExample = new ThresholdValueExample();
EquipmentExample equipmentExample = new EquipmentExample(); thresholdValueExample.createCriteria().andEquipmentIdEqualTo(equipmentId).andStagesEqualTo(stages);
equipmentExample.createCriteria().andTypeEqualTo(beneficiation.getType()).andAuthIdEqualTo(beneficiation.getAuthId()); thresholdValueExample.setOrderByClause("created_at DESC limit 1");
List<Equipment> equipmentList = equipmentMapper.selectByExample(equipmentExample); List<ThresholdValue> thresholdValueList = thresholdValueMapper.selectByExample(thresholdValueExample);
if(CollectionUtil.isNotEmpty(equipmentList)){ if(CollectionUtil.isNotEmpty(thresholdValueList)){
equipmentId = equipmentList.get(0).getId(); thresholdValue = thresholdValueList.get(0);
thresholdValue.setMin(min);
thresholdValue.setMax(max);
thresholdValueMapper.updateByPrimaryKeySelective(thresholdValue);
}else { }else {
Equipment equipment = new Equipment(); thresholdValue = new ThresholdValue();
equipment.setId(snowflake.nextId()); thresholdValue.setId(snowflake.nextId());
equipment.setType(beneficiation.getType()); thresholdValue.setEquipmentId(equipmentId);
equipment.setAuthId(beneficiation.getAuthId()); thresholdValue.setStages(stages);
equipment.setVerion(beneficiation.getVersion()); thresholdValue.setMin(min);
equipmentMapper.insertSelective(equipment); thresholdValue.setMax(max);
equipmentId = equipment.getId(); thresholdValueMapper.insertSelective(thresholdValue);
} }
// 查询该设备上一条最新信息,如果值相同,则不添加 }
RecordExample recordExample = new RecordExample();
recordExample.createCriteria().andEquipmentIdEqualTo(equipmentId);
recordExample.setOrderByClause("time DESC Limit 1"); private void saveRecord(int value, Long equipmentId, Byte messageType) {
List<Record> records = recordDao.selectByExample(recordExample);
if(CollectionUtil.isEmpty(records)){
Record record = new Record();
record.setId(snowflake.nextId());
record.setEquipmentId(equipmentId);
record.setValue(beneficiation.getValue());
record.setTime(new Date(System.currentTimeMillis()));
recordDao.insertSelective(record);
}else if(!records.get(0).getValue().equalsIgnoreCase(beneficiation.getValue())){
Record record = new Record(); Record record = new Record();
record.setId(snowflake.nextId()); record.setId(snowflake.nextId());
record.setTime(new Date());
record.setEquipmentId(equipmentId); record.setEquipmentId(equipmentId);
record.setValue(beneficiation.getValue()); record.setValue(value);
record.setTime(new Date(System.currentTimeMillis())); record.setType(messageType);
log.info("存入记录表:{}",record);
recordDao.insertSelective(record); recordDao.insertSelective(record);
} }
}
} }

129
beneficiation/src/main/resources/mapper_dao/RecordDao.xml

@ -16,4 +16,133 @@
ORDER BY r.time DESC ORDER BY r.time DESC
LIMIT 1 LIMIT 1
</select> </select>
<select id="getByStartAddr" resultType="com.ccsens.beneficiation.bean.vo.MessageVo$AddrDispose">
SELECT
id,
start_addr,
end_addr,
content_num,
content_length
FROM
tall.t_util_addr_dispose
WHERE
start_addr = #{startAddr}
and project = #{project}
and rec_status = 0
limit 1
</select>
<select id="getEquipmentTypeByAddr" resultType="com.ccsens.beneficiation.bean.vo.MessageVo$EquipmentType">
SELECT
e.id,
e.type as equipmentType,
t.type as messageType
from
t_equipment_type t
LEFT JOIN t_equipment e
on t.equipment_id = e.id and e.rec_status = 0
WHERE
t.addr = #{addr}
and t.rec_status = 0
</select>
<resultMap id="queryBeltWeigher" type="com.ccsens.beneficiation.bean.vo.ParameterVo$BeltWeigher">
<id column="title" property="title"/>
<collection property="values" ofType="com.ccsens.beneficiation.bean.vo.ParameterVo$BeltWeigherValue">
<id column="id" property="id"/>
<result column="currentTimeValue" property="currentTimeValue"/>
<result column="totalValue" property="totalValue"/>
</collection>
</resultMap>
<select id="queryBeltWeigher" resultMap="queryBeltWeigher">
SELECT
e.id,
if(e.type = 3,'流量计','皮带秤') as title,
(
SELECT `value` FROM t_record WHERE
equipment_id = e.id and type = 0 and rec_status = 0
ORDER BY time DESC
limit 1
) as currentTimeValue,
(
SELECT `value` FROM t_record WHERE
equipment_id = e.id and type = 2 and rec_status = 0
ORDER BY time DESC
limit 1
) as totalValue
FROM
t_equipment e
WHERE
(e.type = 4 or e.type = 3)
and e.rec_status = 0
</select>
<resultMap id="queryTransducer" type="com.ccsens.beneficiation.bean.vo.ParameterVo$Transducer">
<id column="title" property="title"/>
<collection property="values" ofType="com.ccsens.beneficiation.bean.vo.ParameterVo$TransducerValue">
<id column="id" property="id"/>
<result column="currentTimeValue" property="currentTimeValue"/>
<result column="setTimeValue" property="setTimeValue"/>
</collection>
</resultMap>
<select id="queryTransducer" resultMap="queryTransducer">
SELECT
e.id,
if(e.type = 2,'电磁阀','变频器') as title,
(
SELECT `value` FROM t_record WHERE
equipment_id = e.id and type = 0 and rec_status = 0
ORDER BY time DESC
limit 1
) as currentTimeValue,
(
SELECT `value` FROM t_record WHERE
equipment_id = e.id and type = 1 and rec_status = 0
ORDER BY time DESC
limit 1
) as setTimeValue
FROM
t_equipment e
WHERE
(e.type = 2 or e.type = 5)
and e.rec_status = 0
</select>
<resultMap id="queryParameter" type="com.ccsens.beneficiation.bean.vo.ParameterVo$Parameter">
<id column="title" property="title"/>
<collection property="values" ofType="com.ccsens.beneficiation.bean.vo.ParameterVo$ParameterThreshold">
<id column="id" property="id"/>
<result column="currentTimeValue" property="currentTimeValue"/>
</collection>
</resultMap>
<select id="queryParameter" resultMap="queryParameter">
SELECT
e.id,
'电耳' as title,
(
SELECT `value` FROM t_record WHERE
equipment_id = e.id and type = 0 and rec_status = 0
ORDER BY time DESC
limit 1
) as currentTimeValue
FROM
t_equipment e
WHERE
e.type = 1
and e.rec_status = 0
</select>
<select id="getThresholdValue" resultType="com.ccsens.beneficiation.bean.vo.ParameterVo$ThresholdValue">
SELECT
id,
CONCAT('thresholdValue',stages) as type,
CONCAT('阀值',stages) as `key`,
min as minValue,
max as `maxValue`
FROM
t_threshold_value
WHERE
equipment_id = #{equipmentId}
and stages = #{stages}
and rec_status = 0
ORDER BY created_at DESC
LIMIT 1
</select>
</mapper> </mapper>

3
beneficiation/src/main/resources/mapper_dao/WeightDao.xml

@ -5,10 +5,9 @@
<select id="queryWeightDay" resultType="com.ccsens.beneficiation.bean.vo.WeightVo$WeightDay"> <select id="queryWeightDay" resultType="com.ccsens.beneficiation.bean.vo.WeightVo$WeightDay">
SELECT SELECT
DATE_FORMAT(time, #{dateTypeStr}) as date,
if(#{dateType} = 1, if(#{dateType} = 1,
CONCAT(DATE_FORMAT(time, '%Y'),'-',DATE_FORMAT(time, '%u')+1), CONCAT(DATE_FORMAT(time, '%Y'),'-',DATE_FORMAT(time, '%u')+1),
DATE_FORMAT(time, #{dateTypeStr}, DATE_FORMAT(time, #{dateTypeStr})
) )
as date, as date,
sum(weight) as weight sum(weight) as weight

27
beneficiation/src/main/resources/mapper_raw/EquipmentMapper.xml

@ -5,7 +5,6 @@
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="type" jdbcType="TINYINT" property="type" /> <result column="type" jdbcType="TINYINT" property="type" />
<result column="auth_id" jdbcType="VARCHAR" property="authId" /> <result column="auth_id" jdbcType="VARCHAR" property="authId" />
<result column="addr" jdbcType="VARCHAR" property="addr" />
<result column="verion" jdbcType="VARCHAR" property="verion" /> <result column="verion" jdbcType="VARCHAR" property="verion" />
<result column="operator" jdbcType="BIGINT" property="operator" /> <result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" /> <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
@ -71,7 +70,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, type, auth_id, addr, verion, operator, created_at, updated_at, rec_status id, type, auth_id, verion, operator, created_at, updated_at, rec_status
</sql> </sql>
<select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.EquipmentExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.EquipmentExample" resultMap="BaseResultMap">
select select
@ -105,13 +104,11 @@
</delete> </delete>
<insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.Equipment"> <insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.Equipment">
insert into t_equipment (id, type, auth_id, insert into t_equipment (id, type, auth_id,
addr, verion, operator, verion, operator, created_at,
created_at, updated_at, rec_status updated_at, rec_status)
)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=TINYINT}, #{authId,jdbcType=VARCHAR}, values (#{id,jdbcType=BIGINT}, #{type,jdbcType=TINYINT}, #{authId,jdbcType=VARCHAR},
#{addr,jdbcType=VARCHAR}, #{verion,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{verion,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.ccsens.beneficiation.bean.po.Equipment"> <insert id="insertSelective" parameterType="com.ccsens.beneficiation.bean.po.Equipment">
insert into t_equipment insert into t_equipment
@ -125,9 +122,6 @@
<if test="authId != null"> <if test="authId != null">
auth_id, auth_id,
</if> </if>
<if test="addr != null">
addr,
</if>
<if test="verion != null"> <if test="verion != null">
verion, verion,
</if> </if>
@ -154,9 +148,6 @@
<if test="authId != null"> <if test="authId != null">
#{authId,jdbcType=VARCHAR}, #{authId,jdbcType=VARCHAR},
</if> </if>
<if test="addr != null">
#{addr,jdbcType=VARCHAR},
</if>
<if test="verion != null"> <if test="verion != null">
#{verion,jdbcType=VARCHAR}, #{verion,jdbcType=VARCHAR},
</if> </if>
@ -192,9 +183,6 @@
<if test="record.authId != null"> <if test="record.authId != null">
auth_id = #{record.authId,jdbcType=VARCHAR}, auth_id = #{record.authId,jdbcType=VARCHAR},
</if> </if>
<if test="record.addr != null">
addr = #{record.addr,jdbcType=VARCHAR},
</if>
<if test="record.verion != null"> <if test="record.verion != null">
verion = #{record.verion,jdbcType=VARCHAR}, verion = #{record.verion,jdbcType=VARCHAR},
</if> </if>
@ -220,7 +208,6 @@
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
type = #{record.type,jdbcType=TINYINT}, type = #{record.type,jdbcType=TINYINT},
auth_id = #{record.authId,jdbcType=VARCHAR}, auth_id = #{record.authId,jdbcType=VARCHAR},
addr = #{record.addr,jdbcType=VARCHAR},
verion = #{record.verion,jdbcType=VARCHAR}, verion = #{record.verion,jdbcType=VARCHAR},
operator = #{record.operator,jdbcType=BIGINT}, operator = #{record.operator,jdbcType=BIGINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, created_at = #{record.createdAt,jdbcType=TIMESTAMP},
@ -239,9 +226,6 @@
<if test="authId != null"> <if test="authId != null">
auth_id = #{authId,jdbcType=VARCHAR}, auth_id = #{authId,jdbcType=VARCHAR},
</if> </if>
<if test="addr != null">
addr = #{addr,jdbcType=VARCHAR},
</if>
<if test="verion != null"> <if test="verion != null">
verion = #{verion,jdbcType=VARCHAR}, verion = #{verion,jdbcType=VARCHAR},
</if> </if>
@ -264,7 +248,6 @@
update t_equipment update t_equipment
set type = #{type,jdbcType=TINYINT}, set type = #{type,jdbcType=TINYINT},
auth_id = #{authId,jdbcType=VARCHAR}, auth_id = #{authId,jdbcType=VARCHAR},
addr = #{addr,jdbcType=VARCHAR},
verion = #{verion,jdbcType=VARCHAR}, verion = #{verion,jdbcType=VARCHAR},
operator = #{operator,jdbcType=BIGINT}, operator = #{operator,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP}, created_at = #{createdAt,jdbcType=TIMESTAMP},

258
beneficiation/src/main/resources/mapper_raw/EquipmentTypeMapper.xml

@ -0,0 +1,258 @@
<?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.ccsens.beneficiation.persist.mapper.EquipmentTypeMapper">
<resultMap id="BaseResultMap" type="com.ccsens.beneficiation.bean.po.EquipmentType">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="equipment_id" jdbcType="BIGINT" property="equipmentId" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="addr" jdbcType="INTEGER" property="addr" />
<result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, equipment_id, type, addr, operator, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.EquipmentTypeExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from t_equipment_type
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_equipment_type
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from t_equipment_type
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.ccsens.beneficiation.bean.po.EquipmentTypeExample">
delete from t_equipment_type
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.EquipmentType">
insert into t_equipment_type (id, equipment_id, type,
addr, operator, created_at,
updated_at, rec_status)
values (#{id,jdbcType=BIGINT}, #{equipmentId,jdbcType=BIGINT}, #{type,jdbcType=TINYINT},
#{addr,jdbcType=INTEGER}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.ccsens.beneficiation.bean.po.EquipmentType">
insert into t_equipment_type
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="equipmentId != null">
equipment_id,
</if>
<if test="type != null">
type,
</if>
<if test="addr != null">
addr,
</if>
<if test="operator != null">
operator,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="recStatus != null">
rec_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="equipmentId != null">
#{equipmentId,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=TINYINT},
</if>
<if test="addr != null">
#{addr,jdbcType=INTEGER},
</if>
<if test="operator != null">
#{operator,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
#{recStatus,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.ccsens.beneficiation.bean.po.EquipmentTypeExample" resultType="java.lang.Long">
select count(*) from t_equipment_type
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update t_equipment_type
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.equipmentId != null">
equipment_id = #{record.equipmentId,jdbcType=BIGINT},
</if>
<if test="record.type != null">
type = #{record.type,jdbcType=TINYINT},
</if>
<if test="record.addr != null">
addr = #{record.addr,jdbcType=INTEGER},
</if>
<if test="record.operator != null">
operator = #{record.operator,jdbcType=BIGINT},
</if>
<if test="record.createdAt != null">
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
</if>
<if test="record.updatedAt != null">
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update t_equipment_type
set id = #{record.id,jdbcType=BIGINT},
equipment_id = #{record.equipmentId,jdbcType=BIGINT},
type = #{record.type,jdbcType=TINYINT},
addr = #{record.addr,jdbcType=INTEGER},
operator = #{record.operator,jdbcType=BIGINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.beneficiation.bean.po.EquipmentType">
update t_equipment_type
<set>
<if test="equipmentId != null">
equipment_id = #{equipmentId,jdbcType=BIGINT},
</if>
<if test="type != null">
type = #{type,jdbcType=TINYINT},
</if>
<if test="addr != null">
addr = #{addr,jdbcType=INTEGER},
</if>
<if test="operator != null">
operator = #{operator,jdbcType=BIGINT},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.beneficiation.bean.po.EquipmentType">
update t_equipment_type
set equipment_id = #{equipmentId,jdbcType=BIGINT},
type = #{type,jdbcType=TINYINT},
addr = #{addr,jdbcType=INTEGER},
operator = #{operator,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

41
beneficiation/src/main/resources/mapper_raw/RecordMapper.xml

@ -4,12 +4,13 @@
<resultMap id="BaseResultMap" type="com.ccsens.beneficiation.bean.po.Record"> <resultMap id="BaseResultMap" type="com.ccsens.beneficiation.bean.po.Record">
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="equipment_id" jdbcType="BIGINT" property="equipmentId" /> <result column="equipment_id" jdbcType="BIGINT" property="equipmentId" />
<result column="value" jdbcType="VARCHAR" property="value" /> <result column="value" jdbcType="INTEGER" property="value" />
<result column="time" jdbcType="TIMESTAMP" property="time" /> <result column="time" jdbcType="TIMESTAMP" property="time" />
<result column="operator" jdbcType="BIGINT" property="operator" /> <result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" /> <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" /> <result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" /> <result column="rec_status" jdbcType="TINYINT" property="recStatus" />
<result column="type" jdbcType="TINYINT" property="type" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -70,7 +71,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, equipment_id, value, time, operator, created_at, updated_at, rec_status id, equipment_id, value, time, operator, created_at, updated_at, rec_status, type
</sql> </sql>
<select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.RecordExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.RecordExample" resultMap="BaseResultMap">
select select
@ -105,10 +106,12 @@
<insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.Record"> <insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.Record">
insert into t_record (id, equipment_id, value, insert into t_record (id, equipment_id, value,
time, operator, created_at, time, operator, created_at,
updated_at, rec_status) updated_at, rec_status, type
values (#{id,jdbcType=BIGINT}, #{equipmentId,jdbcType=BIGINT}, #{value,jdbcType=VARCHAR}, )
values (#{id,jdbcType=BIGINT}, #{equipmentId,jdbcType=BIGINT}, #{value,jdbcType=INTEGER},
#{time,jdbcType=TIMESTAMP}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{time,jdbcType=TIMESTAMP}, #{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}) #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}, #{type,jdbcType=TINYINT}
)
</insert> </insert>
<insert id="insertSelective" parameterType="com.ccsens.beneficiation.bean.po.Record"> <insert id="insertSelective" parameterType="com.ccsens.beneficiation.bean.po.Record">
insert into t_record insert into t_record
@ -137,6 +140,9 @@
<if test="recStatus != null"> <if test="recStatus != null">
rec_status, rec_status,
</if> </if>
<if test="type != null">
type,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null"> <if test="id != null">
@ -146,7 +152,7 @@
#{equipmentId,jdbcType=BIGINT}, #{equipmentId,jdbcType=BIGINT},
</if> </if>
<if test="value != null"> <if test="value != null">
#{value,jdbcType=VARCHAR}, #{value,jdbcType=INTEGER},
</if> </if>
<if test="time != null"> <if test="time != null">
#{time,jdbcType=TIMESTAMP}, #{time,jdbcType=TIMESTAMP},
@ -163,6 +169,9 @@
<if test="recStatus != null"> <if test="recStatus != null">
#{recStatus,jdbcType=TINYINT}, #{recStatus,jdbcType=TINYINT},
</if> </if>
<if test="type != null">
#{type,jdbcType=TINYINT},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.ccsens.beneficiation.bean.po.RecordExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.ccsens.beneficiation.bean.po.RecordExample" resultType="java.lang.Long">
@ -181,7 +190,7 @@
equipment_id = #{record.equipmentId,jdbcType=BIGINT}, equipment_id = #{record.equipmentId,jdbcType=BIGINT},
</if> </if>
<if test="record.value != null"> <if test="record.value != null">
value = #{record.value,jdbcType=VARCHAR}, value = #{record.value,jdbcType=INTEGER},
</if> </if>
<if test="record.time != null"> <if test="record.time != null">
time = #{record.time,jdbcType=TIMESTAMP}, time = #{record.time,jdbcType=TIMESTAMP},
@ -198,6 +207,9 @@
<if test="record.recStatus != null"> <if test="record.recStatus != null">
rec_status = #{record.recStatus,jdbcType=TINYINT}, rec_status = #{record.recStatus,jdbcType=TINYINT},
</if> </if>
<if test="record.type != null">
type = #{record.type,jdbcType=TINYINT},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -207,12 +219,13 @@
update t_record update t_record
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
equipment_id = #{record.equipmentId,jdbcType=BIGINT}, equipment_id = #{record.equipmentId,jdbcType=BIGINT},
value = #{record.value,jdbcType=VARCHAR}, value = #{record.value,jdbcType=INTEGER},
time = #{record.time,jdbcType=TIMESTAMP}, time = #{record.time,jdbcType=TIMESTAMP},
operator = #{record.operator,jdbcType=BIGINT}, operator = #{record.operator,jdbcType=BIGINT},
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, created_at = #{record.createdAt,jdbcType=TIMESTAMP},
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, updated_at = #{record.updatedAt,jdbcType=TIMESTAMP},
rec_status = #{record.recStatus,jdbcType=TINYINT} rec_status = #{record.recStatus,jdbcType=TINYINT},
type = #{record.type,jdbcType=TINYINT}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -224,7 +237,7 @@
equipment_id = #{equipmentId,jdbcType=BIGINT}, equipment_id = #{equipmentId,jdbcType=BIGINT},
</if> </if>
<if test="value != null"> <if test="value != null">
value = #{value,jdbcType=VARCHAR}, value = #{value,jdbcType=INTEGER},
</if> </if>
<if test="time != null"> <if test="time != null">
time = #{time,jdbcType=TIMESTAMP}, time = #{time,jdbcType=TIMESTAMP},
@ -241,18 +254,22 @@
<if test="recStatus != null"> <if test="recStatus != null">
rec_status = #{recStatus,jdbcType=TINYINT}, rec_status = #{recStatus,jdbcType=TINYINT},
</if> </if>
<if test="type != null">
type = #{type,jdbcType=TINYINT},
</if>
</set> </set>
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.beneficiation.bean.po.Record"> <update id="updateByPrimaryKey" parameterType="com.ccsens.beneficiation.bean.po.Record">
update t_record update t_record
set equipment_id = #{equipmentId,jdbcType=BIGINT}, set equipment_id = #{equipmentId,jdbcType=BIGINT},
value = #{value,jdbcType=VARCHAR}, value = #{value,jdbcType=INTEGER},
time = #{time,jdbcType=TIMESTAMP}, time = #{time,jdbcType=TIMESTAMP},
operator = #{operator,jdbcType=BIGINT}, operator = #{operator,jdbcType=BIGINT},
created_at = #{createdAt,jdbcType=TIMESTAMP}, created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP}, updated_at = #{updatedAt,jdbcType=TIMESTAMP},
rec_status = #{recStatus,jdbcType=TINYINT} rec_status = #{recStatus,jdbcType=TINYINT},
type = #{type,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT} where id = #{id,jdbcType=BIGINT}
</update> </update>
</mapper> </mapper>

28
beneficiation/src/main/resources/mapper_raw/ThresholdValueMapper.xml

@ -3,7 +3,7 @@
<mapper namespace="com.ccsens.beneficiation.persist.mapper.ThresholdValueMapper"> <mapper namespace="com.ccsens.beneficiation.persist.mapper.ThresholdValueMapper">
<resultMap id="BaseResultMap" type="com.ccsens.beneficiation.bean.po.ThresholdValue"> <resultMap id="BaseResultMap" type="com.ccsens.beneficiation.bean.po.ThresholdValue">
<id column="id" jdbcType="BIGINT" property="id" /> <id column="id" jdbcType="BIGINT" property="id" />
<result column="type" jdbcType="TINYINT" property="type" /> <result column="equipment_id" jdbcType="BIGINT" property="equipmentId" />
<result column="stages" jdbcType="TINYINT" property="stages" /> <result column="stages" jdbcType="TINYINT" property="stages" />
<result column="max" jdbcType="INTEGER" property="max" /> <result column="max" jdbcType="INTEGER" property="max" />
<result column="min" jdbcType="INTEGER" property="min" /> <result column="min" jdbcType="INTEGER" property="min" />
@ -71,7 +71,7 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, type, stages, max, min, operator, created_at, updated_at, rec_status id, equipment_id, stages, max, min, operator, created_at, updated_at, rec_status
</sql> </sql>
<select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValueExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValueExample" resultMap="BaseResultMap">
select select
@ -104,11 +104,11 @@
</if> </if>
</delete> </delete>
<insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValue"> <insert id="insert" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValue">
insert into t_threshold_value (id, type, stages, insert into t_threshold_value (id, equipment_id, stages,
max, min, operator, max, min, operator,
created_at, updated_at, rec_status created_at, updated_at, rec_status
) )
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=TINYINT}, #{stages,jdbcType=TINYINT}, values (#{id,jdbcType=BIGINT}, #{equipmentId,jdbcType=BIGINT}, #{stages,jdbcType=TINYINT},
#{max,jdbcType=INTEGER}, #{min,jdbcType=INTEGER}, #{operator,jdbcType=BIGINT}, #{max,jdbcType=INTEGER}, #{min,jdbcType=INTEGER}, #{operator,jdbcType=BIGINT},
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT}
) )
@ -119,8 +119,8 @@
<if test="id != null"> <if test="id != null">
id, id,
</if> </if>
<if test="type != null"> <if test="equipmentId != null">
type, equipment_id,
</if> </if>
<if test="stages != null"> <if test="stages != null">
stages, stages,
@ -148,8 +148,8 @@
<if test="id != null"> <if test="id != null">
#{id,jdbcType=BIGINT}, #{id,jdbcType=BIGINT},
</if> </if>
<if test="type != null"> <if test="equipmentId != null">
#{type,jdbcType=TINYINT}, #{equipmentId,jdbcType=BIGINT},
</if> </if>
<if test="stages != null"> <if test="stages != null">
#{stages,jdbcType=TINYINT}, #{stages,jdbcType=TINYINT},
@ -186,8 +186,8 @@
<if test="record.id != null"> <if test="record.id != null">
id = #{record.id,jdbcType=BIGINT}, id = #{record.id,jdbcType=BIGINT},
</if> </if>
<if test="record.type != null"> <if test="record.equipmentId != null">
type = #{record.type,jdbcType=TINYINT}, equipment_id = #{record.equipmentId,jdbcType=BIGINT},
</if> </if>
<if test="record.stages != null"> <if test="record.stages != null">
stages = #{record.stages,jdbcType=TINYINT}, stages = #{record.stages,jdbcType=TINYINT},
@ -218,7 +218,7 @@
<update id="updateByExample" parameterType="map"> <update id="updateByExample" parameterType="map">
update t_threshold_value update t_threshold_value
set id = #{record.id,jdbcType=BIGINT}, set id = #{record.id,jdbcType=BIGINT},
type = #{record.type,jdbcType=TINYINT}, equipment_id = #{record.equipmentId,jdbcType=BIGINT},
stages = #{record.stages,jdbcType=TINYINT}, stages = #{record.stages,jdbcType=TINYINT},
max = #{record.max,jdbcType=INTEGER}, max = #{record.max,jdbcType=INTEGER},
min = #{record.min,jdbcType=INTEGER}, min = #{record.min,jdbcType=INTEGER},
@ -233,8 +233,8 @@
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValue"> <update id="updateByPrimaryKeySelective" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValue">
update t_threshold_value update t_threshold_value
<set> <set>
<if test="type != null"> <if test="equipmentId != null">
type = #{type,jdbcType=TINYINT}, equipment_id = #{equipmentId,jdbcType=BIGINT},
</if> </if>
<if test="stages != null"> <if test="stages != null">
stages = #{stages,jdbcType=TINYINT}, stages = #{stages,jdbcType=TINYINT},
@ -262,7 +262,7 @@
</update> </update>
<update id="updateByPrimaryKey" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValue"> <update id="updateByPrimaryKey" parameterType="com.ccsens.beneficiation.bean.po.ThresholdValue">
update t_threshold_value update t_threshold_value
set type = #{type,jdbcType=TINYINT}, set equipment_id = #{equipmentId,jdbcType=BIGINT},
stages = #{stages,jdbcType=TINYINT}, stages = #{stages,jdbcType=TINYINT},
max = #{max,jdbcType=INTEGER}, max = #{max,jdbcType=INTEGER},
min = #{min,jdbcType=INTEGER}, min = #{min,jdbcType=INTEGER},

41
util/src/test/java/com/ccsens/util/OtherTest.java

@ -2,6 +2,7 @@ package com.ccsens.util;
import cn.hutool.core.util.ImageUtil; import cn.hutool.core.util.ImageUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
@ -11,7 +12,10 @@ import javax.script.ScriptException;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List;
@Slf4j @Slf4j
public class OtherTest { public class OtherTest {
@ -65,4 +69,41 @@ public class OtherTest {
System.out.println(aa + "++++" + bb); System.out.println(aa + "++++" + bb);
System.out.println(aa1 + "++++" + bb1); System.out.println(aa1 + "++++" + bb1);
} }
@Data
public static class AA{
private int a;
private int b;
public AA(int a, int b) {
this.a = a;
this.b = b;
}
public AA() {
}
}
@Test
public void test6() {
AA a1 = new AA(1,4);
AA a2 = new AA(2,3);
AA a3 = new AA(2,2);
AA a4 = new AA(4,1);
List<AA> aas = new ArrayList<>();
aas.add(a3);
aas.add(a4);
aas.add(a1);
aas.add(a2);
aas.sort(Comparator.comparingInt(o -> o.a));
aas.forEach(aa -> {
System.out.print(aa.a);
});
System.out.println("");
aas.forEach(aa -> {
System.out.print(aa.b);
});
}
} }

Loading…
Cancel
Save