示例#1
0
 /// <summary>
 /// 删除
 /// </summary>
 /// yaoy    16.05.25
 /// <param name="reportFilesId"></param>
 /// <returns></returns>
 public bool Delete(int reportFilesId)
 {
     try
     {
         List <ReportInfo> reportInfo = new DAL.BankCredit.ReportMapper().Find(reportFilesId);
         if (reportInfo.Count > 0)
         {
             foreach (var item in reportInfo)
             {
                 new DAL.BankCredit.TempRecordMapper().DeleteByReportId(item.ReportID);
             }
         }
         reportFilesMapper.Delete(reportFilesId);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// 数据跨信息记录校验
        /// </summary>
        /// yand    16.09.27
        /// <param name="infoType">信息记录实体</param>
        /// <param name="metaInfo">数据元实体</param>
        /// <param name="info">前端传递过来的键值对值</param>
        /// <param name="recordID">信息记录保存的ID</param>
        /// <param name="message">返回的错误信息</param>
        /// <returns></returns>
        public bool DataValidate(InfoTypeInfo infoType, MetaInfo metaInfo, KeyValuePair <string, string> info, string dataSegmentParagraphCode, int recordID, int reportID, ref string message)
        {
            if (!VarificationData(metaInfo, info.Value))
            {
                throw new ApplicationException(metaInfo.Name + "数据类型错误!");
            }
            if (Encoding.GetEncoding("GB2312").GetByteCount(info.Value) > metaInfo.DatasLength)
            {
                throw new ApplicationException(metaInfo.Name + "数据长度错误!");
            }
            if (!(new CodeProofMethod().BaseInfo(infoType.InfoTypeId, info)))
            {
                throw new ApplicationException(metaInfo.Name + "下拉选项有误!");
            }
            //校验时间类型
            if (metaInfo.RuleType.TimeType == true && info.Value != "")
            {
                DateTime dt = new DateTime();
                DateTime.TryParse(info.Value, out dt);
                if (dt == null)
                {
                    throw new ApplicationException(metaInfo.Name + "时间格式有错误");
                }
            }
            //根据财务报表中信息记录类型判断借款人概况信息中借款人性质
            if (infoType.InfoTypeId == 3 || infoType.InfoTypeId == 4 || infoType.InfoTypeId == 5 || infoType.InfoTypeId == 6 || infoType.InfoTypeId == 7)
            {
                if (metaInfo.MetaCode == 7653)
                {
                    //借款人性质
                    string segmentRuleID = "D26";
                    //根据还款记录对应的借据信息记录
                    int infoid = 1;

                    ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                    string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                    if (string.IsNullOrEmpty(s))
                    {
                        throw new ApplicationException("未能找到该报文下对应的借款人概况信息记录,请先填写借款人概况信息");
                    }
                    else
                    {
                        if (s != "04" && (info.Value == "46" || info.Value == "47"))
                        {
                            throw new ApplicationException("当为“事业单位资产负债表信息记录”或“事业单位收入支出表信息记录”时,借款人概况信息中的借款人性质只能是“事业单位”");
                        }
                        if (s == "04" && (info.Value == "43" || info.Value == "44" || info.Value == "45"))
                        {
                            throw new ApplicationException("当为“2007版资产负债表信息记录”或“2007版利润及利润分配表信息记录”或“2007版现金流量表信息记录”时,借款人概况信息中的借款人性质不能为“事业单位”");
                        }
                    }
                }
            }

            //借据信息记录中贷款合同编号
            if (info.Key == "B513")
            {
                //需要获取的贷款合同信息记录中的贷款合同编号
                string segmentRuleID = "B489";
                //根据合同信息记录编号
                int infoid = 10;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, info.Value, segmentRuleID);
                if (string.IsNullOrEmpty(s) || info.Value != s)
                {
                    throw new ApplicationException("未能找到该贷款合同号码对应的贷款合同信息");
                }
            }
            if (metaInfo.MetaCode == 7511)
            {
                czType = info.Value;
                if (info.Value == "4" && recordID == 0)
                {
                    throw new ApplicationException("该条信息记录不存在,信息记录操作类型不能为删除操作");
                }
                if (info.Value == "4" && ParagraphCode == "C")
                {
                    throw new ApplicationException("当信息记录操作类型为删除时不能存在标识变更段");
                }
            }
            if (metaInfo.MetaCode == 2501)
            {
                //根据recordId获取信息获取保存的报文文件ID

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                bool result = ValidateInfos(infoType.InfoTypeId, reportInfo.ReportFileID, metaInfo.MetaCode, info, dataSegmentParagraphCode);
            }
            // 借据编号
            if (info.Key == "H566" || info.Key == "G548")
            {
                jjbh = info.Value;
            }
            //展期金额
            if (metaInfo.MetaCode == 1517)
            {
                //展期金额赋值
                zqje = info.Value;
                //需要获取的借据金额对应的段标识
                string segmentRuleID = "F523";
                //根据还款记录对应的借据信息记录
                int infoid = 11;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);
                string     s          = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                if (string.IsNullOrEmpty(s))
                {
                    throw new ApplicationException("未能找到该借据编号对应的借据信息");
                }
                else
                {
                    if (Convert.ToDouble(s) < Convert.ToDouble(info.Value))
                    {
                        throw new ApplicationException("展期金额应小于贷款业务借款中借据金额");
                    }
                }
            }
            //贷款业务展期
            if (infoType.InfoTypeId == 13)
            {
                //展期还款次数
                if (info.Key == "H567")
                {
                    zqcs = info.Value;
                }
                //展期金额
                if (info.Key == "H569")
                {
                    if (zqcs == "1")
                    {
                        ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);
                        //jjbh该展期对应的借据编号
                        //借据还款信息记录ID
                        infoType.InfoTypeId = 12;
                        string result = Validate160(infoType.InfoTypeId, reportInfo.ReportFileID, jjbh);
                        if (!string.IsNullOrEmpty(result))
                        {
                            if (Convert.ToDouble(result) != Convert.ToDouble(zqje))
                            {
                                throw new ApplicationException("对于贷款业务展期信息记录,当展期次数为1,同时该展期信息记录的对应的贷款业务借据信息记录下无还款信息记录时,展期金额等于该展期信息记录对应的最新贷款业务借据记录的借据余额");
                            }
                        }
                    }
                    //操作类型为新增
                    if (czType == "1")
                    {
                        //需要获取的展期标志对应的段标识
                        string segmentRuleID = "F532";
                        //根据还款记录对应的借据信息记录
                        int infoid = 11;

                        ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                        string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                        if (string.IsNullOrEmpty(s))
                        {
                            throw new ApplicationException("未能找到该借据编号对应的借据信息");
                        }
                        else
                        {
                            if (s == "2")
                            {
                                throw new ApplicationException("当信息记录操作类型为新增时借据信息记录中展期标志必须为‘是’");
                            }
                        }
                    }
                }
            }

            //展期起始时间
            if (info.Key == "H570")
            {
                //需要获取的借据时间对应的段标识
                string segmentRuleID = "F525";
                //根据还款记录对应的借据信息记录
                int infoid = 11;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                if (string.IsNullOrEmpty(s))
                {
                    throw new ApplicationException("未能找到该借据编号对应的借据信息");
                }
                else
                {
                    if (Convert.ToDouble(s) > Convert.ToDouble(info.Value))
                    {
                        throw new ApplicationException("展期起始日期不应该小于贷款业务借款中借据放款日期");
                    }
                }
            }
            //借据还款日期
            if (info.Key == "G549")
            {
                //需要获取的借据时间对应的段标识
                string segmentRuleID = "F525";
                //根据还款记录对应的借据信息记录
                int infoid = 11;

                ReportInfo reportInfo = new DAL.BankCredit.ReportMapper().FindByReportID(reportID);

                string s = InfoValueValidate(infoid, reportInfo.ReportFileID, info, jjbh, segmentRuleID);
                if (string.IsNullOrEmpty(s))
                {
                    throw new ApplicationException("未能找到该借据编号对应的借据信息");
                }
                else
                {
                    if (Convert.ToDouble(s) > Convert.ToDouble(info.Value))
                    {
                        throw new ApplicationException("还款日期不应该小于贷款业务借款中借据放款日期");
                    }
                }
            }
            //TODO 增加 163中的还款信息记录中的业务发生时间和借据信息中的业务发生日期的校验
            return(true);
        }