deron_tongdun_interface.lsc 2.29 KB
Newer Older
Spencer Chang's avatar
Spencer Chang 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Calvin  
    $Date: 2017年12月29日10:47:06  
    $Revision: 1.0  
    $Purpose: 同盾中间表
-->
<a:service xmlns:s="leaf.plugin.script" xmlns:a="http://www.leaf-framework.org/application" xmlns:p="uncertain.proc" trace="true">
    <a:init-procedure>
        <a:model-query fetchAll="true" model="hls.HLS530.get_batch_id" rootPath="batch_id_path"/>
        <p:echo/>
        <s:server-script><![CDATA[
            var children = $ctx.parameter.getChildren();
            
            var record_data = $ctx.get('/model/batch_id_path').getChildren();
            var batch_id = record_data[0].batch_id;
            
            function lowerJSONKey(jsonObj) {
                for (var key in jsonObj) {
                    jsonObj["\"" + key.toLowerCase() + "\""] = jsonObj[key];
                    delete(jsonObj[key]);
                }
                return jsonObj;
            }
            
            
            for (var i = 0;i < children.length;i++) {
                bp_id = children[i].bp_id;
                bp_class = children[i].bp_class;
                var bp_np_list_bm = $bm('interface.TONGDUN_INTERFACE.deron_tongdun_interface');
                var bp_org_list_bm = $bm('interface.TONGDUN_INTERFACE.deron_tongdun_interface_org');
                if (bp_class == 'NP') {
                    var bp_list_result = bp_np_list_bm.queryAsMap({
                        "bp_id": bp_id
                    });
                    var bp_list_records = bp_list_result.getChildren();
                } else {
                    var bp_list_result = bp_org_list_bm.queryAsMap({
                        "bp_id": bp_id
                    });
                    var bp_list_records = bp_list_result.getChildren();
                }
                var json_list = JSON.stringify(bp_list_records);
                json_list = json_list.replace(/\[|]/g, '');
                // println(json_list);
                $bm('interface.TONGDUN_INTERFACE.deron_tongdun_interface').update({
                    batch_id: batch_id,
                    bp_id: bp_id,
                    json_list: json_list
                });
            }
        ]]></s:server-script>
        <p:echo/>
    </a:init-procedure>
    <!-- <a:service-output output="/parameter"/> -->
</a:service>