在ACT方案中,每个用户分配了相应的相应的仓库与库位,避免了一些不相关的仓存操作。
在ax中用户所属仓存放在表ACT_LocationOwnerAuth中(地点授权),通常控制用户使用所属仓一般是在Lookup时过滤,使操作无法选择不相关的仓库仓位,从而实现仓库权限控制。
下面看一段代码,这段代码用于Lookup仓库之用:
private void Fld2_1_Lookup()
{
Query query;
QueryBuildDataSource qbds;
ACT_InventLocationResults inventLocationResults;
ACT_InventLocationLookup curInventLocationResults;
SysTableLookup tableLookup = SysTableLookup::newParameters(tableNum(ACT_InventLocationLookup), dlgWMSLocationId.control());
;
inventLocationResults = new ACT_InventLocationResults();
curInventLocationResults = inventLocationResults.get(); //获取当前用户所有仓库
tableLookup.parmTmpBuffer(curInventLocationResults);
tableLookup.addLookupfield(fieldNum(ACT_InventLocationLookup, InventLocationId));
tableLookup.addLookupfield(fieldNum(ACT_InventLocationLookup, Name));
tableLookup.performFormLookup();
}
上述代码中,使用了类ACT_InventLocationResults.Get()方法获取当前用户所属仓库。在此方法中循环读取了ACT_LocationOwnerAuth这个表,将用户对应的仓库记录插入到临时表ACT_InventLocationLookup中,然后返回此临时表。
再接着,就是Lookup用户所属的仓位,方法与上面差不多。利用刚才选择的仓库进一步Lookup出相应的所属仓位,同样的是ACT_LocationOwnerAuth表。
再看代码:(Lookup所属仓位之用)
private void Fld3_1_Lookup()
{
SysTableLookup tableLookup;
TableId tableId;
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildDataSource qbdsAuth;
QueryBuildRange queryBuildRange;
QueryBuildRange qbrUser;
DictRelation dr;
Object control = dlg.formRun().controlCallingMethod();
;
tableLookup = SysTableLookup::newParameters(tableNum(WMSLocation), control);
query = new Query();
queryBuildDataSource = query.addDataSource(tablenum(WMSLocation));
qbdsAuth = queryBuildDataSource.addDataSource(tablenum(ACT_LocationOwnerAuth));
dr = new DictRelation(tablenum(ACT_LocationOwnerAuth));
dr.loadFieldRelation(fieldnum(ACT_LocationOwnerAuth, InventLocationId));
dr.loadFieldRelation(fieldnum(ACT_LocationOwnerAuth, WMSLocationId));
qbdsAuth.addRelation(dr);
queryBuildRange = queryBuildDataSource.addRange(fieldnum(WMSLocation, InventLocationId));
qbrUser = qbdsAuth.addRange(fieldnum(ACT_LocationOwnerAuth, UserId));
queryBuildRange.value(queryValue(dlgLocationId.value()));
queryBuildDataSource.addRange(fieldnum(WMSLocation, ACT_Status)).value(sysQuery::value(ACT_Status::InUse)); //注意此状态
qbrUser.value(queryValue(curuserid()));
tableLookup.parmQuery(query);
tableLookup.addLookupfield(fieldnum(WMSLocation, wMSLocationId));
tableLookup.addLookupfield(fieldnum(WMSLocation, InventLocationId));
tableLookup.addLookupfield(fieldnum(WMSLocation,Name));
tableLookup.addLookupfield(fieldnum(WMSLocation,CNName));
tableLookup.addLookupfield(fieldnum(WMSLocation, LocationType));
tableLookup.addLookupfield(fieldnum(WMSLocation, StoreAreaId));
tableLookup.performFormLookup();
}