ZzglBmgwM.java 3.52 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5 6 7
package cn.timer.api.bean.zzgl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Stream;

8
import javax.persistence.*;
yuquan.zhu committed
9

10
import cn.timer.api.bean.yggl.YgglMainEmp;
11
import com.alibaba.druid.sql.ast.expr.SQLCaseExpr.Item;
yuquan.zhu committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Tang 2019-11-17
 */
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "zzgl_bmgw_m")
@ApiModel("部门岗位表")
public class ZzglBmgwM extends Model<ZzglBmgwM> {

37 38
	private static final long serialVersionUID = -3467488578145579513L;

yuquan.zhu committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
	@Id
	@GeneratedValue
	@TableId(type = IdType.AUTO)
	@ApiModelProperty(value = "编号", example = "101")
	private Integer id;

	@ApiModelProperty(value = "组织机构代码 企业中心(企业信息id)", example = "101")
	private Integer orgCode;

	@ApiModelProperty(value = "上级部门id 上级部门id", example = "101")
	private Integer upId;

	@ApiModelProperty(value = "名称 ", example = "名称")
	private String name;

	@ApiModelProperty(value = "状态 状态 0:正常1:关闭", example = "0")
	private Integer sts;

	@ApiModelProperty(value = "是否管理者 0:超管;1:管理员;2:员工", example = "1")
	private Integer isAdmin;

	@ApiModelProperty(value = "是否可修改 是否可修改 0:否 1:是", example = "0")
	private Integer isUpdate;

	@ApiModelProperty(value = "类型 0:部门;1:岗位", example = "0")
	private Integer type;

	@ApiModelProperty(value = "备注 ", example = "备注")
	private String remark;

69 70 71
	@ApiModelProperty(value = "部门领导id ", example = "9688")
	private Integer leader;

yuquan.zhu committed
72 73 74 75 76 77 78 79
	@TableField(fill = FieldFill.UPDATE)
	@ApiModelProperty(value = "更新时间 ", example = "2019-10-01")
	private Date updateTime;

	@TableField(fill = FieldFill.INSERT)
	@ApiModelProperty(value = "创建时间 ", example = "2019-10-01")
	private Date createTime;

80 81 82 83 84
	@Transient
	@TableField(exist = false)
	@ApiModelProperty(value = "员工列表")
	private List<YgglMainEmp> userList;

yuquan.zhu committed
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
	// 遍历,获取旗下所有子部门和岗位id
	public static void getupDepts(ArrayList<Integer> list, Integer objId, List<ZzglBmgwM> objs) {
		if (objId != null) {
			list.add(objId);
			Stream<ZzglBmgwM> s = objs.stream().filter(item -> objId.equals(item.getId()));
			if (s != null)
				s.forEach(zzglBmgwM -> {
					getupDepts(list, zzglBmgwM.getUpId(), objs);
				});
		}
	}

	// 遍历,获取旗下所有子部门和岗位id(weng)
	public static void getDepts(ArrayList<Integer> list, Integer objId, List<ZzglBmgwM> objs) {
		if (objId != null) {
		objs.stream().filter(item -> objId.equals(item.getUpId())).forEach(zzglBmgwM -> {
			list.add(zzglBmgwM.getId());
			getDepts(list, zzglBmgwM.getId(), objs);
		});
		}
	}
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
	// 遍历,获取该员工所有上级部门(weng)
	public static void getUpDepts(ArrayList<Integer> list, Integer objId, List<ZzglBmgwM> objs) {//7290
		if (objId != null) {
			for (ZzglBmgwM bmgw : objs) {
				Integer bmgwId = bmgw.getId();
				Integer upId = bmgw.getUpId();
				if (bmgwId.equals(objId)) {
					list.add(bmgwId);
					if (upId!=null) {
						getUpDepts(list, upId, objs);
					}
				}
			}
		}
	}
121 122 123 124



}