<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="最终用户与认证产线">

	<query id="CoreComBaseCustomRPline.getFinallUser" desc="查询最终客户">
		<![CDATA[
	            SELECT DISTINCT MER.CUSTOMER_NO, MER.CUSTOMER_NM
  FROM (SELECT *
          FROM SLM_BASE_CUSTM_USE
         WHERE SALE_ORG IN ('100102',
                            
                            '100101',
                            '100103')
           AND CUSTM_USE = '100204') TS
  LEFT JOIN SLM_BASE_CUSTOMER MER
    ON TS.CUSTOMER_NO = MER.CUSTOMER_NO
   AND TS.VALIDFLAG = '1'
   AND MER.VALIDFLAG = '1'
 WHERE MER.CUSTOMER_NM || '&' LIKE '%' || ?|| '%'
 ORDER BY NLSSORT( MER.CUSTOMER_NM,'NLS_SORT = SCHINESE_PINYIN_M')     
		]]>
	</query>

	<query id="CoreComBaseCustomRPline.getProDuc" desc="查询品名">
		<![CDATA[
	            SELECT PRODUCCODE, PRODUCNAME, PRODUC_STYLE, PRODUC_DESC,PRODUC_JX
  FROM COM_BASE_PRODUCT T
 WHERE T.VALIDFLAG = '1'
  ORDER BY NLSSORT( PRODUC_DESC,'NLS_SORT = SCHINESE_PINYIN_M')  
		]]>
	</query>

	<query id="CoreComBaseCustomRPline.getProline" desc="查询产线">
		<![CDATA[
	   SELECT 'False' CHC,
       '' CUSTOMER_NO,
       '' PRODUCCODE,
       PLINE_CODE,
       PLINE_NAME,
       PROCESS_CODE,
       PROCESS_DESC,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC
  FROM COM_BASE_PLINE A
 WHERE A.PLINE_CODE NOT IN (SELECT B.PLINE_CODE
                              FROM COM_BASE_CUSTOM_R_PLINE B
                             WHERE B.CUSTOMER_NO = ?
                               AND B.Produccode = ?
                               AND B.VALIDFLAG = '1')
UNION
SELECT 'True' CHC,
       B.CUSTOMER_NO,
       B.PRODUCCODE,
       B.PLINE_CODE,
       B.PLINE_NAME,
       A.PROCESS_CODE,
       A.PROCESS_DESC,
       A.DEPARTMENT_CODE,
       A.DEPARTMENT_DESC
  FROM COM_BASE_CUSTOM_R_PLINE B, COM_BASE_PLINE A
 WHERE A.PLINE_CODE = B.PLINE_CODE
   AND B.CUSTOMER_NO = ?
   AND B.PRODUCCODE = ?
   AND B.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
	           
		]]>
	</query>

	<query id="CoreComBaseCustomRPline.deleteCustPline" desc="删除最终用户与认证产线">
		<![CDATA[
              DELETE COM_BASE_CUSTOM_R_PLINE
               WHERE CUSTOMER_NO = ?
                 AND PRODUCCODE = ?
		]]>
	</query>

	<query id="CoreComBaseCustomRPline.addCustPline" desc="增加最终用户与认证产线">
		<![CDATA[
               INSERT INTO COM_BASE_CUSTOM_R_PLINE(
        CUSTOMER_NO,
        CUSTOMER_NM,
        PRODUCCODE,
        PRODUCNAME,
        PLINE_CODE,
        PLINE_NAME,
        PROCESS_CDOE,
        PROCESS_DESC,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME,
        DELETE_NAME,
        DELETE_TIME,
        VALIDFLAG,
        MEMO)
 VALUES( 
        '#CUSTOMER_NO#',
        '#CUSTOMER_NM#',
        '#PRODUCCODE#',
        '#PRODUCNAME#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#PROCESS_CDOE#',
        '#PROCESS_DESC#',
        '#CREATE_NAME#',
        SYSDATE,
        '#UPDATE_NAME#',
        NULL,
        '#DELETE_NAME#',
        NULL,
        '1',
        '#MEMO#')
		]]>
	</query>

	<query id="CoreComBaseCustomRPline.getCustPline" desc="查询最终用户与认证产线">
		<![CDATA[
              SELECT CUSTOMER_NO,
       CUSTOMER_NM,
       PRODUCCODE,
       PRODUCNAME,
       PLINE_CODE,
       PLINE_NAME,
       PROCESS_CDOE,
       PROCESS_DESC,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       VALIDFLAG,
       MEMO
  FROM COM_BASE_CUSTOM_R_PLINE T WHERE T.VALIDFLAG = '1'
		]]>
	</query>



</queryMap>