<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="冶金规范">
    <query id="ComMscRJgDAL.getSLmOrderLineByPk" desc="通过合同行主键查询记录">
		<![CDATA[
SELECT T.ORD_PK,
       T.ORD_LN_PK,
       T.ORDER_SEQ,
       T.CUST_ALPHA_NO,
       T.PSC,
       T.PSC_DESC,
       T.MSC,
       T.MSC_DESC,
       T.MSC_STYLE,
       T.USE_CODE,
       T.USE_DESC,
       T.PRD_CLS,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ORDER_SPEC_CODE,
       T.ORDER_SPEC_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.DIMATER,
       T.HEIGHT,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LEN_NO,
       T.LEN_DESC,
       T.LEN_UNIT,
       T.LEN_MIN,
       T.LEN_MAX,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.ENDLEN_SPECSTD,
       T.SIGL_LEN,
       T.ORDER_UNIT,
       T.ORDER_QTY,
       T.ORD_ENSU_TOTL_LEN,
       T.PRDCT_WGT,
       T.DELVRY_RANGE_TPE,
       T.DELVRY_RANGE_MIN,
       T.DELVRY_RANGE_MAX,
       T.FINAL_USER,
       T.FINAL_USER_DESC,
       T.OUTS_BILLET_FL,
       T.OUTS_STL_PIPE_FL,
       T.ASSEL_FL,
       T.PRODUCER_FL,
       T.PRDCR_NO,
       T.PRDCR_DESC,
       T.MPS_FL,
       T.MPS_NO,
       T.MPS_DESC,
       TO_CHAR(T.DELVRY_BDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_BDATE,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.DELVRY_DESC,
       T.TRANS_DESC,
       T.ADD_ASK_NO,
       T.ORDER_ADD_DESC,
       T.ORDER_SPECIAL_FL,
       T.ORDER_SPECIAL_HEAD,
       T.ORDER_SPECIAL_PATH,
       T.ORDER_SPECIAL_DESC,
       T.ZBS,
       T.ORDER_PRICE,
       T.TRANS_PRICE,
       T.TEST_ID,
       T.TEST_PRICE,
       T.OUT_PRICE,
       T.BALNCE_PRICE,
       T.BE_ORDER_LN_STATUS,
       T.BE_OBJ_STS_OP,
       T.ORDER_LN_STATUS,
       T.OBJ_STS_OP,
       T.MEMO,
       T.VALIDFLAG,
       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.ORD_LN_PK_OLD,
       T.ISLOCK,
       T.CUST_ALPHA_NO2,
       T.ORDER_CHGE_NO,
       T.CHGE_ORD_LN_PK,
       T.BALNCE_PRICE_STS,
       T.BALNCE_PRICE_ORG,
       T.BALNCE_PRICE_ORG_STS,
       T.PAK_PRICE,
       T.AW,
       T.MPS_NO_INPUT,
       T.MAN_INSPECTION,
       T.INSPECTION_VALUE,
       T.MPS_NO_FILE,
       T.QUALITY_USER,
       T.QUALITY_USER_DESC
  FROM SLM_ORDER_LINE T
 WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
		 ]]>
	</query>
	
    <query id="ComMscRJgDAL.getComBaseSpecByPk" desc="通过规格主键查询记录">
		<![CDATA[
 SELECT 
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.DIMATER,
       T.HEIGHT,
       T.WEIGHT,
       T.MSC_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.SPEC_CODE_OLD
 FROM COM_BASE_SPEC T
 WHERE
T.SPEC_CODE = '#SPEC_CODE#'
		 ]]>
	</query>
	
    <query id="ComMscRJgDAL.getComPscByPk" desc="通过产品主键查询记录">
		<![CDATA[
SELECT T.PSC,
       T.PSC_DESC,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.NEW_PROC_CODE,
       T.NEW_PROC_DESC,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC,
       T.UNIT_CODE,
       T.AUTOJUDGE,
       T.UNIT_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,
       T.MEMO,
       T.PSC_OLD,
       T.PRODUC_HEAD,
       T.PRODUC_TYPE,
       T.PRODUC_STYLE,
       T.PRODUC_DESC
  FROM COM_PSC T
 WHERE T.PSC = '#PSC#'
		 ]]>
	</query>
    
    <query id="ComMscRJgDAL.getMscRJgBySpec" 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,
       DET.BASENAME DEMAND_DETECTION_DESC,
       BON.BASENAME DEMAND_BONDERIZING_DESC,
       COP.BASENAME DEMAND_COPPER_DESC,
       BLA.BASENAME DEMAND_BLAST_DESC,
       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
  FROM COM_MSC_R_JG T
  LEFT JOIN COM_BASE_INFO DET ON DET.BASECODE = T.DEMAND_DETECTION
  LEFT JOIN COM_BASE_INFO BON ON BON.BASECODE = T.DEMAND_BONDERIZING
  LEFT JOIN COM_BASE_INFO COP ON COP.BASECODE = T.DEMAND_COPPER
  LEFT JOIN COM_BASE_INFO BLA ON BLA.BASECODE = T.DEMAND_BLAST
 WHERE T.KEY_JG IN
       (SELECT U.KEY_JG
          FROM (SELECT NVL(X.STEELCODE_JG, WM_CONCAT(Y.STEELCODE)) STEELCODE_JG,
                       X.CUST_ALPHA_NO,
                       X.CODE_JG,
                       X.KEY_JG
                  FROM (SELECT P.CODE_JG,
                               P.STEELCODE_JG,
                               P.KEY_JG,
                               P.CUST_ALPHA_NO
                          FROM (SELECT A.CUST_ALPHA_NO,
                                       A.KEY_JG,
                                       A.CODE_JG,
                                       B.STEELCODE_JG,
                                       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 = '#MSC#'
                                   AND A.STOCK_STYLE = 'A'
                                   AND A.VALIDFLAG = '1'
                                   AND B.VALIDFLAG = '1') P
                         WHERE TO_NUMBER(P.MIN_H_CP) <= TO_NUMBER('#HEIGHT#')
                           AND TO_NUMBER(P.MAX_H_CP) >= TO_NUMBER('#HEIGHT#')
                           AND TO_NUMBER(P.MIN_D_JG) <= TO_NUMBER('#DIMATER#')
                           AND TO_NUMBER(P.MAX_D_JG) >= TO_NUMBER('#DIMATER#')) X,
                       COM_MSC_JG_R_STEEL Y
                 WHERE X.STEELCODE_JG = Y.STEELCODE_JG(+)
                 GROUP BY X.CODE_JG,
                          X.STEELCODE_JG,
                          X.KEY_JG,
                          X.CUST_ALPHA_NO) U
         WHERE INSTR(U.STEELCODE_JG, '#STEELCODE#') > 0
           AND NVL(U.CUST_ALPHA_NO, '/') = NVL('#CUST_ALPHA_NO#', '/'))
		 ]]>
	</query>
	
    <query id="ComMscRJgDAL.getMscRJgBySpec2" 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
  FROM COM_MSC_R_JG T
 WHERE T.KEY_JG IN
       (SELECT U.KEY_JG
          FROM (SELECT NVL(WM_CONCAT(Y.STEELCODE_JG), X.STEELCODE_JG) STEELCODE_JG,
                       X.CODE_JG,
                       X.CUST_ALPHA_NO,
                       X.KEY_JG
                  FROM (SELECT P.CODE_JG,
                               Q.STEELCODE_JG,
                               P.CUST_ALPHA_NO,
                               P.KEY_JG
                          FROM (SELECT A.CODE_JG, A.CUST_ALPHA_NO, 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 = '#MSC#'
                                   AND B.SPEC_CODE = '#SPEC_CODE#'
                                   AND A.STOCK_STYLE = 'A'
                                   AND A.VALIDFLAG = '1'
                                   AND B.VALIDFLAG = '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.CUST_ALPHA_NO,
                          X.KEY_JG) U
         WHERE INSTR(U.STEELCODE_JG, '#STEEELCODE#') > 0
           AND NVL(U.CUST_ALPHA_NO, '/') = NVL('#CUST_ALPHA_NO#', '/'))
		 ]]>
	</query>
	
     <query id="ComMscRJgDAL.delDesignMscRJg" desc="删除质量设计接箍和冶金规范关系">
		<![CDATA[
  DELETE FROM SLM_ORD_DESIGN_MSC_JG
   WHERE DESGIN_KEY = (SELECT T.DESGIN_KEY
                         FROM SLM_ORD_DESIGN_STS_TKLG T
                        WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
                          AND T.VALIDFLAG = '1')
		 ]]>
	</query>
	
     <query id="ComMscRJgDAL.delCraftMscRJg" desc="删除工艺设计接箍和冶金规范关系">
		<![CDATA[
  DELETE FROM CRAFT_ORD_DESIGN_MSC_JG
   WHERE DESGIN_KEY = (SELECT T.DESGIN_KEY
                         FROM CRAFT_ORD_DESIGN T
                        WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
                          AND T.VALIDFLAG = '2')
		 ]]>
	</query>
    
     <query id="ComMscRJgDAL.insertDesignMscRJg" desc="插入到质量设计接箍和冶金关系表">
		<![CDATA[
  INSERT INTO SLM_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)
  VALUES
    ((SELECT T.DESGIN_KEY
       FROM SLM_ORD_DESIGN_STS_TKLG T
      WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
        AND T.VALIDFLAG = '1'),
     '#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#')
		 ]]>
	</query>
	
     <query id="ComMscRJgDAL.insertCraftMscRJg" 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)
  VALUES
    ((SELECT T.DESGIN_KEY
       FROM CRAFT_ORD_DESIGN T
      WHERE T.ORD_LN_PK = '#ORD_LN_PK#'
        AND T.VALIDFLAG = '2'),
     '#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#')
		 ]]>
	</query>
	
     <query id="ComMscRJgDAL.getKeyJgByOrdLnPk" desc="查询设定接箍">
		<![CDATA[
SELECT T.*
  FROM SLM_ORD_DESIGN_MSC_JG T, SLM_ORD_DESIGN_STS_TKLG A
 WHERE T.DESGIN_KEY = A.DESGIN_KEY
   AND T.SET_JG = '1'
   AND A.ORD_LN_PK = '#ORD_LN_PK#'
   AND A.VALIDFLAG = '1'
		 ]]>
	</query>
	
     <query id="ComMscRJgDAL.getCraftKeyJgByOrdLnPk" desc="查询设定接箍">
		<![CDATA[
SELECT T.*
  FROM CRAFT_ORD_DESIGN_MSC_JG T, CRAFT_ORD_DESIGN A
 WHERE T.DESGIN_KEY = A.DESGIN_KEY
   AND T.SET_JG = '1'
   AND A.ORD_LN_PK = '#ORD_LN_PK#'
   AND A.VALIDFLAG = '2'
		 ]]>
	</query>
</queryMap>