<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍码和备料码">
	<query id="MscJGDao.getJGByDAndH" desc="查询接箍码 外径、壁厚">  
             <![CDATA[ 
SELECT U.CODE_JG, U.KEY_JG, U.ORDER_SPECIAL_DESC
  FROM (SELECT NVL(X.STEELCODE_JG, WM_CONCAT(Y.STEELCODE)) STEELCODE_JG,
               X.MODEL_DESC,
               X.ORDER_SPECIAL_DESC,
               X.CODE_JG,
               X.KEY_JG
          FROM (SELECT P.CODE_JG,
                       P.STEELCODE_JG,
                       P.MODEL_DESC,
                       P.KEY_JG,
                       P.ORDER_SPECIAL_DESC
                  FROM (SELECT A.ORDER_SPECIAL_DESC,
                               A.KEY_JG,
                               A.CODE_JG,
                               B.STEELCODE_JG,
                               B.MODEL_DESC,
                               NVL(TRIM(B.MIN_H_CP), '0') MIN_H_CP,
                               NVL(TRIM(B.MAX_H_CP), '10000') MAX_H_CP,
                               NVL(TRIM(B.MIN_D_JG), '0') MIN_D_JG,
                               NVL(TRIM(B.MAX_D_JG), '10000') MAX_D_JG
                          FROM COM_MSC_R_JG A, COM_MSC_JG B
                         WHERE A.CODE_JG = B.CODE_JG
                           AND A.MSC = ?
                           AND A.STOCK_STYLE = 'A'
                           AND A.VALIDFLAG = '1'
                           AND B.VALIDFLAG = '1'
                           AND DECODE(?, NULL, '1', A.KEY_JG) = NVL(?, '1')) P
                 WHERE TO_NUMBER(P.MIN_H_CP) <= TO_NUMBER(?)
                   AND TO_NUMBER(P.MAX_H_CP) >= TO_NUMBER(?)
                   AND TO_NUMBER(P.MIN_D_JG) <= TO_NUMBER(?)
                   AND TO_NUMBER(P.MAX_D_JG) >= TO_NUMBER(?)) X,
               COM_MSC_JG_R_STEEL Y
         WHERE X.STEELCODE_JG = Y.STEELCODE_JG(+)
         GROUP BY X.CODE_JG,
                  X.STEELCODE_JG,
                  X.MODEL_DESC,
                  X.KEY_JG,
                  X.ORDER_SPECIAL_DESC) U
 WHERE INSTR(U.STEELCODE_JG, ?) > 0
   AND ? LIKE '%' || U.MODEL_DESC || '%'
   AND NVL(U.ORDER_SPECIAL_DESC, '/') =
       NVL((SELECT L.ORDER_SPECIAL_DESC
             FROM SLM_ORDER_LINE L
            WHERE L.ORD_LN_PK = ?),
           '/')
                     ]]>
	</query>

	<query id="MscJGDao.getJGBySpecCode" desc="查询接箍码 产品规格">  
             <![CDATA[ 
SELECT U.CODE_JG, U.ORDER_SPECIAL_DESC, U.KEY_JG
  FROM (SELECT NVL(WM_CONCAT(Y.STEELCODE_JG), X.STEELCODE_JG) STEELCODE_JG,
               X.MODEL_DESC,
               X.CODE_JG,
               X.ORDER_SPECIAL_DESC,
               X.KEY_JG
          FROM (SELECT P.CODE_JG,
                       Q.STEELCODE_JG,
                       Q.MODEL_DESC,
                       P.ORDER_SPECIAL_DESC,
                       P.KEY_JG
                  FROM (SELECT A.CODE_JG, A.ORDER_SPECIAL_DESC, A.KEY_JG
                          FROM COM_MSC_R_JG A, COM_MSC_JG_R_SPEC B
                         WHERE A.CODE_JG = B.CODE_JG
                           AND A.MSC = ?
                           AND B.SPEC_CODE = ?
                           AND A.STOCK_STYLE = 'A'
                           AND A.VALIDFLAG = '1'
                           AND B.VALIDFLAG = '1'
                           AND DECODE(?, NULL, '1', A.KEY_JG) = NVL(?, '1')) P,
                       COM_MSC_JG Q
                 WHERE P.CODE_JG = Q.CODE_JG) X,
               COM_MSC_JG_R_STEEL Y
         WHERE X.STEELCODE_JG = Y.STEELCODE_JG(+)
         GROUP BY X.CODE_JG,
                  X.STEELCODE_JG,
                  X.MODEL_DESC,
                  X.ORDER_SPECIAL_DESC,
                  X.KEY_JG) U
 WHERE INSTR(U.STEELCODE_JG, ?) > 0
   AND ? LIKE '%' || U.MODEL_DESC || '%'
   AND NVL(U.ORDER_SPECIAL_DESC, '/') =
       NVL((SELECT L.ORDER_SPECIAL_DESC
             FROM SLM_ORDER_LINE L
            WHERE L.ORD_LN_PK = ?),
           '/')
                     ]]>
	</query>

	<query id="MscJGDao.saveJG" desc="保存接箍码">  
             <![CDATA[ 
INSERT INTO CRAFT_ORD_DESIGN_MSC_JG
  (DESGIN_KEY,
   CODE_JG,
   DEMAND_DETECTION,
   DEMAND_BONDERIZING,
   DEMAND_COPPER,
   DEMAND_BLAST,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   MIN_H,
   MAX_H,
   MIN_D,
   MAX_D,
   SET_JG,
   CUST_ALPHA_NO,
   KEY_JG,
   ORDER_SPECIAL_DESC,
   ALPHA_CODE,
   TORQUE_UNIT,
   TORQUE_MAX,
   TORQUE_MIN,
   TORQUE_BEST,
   POINT_MAX,
   POINT_MIN,
   M_STD_NO,
   W_STD_NO,
   M_PRINT_NO,
   W_PRINT_NO,
   FILE_PATH,
   JG_MEMO,
   MEMO)
VALUES
  ('#DESGIN_KEY#',
   '#CODE_JG#',
   '#DEMAND_DETECTION#',
   '#DEMAND_BONDERIZING#',
   '#DEMAND_COPPER#',
   '#DEMAND_BLAST#',
   '#PRODUCCODE#',
   '#PRODUCNAME#',
   '#STEELCODE#',
   '#STEELNAME#',
   '#MIN_H#',
   '#MAX_H#',
   '#MIN_D#',
   '#MAX_D#',
   '#SET_JG#',
   '#CUST_ALPHA_NO#',
   '#KEY_JG#',
   '#ORDER_SPECIAL_DESC#',
   '#ALPHA_CODE#',
   '#TORQUE_UNIT#',
   '#TORQUE_MAX#',
   '#TORQUE_MIN#',
   '#TORQUE_BEST#',
   '#POINT_MAX#',
   '#POINT_MIN#',
   '#M_STD_NO#',
   '#W_STD_NO#',
   '#M_PRINT_NO#',
   '#W_PRINT_NO#',
   '#FILE_PATH#',
   '#JG_MEMO#',
   '#MEMO#')
                     ]]>
	</query>


	<query id="MscJGDao.getJGInfo" desc="查询接箍信息">  
             <![CDATA[ 
              SELECT T.MSC,
       T.MSC_DESC,
       T.CODE_JG,
       T.STOCK_STYLE,
       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,
       T.MEMO,
       T.GROUP_NUM,
       T.DEMAND_DETECTION,
       T.DEMAND_BONDERIZING,
       T.DEMAND_COPPER,
       T.DEMAND_BLAST,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.MIN_H,
       T.MAX_H,
       T.MIN_D,
       T.MAX_D,
       T.CUST_ALPHA_NO,
       T.KEY_JG,
       T.ORDER_SPECIAL_DESC,
       T.ALPHA_CODE,
       T.TORQUE_UNIT,
       T.TORQUE_MAX,
       T.TORQUE_MIN,
       T.TORQUE_BEST,
       T.POINT_MAX,
       T.POINT_MIN,
       T.M_STD_NO,
       T.W_STD_NO,
       T.M_PRINT_NO,
       T.W_PRINT_NO,
       T.FILE_PATH,
       T.JG_MEMO
  FROM COM_MSC_R_JG T
 WHERE T.KEY_JG = ?
   AND T.VALIDFLAG = '1'
               ]]>
	</query>

	<query id="MscJGDao.getJGBL" desc="查询接箍与备料关系">  
             <![CDATA[ 
            SELECT T.CODE_JG, T.PSC_BL, T.CUST_ALPHA_NO, T.ORDER_SPECIAL_DESC, T.ALPHA_CODE
              FROM COM_MSC_JG_R_BL T
             WHERE T.CODE_JG = ?
               AND T.CUST_ALPHA_NO = ?
               AND T.ALPHA_CODE = ?
               AND T.VALIDFLAG = '1'
                     ]]>
	</query>

	<query id="MscJGDao.getJGBLInfo" desc="查询备料评审信息">  
             <![CDATA[ 
SELECT T.ORD_LN_PK, T.DESGIN_KEY, T.VALIDFLAG
   FROM CRAFT_ORD_DESIGN T
  WHERE T.CRAFT_SEQ = (SELECT MAX(A.CRAFT_SEQ)
                         FROM CRAFT_ORD_DESIGN A
                        WHERE A.ORD_LN_PK = ?)
    AND T.ORD_LN_PK = ?
               ]]>
	</query>

	<query id="MscJGDao.saveMscJGBL" desc="保存接箍备料对应关系">  
             <![CDATA[ 
             INSERT INTO CRAFT_ORD_DESIGN_MSC_JG_BL
  (DESGIN_KEY, CODE_JG, PSC_BL, DESGIN_KEY_BL, CUST_ALPHA_NO, ORDER_SPECIAL_DESC, ALPHA_CODE)
VALUES
  (?, ?, ?, ?, ?, ?, ?)
               ]]>
	</query>

	<query id="MscJGDao.getJGBaseInfo" desc="查询接箍基础信息">  
             <![CDATA[ 
           SELECT 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,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       VALIDFLAG,
       MEMO,
       STD_CODE,
       STD_NAME,
       CHECK_J_VAL,
       STD_STYLE,
       STD_STYLE_DESC,
       TAPER,
       MIN_D_JG,
       MAX_D_JG
  FROM COM_MSC_JG T
 WHERE T.CODE_JG = ?
               ]]>
	</query>

	<query id="MscJGDao.getSetJG" desc="查询设定接箍">
             <![CDATA[ 
    SELECT T.*
  FROM CRAFT_ORD_DESIGN_MSC_JG T
 WHERE T.DESGIN_KEY = ?
   AND T.SET_JG = '1'
               ]]>
	</query>
	
	<query id="MscJGDao.DeleteJg" desc="删除接箍">  
             <![CDATA[ 
DELETE FROM CRAFT_ORD_DESIGN_MSC_JG T WHERE T.DESGIN_KEY = {0}
               ]]>
	</query>

	<query id="MscJGDao.updateSetJG" desc="修改设定接箍信息">  
             <![CDATA[ 
UPDATE CRAFT_ORD_DESIGN_MSC_JG T
   SET T.DESGIN_KEY         = '#DESGIN_KEY#',
       T.CODE_JG            = '#CODE_JG#',
       T.DEMAND_DETECTION   = '#DEMAND_DETECTION#',
       T.DEMAND_BONDERIZING = '#DEMAND_BONDERIZING#',
       T.DEMAND_COPPER      = '#DEMAND_COPPER#',
       T.DEMAND_BLAST       = '#DEMAND_BLAST#',
       T.PRODUCCODE         = '#PRODUCCODE#',
       T.PRODUCNAME         = '#PRODUCNAME#',
       T.STEELCODE          = '#STEELCODE#',
       T.STEELNAME          = '#STEELNAME#',
       T.MIN_H              = '#MIN_H#',
       T.MAX_H              = '#MAX_H#',
       T.MIN_D              = '#MIN_D#',
       T.MAX_D              = '#MAX_D#',
       T.SET_JG             = '#SET_JG#',
       T.CUST_ALPHA_NO      = '#CUST_ALPHA_NO#',
       T.KEY_JG             = '#KEY_JG#',
       T.ORDER_SPECIAL_DESC = '#ORDER_SPECIAL_DESC#',
       T.ALPHA_CODE         = '#ALPHA_CODE#',
       T.TORQUE_UNIT        = '#TORQUE_UNIT#',
       T.TORQUE_MAX         = '#TORQUE_MAX#',
       T.TORQUE_MIN         = '#TORQUE_MIN#',
       T.TORQUE_BEST        = '#TORQUE_BEST#',
       T.POINT_MAX          = '#POINT_MAX#',
       T.POINT_MIN          = '#POINT_MIN#',
       T.M_STD_NO = '#M_STD_NO#',
       T.W_STD_NO = '#W_STD_NO#',
       T.M_PRINT_NO = '#M_PRINT_NO#',
       T.W_PRINT_NO = '#W_PRINT_NO#',
       T.FILE_PATH = '#FILE_PATH#',
       T.JG_MEMO = '#JG_MEMO#',
       T.MEMO = '#MEMO#'
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.CODE_JG = '#CODE_JG#'
   AND T.KEY_JG = '#KEY_JG#'
               ]]>
	</query>
	
	<query id="MscJGDao.getCountByKeyJg" desc="查询是否存在KEYjg">  
             <![CDATA[ 
select COUNT(1) from com_msc_r_jg t where t.key_jg = ?
               ]]>
	</query>

	<query id="MscJGDao.getTorque" desc="查询拧接信息">
		<![CDATA[
SELECT *
  FROM COM_MSC_R_JG_TORQUE T
 WHERE T.KEY_JG = {0}
   AND ({1} IS NULL OR T.MIN_D IS NULL OR T.MIN_D <= TO_NUMBER({1}))
   AND ({1} IS NULL OR T.MAX_D IS NULL OR T.MAX_D >= TO_NUMBER({1}))
   AND ({2} IS NULL OR T.MIN_H IS NULL OR T.MIN_H <= TO_NUMBER({2}))
   AND ({2} IS NULL OR T.MAX_H IS NULL OR T.MAX_H >= TO_NUMBER({2}))
        ]]>
	</query>
</queryMap>