<![CDATA[select t1.* from (SELECT t1.ACTIVE, t1.CAMPAIGN_ID, t131.NAME AS CAMPAIGN_ID_TEXT, t1.CITY, t1.COLOR, t61.CURRENCY_ID AS COMPANY_CURRENCY, t1.COMPANY_ID, t151.NAME AS COMPANY_ID_TEXT, t1.CONTACT_NAME, t1.COUNTRY_ID, t161.NAME AS COUNTRY_ID_TEXT, t1.CREATE_DATE, t1.CREATE_UID, t111.NAME AS CREATE_UID_TEXT, t1.DATE_ACTION_LAST, t1.DATE_CLOSED, t1.DATE_CONVERSION, t1.DATE_DEADLINE, t1.DATE_LAST_STAGE_UPDATE, t1.DATE_OPEN, t1.DAY_CLOSE, t1.DAY_OPEN, t1.DESCRIPTION, t1.EMAIL_CC, t1.EMAIL_FROM, t1.EXPECTED_REVENUE, t1.IBIZFUNCTION, t1.ID, t1.LOST_REASON, t181.NAME AS LOST_REASON_TEXT, t1.MEDIUM_ID, t51.NAME AS MEDIUM_ID_TEXT, t1.MESSAGE_BOUNCE, t1.MESSAGE_MAIN_ATTACHMENT_ID, t1.MOBILE, t1.NAME, t41.EMAIL AS PARTNER_ADDRESS_EMAIL, t41.MOBILE AS PARTNER_ADDRESS_MOBILE, t41.NAME AS PARTNER_ADDRESS_NAME, t41.PHONE AS PARTNER_ADDRESS_PHONE, t1.PARTNER_ID, t1.PARTNER_NAME, t1.PHONE, t1.PLANNED_REVENUE, t1.PRIORITY, t1.PROBABILITY, t1.REFERRED, t1.SOURCE_ID, t31.NAME AS SOURCE_ID_TEXT, t1.STAGE_ID, t141.NAME AS STAGE_ID_TEXT, t1.STATE_ID, t121.NAME AS STATE_ID_TEXT, t1.STREET, t1.STREET2, t1.TEAM_ID, t71.NAME AS TEAM_ID_TEXT, t1.TITLE, t171.NAME AS TITLE_TEXT, t1.TYPE, t21.EMAIL AS USER_EMAIL, t1.USER_ID, t21.NAME AS USER_ID_TEXT, t11.LOGIN AS USER_LOGIN, t1.WEBSITE, t1.WRITE_DATE, t1.WRITE_UID, t91.NAME AS WRITE_UID_TEXT, t1.ZIP FROM CRM_LEAD t1 LEFT JOIN RES_USERS t11 ON t1.USER_ID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN UTM_SOURCE t31 ON t1.SOURCE_ID = t31.ID LEFT JOIN RES_PARTNER t41 ON t1.PARTNER_ID = t41.ID LEFT JOIN UTM_MEDIUM t51 ON t1.MEDIUM_ID = t51.ID LEFT JOIN RES_COMPANY t61 ON t1.COMPANY_ID = t61.ID LEFT JOIN CRM_TEAM t71 ON t1.TEAM_ID = t71.ID LEFT JOIN RES_USERS t81 ON t1.WRITE_UID = t81.ID LEFT JOIN RES_PARTNER t91 ON t81.PARTNER_ID = t91.ID LEFT JOIN RES_USERS t101 ON t1.CREATE_UID = t101.ID LEFT JOIN RES_PARTNER t111 ON t101.PARTNER_ID = t111.ID LEFT JOIN RES_COUNTRY_STATE t121 ON t1.STATE_ID = t121.ID LEFT JOIN UTM_CAMPAIGN t131 ON t1.CAMPAIGN_ID = t131.ID LEFT JOIN CRM_STAGE t141 ON t1.STAGE_ID = t141.ID LEFT JOIN RES_PARTNER t151 ON t61.PARTNER_ID = t151.ID LEFT JOIN RES_COUNTRY t161 ON t1.COUNTRY_ID = t161.ID LEFT JOIN RES_PARTNER_TITLE t171 ON t1.TITLE = t171.ID LEFT JOIN CRM_LOST_REASON t181 ON t1.LOST_REASON = t181.ID ) t1 where id=#{id}]]>
<where><iftest="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<iftest="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Default]-->
<sqlid="Default"databaseId="postgresql">
<![CDATA[ SELECT t1.ACTIVE, t1.CAMPAIGN_ID, t131.NAME AS CAMPAIGN_ID_TEXT, t1.CITY, t1.COLOR, t61.CURRENCY_ID AS COMPANY_CURRENCY, t1.COMPANY_ID, t151.NAME AS COMPANY_ID_TEXT, t1.CONTACT_NAME, t1.COUNTRY_ID, t161.NAME AS COUNTRY_ID_TEXT, t1.CREATE_DATE, t1.CREATE_UID, t111.NAME AS CREATE_UID_TEXT, t1.DATE_ACTION_LAST, t1.DATE_CLOSED, t1.DATE_CONVERSION, t1.DATE_DEADLINE, t1.DATE_LAST_STAGE_UPDATE, t1.DATE_OPEN, t1.DAY_CLOSE, t1.DAY_OPEN, t1.EMAIL_FROM, t1.EXPECTED_REVENUE, t1.IBIZFUNCTION, t1.ID, t1.LOST_REASON, t181.NAME AS LOST_REASON_TEXT, t1.MEDIUM_ID, t51.NAME AS MEDIUM_ID_TEXT, t1.MESSAGE_BOUNCE, t1.MESSAGE_MAIN_ATTACHMENT_ID, t1.MOBILE, t1.NAME, t41.EMAIL AS PARTNER_ADDRESS_EMAIL, t41.MOBILE AS PARTNER_ADDRESS_MOBILE, t41.NAME AS PARTNER_ADDRESS_NAME, t41.PHONE AS PARTNER_ADDRESS_PHONE, t1.PARTNER_ID, t1.PARTNER_NAME, t1.PHONE, t1.PLANNED_REVENUE, t1.PRIORITY, t1.PROBABILITY, t1.REFERRED, t1.SOURCE_ID, t31.NAME AS SOURCE_ID_TEXT, t1.STAGE_ID, t141.NAME AS STAGE_ID_TEXT, t1.STATE_ID, t121.NAME AS STATE_ID_TEXT, t1.STREET, t1.STREET2, t1.TEAM_ID, t71.NAME AS TEAM_ID_TEXT, t1.TITLE, t171.NAME AS TITLE_TEXT, t1.TYPE, t21.EMAIL AS USER_EMAIL, t1.USER_ID, t21.NAME AS USER_ID_TEXT, t11.LOGIN AS USER_LOGIN, t1.WEBSITE, t1.WRITE_DATE, t1.WRITE_UID, t91.NAME AS WRITE_UID_TEXT, t1.ZIP FROM CRM_LEAD t1 LEFT JOIN RES_USERS t11 ON t1.USER_ID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN UTM_SOURCE t31 ON t1.SOURCE_ID = t31.ID LEFT JOIN RES_PARTNER t41 ON t1.PARTNER_ID = t41.ID LEFT JOIN UTM_MEDIUM t51 ON t1.MEDIUM_ID = t51.ID LEFT JOIN RES_COMPANY t61 ON t1.COMPANY_ID = t61.ID LEFT JOIN CRM_TEAM t71 ON t1.TEAM_ID = t71.ID LEFT JOIN RES_USERS t81 ON t1.WRITE_UID = t81.ID LEFT JOIN RES_PARTNER t91 ON t81.PARTNER_ID = t91.ID LEFT JOIN RES_USERS t101 ON t1.CREATE_UID = t101.ID LEFT JOIN RES_PARTNER t111 ON t101.PARTNER_ID = t111.ID LEFT JOIN RES_COUNTRY_STATE t121 ON t1.STATE_ID = t121.ID LEFT JOIN UTM_CAMPAIGN t131 ON t1.CAMPAIGN_ID = t131.ID LEFT JOIN CRM_STAGE t141 ON t1.STAGE_ID = t141.ID LEFT JOIN RES_PARTNER t151 ON t61.PARTNER_ID = t151.ID LEFT JOIN RES_COUNTRY t161 ON t1.COUNTRY_ID = t161.ID LEFT JOIN RES_PARTNER_TITLE t171 ON t1.TITLE = t171.ID LEFT JOIN CRM_LOST_REASON t181 ON t1.LOST_REASON = t181.ID
]]>
</sql>
<!--数据查询[View]-->
<sqlid="View"databaseId="postgresql">
<![CDATA[ SELECT t1.ACTIVE, t1.CAMPAIGN_ID, t131.NAME AS CAMPAIGN_ID_TEXT, t1.CITY, t1.COLOR, t61.CURRENCY_ID AS COMPANY_CURRENCY, t1.COMPANY_ID, t151.NAME AS COMPANY_ID_TEXT, t1.CONTACT_NAME, t1.COUNTRY_ID, t161.NAME AS COUNTRY_ID_TEXT, t1.CREATE_DATE, t1.CREATE_UID, t111.NAME AS CREATE_UID_TEXT, t1.DATE_ACTION_LAST, t1.DATE_CLOSED, t1.DATE_CONVERSION, t1.DATE_DEADLINE, t1.DATE_LAST_STAGE_UPDATE, t1.DATE_OPEN, t1.DAY_CLOSE, t1.DAY_OPEN, t1.DESCRIPTION, t1.EMAIL_CC, t1.EMAIL_FROM, t1.EXPECTED_REVENUE, t1.IBIZFUNCTION, t1.ID, t1.LOST_REASON, t181.NAME AS LOST_REASON_TEXT, t1.MEDIUM_ID, t51.NAME AS MEDIUM_ID_TEXT, t1.MESSAGE_BOUNCE, t1.MESSAGE_MAIN_ATTACHMENT_ID, t1.MOBILE, t1.NAME, t41.EMAIL AS PARTNER_ADDRESS_EMAIL, t41.MOBILE AS PARTNER_ADDRESS_MOBILE, t41.NAME AS PARTNER_ADDRESS_NAME, t41.PHONE AS PARTNER_ADDRESS_PHONE, t1.PARTNER_ID, t1.PARTNER_NAME, t1.PHONE, t1.PLANNED_REVENUE, t1.PRIORITY, t1.PROBABILITY, t1.REFERRED, t1.SOURCE_ID, t31.NAME AS SOURCE_ID_TEXT, t1.STAGE_ID, t141.NAME AS STAGE_ID_TEXT, t1.STATE_ID, t121.NAME AS STATE_ID_TEXT, t1.STREET, t1.STREET2, t1.TEAM_ID, t71.NAME AS TEAM_ID_TEXT, t1.TITLE, t171.NAME AS TITLE_TEXT, t1.TYPE, t21.EMAIL AS USER_EMAIL, t1.USER_ID, t21.NAME AS USER_ID_TEXT, t11.LOGIN AS USER_LOGIN, t1.WEBSITE, t1.WRITE_DATE, t1.WRITE_UID, t91.NAME AS WRITE_UID_TEXT, t1.ZIP FROM CRM_LEAD t1 LEFT JOIN RES_USERS t11 ON t1.USER_ID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN UTM_SOURCE t31 ON t1.SOURCE_ID = t31.ID LEFT JOIN RES_PARTNER t41 ON t1.PARTNER_ID = t41.ID LEFT JOIN UTM_MEDIUM t51 ON t1.MEDIUM_ID = t51.ID LEFT JOIN RES_COMPANY t61 ON t1.COMPANY_ID = t61.ID LEFT JOIN CRM_TEAM t71 ON t1.TEAM_ID = t71.ID LEFT JOIN RES_USERS t81 ON t1.WRITE_UID = t81.ID LEFT JOIN RES_PARTNER t91 ON t81.PARTNER_ID = t91.ID LEFT JOIN RES_USERS t101 ON t1.CREATE_UID = t101.ID LEFT JOIN RES_PARTNER t111 ON t101.PARTNER_ID = t111.ID LEFT JOIN RES_COUNTRY_STATE t121 ON t1.STATE_ID = t121.ID LEFT JOIN UTM_CAMPAIGN t131 ON t1.CAMPAIGN_ID = t131.ID LEFT JOIN CRM_STAGE t141 ON t1.STAGE_ID = t141.ID LEFT JOIN RES_PARTNER t151 ON t61.PARTNER_ID = t151.ID LEFT JOIN RES_COUNTRY t161 ON t1.COUNTRY_ID = t161.ID LEFT JOIN RES_PARTNER_TITLE t171 ON t1.TITLE = t171.ID LEFT JOIN CRM_LOST_REASON t181 ON t1.LOST_REASON = t181.ID
<![CDATA[select t1.* from (SELECT t1.ACTIVITY_DATE_DEADLINE, t1.ACTIVITY_STATE, t1.CREATE_DATE, t1.CREATE_UID, t41.NAME AS CREATE_UNAME, t1.DATE_END, t1.ID, t1.NAME, t1.ORDERING_DATE, t1.ORDER_COUNT, t1.ORIGIN, t1.SCHEDULE_DATE, t1.VENDOR_ID, t51.NAME AS VENDOR_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UNAME FROM PURCHASE_REQUISITION t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN RES_USERS t31 ON t1.CREATE_UID = t31.ID LEFT JOIN RES_PARTNER t41 ON t31.PARTNER_ID = t41.ID LEFT JOIN RES_PARTNER t51 ON t1.VENDOR_ID = t51.ID ) t1 where id=#{id}]]>
<![CDATA[select t1.* from (SELECT t1.ACTIVITY_DATE_DEADLINE, t1.ACTIVITY_STATE, t1.CREATE_DATE, t1.CREATE_UID, t41.NAME AS CREATE_UNAME, t1.DATE_END, t1.ID, t1.NAME, t1.ORDERING_DATE, t1.ORDER_COUNT, t1.ORIGIN, t1.SCHEDULE_DATE, t1.TYPE_ID, t1.VENDOR_ID, t51.NAME AS VENDOR_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UNAME FROM PURCHASE_REQUISITION t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN RES_USERS t31 ON t1.CREATE_UID = t31.ID LEFT JOIN RES_PARTNER t41 ON t31.PARTNER_ID = t41.ID LEFT JOIN RES_PARTNER t51 ON t1.VENDOR_ID = t51.ID ) t1 where id=#{id}]]>
<![CDATA[ SELECT t1.ACTIVITY_DATE_DEADLINE, t1.ACTIVITY_STATE, t1.CREATE_DATE, t1.CREATE_UID, t41.NAME AS CREATE_UNAME, t1.DATE_END, t1.ID, t1.NAME, t1.ORDERING_DATE, t1.ORDER_COUNT, t1.ORIGIN, t1.SCHEDULE_DATE, t1.VENDOR_ID, t51.NAME AS VENDOR_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UNAME FROM PURCHASE_REQUISITION t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN RES_USERS t31 ON t1.CREATE_UID = t31.ID LEFT JOIN RES_PARTNER t41 ON t31.PARTNER_ID = t41.ID LEFT JOIN RES_PARTNER t51 ON t1.VENDOR_ID = t51.ID
<![CDATA[ SELECT t1.ACTIVITY_DATE_DEADLINE, t1.ACTIVITY_STATE, t1.CREATE_DATE, t1.CREATE_UID, t41.NAME AS CREATE_UNAME, t1.DATE_END, t1.ID, t1.NAME, t1.ORDERING_DATE, t1.ORDER_COUNT, t1.ORIGIN, t1.SCHEDULE_DATE, t1.TYPE_ID, t1.VENDOR_ID, t51.NAME AS VENDOR_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UNAME FROM PURCHASE_REQUISITION t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN RES_USERS t31 ON t1.CREATE_UID = t31.ID LEFT JOIN RES_PARTNER t41 ON t31.PARTNER_ID = t41.ID LEFT JOIN RES_PARTNER t51 ON t1.VENDOR_ID = t51.ID
]]>
</sql>
<!--数据查询[View]-->
<sqlid="View"databaseId="postgresql">
<![CDATA[ SELECT t1.ACTIVITY_DATE_DEADLINE, t1.ACTIVITY_STATE, t1.CREATE_DATE, t1.CREATE_UID, t41.NAME AS CREATE_UNAME, t1.DATE_END, t1.ID, t1.NAME, t1.ORDERING_DATE, t1.ORDER_COUNT, t1.ORIGIN, t1.SCHEDULE_DATE, t1.VENDOR_ID, t51.NAME AS VENDOR_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UNAME FROM PURCHASE_REQUISITION t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN RES_USERS t31 ON t1.CREATE_UID = t31.ID LEFT JOIN RES_PARTNER t41 ON t31.PARTNER_ID = t41.ID LEFT JOIN RES_PARTNER t51 ON t1.VENDOR_ID = t51.ID
<![CDATA[ SELECT t1.ACTIVITY_DATE_DEADLINE, t1.ACTIVITY_STATE, t1.CREATE_DATE, t1.CREATE_UID, t41.NAME AS CREATE_UNAME, t1.DATE_END, t1.ID, t1.NAME, t1.ORDERING_DATE, t1.ORDER_COUNT, t1.ORIGIN, t1.SCHEDULE_DATE, t1.TYPE_ID, t1.VENDOR_ID, t51.NAME AS VENDOR_ID_TEXT, t1.WRITE_DATE, t1.WRITE_UID, t21.NAME AS WRITE_UNAME FROM PURCHASE_REQUISITION t1 LEFT JOIN RES_USERS t11 ON t1.WRITE_UID = t11.ID LEFT JOIN RES_PARTNER t21 ON t11.PARTNER_ID = t21.ID LEFT JOIN RES_USERS t31 ON t1.CREATE_UID = t31.ID LEFT JOIN RES_PARTNER t41 ON t31.PARTNER_ID = t41.ID LEFT JOIN RES_PARTNER t51 ON t1.VENDOR_ID = t51.ID
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Crm_lead-searchDefault-all') and hasPermission(#context,'iBizBusinessCentral-Crm_lead-Get')")
@PreAuthorize("hasAnyAuthority('ROLE_SUPERADMIN','iBizBusinessCentral-Crm_lead-searchDefault-all') and hasPermission(#context,'iBizBusinessCentral-Crm_lead-Get')")