package com.yanzhu.jh.project.domain;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

import java.util.Date;
import java.util.List;

/**
 * 考勤人员基本属性对象 sur_project_attendance_user
 * 
 * @author ruoyi
 * @date 2023-09-24
 */
public class SurProjectAttendanceUser extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /**  */
    private Long id;

    /** 配置项ID,可以获取项目ID和总包ID */
    @Excel(name = "配置项ID,可以获取项目ID和总包ID")
    private Long cfgid;

    /** 注册应用ID */
    @Excel(name = "注册应用ID")
    private String appId;

    /** 厂商编号参考字典attendance_vendors */
    @Excel(name = "厂商编号参考字典attendance_vendors")
    private String vendorsCode;

    /** 工人id */
    @Excel(name = "工人id")
    private String workerId;

    /** 项目工人履历id对于旧劳务，这个字段相当于工人的projectWorkerId，管理人员的registerManagerId */
    @Excel(name = "项目工人履历id对于旧劳务，这个字段相当于工人的projectWorkerId，管理人员的registerManagerId")
    private Long laborWorkerId;

    /** 人员类别0：工人，1：管理人员 */
    @Excel(name = "人员类别0：工人，1：管理人员")
    private Long workerCategory;

    /** 工号 */
    @Excel(name = "工号")
    private Long qrCode;

    /** 姓名 */
    @Excel(name = "姓名")
    private String name;

    /** 民族 */
    @Excel(name = "民族")
    private String ethnic;

    /** 籍贯 */
    @Excel(name = "籍贯")
    private String nativePlace;

    /** 性别0:男 1:女 */
    @Excel(name = "性别0:男 1:女")
    private Long gender;

    /** 出生日期时间戳 */
    @Excel(name = "出生日期时间戳")
    private Long birthDate;

    /** 联系电话 */
    @Excel(name = "联系电话")
    private String phone;

    /** 学历 */
    @Excel(name = "学历")
    private String degreeName;

    /** 身份证照 */
    @Excel(name = "身份证照")
    private String photo;

    /** 近照 */
    @Excel(name = "近照")
    private String recentPhoto;

    /** 所属班组ID */
    @Excel(name = "所属班组ID")
    private String groupId;

    /** 所属班组 */
    @Excel(name = "所属班组")
    private String groupName;

    /** 是否班组长 */
    @Excel(name = "是否班组长")
    private Integer leader;

    /** 工种编码 */
    @Excel(name = "工种编码")
    private String workTypeCode;

    /** 工种 */
    @Excel(name = "工种")
    private String workTypeName;

    /** 是否特殊工种 */
    @Excel(name = "是否特殊工种")
    private Integer specWorkType;

    /** 安全帽编号 */
    @Excel(name = "安全帽编号")
    private String hatCode;

    /** 进退场状态0:进场，1:退场 */
    @Excel(name = "进退场状态0:进场，1:退场")
    private Long state;

    /** 进场日期 */
    @Excel(name = "进场日期")
    private String enterDate;

    /** 退场日期 */
    @Excel(name = "退场日期")
    private String exitDate;

    /** 分包商id */
    @Excel(name = "分包商id")
    private String companyId;

    /** 分包商名称 */
    @Excel(name = "分包商名称")
    private String companyName;

    /** 平台对应分包商ID */
    @Excel(name = "平台对应分包商ID")
    private Long vendorId;

    /** 队伍id */
    @Excel(name = "队伍id")
    private Integer teamId;

    /** 队伍名称 */
    @Excel(name = "队伍名称")
    private String teamName;

    /** 进场方式0:自动,1:手动2:拍照 */
    @Excel(name = "进场方式0:自动,1:手动2:拍照")
    private String enterType;

    /** 服务返回的JSON */
    @Excel(name = "服务返回的JSON")
    private String other;

    /** 是否有效 */
    @Excel(name = "是否有效")
    private Long isDel;

    /** 人员部门类型 */
    @Excel(name = "人员部门类型")
    private String companyTypeId;

    /** 重要::yanzhu接口接收base64图片 */
    private String recentPhotoBase64;

    public String getRecentPhotoBase64() {
        return recentPhotoBase64;
    }

    public void setRecentPhotoBase64(String recentPhotoBase64) {
        this.recentPhotoBase64 = recentPhotoBase64;
    }

    private Date inTime;
    private Date outTime;

    public static SurProjectAttendanceUser createFromHuazhu(JSONObject j) {
        SurProjectAttendanceUser u=new SurProjectAttendanceUser();
        u.workerId=j.getString("id");
        u.name=j.getString("name");
        u.ethnic=j.getString("nationalName");
        u.nativePlace=j.getString("provinceName")+j.getString("cityName");
        u.gender=j.getLongValue("sex",0);
        u.birthDate=j.getLongValue("birthday",0);
        u.phone=j.getString("phone");
        u.degreeName=j.getString("levelOfEducation");
        u.recentPhoto=j.getString("profile");
        u.groupId=j.getString("teamId");
        u.groupName=j.getString("teamName");
        u.workTypeCode=j.getString("workerTypeId");
        u.workTypeName=j.getString("workerTypeName");
        u.state=j.getLongValue("status",1)==2l?0l:1l;
        long enterTime=j.getLong("enterTime");
        if(enterTime>0){
            u.enterDate= DateUtil.format(DateUtil.date(enterTime),"yyyy-MM-dd HH:mm:ss");
        }
        long leaveTime=j.getLong("leaveTime");
        if(leaveTime>0) {
            u.exitDate = DateUtil.format(DateUtil.date(leaveTime), "yyyy-MM-dd HH:mm:ss");
        }
        u.vendorId=j.getLongValue("unitProjectId",0);
        u.companyId=""+j.getLongValue("unitId",0);
        u.companyName=j.getString("unitName");
        u.teamName=j.getString("teamName");
        return u;
    }

    public static SurProjectAttendanceUser createFromJgw(JSONObject j) {
        SurProjectAttendanceUser u=new SurProjectAttendanceUser();
        u.workerId=j.getString("workerId");
        u.name=j.getString("name");
        u.ethnic=j.getString("minor");
        u.phone=j.getString("workPhone");
        u.nativePlace=j.getString("address");
        u.gender=j.getLong("sex")==0l?1l:0l;
        String tmp=j.getString("birthday");
        if(StrUtil.isNotEmpty(tmp)) {
            try {
                u.birthDate = DateUtil.parse(tmp).getTime();
            }catch (Exception ex){

            }
        }
        u.photo=j.getString("headImage");
        u.degreeName=j.getString("education");
        u.recentPhoto=j.getString("vaildPhoto");
        u.groupId="";
        u.groupName="";
        u.workTypeCode="";
        u.workTypeName=j.getString("jobtype");
        u.state="01".equals( j.getString("workerStatus"))?0l:1l;
        String workDate=j.getString("workDate");
        if(!StrUtil.isEmpty(workDate)){
            u.enterDate=workDate;
        }
        u.vendorId=0l;
        u.companyId=j.getString("subcontractorId");
        u.companyName="";
        u.teamName="";
        u.isDel=0l;
        JSONArray ja=j.getJSONArray("corpName");
        if(ja!=null && ja.size()>0){
            Object obj=ja.get(0);
            if(obj!=null){
                u.companyName=obj.toString();
            }
        }

        u.leader=j.getInteger("isAdmin")==1?1:0;
        return  u;
    }

    public Date getInTime() {
        return inTime;
    }

    public void setInTime(Date inTime) {
        this.inTime = inTime;
    }

    public Date getOutTime() {
        return outTime;
    }

    public void setOutTime(Date outTime) {
        this.outTime = outTime;
    }

    private Long projectId;
    private Long subDeptId;
    private Long deptId;

    private List<String> workerIds;

    public List<String> getWorkerIds() {
        return workerIds;
    }

    public void setWorkerIds(List<String> workerIds) {
        this.workerIds = workerIds;
    }

    private int size;

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    private int index;
    public Long getProjectId() {
        return projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public Long getSubDeptId() {
        return subDeptId;
    }

    public void setSubDeptId(Long subDeptId) {
        this.subDeptId = subDeptId;
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    public static SurProjectAttendanceUser create(JSONObject json) {
        SurProjectAttendanceUser u=new SurProjectAttendanceUser();
        u.workerId=json.getString("workerId");
        u.laborWorkerId=json.getLongValue("laborWorkerId",0);
        u.workerCategory=json.getLongValue("workerCategory",0);
        u.qrCode=json.getLongValue("qrCode",0);
        u.name=json.getString("name");
        u.ethnic=json.getString("ethnic");
        u.nativePlace=json.getString("nativePlace");
        u.gender=json.getLongValue("gender",0);
        u.birthDate=json.getLongValue("birthDate",0);
        u.phone=json.getString("phone");
        u.recentPhoto=json.getString("recentPhoto");
        u.groupId=json.getString("groupId");
        u.groupName=json.getString("groupName");
        u.leader=json.getBooleanValue("leader",false)?1:0;
        u.workTypeCode=json.getString("workTypeCode");
        u.workTypeName=json.getString("workTypeName");
        u.specWorkType=json.getBooleanValue("specWorkType",false)?1:0;
        u.hatCode=json.getString("hatCode");
        u.state=json.getLongValue("state",0);
        u.enterDate=json.getString("enterDate");
        u.exitDate=json.getString("exitDate");
        u.companyId=""+json.getLongValue("companyId",0);
        u.companyName=json.getString("companyName");
        u.vendorId=json.getLongValue("vendorId",0);
        u.teamId=json.getInteger("teamId");
        u.teamName=json.getString("teamName");
        u.enterType=json.getString("enterType");
        u.isDel=0l;
        return u;
    }
    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }
    public void setCfgid(Long cfgid) 
    {
        this.cfgid = cfgid;
    }

    public Long getCfgid() 
    {
        return cfgid;
    }
    public void setVendorsCode(String vendorsCode) 
    {
        this.vendorsCode = vendorsCode;
    }

    public String getVendorsCode() 
    {
        return vendorsCode;
    }
    public void setWorkerId(String workerId)
    {
        this.workerId = workerId;
    }

    public String getWorkerId()
    {
        return workerId;
    }
    public void setLaborWorkerId(Long laborWorkerId) 
    {
        this.laborWorkerId = laborWorkerId;
    }

    public Long getLaborWorkerId() 
    {
        return laborWorkerId;
    }
    public void setWorkerCategory(Long workerCategory) 
    {
        this.workerCategory = workerCategory;
    }

    public Long getWorkerCategory() 
    {
        return workerCategory;
    }
    public void setQrCode(Long qrCode) 
    {
        this.qrCode = qrCode;
    }

    public Long getQrCode() 
    {
        return qrCode;
    }
    public void setName(String name) 
    {
        this.name = name;
    }

    public String getName() 
    {
        return name;
    }
    public void setEthnic(String ethnic) 
    {
        this.ethnic = ethnic;
    }

    public String getEthnic() 
    {
        return ethnic;
    }
    public void setNativePlace(String nativePlace) 
    {
        this.nativePlace = nativePlace;
    }

    public String getNativePlace() 
    {
        return nativePlace;
    }
    public void setGender(Long gender) 
    {
        this.gender = gender;
    }

    public Long getGender() 
    {
        return gender;
    }
    public void setBirthDate(Long birthDate) 
    {
        this.birthDate = birthDate;
    }

    public Long getBirthDate() 
    {
        return birthDate;
    }
    public void setPhone(String phone) 
    {
        this.phone = phone;
    }

    public String getPhone() 
    {
        return phone;
    }
    public void setDegreeName(String degreeName) 
    {
        this.degreeName = degreeName;
    }

    public String getDegreeName() 
    {
        return degreeName;
    }
    public void setPhoto(String photo) 
    {
        this.photo = photo;
    }

    public String getPhoto() 
    {
        return photo;
    }
    public void setRecentPhoto(String recentPhoto) 
    {
        this.recentPhoto = recentPhoto;
    }

    public String getRecentPhoto() 
    {
        return recentPhoto;
    }
    public void setGroupId(String groupId)
    {
        this.groupId = groupId;
    }

    public String getGroupId()
    {
        return groupId;
    }
    public void setGroupName(String groupName) 
    {
        this.groupName = groupName;
    }

    public String getGroupName() 
    {
        return groupName;
    }
    public void setLeader(Integer leader) 
    {
        this.leader = leader;
    }

    public Integer getLeader() 
    {
        return leader;
    }
    public void setWorkTypeCode(String workTypeCode) 
    {
        this.workTypeCode = workTypeCode;
    }

    public String getWorkTypeCode() 
    {
        return workTypeCode;
    }
    public void setWorkTypeName(String workTypeName) 
    {
        this.workTypeName = workTypeName;
    }

    public String getWorkTypeName() 
    {
        return workTypeName;
    }
    public void setSpecWorkType(Integer specWorkType) 
    {
        this.specWorkType = specWorkType;
    }

    public Integer getSpecWorkType() 
    {
        return specWorkType;
    }
    public void setHatCode(String hatCode) 
    {
        this.hatCode = hatCode;
    }

    public String getHatCode() 
    {
        return hatCode;
    }
    public void setState(Long state) 
    {
        this.state = state;
    }

    public Long getState() 
    {
        return state;
    }
    public void setEnterDate(String enterDate) 
    {
        this.enterDate = enterDate;
    }

    public String getEnterDate() 
    {
        return enterDate;
    }
    public void setExitDate(String exitDate) 
    {
        this.exitDate = exitDate;
    }

    public String getExitDate() 
    {
        return exitDate;
    }
    public void setCompanyId(String companyId)
    {
        this.companyId = companyId;
    }

    public String getCompanyId()
    {
        return companyId;
    }
    public void setCompanyName(String companyName) 
    {
        this.companyName = companyName;
    }

    public String getCompanyName() 
    {
        return companyName;
    }
    public void setVendorId(Long vendorId) 
    {
        this.vendorId = vendorId;
    }

    public Long getVendorId() 
    {
        return vendorId;
    }
    public void setTeamId(Integer teamId) 
    {
        this.teamId = teamId;
    }

    public Integer getTeamId() 
    {
        return teamId;
    }
    public void setTeamName(String teamName) 
    {
        this.teamName = teamName;
    }

    public String getTeamName() 
    {
        return teamName;
    }
    public void setEnterType(String enterType) 
    {
        this.enterType = enterType;
    }

    public String getEnterType() 
    {
        return enterType;
    }
    public void setOther(String other) 
    {
        this.other = other;
    }

    public String getOther() 
    {
        return other;
    }
    public void setIsDel(Long isDel) 
    {
        this.isDel = isDel;
    }

    public Long getIsDel() 
    {
        return isDel;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getCompanyTypeId() {
        return companyTypeId;
    }

    public void setCompanyTypeId(String companyTypeId) {
        this.companyTypeId = companyTypeId;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("cfgid", getCfgid())
            .append("vendorsCode", getVendorsCode())
            .append("workerId", getWorkerId())
            .append("laborWorkerId", getLaborWorkerId())
            .append("workerCategory", getWorkerCategory())
            .append("qrCode", getQrCode())
            .append("name", getName())
            .append("ethnic", getEthnic())
            .append("nativePlace", getNativePlace())
            .append("gender", getGender())
            .append("birthDate", getBirthDate())
            .append("phone", getPhone())
            .append("degreeName", getDegreeName())
            .append("photo", getPhoto())
            .append("recentPhoto", getRecentPhoto())
            .append("groupId", getGroupId())
            .append("groupName", getGroupName())
            .append("leader", getLeader())
            .append("workTypeCode", getWorkTypeCode())
            .append("workTypeName", getWorkTypeName())
            .append("specWorkType", getSpecWorkType())
            .append("hatCode", getHatCode())
            .append("state", getState())
            .append("enterDate", getEnterDate())
            .append("exitDate", getExitDate())
            .append("companyId", getCompanyId())
            .append("companyName", getCompanyName())
            .append("vendorId", getVendorId())
            .append("teamId", getTeamId())
            .append("teamName", getTeamName())
            .append("enterType", getEnterType())
            .append("other", getOther())
            .append("remark", getRemark())
            .append("isDel", getIsDel())
            .append("createBy", getCreateBy())
            .append("createTime", getCreateTime())
            .append("updateBy", getUpdateBy())
            .append("updateTime", getUpdateTime())
            .toString();
    }
}
