hsbc_downing_file.lsc 3.19 KB
Newer Older
panhong18943's avatar
panhong18943 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: wangwei5743
    $Date: 2017-8-17 上午10:38:31
    $Revision: 1.0
    $Purpose: 农行代扣接口生成txt
-->
<a:service xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <s:server-script><![CDATA[
            importPackage(Packages.java.lang);
            importPackage(Packages.java.io);

            importPackage(java.util.zip);
            importPackage(java.io); /*可以传入参数*/
            importPackage(Packages.com.hand.hsbc);

            function main() {
				//以下参数请查看class目录下paraconfig.properties文件进行配置
				var URL = AuthTypeMode.getProperties("URL");
				var USER_NAME = AuthTypeMode.getProperties("USER_NAME");
				var PORT = AuthTypeMode.getProperties("PORT");
				var ROOT_PATH = AuthTypeMode.getProperties("ROOT_PATH");
				var KEY_PATH = AuthTypeMode.getProperties("KEY_PATH");
				var AUTH_CODE = AuthTypeMode.getProperties("AUTH_CODE");
				var DOWN_FILEDIR = AuthTypeMode.getProperties("DOWN_FILEDIR");
				var HSBC_BANK_CODE = AuthTypeMode.getProperties("HSBC_BANK_CODE");
				var SYSTEM_FLAG = AuthTypeMode.getProperties("SYSTEM_FLAG");

                var date=new Date();
                var year=date.getFullYear();
                var month=date.getMonth()+1;
                DOWN_FILEDIR = DOWN_FILEDIR+year+"\\"+month+"\\";
                var tranfer_dir= new File(String(DOWN_FILEDIR));
                if(!tranfer_dir.exists()){
                    //如果文件夹不存在,创建年月文件夹
                    tranfer_dir.mkdirs();//创建文件夹
                }

				var sftpTool = new SftpTool(URL,USER_NAME,PORT);
				var down_code= sftpTool.downloaddiff(ROOT_PATH,SYSTEM_FLAG,HSBC_BANK_CODE, DOWN_FILEDIR, new AuthTypeMode(AUTH_CODE,KEY_PATH));

				//生成log_id
				var log_bm = new ModelService('hsbc.HSBC110.hsbc_get_log_id');
				var res = log_bm.queryAsMap();
				var arr = res.getChildren();
				var log_id = arr[0].log_id;

				log_bm.insert({
					log_id: log_id,
					interface_code:'HSBC_DOWN',
					reqsn:'',
					request:down_code,
					send_return_code:'DOWN_FINISHED'
				});

            //var down_code='ACK1PSRV3.PC000018926.20220118153157978927.20220118073230005.XML;ACK2PSRV3.PC000018926.20220118153157978927.20220118073238006.XML';
				try {
59
        if (true) {
panhong18943's avatar
panhong18943 committed
60 61 62 63 64 65 66 67 68
						//解析XML文件2个,先修改下载状态。 建议还是解析XML和修改下载状态独立吧
						var bm = $bm('hsbc.HSBC120.update_down_file_status');
						var fileNames = down_code.split(';');

						for (var i = 0;i < fileNames.length;i++) {
							var file_path=DOWN_FILEDIR+fileNames[i];
							var xml_str=SaxReaderXml.xmlToString(file_path);


69
                                if (true) {
panhong18943's avatar
panhong18943 committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
								bm.insert({
									file_name:fileNames[i],
									file_path:file_path.toString(),
									xml_str:xml_str
								});
							}
						}
					}
				} catch (e) {
					raise_app_error(e);
					println(e);
				}
				println('LSC执行完成');
            }
            main();
            ]]></s:server-script>
        <p:echo/>
    </a:init-procedure>
    <a:service-output output="/parameter"/>
</a:service>