package com.sa.ibiz.demo.demoapp.controller.demo.vo;

import java.sql.Timestamp;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.util.StringUtils;
import com.sa.ibiz.demo.demo.domain.Org;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.util.Map;
import java.util.Date;
import org.springframework.cglib.beans.BeanCopier;
import javax.validation.constraints.Size;
import java.util.UUID;
import org.springframework.cglib.beans.BeanCopier;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.sa.ibiz.demo.ibizutil.security.AuthenticationUser;
import java.math.BigInteger;
import com.alibaba.fastjson.JSONObject;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Org_EditForm_Main2{

    @JsonProperty(access=Access.WRITE_ONLY)
    private Map<String,String> srfparentdata;
    @JsonIgnore
    private Timestamp updatedate;
    @JsonProperty(access=Access.WRITE_ONLY)
    private String srforikey;
    @JsonIgnore
    private String orgid;
    @JsonIgnore
    private String orgname;
    @JsonIgnore
    private String srftempmode;
    @JsonProperty
    private String srfuf;
    @JsonProperty
    private String srfdeid;
    @JsonProperty(access=Access.WRITE_ONLY)
    private String srfsourcekey;
    @JsonIgnore
    private String porgname;
    @JsonIgnore
    private String orgcode;
    @JsonIgnore
    private String levelcode;
    @JsonIgnore
    private String shortname;
    @JsonIgnore
    private String memo;
    @JsonIgnore
    private String createman;
    @JsonIgnore
    private Timestamp createdate;
    @JsonIgnore
    private String updateman;
    @JsonIgnore
    private String porgid;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    @JsonProperty(value = "srfupdatedate")
    public Timestamp getSrfupdatedate(){
        return updatedate;
    }
    @JsonProperty(value = "srfupdatedate")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    public void setSrfupdatedate(Timestamp updatedate){
        this.updatedate = updatedate;
    }

    @JsonProperty(value = "srforikey")
    public String getSrforikey(){
        return srforikey;
    }
    @JsonProperty(value = "srforikey")
    public void setSrforikey(String srforikey){
        this.srforikey = srforikey;
    }

    @Size(min = 0, max = 100, message = "[组织机构标识]长度必须在[100]以内!")
    @JsonProperty(value = "srfkey")
    public String getSrfkey(){
        return orgid;
    }
    @JsonProperty(value = "srfkey")
    public void setSrfkey(String orgid){
        this.orgid = orgid;
    }

    @Size(min = 0, max = 200, message = "[组织机构名称]长度必须在[200]以内!")
    @JsonProperty(value = "srfmajortext")
    public String getSrfmajortext(){
        return orgname;
    }

    @JsonProperty(value = "srftempmode")
    public String getSrftempmode(){
        return srftempmode;
    }
    @JsonProperty(value = "srftempmode")
    public void setSrftempmode(String srftempmode){
        this.srftempmode = srftempmode;
    }

    @JsonProperty(value = "srfdeid")
    public String getSrfdeid(){
        return srfdeid;
    }
    @JsonProperty(value = "srfdeid")
    public void setSrfdeid(String srfdeid){
        this.srfdeid = srfdeid;
    }

    @NotBlank(message = "[组织机构名称]不允许为空!")
    @Size(min = 0, max = 200, message = "[组织机构名称]长度必须在[200]以内!")
    @JsonProperty(value = "orgname")
    public String getOrgname(){
        return orgname;
    }
    @JsonProperty(value = "orgname")
    public void setOrgname(String orgname){
        this.orgname = orgname;
    }

    @Size(min = 0, max = 200, message = "[上级机构]长度必须在[200]以内!")
    @JsonProperty(value = "porgname")
    public String getPorgname(){
        return porgname;
    }
    @JsonProperty(value = "porgname")
    public void setPorgname(String porgname){
        this.porgname = porgname;
    }

    @Size(min = 0, max = 500, message = "[组织编号]长度必须在[500]以内!")
    @JsonProperty(value = "orgcode")
    public String getOrgcode(){
        return orgcode;
    }
    @JsonProperty(value = "orgcode")
    public void setOrgcode(String orgcode){
        this.orgcode = orgcode;
    }

    @Size(min = 0, max = 500, message = "[级别编码]长度必须在[500]以内!")
    @JsonProperty(value = "levelcode")
    public String getLevelcode(){
        return levelcode;
    }
    @JsonProperty(value = "levelcode")
    public void setLevelcode(String levelcode){
        this.levelcode = levelcode;
    }

    @Size(min = 0, max = 100, message = "[简称]长度必须在[100]以内!")
    @JsonProperty(value = "shortname")
    public String getShortname(){
        return shortname;
    }
    @JsonProperty(value = "shortname")
    public void setShortname(String shortname){
        this.shortname = shortname;
    }

    @Size(min = 0, max = 4000, message = "[备注]长度必须在[4000]以内!")
    @JsonProperty(value = "memo")
    public String getMemo(){
        return memo;
    }
    @JsonProperty(value = "memo")
    public void setMemo(String memo){
        this.memo = memo;
    }

    @Size(min = 0, max = 60, message = "[建立人]长度必须在[60]以内!")
    @JsonProperty(value = "createman")
    public String getCreateman(){
        return createman;
    }
    @JsonProperty(value = "createman")
    public void setCreateman(String createman){
        this.createman = createman;
    }

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    @JsonProperty(value = "createdate")
    public Timestamp getCreatedate(){
        return createdate;
    }
    @JsonProperty(value = "createdate")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    public void setCreatedate(Timestamp createdate){
        this.createdate = createdate;
    }

    @Size(min = 0, max = 60, message = "[更新人]长度必须在[60]以内!")
    @JsonProperty(value = "updateman")
    public String getUpdateman(){
        return updateman;
    }
    @JsonProperty(value = "updateman")
    public void setUpdateman(String updateman){
        this.updateman = updateman;
    }

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    @JsonProperty(value = "updatedate")
    public Timestamp getUpdatedate(){
        return updatedate;
    }
    @JsonProperty(value = "updatedate")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
    public void setUpdatedate(Timestamp updatedate){
        this.updatedate = updatedate;
    }

    @Size(min = 0, max = 100, message = "[组织机构标识]长度必须在[100]以内!")
    @JsonProperty(value = "orgid")
    public String getOrgid(){
        return orgid;
    }
    @JsonProperty(value = "orgid")
    public void setOrgid(String orgid){
        this.orgid = orgid;
    }

    @Size(min = 0, max = 100, message = "[组织机构]长度必须在[100]以内!")
    @JsonProperty(value = "porgid")
    public String getPorgid(){
        //输出获取外键值方法-用于通过parentdata关系填充外键值id
        if(StringUtils.isEmpty(porgid) && this.getSrfparentdata() != null)
        {
            if(this.getSrfparentdata().containsKey("srfparentmode")&& this.getSrfparentdata().get("srfparentmode").equals("DER1N_ORG_ORG_PORGID"))
                this.porgid=this.getSrfparentdata().get("srfparentkey");
        }
        return porgid;
    }
    @JsonProperty(value = "porgid")
    public void setPorgid(String porgid){
        this.porgid = porgid;
    }

    public  void fromOrg(Org sourceEntity)  {
        this.fromOrg(sourceEntity,true);
    }

     /**
	 * do转换为vo
	 * @param sourceEntity do数据对象
	 * @return
	 */
    public  void fromOrg(Org sourceEntity,boolean reset)  {
      BeanCopier copier=BeanCopier.create(Org.class, Org_EditForm_Main2.class, false);
      copier.copy(sourceEntity,this,  null);
      this.toString();
	}

    /**
	 * vo转换为do
	 * @param
	 * @return
	 */
    public  Org toOrg()  {
        Org targetEntity =new Org();
        BeanCopier copier=BeanCopier.create(Org_EditForm_Main2.class, Org.class, false);
        copier.copy(this, targetEntity, null);
        return targetEntity;
	}

     /**
	 * 新建
	 * @param
	 * @return
	 */
    private boolean isCreate()
    {
    	if((StringUtils.isEmpty(this.srfuf))||this.srfuf.equals("0"))
	    	return true;
    	else
    	    return false;
    }
     /**
	 * 更新
	 * @param
	 * @return
	 */
    private boolean isUpdate()
    {
    	if((!StringUtils.isEmpty(this.srfuf))&&this.srfuf.equals("1"))
	    	return true;
    	else
    	    return false;
    }

}
