package com.coffee.bus.entity; import cn.hutool.crypto.asymmetric.Sign; 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.DeviceTypeEnum; 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 lombok.experimental.Accessors; import javax.validation.constraints.DecimalMax; import javax.validation.constraints.DecimalMin; import javax.validation.constraints.Max; import javax.validation.constraints.Min; import java.math.BigDecimal; import java.util.Date; /** * @author 龙三郎 * @version 1.0.0 * @ClassName BusDeviceUseEntity.java * @Description TODO * @createTime 2022年03月30日 11:01:00 */ @ToString @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) @TableName(value = "bus_infusion_modify",autoResultMap = true) @ApiModel(value="设备输注参数修改记录", description="当输注参数发生修改时,在此表中进行记录") public class BusInfusionModifyEntity extends CommonDeviceParam { // @ApiModelProperty(value = "网络泵id",readOnly = true) // private String deviceId; @ApiModelProperty(value = "输注记录") private String infusionId; // @ApiModelProperty(value = "泵类型",readOnly = true) // @TableField(updateStrategy = FieldStrategy.NEVER) // private DeviceTypeEnum type; // @ApiModelProperty(value = "总量",readOnly = true) // @Max(value = 999,message = "总量最大值不得超过999") // @Min(value = 0,message ="总量最小值不得超过0" ) // private Integer totalDose; // // @ApiModelProperty(value = "公共参数-首次量",readOnly = true) // @Max(value = 50,message = "首次量最大值不得超过50") // @Min(value = 0,message ="首次量最小值不得超过0" ) // private Integer firstDose; // // @ApiModelProperty(value = "公共参数-剩余量",readOnly = true) // private BigDecimal remainDose; // // @ApiModelProperty(value = "公共参数-已输入量",readOnly = true) // private BigDecimal inputDose; // // @ApiModelProperty(value = "公共参数-追加量",readOnly = true) // @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10") // @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" ) // private BigDecimal appendDose; // // @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true) // @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99") // @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" ) // private BigDecimal appendLockTime; // // @ApiModelProperty(value = "公共参数-极限量",readOnly = true) // @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90") // @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" ) // private BigDecimal maxDose; // // @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true) // private Integer selfControlLockTime; // // @ApiModelProperty(value = "公共参数-自控次数",readOnly = true) // private Integer selfControlCount; // // @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true) // private Integer pcaValidCount; // // @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true) // private Integer pcaInvalidCount; // // @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true) // private Integer pcaTotalCount; // // @ApiModelProperty(value = "持续泵参数-持续量",readOnly = true) // @DecimalMax(value = "50",message = "持续给液量最大值不得超过50") // @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" ) // private BigDecimal continueDose; // // @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true) // @Max(value = 20,message = "脉冲量最大值不得超过20") // @Min(value = 0,message ="脉冲量最小值不得超过0" ) // private Integer pulseDose; // // @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true) // @Max(value = 90,message = "脉冲锁时最大值不得超过90") // @Min(value = 30,message ="脉冲锁时最小值不得超过30" ) // private Integer pulseLockTime; // // @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true) // @Max(value = 60,message = "脉冲首次锁时最大值不得超过60") // @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" ) // private Integer pulseFirstLockTime; // // @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true) // @DecimalMax(value = "10",message = "加档周期最大值不得超过10") // @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" ) // private BigDecimal flowUpCycle; // // @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true) // @DecimalMax(value = "10",message = "减档周期最大值不得超过10") // @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" ) // private BigDecimal flowDownCycle; // // @ApiModelProperty(value = "智能泵参数-计次",readOnly = true) // @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10") // @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" ) // private BigDecimal flowCount; // // @ApiModelProperty(value = "智能泵参数-上限",readOnly = true) // @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90") // @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" ) // private BigDecimal flowUpLimit; // // @ApiModelProperty(value = "智能泵参数-下限",readOnly = true) // @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50") // @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" ) // private BigDecimal flowDownLimit; // // @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true) // @DecimalMax(value = "95",message = "自调比例不得超过95") // @DecimalMin(value = "0",message ="自调比例最小值不得超过0" ) // private BigDecimal flowAdjustRate; @ApiModelProperty(value = "参数修改时间") private Date modifyTime; // @ApiModelProperty(value = "分包标记位",readOnly = true) // @JsonIgnoreProperties(allowSetters = true) // private String classification; public static BusInfusionModifyEntity parseRunningInfo(BusDeviceRunningEntity running){ BusInfusionModifyEntity entity = new BusInfusionModifyEntity(); entity.setDeviceId(running.getDeviceId()); entity.setTenantId(running.getTenantId()); entity.setInfusionId(running.getInfusionId()); entity.setType(running.getType()); entity.setClassification(running.getClassification()); entity.setTotalDose(running.getTotalDose()); entity.setFirstDose(running.getFirstDose()); entity.setRemainDose(running.getRemainDose()); entity.setInputDose(running.getInputDose()); entity.setContinueDose(running.getContinueDose()); entity.setAppendDose(running.getAppendDose()); entity.setMaxDose(running.getMaxDose()); entity.setSelfControlLockTime(running.getSelfControlLockTime()); entity.setSelfControlCount(running.getSelfControlCount()); entity.setPcaValidCount(running.getPcaValidCount()); entity.setPcaInvalidCount(running.getPcaInvalidCount()); entity.setPcaTotalCount(running.getPcaTotalCount()); /** * 脉冲泵参数 */ entity.setPulseDose(running.getPulseDose()); entity.setPulseFirstLockTime(running.getPulseFirstLockTime()); entity.setPulseLockTime(running.getPulseLockTime()); /** * 智能泵参数 */ entity.setFlowAdjustRate(running.getFlowAdjustRate()); entity.setFlowCount(running.getFlowCount()); entity.setFlowDownCycle(running.getFlowDownCycle()); entity.setFlowUpCycle(running.getFlowUpCycle()); entity.setFlowDownLimit(running.getFlowDownLimit()); entity.setFlowUpLimit(running.getFlowUpLimit()); entity.setModifyTime(running.getUploadTime()); return entity; } public String signParam(Sign sign){ //保证参数有序 JSONObject param = new JSONObject(true); //加密过程中,加入分包标识,保证新的输注的输注参数必定发生改变 switch (this.getType()){ case continuous: param.putOpt("continueDose",this.getContinueDose()); param.putOpt("firstDose",this.getFirstDose()); param.putOpt("appendDose",this.getAppendDose()); param.putOpt("appendLockTime",this.getAppendLockTime()); param.putOpt("maxDose",this.getMaxDose()); param.putOpt("classification",this.getClassification()); break; case pulse: param.putOpt("firstDose",this.getFirstDose()); param.putOpt("firstLockTime",this.getPulseFirstLockTime()); param.putOpt("continueDose",this.getContinueDose()); param.putOpt("pulseDose",this.getPulseDose()); param.putOpt("lockTime",this.getPulseLockTime()); param.putOpt("appendDose",this.getAppendDose()); param.putOpt("appendLockTime",this.getAppendLockTime()); param.putOpt("maxDose",this.getMaxDose()); param.putOpt("classification",this.getClassification()); break; case intelligent: param.putOpt("firstDose",this.getFirstDose()); param.putOpt("appendDose",this.getAppendDose()); param.putOpt("appendLockTime",this.getAppendLockTime()); param.putOpt("flowUpCycle",this.getFlowUpCycle()); param.putOpt("flowCount",this.getFlowCount()); param.putOpt("flowDownCycle",this.getFlowDownCycle()); param.putOpt("flowAdjustRate",this.getFlowAdjustRate()); param.putOpt("flowUpLimit",this.getFlowUpLimit()); param.putOpt("flowDownLimit",this.getFlowDownLimit()); param.putOpt("continueDose",this.getContinueDose()); param.putOpt("maxDose",this.getMaxDose()); param.putOpt("classification",this.getClassification()); break; default:break; } return sign.signHex(param.toString()); } }