<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="ComBaseWell.QUERY" desc="权限功能">
		<![CDATA[
		SELECT 
		    'FALSE' CHK,
			WELL_CODE,
            WELL_NAME,
            WEIGHT,
            CREATE_NAME,
            TO_CHAR(CREATE_TIME,'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
            UPDATE_NAME,
            TO_CHAR(UPDATE_TIME,'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
            DELETE_NAME,
            TO_CHAR(DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
            DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAGNAME,
            MEMO,
            PROCESS_CDOE
        FROM COM_BASE_WELL
        WHERE VALIDFLAG in ('1' , ?)
        ORDER BY WELL_CODE 
		]]>
	</query>
<query id="ComBaseWell.ADD" desc="权限功能">
		<![CDATA[
			INSERT INTO COM_BASE_WELL
			(
			WELL_CODE,
            WELL_NAME,
            WEIGHT,
            CREATE_NAME,
            CREATE_TIME,
            VALIDFLAG,
            MEMO,
            PROCESS_CDOE,
            PROCESS_DESC
            )
			VALUES
			(?,?,?,?,SYSDATE,'1',?, ?, ?)	
		]]>
	</query>
	<query id="ComBaseWell.UPDATE" desc="权限功能">
		<![CDATA[
			UPDATE COM_BASE_WELL C
			SET C.WELL_NAME=?,C.WEIGHT=?,C.MEMO=?, C.UPDATE_NAME=?,C.UPDATE_TIME=SYSDATE,
			PROCESS_CDOE = ?, PROCESS_DESC = ?
			WHERE C.WELL_CODE=?
		]]>
	</query>
<query id="ComBaseWell.DELETE" desc="权限功能">
		<![CDATA[
			UPDATE COM_BASE_WELL C
			SET C.VALIDFLAG='0',C.DELETE_NAME=?,C.DELETE_TIME=SYSDATE
			WHERE C.WELL_CODE=?
		]]>
	</query>
<query id="ComBaseWell.RESUME" desc="权限功能">
		<![CDATA[
			UPDATE COM_BASE_WELL C
			SET C.VALIDFLAG='1',C.DELETE_NAME='',C.DELETE_TIME=NULL
			WHERE C.WELL_CODE=?
		]]>
	</query>
<query id="ComBaseWell.CHECK" desc="权限功能">
		<![CDATA[
			SELECT WELL_CODE,
            WELL_NAME,
            WEIGHT,
            CREATE_NAME,
            CREATE_TIME,
            UPDATE_NAME,
            UPDATE_TIME,
            DELETE_NAME,
            DELETE_TIME,
            DECODE(VALIDFLAG,'1','有效','无效') VALIDFLAGNAME,
            MEMO FROM COM_BASE_WELL
			WHERE WELL_NAME=?
		]]>
	</query>
	
	<query id="ComBaseWell.CHECKUpdate" desc="权限功能">
		<![CDATA[
			SELECT  1
            FROM COM_BASE_WELL
			WHERE WELL_NAME=? AND WELL_CODE !=?
		]]>
	</query>
	
	<query id="ComBaseWell.CHECKYear" desc="权限功能">
		<![CDATA[
			SELECT  1
            FROM COM_BASE_WELL_MONTH
			WHERE WELL_CODE=? AND YEAR =TO_NUMBER(?)
		]]>
	</query>
	

	<query id="ComBaseWell.QUERYMonth" desc="权限功能">
		<![CDATA[
	   SELECT WELL_CODE,
       WELL_NAME,
       YEAR,
       YEAR AS YEAR_OLD,
       MONTH_1,
       MONTH_2,
       MONTH_3,
       MONTH_4,
       MONTH_5,
       MONTH_6,
       MONTH_7,
       MONTH_8,
       MONTH_9,
       MONTH_10,
       MONTH_11,
       MONTH_12,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       UPDATE_NAME,
       TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       DECODE(VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
       MEMO
   FROM COM_BASE_WELL_MONTH
   WHERE  WELL_CODE=?
			 
		]]>
	</query>
	
	<query id="ComBaseWell.ADDMonth" desc="权限功能">
		<![CDATA[
	  INSERT INTO COM_BASE_WELL_MONTH
  (WELL_CODE,
   WELL_NAME,
   YEAR,
   MONTH_1,
   MONTH_2,
   MONTH_3,
   MONTH_4,
   MONTH_5,
   MONTH_6,
   MONTH_7,
   MONTH_8,
   MONTH_9,
   MONTH_10,
   MONTH_11,
   MONTH_12,
   CREATE_NAME,
   CREATE_TIME,
   VALIDFLAG,
   MEMO)
   VALUES
  (?,  ?,  ?, ?,  ?, ?,?, ?,?, ?,?,?, ?,  ?, ?, ?,  SYSDATE,'1',  ?)
	  	 
		]]>
	</query>

    <query id="ComBaseWell.UpDateMonth" desc="权限功能">
		<![CDATA[
        UPDATE COM_BASE_WELL_MONTH
        SET 
        
        WELL_NAME = ?,
        YEAR = ?,
        MONTH_1 = ?,
        MONTH_2 = ?,
        MONTH_3 = ?,
        MONTH_4 = ?,
        MONTH_5 = ?,
        MONTH_6 = ?,
        MONTH_7 = ?,
        MONTH_8 = ?,
        MONTH_9 = ?,
        MONTH_10 = ?,
        MONTH_11 = ?,
        MONTH_12 = ?,
        UPDATE_NAME = ?,
        UPDATE_TIME = SYSDATE,
        MEMO = ?
        WHERE WELL_CODE = ? AND  YEAR = ?
			 
		]]>
	</query>
	
		<query id="CoreBaseWell.checkWellDelete" desc="权限功能">
		<![CDATA[
         
        SELECT COUNT(1) AS COUM FROM COM_BASE_WELL_MONTH
        WHERE WELL_CODE=? AND VALIDFLAG='1'

		]]>
	</query>
	
		<query id="CoreBaseWell.queryWellMax" desc="权限功能">
		<![CDATA[
         
         SELECT WELL_CODE
        FROM (SELECT MAX(WELL_CODE) AS WELL_CODE FROM COM_BASE_WELL)
        WHERE WELL_CODE IS NOT NULL

		]]>
	</query>
	
	<query id="CoreBaseWell.checkFromResume" desc="标准名称 检验标准代码是否已经恢复">
		<![CDATA[
			SELECT 1
              FROM COM_BASE_WELL S
             WHERE S.WELL_CODE = ?
               AND S.VALIDFLAG = 0
		]]>
	</query>
	
	
	<query id="CoreBaseWell.deleteWell" desc="标准基础 作废">
		<![CDATA[
			UPDATE COM_BASE_WELL
               SET DELETE_NAME = ?, DELETE_TIME = SYSDATE, VALIDFLAG = '0'
             WHERE WELL_CODE = ?
		]]>
	</query>
	
	<query id="CoreBaseWell.resumeWell" desc="标准基础 恢复">
		<![CDATA[
			UPDATE COM_BASE_WELL
               SET DELETE_NAME = ?, DELETE_TIME = NULL, VALIDFLAG = '1'
             WHERE WELL_CODE = ?
		]]>
    </query>
	
	<query id="CoreBaseWell.deleteMonthWell" desc="产品规范 作废">
		<![CDATA[
			UPDATE COM_BASE_WELL_MONTH
               SET DELETE_NAME = ?, DELETE_TIME = SYSDATE, VALIDFLAG = '0'
             WHERE WELL_CODE=? AND YEAR=?
		]]>
	</query>
	
	<query id="CoreProductManage.resumeMonthWell" desc="产品规范 恢复">
		<![CDATA[
			UPDATE COM_BASE_WELL_MONTH
               SET DELETE_NAME = ?, DELETE_TIME = NULL, VALIDFLAG = '1'
             WHERE WELL_CODE=? AND YEAR=?		
		]]>
	</query>
	
</queryMap>