<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	
	<query id="CoreOrderModel.GetMaxCode" desc="获取最大值">
		<![CDATA[
			select max(ORDER_MODEL_NO) from SLM_ORDER_MODEL_HEAD where ORDER_MODEL_NO like ?|| '%'
		]]>
	</query>
	
	<query id="CoreOrderModel.GetMaxCode_Item" desc="获取最大值">
		<![CDATA[
			SELECT MAX(MODEL_SEQ_NO) FROM SLM_ORDER_MODEL_ITEM WHERE ORDER_MODEL_NO=?
		]]>
	</query>
	
	<query id="CoreOrderModel.GetIndex" desc="获取最大顺序号">
		<![CDATA[
			 SELECT MAX(MODEL_INDEX) FROM SLM_ORDER_MODEL_ITEM WHERE ORDER_MODEL_NO=?
		]]>
	</query> 
	
	<query id="CoreOrderModel.isRepeatName" desc="判断描述是否存在">
		<![CDATA[
			SELECT ORDER_MODEL_NO FROM SLM_ORDER_MODEL_HEAD WHERE ORDER_MODEL_DESC = ?
		]]>
	</query>
	
	<query id="CoreOrderModel.isRepeatName_Item" desc="判断条目序号是否存在">
		<![CDATA[
			SELECT MODEL_SEQ FROM SLM_ORDER_MODEL_ITEM WHERE MODEL_SEQ = ? AND ORDER_MODEL_NO = ?
			AND VALIDFLAG = '1'
		]]>
	</query>
	
	
	<query id="CoreOrderModel.GetSy" desc="适用单位数据源绑定">
		<![CDATA[
			SELECT A.CUSTOMER_NO,A.CUSTOMER_NM FROM SLM_BASE_CUSTOMER A,SLM_BASE_CUSTM_RIGHT B 
			WHERE A.CUSTOMER_NO=B.CUSTOMER_NO AND B.SALE_ORG=? UNION
			SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE SORTCODE='1206' ORDER BY CUSTOMER_NO
		]]>
	</query>
	
	<query id="CoreOrderModel.doQuery" desc="查询功能">
		<![CDATA[
			SELECT *
   FROM (SELECT *
          FROM SLM_ORDER_MODEL_HEAD
         WHERE USE_UNIT = ?
           AND VALIDFLAG = '1'
        UNION ALL
        SELECT *
          FROM SLM_ORDER_MODEL_HEAD
         WHERE GENERAL_FL = '1'
           AND ORDER_MODEL_NO NOT IN
               (SELECT ORDER_MODEL_NO
                  FROM SLM_ORDER_MODEL_HEAD
                 WHERE USE_UNIT = ?
                   AND VALIDFLAG = '1')
        UNION ALL
        SELECT *
          FROM SLM_ORDER_MODEL_HEAD
         WHERE GENERAL_FL != '1'
           AND USE_UNIT != ?
           AND VALIDFLAG = '1')
  WHERE LOWER(USE_UNIT) || '&' LIKE '%' || LOWER(?) || '%'
   AND LOWER(ORDER_MODEL_DESC) || '&' LIKE '%' || LOWER(?) || '%'
 ORDER BY ORDER_MODEL_NO

		]]>
	</query>
	
	<query id="CoreOrderModel.doQueryNew" desc="查询功能">
		<![CDATA[
			SELECT ORDER_MODEL_NO,
       ORDER_MODEL_DESC,
       GENERAL_FL,
       CUSTOMER_MODEL_FL,
       USE_UNIT,
       USE_UNIT_DESC,
       ORDER_MODEL_STS,
       VALIDFLAG,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME
    FROM SLM_ORDER_MODEL_HEAD
    WHERE LOWER(ORDER_MODEL_DESC) || '&' LIKE '%' || LOWER(?) || '%'
    AND LOWER(USE_UNIT) || '&' LIKE '%' || LOWER(?) || '%'
    AND VALIDFLAG = '1'
    ORDER BY ORDER_MODEL_NO

		]]>
	</query>
	
	
	<query id="CoreOrderModel.GetOrderModelItem" desc="查询功能">
		<![CDATA[
     SELECT B.ORDER_MODEL_NO,
       B.ORDER_MODEL_DESC,
       A.MODEL_SEQ_NO,
       A.MODEL_SEQ,
       A.MODEL_INDEX,
       A.MODEL_CLS,
       A.MODEL_ITM,
       A.MODEL_ITM_VAL

   FROM SLM_ORDER_MODEL_HEAD B, SLM_ORDER_MODEL_ITEM A
   WHERE B.ORDER_MODEL_NO = ?
   AND B.ORDER_MODEL_NO = A.ORDER_MODEL_NO(+)
   AND B.VALIDFLAG = '1'
   AND A.VALIDFLAG(+) = '1'
   ORDER BY MODEL_INDEX

			
		]]>
	</query>
	
	
	<query id="CoreOrderModel.doAdd" desc="新增">
		<![CDATA[
			 insert into SLM_ORDER_MODEL_HEAD (
			 			 ORDER_MODEL_NO,
			 			 Order_Model_Desc,
			 			 Use_Unit,
			 			 Use_Unit_Desc,
			 			 General_Fl,
			 			 Customer_Model_Fl,
			 			 Order_Model_Sts,
			 			 Validflag,
			 			 Create_Name,
			 			 Create_Time
			 			 ) 
			 			 VALUES(?,?,?,?
			 			 		,?,?,?,1,
			 			 		?,SYSDATE)
							
			  
		]]>
	</query>
	
	<query id="CoreOrderModel.doAdd_Item" desc="新增">
		<![CDATA[
			 insert into SLM_ORDER_MODEL_ITEM (
       						 ORDER_MODEL_NO,
       						 Model_Seq_No,
       						 Model_Seq,
       						 Model_Index,
       						 Model_Cls,
       						 Model_Itm,
       						 Model_Itm_Val,
       						 Validflag,
       						 Create_Name,
       						 Create_Time
							) values
							(
							?,?,?,?
							,'','',?,1,
							?,SYSDATE)
		]]>
	</query>
	
	
	
	<query id="CoreOrderModel.doUpdate" desc="修改">
		<![CDATA[
			 UPDATE SLM_ORDER_MODEL_HEAD 
			 SET 
			 USE_UNIT=?,
			 USE_UNIT_DESC=?,
			 ORDER_MODEL_DESC=?,	 
			 GENERAL_FL=?,
			 CUSTOMER_MODEL_FL=?,
			 UPDATE_NAME=?,
			 UPDATE_TIME=SYSDATE
			 WHERE 
			 ORDER_MODEL_NO=?
		]]>
	</query>
	
	<query id="CoreOrderModel.doUpdate_Item" desc="修改">
		<![CDATA[
			 update SLM_ORDER_MODEL_ITEM
			 SET 
			 MODEL_SEQ=?,
			 MODEL_ITM_VAL=?,
			 UPDATE_NAME=?,
			 UPDATE_TIME=SYSDATE
			 where 
			 ORDER_MODEL_NO=? 
			 and 
			 MODEL_SEQ_NO=?
		]]>
	</query>
	
	<query id="CoreOrderModel.DELETE" desc="作废">
		<![CDATA[
			 UPDATE SLM_ORDER_MODEL_HEAD T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.ORDER_MODEL_NO = ?
		]]>
	</query>
	
	<query id="CoreOrderModel.RESUME" desc="恢复">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_HEAD T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.ORDER_MODEL_NO = ?
		]]>
	</query>
	
	
	<query id="CoreOrderModel.DELETE_ITEM" desc="作废">
		<![CDATA[
			 UPDATE SLM_ORDER_MODEL_ITEM T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.ORDER_MODEL_NO = ?
		]]>
	</query>
	
	<query id="CoreOrderModel.RESUME_ITEM" desc="恢复">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_ITEM T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.ORDER_MODEL_NO = ?
		]]>
	</query>
	
	<query id="CoreOrderModel.DELETE_ITEMNo" desc="作废">
		<![CDATA[
			 UPDATE SLM_ORDER_MODEL_ITEM T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.ORDER_MODEL_NO = ? AND T.MODEL_SEQ_NO = ?
		]]>
	</query>
	
	<query id="CoreOrderModel.RESUME_ITEMNo" desc="恢复">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_ITEM T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.ORDER_MODEL_NO = ? AND T.MODEL_SEQ_NO= ?
		]]>
	</query>
	
	<query id="CoreOrderModel.UpdateLaseX" desc="上移功能sql语句一">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_ITEM T
               SET T.MODEL_INDEX=?
             WHERE T.MODEL_INDEX=?-1 AND T.ORDER_MODEL_NO = ? 
		]]>
	</query>
	
	<query id="CoreOrderModel.UpdateLaseY" desc="上移功能sql语句二">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_ITEM T
               SET T.MODEL_INDEX=?-1
             WHERE T.ORDER_MODEL_NO = ? AND T.MODEL_SEQ_NO= ?
		]]>
	</query>
	
	<query id="CoreOrderModel.UpdateNextX" desc="下移功能sql语句二">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_ITEM T
               SET T.MODEL_INDEX=?
             WHERE T.MODEL_INDEX=?+1 AND T.ORDER_MODEL_NO = ? 
		]]>
	</query>
	
	<query id="CoreOrderModel.UpdateNextY" desc="下移功能sql语句二">
		<![CDATA[
			UPDATE SLM_ORDER_MODEL_ITEM T
               SET T.MODEL_INDEX=?+1
             WHERE T.ORDER_MODEL_NO = ? AND T.MODEL_SEQ_NO= ?
		]]>
	</query>
	
</queryMap>