标签:
CRM项目中,我们为了满足客户的需求,我们在设计数据库表的时候需要预留出来几个字段,当用户提出需求的时候,我们不需要修改其他的地方只需要,系统设置这个按钮下设置自己需要的字段就行了,不知道,大家明白没有,可以通俗的说就是你界面上现在需要一个用户的性别,原来的你的界面上没有这个lebel,我们通过系统设置这个按钮动态的显示出来这个字段就行了界面上也呈现出来,这个用代码怎么实现的啊,首先我们需要通过系统设置这个按钮,用户设置的字段的名称,提交给后台,在后台我们把之前预留的字段修改成用户自己定义的名称就行了。说上去很简单,但是用代码怎么实现那,我们首先这样想,这个字段我们用什么的数据结构来存储啊,怎么才能做到让一个值对应着一个键啊,大家是不是首先想到的就是Map,Map这个数据集合在项目中用途是很大。
直接上代码,文字永远是表达不清楚的,代码最容易说事
package com.ebizwindow.crm.portlet.base; import java.io.IOException; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; import javax.portlet.PortletRequest; import javax.portlet.PortletURL; import javax.servlet.http.HttpServletRequest; import com.ebizwindow.crm.NoSuchCustomerException; import com.ebizwindow.crm.constants.PortletIDs; import com.ebizwindow.crm.constants.TableConst; import com.ebizwindow.crm.model.Activity; import com.ebizwindow.crm.model.Clue; import com.ebizwindow.crm.model.CompanyColumnDefinition; import com.ebizwindow.crm.model.Contact; import com.ebizwindow.crm.model.Contract; import com.ebizwindow.crm.model.Customer; import com.ebizwindow.crm.model.Market; import com.ebizwindow.crm.model.Opportunity; import com.ebizwindow.crm.model.Order; import com.ebizwindow.crm.model.Product; import com.ebizwindow.crm.model.ProductCategory; import com.ebizwindow.crm.model.Quotation; import com.ebizwindow.crm.model.ReceivablesPlan; import com.ebizwindow.crm.model.ReceivablesRecord; import com.ebizwindow.crm.service.ActivityLocalServiceUtil; import com.ebizwindow.crm.service.ClueLocalServiceUtil; import com.ebizwindow.crm.service.CompanyColumnDefinitionLocalServiceUtil; import com.ebizwindow.crm.service.ContactLocalServiceUtil; import com.ebizwindow.crm.service.ContractLocalServiceUtil; import com.ebizwindow.crm.service.CustomerLocalServiceUtil; import com.ebizwindow.crm.service.MarketLocalServiceUtil; import com.ebizwindow.crm.service.OpportunityLocalServiceUtil; import com.ebizwindow.crm.service.OrderLocalServiceUtil; import com.ebizwindow.crm.service.ProductCategoryLocalServiceUtil; import com.ebizwindow.crm.service.ProductLocalServiceUtil; import com.ebizwindow.crm.service.QuotationLocalServiceUtil; import com.ebizwindow.crm.service.ReceivablesPlanLocalServiceUtil; import com.ebizwindow.crm.service.ReceivablesRecordLocalServiceUtil; import com.ebizwindow.crm.utils.ActivityUtils; import com.ebizwindow.crm.utils.DateUtil; import com.ebizwindow.crm.utils.FileEntryUtil; import com.ebizwindow.crm.utils.LanguageUtil; import com.ebizwindow.crm.utils.PortletURLUtil; import com.ebizwindow.crm.utils.TextUtil; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.util.StringPool; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.model.User; import com.liferay.portal.service.CompanyLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.theme.ThemeDisplay; import com.liferay.portal.util.PortalUtil; public class DynamicDetailEntity { public static Map<String, String> getMarketValue(PortletRequest portletRequest, Long marketId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (marketId > 0){ Market market = MarketLocalServiceUtil.getMarket(marketId); if (market != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Market, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("name")) { dynamicValue.put(columnName, market.getName()); } else if (columnName.equals("code")) { dynamicValue.put(columnName, market.getCode()); } else if (columnName.equals("priority")) { dynamicValue.put(columnName, market.getPriority()); } else if (columnName.equals("type")){ dynamicValue.put(columnName, market.getType()); } else if (columnName.equals("intention")){ dynamicValue.put(columnName, market.getIntention()); } else if (columnName.equals("status")){ dynamicValue.put(columnName, market.getStatus()); } else if (columnName.equals("comments")){ dynamicValue.put(columnName, market.getComments()); } else if (columnName.equals("actualFees")) { dynamicValue.put(columnName, TextUtil.doubleToText(market.getActualFees(),2)); } else if (columnName.equals("planFees")){ dynamicValue.put(columnName, TextUtil.doubleToText(market.getPlanFees(),2)); } else if (columnName.equals("planFeedBack")){ dynamicValue.put(columnName, String.valueOf(market.getPlanFeedBack())); } else if (columnName.equals("actualFeedBack")){ dynamicValue.put(columnName, String.valueOf(market.getActualFeedBack())); } else if (columnName.equals("endDate")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getEndDate())); } else if (columnName.equals("beginDate")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getBeginDate())); } else if (columnName.equals("createDate")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getCreateDate())); } else if (columnName.equals("auditDate")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getAuditDate())); } else if (columnName.equals("editDate")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getEditDate())); } else if (columnName.equals("createUserId")){ long createUserId = market.getCreateUserId(); String createUserName = StringPool.BLANK; if (createUserId != 0L) { createUserName = UserLocalServiceUtil.getUser(createUserId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(market.getCreateDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("ownerId")){ long userId = market.getOwnerId(); User user = null ; if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); } dynamicValue.put(columnName, user != null ? user.getFirstName() + StringPool.BLANK + user.getLastName() : StringPool.BLANK); } else if (columnName.equals("editUserId")){ long editUserId = market.getEditUserId(); String editUserName = StringPool.BLANK; if (editUserId != 0L) { editUserName = UserLocalServiceUtil.getUser(editUserId).getFirstName(); editUserName += ", "; editUserName += DateUtil.formatDateTime(market.getEditDate()); } dynamicValue.put(columnName, editUserName); } else if (columnName.equals("auditUserId")){ long auditUserId = market.getAuditUserId(); String auditUserName = StringPool.BLANK; if (auditUserId != 0l) { auditUserName = UserLocalServiceUtil.getUser(auditUserId).getFirstName(); auditUserName += ", "; auditUserName += DateUtil.formatDate(market.getAuditDate()); } dynamicValue.put(columnName, auditUserName); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, market.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, market.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, market.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, market.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, market.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, market.getStrField6()); } else if (columnName.equals("strField7")){ dynamicValue.put(columnName, market.getStrField7()); } else if (columnName.equals("strField8")){ dynamicValue.put(columnName, market.getStrField8()); } else if (columnName.equals("textareaField1")){ String textareaField1 = market.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = market.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(market.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(market.getIntegerField2())); } else if (columnName.equals("floatField1")){ dynamicValue.put(columnName, TextUtil.doubleToText(market.getFloatField1(), 2)); } else if (columnName.equals("floatField2")){ dynamicValue.put(columnName, TextUtil.doubleToText(market.getFloatField2(), 2)); } else if (columnName.equals("floatField3")){ dynamicValue.put(columnName, TextUtil.doubleToText(market.getFloatField3(), 2)); } else if (columnName.equals("floatField4")){ dynamicValue.put(columnName, TextUtil.doubleToText(market.getFloatField4(), 2)); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDate(market.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, market.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, market.getAttaField2())); } } } } return dynamicValue; } public static Map<String, String> getCustomerValue(PortletRequest portletRequest, Long customerId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (customerId > 0) { Customer customer = null; try { customer = CustomerLocalServiceUtil.getCustomer(customerId); } catch (NoSuchCustomerException e) { _log.error("Exception : No Such Customer Exception " + customerId); customer = null; } if (customer != null) { List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil.searchByTableName(companyId, TableConst.CRM_Customer, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("code")) { dynamicValue.put(columnName, customer.getCode()); } else if (columnName.equals("customerName")) { dynamicValue.put(columnName, customer.getCustomerName() ); } else if (columnName.equals("customerType")) { String type = customer.getCustomerType(); dynamicValue.put(columnName, type == null?StringPool.BLANK:type); } else if (columnName.equals("source")){ String source = customer.getSource(); dynamicValue.put(columnName, source == null?StringPool.BLANK:source); } else if (columnName.equals("upCustomerId")) { String upName = StringPool.BLANK; long upId = customer.getUpCustomerId(); if (upId != 0L) { String prefix = "<a href=‘" + PortletURLUtil.getObjDetailURL( portletRequest, PortletIDs.CUSTOMER_DETAIL, upId) + "‘>"; String suffix = "</a>"; upName = prefix + CustomerLocalServiceUtil .getCustomer(upId).getCustomerName() + suffix; } dynamicValue.put(columnName, upName ); } else if (columnName.equals("contactId")) { long contactId = customer.getContactId(); String contactName = StringPool.BLANK; if (contactId > 0) { String prefix = "<a href=‘" + PortletURLUtil.getObjDetailURL( portletRequest, PortletIDs.CONTACT_DETAIL, contactId) + "‘>"; String suffix = "</a>"; contactName = prefix+ ContactLocalServiceUtil.getContact(contactId).getContactName() + suffix; } dynamicValue.put(columnName, contactName); } else if (columnName.equals("region")) { String region = customer.getRegion(); dynamicValue.put(columnName, region == null?StringPool.BLANK:region); } else if (columnName.equals("phone")) { dynamicValue.put(columnName, customer.getPhone()); } else if (columnName.equals("email")) { dynamicValue.put(columnName, customer.getEmail()); } else if (columnName.equals("mobile")) { dynamicValue.put(columnName, customer.getMobile()); } else if (columnName.equals("country")) { String country = customer.getCountry(); dynamicValue.put(columnName, country); } else if (columnName.equals("province")) { String province = customer.getProvince(); dynamicValue.put(columnName, province); } else if (columnName.equals("city")) { String city = customer.getCity(); dynamicValue.put(columnName, city); } else if (columnName.equals("area")) { String area = customer.getArea(); dynamicValue.put(columnName, area); } else if (columnName.equals("postCode")) { String postCode = customer.getPostCode(); dynamicValue.put(columnName, postCode == null ? StringPool.BLANK : postCode); } else if (columnName.equals("address")) { Locale locale = CompanyLocalServiceUtil.getCompany(companyId).getLocale(); String address = customer.getAddress(); if (!address.equals("")) { address += " <a class=‘baiduMap‘ style=‘color:#015BA7;‘ href=‘javascript:void(0);‘>" + LanguageUtil.get( PortletIDs.INITIALIZATION, locale, "baidu.map") + "</a>"; } else { address += "<a class=‘baiduMap‘ style=‘color:#015BA7;‘ href=‘javascript:void(0);‘>" + LanguageUtil.get( PortletIDs.INITIALIZATION, locale, "baidu.map.marker") + "</a>"; } dynamicValue.put(columnName, address); } else if (columnName.equals("ownerId")) { long ownerId = customer.getOwnerId(); String ownerName = StringPool.BLANK; if (ownerId != 0L) { ownerName = UserLocalServiceUtil.getUser(ownerId).getFirstName(); } dynamicValue.put(columnName, ownerName); } else if (columnName.equals("createUserId")) { long createUserId = customer.getCreateUserId(); StringBuffer createUser = new StringBuffer(StringPool.BLANK); if (createUserId != 0L) { createUser.append(UserLocalServiceUtil.getUser(createUserId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(customer.getCreateDate())); } dynamicValue.put(columnName, createUser.toString()); } else if (columnName.equals("createDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(customer.getCreateDate())); } else if (columnName.equals("editUserId")) { long editUserId = customer.getEditUserId(); StringBuffer editUser = new StringBuffer(StringPool.BLANK); if (editUserId != 0L) { editUser.append(UserLocalServiceUtil.getUser(editUserId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(customer.getEditDate())); } dynamicValue.put(columnName, editUser.toString()); } else if (columnName.equals("editDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(customer.getEditDate())); } else if (columnName.equals("ownerChangeDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(customer.getOwnerChangeDate())); } else if (columnName.equals("webSite")) { String webSite = customer.getWebSite() != null ? customer.getWebSite() : StringPool.BLANK; StringBuffer sb = new StringBuffer(StringPool.BLANK); sb.append("<a href=").append(StringPool.QUOTE).append("http://").append(webSite) .append(StringPool.QUOTE).append(StringPool.SPACE).append("target=") .append(StringPool.QUOTE).append("_blank").append(StringPool.QUOTE) .append(">").append(webSite).append("</a>"); dynamicValue.put(columnName, sb.toString()); } else if (columnName.equals("relationShip")) { String relationShip = customer.getRelationShip(); dynamicValue.put(columnName, relationShip == null ? StringPool.BLANK : relationShip); } else if (columnName.equals("industry")) { String industry = customer.getIndustry(); dynamicValue.put(columnName, industry == null ? StringPool.BLANK : industry); } else if (columnName.equals("staffNum")) { String staffNum = customer.getStaffNum(); dynamicValue.put(columnName, staffNum); } else if (columnName.equals("yearRevenue")) { double yearRevenue = customer.getYearRevenue(); dynamicValue.put(columnName, TextUtil.doubleToText(yearRevenue, 2)); } else if (columnName.equals("strField1")) { dynamicValue.put(columnName, customer.getStrField1()); } else if (columnName.equals("strField2")) { dynamicValue.put(columnName, customer.getStrField2()); } else if (columnName.equals("strField3")) { dynamicValue.put(columnName, customer.getStrField3()); } else if (columnName.equals("strField4")) { dynamicValue.put(columnName, customer.getStrField4()); } else if (columnName.equals("strField5")) { dynamicValue.put(columnName, customer.getStrField5()); } else if (columnName.equals("strField6")) { dynamicValue.put(columnName, customer.getStrField6()); } else if (columnName.equals("strField7")) { dynamicValue.put(columnName, customer.getStrField7()); } else if (columnName.equals("strField8")) { dynamicValue.put(columnName, customer.getStrField8()); } else if (columnName.equals("strField9")) { dynamicValue.put(columnName, customer.getStrField9()); } else if (columnName.equals("strField10")) { dynamicValue.put(columnName, customer.getStrField10()); } else if (columnName.equals("textareaField1")) { String textareaField1 = customer.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")) { String textareaField2 = customer.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("textareaField3")) { String textareaField3 = customer.getTextareaField3(); if (textareaField3 == null) { textareaField3 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField3); } else if (columnName.equals("textareaField4")) { String textareaField4 = customer.getTextareaField4(); if (textareaField4 == null) { textareaField4 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField4); } else if (columnName.equals("floatField1")) { double floatField1 = customer.getFloatField1(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField1, 2)); } else if (columnName.equals("floatField2")){ double floatField2 = customer.getFloatField2(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField2, 2)); } else if (columnName.equals("floatField3")){ double floatField3 = customer.getFloatField3(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField3, 2)); } else if (columnName.equals("floatField4")){ double floatField4 = customer.getFloatField4(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField4, 2)); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(customer.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(customer.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(customer.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(customer.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, customer.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, customer.getAttaField2())); } else if (columnName.equals("integerField1")) { dynamicValue.put(columnName, String.valueOf(customer.getIntegerField1())); } else if (columnName.equals("integerField2")) { dynamicValue.put(columnName, String.valueOf(customer.getIntegerField2())); } else if (columnName.equals("integerField3")) { dynamicValue.put(columnName, String.valueOf(customer.getIntegerField3())); } else if (columnName.equals("integerField4")) { dynamicValue.put(columnName, String.valueOf(customer.getIntegerField4())); } } } } return dynamicValue; } public static Map<String, String> getContactValue(PortletRequest portletRequest, Long contactId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (contactId > 0) { Contact contact = null; try { contact = ContactLocalServiceUtil.getContact(contactId); } catch (NoSuchCustomerException e) { _log.error("Exception : No Such Contact Exception " + contactId); contact = null; } if (contact != null) { List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil.searchByTableName(companyId, TableConst.CRM_Contact, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("contactName")) { dynamicValue.put(columnName, contact.getContactName()); } else if (columnName.equals("sex")) { String sex = contact.getSex(); dynamicValue.put(columnName, sex == null?StringPool.BLANK:sex); } else if (columnName.equals("customerId")) { String customerName = StringPool.BLANK ; long customerId = contact.getCustomerId(); if (customerId != 0L) { String url = PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CUSTOMER_DETAIL, customerId); HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); url += "&layoutId=" + layoutId; String prefix = "<a href=‘"+ url +"‘>"; String suffix = "</a>"; customerName = prefix+CustomerLocalServiceUtil.getCustomer(customerId).getCustomerName()+suffix; } dynamicValue.put(columnName, customerName); } else if (columnName.equals("homeDescription")) { String homeDescription = contact.getHomeDescription(); dynamicValue.put(columnName, homeDescription==null ? StringPool.BLANK : homeDescription); } else if (columnName.equals("position")) { String position = contact.getPosition(); dynamicValue.put(columnName, position==null ? StringPool.BLANK : position); } else if (columnName.equals("appellation")) { dynamicValue.put(columnName, contact.getAppellation()); } else if (columnName.equals("department")) { String departmentName = contact.getDepartment(); dynamicValue.put(columnName, departmentName == null?StringPool.BLANK : departmentName); } else if (columnName.equals("upContactId")) { String upName = StringPool.BLANK; long upId = contact.getUpContactId(); if(upId != 0L){ String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CONTACT_DETAIL, upId)+"‘>"; String suffix = "</a>"; upName = prefix+ContactLocalServiceUtil.getContact(upId).getContactName()+suffix; } dynamicValue.put(columnName, upName); } else if (columnName.equals("phone")) { dynamicValue.put(columnName, contact.getPhone()); } else if (columnName.equals("email")) { dynamicValue.put(columnName, contact.getEmail()); } else if (columnName.equals("fax")) { dynamicValue.put(columnName, contact.getFax()); } else if (columnName.equals("mobile")) { dynamicValue.put(columnName, contact.getMobile()); } else if (columnName.equals("country")) { String country = contact.getCountry(); dynamicValue.put(columnName, country); } else if (columnName.equals("province")) { String province = contact.getProvince(); dynamicValue.put(columnName, province); } else if (columnName.equals("city")) { String city = contact.getCity(); dynamicValue.put(columnName, city); } else if (columnName.equals("area")) { String area = contact.getArea(); dynamicValue.put(columnName, area); } else if (columnName.equals("postCode")) { String postCode = contact.getPostCode(); dynamicValue.put(columnName, postCode == null ? StringPool.BLANK : postCode); } else if (columnName.equals("address")) { String address = contact.getAddress(); Locale locale = CompanyLocalServiceUtil.getCompany(companyId).getLocale(); if (!address.equals("")) { address += " <a class=‘baiduMap‘ style=‘color:#015BA7;‘ href=‘javascript:void(0);‘>" + LanguageUtil.get( PortletIDs.INITIALIZATION, locale, "baidu.map") + "</a>"; } else { address += "<a class=‘baiduMap‘ style=‘color:#015BA7;‘ href=‘javascript:void(0);‘>" + LanguageUtil.get( PortletIDs.INITIALIZATION, locale, "baidu.map.marker") + "</a>"; } dynamicValue.put(columnName, address == null ? StringPool.BLANK : address); } else if (columnName.equals("homeCountry")) { String homeCountry = contact.getHomeCountry(); dynamicValue.put(columnName, homeCountry); } else if (columnName.equals("homeProvince")) { String homeProvince = contact.getHomeProvince(); dynamicValue.put(columnName, homeProvince); } else if (columnName.equals("homeCity")) { String homeCity = contact.getHomeCity(); dynamicValue.put(columnName, homeCity); } else if (columnName.equals("homePostCode")) { String homePostCode = contact.getHomePostCode(); dynamicValue.put(columnName, homePostCode==null?StringPool.BLANK : homePostCode); } else if (columnName.equals("homeDescription")) { String homeDescription = contact.getHomeDescription(); dynamicValue.put(columnName, homeDescription==null?StringPool.BLANK : homeDescription); } else if (columnName.equals("interest")) { dynamicValue.put(columnName, contact.getInterest()); } else if (columnName.equals("birthday")) { Date birthday = contact.getBirthday(); dynamicValue.put(columnName, birthday == null ? StringPool.BLANK : DateUtil.formatDateNoHour(birthday)); } else if (columnName.equals("homePhone")) { dynamicValue.put(columnName, contact.getHomePhone()); } else if (columnName.equals("relationShip")) { String relationShip = contact.getRelationShip(); dynamicValue.put(columnName, relationShip == null?StringPool.BLANK:relationShip); } else if (columnName.equals("ownerId")) { long ownerId = contact.getOwnerId(); String ownerName = StringPool.BLANK; try { if (ownerId != 0L) { User user = UserLocalServiceUtil.getUser(ownerId); ownerName = user.getFirstName(); } } catch (PortalException e) { ownerId = PortalUtil.getUserId(portletRequest); contact.setOwnerId(ownerId); ContactLocalServiceUtil.updateContact(contact, true); ownerName = UserLocalServiceUtil.getUser(ownerId).getFirstName(); } catch (SystemException e) { ownerId = PortalUtil.getUserId(portletRequest); contact.setOwnerId(ownerId); ContactLocalServiceUtil.updateContact(contact, true); ownerName = UserLocalServiceUtil.getUser(ownerId).getFirstName(); } dynamicValue.put(columnName, ownerName); } else if (columnName.equals("createUserId")) { long createUserId = contact.getCreateUserId(); StringBuffer createUser = new StringBuffer(StringPool.BLANK); if (createUserId != 0L) { createUser.append(UserLocalServiceUtil.getUser(createUserId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(contact.getCreateDate())); } dynamicValue.put(columnName, createUser.toString()); } else if (columnName.equals("createDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(contact.getCreateDate())); } else if (columnName.equals("editUserId")) { long editUserId = contact.getEditUserId(); StringBuffer editUser = new StringBuffer(StringPool.BLANK); if (editUserId > 0) { editUser.append(UserLocalServiceUtil.getUser(editUserId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(contact.getEditDate())); } dynamicValue.put(columnName, editUser.toString()); } else if (columnName.equals("editDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(contact.getEditDate())); } else if (columnName.equals("strField1")) { dynamicValue.put(columnName, contact.getStrField1()); } else if (columnName.equals("strField2")) { dynamicValue.put(columnName, contact.getStrField2()); } else if (columnName.equals("strField3")) { dynamicValue.put(columnName, contact.getStrField3()); } else if (columnName.equals("strField4")) { dynamicValue.put(columnName, contact.getStrField4()); } else if (columnName.equals("strField5")) { dynamicValue.put(columnName, contact.getStrField5()); } else if (columnName.equals("strField6")) { dynamicValue.put(columnName, contact.getStrField6()); } else if (columnName.equals("strField7")) { dynamicValue.put(columnName, contact.getStrField7()); } else if (columnName.equals("strField8")) { dynamicValue.put(columnName, contact.getStrField8()); } else if (columnName.equals("textareaField1")) { String textareaField1 = contact.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")) { String textareaField2 = contact.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("textareaField3")) { String textareaField3 = contact.getTextareaField3(); if (textareaField3 == null) { textareaField3 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField3); } else if (columnName.equals("textareaField4")) { String textareaField4 = contact.getTextareaField4(); StringBuffer value = new StringBuffer(StringPool.BLANK); if (textareaField4 == null) { textareaField4 = StringPool.BLANK; } dynamicValue.put(columnName, value.toString()); } else if (columnName.equals("floatField1")) { double floatField1 = contact.getFloatField1(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField1, 2)); } else if (columnName.equals("floatField2")) { double floatField2 = contact.getFloatField2(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField2, 2)); } else if (columnName.equals("floatField3")) { double floatField3 = contact.getFloatField3(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField3, 2)); } else if (columnName.equals("floatField4")) { double floatField4 = contact.getFloatField4(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField4, 2)); } else if (columnName.equals("dateField1")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contact.getDateField1())); } else if (columnName.equals("dateField2")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contact.getDateField2())); } else if (columnName.equals("dateField3")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contact.getDateField3())); } else if (columnName.equals("dateField4")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contact.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, contact.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, contact.getAttaField2())); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(contact.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(contact.getIntegerField2())); } } } } return dynamicValue; } public static Map<String, String> getContractValue(PortletRequest portletRequest, Long contractId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (contractId > 0) { Contract contract = ContractLocalServiceUtil.getContract(contractId); if (contract != null) { List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Contract, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("code")) { dynamicValue.put(columnName, contract.getCode()); } else if (columnName.equals("title")) { dynamicValue.put(columnName, contract.getTitle() ); } else if (columnName.equals("customerId")) { String customerName = StringPool.BLANK; long customerId = contract.getCustomerId(); if (customerId != 0L) { String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CUSTOMER_DETAIL, customerId)+"‘>"; String suffix = "</a>"; customerName = prefix+CustomerLocalServiceUtil.getCustomer(customerId).getCustomerName()+suffix; } dynamicValue.put(columnName, customerName ); } else if (columnName.equals("signingUserName")) { String signingUserName = contract.getSigningUserName(); dynamicValue.put(columnName, signingUserName); } else if (columnName.equals("signingUserPosition")) { String signingUserPosition = contract.getSigningUserPosition(); dynamicValue.put(columnName, signingUserPosition); } else if (columnName.equals("amount")) { double amount = contract.getAmount(); dynamicValue.put(columnName, TextUtil.doubleToText(amount, 2)); } else if (columnName.equals("signingTime")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getSigningTime()) ); } else if (columnName.equals("opportunityId")) { String opportunityName = StringPool.BLANK; long opportunityId = contract.getOpportunityId(); if (opportunityId != 0L) { opportunityName = OpportunityLocalServiceUtil.getOpportunity(opportunityId).getTopic(); } dynamicValue.put(columnName, opportunityName ); } else if (columnName.equals("startDate")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getStartDate()) ); } else if (columnName.equals("endDate")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getEndDate()) ); } else if (columnName.equals("status")) { String status = contract.getStatus(); dynamicValue.put(columnName, status); } else if (columnName.equals("auditUserId")){ StringBuffer auditUser = new StringBuffer(StringPool.BLANK); long auditUserId = contract.getAuditUserId(); if (auditUserId != 0L) { auditUser.append(UserLocalServiceUtil.getUser(auditUserId).getFirstName()); } auditUser.append(StringPool.COMMA).append(DateUtil.formatDateTime(contract.getAuditDate())); dynamicValue.put(columnName, auditUser.toString()); } else if (columnName.equals("auditDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(contract.getAuditDate())); } else if (columnName.equals("auditOpinion")){ String auditOpinion = contract.getAuditOpinion(); dynamicValue.put(columnName, auditOpinion==null?StringPool.BLANK:auditOpinion); } else if (columnName.equals("createUserId")){ long userId = contract.getCreateUserId(); StringBuffer createUser = new StringBuffer(StringPool.BLANK); if (userId > 0) { createUser.append(UserLocalServiceUtil.getUser(userId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(contract.getCreateDate())); } dynamicValue.put(columnName, createUser.toString()); } else if (columnName.equals("createDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(contract.getCreateDate())); } else if (columnName.equals("editUserId")){ long userId = contract.getEditUserId(); StringBuffer editUser = new StringBuffer(StringPool.BLANK); if (userId > 0) { editUser.append(UserLocalServiceUtil.getUser(userId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(contract.getEditDate())); } dynamicValue.put(columnName, editUser.toString()); } else if (columnName.equals("editDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(contract.getEditDate())); } else if (columnName.equals("ownerId")) { long ownerId = contract.getOwnerId(); User user = null; if (ownerId > 0) { user = UserLocalServiceUtil.getUser(ownerId); } dynamicValue.put(columnName, user != null ? user.getFirstName() : StringPool.BLANK); } else if (columnName.equals("ownerChangeDate")) { Date ownerChangeDate = contract.getOwnerChangeDate(); dynamicValue.put(columnName, DateUtil.formatDateTime(ownerChangeDate)); } else if (columnName.equals("specialTerms")) { dynamicValue.put(columnName, contract.getSpecialTerms() != null ? contract.getSpecialTerms() : StringPool.BLANK); } else if (columnName.equals("content")) { String content = contract.getContent(); dynamicValue.put(columnName, content); } else if (columnName.equals("strField1")) { dynamicValue.put(columnName, contract.getStrField1()==null?StringPool.BLANK:contract.getStrField1()); } else if (columnName.equals("strField2")) { dynamicValue.put(columnName, contract.getStrField2()==null?StringPool.BLANK:contract.getStrField2()); } else if (columnName.equals("strField3")) { dynamicValue.put(columnName, contract.getStrField3()==null?StringPool.BLANK:contract.getStrField3()); } else if (columnName.equals("strField4")) { dynamicValue.put(columnName, contract.getStrField4()==null?StringPool.BLANK:contract.getStrField4()); } else if (columnName.equals("strField5")) { dynamicValue.put(columnName, contract.getStrField5()==null?StringPool.BLANK:contract.getStrField5()); } else if (columnName.equals("strField6")) { dynamicValue.put(columnName, contract.getStrField6()==null?StringPool.BLANK:contract.getStrField6()); } else if (columnName.equals("strField7")) { dynamicValue.put(columnName, contract.getStrField5()==null?StringPool.BLANK:contract.getStrField7()); } else if (columnName.equals("strField8")) { dynamicValue.put(columnName, contract.getStrField6()==null?StringPool.BLANK:contract.getStrField8()); } else if (columnName.equals("textareaField1")) { String textareaField1 = contract.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")) { String textareaField2 = contract.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("floatField1")) { double floatField1 = contract.getFloatField1(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField1, 2)); } else if (columnName.equals("floatField2")) { double floatField2 = contract.getFloatField2(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField2, 2)); } else if (columnName.equals("floatField3")) { double floatField3 = contract.getFloatField3(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField3, 2)); } else if (columnName.equals("floatField4")) { double floatField4 = contract.getFloatField4(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField4, 2)); } else if (columnName.equals("dateField1")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getDateField1())); } else if (columnName.equals("dateField2")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getDateField2())); } else if (columnName.equals("dateField3")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getDateField3())); } else if (columnName.equals("dateField4")) { dynamicValue.put(columnName, DateUtil.formatDateNoHour(contract.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, contract.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, contract.getAttaField2())); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(contract.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(contract.getIntegerField2())); } } } } return dynamicValue; } public static Map<String, String> getClueValue(PortletRequest portletRequest, Long clueId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (clueId > 0){ Clue clue = ClueLocalServiceUtil.getClue(clueId); if (clue != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Clue, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("name")) { dynamicValue.put(columnName, clue.getName()); } else if (columnName.equals("customerName")) { dynamicValue.put(columnName, clue.getCustomerName()); } else if (columnName.equals("contactName")) { dynamicValue.put(columnName, clue.getContactName()); } else if (columnName.equals("code")) { dynamicValue.put(columnName, clue.getCode()); } else if (columnName.equals("phone")) { dynamicValue.put(columnName, clue.getPhone()); } else if (columnName.equals("type")){ dynamicValue.put(columnName, clue.getType()); } else if (columnName.equals("source")){ dynamicValue.put(columnName, clue.getSource()); } else if (columnName.equals("mobile")){ dynamicValue.put(columnName, clue.getMobile()); } else if (columnName.equals("fax")){ dynamicValue.put(columnName, clue.getFax()); } else if (columnName.equals("email")){ dynamicValue.put(columnName, clue.getEmail()); } else if (columnName.equals("webSite")){ dynamicValue.put(columnName, clue.getWebSite()); } else if (columnName.equals("comments")){ dynamicValue.put(columnName, clue.getComments()); } else if (columnName.equals("address")){ String address = clue.getAddress(); Locale locale = CompanyLocalServiceUtil.getCompany(companyId).getLocale(); if (!address.equals("")) { address += " <a class=‘baiduMap‘ style=‘color:#015BA7;‘ href=‘javascript:void(0);‘>" + LanguageUtil.get( PortletIDs.INITIALIZATION, locale, "baidu.map") + "</a>"; } else { address += "<a class=‘baiduMap‘ style=‘color:#015BA7;‘ href=‘javascript:void(0);‘>" + LanguageUtil.get( PortletIDs.INITIALIZATION, locale, "baidu.map.marker") + "</a>"; } dynamicValue.put(columnName, address); } else if (columnName.equals("postCode")){ dynamicValue.put(columnName, clue.getPostCode()); } else if (columnName.equals("stage")){ dynamicValue.put(columnName, clue.getStage()); } else if (columnName.equals("createDate")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getCreateDate())); } else if (columnName.equals("editDate")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getEditDate())); } else if (columnName.equals("convertDate")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getConvertDate())); } else if (columnName.equals("auditDate")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getAuditDate())); } else if (columnName.equals("convertStatus")){ // if (clue.getConvertStatus().equals("Convert")){ // dynamicValue.put(columnName, SystemStatus.Convert.getStatus()); // } else { // dynamicValue.put(columnName, SystemStatus.Unconvert.getStatus()); // } dynamicValue.put(columnName, clue.getConvertStatus()); } else if (columnName.equals("auditStatus")){ dynamicValue.put(columnName, clue.getAuditStatus()); } else if (columnName.equals("staffNum")){ dynamicValue.put(columnName, String.valueOf(clue.getStaffNum())); } else if (columnName.equals("yearRevenue")){ dynamicValue.put(columnName, TextUtil.doubleToText(clue.getYearRevenue(),2)); } else if (columnName.equals("country")) { String countryName = clue.getCountry(); dynamicValue.put(columnName, countryName); } else if (columnName.equals("province")) { String provinceName = clue.getProvince(); dynamicValue.put(columnName, provinceName); } else if (columnName.equals("city")) { String cityName = clue.getCity(); dynamicValue.put(columnName, cityName); } else if (columnName.equals("area")) { String areaName = clue.getArea(); dynamicValue.put(columnName, areaName); } else if (columnName.equals("marketId")) { long marketId = clue.getMarketId(); String marketName = StringPool.BLANK; if (marketId > 0) { String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.MARKET_DETAIL, marketId)+"‘>"; String suffix = "</a>"; marketName = prefix+MarketLocalServiceUtil.getMarket(marketId).getName()+suffix; } dynamicValue.put(columnName, marketName); } else if (columnName.equals("customerId")) { long customerId = clue.getCustomerId(); String customerName = StringPool.BLANK; if (customerId > 0) { try { String prefix = "<a href=‘" + PortletURLUtil.getObjDetailURL( portletRequest, PortletIDs.CUSTOMER_DETAIL, customerId) + "‘>"; String suffix = "</a>"; customerName = prefix + CustomerLocalServiceUtil.getCustomer( customerId).getCustomerName() + suffix; } catch (NoSuchCustomerException e) { clue.setCustomerId(0); clue = ClueLocalServiceUtil.getClue(clueId); } } dynamicValue.put(columnName, customerName); } else if (columnName.equals("contactId")) { long contactId = clue.getContactId(); String contactName = StringPool.BLANK; if (contactId > 0) { String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CONTACT_DETAIL, contactId)+"‘>"; String suffix = "</a>"; contactName = prefix+ContactLocalServiceUtil.getContact(contactId).getContactName()+suffix; } dynamicValue.put(columnName, contactName); } else if (columnName.equals("opportunityId")) { long opportunityId = clue.getOpportunityId(); String opportunityName = StringPool.BLANK; if (opportunityId > 0) { String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.OPPORTUNITY_DETAIL, opportunityId)+"‘>"; String suffix = "</a>"; opportunityName = prefix+OpportunityLocalServiceUtil.getOpportunity(opportunityId).getTopic()+suffix; } dynamicValue.put(columnName, opportunityName); } else if (columnName.equals("createUserId")) { long createUserId = clue.getCreateUserId(); String createUserName = StringPool.BLANK; if (createUserId != 0L) { createUserName = UserLocalServiceUtil.getUser(createUserId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(clue.getCreateDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("editUserId")) { long editUserId = clue.getEditUserId(); String editUserName = StringPool.BLANK; if (editUserId != 0L) { editUserName = UserLocalServiceUtil.getUser(editUserId).getFirstName(); editUserName += ", "; editUserName += DateUtil.formatDateTime(clue.getEditDate()); } dynamicValue.put(columnName, editUserName); } else if (columnName.equals("convertUserId")) { long convertUserId = clue.getConvertUserId(); String convertUserName = StringPool.BLANK; if (convertUserId != 0l){ convertUserName = UserLocalServiceUtil.getUser(convertUserId).getFirstName(); convertUserName += ", "; convertUserName += DateUtil.formatDate(clue.getConvertDate()); } dynamicValue.put(columnName, convertUserName); } else if (columnName.equals("auditUserId")) { long auditUserId = clue.getAuditUserId(); String auditUserName = StringPool.BLANK; if (auditUserId != 0l) { auditUserName = UserLocalServiceUtil.getUser(auditUserId).getFirstName(); auditUserName += ", "; auditUserName += DateUtil.formatDate(clue.getAuditDate()); } dynamicValue.put(columnName, auditUserName); } else if (columnName.equals("industry")){ String industry = clue.getIndustry(); dynamicValue.put(columnName, industry == null ? StringPool.BLANK : industry); } else if (columnName.equals("ownerId")){ long userId = clue.getOwnerId(); User user = null ; if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); } dynamicValue.put(columnName, user != null ? user.getFirstName() + StringPool.BLANK + user.getLastName() : StringPool.BLANK); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, clue.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, clue.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, clue.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, clue.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, clue.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, clue.getStrField6()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, clue.getStrField7()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, clue.getStrField8()); } else if (columnName.equals("textareaField1")){ String textareaField1 = clue.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = clue.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(clue.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(clue.getIntegerField2())); } else if (columnName.equals("floatField1")){ dynamicValue.put(columnName, TextUtil.doubleToText(clue.getFloatField1(),2)); } else if (columnName.equals("floatField2")){ dynamicValue.put(columnName, TextUtil.doubleToText(clue.getFloatField2(),2)); } else if (columnName.equals("floatField3")){ dynamicValue.put(columnName, TextUtil.doubleToText(clue.getFloatField3(),2)); } else if (columnName.equals("floatField4")){ dynamicValue.put(columnName, TextUtil.doubleToText(clue.getFloatField4(),2)); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDate(clue.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, clue.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, clue.getAttaField2())); } } } } return dynamicValue; } public static Map<String, String> getOpportunityValue(PortletRequest portletRequest, Long opportunityId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (opportunityId > 0){ Opportunity opportunity = OpportunityLocalServiceUtil.getOpportunity(opportunityId); if (opportunity != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Opportunity, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("topic")) { dynamicValue.put(columnName, opportunity.getTopic()); } else if (columnName.equals("code")) { dynamicValue.put(columnName, opportunity.getCode()); } else if (columnName.equals("type")){ dynamicValue.put(columnName, opportunity.getType()); } else if (columnName.equals("experience")) { dynamicValue.put(columnName, opportunity.getExperience()); } else if (columnName.equals("description")) { dynamicValue.put(columnName, opportunity.getDescription()); } else if (columnName.equals("status")) { dynamicValue.put(columnName, opportunity.getStatus()); } else if (columnName.equals("source")){ dynamicValue.put(columnName, opportunity.getSource()); } else if (columnName.equals("currentStage")){ dynamicValue.put(columnName, opportunity.getCurrentStage()); } else if (columnName.equals("source")){ dynamicValue.put(columnName, opportunity.getSource()); } else if (columnName.equals("amount")){ dynamicValue.put(columnName, TextUtil.doubleToText(opportunity.getAmount(),2)); } else if (columnName.equals("feel")){ dynamicValue.put(columnName, opportunity.getFeel()); } else if (columnName.equals("probability")){ if (!opportunity.getProbability().equals( StringPool.BLANK)) { dynamicValue.put(columnName, opportunity.getProbability() + StringPool.PERCENT); } else { dynamicValue.put(columnName, StringPool.BLANK); } } else if (columnName.equals("completeResult")){ dynamicValue.put(columnName, opportunity.getCompleteResult()); } else if (columnName.equals("editDate")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getEditDate())); } else if (columnName.equals("closeDate")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getCloseDate())); } else if (columnName.equals("completeDate")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getCompleteDate())); } else if (columnName.equals("createUserId")){ long createUserId = opportunity.getCreateUserId(); String createUserName = StringPool.BLANK; if (createUserId != 0L) { createUserName = UserLocalServiceUtil.getUser(createUserId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(opportunity.getCreateDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("ownerId")){ long userId = opportunity.getOwnerId(); User user = null ; if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); } dynamicValue.put(columnName, user != null ? user.getFirstName() + StringPool.BLANK + user.getLastName() : StringPool.BLANK); } else if (columnName.equals("editUserId")){ long editUserId = opportunity.getEditUserId(); String editUserName = StringPool.BLANK; if (editUserId != 0L) { editUserName = UserLocalServiceUtil.getUser(editUserId).getFirstName(); editUserName += ", "; editUserName += DateUtil.formatDateTime(opportunity.getEditDate()); } dynamicValue.put(columnName, editUserName); } else if (columnName.equals("marketId")){ long marketId = opportunity.getMarketId(); String marketName = StringPool.BLANK; if (marketId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.MARKET_DETAIL, marketId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; marketName = prefix+MarketLocalServiceUtil.getMarket(marketId).getName()+suffix; } dynamicValue.put(columnName, marketName); } else if (columnName.equals("customerId")){ long customId = opportunity.getCustomerId(); String customerName = StringPool.BLANK; if (customId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CUSTOMER_DETAIL, customId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; customerName = prefix+CustomerLocalServiceUtil.getCustomer(customId).getCustomerName()+suffix; } dynamicValue.put(columnName, customerName); } else if (columnName.equals("createDate")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getCreateDate())); } else if (columnName.equals("contactId")) { long contactId = opportunity.getContactId(); String contactName = StringPool.BLANK; if (contactId > 0) { String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CONTACT_DETAIL, contactId)+"‘>"; String suffix = "</a>"; contactName = prefix+ContactLocalServiceUtil.getContact(contactId).getContactName()+suffix; } dynamicValue.put(columnName, contactName); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, opportunity.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, opportunity.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, opportunity.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, opportunity.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, opportunity.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, opportunity.getStrField6()); } else if (columnName.equals("strField7")){ dynamicValue.put(columnName, opportunity.getStrField7()); } else if (columnName.equals("strField8")){ dynamicValue.put(columnName, opportunity.getStrField8()); } else if (columnName.equals("textareaField1")){ String textareaField1 = opportunity.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = opportunity.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("floatField1")){ dynamicValue.put(columnName, TextUtil.doubleToText(opportunity.getFloatField1(),2)); } else if (columnName.equals("floatField2")){ dynamicValue.put(columnName, TextUtil.doubleToText(opportunity.getFloatField2(),2)); } else if (columnName.equals("floatField3")){ dynamicValue.put(columnName, TextUtil.doubleToText(opportunity.getFloatField3(),2)); } else if (columnName.equals("floatField4")){ dynamicValue.put(columnName, TextUtil.doubleToText(opportunity.getFloatField4(),2)); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(opportunity.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(opportunity.getIntegerField2())); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDate(opportunity.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, opportunity.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, opportunity.getAttaField2())); } } } } return dynamicValue; } public static Map<String, String> getQuotationValue(PortletRequest portletRequest, Long quotationId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (quotationId > 0){ Quotation quotation = QuotationLocalServiceUtil.getQuotation(quotationId); if (quotation != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Quotation, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("name")) { dynamicValue.put(columnName, quotation.getName()); } else if (columnName.equals("code")) { dynamicValue.put(columnName, quotation.getCode()); } else if (columnName.equals("phone")) { dynamicValue.put(columnName, quotation.getPhone()); } else if (columnName.equals("email")) { dynamicValue.put(columnName, quotation.getEmail()); } else if (columnName.equals("fax")){ dynamicValue.put(columnName, quotation.getFax()); } else if (columnName.equals("type")){ dynamicValue.put(columnName, quotation.getType()); } else if (columnName.equals("description")){ dynamicValue.put(columnName, quotation.getDescription() .length() > 10 ? quotation.getDescription() .substring(0, 10) + "..." : quotation.getDescription()); } else if (columnName.equals("createDate")){ dynamicValue.put(columnName, DateUtil.formatDate(quotation.getCreateDate())); } else if (columnName.equals("editDate")){ dynamicValue.put(columnName, DateUtil.formatDate(quotation.getEditDate())); } else if (columnName.equals("auditDate")){ dynamicValue.put(columnName, DateUtil.formatDate(quotation.getAuditDate())); } else if (columnName.equals("amount")){ dynamicValue.put(columnName, TextUtil.doubleToText(quotation.getAmount(),2)); } else if (columnName.equals("opportunityId")){ long opportunityId = quotation.getOpportunityId(); String opportunityName = StringPool.BLANK; if (opportunityId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.OPPORTUNITY_DETAIL, opportunityId) + "&layoutId=" + layoutId + "&jumpFlag=down‘>"; String suffix = "</a>"; opportunityName = prefix+OpportunityLocalServiceUtil.getOpportunity(opportunityId).getTopic()+suffix; } dynamicValue.put(columnName, opportunityName); } else if (columnName.equals("clueId")){ long clueId = quotation.getClueId(); String clueName = StringPool.BLANK; if (clueId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CLUE_DETAIL, clueId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; clueName = prefix+ClueLocalServiceUtil.getClue(clueId).getName()+suffix; } dynamicValue.put(columnName, clueName); } else if (columnName.equals("contactId")){ long contactId = quotation.getContactId(); String contactName = StringPool.BLANK; if (contactId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CONTACT_DETAIL, contactId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; contactName = prefix+ContactLocalServiceUtil.getContact(contactId).getContactName()+suffix; } dynamicValue.put(columnName, contactName); } else if (columnName.equals("customerId")){ long customId = quotation.getCustomerId(); String customerName = StringPool.BLANK; if (customId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CUSTOMER_DETAIL, customId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; customerName = prefix+CustomerLocalServiceUtil.getCustomer(customId).getCustomerName()+suffix; } dynamicValue.put(columnName, customerName); } else if (columnName.equals("createUserId")){ long createUserId = quotation.getCreateUserId(); String createUserName = StringPool.BLANK; if (createUserId != 0L) { createUserName = UserLocalServiceUtil.getUser(createUserId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(quotation.getCreateDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("ownerId")){ long userId = quotation.getOwnerId(); User user = null ; if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); } dynamicValue.put(columnName, user != null ? user.getFirstName() + StringPool.BLANK + user.getLastName() : StringPool.BLANK); } else if (columnName.equals("editUserId")){ long editUserId = quotation.getEditUserId(); String editUserName = StringPool.BLANK; if (editUserId != 0L) { editUserName = UserLocalServiceUtil.getUser(editUserId).getFirstName(); editUserName += ", "; editUserName += DateUtil.formatDateTime(quotation.getEditDate()); } dynamicValue.put(columnName, editUserName); } else if (columnName.equals("auditUserId")){ long auditUserId = quotation.getAuditUserId(); String auditUserName = StringPool.BLANK; if (auditUserId != 0l) { auditUserName = UserLocalServiceUtil.getUser(auditUserId).getFirstName(); auditUserName += ", "; auditUserName += DateUtil.formatDate(quotation.getAuditDate()); } dynamicValue.put(columnName, auditUserName); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, quotation.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, quotation.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, quotation.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, quotation.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, quotation.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, quotation.getStrField6()); } else if (columnName.equals("strField7")){ dynamicValue.put(columnName, quotation.getStrField7()); } else if (columnName.equals("strField8")){ dynamicValue.put(columnName, quotation.getStrField8()); } else if (columnName.equals("textareaField1")){ String textareaField1 = quotation.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = quotation.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("floatField1")){ dynamicValue.put(columnName, TextUtil.doubleToText(quotation.getFloatField1(),2)); } else if (columnName.equals("floatField2")){ dynamicValue.put(columnName, TextUtil.doubleToText(quotation.getFloatField2(),2)); } else if (columnName.equals("floatField3")){ dynamicValue.put(columnName, TextUtil.doubleToText(quotation.getFloatField3(),2)); } else if (columnName.equals("floatField4")){ dynamicValue.put(columnName, TextUtil.doubleToText(quotation.getFloatField4(),2)); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDate(quotation.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDate(quotation.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDate(quotation.getDateField4())); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(quotation.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(quotation.getIntegerField2())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, quotation.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, quotation.getAttaField2())); } } } } return dynamicValue; } public static Map<String, String> getOrderValue(PortletRequest portletRequest, Long orderId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (orderId > 0){ Order order = OrderLocalServiceUtil.getOrder(orderId); if (order != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Order, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("name")) { dynamicValue.put(columnName, order.getName()); } else if (columnName.equals("code")) { dynamicValue.put(columnName, order.getCode()); } else if (columnName.equals("phone")) { dynamicValue.put(columnName, order.getPhone()); } else if (columnName.equals("description")){ dynamicValue.put(columnName, order.getDescription()); } else if (columnName.equals("totalAmount")){ dynamicValue.put(columnName, TextUtil.doubleToText(order.getTotalAmount(),2)); } else if (columnName.equals("auditDate")){ dynamicValue.put(columnName, DateUtil.formatDate(order.getAuditDate())); } else if (columnName.equals("closeDate")){ dynamicValue.put(columnName, DateUtil.formatDate(order.getCloseDate())); } else if (columnName.equals("editDate")){ dynamicValue.put(columnName, DateUtil.formatDate(order.getEditDate())); } else if (columnName.equals("createDate")){ dynamicValue.put(columnName, DateUtil.formatDate(order.getCreateDate())); } else if (columnName.equals("opportunityId")){ long opportunityId = order.getOpportunityId(); String opportunityName = StringPool.BLANK; if (opportunityId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.OPPORTUNITY_DETAIL, opportunityId) + "&layoutId=" + layoutId + "&jumpFlag=down‘>"; String suffix = "</a>"; opportunityName = prefix+OpportunityLocalServiceUtil.getOpportunity(opportunityId).getTopic()+suffix; } dynamicValue.put(columnName, opportunityName); } else if (columnName.equals("contactId")){ long contactId = order.getContactId(); String contactName = StringPool.BLANK; if (contactId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CONTACT_DETAIL, contactId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; contactName = prefix+ContactLocalServiceUtil.getContact(contactId).getContactName()+suffix; } dynamicValue.put(columnName, contactName); } else if (columnName.equals("contractId")){ long contractId = order.getContractId(); String contractName = StringPool.BLANK; if(contractId > 0){ HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CONTRACT_DETAIL, contractId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; contractName = prefix+ContractLocalServiceUtil.getContract(contractId).getTitle()+suffix; } dynamicValue.put(columnName, contractName); } else if (columnName.equals("customerId")){ long customerId = order.getCustomerId(); String customerName = StringPool.BLANK; if (customerId > 0) { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); String layoutId = themeDisplay.getLayout().getFriendlyURL(); String prefix = "<a href=‘"+PortletURLUtil.getObjDetailURL(portletRequest, PortletIDs.CUSTOMER_DETAIL, customerId) + "&layoutId=" + layoutId + "‘>"; String suffix = "</a>"; customerName = prefix+CustomerLocalServiceUtil.getCustomer(customerId).getCustomerName()+suffix; } dynamicValue.put(columnName, customerName); } else if (columnName.equals("createUserId")){ long userId = order.getCreateUserId(); String createUserName = StringPool.BLANK; if (userId != 0L) { createUserName = UserLocalServiceUtil.getUser(userId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(order.getCreateDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("ownerId")){ long userId = order.getOwnerId(); User user = null ; if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); } dynamicValue.put(columnName, user != null ? user.getFirstName() + " " + user.getLastName() : ""); } else if (columnName.equals("editUserId")){ long userId = order.getEditUserId(); String createUserName = StringPool.BLANK; if (userId != 0L) { createUserName = UserLocalServiceUtil.getUser(userId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(order.getEditDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("auditUserId")){ long userId = order.getAuditUserId(); String createUserName = StringPool.BLANK; if (userId != 0L) { createUserName = UserLocalServiceUtil.getUser(userId).getFirstName(); createUserName += ", "; createUserName += DateUtil.formatDateTime(order.getAuditDate()); } dynamicValue.put(columnName, createUserName); } else if (columnName.equals("auditStatus")){ String auditStatus = order.getAuditStatus(); String result = StringPool.BLANK; if (auditStatus.equals("pass")) { result = "通过"; } else if (auditStatus.equals("refuse")){ result = "未通过"; } else { result = "审核中"; } dynamicValue.put(columnName, result); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, order.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, order.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, order.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, order.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, order.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, order.getStrField6()); } else if (columnName.equals("strField7")){ dynamicValue.put(columnName, order.getStrField7()); } else if (columnName.equals("strField8")){ dynamicValue.put(columnName, order.getStrField8()); } else if (columnName.equals("textareaField1")){ String textareaField1 = order.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = order.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("floatField1")){ dynamicValue.put(columnName, TextUtil.doubleToText(order.getFloatField1(),2)); } else if (columnName.equals("floatField2")){ dynamicValue.put(columnName, TextUtil.doubleToText(order.getFloatField2(),2)); } else if (columnName.equals("floatField3")){ dynamicValue.put(columnName, TextUtil.doubleToText(order.getFloatField3(),2)); } else if (columnName.equals("floatField4")){ dynamicValue.put(columnName, TextUtil.doubleToText(order.getFloatField4(),2)); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(order.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(order.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(order.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(order.getDateField4())); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(order.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(order.getIntegerField2())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, order.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, order.getAttaField2())); } } } } return dynamicValue; } public static Map<String, String> getActivityValue(PortletRequest portletRequest, Long activityId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (activityId > 0){ Activity activity = ActivityLocalServiceUtil.getActivity(activityId); if (activity != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Activity, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("title")) { dynamicValue.put(columnName, activity.getTitle()); } else if (columnName.equals("createUserId")) { StringBuffer createUser = new StringBuffer(StringPool.BLANK); long createUserId = activity.getCreateUserId(); if (createUserId != 0L) { createUser.append(UserLocalServiceUtil.getUser(createUserId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(activity.getCreateDate())); } dynamicValue.put(columnName, createUser.toString()); } else if (columnName.equals("createDate")){ dynamicValue.put(columnName, DateUtil.formatDateTime(activity.getCreateDate())); } else if (columnName.equals("editUserId")) { StringBuffer editUser = new StringBuffer(StringPool.BLANK); long editUserId = activity.getEditUserId(); if (editUserId != 0L) { editUser.append(UserLocalServiceUtil.getUser(editUserId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(activity.getEditDate())); } dynamicValue.put(columnName, editUser.toString()); } else if (columnName.equals("editDate")) { Date editDate = activity.getEditDate(); dynamicValue.put(columnName, DateUtil.formatDateTime(editDate)); } else if (columnName.equals("executorId")) { long executorId = activity.getExecutorId(); User user = null; String value = null; if (executorId > 0) { user = UserLocalServiceUtil.getUser(executorId); value = user.getFirstName(); } else { value = StringPool.BLANK; } dynamicValue.put(columnName, value); } else if (columnName.equals("isAppointment")){ boolean isAppointment = activity.getIsAppointment(); Locale locale = PortalUtil.getCompany(portletRequest).getLocale(); String value = null; if (isAppointment) { value = LanguageUtil.get(PortletIDs.ACTIVITY_EDIT, locale, "yes"); } else { value = LanguageUtil.get(PortletIDs.ACTIVITY_EDIT, locale, "no"); } dynamicValue.put(columnName, value); } else if (columnName.equals("actionMeans")){ String style = activity.getActionMeans(); dynamicValue.put(columnName, style); } else if (columnName.equals("expectResult")){ String result = activity.getExpectResult(); dynamicValue.put(columnName, result); } else if (columnName.equals("factResult")){ String completeResult = activity.getFactResult(); dynamicValue.put(columnName, completeResult); } else if (columnName.equals("status")){ String status = activity.getStatus(); dynamicValue.put(columnName, status ); } else if (columnName.equals("completeDate")){ dynamicValue.put(columnName, DateUtil.formatDateTime(activity.getCompleteDate())); } else if (columnName.equals("nextVisitDate")){ dynamicValue.put(columnName, DateUtil.formatDateTime(activity.getNextVisitDate())); } else if (columnName.equals("relationObj")) { long relationObj = activity.getRelationObj(); String relation = activity.getRelation(); String obName = ActivityUtils.getObName(relation, relationObj); String relationName = ActivityUtils.getRelation(portletRequest, relation); String value = relationName + "--" + obName; dynamicValue.put(columnName, value); } else if (columnName.equals("startDate")){ dynamicValue.put(columnName, DateUtil.formatDateTime(activity.getStartDate())); } else if (columnName.equals("endDate")){ dynamicValue.put(columnName, DateUtil.formatDateTime(activity.getEndDate())); } else if (columnName.equals("aheadRemind")){ String remindStr = StringPool.BLANK; int aheadRemind = activity.getAheadRemind(); if (aheadRemind == -1) { remindStr = "不提醒"; } else if (aheadRemind == 0) { remindStr = "准时"; } else if (aheadRemind == 5) { remindStr = "提前5分钟"; } else if (aheadRemind == 10) { remindStr = "提前10分钟"; } else if (aheadRemind == 20) { remindStr = "提前20分钟"; } else if (aheadRemind == 30) { remindStr = "提前30分钟"; } else if (aheadRemind == 60) { remindStr = "提前1小时"; } else if (aheadRemind == 120) { remindStr = "提前2小时"; } else if (aheadRemind == 180) { remindStr = "提前3小时"; } else if (aheadRemind == 360) { remindStr = "提前6小时"; } else if (aheadRemind == 1440) { remindStr = "提前1天"; } else if (aheadRemind == 2880) { remindStr = "提前2天"; } else if (aheadRemind == 4320) { remindStr = "提前3天"; } dynamicValue.put(columnName, remindStr); } else if (columnName.equals("description")) { String description = activity.getDescription(); dynamicValue.put(columnName, description); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, activity.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, activity.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, activity.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, activity.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, activity.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, activity.getStrField6()); } else if (columnName.equals("strField7")){ dynamicValue.put(columnName, activity.getStrField7()); } else if (columnName.equals("strField8")){ dynamicValue.put(columnName, activity.getStrField8()); } else if (columnName.equals("textareaField1")){ String textareaField1 = activity.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = activity.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("floatField1")) { double floatField1 = activity.getFloatField1(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField1, 2)); } else if (columnName.equals("floatField2")) { double floatField2 = activity.getFloatField2(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField2, 2)); } else if (columnName.equals("floatField3")) { double floatField3 = activity.getFloatField3(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField3, 2)); } else if (columnName.equals("floatField4")) { double floatField4 = activity.getFloatField4(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField4, 2)); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(activity.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(activity.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(activity.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(activity.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, activity.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, activity.getAttaField2())); } else if (columnName.equals("integerField1")){ dynamicValue.put(columnName, String.valueOf(activity.getIntegerField1())); } else if (columnName.equals("integerField2")){ dynamicValue.put(columnName, String.valueOf(activity.getIntegerField2())); } } } } return dynamicValue; } public static Map<String, String> getProductValue(PortletRequest portletRequest, Long productId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (productId > 0){ Product product = ProductLocalServiceUtil.getProduct(productId); if (product != null){ List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_Product, true); dynamicValue = new HashMap<String, String>(); for(CompanyColumnDefinition companyColumn : companyColumns){ String columnName = companyColumn.getColumnName(); if (columnName.equals("productName")) { dynamicValue.put(columnName, product.getProductName()); } else if (columnName.equals("createUserId")) { long userId = product.getCreateUserId(); StringBuffer createUser = new StringBuffer(StringPool.BLANK); if (userId > 0) { createUser.append(UserLocalServiceUtil.getUser(userId).getFirstName()) .append(StringPool.COMMA) .append(DateUtil.formatDateTime(product.getCreateDate())); } dynamicValue.put(columnName, createUser.toString()); } else if (columnName.equals("createDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(product.getCreateDate())); } else if (columnName.equals("productAbbr")){ dynamicValue.put(columnName, product.getProductAbbr()); } else if (columnName.equals("code")){ dynamicValue.put(columnName, product.getCode()); } else if (columnName.equals("productUnit")) { dynamicValue.put(columnName, product.getProductUnit()); } else if (columnName.equals("standard")){ String standard = product.getStandard(); dynamicValue.put(columnName, standard==null?StringPool.BLANK:standard); } else if (columnName.equals("productModel")){ String modal = product.getProductModel(); dynamicValue.put(columnName, modal==null?StringPool.BLANK:modal); } else if (columnName.equals("productCost")){ double cost = product.getProductCost(); dynamicValue.put(columnName, TextUtil.doubleToText(cost, 2)); } else if (columnName.equals("unitPrice")){ double unitPrice = product.getUnitPrice(); dynamicValue.put(columnName, TextUtil.doubleToText(unitPrice, 2)); } else if (columnName.equals("description")){ String description = product.getDescription().length() > 10 ? product .getDescription().substring(0, 10) + "..." : product.getDescription(); dynamicValue.put(columnName, description == null ? StringPool.BLANK : description); } else if (columnName.equals("productCategoryId")) { long productCategoryId = product.getProductCategoryId(); ProductCategory category = null; String categoryName = StringPool.BLANK; if (productCategoryId > 0) { category = ProductCategoryLocalServiceUtil.getProductCategory(productCategoryId); categoryName = category.getCategoryName(); } dynamicValue.put(columnName, categoryName); } else if (columnName.equals("strField1")){ dynamicValue.put(columnName, product.getStrField1()); } else if (columnName.equals("strField2")){ dynamicValue.put(columnName, product.getStrField2()); } else if (columnName.equals("strField3")){ dynamicValue.put(columnName, product.getStrField3()); } else if (columnName.equals("strField4")){ dynamicValue.put(columnName, product.getStrField4()); } else if (columnName.equals("strField5")){ dynamicValue.put(columnName, product.getStrField5()); } else if (columnName.equals("strField6")){ dynamicValue.put(columnName, product.getStrField6()); } else if (columnName.equals("strField7")){ dynamicValue.put(columnName, product.getStrField7()); } else if (columnName.equals("strField8")){ dynamicValue.put(columnName, product.getStrField8()); } else if (columnName.equals("strField9")){ dynamicValue.put(columnName, product.getStrField9()); } else if (columnName.equals("strField10")){ dynamicValue.put(columnName, product.getStrField10()); } else if (columnName.equals("textareaField1")){ String textareaField1 = product.getTextareaField1(); if (textareaField1 == null) { textareaField1 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField1); } else if (columnName.equals("textareaField2")){ String textareaField2 = product.getTextareaField2(); if (textareaField2 == null) { textareaField2 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField2); } else if (columnName.equals("textareaField3")){ String textareaField3 = product.getTextareaField3(); if (textareaField3 == null) { textareaField3 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField3); } else if (columnName.equals("textareaField4")){ String textareaField4 = product.getTextareaField4(); if (textareaField4 == null) { textareaField4 = StringPool.BLANK; } dynamicValue.put(columnName, textareaField4); } else if (columnName.equals("floatField1")) { double floatField1 = product.getFloatField1(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField1, 2)); } else if (columnName.equals("floatField2")) { double floatField2 = product.getFloatField2(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField2, 2)); } else if (columnName.equals("floatField3")) { double floatField3 = product.getFloatField3(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField3, 2)); } else if (columnName.equals("floatField4")) { double floatField4 = product.getFloatField4(); dynamicValue.put(columnName, TextUtil.doubleToText(floatField4, 2)); } else if (columnName.equals("dateField1")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(product.getDateField1())); } else if (columnName.equals("dateField2")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(product.getDateField2())); } else if (columnName.equals("dateField3")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(product.getDateField3())); } else if (columnName.equals("dateField4")){ dynamicValue.put(columnName, DateUtil.formatDateNoHour(product.getDateField4())); } else if (columnName.equals("attaField1")) { dynamicValue.put(columnName, getAttathment(portletRequest, product.getAttaField1())); } else if (columnName.equals("attaField2")) { dynamicValue.put(columnName, getAttathment(portletRequest, product.getAttaField2())); } } } } return dynamicValue; } public static Map<String, String> getRPlanValue( PortletRequest portletRequest, Long receivablesPlanId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (receivablesPlanId != null && receivablesPlanId > 0) { ReceivablesPlan receivablesPlan = ReceivablesPlanLocalServiceUtil .getReceivablesPlan(receivablesPlanId); if (receivablesPlan != null) { List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_RPLAN, true); dynamicValue = new HashMap<String, String>(); for (CompanyColumnDefinition companyColumn : companyColumns) { String columnName = companyColumn.getColumnName(); if (columnName.equals("receivablesPlanCode")) { dynamicValue.put(columnName, receivablesPlan.getReceivablesPlanCode()); } else if (columnName.equals("customerId")) { Customer customer = null; String value = StringPool.BLANK; long customerId = receivablesPlan.getCustomerId(); if (customerId > 0) { customer = CustomerLocalServiceUtil .getCustomer(customerId); if (customer != null) { value = customer.getCustomerName(); } } dynamicValue.put(columnName, value); } else if (columnName.equals("orderId")) { Order order = null; String value = StringPool.BLANK; long orderId = receivablesPlan.getOrderId(); if (orderId > 0) { order = OrderLocalServiceUtil.getOrder(orderId); if (order != null) { value = order.getName(); } } dynamicValue.put(columnName, value); } else if (columnName.equals("currency")) { dynamicValue.put(columnName, receivablesPlan.getCurrency()); } else if (columnName.equals("receivable")) { String value = TextUtil.doubleToText(receivablesPlan.getReceivable(), 2); dynamicValue.put(columnName, value); } else if (columnName.equals("paid")) { String value = TextUtil.doubleToText(receivablesPlan.getPaid(), 2); dynamicValue.put(columnName, value); } else if (columnName.equals("isHasInvoice")) { dynamicValue.put(columnName, receivablesPlan.getIsHasInvoice()); } else if (columnName.equals("startDate")) { String value = DateUtil.formatDateNoHour(receivablesPlan.getStartDate()); dynamicValue.put(columnName, value); } else if (columnName.equals("endDate")) { String value = DateUtil.formatDateNoHour(receivablesPlan.getEndDate()); dynamicValue.put(columnName, value); } else if (columnName.equals("status")) { dynamicValue.put(columnName, receivablesPlan.getStatus()); } else if (columnName.equals("period")) { dynamicValue.put(columnName, String.valueOf(receivablesPlan.getPeriod())); } else if (columnName.equals("ownerId")) { User user = null; long ownerId = receivablesPlan.getOwnerId(); String value = StringPool.BLANK; if (ownerId > 0) { user = UserLocalServiceUtil.getUser(ownerId); if (user != null) { value = user.getFirstName(); } } dynamicValue.put(columnName, value); } else if (columnName.equals("createUserId")) { StringBuffer value = new StringBuffer(StringPool.BLANK); User user = null; long userId = receivablesPlan.getCreateUserId(); if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); if (user != null) { value.append(user.getFirstName()).append(StringPool.COMMA).append(StringPool.SPACE) .append(DateUtil.formatDateTime(receivablesPlan.getCreateDate())); } } dynamicValue.put(columnName, value.toString()); } else if (columnName.equals("createDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(receivablesPlan.getCreateDate())); } else if (columnName.equals("editUserId")) { StringBuffer value = new StringBuffer(StringPool.BLANK); User user = null; long userId = receivablesPlan.getEditUserId(); if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); if (user != null) { value.append(user.getFirstName()).append(StringPool.COMMA).append(StringPool.SPACE) .append(DateUtil.formatDateTime(receivablesPlan.getEditDate())); } } dynamicValue.put(columnName, value.toString()); } else if (columnName.equals("editDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(receivablesPlan.getEditDate())); } else if (columnName.equals("accountMan")) { long accountMan = receivablesPlan.getAccountMan(); User user = null; String value = StringPool.BLANK; if (accountMan > 0) { user = UserLocalServiceUtil.getUser(accountMan); value = user.getFirstName(); } dynamicValue.put(columnName, value); } else if (columnName.equals("description")) { dynamicValue.put(columnName, receivablesPlan.getDescription()); } } } } return dynamicValue; } public static Map<String, String> getRRecordValue( PortletRequest portletRequest, Long receivablesRecordId) throws PortalException, SystemException { Map<String, String> dynamicValue = null; long companyId = PortalUtil.getCompanyId(portletRequest); if (receivablesRecordId != null && receivablesRecordId > 0) { ReceivablesRecord receivablesRecord = ReceivablesRecordLocalServiceUtil .getReceivablesRecord(receivablesRecordId); if (receivablesRecord != null) { List<CompanyColumnDefinition> companyColumns = CompanyColumnDefinitionLocalServiceUtil .searchByTableName(companyId, TableConst.CRM_RRECORD, true); dynamicValue = new HashMap<String, String>(); for (CompanyColumnDefinition companyColumn : companyColumns) { String columnName = companyColumn.getColumnName(); if (columnName.equals("receivablesRecordCode")) { dynamicValue.put(columnName,receivablesRecord.getReceivablesRecordCode()); } else if (columnName.equals("customerId")) { Customer customer = null; String value = StringPool.BLANK; long customerId = receivablesRecord.getCustomerId(); if (customerId > 0) { customer = CustomerLocalServiceUtil.getCustomer(customerId); if (customer != null) { value = customer.getCustomerName(); } } dynamicValue.put(columnName, value); } else if (columnName.equals("receivable")) { String value = TextUtil.doubleToText(receivablesRecord.getReceivable(), 2); dynamicValue.put(columnName, value); } else if (columnName.equals("paid")) { String value = TextUtil.doubleToText(receivablesRecord.getPaid(), 2); dynamicValue.put(columnName, value); } else if (columnName.equals("ownerId")) { User user = null; long ownerId = receivablesRecord.getOwnerId(); String value = StringPool.BLANK; if (ownerId > 0) { user = UserLocalServiceUtil.getUser(ownerId); if (user != null) { value = user.getFirstName(); } } dynamicValue.put(columnName, value); } else if (columnName.equals("createUserId")) { StringBuffer value = new StringBuffer(StringPool.BLANK); User user = null; long userId = receivablesRecord.getCreateUserId(); if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); if (user != null) { value.append(user.getFirstName()).append(StringPool.COMMA) .append(DateUtil.formatDateTime(receivablesRecord.getCreateDate())); } } dynamicValue.put(columnName, value.toString()); } else if (columnName.equals("createDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime(receivablesRecord.getCreateDate())); } else if (columnName.equals("editUserId")) { StringBuffer value = new StringBuffer(StringPool.BLANK); User user = null; long userId = receivablesRecord.getEditUserId(); if (userId > 0) { user = UserLocalServiceUtil.getUser(userId); if (user != null) { value.append(user.getFirstName()).append(StringPool.COMMA) .append(DateUtil.formatDateTime(receivablesRecord.getEditDate())); } } dynamicValue.put(columnName, value.toString()); } else if (columnName.equals("editDate")) { dynamicValue.put(columnName, DateUtil.formatDateTime( receivablesRecord.getEditDate())); } else if (columnName.equals("currency")) { dynamicValue.put(columnName, receivablesRecord.getCurrency()); } else if (columnName.equals("description")) { dynamicValue.put(columnName, receivablesRecord.getDescription()); } else if (columnName.equals("head")) { long head = receivablesRecord.getHead(); User user = null; String value = null; if (head > 0) { user = UserLocalServiceUtil.getUser(head); } value = user != null ? user.getFirstName() : StringPool.BLANK; dynamicValue.put(columnName, value); } } } } return dynamicValue; } private static String getAttathment(PortletRequest portletRequest, Long attaField) { String results = StringPool.BLANK; try { if (attaField != null && attaField > 0) { PortletURL getDownloadURL = PortletURLUtil.getPortletURL(portletRequest); getDownloadURL.setParameter("operation", "get.attathment"); getDownloadURL.setParameter("fileEntryId", String.valueOf(attaField)); String fileTitle = FileEntryUtil.getFileEntryTitle(attaField); results += "<a target=‘_blank‘ href=‘"+ getDownloadURL.toString() +"‘>"+ fileTitle +"</a>"; } } catch (PortalException e) { _log.error(e); } catch (SystemException e) { _log.error(e); } catch (IOException e) { _log.error(e); } catch (Exception e) { _log.error(e); } return results; } private static Log _log = LogFactoryUtil.getLog(DynamicDetailEntity.class); }
标签:
原文地址:http://www.cnblogs.com/airycode/p/4813464.html