233 lines
4.7 KiB
Java
233 lines
4.7 KiB
Java
package com.vverp.entity;
|
|
|
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
import com.vverp.annotation.Module;
|
|
import com.vverp.base.Setting;
|
|
import com.vverp.moli.util.SpringUtils;
|
|
import com.vverp.service.DepartmentService;
|
|
|
|
import javax.persistence.*;
|
|
import java.math.BigDecimal;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* Entity - 部门
|
|
*
|
|
* @author dealsky
|
|
* @date 2020/3/11 9:28 上午
|
|
*/
|
|
@Entity
|
|
@Table(name = "t_department")
|
|
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "seq_department")
|
|
@Module(generate = false, name = "部门")
|
|
public class Department extends BaseEntity<Long> {
|
|
|
|
/**
|
|
* 名称
|
|
*/
|
|
@Excel(name = "部门名称_admin", orderNum = "7_admin", needMerge = true)
|
|
private String name;
|
|
|
|
/**
|
|
* 父级id
|
|
*/
|
|
private Long parentId;
|
|
|
|
/**
|
|
* 部门级数
|
|
*/
|
|
private Integer level;
|
|
|
|
/**
|
|
* 排序因子
|
|
*/
|
|
private Integer sortFactor;
|
|
|
|
/**
|
|
* 链
|
|
*/
|
|
private String chain;
|
|
|
|
/**
|
|
* 管理员列表
|
|
*/
|
|
private List<Admin> adminList;
|
|
|
|
/**
|
|
* 主管
|
|
*/
|
|
private String director;
|
|
|
|
/**
|
|
* 主管实体
|
|
*/
|
|
private Admin directorEntity;
|
|
|
|
/**
|
|
* 是否为公司
|
|
*/
|
|
private Boolean companyFlag = Boolean.FALSE;
|
|
|
|
/**
|
|
* 地址
|
|
*/
|
|
private String address;
|
|
|
|
/**
|
|
* 纬度
|
|
*/
|
|
private BigDecimal lat;
|
|
|
|
/**
|
|
* 经度
|
|
*/
|
|
private BigDecimal lng;
|
|
|
|
/**
|
|
* 签到范围(km)
|
|
*/
|
|
private BigDecimal scope;
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
@Transient
|
|
@JsonIgnore
|
|
public String getFullName() {
|
|
Long parentId = this.parentId;
|
|
StringBuilder stringBuilder = new StringBuilder(name);
|
|
while (parentId != null) {
|
|
Department department = SpringUtils.getBean(DepartmentService.class).find(parentId);
|
|
stringBuilder.insert(0, department.getName() + " - ");
|
|
parentId = department.getParentId();
|
|
}
|
|
return stringBuilder.toString();
|
|
}
|
|
|
|
public Long getParentId() {
|
|
return parentId;
|
|
}
|
|
|
|
public void setParentId(Long parentId) {
|
|
this.parentId = parentId;
|
|
}
|
|
|
|
public Integer getLevel() {
|
|
return level;
|
|
}
|
|
|
|
public void setLevel(Integer level) {
|
|
this.level = level;
|
|
}
|
|
|
|
public Integer getSortFactor() {
|
|
return sortFactor;
|
|
}
|
|
|
|
public void setSortFactor(Integer sortFactor) {
|
|
this.sortFactor = sortFactor;
|
|
}
|
|
|
|
public String getChain() {
|
|
return chain;
|
|
}
|
|
|
|
public void setChain(String chain) {
|
|
this.chain = chain;
|
|
}
|
|
|
|
@JsonIgnore
|
|
@OneToMany(mappedBy = "department", cascade = CascadeType.REMOVE)
|
|
public List<Admin> getAdminList() {
|
|
return adminList;
|
|
}
|
|
|
|
public void setAdminList(List<Admin> adminList) {
|
|
this.adminList = adminList;
|
|
}
|
|
|
|
public String getDirector() {
|
|
return director;
|
|
}
|
|
|
|
public void setDirector(String director) {
|
|
this.director = director;
|
|
}
|
|
|
|
@JsonIgnore
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
public Admin getDirectorEntity() {
|
|
return directorEntity;
|
|
}
|
|
|
|
public void setDirectorEntity(Admin directorEntity) {
|
|
this.directorEntity = directorEntity;
|
|
}
|
|
|
|
public Boolean getCompanyFlag() {
|
|
return companyFlag != null ? companyFlag : Boolean.FALSE;
|
|
}
|
|
|
|
public void setCompanyFlag(Boolean companyFlag) {
|
|
this.companyFlag = companyFlag;
|
|
}
|
|
|
|
public String getAddress() {
|
|
return address;
|
|
}
|
|
|
|
public void setAddress(String address) {
|
|
this.address = address;
|
|
}
|
|
|
|
@Column(precision = 19, scale = 6)
|
|
public BigDecimal getLat() {
|
|
return lat;
|
|
}
|
|
|
|
public void setLat(BigDecimal lat) {
|
|
this.lat = lat;
|
|
}
|
|
|
|
@Column(precision = 19, scale = 6)
|
|
public BigDecimal getLng() {
|
|
return lng;
|
|
}
|
|
|
|
public void setLng(BigDecimal lng) {
|
|
this.lng = lng;
|
|
}
|
|
|
|
@Column(precision = 19, scale = 6)
|
|
public BigDecimal getScope() {
|
|
return Setting.setScale(scope);
|
|
}
|
|
|
|
public void setScope(BigDecimal scope) {
|
|
this.scope = scope;
|
|
}
|
|
|
|
@Transient
|
|
@JsonIgnore
|
|
public Admin getDirectorEntityLatest() {
|
|
Admin admin = getDirectorEntity();
|
|
while (admin == null) {
|
|
if (parentId != null) {
|
|
Department department = SpringUtils.getBean(DepartmentService.class).find(parentId);
|
|
admin = department.getDirectorEntity();
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return admin;
|
|
}
|
|
|
|
}
|