296 lines
9.8 KiB
Java
296 lines
9.8 KiB
Java
package com.amarsoft.dict.als.manage;
|
||
|
||
import jbo.com.tenwa.lease.comm.BC_PAY_INFO_LOG;
|
||
import jbo.com.tenwa.lease.comm.LB_INSURANCE_INFO;
|
||
import jbo.com.tenwa.lease.comm.LB_PROJECT_INFO;
|
||
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
import com.amarsoft.are.jbo.BizObject;
|
||
import com.amarsoft.are.jbo.JBOException;
|
||
import com.amarsoft.are.jbo.JBOFactory;
|
||
import com.amarsoft.are.jbo.JBOTransaction;
|
||
import com.amarsoft.awe.res.AppManager;
|
||
import com.amarsoft.awe.res.MenuManager;
|
||
import com.amarsoft.awe.util.ASResultSet;
|
||
import com.amarsoft.awe.util.SqlObject;
|
||
import com.amarsoft.awe.util.Transaction;
|
||
import com.amarsoft.dict.als.cache.CodeCache;
|
||
import com.amarsoft.dict.als.cache.NameCache;
|
||
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
|
||
import com.tenwa.officetempalte.util.FileOperatorUtil;
|
||
|
||
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():"";
|
||
}
|
||
|
||
public static String getYears(String ContractId,String i) throws Exception{
|
||
System.out.println(ContractId+"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"+i);
|
||
String sql = "select insurer_end_date from (SELECT @rownum <20><>= @rownum + 1 AS rownum,insurer_end_date FROM LB_INSURANCE_INFO,(SELECT @rownum <20><>= 0) t WHERE contract_id ='"+ContractId+"' ORDER BY insurer_start_date ) t WHERE t.rownum= '"+i+"';";
|
||
//SqlObject asql = new SqlObject(sql);
|
||
//
|
||
|
||
SqlObject so = new SqlObject(sql);
|
||
so.setDebugSql(so.getDebugSql().replaceAll("<EFBFBD><EFBFBD>", ":"));
|
||
so.setOriginalSql(so.getOriginalSql().replaceAll("<EFBFBD><EFBFBD>", ":"));
|
||
so.setRunSql(so.getRunSql().replaceAll("<EFBFBD><EFBFBD>", ":"));
|
||
Transaction Sqlca = Transaction.createTransaction("als");
|
||
ASResultSet rs = Sqlca.getASResultSet(so);
|
||
// so.setDebugSql(so.getDebugSql().replaceAll("<22><>", ":"));
|
||
//so.setOriginalSql(so.getOriginalSql().replaceAll("<22><>", ":"));
|
||
// so.setRunSql(so.getRunSql().replaceAll("<22><>", ":"));
|
||
while (rs.next()) {
|
||
rs.getString("insurer_end_date");
|
||
}
|
||
// List<Map<String,String>> ds = DataOperatorUtil.getDataBySql(JBOFactory.createJBOTransaction(), sql, null);
|
||
return "";//ds.get(0).get("INSURER_END_DATE");
|
||
// BizObject bo=JBOFactory.createBizObjectQuery(LB_INSURANCE_INFO.CLASS_NAME, "select * from (SELECT @rownum := @rownum + 1 AS rownum,insurer_end_date FROM O,(SELECT @rownum := 0) t WHERE contract_id ='"+ContractId+"' ORDER BY insurer_start_date ) t WHERE t.rownum= '"+i+"'").getSingleResult(false);
|
||
// return bo.getAttribute(LB_INSURANCE_INFO.INSURER_END_DATE).getString();
|
||
}
|
||
//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD>θ<EFBFBD><CEB8><EFBFBD>ʱ<EFBFBD><CAB1>
|
||
public static String getLastTime(String project_no){
|
||
String lastTime="";
|
||
String sql="select max(O.inputtime) as lastTime from bc_pay_info_log O where O.project_no='"+project_no+"' group by O.project_no ";
|
||
Transaction Sqlca = null;
|
||
JBOTransaction tx;
|
||
try {
|
||
tx = JBOFactory.createJBOTransaction();
|
||
Sqlca = Transaction.createTransaction(tx);
|
||
lastTime = Sqlca.getString(sql);
|
||
} catch (JBOException e1) {
|
||
// TODO Auto-generated catch block
|
||
e1.printStackTrace();
|
||
} catch (Exception e) {
|
||
// TODO Auto-generated catch block
|
||
e.printStackTrace();
|
||
}
|
||
|
||
/* try {
|
||
BizObject bo = JBOFactory.createBizObjectQuery(BC_PAY_INFO_LOG.CLASS_NAME, sql).getSingleResult(false);
|
||
lastTime = bo.getAttribute("lastTime").toString();
|
||
} catch (JBOException e) {
|
||
e.printStackTrace();
|
||
}*/
|
||
return lastTime;
|
||
}
|
||
|
||
/*//<2F><>ȡ<EFBFBD><C8A1>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
|
||
public static String getItemName(String codeno,String AddressCode) throws Exception{
|
||
if("".equals(AddressCode))
|
||
return "";
|
||
JBOTransaction tx = JBOFactory.createJBOTransaction();
|
||
Transaction Sqlca = Transaction.createTransaction(tx);
|
||
String addressName = Sqlca.getString("select cl.itemname from code_library cl where cl.codeno='"+codeno+"' and cl.itemno='"+AddressCode+"'");
|
||
Sqlca.disConnect();
|
||
return addressName;
|
||
}*/
|
||
} |