回复 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; |