approved.lsc 4.17 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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
    <a:init-procedure>
        <s:server-script><![CDATA[
       importPackage(Packages.com.guohuan)
                var lov_list_details;
                try {
                    var lov_list_bm = $bm('nt.sys_sms_list');
                    var lov_list_map = lov_list_bm.queryAsMap({
                        sms_id: $ctx.parameter.sms_id
                    });
                    lov_list_details = lov_list_map.getChildren();
                    $ctx.parameter.return_status = 'S';
                    $ctx.parameter.return_message = '执行成功';
                } catch (e) {
                    $ctx.parameter.return_status = 'E';
                    $ctx.parameter.return_message = String(e);
                }
            
                var result = {
                    result: $ctx.parameter.return_status,
                    message: $ctx.parameter.return_message,
                    xml_recs: []
                };
                var xml_recs = result.xml_recs;
                if (lov_list_details) {
                    for (var i = 0;i < lov_list_details.length;i++) {
                        var lov_list_detail = lov_list_details[i];
                          var  command="MT_REQUEST";//MULTI_MT_REQUEST
                          var  sms_id=lov_list_detail.sms_id
                          var  spid="9545";//账号
                          var  sppassword="JQ8GRrBo";//api密码
                          var  da="8618130615066";
                          var  dc="15"; //这些数据都是要从bm中取出,
                          var  obj = new Object(); 
                             obj.contextIn=lov_list_detail.text;
                             obj.da=da;
                             obj.command=command;
                             obj.spid=spid;
                             obj.sppassword=sppassword;
                             obj.dc=dc;
                             obj.obj=obj;
                        xml_recs.push(obj);
                    }
                }
       
               // var  contextIn="你好,这是移通网络单条下行测试短信";//发送内容
               // var  command="MT_REQUEST";//MULTI_MT_REQUEST
               // var  spid="9545";//账号
               // var  sppassword="JQ8GRrBo";//api密码
               // var  da="8618130615066";//号码前面加86
               // var  dc="15"; //这些数据都是要从bm中取出,
               // //var  smspk ; //这些数据都是要从bm中取出smslist-pk,
               // var obj = new Object(); 
               // obj.contextIn=contextIn;
               // obj.command=command;
               // obj.spid=spid;
               // obj.sppassword=sppassword;
               // obj.da=da;
               // obj.dc=dc;
               // obj.obj=obj;
              // var xml_recs=[];
              // xml_recs.push(obj);
               
            function xml_rec_execute(xml_rec) {
                if (!xml_rec) {
                    raise_app_error('no record found');
                }
                
                var contextIn = xml_rec.contextIn;
                var command = xml_rec.command;
               var spid = xml_rec.spid;
                 var sppassword = xml_rec.sppassword;
                   var da = xml_rec.da;
                     var dc = xml_rec.dc;
                var engine = $instance('uncertain.core.UncertainEngine');
                var sms = new Sms(spid,sppassword);
                var req_response = sms.sendMt(null,contextIn,command,spid,sppassword,da,dc);
                //req_response = String(req_response);
                 println("engine>>>"+req_response);
                
             $bm("nt.sys_sms_list").update({
                   sms_id: sms_id,
                   req_response: req_response
               }); 
            }
            
            for (var i = 0;i < xml_recs.length;i++) {
                var xml_single_rec = xml_recs[i];
                println(xml_single_rec);
                xml_rec_execute(xml_single_rec);
            }
       
     ]]></s:server-script>
    </a:init-procedure>
</a:service>