<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="CoreProductName.QUERY" desc="权限功能">
		<![CDATA[
			SELECT  'False' CHK,
			        T.PRODUCCODE,
				    T.PRODUCNAME,
				    T.PRODUC_JX,
				    T.PRODUC_ENG,
				    T.PRODUC_STYLE,
					T.PRODUC_DESC,
					DECODE(T.HAVEJG, '1', '是', '否') HAVEJG,
					T.HAVEJG HAVEJGCODE,
					T.PRODUC_TYPE,
					DECODE(T.PRODUC_TYPE, 'A', '钢管（管坯）', 'B', '钢管+接箍', 'C', '短节+附件', 
					     'D', '接箍', 'E', '双公短节', '未识别') HAVEJG2_DESC,
					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,
					T.DELETE_NAME,
					TO_CHAR(T.DELETE_TIME,'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
					T.VALIDFLAG,
					decode(T.VALIDFLAG,'1','有效','无效') VALIDFLAGNAME,
					T.MEMO,
					A.BASENAME PRODUC_HEAD,
					T.PRODUC_HEAD PRODUC_HEAD_CODE
				FROM COM_BASE_PRODUCT T
				LEFT JOIN COM_BASE_INFO A ON A.BASECODE = T.PRODUC_HEAD
				   WHERE t.VALIDFLAG in ('1' , ?)
				   AND lower(t.PRODUCNAME)||'&' LIKE '%' || lower(?) || '%'
				   ORDER BY t.PRODUCCODE
		]]>
	</query>
	<query id="CoreProductName.ADD" desc="新增">
		<![CDATA[
			 INSERT INTO COM_BASE_PRODUCT
							(PRODUCCODE,
					        PRODUCNAME,
					        PRODUC_STYLE,
							PRODUC_DESC,
					        HAVEJG,
					        CREATE_NAME,
					        CREATE_TIME,
					        VALIDFLAG,
					        MEMO,
					        PRODUC_JX,
					        PRODUC_ENG,
					        PRODUC_TYPE,
					        PRODUC_HEAD
					       )
							VALUES(?,?,?,?,?,
							?,SYSDATE,
							'1',?,?,?,?,?)
							
			  
		]]>
	</query>

	<query id="CoreProductName.doAddLimsMat" desc="新增">
		<![CDATA[
			  INSERT INTO METER_BASE_MATTER_INFO(
					MATTER_NO,
					INDEX_CODE,
					MATTER_NAME,
					MATTER_NATURE_NO,
					MATTER_NATURE_NAME,
					METER_NATURE_NO,
					METER_NATURE_NAME,
					VALID_FLAG,
					CREATE_MAN_NO,
					CREATE_MAN_NAME,
					CREATE_TIME)
			 VALUES(
					(SELECT
					LPAD(
						NVL( MAX( MATTER_NO), 0 ) + 1, 5, '0' )
					FROM
						METER_BASE_MATTER_INFO),
					?,
					?,
					'001003008',
					'外销物料',
					'001004002',
					'外销',
					'1',
					'cx',
					?,
					SYSDATE)
		]]>
	</query>

	<query id="CoreProductName.doUpdateLimsMat" desc="更新">
		<![CDATA[
			UPDATE METER_BASE_MATTER_INFO T
			SET
			T.INDEX_CODE = ?,
			T.MATTER_NAME = ?,
			T.UPDATE_MAN_NO = 'cx',
			T.UPDATE_MAN_NAME = ?,
			T.UPDATE_TIME = SYSDATE
			WHERE
			T.INDEX_CODE = ?
			]]>
	</query>


	<query id="CoreProductName.doLimsMatlogicDelete" desc="更新">
		<![CDATA[
			UPDATE METER_BASE_MATTER_INFO T
			SET
			T.VALID_FLAG = ?,
			T.DELETE_MAN_NO = ?,
			T.DELETE_MAN_NAME = ?,
			T.DELETE_TIME = ?
			WHERE
			T.INDEX_CODE = ?
			]]>
	</query>

	<query id="CoreProductName.MODIFY" desc="修改">
		<![CDATA[
			 UPDATE COM_BASE_PRODUCT set
							PRODUCNAME=?, 
							PRODUC_STYLE=?, 
							PRODUC_DESC=?, 
							HAVEJG=?,
							UPDATE_NAME=?, 
							UPDATE_TIME=SYSDATE,
							MEMO=?, 
							PRODUC_JX=?,
							PRODUC_ENG=?,
							PRODUC_TYPE = ?,
							PRODUC_HEAD = ?
							WHERE PRODUCCODE=?
		]]>
	</query>
	<query id="CoreProductName.DELETE" desc="作废">
		<![CDATA[
			 UPDATE COM_BASE_PRODUCT T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.PRODUCCODE = ?
		]]>
	</query>

	<query id="CoreProductName.RESUME" desc="恢复">
		<![CDATA[
			UPDATE COM_BASE_PRODUCT T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.PRODUCCODE = ?
		]]>
	</query>

	<query id="CoreProductName.QueryMaxCode" desc="获取最大编码">
		<![CDATA[
			SELECT MAX(T.PRODUCCODE) PRODUCCODE FROM COM_BASE_PRODUCT T
		]]>
	</query>

	<query id="CoreProductName.IsExist" desc="是否包含相同的品名数据">
		<![CDATA[
			SELECT COUNT(1) FROM COM_BASE_PRODUCT T WHERE T.PRODUCNAME = ? AND
			DECODE(?, NULL, '^&*', T.PRODUCCODE) != DECODE(?, NULL, '#$%', ?) 
		]]>
	</query>

	<query id="CoreProductName.IsRefrenced" desc="品名是否被引用">
		<![CDATA[
			 SELECT 1 FROM COM_PSC T
             WHERE T.PRODUCCODE=?
             AND T.VALIDFLAG <> 0
		]]>
	</query>

	<query id="CoreProductName.GETMODEL" desc="查询扣型">
		<![CDATA[
		SELECT 'True' CHK, PRODUCCODE, PRODUCNAME, MODEL_CODE, MODEL_DESC
        FROM COM_BASE_PRODUCT_R_MODEL T
        WHERE T.VALIDFLAG = '1'
        AND T.PRODUCCODE = ?
        UNION
        SELECT 'False' CHK, '' PRODUCCODE, '' PRODUCNAME, MODEL_CODE, MODEL_DESC
        FROM COM_BASE_MODEL T1
        WHERE T1.VALIDFLAG = '1'
        AND NOT EXISTS (SELECT 1
        FROM COM_BASE_PRODUCT_R_MODEL T2
        WHERE T2.PRODUCCODE = ?
        AND T1.MODEL_CODE = T2.MODEL_CODE)
		ORDER BY MODEL_CODE	    
		]]>
	</query>

	<query id="CoreProductName.MODELDELETE" desc="删除品名关联的扣型">
		<![CDATA[
		 DELETE FROM COM_BASE_PRODUCT_R_MODEL T
		 WHERE T.PRODUCCODE = ?
		]]>
	</query>

	<query id="CoreProductName.MODELINSERT" desc="插入品名关联的扣型">
		<![CDATA[
		 INSERT INTO COM_BASE_PRODUCT_R_MODEL
      (
       MODEL_CODE,
       MODEL_DESC,
       CREATE_NAME,
       PRODUCCODE,
       PRODUCNAME,
       CREATE_TIME
      )
      VALUES
      (?, ?, ?, ?, ?,SYSDATE)

		]]>
	</query>

	<query id="CoreProductName.isUsed" desc="品名是否被使用">
		<![CDATA[
SELECT COUNT(1)
  FROM COM_PSC T
 WHERE T.PRODUCCODE = '#PRODUCCODE#'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
</queryMap>