<?xml version="1.0" encoding="UTF-8"?>
 
<queryMap desc="接箍码基础管理">
    <query id="JGCodeManage.InitJGSpec" desc="获取规格代码、描述">
		<![CDATA[ 
		      SELECT T.SPEC_NAME,T.SPEC_CODE 
		      FROM COM_BASE_SPEC T
		      WHERE T.VALIDFLAG='1' 
		      AND T.MSC_STYLE= 'C'
		      ORDER BY T.SPEC_NAME  
		]]>
	</query>
	
	 <query id="JGCodeManage.InitStdStyle" desc="获取标准类别代码、描述">
		<![CDATA[ 
		      SELECT T.STD_STYLE_DESC,T.STD_STYLE 
		      FROM COM_BASE_STD_STYLE T
		      WHERE T.VALIDFLAG='1' 
		      ORDER BY T.STD_STYLE_DESC  
		]]>
	</query>
	
	<query id="JGCodeManage.InitJGProduct" desc="获取品种代码、描述">
		<![CDATA[ 
		      SELECT T.BASENAME,T.BASECODE
		      FROM COM_BASE_INFO T
		      WHERE T.VALIDFLAG= '1' AND T.SORTCODE='4050'  
		      ORDER BY T.BASENAME  
		]]>
	</query>
	<query id="JGCodeManage.InitCPProduct" desc="获取品名代码、描述">
		<![CDATA[ 
		      SELECT T.PRODUCNAME,T.PRODUCCODE
		      FROM COM_BASE_PRODUCT T
		      WHERE T.VALIDFLAG= '1'  
		      ORDER BY T.PRODUCNAME  
		]]>
	</query>
	<query id="JGCodeManage.InitJGSteel" desc="获取钢级代码、名称">
		<![CDATA[ 
		      SELECT T.STEELNAME,T.STEELCODE
		      FROM COM_BASE_STEEL T
		      WHERE T.VALIDFLAG= '1'  
		      ORDER BY T.STEELNAME  
		]]>
	</query>
	<query id="JGCodeManage.InitJGModel" desc="获取扣型代码、描述">
		<![CDATA[ 
		      SELECT T.MODEL_DESC,T.MODEL_CODE
		      FROM COM_BASE_MODEL T
		      WHERE T.VALIDFLAG= '1' 
		      ORDER BY T.MODEL_DESC   
		]]>
	</query>
	<query id="JGCodeManage.InitJGStd" desc="获取标准代码、描述">
		<![CDATA[ 
SELECT *
  FROM (SELECT STD_NAME,
               STD_CODE,
               DECODE(STDSTYLE, 'N', '内控', '交付') STDSTYLE
          FROM COM_BASE_STD
         WHERE (STDSTYLE IN ('G', 'X', 'N'))
           AND VALIDFLAG = '1')
 ORDER BY STDSTYLE, STD_NAME
		]]>
	</query>
	<query id="JGCodeManage.InitJGType" desc="获取类别代码、描述">
		<![CDATA[ 
		      SELECT T.BASENAME,T.BASECODE
		      FROM COM_BASE_INFO T
		      WHERE T.VALIDFLAG= '1'   AND T.SORTCODE='4009'  
		      ORDER BY T.BASENAME 
		]]>
	</query>
	<query id="JGCodeManage.InitJGALPHA" desc="获取ALPHA标准代码、描述">
		<![CDATA[ 
		      SELECT T.STD_NAME,T.STD_CODE 
		      FROM COM_BASE_STD T
		      WHERE T.VALIDFLAG='1' 
		      AND T.STDSTYLE= 'K'
		      ORDER BY T.STD_NAME 
		]]>
	</query>
	<query id="JGCodeManage.getProductName" desc="获取品名">
		<![CDATA[ 
SELECT T.PRODUCCODE, T.PRODUCNAME FROM COM_BASE_PRODUCT T ORDER BY T.PRODUCNAME
		]]>
	</query>
	<query id="JGCodeManage.GetJGCode" desc="获取最大的接箍码(不知和max谁效率更高)">
		<![CDATA[ 
		    SELECT T.CODE_JG
            FROM 
            (SELECT CODE_JG FROM COM_MSC_JG  ORDER BY CODE_JG DESC ) T
             WHERE ROWNUM='1'
		]]> 
	</query>
	<query id="JGCodeManage.QUERY" desc="查询">
		<![CDATA[
SELECT 'False' CHK,
       T.CODE_JG,
       T.SPEC_JG,
       (SELECT A.SPEC_NAME
          FROM COM_BASE_SPEC A
         WHERE A.SPEC_CODE = T.SPEC_JG) SPEC_JG_DESC,
       T.PRODUCCODE_JG,
       T.PRODUCCODE_JG_DESC,
       T.STEELCODE_JG,
       T.STEELCODE_JG_DESC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = T.STYLE_JG) STYLE_JG,
       T.MIN_D,
       T.MIN_H,
       T.STD_CODE,
       T.STD_NAME,
       (SELECT REPLACE(WM_CONCAT(STEELCODE_JG), ',', ';')
          FROM COM_MSC_JG_R_STEEL
         WHERE STEELCODE = T.STEELCODE_JG) REP_STEELCODE,
       (SELECT REPLACE(WM_CONCAT(STEELCODE_JG_DESC), ',', ';')
          FROM COM_MSC_JG_R_STEEL
         WHERE STEELCODE = T.STEELCODE_JG) REP_STEELNAME,
       T.DIAMETER_JG,
       T.HEIGHT_JG,
       T.LENGTH_JG,
       T.WEIGHT_JG,
       T.DIAMETER,
       T.ALPHA,
       T.DIAMETER_PL,
       T.HEIGHT_PL,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MIN_H_CP,
       T.MAX_H_CP,
       T.MIN_D_CP,
       T.MAX_D_CP,
       CHECK_J_VAL,
       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,
       DECODE(T.VALIDFLAG, '1', '有效', '无效') VALIDFLAG,
       T.MEMO,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.TAPER,
       T.MIN_D_JG,
       T.MAX_D_JG,
       (SELECT REPLACE(TO_CHAR(WM_CONCAT(A.SPEC_CODE)), ',', ';')
          FROM COM_MSC_JG_R_SPEC A
         WHERE A.CODE_JG = T.CODE_JG) SPEC_CODE,
       (SELECT REPLACE(WM_CONCAT(A.SPEC_NAME), ',', ';')
          FROM COM_MSC_JG_R_SPEC A
         WHERE A.CODE_JG = T.CODE_JG) SPEC_NAME,
       T.M_STD_NO,
       T.W_STD_NO,
       T.M_PRINT_NO,
       T.W_PRINT_NO,
       T.FILE_PATH,
       T.FILE_PATH FILE_NAME,
       T.DIAMETER_SPEC,
       T.DIAMETER_SPEC2,
       T.LENGTH_SPEC,
       T.LENGTH_SPEC2,
       T.DIAMETER_SPEC || '~' || T.DIAMETER_SPEC2 DIAMETER_SPEC_DESC,
       T.LENGTH_SPEC || '~' || T.LENGTH_SPEC2 LENGTH_SPEC_DESC,
       A.EXE_STATUS JG_PLN_STATUS
  FROM COM_MSC_JG T
  LEFT JOIN (SELECT MIN(T2.EXE_STATUS) EXE_STATUS, T2.CODE_JG
               FROM PLN_GX_JG_PROP_S T2
               WHERE T2.CODE_JG IS NOT NULL
              group by t2.code_jg) A
    ON A.CODE_JG = T.CODE_JG
 WHERE UPPER(SPEC_JG_DESC) || '&' LIKE '%' || UPPER(?) || '%'
   AND UPPER(PRODUCCODE_JG_DESC) || '&' LIKE '%' || UPPER(?) || '%'
   AND DECODE(?, NULL, '1', STEELCODE_JG_DESC) = DECODE(?, NULL, '1', ?)
   AND UPPER(MODEL_DESC) || '&' LIKE '%' || UPPER(?) || '%'
   AND (? IS NULL OR T.DIAMETER_JG = TO_NUMBER(?))
   AND STYLE_JG || '&' LIKE ? || '&' --oracle空值和null处理方式不一样
   AND DECODE(?, NULL, '1', T.STD_NAME) = DECODE(?, NULL, '1', ?)
   AND DECODE(?, NULL, 1, T.MIN_D_JG) <= DECODE(?, NULL, 1, TO_NUMBER(?))
   AND DECODE(?, NULL, 1, MAX_D_JG) >= DECODE(?, NULL, 1, TO_NUMBER(?))
   AND DECODE(?, NULL, 1, T.MIN_H_CP) <= DECODE(?, NULL, 1, TO_NUMBER(?))
   AND DECODE(?, NULL, 1, T.MAX_H_CP) >= DECODE(?, NULL, 1, TO_NUMBER(?))
   AND VALIDFLAG IN ('1', ?)
		]]>
	</query>
	
	<query id="JGCodeManage.QUERY1" desc="界面JGCodeManage.cs查询">
		<![CDATA[
			SELECT 
           'False'  CHK
           ,CODE_JG
           ,SPEC_JG
           ,SPEC_JG_DESC
           ,PRODUCCODE_JG
           ,PRODUCCODE_JG_DESC
           ,STEELCODE_JG
           ,STEELCODE_JG_DESC
           ,MODEL_CODE
           ,MODEL_DESC
           ,STYLE_JG
           ,MIN_D
           ,MIN_H
           ,DIAMETER_JG
           ,HEIGHT_JG
           ,LENGTH_JG
           ,WEIGHT_JG
           ,DIAMETER
           ,ALPHA
           ,DIAMETER_PL
           ,HEIGHT_PL
           ,LENGTH_MIN
           ,LENGTH_MAX
           ,PRODUCCODE
           ,PRODUCNAME
           ,MIN_H_CP
           ,MAX_H_CP
           ,MIN_D_CP
           ,MAX_D_CP
           ,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','有效','无效') VALIDFLAG 
           ,MEMO
           FROM COM_MSC_JG  T 
           WHERE T.VALIDFLAG='1'
		]]>
	</query>
	
	<query id="JGCodeManage.QueryWithMsc" desc="冶金规范界面根据冶金规范码查询接箍信息">
		<![CDATA[
SELECT AA.*,
       H.BASENAME STYLE_JG_DESC,
       (SELECT LISTAGG(A.SPEC_NAME, ';') WITHIN GROUP(ORDER BY A.SPEC_NAME)
          FROM COM_MSC_JG_R_SPEC A
         WHERE A.CODE_JG = AA.CODE_JG
           AND A.VALIDFLAG = '1') SPEC_NAME,
       '选择' BL_BTN
  FROM (SELECT (SELECT D.SPEC_NAME
                  FROM COM_BASE_SPEC D
                 WHERE D.SPEC_CODE = A.SPEC_JG) SPEC_JG_DESC,
               A.PRODUCCODE_JG_DESC,
               A.STEELCODE_JG_DESC,
               A.MODEL_DESC,
               A.PRODUCNAME,
               T.DEMAND_DETECTION,
               T.DEMAND_BONDERIZING,
               T.DEMAND_COPPER,
               T.DEMAND_BLAST,
               T.MSC,
               T.MEMO,
               T.KEY_JG,
               T.CUST_ALPHA_NO,
               T.ORDER_SPECIAL_DESC,
               T.ALPHA_CODE,
               AP.ALPHA_NAME,
               A.STD_NAME,
               A.STD_STYLE_DESC,
               A.CHECK_J_VAL,
               (SELECT REPLACE(WM_CONCAT(N.STEELCODE_JG_DESC), ',', ';')
                  FROM COM_MSC_JG_R_STEEL N
                 WHERE N.STEELCODE = A.STEELCODE_JG) REP_STEELNAME,
               (SELECT REPLACE(WM_CONCAT(N.STEELCODE_JG), ',', ';')
                  FROM COM_MSC_JG_R_STEEL N
                 WHERE N.STEELCODE = A.STEELCODE_JG) REP_STEELCODE,
               A.TAPER,
               A.MIN_D_JG,
               A.MAX_D_JG,
               A.CODE_JG,
               A.SPEC_JG,
               A.PRODUCCODE_JG,
               A.STEELCODE_JG,
               (SELECT BASENAME
                  FROM COM_BASE_INFO
                 WHERE BASECODE = A.STYLE_JG) STYLE_JG,
               A.PRODUCCODE,
               A.MODEL_CODE,
               A.DIAMETER_JG,
               A.LENGTH_JG,
               A.HEIGHT_JG,
               A.WEIGHT_JG,
               A.MIN_D,
               A.MIN_H,
               A.DIAMETER_PL,
               A.HEIGHT_PL,
               A.LENGTH_MIN,
               A.LENGTH_MAX,
               A.MIN_H_CP,
               A.MAX_H_CP,
               A.MIN_D_CP,
               A.MAX_D_CP,
               A.DIAMETER,
               A.ALPHA,
               A.VALIDFLAG,
               DECODE(A.VALIDFLAG, '1', '有效', '0', '无效', '未识别') VALIDFLAG_NAME,
               A.CREATE_NAME,
               A.CREATE_TIME,
               A.UPDATE_NAME,
               A.UPDATE_TIME,
               A.DELETE_NAME,
               A.DELETE_TIME,
               T.M_STD_NO,
               T.W_STD_NO,
               T.M_PRINT_NO,
               T.W_PRINT_NO,
               T.FILE_PATH,
               T.FILE_PATH FILE_NAME,
               T.TORQUE_UNIT,
               T.TORQUE_MAX,
               T.TORQUE_MIN,
               T.TORQUE_BEST,
               T.POINT_MAX,
               T.POINT_MIN,
               T.JG_MEMO
          FROM COM_MSC_R_JG T
          LEFT JOIN COM_BASE_STD_ALPHA AP
            ON AP.ALPHA_CODE = T.ALPHA_CODE, COM_MSC_JG A
         WHERE T.MSC = '#MSC#'
           AND T.STOCK_STYLE = 'A'
           AND T.VALIDFLAG = '1'
           AND ((EXISTS
                (SELECT 1
                    FROM COM_MSC_JG_R_STEEL L
                   WHERE L.STEELCODE = A.STEELCODE_JG) AND EXISTS
                (SELECT 1
                    FROM COM_MSC_JG_R_STEEL L
                   WHERE L.STEELCODE = A.STEELCODE_JG
                     AND L.STEELCODE_JG = '#STEELCODE#')) OR
               (NOT EXISTS (SELECT 1
                               FROM COM_MSC_JG_R_STEEL L
                              WHERE L.STEELCODE = A.STEELCODE_JG) AND
                A.STEELCODE_JG = '#STEELCODE#'))
           AND T.CODE_JG = A.CODE_JG) AA
  LEFT JOIN COM_BASE_INFO H
    ON H.BASECODE = AA.STYLE_JG
		]]>
	</query>

	<query id="JGCodeManage.QueryTorqueWithMsc" desc="查询拧接信息">
		<![CDATA[
SELECT B.*
  FROM COM_MSC_R_JG T
  LEFT JOIN COM_BASE_STD_ALPHA AP
    ON AP.ALPHA_CODE = T.ALPHA_CODE, COM_MSC_JG A, COM_MSC_R_JG_TORQUE B
 WHERE T.MSC = '#MSC#'
   AND T.STOCK_STYLE = 'A'
   AND T.VALIDFLAG = '1'
   AND ((EXISTS (SELECT 1
                   FROM COM_MSC_JG_R_STEEL L
                  WHERE L.STEELCODE = A.STEELCODE_JG) AND EXISTS
        (SELECT 1
            FROM COM_MSC_JG_R_STEEL L
           WHERE L.STEELCODE = A.STEELCODE_JG
             AND L.STEELCODE_JG = '#STEELCODE#')) OR
       (NOT EXISTS (SELECT 1
                       FROM COM_MSC_JG_R_STEEL L
                      WHERE L.STEELCODE = A.STEELCODE_JG) AND
        A.STEELCODE_JG = '#STEELCODE#'))
   AND T.CODE_JG = A.CODE_JG
   AND B.KEY_JG = T.KEY_JG
		]]>
	</query>
	
	<query id="JGCodeManage.ADD" desc="添加">
		<![CDATA[ 
		   INSERT INTO COM_MSC_JG 
           (
            SPEC_JG,SPEC_JG_DESC,PRODUCCODE_JG,PRODUCCODE_JG_DESC,
            STEELCODE_JG,STEELCODE_JG_DESC,MODEL_CODE,MODEL_DESC,
            STYLE_JG,MIN_D,MIN_H,DIAMETER_JG,HEIGHT_JG,LENGTH_JG,
            WEIGHT_JG,DIAMETER,ALPHA,DIAMETER_PL,HEIGHT_PL,LENGTH_MIN,
            LENGTH_MAX,CREATE_NAME,CREATE_TIME,MEMO,PRODUCCODE
           ,PRODUCNAME
           ,MIN_D_CP
           ,MAX_D_CP
           ,MIN_H_CP
           ,MAX_H_CP
           ,STD_CODE
           ,STD_NAME
           ,CHECK_J_VAL,
           STD_STYLE,
           STD_STYLE_DESC,
           TAPER, 
           MIN_D_JG,
           MAX_D_JG,
           M_STD_NO,
           W_STD_NO,
           M_PRINT_NO,
           W_PRINT_NO,
           FILE_PATH,
           DIAMETER_SPEC,
           DIAMETER_SPEC2,
           LENGTH_SPEC,
           LENGTH_SPEC2,
           CODE_JG)
            VALUES(?,?,?,?,?,?,?,?,?,?
                   ,?,?,?,?,?,?,?,?,?,?
                   ,?,?,SYSDATE,?,?,?,?,?,?,?,?,?,?,?,
                   ?,?,?,?,?,?,?,?,?,?,?,?,?,?)
		]]>
	</query>
	
	<query id="JGCodeManage.insertJgBacklog" desc="新增接箍制程">
		<![CDATA[ 
DECLARE
  P_KEY_JG        COM_MSC_R_JG.KEY_JG%TYPE := '#KEY_JG#';
  P_NAME          COM_MSC_R_JG.CREATE_NAME%TYPE := '#CREATE_NAME#';
  P_BACKLOG_COUNT NUMBER(5);

BEGIN
  SELECT COUNT(1)
    INTO P_BACKLOG_COUNT
    FROM Com_Msc_Backlog T
   WHERE T.MSC = P_KEY_JG;
  IF P_BACKLOG_COUNT = 0 THEN
    INSERT INTO Com_Msc_Backlog L
      (L.MSC,
       L.MSC_PLINE,
       L.WHOLE_BACKLOG,
       L.WHOLE_BACKLOG_DESC,
       L.CREATE_NAME,
       L.CREATE_TIME,
       L.VALIDFLAG_NK)
      (SELECT P_KEY_JG,
              '000001',
              T.PROCESS_CODE,
              T.PROCESS_DESC || '【' || A.PROCESS_DESC_C || '】',
              P_NAME,
              SYSDATE,
              '1'
         FROM COM_BASE_PROCESS           T,
              COM_BASE_PROCESS_C         A,
              COM_BASE_PROCESS_R_STATION B
        WHERE T.PROCESS_CODE = 'H'
          AND T.PROCESS_CODE = A.PROCESS_CDOE
          AND B.PROCESS_CDOE_C = A.PROCESS_CDOE_C
          AND ROWNUM <= 1);
  
    INSERT INTO COM_MSC_PROCESS
      (MSC,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       MINUTE_PRODUCT,
       MINUTE_WAITE,
       CREATE_NAME,
       CREATE_TIME,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       MINUTE_PRODUCT_OUT,
       MINUTE_WAITE_OUT,
       BATCH_WAITE,
       BATCH_WAITE_OUT)
      SELECT P_KEY_JG,
             '000001',
             ((SELECT NVL(MAX(BACKLOG_SEQ), 0) + 1
                 FROM COM_MSC_PROCESS C
                WHERE C.MSC = P_KEY_JG
                  AND C.MSC_PLINE = '000001')),
             T.PROCESS_CODE,
             T.PROCESS_DESC,
             T.MINUTE_PRODUCT,
             T.MINUTE_WAITE,
             P_NAME,
             SYSDATE,
             T.ICOUNT,
             A.PROCESS_CDOE_C,
             A.PROCESS_DESC_C,
             T.MINUTE_PRODUCT_OUT,
             T.MINUTE_WAITE_OUT,
             T.BATCH_WAITE,
             T.BATCH_WAITE_OUT
        FROM COM_BASE_PROCESS T, COM_BASE_PROCESS_C A
       WHERE T.PROCESS_CODE = 'H'
         AND T.PROCESS_CODE = A.PROCESS_CDOE
         AND ROWNUM <= 1;
  
    INSERT INTO COM_MSC_STATION
      (MSC,
       MSC_PLINE,
       BACKLOG_SEQ,
       PROCESS_CODE,
       PROCESS_DESC,
       STATION_CODE,
       STATION_DESC,
       STATION_TYPE,
       STATION_ID,
       COST,
       CHOOSE,
       RETURN_RESULT,
       SEND_CHECKPLAN,
       GROUP_SEQ,
       CREATE_NAME,
       CREATE_TIME,
       PROCESS_SEQ,
       PROCESS_CODE_C,
       PROCESS_DESC_C)
      SELECT P_KEY_JG,
             '000001',
             (SELECT NVL(MAX(BACKLOG_SEQ), 0) + 1
                FROM COM_MSC_STATION C
               WHERE C.MSC = P_KEY_JG
                 AND C.MSC_PLINE = '000001'
                 AND C.PROCESS_CODE = ''),
             T.PROCESS_CODE,
             T.PROCESS_DESC,
             B.STATION_CODE,
             B.STATION_DESC,
             B.STATION_TYPE,
             B.STATION_ID,
             B.COST,
             B.CHOOSE,
             B.RETURN_RESULT,
             B.SEND_CHECKPLAN,
             '1',
             P_NAME,
             SYSDATE,
             '1',
             A.PROCESS_CDOE_C,
             A.PROCESS_DESC_C
        FROM COM_BASE_PROCESS           T,
             COM_BASE_PROCESS_C         A,
             COM_BASE_PROCESS_R_STATION B
       WHERE T.PROCESS_CODE = 'H'
         AND T.PROCESS_CODE = A.PROCESS_CDOE
         AND B.PROCESS_CDOE_C = A.PROCESS_CDOE_C
         AND ROWNUM <= 1;
  END IF;
END;
		]]>
	</query>
	
	<query id="JGCodeManage.UPDATE" desc="更新">
		<![CDATA[ 
		    UPDATE  COM_MSC_JG 
            SET
            SPEC_JG=?,SPEC_JG_DESC=?,PRODUCCODE_JG=?,PRODUCCODE_JG_DESC=?,
            STEELCODE_JG=?,STEELCODE_JG_DESC=?,MODEL_CODE=?,MODEL_DESC=?,
            STYLE_JG=?,MIN_D=?,MIN_H=?,DIAMETER_JG=?,HEIGHT_JG=?,LENGTH_JG=?,
            WEIGHT_JG=?,DIAMETER=?,ALPHA=?,DIAMETER_PL=?,HEIGHT_PL=?,LENGTH_MIN=?,
            LENGTH_MAX=?,UPDATE_NAME=?,UPDATE_TIME=SYSDATE,MEMO=?  
            ,PRODUCCODE=?
            ,PRODUCNAME=?
            ,MIN_D_CP=?
            ,MAX_D_CP=?
            ,MIN_H_CP=?
            ,MAX_H_CP=?
            ,STD_CODE=?
            ,STD_NAME=?
            ,CHECK_J_VAL=?
            ,STD_STYLE=?
            ,STD_STYLE_DESC = ?
            ,TAPER   = ?
            ,MIN_D_JG = ?
            ,MAX_D_JG = ?
            ,M_STD_NO = ?
            ,W_STD_NO = ?
            ,M_PRINT_NO = ?
            ,W_PRINT_NO = ?
            ,FILE_PATH = ?
            ,DIAMETER_SPEC=?
            ,DIAMETER_SPEC2=?
            ,LENGTH_SPEC=?
            ,LENGTH_SPEC2=?
         WHERE CODE_JG=?
		]]>
	</query>
	<query id="JGCodeManage.updateMscRJg" desc="更新">
		<![CDATA[ 
UPDATE COM_MSC_R_JG T
   SET T.M_STD_NO   = DECODE(T.M_STD_NO, NULL, ?, T.M_STD_NO),
       T.W_STD_NO   = DECODE(T.W_STD_NO, NULL, ?, T.W_STD_NO),
       T.M_PRINT_NO = DECODE(T.M_PRINT_NO, NULL, ?, T.M_PRINT_NO),
       T.W_PRINT_NO = DECODE(T.W_PRINT_NO, NULL, ?, T.W_PRINT_NO),
       T.FILE_PATH = DECODE(T.FILE_PATH, NULL, ?, T.FILE_PATH),
       T.JG_MEMO    = DECODE(T.JG_MEMO, NULL, ?, T.JG_MEMO)
 WHERE T.CODE_JG = ?
		]]>
	</query>
	<query id="JGCodeManage.DELETE" desc="删除">
		<![CDATA[  
		    UPDATE COM_MSC_JG  
			SET DELETE_NAME = ?,DELETE_TIME = SYSDATE, VALIDFLAG = '0'
			WHERE CODE_JG = ?
			 
		]]>
	</query>
	<query id="JGCodeManage.RESUME" desc="恢复">
		<![CDATA[ 
		   UPDATE COM_MSC_JG 
           SET DELETE_NAME = '', DELETE_TIME = '', VALIDFLAG = '1'
           WHERE CODE_JG = ?
		]]>
	</query>
	
	<query id="JGCodeManage.QueryReapt" desc="新增是否重复">
		<![CDATA[ 
		SELECT 1
        FROM COM_MSC_JG
        WHERE SPEC_JG=? AND PRODUCCODE_JG=?
        AND STEELCODE_JG=?  AND STD_CODE=? 
        AND MODEL_CODE=?  AND NVL(STYLE_JG, '/') = NVL(?, '/')
        AND NVL(STD_STYLE, '/') = NVL(?, '/')
		]]>
	</query>
	
	<query id="JGCodeManage.QueryReaptUpdate" desc="修改是否重复">
		<![CDATA[ 
	    SELECT 1
        FROM COM_MSC_JG
        WHERE SPEC_JG=? AND PRODUCCODE_JG=?
        AND STEELCODE_JG=?  AND STD_CODE=? 
        AND MODEL_CODE=?  AND STYLE_JG=?
        AND NVL(STD_STYLE, '/') = NVL(?, '/')
        AND CODE_JG!=?
		]]>
	</query>
	
	<query id="JGCodeManage.QuerySteel" desc="可替代钢级">
		<![CDATA[ 
	    SELECT 
        'False' CHK,
        STEELCODE ,STEELNAME
        FROM COM_BASE_STEEL
        WHERE VALIDFLAG='1'
        ORDER BY STEELCODE
		]]>
	</query>
	
	<query id="JGCodeManage.DynamicSteel" desc="钢级变化所关联的替代钢级">
		<![CDATA[ 
	   SELECT 
	   REPLACE(WM_CONCAT(T.STEELCODE_JG),',',';') REPSTEELCODE,
       REPLACE(WM_CONCAT(T.STEELCODE_JG_DESC),',',';') REPSTEELNAME
       FROM COM_MSC_JG_R_STEEL T
       WHERE T.STEELCODE=?
 
		]]>
	</query>
	
	<query id="JGCodeManage.DeleteSteel" desc="删除关联的钢级">
		<![CDATA[ 
	   DELETE FROM COM_MSC_JG_R_STEEL T 
	   WHERE T.STEELCODE=?
 
		]]>
	</query>
	
	<query id="JGCodeManage.LinkSteel" desc="关联钢级">
		<![CDATA[ 
	   INSERT INTO COM_MSC_JG_R_STEEL
     (STEELCODE,
      STEELCODE_DESC,
      STEELCODE_JG,
      STEELCODE_JG_DESC,
      CREATE_NAME,
      CREATE_TIME
      )
     VALUES
    (?,?,?,?,?,SYSDATE )

		]]>
	</query>
	
	<query id="JGCodeManage.insertJgRSpec" desc="新增接箍规格关联表">
		<![CDATA[ 
INSERT INTO COM_MSC_JG_R_SPEC
  (CODE_JG, SPEC_CODE, SPEC_NAME, CREATE_NAME, CREATE_TIME)
VALUES
  ('#CODE_JG#',
   '#SPEC_CODE#',
   '#SPEC_NAME#',
   '#CREATE_NAME#',
   SYSDATE)
		]]>
	</query>
	
	<query id="JGCodeManage.deleteJgRSpec" desc="删除接箍规格关联表">
		<![CDATA[ 
DELETE FROM COM_MSC_JG_R_SPEC T WHERE T.CODE_JG = '#CODE_JG#'
		]]>
	</query>
	
	<query id="JGCodeManage.QueryJgRMscByDH" desc="通过规格过滤接箍">
		<![CDATA[ 
SELECT AA.*,
       (SELECT LISTAGG(A.SPEC_NAME, ';') WITHIN GROUP(ORDER BY A.SPEC_NAME)
          FROM COM_MSC_JG_R_SPEC A
         WHERE A.CODE_JG = AA.CODE_JG
           AND A.VALIDFLAG = '1') SPEC_NAME,
       B.BASENAME STYLE_JG_DESC,
       '选择' BL_BTN
  FROM (SELECT (SELECT D.SPEC_NAME
                  FROM COM_BASE_SPEC D
                 WHERE D.SPEC_CODE = A.SPEC_JG) SPEC_JG_DESC,
               A.PRODUCCODE_JG_DESC,
               A.STEELCODE_JG_DESC,
               A.MODEL_DESC,
               A.PRODUCNAME,
               T.DEMAND_DETECTION,
               T.DEMAND_BONDERIZING,
               T.DEMAND_COPPER,
               T.DEMAND_BLAST,
               T.MSC,
               T.MEMO,
               T.KEY_JG,
               T.CUST_ALPHA_NO,
               T.ORDER_SPECIAL_DESC,
               T.ALPHA_CODE,
               AP.ALPHA_NAME,
               A.STD_NAME,
               A.STD_STYLE_DESC,
               A.CHECK_J_VAL,
               (SELECT REPLACE(WM_CONCAT(N.STEELCODE_JG_DESC), ',', ';')
                  FROM COM_MSC_JG_R_STEEL N
                 WHERE N.STEELCODE = A.STEELCODE_JG) REP_STEELNAME,
               (SELECT REPLACE(WM_CONCAT(N.STEELCODE_JG), ',', ';')
                  FROM COM_MSC_JG_R_STEEL N
                 WHERE N.STEELCODE = A.STEELCODE_JG) REP_STEELCODE,
               A.TAPER,
               A.MIN_D_JG,
               A.MAX_D_JG,
               A.CODE_JG,
               A.SPEC_JG,
               A.PRODUCCODE_JG,
               A.STEELCODE_JG,
               (SELECT BASENAME
                  FROM COM_BASE_INFO
                 WHERE BASECODE = A.STYLE_JG) STYLE_JG,
               A.PRODUCCODE,
               A.MODEL_CODE,
               A.DIAMETER_JG,
               A.LENGTH_JG,
               A.HEIGHT_JG,
               A.WEIGHT_JG,
               A.MIN_D,
               A.MIN_H,
               A.DIAMETER_PL,
               A.HEIGHT_PL,
               A.LENGTH_MIN,
               A.LENGTH_MAX,
               A.MIN_H_CP,
               A.MAX_H_CP,
               A.MIN_D_CP,
               A.MAX_D_CP,
               A.DIAMETER,
               A.ALPHA,
               A.VALIDFLAG,
               DECODE(A.VALIDFLAG, '1', '有效', '0', '无效', '未识别') VALIDFLAG_NAME,
               A.CREATE_NAME,
               A.CREATE_TIME,
               A.UPDATE_NAME,
               A.UPDATE_TIME,
               A.DELETE_NAME,
               A.DELETE_TIME,
               T.M_STD_NO,
               T.W_STD_NO,
               T.M_PRINT_NO,
               T.W_PRINT_NO,
               T.FILE_PATH,
               T.FILE_PATH FILE_NAME,
               T.TORQUE_UNIT,
               T.TORQUE_MAX,
               T.TORQUE_MIN,
               T.TORQUE_BEST,
               T.POINT_MAX,
               T.POINT_MIN,
               T.JG_MEMO
          FROM COM_MSC_R_JG T
          LEFT JOIN COM_BASE_STD_ALPHA AP
            ON AP.ALPHA_CODE = T.ALPHA_CODE, COM_MSC_JG A
         WHERE T.MSC = {0}
           AND T.STOCK_STYLE = 'A'
           AND T.VALIDFLAG = '1'
           AND T.CODE_JG = A.CODE_JG
           AND {4} LIKE '%' || A.MODEL_DESC || '%'
           AND ((EXISTS
                (SELECT 1
                    FROM COM_MSC_JG_R_STEEL L
                   WHERE L.STEELCODE = A.STEELCODE_JG) AND EXISTS
                (SELECT 1
                    FROM COM_MSC_JG_R_STEEL L
                   WHERE L.STEELCODE = A.STEELCODE_JG
                     AND L.STEELCODE_JG = {5})) OR
               (NOT EXISTS (SELECT 1
                               FROM COM_MSC_JG_R_STEEL L
                              WHERE L.STEELCODE = A.STEELCODE_JG) AND
                A.STEELCODE_JG = {5}))
           AND (TO_NUMBER(NVL(A.MIN_D_JG, '0')) <= TO_NUMBER({1}) AND
               TO_NUMBER(NVL(A.MAX_D_JG, '10000')) >= TO_NUMBER({1}) AND
               TO_NUMBER(NVL(A.MIN_H_CP, '0')) <= TO_NUMBER({2}) AND
               TO_NUMBER(NVL(A.MAX_H_CP, '10000')) >= TO_NUMBER({2}) OR
               EXISTS (SELECT 1
                         FROM COM_MSC_JG_R_SPEC C
                        WHERE C.CODE_JG = A.CODE_JG
                          AND C.SPEC_CODE = {3}))) AA
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = AA.STYLE_JG
		]]>
	</query>

	<query id="JGCodeManage.QueryTorqueByDH" desc="通过规格过滤接箍拧接">
		<![CDATA[
SELECT B.*
  FROM COM_MSC_R_JG T
  LEFT JOIN COM_BASE_STD_ALPHA AP
    ON AP.ALPHA_CODE = T.ALPHA_CODE, COM_MSC_JG A, COM_MSC_R_JG_TORQUE B
 WHERE T.MSC = {0}
   AND T.STOCK_STYLE = 'A'
   AND T.VALIDFLAG = '1'
   AND T.CODE_JG = A.CODE_JG
   AND {4} LIKE '%' || A.MODEL_DESC || '%'
   AND ((EXISTS (SELECT 1
                   FROM COM_MSC_JG_R_STEEL L
                  WHERE L.STEELCODE = A.STEELCODE_JG) AND EXISTS
        (SELECT 1
            FROM COM_MSC_JG_R_STEEL L
           WHERE L.STEELCODE = A.STEELCODE_JG
             AND L.STEELCODE_JG = {5})) OR
       (NOT EXISTS
        (SELECT 1
            FROM COM_MSC_JG_R_STEEL L
           WHERE L.STEELCODE = A.STEELCODE_JG) AND A.STEELCODE_JG = {5}))
   AND (TO_NUMBER(NVL(A.MIN_D_JG, '0')) <= TO_NUMBER({1}) AND
       TO_NUMBER(NVL(A.MAX_D_JG, '10000')) >= TO_NUMBER({1}) AND
       TO_NUMBER(NVL(A.MIN_H_CP, '0')) <= TO_NUMBER({2}) AND
       TO_NUMBER(NVL(A.MAX_H_CP, '10000')) >= TO_NUMBER({2}) OR EXISTS
        (SELECT 1
           FROM COM_MSC_JG_R_SPEC C
          WHERE C.CODE_JG = A.CODE_JG
            AND C.SPEC_CODE = {3}))
   AND B.KEY_JG = T.KEY_JG
		]]>
	</query>
	
	<query id="JGCodeManage.updateJgFile" desc="修改接箍文件路径">
		<![CDATA[ 
UPDATE COM_MSC_JG T
   SET T.FILE_PATH = {1}, T.UPDATE_NAME = {2}, T.UPDATE_TIME = SYSDATE
 WHERE T.CODE_JG = {0}
		]]>
	</query>

	<query id="JGCodeManage.insertTorque" desc="新增接箍拧接">
		<![CDATA[
INSERT INTO COM_MSC_R_JG_TORQUE
  (ID,
   KEY_JG,
   TORQUE_UNIT,
   TORQUE_MAX,
   TORQUE_MIN,
   TORQUE_BEST,
   POINT_MAX,
   POINT_MIN,
   MIN_D,
   MAX_D,
   MIN_H,
   MAX_H)
VALUES
  ((SELECT NVL(MAX(ID), 0) + 1 FROM COM_MSC_R_JG_TORQUE),
   {0},
   {1},
   {2},
   {3},
   {4},
   {5},
   {6},
   {7},
   {8},
   {9},
   {10})
		]]>
	</query>

	<query id="JGCodeManage.updateTorque" desc="修改接箍拧接">
		<![CDATA[
UPDATE COM_MSC_R_JG_TORQUE T
   SET T.TORQUE_UNIT = {1},
       T.TORQUE_MAX  = {2},
       T.TORQUE_MIN  = {3},
       T.TORQUE_BEST = {4},
       T.POINT_MAX   = {5},
       T.POINT_MIN   = {6},
       T.MIN_D = {7},
       T.MAX_D = {8},
       T.MIN_H = {9},
       T.MAX_H = {10}
 WHERE T.ID = {0}
		]]>
	</query>

	<query id="JGCodeManage.deleteTorque" desc="修改接箍拧接">
		<![CDATA[
 DELETE FROM COM_MSC_R_JG_TORQUE T WHERE T.ID = {0}
		]]>
	</query>
</queryMap>