using OpenAuth.Repository.Domain;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenAuth.App.Response
{
    ///<summary>
    ///无人机案件
    ///</summary>
    [SugarTable("drone_caseinfo")]
    public partial class Sugar_Drone_caseinfo
    {
        public Sugar_Drone_caseinfo()
        {

        }

        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="user"></param>
        /// <param name="db"></param>
        public void Init(SysUser user, SqlSugarClient db)
        {
            //主键
            this.Id = Guid.NewGuid().ToString();

            //创建人和创建时间
            this.createtime = DateTime.Now;
            this.createuser = user.Id.ToString();
            this.createusername = user.Name;

            //案件是否关闭，默认0 未关闭
            this.is_closed = 0;

            //是否删除，默认0 未删除
            this.is_delete = 0;

            //是否判读
            this.is_intact = 0;

            //是否退回
            this.is_improve = 0;
            drawbackcount = 0;

            //处理状态
            this.handle_status_id = 0;
            this.handle_status_name = "未办理";

            // 案件是否已查看
            is_checked = 0;

            //时间戳标识案件编号
            this.case_no = DateTime.Now.ToString("yyyyMMddHHmmssffff");

            if (string.IsNullOrEmpty(case_description)) case_description = "";
            if (string.IsNullOrEmpty(address)) address = "";
            if (string.IsNullOrEmpty(typeid)) typeid = "";
            if (string.IsNullOrEmpty(typename)) typename = "";

            if (string.IsNullOrEmpty(countyid)) countyid = "";
            if (string.IsNullOrEmpty(countyname)) countyname = "";
            if (string.IsNullOrEmpty(streetid)) streetid = "";
            if (string.IsNullOrEmpty(streetname)) streetname = "";
            if (string.IsNullOrEmpty(communityid)) communityid = "";
            if (string.IsNullOrEmpty(communityname)) communityname = "";

            InitOther(db);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="user"></param>
        /// <param name="db"></param>
        public void Update(SysUser user, SqlSugarClient db)
        {
            InitOther(db);
        }

        /// <summary>
        /// 初始化 类型、状态、县镇村等名称
        /// </summary>
        /// <param name="db"></param>
        private void InitOther(SqlSugarClient db)
        {
            //类型
            if (!string.IsNullOrEmpty(typeid))
            {
                var typeModel = db.Queryable<SysDataItemDetail>().Where(c => c.ItemDetailId.ToString() == this.typeid).First();
                if (typeModel != null)
                {
                    this.typename = typeModel.ItemName;
                }
            }

            //案件状态
            if (!string.IsNullOrEmpty(case_status_id))
            {
                var statusModel = db.Queryable<SysDataItemDetail>().Where(c => c.ItemDetailId.ToString() == this.case_status_id).First();
                if (statusModel != null)
                {
                    this.case_status_name = statusModel.ItemName;
                }
            }

            //县
            if (!string.IsNullOrEmpty(countyid))
            {
                var model = db.Queryable<SysOrg>().Where(c => c.Id.ToString() == countyid).First();
                if (model != null)
                {
                    countyname = model.Name;
                }
            }

            //镇
            if (!string.IsNullOrEmpty(streetid))
            {
                var model = db.Queryable<SysOrg>().Where(c => c.Id.ToString() == streetid).First();
                if (model != null)
                {
                    streetname = model.Name;
                }
            }

            //村
            if (!string.IsNullOrEmpty(communityid))
            {
                var model = db.Queryable<SysOrg>().Where(c => c.Id.ToString() == communityid).First();
                if (model != null)
                {
                    communityname = model.Name;
                }
            }
        }

        /// <summary>
        /// Desc:
        /// Default:
        /// Nullable:False
        /// </summary>           
        [SugarColumn(IsPrimaryKey = true)]
        public string Id { get; set; }

        /// <summary>
        /// Desc:案件编号
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string case_no { get; set; }

        /// <summary>
        /// Desc:案件名称
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string case_name { get; set; }

        /// <summary>
        /// Desc:案件描述
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string case_description { get; set; }

        /// <summary>
        /// Desc:开始时间
        /// Default:
        /// Nullable:True
        /// </summary>           
        public DateTime? start_time { get; set; }

        /// <summary>
        /// Desc:结束时间
        /// Default:
        /// Nullable:True
        /// </summary>           
        public DateTime? end_time { get; set; }

        /// <summary>
        /// Desc:地址
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string address { get; set; }

        /// <summary>
        /// Desc:经度
        /// Default:
        /// Nullable:True
        /// </summary>           
        public decimal? lng { get; set; }

        /// <summary>
        /// Desc:纬度
        /// Default:
        /// Nullable:True
        /// </summary>           
        public decimal? lat { get; set; }

        /// <summary>
        /// Desc:类型
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string typeid { get; set; }

        /// <summary>
        /// Desc:类型
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string typename { get; set; }

        /// <summary>
        /// Desc:处理状态
        /// Default:
        /// Nullable:True
        /// </summary>           
        public int? handle_status_id { get; set; }

        /// <summary>
        /// Desc:处理状态
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string handle_status_name { get; set; }

        /// <summary>
        /// Desc:案件状态
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string case_status_id { get; set; }

        /// <summary>
        /// Desc:案件状态
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string case_status_name { get; set; }

        /// <summary>
        /// Desc:创建时间
        /// Default:
        /// Nullable:True
        /// </summary>           
        public DateTime? createtime { get; set; }

        /// <summary>
        /// Desc:创建人
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string createuser { get; set; }

        /// <summary>
        /// Desc:创建人姓名
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string createusername { get; set; }

        /// <summary>
        /// Desc:无人机编号
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string drone_no { get; set; }

        /// <summary>
        /// Desc:案件处理人
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string deal_userid { get; set; }

        /// <summary>
        /// Desc:案件处理人
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string deal_username { get; set; }

        /// <summary>
        /// Desc:是否删除
        /// Default:
        /// Nullable:True
        /// </summary>           
        public int? is_delete { get; set; }

        /// <summary>
        /// 县
        /// </summary>
        public string countyid { get; set; }

        /// <summary>
        /// 县
        /// </summary>
        public string countyname { get; set; }

        /// <summary>
        /// 镇
        /// </summary>
        public string streetid { get; set; }

        /// <summary>
        /// 镇
        /// </summary>
        public string streetname { get; set; }

        /// <summary>
        /// 村
        /// </summary>
        public string communityid { get; set; }

        /// <summary>
        /// 村
        /// </summary>
        public string communityname { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string remark { get; set; }

        /// <summary>
        /// 是否关闭
        /// </summary>
        public int? is_closed { get; set; }

        /// <summary>
        /// 面积
        /// </summary>
        public string area { get; set; }

        /// <summary>
        /// 是否违法
        /// </summary>
        public int? is_illegal { get; set; }

        /// <summary>
        /// 关闭人
        /// </summary>
        public string close_user { get; set; }

        /// <summary>
        /// 关闭时间
        /// </summary>
        public DateTime? close_time { get; set; }

        /// <summary>
        /// 判读人
        /// </summary>
        public string identification_user { get; set; }

        /// <summary>
        /// 判读时间
        /// </summary>
        public DateTime? identification_time { get; set; }

        /// <summary>
        /// 是否判读
        /// </summary>
        public int? is_intact { get; set; }

        /// <summary>
        /// 关闭人id
        /// </summary>
        public string close_userid { get; set; }

        /// <summary>
        /// 判读人id
        /// </summary>
        public string identification_userid { get; set; }

        /// <summary>
        /// 审核人id
        /// </summary>
        public string verifyuserid { get; set; }

        /// <summary>
        /// 审核人
        /// </summary>
        public string verifyuser { get; set; }

        /// <summary>
        /// 审核时间
        /// </summary>
        public DateTime? verifytime { get; set; }

        /// <summary>
        /// Desc:是否改进
        /// Default:
        /// Nullable:True
        /// </summary>           
        public int? is_improve { get; set; }

        /// <summary>
        /// Desc:改进原因
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string improve_reason { get; set; }

        /// <summary>
        /// Desc:是否分发
        /// Default:
        /// Nullable:True
        /// </summary>           
        public int? is_dispense { get; set; }

        /// <summary>
        /// Desc:分发人id
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string dispense_userid { get; set; }

        /// <summary>
        /// Desc:分发时间
        /// Default:
        /// Nullable:True
        /// </summary>           
        public DateTime? dispense_time { get; set; }

        /// <summary>
        /// Desc:分发人姓名
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string dispense_username { get; set; }

        /// <summary>
        /// Desc:审核状态
        /// Default:
        /// Nullable:True
        /// </summary>           
        public int? verifystatus { get; set; }

        /// <summary>
        /// Desc:审核状态名称
        /// Default:
        /// Nullable:True
        /// </summary>           
        public string verifystatusname { get; set; }

        /// <summary>
        /// 案件是否已查看
        /// </summary>
        public int? is_checked { get; set; }

        /// <summary>
        /// Desc:处理时间
        /// Default:
        /// Nullable:True
        /// </summary>           
        public DateTime? deal_time { get; set; }

        /// <summary>
        /// 前时相
        /// </summary>
        public DateTime? pre_phase_time { get; set; }

        /// <summary>
        /// 后时相
        /// </summary>
        public DateTime? later_phase_time { get; set; }

        /// <summary>
        /// 前时相 照片
        /// </summary>
        public string pre_phase_img { get; set; }

        /// <summary>
        /// 后时相 照片
        /// </summary>
        public string later_phase_img { get; set; }

        /// <summary>
        /// 是否核销
        /// </summary>
        public int? is_verification { get; set; }

        /// <summary>
        /// 核销人
        /// </summary>
        public string verification_userid { get; set; }

        /// <summary>
        /// 核销人
        /// </summary>
        public string verification_username { get; set; }

        /// <summary>
        /// 核销时间
        /// </summary>
        public DateTime? verification_time { get; set; }

        /// <summary>
        /// 是否退回
        /// </summary>
        public int? is_drawback { get; set; }

        /// <summary>
        /// 退回次数
        /// </summary>
        public int? drawbackcount { get; set; }

        /// <summary>
        /// 退回给谁
        /// </summary>
        public string back_to_userid { get; set; }

        /// <summary>
        /// 退回给谁
        /// </summary>
        public string back_to_username { get; set; }

        /// <summary>
        /// 退回类型
        /// </summary>
        public string drawback_type { get; set; }

        /// <summary>
        /// 退回描述
        /// </summary>
        public string drawback_description { get; set; }

        /// <summary>
        /// 是否暂结
        /// </summary>
        public int? is_tentative_complete { get; set; }

        /// <summary>
        /// 暂结人
        /// </summary>
        public string tentative_userid { get; set; }

        /// <summary>
        /// 暂结人
        /// </summary>
        public string tentative_username { get; set; }

        /// <summary>
        /// 暂结时间
        /// </summary>
        public DateTime? tentative_time { get; set; }

        /// <summary>
        /// 是否核查
        /// </summary>
        public int? is_examine { get; set; }

        /// <summary>
        /// 核查人
        /// </summary>
        public string examiner_id { get; set; }

        /// <summary>
        /// 核查人
        /// </summary>
        public string examiner_name { get; set; }

        /// <summary>
        /// 核查时间
        /// </summary>
        public DateTime? examine_time { get; set; }

        /// <summary>
        /// 处理措施
        /// </summary>
        public string measure_name { get; set; }

        /// <summary>
        /// 农用地面积
        /// </summary> 
        public string nongyongdi_area { get; set; }

        /// <summary>
        /// 耕地面积
        /// </summary> 
        public string gengdi_area { get; set; }

        /// <summary>
        /// 永久基本农田面积
        /// </summary> 
        public string yongjiujibennongtian_area { get; set; }

        /// <summary>
        /// 重点区域面积
        /// </summary> 
        public string zhongdianquyu_area { get; set; }

        /// <summary>
        /// 生态保护红线面积
        /// </summary> 
        public string shengtaibaohuhongxian_area { get; set; }

        /// <summary>
        /// 国土空间规划面积
        /// </summary> 
        public string guotukongjianguihua_area { get; set; }

        /// <summary>
        /// 图斑来源(全域巡查、卫片下发)
        /// </summary> 
        public string tubanlaiyuan { get; set; }

        /// <summary>
        /// 批次号
        /// </summary> 
        public string picihao { get; set; }

        /// <summary>
        /// 标注类型  在建 已建成 持续变化
        /// </summary> 
        public string is_build_name { get; set; }
        /// <summary>
        /// 同步时间
        /// </summary>
        public DateTime? synchronoustime { get; set; }

        /// <summary>
        /// 自定义字段值
        /// </summary>
        public Dictionary<string, object> extra_info { get; set; }
        public string mineralsinfo { get; set; }
        public string resubmitremark { get; set; }
    }
}
