/// <summary>
        /// 免费申请
        /// </summary>
        private string IncidentFreeApply(DataRow row)
        {
            if (!row.Table.Columns.Contains("IncidentID") || string.IsNullOrEmpty(row["IncidentID"].AsString()))//报事ID
            {
                return(new ApiResult(false, "缺少参数IncidentID").toJson());
            }
            if (!row.Table.Columns.Contains("FeesFreeReason") || string.IsNullOrEmpty(row["FeesFreeReason"].AsString()))
            {
                return(new ApiResult(false, "缺少参数FeesFreeReason").toJson());
            }

            var incidentId     = AppGlobal.StrToLong(row["IncidentID"].ToString());
            var feesFreeReason = row["FeesFreeReason"].ToString();
            var incidentInfo   = GetIncidentInfo(incidentId);

            using (var conn = new SqlConnection(Global_Fun.BurstConnectionString(incidentInfo.CommID, Global_Fun.BURST_TYPE_CHARGE)))
            {
                // 该报事下至少一笔费用已经收取、冲抵、减免、代扣
                var sql = @"SELECT count(1) FROM Tb_HSPR_Fees 
                            WHERE IncidentID=@IncidentID AND (IsCharge=1 OR PaidAmount>0 OR WaivAmount>0 OR IsBank=1 OR IsPrec=1);";

                var i = conn.Query <int>(sql, new { IncidentID = incidentId }).FirstOrDefault();
                if (i > 0)
                {
                    return(new ApiResult(false, "费用已收取,不允许免费").toJson());
                }
            }

            using (var conn = new SqlConnection(PubConstant.hmWyglConnectionString))
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    // 是否已经提交申请
                    var sql = @"SELECT count(1) FROM Tb_HSPR_IncidentFreeApply 
                                WHERE IncidentID=@IncidentID AND AuditState='审核中';";
                    int i   = conn.Query <int>(sql, new { IncidentID = incidentId }, trans).FirstOrDefault();
                    if (i > 0)
                    {
                        trans.Commit();
                        return(new ApiResult(false, "已提交申请,请勿重复申请").toJson());
                    }

                    // 判断该报事本身是否为不收费
                    sql = @"SELECT count(1) FROM Tb_HSPR_IncidentAccept 
                            WHERE IncidentID=@IncidentID AND isnull(IsFee,0)=0";
                    i   = conn.Query <int>(sql, new { IncidentID = incidentId }, trans).FirstOrDefault();
                    if (i > 0)
                    {
                        trans.Commit();
                        return(new ApiResult(false, "该报事已是免费状态").toJson());
                    }

                    var iid        = Guid.NewGuid().ToString();
                    var auditState = "审核中";
                    var auditUser  = default(string);
                    var title      = $"{Global_Var.UserName}提交的报事编号为【{incidentInfo.IncidentNum}】的免费申请";

                    sql = @"INSERT INTO Tb_HSPR_IncidentAuditingWorkFlow(IID, KeyIID, CommID, RoleCode, IsAudit, AuditType,orderID)
                            SELECT newid(), @KeyIID, @CommID, RoleCode, 0, 0,orderID FROM Tb_HSPR_IncidentAuditingSet WHERE AuditType=3
                            AND TypeCode=(SELECT BigCorpTypeCode FROM Tb_HSPR_IncidentAccept WHERE IncidentID=@IncidentID)
                            ORDER BY OrderID;";

                    // 插入有审核权限的岗位
                    i = conn.Execute(sql, new
                    {
                        KeyIID     = iid,
                        CommID     = incidentInfo.CommID,
                        IncidentID = incidentId
                    }, trans);

                    if (i == 0)
                    {
                        trans.Rollback();
                        return(JSONHelper.FromString(false, "未设置审核岗位,不能提交申请"));
                    }

                    sql = @"INSERT INTO Tb_HSPR_IncidentFreeApply(IID, CommID,CommName,IncidentID,IncidentNum,Title,FreeReason,
                                WorkStartDate,UserCode,UserName,AuditUser,AuditState)

                            SELECT @IID,a.CommID,b.CommName,a.IncidentID,a.IncidentNum,@Title,
                                @FreeReason,getdate(),@UserCode,@UserName,@AuditUser,@AuditState
                            FROM Tb_HSPR_IncidentAccept a 
                            LEFT JOIN Tb_HSPR_Community b ON a.CommID=b.CommID
                            WHERE a.IncidentID=@IncidentID;";

                    i = conn.Execute(sql, new
                    {
                        IID        = iid,
                        IncidentID = incidentId,
                        Title      = title,
                        UserName   = Global_Var.LoginUserName,
                        UserCode   = Global_Var.LoginUserCode,
                        FreeReason = feesFreeReason,
                        AuditUser  = auditUser,
                        AuditState = auditState
                    }, trans);

                    trans.Commit();

                    if (i > 0)
                    {
                        // 推送给审核人
                        PMSIncidentPush.SynchPushIncidentFreeApplied(iid);

                        return(JSONHelper.FromString(true, "申请成功"));
                    }

                    trans.Rollback();
                    return(JSONHelper.FromString(false, "申请失败"));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(JSONHelper.FromString(false, ex.Message + Environment.NewLine + ex.StackTrace));
                }
            }
        }
        /// <summary>
        /// 延期申请
        /// </summary>
        private string IncidentDelayApply(DataRow row)
        {
            if (!row.Table.Columns.Contains("IncidentID") || string.IsNullOrEmpty(row["IncidentID"].ToString()))
            {
                return(new ApiResult(false, "缺少参数IncidentID").toJson());
            }
            if (!row.Table.Columns.Contains("DelayHours") || string.IsNullOrEmpty(row["DelayHours"].ToString()))
            {
                return(new ApiResult(false, "缺少参数DelayHours").toJson());
            }
            if (!row.Table.Columns.Contains("DelayDate") || string.IsNullOrEmpty(row["DelayDate"].ToString()))
            {
                return(new ApiResult(false, "缺少参数DelayDate").toJson());
            }
            if (!row.Table.Columns.Contains("DelayReason") || string.IsNullOrEmpty(row["DelayReason"].ToString()))
            {
                return(new ApiResult(false, "缺少参数DelayReason").toJson());
            }

            var incidentId  = AppGlobal.StrToLong(row["IncidentID"].ToString());
            var delayHours  = AppGlobal.StrToInt(row["DelayHours"].ToString());
            var delayDate   = row["DelayDate"].ToString();
            var delayReason = row["DelayReason"].ToString();

            var incidentInfo = GetIncidentInfo(incidentId);

            using (var conn = new SqlConnection(PubConstant.hmWyglConnectionString))
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    var sql = @"SELECT count(1) FROM Tb_HSPR_IncidentDelayApply 
                                WHERE IncidentID=@IncidentID AND (AuditState IS NULL OR AuditState='审核中');";

                    // 是否已经提交申请
                    int i = conn.Query <int>(sql, new { IncidentID = incidentId }, trans).FirstOrDefault();
                    if (i > 0)
                    {
                        trans.Commit();
                        return(JSONHelper.FromString(false, "已提交申请,请勿重复申请"));
                    }

                    var iid        = Guid.NewGuid().ToString();
                    var auditState = "审核中";
                    var title      = $"{Global_Var.UserName}提交的报事编号为【{incidentInfo.IncidentNum}】的延期申请";

                    sql = @"INSERT INTO Tb_HSPR_IncidentAuditingWorkFlow(IID, KeyIID, CommID, RoleCode, IsAudit, AuditType,orderID)
                            SELECT newid(), @KeyIID, @CommID, RoleCode, 0, 0,orderID 
                            FROM Tb_HSPR_IncidentAuditingSet 
                            WHERE AuditType=0
                            AND TypeCode=(SELECT BigCorpTypeCode FROM Tb_HSPR_IncidentAccept WHERE IncidentID=@IncidentID)
                            ORDER BY OrderID;";

                    // 插入有审核权限的岗位
                    i = conn.Execute(sql, new
                    {
                        KeyIID     = iid,
                        CommID     = incidentInfo.CommID,
                        IncidentID = incidentId
                    }, trans);

                    if (i == 0)
                    {
                        trans.Rollback();
                        return(JSONHelper.FromString(false, "未设置审核岗位,不能提交申请"));
                    }

                    sql = @"INSERT INTO Tb_HSPR_IncidentDelayApply(IID,CommID,CommName,IncidentID,IncidentNum,DealLimit,
                                RoomSign,BigReasonName,BigReasonCode,SmallReasonName,SmalReasonCode,Title,DelayReason,
                                DelayHours,DealyDate,WorkStartDate,UserCode,UserName,AuditState)

                            SELECT @IID,a.CommID,b.CommName,a.IncidentID,a.IncidentNum,isnull(a.DealLimit,0) AS DealLimit,
                                c.RoomSign,d.TypeName AS BigTypeName,BigCorpTypeCode,e.TypeName AS FineTypeName,FineCorpTypeCode,
                                @Title,@DelayReason,@DelayHours,@DealyDate,getdate(),@UserCode,@UserName,@AuditState
                            FROM Tb_HSPR_IncidentAccept a 
                                LEFT JOIN Tb_HSPR_Community b ON a.CommID=b.CommID
                                LEFT JOIN Tb_HSPR_Room c ON a.RoomID=c.RoomID
                                LEFT JOIN Tb_HSPR_CorpIncidentType d ON d.TypeCode=a.BigCorpTypeCode
                                LEFT JOIN Tb_HSPR_CorpIncidentType e ON e.TypeCode=a.FineCorpTypeCode
                            WHERE a.IncidentID=@IncidentID;";

                    i = conn.Execute(sql, new
                    {
                        IID         = iid,
                        IncidentID  = incidentId,
                        Title       = title,
                        UserName    = Global_Var.LoginUserName,
                        UserCode    = Global_Var.LoginUserCode,
                        DelayReason = delayReason,
                        DelayHours  = delayHours,
                        DealyDate   = delayDate,
                        AuditState  = auditState
                    }, trans);

                    trans.Commit();

                    if (i > 0)
                    {
                        // 推送给审核人
                        PMSIncidentPush.SynchPushIncidentDelayApplied(iid);

                        return(JSONHelper.FromString(true, "申请成功"));
                    }

                    trans.Rollback();
                    return(JSONHelper.FromString(false, "申请失败"));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(JSONHelper.FromString(false, ex.Message + Environment.NewLine + ex.StackTrace));
                }
            }
        }
        /// <summary>
        /// 非正常关闭申请
        /// </summary>
        private string IncidentUnnormalCloseApply(DataRow row)
        {
            if (!row.Table.Columns.Contains("IncidentID") || string.IsNullOrEmpty(row["IncidentID"].ToString()))
            {
                return(new ApiResult(false, "缺少参数IncidentID").toJson());
            }
            if (!row.Table.Columns.Contains("CloseReason") || string.IsNullOrEmpty(row["CloseReason"].ToString()))
            {
                return(new ApiResult(false, "缺少参数CloseReason").toJson());
            }
            if (!row.Table.Columns.Contains("CloseSituation") || string.IsNullOrEmpty(row["CloseSituation"].ToString()))
            {
                return(new ApiResult(false, "缺少参数CloseSituation").toJson());
            }

            var incidentId     = AppGlobal.StrToLong(row["IncidentID"].ToString());
            var CloseReason    = row["CloseReason"].ToString();
            var CloseSituation = row["CloseSituation"].ToString();
            var imgs           = default(string);

            if (row.Table.Columns.Contains("Imgs") && !string.IsNullOrEmpty(row["Imgs"].AsString()))
            {
                imgs = row["Imgs"].AsString();
            }

            var incidentInfo = GetIncidentInfo(incidentId);

            using (var conn = new SqlConnection(PubConstant.hmWyglConnectionString))
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    var sql = @"SELECT count(1) FROM Tb_HSPR_IncidentUnnormalClose 
                                WHERE IncidentID=@IncidentID AND (AuditState IS NULL OR AuditState='审核中');";

                    // 是否已经提交申请
                    int i = conn.Query <int>(sql, new { IncidentID = incidentId }, trans).FirstOrDefault();
                    if (i > 0)
                    {
                        trans.Commit();
                        return(JSONHelper.FromString(false, "已提交申请,请勿重复申请"));
                    }

                    var iid        = Guid.NewGuid().ToString();
                    var auditState = "审核中";
                    var title      = $"{Global_Var.UserName}提交的报事编号为【{incidentInfo.IncidentNum}】的非正常关闭申请";

                    sql = @"INSERT INTO Tb_HSPR_IncidentAuditingWorkFlow(IID, KeyIID, CommID, RoleCode, IsAudit, AuditType,orderID)
                            SELECT newid(), @KeyIID, @CommID, RoleCode, 0, 2,orderID 
                            FROM Tb_HSPR_IncidentAuditingSet 
                            WHERE AuditType=2
                            AND TypeCode=(SELECT BigCorpTypeCode FROM Tb_HSPR_IncidentAccept WHERE IncidentID=@IncidentID)
                            ORDER BY OrderID;";

                    // 插入有审核权限的岗位
                    i = conn.Execute(sql, new
                    {
                        KeyIID     = iid,
                        CommID     = incidentInfo.CommID,
                        IncidentID = incidentId
                    }, trans);

                    if (i == 0)
                    {
                        trans.Rollback();
                        return(JSONHelper.FromString(false, "未设置审核岗位,不能提交申请"));

                        // 此处不再更新主表数据
                        //conn.Execute(@"UPDATE Tb_HSPR_IncidentAccept SET IsClose=1,CloseTime=getdate(),CloseType=1,NoNormalCloseReasons=@CloseReason,
                        //            CloseSituation=@CloseSituation,CloseUserCode=@CloseUserCode WHERE IncidentID=@IncidentID;",
                        //            new
                        //            {
                        //                IncidentID = IncidentID,
                        //                CloseUserCode = Global_Var.LoginUserCode,
                        //                CloseSituation = CloseSituation,
                        //                CloseReason = CloseReason
                        //            }, trans);
                    }

                    sql = @"INSERT INTO Tb_HSPR_IncidentUnnormalClose(IID,CommID,CommName,IncidentID,IncidentNum,
                                RoomSign,Title,CloseReason,WorkStartDate,UserCode,UserName,AuditState)

                            SELECT @IID,a.CommID,b.CommName,IncidentID,IncidentNum,c.RoomSign,@Title,
                                @CloseReason,getdate(),@UserCode,@UserName,@AuditState
                            FROM Tb_HSPR_IncidentAccept a
                                LEFT JOIN Tb_HSPR_Community b ON a.CommID=b.CommID
                                LEFT JOIN Tb_HSPR_Room c ON a.RoomID=c.RoomID
                            WHERE IncidentID=@IncidentID;";

                    i = conn.Execute(sql, new
                    {
                        IID         = iid,
                        IncidentID  = incidentId,
                        Title       = title,
                        UserName    = Global_Var.LoginUserName,
                        UserCode    = Global_Var.LoginUserCode,
                        CloseReason = CloseReason,
                        AuditState  = auditState
                    }, trans);

                    if (!string.IsNullOrEmpty(imgs))
                    {
                        sql = @"INSERT INTO Tb_HSPR_IncidentAdjunct(AdjunctCode,IncidentID, AdjunctName,FilPath,FileExName,FileSize,ImgGUID)
                                VALUES(@AdjunctCode,@IncidentID,'非正常关闭图片',@FilPath,@FileExName,@FileSize,@ImgGUID)";

                        var tmp = imgs.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (var item in tmp)
                        {
                            Thread.Sleep(50);
                            var adjunctCode = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random((int)(DateTime.Now.Ticks & 0xffffffffL) | (int)(DateTime.Now.Ticks >> 32)).Next(100, 999).ToString();

                            conn.Execute(sql, new
                            {
                                AdjunctCode = adjunctCode,
                                IncidentID  = incidentId,
                                FilPath     = item,
                                FileExName  = Path.GetExtension(item),
                                FileSize    = 0,
                                ImgGUID     = iid
                            }, trans);
                        }
                    }

                    trans.Commit();

                    if (i > 0)
                    {
                        // 推送给审核人
                        PMSIncidentPush.SynchPushIncidentUnnormalCloseApplied(iid);

                        return(JSONHelper.FromString(true, "申请成功"));
                    }

                    trans.Rollback();
                    return(JSONHelper.FromString(false, "申请失败"));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(JSONHelper.FromString(false, ex.Message + Environment.NewLine + ex.StackTrace));
                }
            }
        }
        /// <summary>
        /// 报事受理
        /// </summary>
        private string IncidentAccept(DataRow row)
        {
            if (!row.Table.Columns.Contains("CommunityId") || string.IsNullOrEmpty(row["CommunityId"].ToString()))
            {
                return(JSONHelper.FromString(false, "小区编号不能为空"));
            }
            if (!row.Table.Columns.Contains("IncidentPlace") || string.IsNullOrEmpty(row["IncidentPlace"].ToString()))
            {
                return(JSONHelper.FromString(false, "报事区域不能为空"));
            }
            if (!row.Table.Columns.Contains("CustID") || string.IsNullOrEmpty(row["CustID"].ToString()))
            {
                return(JSONHelper.FromString(false, "客户编号不能为空"));
            }
            if (!row.Table.Columns.Contains("Content") || string.IsNullOrEmpty(row["Content"].ToString()))
            {
                return(JSONHelper.FromString(false, "报事内容不能为空"));
            }
            if (!row.Table.Columns.Contains("RoomID") || string.IsNullOrEmpty(row["RoomID"].ToString()))
            {
                return(JSONHelper.FromString(false, "房间编号不能为空"));
            }
            if (!row.Table.Columns.Contains("Phone") || string.IsNullOrEmpty(row["Phone"].ToString()))
            {
                return(JSONHelper.FromString(false, "联系方式不能为空"));
            }

            var communityId = row["CommunityId"].AsString();

            var community = GetCommunity(communityId);

            if (community == null)
            {
                return(JSONHelper.FromString(false, "未查询到小区信息"));
            }

            var incidentPlace = row["IncidentPlace"].ToString();
            var content       = row["Content"].ToString();
            var custId        = AppGlobal.StrToLong(row["CustID"].ToString());
            var roomId        = AppGlobal.StrToLong(row["RoomID"].ToString());
            var regionalId    = 0L;
            var phone         = row["Phone"].ToString();
            var incidentImgs  = "";
            var reserveDate   = DateTime.Now.ToString();
            var incidentMan   = row["IncidentMan"].ToString();
            // 1=户内报事,2=公区报事,3=通知开水,4=通知开电,5=人员放行,6=车辆放行
            var type    = 0;
            var isTousu = 0;
            var appName = "业主App";

            if (row.Table.Columns.Contains("RegionalID") && !string.IsNullOrEmpty(row["RegionalID"].ToString()))
            {
                regionalId = AppGlobal.StrToLong(row["RegionalID"].ToString());
            }
            if (row.Table.Columns.Contains("IncidentImgs") && !string.IsNullOrEmpty(row["IncidentImgs"].ToString()))
            {
                incidentImgs = row["IncidentImgs"].ToString();
            }
            if (row.Table.Columns.Contains("ReserveDate") && !string.IsNullOrEmpty(row["ReserveDate"].ToString()))
            {
                reserveDate = row["ReserveDate"].ToString();
            }
            if (row.Table.Columns.Contains("IsTousu") && !string.IsNullOrEmpty(row["IsTousu"].ToString()))
            {
                isTousu = AppGlobal.StrToInt(row["IsTousu"].ToString());
            }
            if (row.Table.Columns.Contains("Type") && !string.IsNullOrEmpty(row["Type"].ToString()))
            {
                type = AppGlobal.StrToInt(row["Type"].ToString());
            }
            if (row.Table.Columns.Contains("AppName") && !string.IsNullOrEmpty(row["AppName"].ToString()))
            {
                appName = row["AppName"].ToString();
            }

            var bigCorpTypeID    = 0L;
            var bigCorpTypeCode  = default(string);
            var fineCorpTypeID   = 0L;
            var fineCorpTypeCode = default(string);

            var incidentSource = "客户报事";
            var drClass        = 1;

            PubConstant.hmWyglConnectionString = GetConnectionStr(community);

            // 新版报事控制
            var control = PMSIncidentAccept.GetIncidentControlSet();

            if (control.DefaultIndoorIncidentAcceptTypeID != 0 &&
                (incidentPlace == "户内" || incidentPlace == "户内报事" || incidentPlace == "业主权属"))
            {
                bigCorpTypeID = control.DefaultIndoorIncidentAcceptTypeID;
            }
            else if (control.DefaultPublicIncidentAcceptTypeID != 0 &&
                     (incidentPlace == "公区" || incidentPlace == "公区报事" || incidentPlace == "公共区域"))
            {
                bigCorpTypeID = control.DefaultPublicIncidentAcceptTypeID;
            }

            // 1 = 户内报事,2 = 公区报事,3 = 通知开水,4 = 通知开电,5 = 人员放行,6 = 车辆放行
            switch (type)
            {
            case 3: drClass = 2; fineCorpTypeID = control.DefaultNotifyOpenWaterIncidentAcceptTypeID; break;     // 通知开水

            case 4: drClass = 2; fineCorpTypeID = control.DefaultNotifyOpenPowerIncidentAcceptTypeID; break;     // 通知开电

            case 5: drClass = 2; fineCorpTypeID = control.DefaultLetPersonPassIncidentAcceptTypeID; break;       // 人员放行

            case 6: drClass = 2; fineCorpTypeID = control.DefaultLetCarPassIncidentAcceptTypeID; break;          // 车辆放行
            }

            if (bigCorpTypeID == 0 && fineCorpTypeID == 0)
            {
                using (var conn = new SqlConnection(PubConstant.UnifiedContionString))
                {
                    var sql = @"SELECT * FROM Tb_Control_AppIncidentAccept 
                                WHERE CommunityID IS NOT NULL AND CommunityID=@CommunityID AND IsEnable=1 AND IsDelete=0
                                UNION ALL
                                SELECT * FROM Tb_Control_AppIncidentAccept 
                                WHERE CommunityID IS NULL AND CorpID=@CorpID AND IsEnable=1 AND IsDelete=0";

                    try
                    {
                        var data = conn.Query(sql, new { CorpID = community.CorpID, CommunityID = community.Id }).FirstOrDefault();
                        if (data != null)
                        {
                            if (incidentPlace == "户内" || incidentPlace == "户内报事" || incidentPlace == "业主权属")
                            {
                                bigCorpTypeID = data.DefaultIndoorIncidentTypeID;
                            }
                            else
                            {
                                bigCorpTypeID = data.DefaultPublicIncidentTypeID;
                            }

                            incidentSource = data.DefaultIncidentSource;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            using (var conn = new SqlConnection(PubConstant.hmWyglConnectionString))
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    var sql = @"SELECT IncidentID,IncidentNum FROM Tb_HSPR_IncidentAccept
                                WHERE CommID=@CommID AND RoomID=@RoomID AND RegionalID=@RegionalID AND IncidentContent=@IncidentContent
                                AND isnull(IsDelete,0)=0 AND isnull(IsClose,0)=0 AND convert(varchar(13),IncidentDate)=convert(varchar(13),getdate())";

                    var incidentInfo = conn.Query(sql, new
                    {
                        CommID          = community.CommID,
                        RoomID          = roomId,
                        RegionalID      = regionalId,
                        IncidentContent = content
                    }, trans).FirstOrDefault();

                    if (incidentInfo != null)
                    {
                        trans.Commit();
                        return(new ApiResult(false, "此报事已受理,请勿重复提交").toJson());
                    }

                    var dispLimit = 0.0m;
                    var dealLimit = 0.0m;

                    if (bigCorpTypeID != 0)
                    {
                        sql = @"SELECT TypeCode FROM Tb_HSPR_CorpIncidentType WHERE CorpTypeID=@BigCorpTypeID;
                                SELECT isnull(DispLimit,0) FROM Tb_HSPR_CorpIncidentType WHERE CorpTypeID=@BigCorpTypeID;
                                SELECT CASE WHEN @IncidentPlace='户内' THEN isnull(DealLimit,0) ELSE isnull(DealLimit2,0) END 
                                FROM Tb_HSPR_CorpIncidentType WHERE CorpTypeID=@BigCorpTypeID;";
                        var reader = conn.QueryMultiple(sql, new { BigCorpTypeID = bigCorpTypeID, IncidentPlace = incidentPlace }, trans);
                        bigCorpTypeCode = reader.Read <string>().FirstOrDefault();
                        dispLimit       = reader.Read <decimal>().FirstOrDefault();
                        dealLimit       = reader.Read <decimal>().FirstOrDefault();
                    }

                    if (fineCorpTypeID != 0)
                    {
                        sql = @"SELECT TypeCode FROM Tb_HSPR_CorpIncidentType WHERE CorpTypeID=@CorpTypeID;";
                        fineCorpTypeCode = conn.Query <string>(sql, new { CorpTypeID = fineCorpTypeID }, trans).FirstOrDefault();
                    }

                    // 报事id
                    var incidentId = conn.Query <long>("Proc_HSPR_IncidentAccept_GetMaxNum",
                                                       new { CommID = community.CommID, SQLEx = "" }, trans, false, null, CommandType.StoredProcedure).FirstOrDefault();

                    // 报事编号
                    var incidentNum = conn.Query <long>("Proc_HSPR_IncidentAccept_GetMaxIncidentNum",
                                                        new { CommID = community.CommID, }, trans, false, null, CommandType.StoredProcedure).FirstOrDefault();

                    // 更新报事编号
                    conn.Execute("Proc_HSPR_IncidentAssigned_GetCoordinateNum_UpdateSNum",
                                 new { CommID = community.CommID, IncidentType = 3, IncidentHead = "" }, trans, null, CommandType.StoredProcedure);

                    sql = @"INSERT INTO Tb_HSPR_IncidentAccept(CommID,IncidentID,IncidentNum,IncidentPlace,IncidentSource,IncidentMode,
                                 DrClass,IsTouSu,CustID,RoomID,RegionalID,IncidentMan,IncidentDate,IncidentContent,IncidentImgs,Phone,AdmiMan,AdmiDate,
                                 DispType,DispLimit,DealLimit,ReserveDate,IsFee,Duty,BigCorpTypeID,TypeID,BigCorpTypeCode,IsStatistics,IsDelete,
                                 FineCorpTypeID,FineCorpTypeCode)
                            VALUES(@CommID,@IncidentID,@IncidentNum,@IncidentPlace,@IncidentSource,@IncidentMode,
                                 @DrClass,0,@CustID,@RoomID,@RegionalID,@IncidentMan,getdate(),@IncidentContent,@IncidentImgs,@Phone,@AdmiMan,getdate(),
                                 0,@DispLimit,@DealLimit,@ReserveDate,0,'物业类',@BigCorpTypeID,@TypeID,@BigCorpTypeCode,1,0,
                                 @FineCorpTypeID,@FineCorpTypeCode);";

                    conn.Execute(sql, new
                    {
                        CommID           = community.CommID,
                        IncidentID       = incidentId,
                        IncidentNum      = incidentNum,
                        IncidentPlace    = incidentPlace,
                        IncidentSource   = incidentSource,
                        IncidentMode     = "业主APP",
                        CustID           = custId,
                        RoomID           = roomId,
                        RegionalID       = regionalId,
                        IncidentMan      = incidentMan,
                        IncidentContent  = content,
                        IncidentImgs     = incidentImgs,
                        Phone            = phone,
                        DispLimit        = dispLimit,
                        DealLimit        = dealLimit,
                        ReserveDate      = reserveDate,
                        BigCorpTypeID    = bigCorpTypeID,
                        BigCorpTypeCode  = bigCorpTypeCode,
                        FineCorpTypeID   = fineCorpTypeID,
                        FineCorpTypeCode = fineCorpTypeCode,
                        DrClass          = drClass,
                        AdmiMan          = appName,
                        TypeID           = $",{bigCorpTypeID},"
                    }, trans);

                    trans.Commit();

                    // 推送信息
                    PMSIncidentPush.SynchPushIncidentAccepted(incidentId);

                    return(JSONHelper.FromString(true, "报事成功!稍后会有人员与您联系!"));
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(JSONHelper.FromString(false, ex.Message + ex.StackTrace));
                }
            }
        }