Java tutorial
/** * @(#)AlarmRecords.java 1.0 14:34:51 * Copyright 2015 bjth, Inc. All rights reserved. * attech PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package com.sccl.attech.modules.message.entity; import java.util.Date; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; import javax.validation.constraints.NotNull; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFoundAction; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; import com.sccl.attech.common.persistence.IdEntity; import com.sccl.attech.common.utils.excel.annotation.ExcelField; import com.sccl.attech.modules.sys.entity.Office; import com.sccl.attech.modules.sys.entity.User; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; /** * * @author deng * */ @Entity @Table(name = "alarm_records") @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) public class AlarmRecords extends IdEntity<AlarmRecords> { private static final long serialVersionUID = -1787044004512094684L; /** The state . */ public static String STATE_NOREAD = "0"; /** The state . */ private static String STATE_READ = "1"; private Office company; //? private Office office; // private User user; // private String name;//?? private String type; //0?1? private String content;// private String state;//?01 private String location_desc;//? private Date location_date;//? private String typeName;//excel public final static String ALARM_RECORD_TYPE = "0"; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "company_id") @NotFound(action = NotFoundAction.IGNORE) @JsonIgnore @NotNull @ExcelField(title = "?", align = 2, sort = 30) public Office getCompany() { return company; } public void setCompany(Office company) { this.company = company; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "offiec_id") @NotFound(action = NotFoundAction.IGNORE) @JsonIgnore @NotNull @ExcelField(title = "", align = 2, sort = 30) public Office getOffice() { return office; } public void setOffice(Office office) { this.office = office; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") @NotFound(action = NotFoundAction.IGNORE) @JsonIgnore @NotNull public User getUser() { return user; } public void setUser(User user) { this.user = user; } @ExcelField(title = "", align = 2, sort = 30) public String getName() { return name; } public void setName(String name) { this.name = name; } public String getType() { return type; } public void setType(String type) { this.type = type; } @Transient @ExcelField(title = "", align = 2, sort = 40) public String getTypeName() { if ("1".equals(type)) { typeName = "?"; } else if ("0".equals(type)) { typeName = "?"; } return typeName; } @ExcelField(title = "", align = 2, sort = 50) public String getContent() { return content; } public void setContent(String content) { this.content = content; } @ExcelField(title = "??", align = 2, sort = 30) public String getLocation_desc() { return location_desc; } public void setLocation_desc(String location_desc) { this.location_desc = location_desc; } @Temporal(TemporalType.TIMESTAMP) @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @ExcelField(title = "", align = 2, sort = 40) public Date getLocation_date() { return location_date; } public void setLocation_date(Date location_date) { this.location_date = location_date; } public String getState() { return state; } public void setState(String state) { this.state = state; } public void initByUser(User user) { this.name = user.getName(); this.company = user.getCompany(); this.office = user.getOffice(); this.state = AlarmRecords.STATE_NOREAD;// this.location_date = new Date(); } public static final String ALARM_STATE_READ = "1"; public static final String ALARM_STATE_NOTREAD = "0"; /** * @see java.lang.Object#toString() */ public String toString() { return new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE).append("id", this.id) .append("typeName", this.typeName).append("content", this.content).append("office", this.office) .append("name", this.name).append("company", this.company).append("state", this.state) .append("location_date", this.location_date).append("location_desc", this.location_desc) .append("type", this.type).append("user", this.user).toString(); } }