/// <summary> /// 产生对账明细 /// </summary> /// <param name="hb">行别</param> /// <param name="model">请求报文</param> /// <param name="outFileName">产生的对账文件</param> private void GenerateDuiZhangDetail(string hb, WtwyzzjcdzModel model, out string outFileName) { string fileName = ""; fileName += "11";//机构码 fileName += "G501"; fileName += "_W"; DateTime dt = new DateTime(); string strDate = dt.ToString("yyyyMMdd"); fileName += strDate; fileName += "."; fileName += "380910";//6位银行代号 outFileName = fileName; string filePath = BasicOperation.GetFilePath(hb) + fileName;//文件的完整路径 List <ZbmxzModel> list = db2Operation.GetZbmxzByJyrq(model.Qsrq, model.Zzrq); FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312"))) { string summaryLine = string.Empty; summaryLine += model.Yhzh; summaryLine += ","; summaryLine += strDate; summaryLine += ","; summaryLine += model.Zje; summaryLine += ","; summaryLine += model.Zbs; summaryLine += ","; sw.WriteLine(summaryLine);//汇总行 } //明细行 for (int i = 1; i <= list.Count; i++) { string detailLine = string.Empty; detailLine += i.ToString(); detailLine += ","; detailLine += list[i].Jyrq; detailLine += ","; detailLine += list[i].Jysj; detailLine += ","; detailLine += BasicOperation.GenerateBatchCode("110000000", i);//批次号 detailLine += ","; detailLine += BasicOperation.GenerateName("李", i); detailLine += ","; detailLine += list[i].Zh; detailLine += ","; detailLine += list[i].Fse; detailLine += ","; detailLine += list[i].Yhls; //银行流水 detailLine += ","; detailLine += list[i].Jdbz; //记账标志 detailLine += ","; detailLine += list[i].Yhls; //备注中添写银行流水号 detailLine += ","; using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(detailLine); } } }
/// <summary> /// 业务处理详情 /// </summary> /// <param name="hb">行别</param> /// <param name="model">请求报文</param> private void ExecuteDetail(string hb, XezfdkModel model) { //具体处理过程; //从ftp服务器取文件,本程序中是从本机读取; string fileFromPath = BasicOperation.GetFilePath(hb); string inputLine = ""; StringBuilder outputLine; DateTime dt = DateTime.Now; string strDate = dt.ToString("yyyyMMdd"); string tail = model.Wjmc.Substring(4); string outFile = "HRB_" + tail;//返回文件的名称 ; string filePath = fileFromPath + outFile; using (StreamReader sr = new StreamReader(fileFromPath + model.Wjmc, Encoding.GetEncoding("gb2312"))) { inputLine = sr.ReadLine();//读取第一行汇总数据; FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(inputLine); } for (int i = 1; i <= Convert.ToInt32(model.Zbs); i++) { inputLine = sr.ReadLine(); string[] inputArray = inputLine.Split(new char[] { '~' }); string kkzt = BatchWithHolding(1); //扣款状态,全部返回成功; string kkxx = "0" + kkzt; //扣款信息; //生成银行流水号; string yhlsh = ""; yhlsh += strDate; if (i < 10) { yhlsh += "0"; } yhlsh += i.ToString(); outputLine = new StringBuilder(); outputLine.Append("M~"); outputLine.Append(inputArray[1]); outputLine.Append("~"); outputLine.Append(inputArray[2]); outputLine.Append("~"); outputLine.Append(inputArray[3]); outputLine.Append("~"); outputLine.Append(inputArray[4]); outputLine.Append("~"); outputLine.Append(inputArray[5]); outputLine.Append("~"); outputLine.Append(inputArray[6]); outputLine.Append("~"); outputLine.Append(inputArray[7]); outputLine.Append("~"); outputLine.Append(inputArray[8]); outputLine.Append("~"); outputLine.Append(kkzt); outputLine.Append("~"); outputLine.Append(kkxx); outputLine.Append("~"); outputLine.Append(i.ToString());//汇划报文顺序号 outputLine.Append("~"); outputLine.Append(yhlsh); outputLine.Append("~"); outputLine.Append(strDate); outputLine.Append("~"); outputLine.Append(inputArray[9]); outputLine.Append("~"); outputLine.Append(inputArray[10]); outputLine.Append("~"); outputLine.Append(inputArray[11]); outputLine.Append("~"); using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(outputLine.ToString()); } //更新账表分户账和账表明细账 UpdateZbInfo(BasicOperation.GetExecutePermission(), inputArray); } } //模拟前置机动作:更新djplzxzf的zt字段; string command = "update djplzxzf set zt='3' where djhm='" + model.Pch + "'"; db2Operation.ExecuteDB2Update(command); }
/// <summary> /// 生成贷款批量处理文件 /// </summary> /// <param name="hb">行别</param> /// <param name="model">请求报文</param> private void LoanBatchWithDrawDetail(string hb, DkplshfqModel model) { //从ftp服务器取文件,本程序中是从本机读取; string fileFromPath = BasicOperation.GetFilePath(hb);; string inputLine = ""; StringBuilder outputLine; DateTime dt = DateTime.Now; string strDate = dt.ToString("yyyyMMdd"); string tail = model.Wjmc.Substring(3); string outFile = "DKR" + tail;//返回文件的名称 ; string filePath = fileFromPath + outFile; using (StreamReader sr = new StreamReader(fileFromPath + model.Wjmc, Encoding.GetEncoding("gb2312"))) { inputLine = sr.ReadLine();//读取第一行汇总数据; string[] s = inputLine.Split(new char[] { '~' }); s[3] = s[2]; inputLine = s[0] + "~"; inputLine += s[1]; inputLine += "~"; inputLine += s[2]; inputLine += "~"; inputLine += s[3]; inputLine += "~"; FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(inputLine); } for (int i = 1; i <= Convert.ToInt32(model.Zjls); i++) { inputLine = sr.ReadLine(); string[] inputArray = inputLine.Split(new char[] { '~' }); outputLine = new StringBuilder(); outputLine.Append("M~"); outputLine.Append(inputArray[1]); outputLine.Append("~"); outputLine.Append(inputArray[2]); outputLine.Append("~"); outputLine.Append(inputArray[3]); outputLine.Append("~"); outputLine.Append(inputArray[3]); outputLine.Append("~"); outputLine.Append(inputArray[5]); outputLine.Append("~"); outputLine.Append(inputArray[6]); outputLine.Append("~"); outputLine.Append("0000");//银行扣款的状态标志; outputLine.Append("~"); outputLine.Append(inputArray[8]); outputLine.Append("~"); outputLine.Append(inputArray[9]); outputLine.Append("~"); outputLine.Append(inputArray[10]); outputLine.Append("~"); outputLine.Append(inputArray[11]); outputLine.Append("~"); outputLine.Append(inputArray[12]); outputLine.Append("~"); outputLine.Append(inputArray[13]); outputLine.Append("~"); using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(outputLine.ToString()); } } } Console.WriteLine("文件处理成功"); //模拟前置机动作:更新djplzxzf的zt字段; string command = "update djplzxzf set zt='3' where djhm='" + model.Pch + "'"; db2Operation.ExecuteDB2Update(command); }
/// <summary> /// 产生对账明细 /// </summary> private void GenerateDuiZhangDetail(string hb, out string outFileName) { string strDate = DateTime.Now.ToShortDateString(); string fileName = ""; fileName += model.Jgm; fileName += "Z";//支取 fileName += "_W"; fileName += strDate; fileName += "."; fileName += "380910";//6位银行代号 outFileName = fileName; List <ZbmxzModel> list = db2Operation.GetZbmxzByRqrq(db2Operation.GetDjrqrq()); string filePath = BasicOperation.GetFilePath(hb) + fileName;//文件的完整路径 FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312"))) { //汇总行:机构码,交易日期,总金额,总笔数 string summaryLine = string.Empty; summaryLine += model.Jgm; summaryLine += ","; summaryLine += strDate; summaryLine += ","; summaryLine += model.Zje; summaryLine += ","; summaryLine += model.Zbs; summaryLine += ","; sw.WriteLine(summaryLine); } //明细行 for (int i = 1; i <= list.Count; i++) { string detailLine = string.Empty; detailLine += i.ToString(); detailLine += ","; detailLine += list[i].Jyrq; detailLine += ","; detailLine += list[i].Jysj; detailLine += ","; detailLine += BasicOperation.GenerateBatchCode("110000000", i);//批次号 detailLine += ","; detailLine += BasicOperation.GenerateName("李", i); detailLine += ","; detailLine += list[i].Zh; detailLine += ","; detailLine += list[i].Fse; detailLine += ","; detailLine += list[i].Yhls; //银行流水 detailLine += ","; detailLine += list[i].Jdbz; //记账标志 detailLine += ","; detailLine += list[i].Yhls; //备注中添写银行流水号 detailLine += ","; using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(detailLine); } } }
/// <summary> /// 银行日记账对账--生成对账明细 /// </summary> /// <param name="whichBank">行别</param> /// <param name="transcationCode">交易码</param> /// <param name="bankCount">银行账号</param> /// <param name="qsrq">起始日期</param> /// <param name="zzrq">终止日期</param> /// <returns>对账文件名称</returns> private string GenetrateCountCheckingFile(string whichBank, string transcationCode, string bankCount, string qsrq, string zzrq) { string fileName = string.Empty; fileName += "YHDZ"; fileName += bankCount; fileName += "_"; fileName += qsrq; fileName += "_"; fileName += zzrq; //详细文件内容 List <ZbmxzModel> list = db2Operation.GetZbmxzByJyrq(model.Qsrq, model.Zzrq); string filePath = BasicOperation.GetFilePath(whichBank) + fileName;//文件的完整路径 FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write); //明细行 for (int i = 1; i <= list.Count; i++) { string detailLine = string.Empty; detailLine += "M"; detailLine += "~"; detailLine += "杭州住房公积金管理中心萧山分中心";//账户名称,需要修改 detailLine += "~"; detailLine += list[i].Zh; detailLine += "~"; detailLine += list[i].Yhls; detailLine += "~"; detailLine += list[i].Pjhm; detailLine += "~"; detailLine += list[i].Jyrq; detailLine += "~"; detailLine += list[i].Jysj; detailLine += "~"; detailLine += "划款";//摘要 detailLine += "~"; detailLine += list[i].Jdbz; detailLine += "~"; detailLine += list[i].Fse; detailLine += "~"; detailLine += list[i].Ye; detailLine += "~"; detailLine += list[i].Dfhm; detailLine += "~"; detailLine += list[i].Dfzh; detailLine += "~"; using (StreamWriter sw = new StreamWriter(filePath, true, Encoding.GetEncoding("gb2312"))) { sw.WriteLine(detailLine); } //汇总行 using (StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("gb2312"))) { string summaryLine = string.Empty; summaryLine += "H"; summaryLine += "~"; summaryLine += Encoding.Default.GetString(modelMsg.Hzjfbs); //借方笔数 summaryLine += "~"; summaryLine += Encoding.Default.GetString(modelMsg.Hzjffsz); //借方发生额 summaryLine += "~"; summaryLine += Encoding.Default.GetString(modelMsg.Hzdfbs); //贷方笔数 summaryLine += "~"; summaryLine += Encoding.Default.GetString(modelMsg.Hzdffse); //贷方发生额 summaryLine += "~"; summaryLine += "435654"; //余额 summaryLine += "~"; sw.WriteLine(summaryLine); //汇总行 } } return(fileName); }