package uap.itf.bq.license;
import nc.bs.framework.common.NCLocator;
import nc.bs.framework.common.RuntimeEnv;
import nc.pub.iufo.exception.UFOSrvException;
import com.ufida.iufo.pub.tools.AppDebug;
/**
* 报表license校验工具
* @author
*
*/
public class BQLicenseUtil {
/**
* 报表平台中的自由报表产品license标志号
*/
public static final String REPORT_PRODUCT_OF_SYSTEM = "14130RPTM01";
/**
* 商业分析平台中的自由报表产品license标志号
*/
public static final String REPORT_PRODUCT_OF_BQ = "05030RPTM01";
/**
* 报表平台中的自由报表license校验(报表数量不允许与license相同)
* @return
*/
public static boolean checkLicense() {
return checkLicense(REPORT_PRODUCT_OF_SYSTEM);
}
/**
* 报表平台中的自由报表license校验
* @param isAllowSame :报表数量是否允许与license相同(执行时允许数量与license相同,新增、导入、粘贴时不允许相同)
* @return
*/
public static boolean checkLicense(boolean isAllowSame) {
return checkLicense(isAllowSame , REPORT_PRODUCT_OF_SYSTEM);
}
/**
* 报表license校验
* @param product :产品license标志号
* @return
*/
public static boolean checkLicense(String product) {
return checkLicense(false , product);
}
/**
* 报表license校验
* @param product :产品license标志号
* @return
*/
public static boolean checkLicense(boolean isAllowSame , String product) {
// 开发环境不走license校验
if(RuntimeEnv.getInstance().isDevelopMode())
return true ;
try {
ILicenseService srv = NCLocator.getInstance().lookup(
ILicenseService.class);
return srv.isReportCountLessThanLicense(isAllowSame , product);
// return srv.isReportCountLessThanLicense(isAllowSame , product) || PrintCil.isTraining();
} catch (UFOSrvException ex) {
AppDebug.debug(ex);
}
AppDebug.debug(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID(
"1413006_0", "01413006-1576")/* @res "报表数目已达到产品授权数" */);
return false;
}
}
package uap.itf.bq.license;
import com.ufida.iufo.pub.tools.AppDebug;
import nc.bs.dao.BaseDAO;
import nc.bs.dao.DAOException;
import nc.bs.framework.common.NCLocator;
import nc.itf.uap.IUAPQueryBS;
import nc.itf.uap.cil.ICilService;
import nc.pub.iufo.exception.UFOSrvException;
import nc.pub.iufo.processor.CountQryProcessor;
import nc.pub.smart.util.SmartUtilities;
public class LicenseService implements ILicenseService{
/**
* /**
* 报表数量是否超过license
* @param isAllowSame:报表数量是否允许与licensee相同
* @param product:产品
* @return
* @throws UFOSrvException
*/
@Override
public boolean isReportCountLessThanLicense(boolean isAllowSame,
String product) throws UFOSrvException {
int license = 0;
ICilService cilSrv = (ICilService) NCLocator.getInstance().lookup(ICilService.class);
if (cilSrv.isNCDEMO())
license = 50;
else
license = cilSrv.getProductLicense(product);
Integer count = 0 ;
if (BQLicenseUtil.REPORT_PRODUCT_OF_SYSTEM.equals(product)) {
count = getReportCount(product) + getPivotCount() + getDashboardCount();
}else{
count = getReportCount(product);
}
if (count <= license) {
//如果允许报表数=license(比如报表执行过程中的license校验),则返回true
if (!isAllowSame && count == license) {
return false;
}
return true;
} else {
AppDebug.debug(nc.vo.ml.NCLangRes4VoTransl.getNCLangRes().getStrByID("1413006_0", "01413006-1578", null,
new String[] { Integer.valueOf(license).toString() })/*
* @res ""报表数目已达到产品授权数(授权数=
* " + license + ")""
*/);
return false;
}
}
/**
* 获得自定义自由报表数量
* @param reportType
* @return
* @throws UFOSrvException
*/
private Integer getReportCount(String reportType) throws UFOSrvException {
String sql = "select count(id) from iufo_freereport ";
if (BQLicenseUtil.REPORT_PRODUCT_OF_SYSTEM.equals(reportType)) {
sql += " where pk_dir not in (select pk_dir from iufo_freerep_dir where sysInit = 'Y' or modulecode = 'hr' or modulecode = 'bq')";
} else if(BQLicenseUtil.REPORT_PRODUCT_OF_BQ.equals(reportType)) {
sql += "where pk_dir in (select pk_dir from iufo_freerep_dir where modulecode = 'bq')";
}
try {
IUAPQueryBS querySrv = NCLocator.getInstance().lookup(IUAPQueryBS.class);
Integer iCount = (Integer) querySrv.executeQuery(sql, new CountQryProcessor());
return iCount;
} catch (Exception ex) {
AppDebug.debug(ex);
throw new UFOSrvException();
}
}
/**
* 获得自定义透视表数量
* @return
* @throws UFOSrvException
*/
private Integer getPivotCount() throws UFOSrvException{
String sql = "select count(pk_def) from bi_pivot_def where sysInit is null or sysInit = 'N'";
BaseDAO dao = new BaseDAO(SmartUtilities.getDefDsName());
try {
Integer iCount = (Integer) dao.executeQuery(sql, new CountQryProcessor());
return iCount;
} catch (DAOException e) {
AppDebug.debug(e);
throw new UFOSrvException();
}
}
/**
* 获得自定义仪表板数量
* @return
* @throws UFOSrvException
*/
private Integer getDashboardCount() throws UFOSrvException{
String sql = "select count(pk) from bi_dashboard_def where sysInit is null or sysInit = 'N'";
BaseDAO dao = new BaseDAO(SmartUtilities.getDefDsName());
try {
Integer iCount = (Integer) dao.executeQuery(sql, new CountQryProcessor());
return iCount;
} catch (DAOException e) {
AppDebug.debug(e);
throw new UFOSrvException();
}
}
}
NC65_自定义报表超过license解除补丁.zip 补丁下载:
链接:https://pan.baidu.com/s/1YEtUXPDTzX7zpNwyB3Ov_Q
提取码:ls5v