<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc=" 芯棒基础">

	<query id="FrmComBaseMandrel.initModel" desc="初始化扣型">
             <![CDATA[
               SELECT T.MODEL_CODE, T.MODEL_DESC
  FROM COM_BASE_MODEL T
 WHERE T.VALIDFLAG = '1'
 ORDER BY T.MODEL_DESC
                 ]]>
	</query>

	<query id="FrmComBaseMandrel.query" desc="查询">
             <![CDATA[
         SELECT 
       T.MANDREL_ID,
       T.DIAMETER_MANDREL,
       T.LEN_MANDREL,
       T.SCREW_MODEL,
       T.TAPER_MANDREL,
       T.MASSY_OR_HOLLOW,
       T.MEMO,
       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,
       (SELECT COUNT(*)
           FROM COM_BASE_MANDREL_SPEC T1 WHERE T1.MANDREL_ID = T.MANDREL_ID) APP_NUMBER
 FROM COM_BASE_MANDREL T
 WHERE 1=1
                 ]]>
	</query>

	<query id="FrmComBaseMandrel.add" desc="新增">
             <![CDATA[
         INSERT INTO COM_BASE_MANDREL(
        MANDREL_ID,
        DIAMETER_MANDREL,
        LEN_MANDREL,
        SCREW_MODEL,
        TAPER_MANDREL,
        MASSY_OR_HOLLOW,
        MEMO,
        CREATE_NAME,
        CREATE_TIME,
        UPDATE_NAME,
        UPDATE_TIME)
 VALUES( 
        (SELECT 'XB' ||
  LPAD(SUBSTR(NVL(MAX(T.MANDREL_ID),'0000'),-4,4) + 1, 4, '0') AS MANDREL_ID
  FROM COM_BASE_MANDREL T),
        '#DIAMETER_MANDREL#',
        '#LEN_MANDREL#',
        '#SCREW_MODEL#',
        '#TAPER_MANDREL#',
        '#MASSY_OR_HOLLOW#',
        '#MEMO#',
        '#CREATE_NAME#',
        SYSDATE,
        '#UPDATE_NAME#',
        NULL)
                 ]]>
	</query>

	<query id="FrmComBaseMandrel.update" desc="修改">
             <![CDATA[
          UPDATE COM_BASE_MANDREL T
   SET 
        T.DIAMETER_MANDREL = '#DIAMETER_MANDREL#',
        T.LEN_MANDREL = '#LEN_MANDREL#',
        T.SCREW_MODEL = '#SCREW_MODEL#',
        T.TAPER_MANDREL = '#TAPER_MANDREL#',
        T.MASSY_OR_HOLLOW = '#MASSY_OR_HOLLOW#',
        T.MEMO = '#MEMO#',
        T.CREATE_NAME = '#CREATE_NAME#',
        T.CREATE_TIME = SYSDATE,
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE
 WHERE
T.MANDREL_ID = '#MANDREL_ID#'
                 ]]>
	</query>

	<query id="FrmComBaseMandrel.delete" desc="删除">
             <![CDATA[
          DELETE FROM  COM_BASE_MANDREL T WHERE T.MANDREL_ID = ?
                 ]]>
	</query>

	<query id="FrmComBaseMandrel.checkMandrel" desc="验证芯棒是否重复">
             <![CDATA[
         select COUNT(1) COUNT  from COM_BASE_MANDREL t WHERE T.DIAMETER_MANDREL=TO_NUMBER(?)
                 ]]>
	</query>
	<query id="FrmComBaseMandrel.checkMandrel1" desc=" 验证芯棒直径，长度，锥度，芯棒扣型，实心空心是否重复">
             <![CDATA[
        SELECT COUNT(1) COUNT
  FROM COM_BASE_MANDREL T
 WHERE T.DIAMETER_MANDREL = TO_NUMBER(?)
   AND T.LEN_MANDREL = TO_NUMBER(?)
   AND T.SCREW_MODEL = ?
   AND T.TAPER_MANDREL = ?
   AND T.MASSY_OR_HOLLOW = ?
                 ]]>
	</query>
</queryMap>