找回密码
 注册成为天翎用户
楼主: 国福龙凤

[已解决] 字段循环读取

[复制链接]
 楼主| 国福龙凤 发表于 2013-8-1 15:57:57 | 显示全部楼层
回复 9# 国福龙凤

如果把括号放在最外面,包括dql,branch却不能循环了
    var doc = getCurrentDocument();
var users = createObject("java.util.ArrayList");
var userCollection = getUsersByRoleId("11e2-f04a-1771dbb9-9be9-49c6e2fe0cfc");
var sql = "select item_cost_center_code,domainid from tlk_tm_pendingrelease_limit_detail where parent='"+doc.getId()+"'";
                        
        $PRINTER.println("#####sql######" +sql);
var datas = queryBySQL(sql);
for (var iter = datas.iterator(); iter.hasNext();) {
  var data = iter.next();
  var branch = data.getItemValueAsString("cost_center_code");
        $PRINTER.println("#####branch#######" + branch);

for(var iter = userCollection.iterator(); iter.hasNext();){
        var user = iter.next();
        var depts = user.getDepartments();
        var deptList = "";
        for(var dIter = depts.iterator(); dIter.hasNext();){
                var dept = dIter.next();
                deptList += "'"+dept.getId()+"',";
        }
        if(deptList != ""){
                deptList = deptList.substring(0,deptList.length - 1);
        } else {
                deptList = "''";
        }

        var dql = "$formname='deptcompany' and dept in ("+deptList+") and branch='"+branch+"'";
     $PRINTER.println("#####dql######" +dql);
        var count = countByDQL(dql);
        if(count > 0)
                users.add(user);
}
}


打印结果:
JsUtil:#####sql######select item_cost_center_code,domainid from tlk_tm_pendingrelease_limit_detail where parent='11e2-f5a0-c0684e91-8979-c599bc4e2a0d'
JsUtil:#####branch#######11010200
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e798-e3ca56f0-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e798-eba9df81-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e797-19fbdb61-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e797-12e63280-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e799-1e57a895-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e799-27ee5706-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e797-48ed86d4-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-b0f5ded7-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e799-7d2b2bdb-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-c018d709-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-b910e9c8-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e799-4037fdc8-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-a2252556-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-e96d21bc-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-c9e8e4fa-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-e0dfccfb-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-f10e68cd-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e796-f9af1e7e-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e797-02c68acf-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e799-4778ae49-8026-e1373cbbbaff') and branch='11010200'
JsUtil:#####dql######$formname='deptcompany' and dept in ('11e2-e799-74e62aba-8026-e1373cbbbaff') and branch='11010200'

users;
kimi 发表于 2013-8-1 16:08:40 | 显示全部楼层
您好:你的代码打印完了么?看来你的代码有两层for循环呀,你现在打印的还是你里层for循环的东西呀。
 楼主| 国福龙凤 发表于 2013-8-1 16:54:14 | 显示全部楼层
回复 12# kimi


    已经打印完了,我打印的是dql那段
kimi 发表于 2013-8-1 17:51:27 | 显示全部楼层
电话和客户进行沟通,先让客户把里层的for循环给屏蔽掉,然后再把dql语句放到第一个for循环里面,再看执行的情况。
 楼主| 国福龙凤 发表于 2013-8-8 14:48:28 | 显示全部楼层
问题已解决,谢谢
david 发表于 2013-8-8 14:53:36 | 显示全部楼层
感谢楼主反馈,该贴结贴。

本版积分规则

手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-9-26 20:43

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表