Ejemplo n.º 1
0
 public ReturnCountyCheck Get(NoVerifyAddCountryCheck requset)
 {
     return(CountryPerson.AddCheck(requset));
 }
        public ReturnCountyCheck AddCheck(NoVerifyAddCountryCheck requset)
        {
            using (var db = DbFactory.Open())
            {
                if (string.IsNullOrEmpty(adcd))
                {
                    throw new Exception("请重新登录");
                }
                var auditCounty        = new AuditCounty();
                var returnCountryCheck = new ReturnCountyCheck();

                auditCounty.Year          = requset.year;
                auditCounty.CountyADCD    = adcd;
                auditCounty.CountyAddTime = DateTime.Now;
                var oldAuditCountry = db.Single <AuditCounty>(x => x.CountyADCD == adcd);
                int auditnum        = 1;
                if (null != oldAuditCountry)
                {
                    auditnum = oldAuditCountry.AuditNums.Value + 1;
                }
                //查询数据有没有更改
                var bulid = db.From <CountryPerson>().Where(x => x.adcd == adcd).And(x => x.AuditNums == auditnum);
                var list  = db.Select <CountryPerson>(bulid);
                //2种状态一种是第一次提交另外就是第二次提交
                if (oldAuditCountry != null)
                {
                    //审核不通过的2种状态一种更改过数据一种没更改数据
                    if (oldAuditCountry.Status == -1)
                    {
                        if (list.Count == 0)
                        {
                            returnCountryCheck.IsSuccess    = false;
                            returnCountryCheck.CheckStatus  = oldAuditCountry.Status;
                            returnCountryCheck.CheckSuggest = db.Select <AuditCountyDetails>("select Remarks,max(AuditTime) from dbo.AuditCountyDetails where  CountyID='" + oldAuditCountry.ID + "' group by Remarks ")[0].Remarks;
                            return(returnCountryCheck);
                        }
                    }
                    //审核种
                    else if (oldAuditCountry.Status == 1)
                    {
                        returnCountryCheck.IsSuccess    = false;
                        returnCountryCheck.CheckStatus  = oldAuditCountry.Status;
                        returnCountryCheck.CheckSuggest = "";
                        return(returnCountryCheck);
                    }
                    auditCounty.AuditNums  = oldAuditCountry.AuditNums + 1;
                    auditCounty.Status     = 1;
                    auditCounty.operateLog = null;
                    auditCounty.ID         = db.Select <AuditCounty>("select * from dbo.AuditCounty  where CountyADCD='" + adcd + "' and Year='" + DateTime.Now.Year + "'")[0].ID;
                }
                else
                {
                    var bulidFirst = db.From <CountryPerson>().Where(x => x.adcd == adcd);
                    var listFirst  = db.Select <CountryPerson>(bulidFirst);
                    //第一次没有记录就提交
                    if (listFirst.Count == 0)
                    {
                        returnCountryCheck.IsSuccess    = false;
                        returnCountryCheck.CheckStatus  = 3;
                        returnCountryCheck.CheckSuggest = "提交后未更改数据";
                        return(returnCountryCheck);
                    }
                    //第一次提交
                    auditCounty.AuditNums  = 1;
                    auditCounty.Status     = 1;
                    auditCounty.operateLog = null;
                    if (db.Insert <AuditCounty>(auditCounty) == 1)
                    {
                        returnCountryCheck.IsSuccess    = true;
                        returnCountryCheck.CheckStatus  = 3;
                        returnCountryCheck.CheckSuggest = "";
                        #region 日志
                        StringBuilder sb = new StringBuilder();
                        sb.Append("在栏目{组织责任/县级防汛防台责任人}下,{" + RealName + "}第{" + auditCounty.AuditNums + "}次提交了责任人审核申请");
                        logHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增);
                        #endregion
                    }
                    else
                    {
                        returnCountryCheck.IsSuccess    = false;
                        returnCountryCheck.CheckStatus  = 3;
                        returnCountryCheck.CheckSuggest = "";
                    }
                    return(returnCountryCheck);
                }
                //审核失败未更改数据
                if (list.Count == 0)
                {
                    returnCountryCheck.IsSuccess    = false;
                    returnCountryCheck.CheckStatus  = 3;
                    returnCountryCheck.CheckSuggest = "提交后未更改数据";
                    return(returnCountryCheck);
                }
                //更新数据库
                if (db.Update <AuditCounty>(auditCounty) == 1)
                {
                    returnCountryCheck.IsSuccess    = true;
                    returnCountryCheck.CheckStatus  = 3;
                    returnCountryCheck.CheckSuggest = "";
                    #region 日志
                    StringBuilder sb = new StringBuilder();
                    sb.Append("在栏目{组织责任/县级防汛防台责任人}下,{" + RealName + "}第{" + auditCounty.AuditNums + "}次提交了责任人审核申请");
                    logHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新);
                    #endregion
                }
                else
                {
                    returnCountryCheck.IsSuccess    = false;
                    returnCountryCheck.CheckStatus  = 3;
                    returnCountryCheck.CheckSuggest = "";
                }
                return(returnCountryCheck);
            }
        }