<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="基价管理">

<query id="CorePriceBasePrice.GetFactorInfo" desc="根据因素名称查询因素信息 ">
	<![CDATA[
		  SELECT * FROM  SLM_PRICE_FACTOR  T WHERE  T.FACTOR_NAME = ? AND T.VALIDFLAG = '1'
	     	]]>
	</query>
	
	<query id="CorePriceBasePrice.GetRangeInfo" desc="根据框架ID获取相应 的 因素范围信息 ">
	<![CDATA[
select frame_id,br_id,t.factorclassify_id ,factorclassify_name, case when factor_val !='' then '='  else factor_min_sign    end as factor_min_sign  
       ,case     when factor_val !='' then factor_val  else factor_min_val    end as factor_min_val  
      , case     when factor_val !='' then '='  else factor_max_sign    end as factor_max_sign 
      , case     when factor_val !='' then factor_val  else factor_max_val    end as factor_max_val
       from slm_price_baseframe_classify t where t.factorclassify_id in ('Y_1_FACTOR_ID','Y_2_FACTOR_ID') and t.frame_id=?
	]]>
	</query>
	
	<query id="CorePriceBasePrice.insert" desc="插入基价维护 信息">
	<![CDATA[
  INSERT INTO SLM_PRICE_BASEPRICE(
  PRICE_HEAD_ID,
        PRICE_VER_ID,
        PRICE_VER_M,
        PRICE_VER_SQE,
        FRAME_ID,
        X_1_ID_VALUE,
        X_2_ID_VALUE,
        X_3_ID_VALUE,
        X_4_ID_VALUE,
        X_5_ID_VALUE,
        X_6_ID_VALUE,
        X_7_ID_VALUE,
        X_8_ID_VALUE,
        Y_1_ID_VALUE,
        Y_2_ID_VALUE,
        PRICE_NUM,
        CREATE_NAME,
        CREATE_TIME)
 VALUES( 
       (SELECT 'J' || LPAD(TO_NUMBER(NVL(SUBSTR(MAX(PRICE_HEAD_ID), 2, 6), '0')) + 1, 6, '0') FROM SLM_PRICE_BASEPRICE A ),
         '#PRICE_VER_ID#',
        '#PRICE_VER_M#',
        '#PRICE_VER_SQE#',
        '#FRAME_ID#',
        '#X1_ID_VALUE#',
        '#X2_ID_VALUE#',
        '#X3_ID_VALUE#',
        '#X4_ID_VALUE#',
        '#X5_ID_VALUE#',
        '#X6_ID_VALUE#',
        '#X7_ID_VALUE#',
        '#X8_ID_VALUE#',
        '#Y1_ID_VALUE#',
        '#Y2_ID_VALUE#',
        '#PRICE_NUM#',
        '#CREATE_NAME#',
        SYSDATE)
       
	       
	]]>
	</query>
		<query id="CorePriceBasePrice.update" desc="更新基价维护 信息">
	<![CDATA[
 UPDATE SLM_PRICE_BASEPRICE T
   SET 
   
        T.PRICE_VER_ID = '#PRICE_VER_ID#',
        T.PRICE_VER_M = '#PRICE_VER_M#',
        T.PRICE_VER_SQE = '#PRICE_VER_SQE#',
        T.FRAME_ID = '#FRAME_ID#',
        T.X_1_ID_VALUE = '#X1_ID_VALUE#',
        T.X_2_ID_VALUE = '#X2_ID_VALUE#',
        T.X_3_ID_VALUE = '#X3_ID_VALUE#',
        T.X_4_ID_VALUE = '#X4_ID_VALUE#',
        T.X_5_ID_VALUE = '#X5_ID_VALUE#',
        T.X_6_ID_VALUE = '#X6_ID_VALUE#',
        T.X_7_ID_VALUE = '#X7_ID_VALUE#',
        T.X_8_ID_VALUE = '#X8_ID_VALUE#',
        T.Y_1_ID_VALUE = '#Y1_ID_VALUE#',
        T.Y_2_ID_VALUE = '#Y2_ID_VALUE#',
        T.PRICE_NUM = '#PRICE_NUM#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE
 WHERE
T.PRICE_HEAD_ID = '#PRICE_HEAD_ID#'
AND T.PRICE_VER_SQE = '#PRICE_VER_SQE#'
AND T.FRAME_ID = '#FRAME_ID#'
	       
	]]>
	</query>
	
			<query id="CorePriceBasePrice.query" desc="更新基价维护 信息">
	<![CDATA[
select validflag,create_name,create_time, frame_id,PRICE_HEAD_ID,price_ver_id,price_ver_m ,m.TiaoShu, t.x_1_id_value,t.x_2_id_value,t.x_3_id_value,x_4_id_value,x_5_id_value,
x_6_id_value,x_7_id_value,x_8_id_value, price_num from slm_price_baseprice  t  left join (select nvl(t.x_1_id_value,'') as x_1_id_value ,NVL(t.x_2_id_value,'') as x_2_id_value,nvl(t.x_3_id_value,'') as x_3_id_value, count(*) as TiaoShu from slm_price_baseprice  t  group by nvl(t.x_1_id_value,''),NVL(t.x_2_id_value,''),nvl(t.x_3_id_value,'')
)  m on nvl(t.x_1_id_value,'0')=nvl(m.x_1_id_value,'0') and nvl(t.x_2_id_value,'0')=nvl(m.x_2_id_value,'0') and nvl(t.x_3_id_value,'0')=nvl(m.x_3_id_value,'0')



	       
	]]>
	</query>
	
	<query id="CorePriceBasePrice.canResume" desc="查询订货规格">
	<![CDATA[

	        SELECT * FROM  SLM_PRICE_BASEPRICE  T 
	   WHERE  T.PRICE_HEAD_ID != '#PRICE_HEAD_ID#' 
	      AND T.VALIDFLAG = '1'
	     
	]]>
	</query>
	
	<query id="CorePriceBasePrice.Delete" desc="删除价格因素范围">
	<![CDATA[
	
	   UPDATE   SLM_PRICE_BASEPRICE  T 
	   SET T.VALIDFLAG = '0',
	       T.UPDATE_NAME = '#UPDATE_NAME#',
	       T.UPDATE_TIME = SYSDATE
	   WHERE  T.PRICE_HEAD_ID = '#PRICE_HEAD_ID#' 
	      AND T.VALIDFLAG = '1'
	     
	]]>
	</query>

	<query id="CorePriceBasePrice.Resume" desc="恢复价格因素范围">
	<![CDATA[
	
	   UPDATE  SLM_PRICE_BASEPRICE  T 
	   SET T.VALIDFLAG = '1',
	       T.UPDATE_NAME =  '#UPDATE_NAME#',
	       T.UPDATE_TIME = SYSDATE
	   WHERE  T.PRICE_HEAD_ID = '#PRICE_HEAD_ID#' 
	      AND T.VALIDFLAG = '0'
	     
	]]>
	</query>
	
	
	
	</queryMap>
