/// <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); }