package com.yccrc.kede.domain;

import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yccrc.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.List;

/**
 * 项目信息对象 project
 * 
 * @author yccrc
 * @date 2022-04-25
 */
@Data
@TableName("project")
@ApiModel(value = "项目信息")
public class Project extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** $column.columnComment */
	@TableId
	@ApiModelProperty(value = "ID")
    private Integer id;

	@ApiModelProperty(value = "项目编号")
	private String projectNo;

	@ApiModelProperty(value = "项目名称")
	private String projectName;

	@ApiModelProperty(value = "项目年份")
	private String projectYear;

	/** 关联企业ID */
	@ApiModelProperty(value = "关联企业ID")
    private Integer entId;

    /** 关联原始项目ID */
	@ApiModelProperty(value = "关联原始项目ID")
    private Integer projectRefId;

    /** 企业名称 */
	@ApiModelProperty(value = "企业名称")
    private String entName;

    /** 通讯地址 */
	@ApiModelProperty(value = "通讯地址")
    private String address;

    /** 联系人姓名 */
	@ApiModelProperty(value = "联系人姓名")
    private String linkName;

    /** 联系人手机 */
	@ApiModelProperty(value = "联系人手机")
    private String linkMobile;

	/** 联系人座机 */
	@ApiModelProperty(value = "联系座机")
    private String linkPhone;

    /** 职工总人数 */
	@ApiModelProperty(value = "职工总人数")
    private String totoalPersons;

    /** 年度销售收入(万元) */
	@ApiModelProperty(value = "年度销售收入(万元)")
    private String sales;

    /** 研发人数 */
	@ApiModelProperty(value = "研发人数")
    private String techPersons;

    /** 研发投入 */
	@ApiModelProperty(value = "研发投入")
    private String techInvest;

    /** 占销售收入比例 */
	@ApiModelProperty(value = "占销售收入比例")
    private String techRate;

    /** 企业所属行业 */
	@ApiModelProperty(value = "企业所属行业")
    private String industry;

    /** 创新示范区企业 */
	@ApiModelProperty(value = "创新示范区企业")
    private Integer innovateFlag;

    /** 是否跨年 */
	@ApiModelProperty(value = "是否跨年")
    private Integer overYearFlag;

    /** 项目开始日期 */
	@ApiModelProperty(value = "项目开始日期")
    private String projectStartDate;

    /** 项目结束日期 */
	@ApiModelProperty(value = "项目结束日期")
    private String projectEndDate;

    /** 是否中小企业 */
	@ApiModelProperty(value = "是否中小企业")
    private Integer smallFlag;

    /** 是否高新企业 */
	@ApiModelProperty(value = "是否高新企业")
    private Integer techFlag;

    /** 高新企业所属技术领域(JSON数组) */
	@ApiModelProperty(value = "高新企业所属技术领域(JSON数组)")
    private String techScope;

    /** 高新证书有效期 */
	@ApiModelProperty(value = "高新证书有效期")
    private String techStartDate;

    /** 高新证书有效期 */
	@ApiModelProperty(value = "高新证书有效期")
    private String techEndDate;

    /** 高新证书 */
	@ApiModelProperty(value = "高新证书")
    private String techLicense;

    /** 用户ID */
	@ApiModelProperty(value = "用户ID")
    private Long userId;

    /** 1:企业自填 2:技术 3:财务 */
	@ApiModelProperty(value = "1:企业自填 2:技术 3:财务")
    private Integer projectOwner;

    /** 审核状态 1:待提交 2:提交审核 3:审核通过 4:审核拒绝 */
	@ApiModelProperty(value = "审核状态 1:待提交 2:提交审核 3:审核通过 4:审核拒绝")
    private Integer authState;


    /** 申报状态 1:未申报 2:已申报 3:撤回 */
	@ApiModelProperty(value = "申报状态 1:未申报 2:已申报 3:撤回")
    private Integer reportState;

    /** 申报提交标记1:是 0 否 */
	@ApiModelProperty(value = "申报提交标记1:是 0 否")
    private Integer reportFlag;

	@TableField(exist=false)
	@ApiModelProperty(value = "资料完成百分比")
	private String compRate;

	@TableField(exist=false)
	@ApiModelProperty(value = "项目日志")
	private List<ProjectLog> projectLogList;

	@TableField(exist=false)
	private String license;

	@TableField(exist=false)
	private Long attachCnt;

	public String getCompRate() {
		int sumCnt = 13;
		int finCnt = 0 ;
		//if(!StrUtil.isEmpty(projectNo)) finCnt++;
		//if(!StrUtil.isEmpty(projectName)) finCnt++;
		//if(!StrUtil.isEmpty(projectYear)) finCnt++;
		if(!StrUtil.isEmpty(entName)) finCnt++;
		if(!StrUtil.isEmpty(address)) finCnt++;
		if(!StrUtil.isEmpty(linkName)) finCnt++;
		if(!StrUtil.isEmpty(linkMobile)) finCnt++;
		if(!StrUtil.isEmpty(totoalPersons)) finCnt++;
		if(!StrUtil.isEmpty(sales)) finCnt++;
		if (!StrUtil.isEmpty(techPersons)) finCnt++;
		if (!StrUtil.isEmpty(techInvest)) finCnt++;
		if (!StrUtil.isEmpty(techRate)) finCnt++;
		if (!StrUtil.isEmpty(industry)) finCnt++;
		if (innovateFlag != null) finCnt++;
		//if(overYearFlag!=null) finCnt++;
		if (smallFlag != null) finCnt++;
		if (techFlag != null) finCnt++;
		return NumberUtil.div(finCnt * 100, sumCnt, 2) + "%";
	}

	public String toStr() {
		return "Project{" +
				", projectNo='" + projectNo + '\'' +
				", projectName='" + projectName + '\'' +
				", projectYear='" + projectYear + '\'' +
				", entId=" + entId +
				", projectRefId=" + projectRefId +
				", entName='" + entName + '\'' +
				", address='" + address + '\'' +
				", linkName='" + linkName + '\'' +
				", linkMobile='" + linkMobile + '\'' +
				", linkPhone='" + linkPhone + '\'' +
				", totoalPersons='" + totoalPersons + '\'' +
				", sales='" + sales + '\'' +
				", techPersons='" + techPersons + '\'' +
				", techInvest='" + techInvest + '\'' +
				", techRate='" + techRate + '\'' +
				", industry='" + industry + '\'' +
				", innovateFlag=" + innovateFlag +
				", overYearFlag=" + overYearFlag +
				", projectStartDate='" + projectStartDate + '\'' +
				", projectEndDate='" + projectEndDate + '\'' +
				", smallFlag=" + smallFlag +
				", techFlag=" + techFlag +
				", techScope='" + techScope + '\'' +
				", techStartDate='" + techStartDate + '\'' +
				", techEndDate='" + techEndDate + '\'' +
				", techLicense='" + techLicense + '\'' +
				", authState=" + authState +
				", reportState=" + reportState +
				", reportFlag=" + reportFlag +
				", compRate='" + compRate + '\'' +
				", projectLogList=" + projectLogList +
				", license='" + license + '\'' +
				", attachCnt=" + attachCnt +
				'}';
	}
}
