<?xml version="1.0" encoding="UTF-8"?>

<queryMap desc="价格因素管理">

	<query id="CorePriceFactor.queryTableName" desc="查询订货规格">
	<![CDATA[
	SELECT T.TABLE_NAME
    FROM USER_TABLES T
    WHERE T.TABLE_NAME LIKE 'COM%'
    OR T.TABLE_NAME LIKE 'SLM%' OR T.TABLE_NAME LIKE 'SEL%'
		   
	]]>

	</query>

	<query id="CorePriceFactor.queryColumnName" desc="查询订货规格">
	<![CDATA[
	
	 SELECT T.COLUMN_NAME FROM USER_TAB_COLUMNS T WHERE T.TABLE_NAME = ?
		   
	]]>
	</query>

	<query id="CorePriceFactor.queryBaseInfo" desc="查询订货规格">
	<![CDATA[
	
	 SELECT BASECODE,BASENAME FROM COM_BASE_INFO T WHERE T.SORTCODE = ? AND T.VALIDFLAG = '1'
		   
	]]>

	</query>

	<query id="CorePriceFactor.queryColumnType" desc="查询订货规格">
	<![CDATA[
	
	    SELECT T.DATA_TYPE
      FROM USER_TAB_COLUMNS T
     WHERE T.TABLE_NAME = ?
       AND T.COLUMN_NAME = ?
	     
	]]>

	</query>

	<query id="CorePriceFactor.queryFacNameByName" desc="查询订货规格">
	<![CDATA[
	
	   SELECT 1 FROM  SLM_PRICE_FACTOR  T WHERE  T.FACTOR_NAME = ? AND T.VALIDFLAG = '1'
	     
	]]>
	</query>

	<query id="CorePriceFactor.queryFacNameById" desc="查询订货规格">
	<![CDATA[
	
	  SELECT T.FACTOR_NAME FROM SLM_PRICE_FACTOR T
	  WHERE T.FACTOR_ID = ? AND T.VALIDFLAG = '1'
	     
	]]>
	</query>

	<query id="CorePriceFactor.insert" desc="查询订货规格">
	<![CDATA[
	    INSERT INTO SLM_PRICE_FACTOR(
        FACTOR_ID,
        FACTOR_NAME,
        TABLE_NAME,
        COLUMN_KEY,
        COLUMN_TYPE,
        VAL_SQL,
        VER_TYPE,
        CREATE_NAME,
        CREATE_TIME)
 VALUES( 
        (SELECT 'F' || LPAD(TO_NUMBER(NVL(SUBSTR(MAX(FACTOR_ID), 2, 6), '0')) + 1, 6, '0') FROM SLM_PRICE_FACTOR A ),
        '#FACTOR_NAME#',
        '#TABLE_NAME#',
        '#COLUMN_KEY#',
        '#COLUMN_TYPE#',
        '#VAL_SQL#',
        '#VER_TYPE#',
        '#CREATE_NAME#',
        SYSDATE)
	       
	]]>
	</query>

	<query id="CorePriceFactor.update" desc="查询订货规格">
	<![CDATA[
	
	  UPDATE SLM_PRICE_FACTOR T
   SET T.FACTOR_NAME = '#FACTOR_NAME#',
       T.TABLE_NAME  = '#TABLE_NAME#',
       T.COLUMN_KEY  = '#COLUMN_KEY#',
       T.COLUMN_TYPE = '#COLUMN_TYPE#',
       T.VAL_SQL     = '#VAL_SQL#',
       T.VER_TYPE    = '#VER_TYPE#',
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
   WHERE T.FACTOR_ID = '#FACTOR_ID#'
         AND T.VALIDFLAG = '1'
	  
	     
	]]>
	</query>

	<query id="CorePriceFactor.query" desc="查询订货规格">
	<![CDATA[
	SELECT T.FACTOR_ID,
       T.FACTOR_NAME,
       T.TABLE_NAME,
       T.COLUMN_KEY,
       T.COLUMN_TYPE,
       T.VAL_SQL,
       T.VER_TYPE,
       DECODE(T.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
       T.CREATE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.UPDATE_NAME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME
  FROM SLM_PRICE_FACTOR T
 WHERE T.FACTOR_ID LIKE '%'|| '#FACTOR_ID#' ||'%'
   AND T.FACTOR_NAME LIKE '%'|| '#FACTOR_NAME#' || '%'
   AND T.VALIDFLAG IN ('1', '#VALIDFLAG#')
 
	     
	]]>
	</query>


	<query id="CorePriceFactor.canResume" desc="查询订货规格">
	<![CDATA[
	
	   SELECT 1 FROM  SLM_PRICE_FACTOR  T 
	   WHERE  T.FACTOR_ID != ? 
	      AND T.FACTOR_NAME = ? 
	      AND T.VALIDFLAG = '1'
	     
	]]>
	</query>

	<query id="CorePriceFactor.Delete" desc="查询订货规格">
	<![CDATA[
	
	   UPDATE   SLM_PRICE_FACTOR  T 
	   SET T.VALIDFLAG = '0',
	       T.UPDATE_NAME = ?,
	       T.UPDATE_TIME = SYSDATE
	   WHERE  T.FACTOR_ID = ? 
	      AND T.VALIDFLAG = '1'
	     
	]]>
	</query>

	<query id="CorePriceFactor.Resume" desc="查询订货规格">
	<![CDATA[
	
	   UPDATE  SLM_PRICE_FACTOR  T 
	   SET T.VALIDFLAG = '1',
	       T.UPDATE_NAME = ?,
	       T.UPDATE_TIME = SYSDATE
	   WHERE  T.FACTOR_ID = ? 
	      AND T.VALIDFLAG = '0'
	     
	]]>
	</query>




</queryMap>