2018-06-03 22:26:41 +08:00

223 lines
6.5 KiB
Java

package com.amarsoft.dict.als.manage;
import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.awe.res.AppManager;
import com.amarsoft.awe.res.MenuManager;
import com.amarsoft.dict.als.cache.CodeCache;
import com.amarsoft.dict.als.cache.NameCache;
public class NameManager
{
public static String getItemName(String sCodeNo, String sItemNo)
throws Exception
{
return getItemName(sCodeNo, sItemNo, null);
}
public static String getItemName(String sCodeNo, String sItemNo, String language) throws Exception {
return CodeCache.getItemName(sCodeNo, sItemNo, language);
}
public static String getName(String sID, String sType)
throws Exception
{
if ("User".equalsIgnoreCase(sType)) {
return getUserName(sID);
}
if ("Org".equalsIgnoreCase(sType)) {
return getOrgName(sID);
}
if ("Business".equalsIgnoreCase(sType)) {
return getBusinessName(sID);
}
if ("App".equals(sType)) {
return getAppName(sID);
}
if ("Role".equals(sType)) {
return getRoleNames(sID);
}
if ("Customer".equalsIgnoreCase(sType)) {
return getCustomerName(sID);
}
return sID;
}
public static String getUserNames(String sUserIDs)
throws Exception
{
String[] userIDArray = sUserIDs.split("\\,");
String sUserNames = "";
for (int i = 0; i < userIDArray.length; i++) {
if (i == 0)
sUserNames = getUserName(userIDArray[i]);
else {
sUserNames = sUserNames + "," + getUserName(userIDArray[i]);
}
}
return sUserNames;
}
/*public static String getCustManageName(String sCustomerID) throws Exception {
if ((sCustomerID == null) || ("".equals(sCustomerID))) return "";
String sManagerUserID = getCustManageUserID(sCustomerID);
if ((sManagerUserID == null) || ("".equals(sManagerUserID))) return "";
return getUserName(sManagerUserID);
}*/
public static String getOrgNames(String sOrgIDs)
throws Exception
{
String[] orgIDArray = sOrgIDs.split("\\,");
String sOrgNames = "";
for (int i = 0; i < orgIDArray.length; i++) {
if (i == 0)
sOrgNames = getOrgName(orgIDArray[i]);
else {
sOrgNames = sOrgNames + "," + getOrgName(orgIDArray[i]);
}
}
return sOrgNames;
}
/*public static String getCustManageOrgName(String sCustomerID) throws Exception {
if ((sCustomerID == null) || ("".equals(sCustomerID))) return "";
String sManagerOrgID = getCustManageOrgID(sCustomerID);
if ((sManagerOrgID == null) || ("".equals(sManagerOrgID))) return "";
return getOrgName(sManagerOrgID);
}*/
public static String getObjectName(String sObjectType)
throws Exception
{
return ObjectTypeManager.getObjectTypeName(sObjectType);
}
public static String getAppName(String sAppID)
throws Exception
{
return AppManager.getAppName(sAppID);
}
public static String getMenuName(String sMenuID)
throws Exception
{
return MenuManager.getMenuName(sMenuID);
}
public static String getRoleName(String sRoleID)
throws Exception
{
return RoleManager.getRoleName(sRoleID);
}
public static String getRoleNames(String sRoleIDs)
throws Exception
{
String[] roleIDArray = sRoleIDs.split("\\,");
String sRoleNames = "";
for (int i = 0; i < roleIDArray.length; i++) {
if (i == 0)
sRoleNames = getRoleName(roleIDArray[i]);
else {
sRoleNames = sRoleNames + "," + getRoleName(roleIDArray[i]);
}
}
return sRoleNames;
}
public static String getNames(String sType, String sIDs)
throws Exception
{
String sNames = null;
if ("Role".equals(sType))
sNames = getRoleNames(sIDs);
else {
sNames = sIDs;
}
return sNames.replaceAll(",", "\n");
}
public static String getLength(String str, String adjustLength)
{
return str.length() / Integer.parseInt(adjustLength) - 1 + "";
}
public static String isNull1(String str)
{
if ((str == null) || (str.equals(""))) {
return "0";
}
return "1";
}
public static String isNull2(String str1, String str2)
{
if (str1 == null) str1 = "";
if (str2 == null) str2 = "";
String str = str1 + str2;
return getLength(str, str2.length() + "");
}
public static String getUserName(String sUserID)
throws Exception
{
if ((sUserID == null) || ("".equals(sUserID))) return "";
return NameCache.getName("jbo.sys.USER_INFO", "UserName", "UserID", sUserID);
}
public static String getOrgName(String sOrgID)
throws Exception
{
if ((sOrgID == null) || ("".equals(sOrgID))) return "";
return NameCache.getName("jbo.sys.ORG_INFO", "OrgName", "OrgID", sOrgID);
}
public static String getCustomerName(String sCustomerID)
throws Exception
{
return NameCache.getName("jbo.app.tenwa.customer.CUSTOMER_INFO", "CustomerName", "CustomerID", sCustomerID);
}
public static String getBusinessName(String sTypeNo)
throws Exception
{
return NameCache.getName("jbo.app.BUSINESS_TYPE", "TypeName", "TypeNo", sTypeNo);
}
public static String getFomatDocType(String typeNo)
throws Exception
{
return NameCache.getName("jbo.app.FORMATDOC_TYPE", "TYPETITLE", "TYPENO", typeNo);
}
/*public static String getCustManageUserID(String sCustomerID)
throws Exception
{
if ((sCustomerID == null) || ("".equals(sCustomerID))) return "";
BizObjectQuery bq = JBOFactory.createBizObjectQuery("jbo.app.CUSTOMER_BELONG", "select UserID from O where BelongAttribute = '1' and CustomerID =:CustomerID");
BizObject bo = bq.setParameter("CustomerID", sCustomerID).getSingleResult(false);
return bo == null ? "" : bo.getAttribute("UserID").getString();
}*/
/*public static String getCustManageOrgID(String sCustomerID)
throws Exception
{
if ((sCustomerID == null) || ("".equals(sCustomerID))) return "";
BizObjectQuery bq = JBOFactory.createBizObjectQuery("jbo.app.CUSTOMER_BELONG", "select OrgID from O where BelongAttribute = '1' and CustomerID =:CustomerID");
BizObject bo = bq.setParameter("CustomerID", sCustomerID).getSingleResult(false);
return bo == null ? "" : bo.getAttribute("OrgID").getString();
}*/
public static String getProjectNameByID(String projectID) throws Exception{
BizObject bo = JBOFactory.createBizObjectQuery(LB_PROJECT_INFO.CLASS_NAME, "ID=:ID").setParameter("ID", projectID).getSingleResult(false);
return bo != null?bo.getAttribute("PROJECT_NAME").getString():"";
}
}