| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- package com.coffee.bus.entity;
- import cn.hutool.json.JSONObject;
- import com.baomidou.mybatisplus.annotation.FieldStrategy;
- import com.baomidou.mybatisplus.annotation.TableField;
- import com.baomidou.mybatisplus.annotation.TableName;
- import com.coffee.bus.entity.common.CommonDeviceParam;
- import com.coffee.bus.enums.DeviceAlarmEnum;
- import com.coffee.bus.enums.DeviceStatusEnum;
- import com.coffee.bus.enums.DeviceTypeEnum;
- import com.coffee.bus.enums.FlowStatusEnum;
- import com.coffee.common.entity.TenantGenericEntity;
- import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
- import io.swagger.annotations.ApiModel;
- import io.swagger.annotations.ApiModelProperty;
- import lombok.Data;
- import lombok.EqualsAndHashCode;
- import lombok.ToString;
- import org.tio.utils.crypto.Md5;
- import java.util.Date;
- /**
- * @author lifang
- * @version 1.0.0
- * @ClassName BusDeviceAlarmEntity.java
- * @Description 设备报警信息
- * @createTime 2022年04月08日 16:18:00
- */
- @EqualsAndHashCode(callSuper = true)
- @Data
- @TableName(value = "bus_device_alarm",autoResultMap = true)
- @ApiModel(value="设备报警信息", description="设备报警信息记录")
- @ToString
- public class BusDeviceAlarmEntity extends TenantGenericEntity<String,String> {
- @ApiModelProperty(value = "设备唯一编码",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- private String deviceId;
- @ApiModelProperty(value = "报警时间")
- private Date uploadTime;
- @ApiModelProperty(value = "报警原因")
- private String cause;
- @ApiModelProperty(value = "是否为报警信息",hidden = true)
- @JsonIgnoreProperties
- private Boolean alarm;
- @ApiModelProperty(value = "报警记录所绑定的历史记录id,后续用于更新操作",hidden = true)
- @JsonIgnoreProperties(allowSetters = true)
- private String historyId;
- @ApiModelProperty(value = "输注记录")
- private String infusionId;
- @ApiModelProperty(value = "设备类型")
- private DeviceTypeEnum deviceType;
- @ApiModelProperty(value = "泵运行状态",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- @TableField(updateStrategy = FieldStrategy.IGNORED)
- private DeviceStatusEnum runState;
- @ApiModelProperty(value = "报警信息",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- @TableField(updateStrategy = FieldStrategy.IGNORED)
- private DeviceAlarmEnum alarmState;
- @ApiModelProperty(value = "输注即将结束提醒",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- @TableField(updateStrategy = FieldStrategy.IGNORED)
- private Boolean warnWillFinished;
- @ApiModelProperty(value = "镇痛不足提醒",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- @TableField(updateStrategy = FieldStrategy.IGNORED)
- private Boolean warnAnalgesicPoor;
- @ApiModelProperty(value = "电量偏低提醒",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- @TableField(updateStrategy = FieldStrategy.IGNORED)
- private Boolean warnLowBattery;
- @ApiModelProperty(value = "加减档提示",accessMode = ApiModelProperty.AccessMode.READ_ONLY)
- @TableField(updateStrategy = FieldStrategy.IGNORED)
- private FlowStatusEnum warnFlow;
- public static BusDeviceAlarmEntity parseHistory(BusDeviceHistoryEntity history){
- BusDeviceAlarmEntity entity = new BusDeviceAlarmEntity();
- entity.setDeviceId(history.getDeviceId());
- entity.setUploadTime(history.getUploadTime());
- if (history.getAlarm() != null && !DeviceAlarmEnum.None.equals(history.getAlarm())) {
- entity.setAlarm(true);
- }
- entity.setHistoryId(history.getId());
- entity.setInfusionId(history.getInfusionId());
- entity.setRunState(history.getRunState());
- entity.setAlarmState(history.getAlarm());
- entity.setWarnWillFinished(history.getWarnWillFinished());
- entity.setWarnAnalgesicPoor(history.getWarnAnalgesicPoor());
- entity.setWarnLowBattery(history.getWarnLowBattery());
- entity.setWarnFlow(history.getWarnFlow());
- entity.setTenantId(history.getTenantId());
- entity.setDeviceType(history.getType());
- return entity;
- }
- public static BusDeviceAlarmEntity parseRunning(BusInfusionHistoryEntity source){
- BusDeviceAlarmEntity entity = new BusDeviceAlarmEntity();
- entity.setDeviceId(source.getDeviceId());
- entity.setUploadTime(source.getLastUploadTime());
- if (source.getAlarm() != null && !DeviceAlarmEnum.None.equals(source.getAlarm())) {
- entity.setAlarm(true);
- }
- entity.setHistoryId(source.getId());
- entity.setInfusionId(source.getId());
- entity.setRunState(source.getRunState());
- entity.setAlarmState(source.getAlarm());
- entity.setWarnWillFinished(source.getWarnWillFinished());
- entity.setWarnAnalgesicPoor(source.getWarnAnalgesicPoor());
- entity.setWarnLowBattery(source.getWarnLowBattery());
- entity.setWarnFlow(source.getWarnFlow());
- entity.setTenantId(source.getTenantId());
- entity.setDeviceType(source.getType());
- return entity;
- }
- public String signParm(){
- JSONObject param = new JSONObject(true);
- param.putOpt("runState",String.valueOf(this.getRunState()));
- param.putOpt("alarmState",String.valueOf(this.getAlarmState()));
- param.putOpt("warnWillFinished",String.valueOf(this.getWarnWillFinished()));
- param.putOpt("warnAnalgesicPoor",String.valueOf(this.getWarnAnalgesicPoor()));
- param.putOpt("warnLowBattery",String.valueOf(this.getWarnLowBattery()));
- param.putOpt("warnFlow",String.valueOf(this.getWarnFlow()));
- return Md5.getMD5(param.toString());
- }
- public static boolean alarmOrWarn(CommonDeviceParam history){
- if (history.getAlarm() != null && !DeviceAlarmEnum.None.equals(history.getAlarm())) {
- return true;
- }
- if (Boolean.TRUE.equals(history.getWarnAnalgesicPoor())) {
- return true;
- }
- if (Boolean.TRUE.equals(history.getWarnLowBattery())) {
- return true;
- }
- if (Boolean.TRUE.equals(history.getWarnWillFinished())) {
- return true;
- }
- return history.getWarnFlow()!=null;
- }
- public static BusDeviceAlarmEntity noSignalOf(String deviceId,String infusionId,String historyId,String tenantId,Date uploadTIme){
- BusDeviceAlarmEntity result = of(deviceId,infusionId,historyId,tenantId,uploadTIme);
- result.setRunState(DeviceStatusEnum.NoSignal);
- return result;
- }
- public static BusDeviceAlarmEntity lowInfusion(String deviceId,String infusionId,String historyId,String tenantId,Date uploadTIme){
- BusDeviceAlarmEntity result = of(deviceId,infusionId,historyId,tenantId,uploadTIme);
- result.setWarnFlow(FlowStatusEnum.Lowest);
- return result;
- }
- public static BusDeviceAlarmEntity insufficient(String deviceId,String infusionId,String historyId,String tenantId,Date uploadTIme){
- BusDeviceAlarmEntity result = of(deviceId,infusionId,historyId,tenantId,uploadTIme);
- result.setWarnAnalgesicPoor(true);
- return result;
- }
- private static BusDeviceAlarmEntity of(String deviceId,String infusionId,String historyId,String tenantId,Date uploadTIme){
- BusDeviceAlarmEntity result = new BusDeviceAlarmEntity();
- result.setRunState(DeviceStatusEnum.Waiting);
- result.setInfusionId(infusionId);
- result.setTenantId(tenantId);
- result.setUploadTime(uploadTIme);
- result.setHistoryId(historyId);
- result.setAlarm(false);
- result.setAlarmState(DeviceAlarmEnum.None);
- result.setDeviceId(deviceId);
- result.setWarnLowBattery(false);
- result.setWarnFlow(FlowStatusEnum.None);
- result.setWarnAnalgesicPoor(false);
- result.setWarnWillFinished(false);
- return result;
- }
- }
|