<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="材质标准管理">

      <query id="ComMaterialStandard.SetGroupSeq" desc="更新分组索引号">
        <![CDATA[      
            UPDATE COM_MSC_STD_PHY  SET GROUP_SEQ=?
            WHERE PIC=? AND INDEX_SEQ=? AND VALIDFLAG='1'
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.CancelGroupSeq" desc="更新分组索引号">
        <![CDATA[      
            UPDATE COM_MSC_STD_PHY  SET GROUP_SEQ=''
            WHERE PIC=? AND INDEX_SEQ=? AND VALIDFLAG='1'
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.GetAddCondition" desc="获取附加条件">
        <![CDATA[      
            SELECT BASENAME，BASECODE
            FROM　COM_BASE_INFO 
            WHERE SORTCODE='4070'
            AND VALIDFLAG='1' 
            ORDER BY BASECODE
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.GetMultStd" desc="获取附加条件">
        <![CDATA[      
            SELECT BASENAME，BASECODE
            FROM　COM_BASE_INFO 
            WHERE SORTCODE='4071'
            AND VALIDFLAG='1' 
            ORDER BY BASECODE
	     ]]>
	  </query>
	  
     <query id="ComMaterialStandard.GetGroupSeq" desc="取得分组索引号">
        <![CDATA[      
            SELECT MAX(GROUP_SEQ) GROUP_SEQ FROM COM_MSC_STD_PHY WHERE PIC=?   
	     ]]>
	  </query>
      <query id="ComMaterialStandard.MAXPIC" desc="主表 最大材质索引号查询">
        <![CDATA[      
              SELECT PIC
                FROM COM_MSC_STD_PIC
               WHERE PIC = (SELECT MAX(PIC) PIC FROM COM_MSC_STD_PIC)
               
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.MAXPIC1" desc="主表 最大材质索引号查询">
        <![CDATA[      
SELECT MAX(SUBSTR(PIC, 5, 6)) PIC FROM COM_MSC_STD_PIC
                WHERE (STDSTYLE=? OR STDSTYLE=? )
	     ]]>
	  </query>
	  
	  <query id="ComMaterialStandard.MAXINDEX" desc="从表 最大序号查询">
        <![CDATA[      
              SELECT INDEX_SEQ
                FROM COM_MSC_STD_PHY
               WHERE INDEX_SEQ =(SELECT MAX(INDEX_SEQ) INDEX_SEQ FROM COM_MSC_STD_PHY WHERE PIC =?)
	     ]]>
	  </query>
	  
	  <query id="ComMaterialStandard.QUERYN" desc="主表查询">
        <![CDATA[
SELECT P.PIC,
       P.PSC,
       P.MSC,
       DECODE(P.STDSTYLE,
              'G',
              '订货标准',
              'K',
              'Alpha',
              'X',
              '协议标准',
              '内控') STDSTYLE,
       P.STD_CODE_NK,
       P.STD_NAME_NK,
       P.PROCESS_CDOE,
       P.PROCESS_DESC,
       P.MODEL_CODE,
       P.MODEL_DESC,
       P.CREATE_NAME,
       TO_CHAR(P.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       P.UPDATE_NAME,
       TO_CHAR(P.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       P.DELETE_NAME,
       TO_CHAR(P.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(P.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAGNAME,
       P.MEMO,
       M.PRODUCNAME, --内控下M表的数据无效 但为了dataset列名一致  保留
       M.STD_NAME,
       M.STD_CODE,
       P.STEELCODE,
       P.STEELNAME,
       P.GRADECODE,
       P.GRADENAME,
       M.STD_STYLE_DESC,
       (SELECT COUNT(DISTINCT(A.PHY_CODE_MAX || A.PHY_CODE_MIN || A.PHY_CODE ||
                              A.ITEM_CODE_F || A.ITEM_CODE_W ||
                              A.ITEM_CODE_S))
          FROM COM_MSC_STD_PHY A
         WHERE A.PIC = P.PIC
           AND A.VALIDFLAG <> '0') COUNT,
       P.STEELCODE_NK,
       P.STEELNAME_NK,
       P.MODEL_CODE_NK,
       P.MODEL_DESC_NK,
       P.PRODUCNAME_NK,
       P.PRODUCCODE_NK,
       P.IMPACT_ID,
       P.STRETCH_PLAN
  FROM COM_MSC_STD_PIC P
  LEFT JOIN COM_PSC M
    ON P.PSC = M.PSC
 WHERE P.VALIDFLAG in ('1', '2', '3', '#VALIDFLAG#')
   AND STDSTYLE NOT IN ('G', 'X', 'K')
   AND DECODE('#STD_CODE_NK#', NULL, '1', P.STD_CODE_NK) =
       DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
   AND UPPER(PIC) LIKE UPPER('#PIC#') || '%'
   AND DECODE('#MSC2#', NULL, '1', P.MSC) =
       DECODE('#MSC2#', NULL, '1', '#MSC2#')
   AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', P.CODE_JG) =
       DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
   AND DECODE('#CODE_JG#', NULL, P.CODE_JG, NULL) IS NULL
   AND NVL(INSTR(P.PRODUCCODE_NK, '#PRODUCCODE#'), 1) > 0
   AND NVL(INSTR(P.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
   AND NVL(INSTR(P.PROCESS_CDOE, '#PROCESS_CDOE#'), 1) > 0
   AND NVL(INSTR(P.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0
    #WHERE#
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.QUERYK" desc="主表查询">
        <![CDATA[
SELECT P.PIC,
       P.PSC,
       P.MSC,
       DECODE(P.STDSTYLE,
              'G',
              '订货标准',
              'K',
              'Alpha',
              'N',
              '内控',
              'X',
              '协议标准') STDSTYLE,
       P.STD_CODE_NK,
       P.STD_NAME_NK,
       P.MODEL_CODE,
       P.MODEL_DESC,
       P.PROCESS_CDOE,
       P.PROCESS_DESC,
       P.CREATE_NAME,
       TO_CHAR(P.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       P.UPDATE_NAME,
       TO_CHAR(P.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       P.DELETE_NAME,
       TO_CHAR(P.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(P.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAGNAME,
       P.MEMO,
       M.PRODUCNAME, --Alpha下M表的数据无效 但为了dataset列名一致  保留
       M.STD_NAME,
       M.STD_CODE,
       M.STEELNAME,
       M.STD_STYLE_DESC,
       (SELECT COUNT(DISTINCT(A.PHY_CODE_MAX || A.PHY_CODE_MIN || A.PHY_CODE ||
                              A.ITEM_CODE_F || A.ITEM_CODE_W ||
                              A.ITEM_CODE_S))
          FROM COM_MSC_STD_PHY A
         WHERE A.PIC = P.PIC
           AND A.VALIDFLAG <> '0') COUNT,
       P.IMPACT_ID,
       P.STRETCH_PLAN
  FROM COM_MSC_STD_PIC P
  LEFT JOIN COM_PSC M
    ON P.PSC = M.PSC
 WHERE P.VALIDFLAG in ('1', '2', '3', '#VALIDFLAG#')
   AND DECODE('#STD_CODE_NK#', NULL, '1', P.STD_CODE_NK) =
       DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
   AND STDSTYLE = 'K'
   AND UPPER(PIC) LIKE UPPER('#PIC#') || '%'
   AND DECODE('#MSC2#', NULL, '1', P.MSC) =
       DECODE('#MSC2#', NULL, '1', '#MSC2#')
   AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', P.CODE_JG) =
       DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
   AND DECODE('#CODE_JG#', NULL, P.CODE_JG, NULL) IS NULL
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.QUERYG" desc="主表查询">
        <![CDATA[
SELECT P.PIC,
       P.PSC,
       P.MSC,
       NVL(M.PSC_DESC,
           D.PRODUCNAME || ',' || D.STD_NAME || ',' || D.STEELNAME || ',' ||
           D.STD_STYLE_DESC || ',' || D.MODEL_DESC || ',' || D.MIN_D || ',' ||
           D.MIN_H || ',' || D.USE_DESC) PSC_DESC,
       DECODE(P.STDSTYLE,
              'G',
              '订货标准',
              'K',
              '客户',
              'X',
              '协议标准',
              '内控') STDSTYLE,
       P.STD_CODE_NK,
       P.STD_NAME_NK,
       P.MODEL_CODE,
       P.MODEL_DESC,
       P.PROCESS_CDOE,
       P.PROCESS_DESC,
       P.CREATE_NAME,
       TO_CHAR(P.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       P.UPDATE_NAME,
       TO_CHAR(P.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       P.DELETE_NAME,
       TO_CHAR(P.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(P.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAGNAME,
       P.MEMO,
       P.PRODUC_HEAD,
       NVL(M.PRODUCNAME, D.PRODUCNAME) PRODUCNAME,
       NVL(M.PRODUCCODE, D.PRODUCCODE) PRODUCCODE,
       NVL(M.STD_NAME, D.STD_NAME) STD_NAME,
       NVL(M.STD_CODE, D.STD_CODE) STD_CODE,
       NVL(M.STEELNAME, D.STEELNAME) STEELNAME,
       NVL(M.STEELCODE, D.STEELCODE) STEELCODE,
       NVL(M.STD_STYLE_DESC, D.STD_STYLE_DESC) STD_STYLE_DESC,
       (SELECT COUNT(DISTINCT(A.PHY_CODE_MAX || A.PHY_CODE_MIN || A.PHY_CODE ||
                              A.ITEM_CODE_F || A.ITEM_CODE_W ||
                              A.ITEM_CODE_S))
          FROM COM_MSC_STD_PHY A
         WHERE A.PIC = P.PIC
           AND A.VALIDFLAG <> '0') COUNT,
       BAS.BASENAME BATCH_LOCA,
       P.IMPACT_ID
  FROM COM_MSC_STD_PIC P
  LEFT JOIN COM_PSC M
    ON P.PSC = M.PSC
  LEFT JOIN COM_MSC_BL D
    ON P.PSC = D.PSC_BL
  LEFT JOIN COM_BASE_INFO BAS
    ON P.BATCH_LOCA = BAS.BASECODE
 WHERE P.VALIDFLAG in ('1', '2', '3', '#VALIDFLAG#')
   AND DECODE('#STD_CODE_NK#', NULL, '1', P.STD_CODE_NK) =
       DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
   AND (STDSTYLE = 'G' OR STDSTYLE = 'X')
   AND UPPER(PIC) LIKE UPPER('#PIC#') || '%'
   AND DECODE('#MSC2#', NULL, '1', P.MSC) =
       DECODE('#MSC2#', NULL, '1', '#MSC2#')
   AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', P.CODE_JG) =
       DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', '#CODE_JG#')
   AND DECODE('#CODE_JG#', NULL, P.CODE_JG, NULL) IS NULL
	     ]]>
	  </query>

      <query id="ComMaterialStandard.QUERYOTHERC" desc="从表查询">
		<![CDATA[
SELECT PIC,
       INDEX_SEQ,
       PHY_CODE_MAX,
       PHY_NAME_MAX,
       PHY_CODE_MIN,
       PHY_NAME_MIN,
       PHY_CODE,
       PHY_NAME,
       ITEM_CODE_F,
       ITEM_NAME_F,
       ITEM_CODE_W,
       ITEM_NAME_W,
       ITEM_CODE_S,
       ITEM_NAME_S,
       RESULT_COUNT,
       DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       DECODE(ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
       DECODE(ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
       GROUP_SEQ,
       DECODE(PHY_TYPE, '1', 'TRUE', 'FALSE') PHY_TYPE,
       PHY_FORMULA,
       STDMIN_SIGN,
       STDMIN,
       STDMAX_SIGN,
       STDMAX,
       DECODE(JUDGE_BASIS,
              'A',
              '最小值',
              'B',
              '最大值',
              'C',
              '平均值',
              'D',
              '逐项值判') JUDGE_BASIS,
       DELIVERYSTATE,
       MODEL_CODE,
       MODEL_DESC,
       --后来添加的7个字段
       DECODE(ADDCONDITION, '1', '符合标准时', '0', '不符合标准时', '') ADDCONDITION,
       ADDSTDCON_CODE,
       ADDSTD_MIN_SIGN,
       ADDSTD_MIN,
       ADDSTD_MAX_SIGN,
       ADDSTD_MAX,
       ADDPERCENT,
       --后来添加的5个字段
       
       STDMIN_SIGN2,
       STDMIN2,
       STDMAX_SIGN2,
       STDMAX2,
       STD_CHOOSE,
       GUID,
       STDMEMO,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SPEC_JG,
       SPEC_JG_DESC,
       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', '有效', '无效') VALIDFLAGNAME,
       DECODE(BILLET_SAMPLE, '1', 'True', '0', 'False') BILLET_SAMPLE,
       FORMULA,
       MIN_F,
       MIN_F_SIGN,
       MAX_F,
       MAX_F_SIGN,
       PHY_MIN_SEQ,
       DECODE(A.IS_PRODUCT_CHECK, '1', 'True', 'False') IS_PRODUCT_CHECK
  FROM COM_MSC_STD_PHY A
 WHERE VALIDFLAG in ('1', '#VALIDFLAG#')
   AND EXISTS
 (SELECT 1
          FROM COM_MSC_STD_PIC B
         WHERE B.VALIDFLAG IN ('1', '2', '3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE_NK#', NULL, '1', B.STD_CODE_NK) =
               DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
           AND DECODE('#MSC#', NULL, '1', B.MSC) =
               DECODE('#MSC#', NULL, '1', '#MSC#')
           AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', B.CODE_JG) =
               DECODE('#CODE_JG#',
                      NULL,
                      '1',
                      'DefaultValue',
                      '1',
                      '#CODE_JG#')
           AND DECODE('#CODE_JG#', NULL, B.CODE_JG, NULL) IS NULL
           AND NVL(INSTR(B.PRODUCCODE_NK, '#PRODUCCODE#'), 1) > 0
           AND NVL(INSTR(B.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
           AND NVL(INSTR(B.PROCESS_CDOE, '#PROCESS_CDOE#'), 1) > 0
           AND NVL(INSTR(B.MODEL_CODE_NK, '#MODEL_CODE_NK#'), 1) > 0
           AND B.STDSTYLE NOT IN ('G', 'X') #WHERE#
           AND A.PIC = B.PIC)
 ORDER BY INDEX_SEQ
		]]>
	 </query>
	 
	  <query id="ComMaterialStandard.QUERYGC" desc="从表查询">
		<![CDATA[
SELECT PIC,
       INDEX_SEQ,
       PHY_CODE_MAX,
       PHY_NAME_MAX,
       PHY_CODE_MIN,
       PHY_NAME_MIN,
       PHY_CODE,
       PHY_NAME,
       ITEM_CODE_F,
       ITEM_NAME_F,
       ITEM_CODE_W,
       ITEM_NAME_W,
       ITEM_CODE_S,
       ITEM_NAME_S,
       RESULT_COUNT,
       DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       DECODE(ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
       DECODE(ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
       GROUP_SEQ,
       DECODE(PHY_TYPE, '1', 'TRUE', 'FALSE') PHY_TYPE,
       PHY_FORMULA,
       STDMIN_SIGN,
       STDMIN,
       STDMAX_SIGN,
       STDMAX,
       DECODE(JUDGE_BASIS,
              'A',
              '最小值',
              'B',
              '最大值',
              'C',
              '平均值',
              'D',
              '逐项值判') JUDGE_BASIS,
       DELIVERYSTATE,
       MODEL_CODE,
       MODEL_DESC,
       --后来添加的7个字段
       DECODE(ADDCONDITION, '1', '符合标准时', '0', '不符合标准时', '') ADDCONDITION,
       ADDSTDCON_CODE,
       ADDSTD_MIN_SIGN,
       ADDSTD_MIN,
       ADDSTD_MAX_SIGN,
       ADDSTD_MAX,
       ADDPERCENT,
       --后来添加的5个字段
       
       STDMIN_SIGN2,
       STDMIN2,
       STDMAX_SIGN2,
       STDMAX2,
       STD_CHOOSE,
       
       GUID,
       STDMEMO,
       SIZE_CODE2,
       SIZE_NAME2,
       SIZE_MIN_SIGN2,
       SIZE_MIN2,
       SIZE_MAX_SIGN2,
       SIZE_MAX2,
       SIZE_CODE,
       SIZE_NAME,
       SIZE_MIN_SIGN,
       SIZE_MIN,
       SIZE_MAX_SIGN,
       SIZE_MAX,
       SPEC_JG,
       SPEC_JG_DESC,
       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', '有效', '无效') VALIDFLAGNAME,
       DECODE(BILLET_SAMPLE, '1', 'True', 'False') BILLET_SAMPLE,
       FORMULA,
       MIN_F,
       MIN_F_SIGN,
       MAX_F,
       MAX_F_SIGN,
       PHY_MIN_SEQ
  FROM COM_MSC_STD_PHY A
 WHERE VALIDFLAG in ('1', '#VALIDFLAG#')
   AND EXISTS
 (SELECT 1
          FROM COM_MSC_STD_PIC B
         WHERE B.VALIDFLAG IN ('1', '2', '3', '#VALIDFLAG#')
           AND DECODE('#STD_CODE_NK#', NULL, '1', B.STD_CODE_NK) =
               DECODE('#STD_CODE_NK#', NULL, '1', '#STD_CODE_NK#')
           AND DECODE('#MSC#', NULL, '1', B.MSC) =
               DECODE('#MSC#', NULL, '1', '#MSC#')
           AND DECODE('#CODE_JG#', NULL, '1', 'DefaultValue', '1', B.CODE_JG) =
               DECODE('#CODE_JG#',
                      NULL,
                      '1',
                      'DefaultValue',
                      '1',
                      '#CODE_JG#')
           AND DECODE('#CODE_JG#', NULL, B.CODE_JG, NULL) IS NULL
           AND NVL(INSTR(B.PRODUCCODE_NK, '#PRODUCCODE#'), 1) > 0
           AND NVL(INSTR(B.STEELCODE_NK, '#STEELCODE_NK#'), 1) > 0
           AND B.STDSTYLE IN ('G', 'X')
           AND A.PIC = B.PIC)
 ORDER BY INDEX_SEQ
		]]>
	 </query>
		
	 <query id="ComMaterialStandard.ADD" desc="主表增加 ">
        <![CDATA[      
         INSERT INTO COM_MSC_STD_PIC
                    (
                     PIC,
                     PSC,
                     STDSTYLE,
                     STD_CODE_NK,
                     STD_NAME_NK,
                     PROCESS_CDOE,
                     PROCESS_DESC,
                     CREATE_NAME,
                     CREATE_TIME,
                     VALIDFLAG,
                     MEMO,
                     MSC,
                     MODEL_CODE,
                     MODEL_DESC,
                     PRODUC_HEAD,
                     CODE_JG,
                     STEELCODE,
                     STEELNAME,
                     GRADECODE,
                     GRADENAME,
                     BATCH_LOCA,
                     STEELCODE_NK,
                     STEELNAME_NK,
                     MODEL_CODE_NK,
                     MODEL_DESC_NK,
                     PRODUCCODE_NK,
                     PRODUCNAME_NK,
                     IMPACT_ID,
                     STRETCH_PLAN)
              VALUES(?,?,?,?,?,?,?,?,SYSDATE,DEFAULT,?,?,?,?,?,?,?,?,?,?, ?,
              ?, ?, ?, ?, ?, ?, ?, ?)
        
	     ]]>
	  </query>

	<query id="ComMaterialStandard.DeleteTemplate" desc=" 模板删除 ">
		<![CDATA[
		DELETE COM_MSC_STD_PHY_TEMPLATE WHERE ID = '#ID#'
	   ]]>
	</query>

	<query id="ComMaterialStandard.SaveTemplate" desc=" 模板增加 ">
        <![CDATA[
INSERT INTO COM_MSC_STD_PHY_TEMPLATE
  (INDEX_SEQ,
   PHY_CODE_MAX,
   PHY_NAME_MAX,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   PHY_CODE,
   PHY_NAME,
   ITEM_CODE_F,
   ITEM_NAME_F,
   ITEM_CODE_W,
   ITEM_NAME_W,
   ITEM_CODE_S,
   ITEM_NAME_S,
   ISCHECK,
   ISJUDGE,
   ISQUOTE,
   PHY_TYPE,
   PHY_FORMULA,
   STDMIN_SIGN,
   STDMIN,
   STDMAX_SIGN,
   STDMAX,
   JUDGE_BASIS,
   DELIVERYSTATE,
   MODEL_CODE,
   MODEL_DESC,
   STDMEMO,
   SIZE_CODE2,
   SIZE_NAME2,
   SIZE_MIN_SIGN2,
   SIZE_MIN2,
   SIZE_MAX_SIGN2,
   SIZE_MAX2,
   SIZE_CODE,
   SIZE_NAME,
   SIZE_MIN_SIGN,
   SIZE_MIN,
   SIZE_MAX_SIGN,
   SIZE_MAX,
   SPEC_JG,
   SPEC_JG_DESC,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   VALIDFLAG,
   RESULT_COUNT,
   ADDCONDITION,
   ADDSTDCON_CODE,
   ADDSTD_MIN_SIGN,
   ADDSTD_MIN,
   ADDSTD_MAX_SIGN,
   ADDSTD_MAX,
   ADDPERCENT,
   STDMIN_SIGN2,
   STDMIN2,
   STDMAX_SIGN2,
   STDMAX2,
   STD_CHOOSE,
   GUID,
   BILLET_SAMPLE,
   GROUP_SEQ,
   FORMULA,
   MIN_F,
   MIN_F_SIGN,
   MAX_F,
   MAX_F_SIGN,
   IS_PRODUCT_CHECK)
VALUES
  (
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   SYSDATE,
   '',
   NULL,
   '',
   NULL,
   DEFAULT,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?)
	     ]]>
	  </query>
	  
	  
	  <query id="ComMaterialStandard.UPDATE" desc="主表修改 ">
        <![CDATA[      
              UPDATE COM_MSC_STD_PIC
                 SET
                     PIC = ?,
                     PSC = ?,
                     STDSTYLE = ?,
                     STD_CODE_NK = ?,
                     STD_NAME_NK = ?,
                     PROCESS_CDOE = ?,
                     PROCESS_DESC = ?,
                     UPDATE_NAME = ?,
                     UPDATE_TIME = SYSDATE,
                     MEMO = ?,
                     MSC=?,
                     MODEL_CODE=?,
                     MODEL_DESC=?,
                     PRODUC_HEAD=?,
                     CODE_JG = ?,
                     STEELCODE=?,
                     STEELNAME=?,
                     GRADECODE=?,
                     GRADENAME=?,
                     BATCH_LOCA = ?,
                     STEELCODE_NK = ?,
                     STEELNAME_NK = ?,
                     MODEL_CODE_NK = ?,
                     MODEL_DESC_NK = ?,
                     PRODUCCODE_NK = ?,
                     PRODUCNAME_NK = ?,
                     IMPACT_ID = ?,
                     STRETCH_PLAN = ?
               WHERE PIC = ?
	     ]]>
	  </query>
	    
	  <query id="ComMaterialStandard.UPDATE1" desc="从表修改">
        <![CDATA[
UPDATE COM_MSC_STD_PHY
   SET PIC             = ?,
       INDEX_SEQ       = ?,
       PHY_CODE_MAX    = ?,
       PHY_NAME_MAX    = ?,
       PHY_CODE_MIN    = ?,
       PHY_NAME_MIN    = ?,
       PHY_CODE        = ?,
       PHY_NAME        = ?,
       ITEM_CODE_F     = ?,
       ITEM_NAME_F     = ?,
       ITEM_CODE_W     = ?,
       ITEM_NAME_W     = ?,
       ITEM_CODE_S     = ?,
       ITEM_NAME_S     = ?,
       ISCHECK         = ?,
       ISJUDGE         = ?,
       ISQUOTE         = ?,
       PHY_TYPE        = ?,
       PHY_FORMULA     = ?,
       STDMIN_SIGN     = ?,
       STDMIN          = ?,
       STDMAX_SIGN     = ?,
       STDMAX          = ?,
       JUDGE_BASIS     = ?,
       DELIVERYSTATE   = ?,
       MODEL_CODE      = ?,
       MODEL_DESC      = ?,
       STDMEMO         = ?,
       SIZE_CODE2      = ?,
       SIZE_NAME2      = ?,
       SIZE_MIN_SIGN2  = ?,
       SIZE_MIN2       = ?,
       SIZE_MAX_SIGN2  = ?,
       SIZE_MAX2       = ?,
       SIZE_CODE       = ?,
       SIZE_NAME       = ?,
       SIZE_MIN_SIGN   = ?,
       SIZE_MIN        = ?,
       SIZE_MAX_SIGN   = ?,
       SIZE_MAX        = ?,
       SPEC_JG         = ?,
       SPEC_JG_DESC    = ?,
       UPDATE_NAME     = ?,
       UPDATE_TIME     = SYSDATE,
       RESULT_COUNT    = ?,
       ADDCONDITION    = ?,
       ADDSTDCON_CODE  = ?,
       ADDSTD_MIN_SIGN = ?,
       ADDSTD_MIN      = ?,
       ADDSTD_MAX_SIGN = ?,
       ADDSTD_MAX      = ?,
       ADDPERCENT      = ?,
       STDMIN_SIGN2    = ?,
       STDMIN2         = ?,
       STDMAX_SIGN2    = ?,
       STDMAX2         = ?,
       STD_CHOOSE      = ?,
       GUID            = ?,
       BILLET_SAMPLE   = ?,
       GROUP_SEQ       = ?,
       FORMULA         = ?,
       MIN_F           = ?,
       MIN_F_SIGN      = ?,
       MAX_F           = ?,
       MAX_F_SIGN      = ?,
       IS_PRODUCT_CHECK = ?
 WHERE PIC = ?
   AND INDEX_SEQ = ?
	     ]]>
	  </query>
	  
	  
	  <query id="ComMaterialStandard.DELETE" desc="主表刪除">
        <![CDATA[
       UPDATE COM_MSC_STD_PIC SET VALIDFLAG=?,DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE PIC = ?  AND VALIDFLAG = '1'
	     ]]>
	  </query>
	  
	    <query id="ComMaterialStandard.RESUME" desc="主表恢復">
        <![CDATA[
       UPDATE COM_MSC_STD_PIC SET VALIDFLAG=?,DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE PIC = ?   AND VALIDFLAG = '0'
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.DELETE1" desc="从表刪除">
        <![CDATA[
       UPDATE COM_MSC_STD_PHY SET VALIDFLAG=?,DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE PIC = ? AND INDEX_SEQ = ?  AND VALIDFLAG='1' 
       AND (SELECT VALIDFLAG FROM COM_MSC_STD_PIC WHERE PIC = ? ) IN ('1', '0')
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.DELETE2" desc="从表全部刪除">
        <![CDATA[
       UPDATE COM_MSC_STD_PHY SET VALIDFLAG=?,DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE PIC = ?  AND VALIDFLAG='1'
	     ]]>
	  </query>
	  
	    <query id="ComMaterialStandard.RESUME1" desc="从表恢復">
        <![CDATA[
       UPDATE COM_MSC_STD_PHY SET VALIDFLAG=?,DELETE_NAME=?,DELETE_TIME=SYSDATE
       WHERE PIC = ? AND INDEX_SEQ = ?
	     ]]>
	  </query>
	  
	    <query id="ComMaterialStandard.GetPSC" desc="产品规范码">
        <![CDATA[
            SELECT PSC_DESC,
                   P.PSC,
                   P.PRODUCNAME,
                   DECODE(S.STDSTYLE,'G','订货标准','K','客户','X','协议标准','内控') STDSTYLE,
                   P.STD_NAME,
                   P.STEELNAME,
                   P.STD_STYLE_DESC
              FROM COM_PSC P LEFT JOIN COM_BASE_STD S ON  P.STD_CODE=S.STD_CODE
              WHERE S.STDSTYLE='G' OR S.STDSTYLE='X'
	     ]]>
	  </query>
	  
	 <query id="ComMaterialStandard.getComPicByPic" desc="通过Pic获取理化表">
        <![CDATA[
SELECT * FROM COM_MSC_STD_PIC T WHERE T.PIC = '#PIC#'
	     ]]>
	  </query>
	  <query id="ComMaterialStandard.getPurchaseAgreementPic" desc="获取采购的理化主表">
        <![CDATA[
SELECT P.PIC,
       P.PSC,
       P.MSC,
       DECODE(P.STDSTYLE,
              'G',
              '订货标准',
              'K',
              'Alpha',
              'X',
              '协议标准',
              '内控') STDSTYLE,
       P.STD_CODE_NK,
       P.STD_NAME_NK,
       P.PROCESS_CDOE,
       P.PROCESS_DESC,
       P.MODEL_CODE,
       P.MODEL_DESC,
       P.CREATE_NAME,
       TO_CHAR(P.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       P.UPDATE_NAME,
       TO_CHAR(P.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       P.DELETE_NAME,
       TO_CHAR(P.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(P.VALIDFLAG,
              '1',
              '录入状态',
              '0',
              '无效',
              '2',
              '提交审核',
              '3',
              '已审核') VALIDFLAGNAME,
       P.MEMO,
       M.PRODUCNAME, --内控下M表的数据无效 但为了dataset列名一致  保留
       M.STD_NAME,
       M.STD_CODE,
       P.STEELCODE,
       P.STEELNAME,
       P.GRADECODE,
       P.GRADENAME,
       M.STD_STYLE_DESC,
       (SELECT COUNT(DISTINCT(A.PHY_CODE_MAX || A.PHY_CODE_MIN || A.PHY_CODE ||
                              A.ITEM_CODE_F || A.ITEM_CODE_W ||
                              A.ITEM_CODE_S))
          FROM COM_MSC_STD_PHY A
         WHERE A.PIC = P.PIC
           AND A.VALIDFLAG <> '0') COUNT,
       P.STEELCODE_NK,
       P.STEELNAME_NK,
       P.MODEL_CODE_NK,
       P.MODEL_DESC_NK,
       P.PRODUCNAME_NK,
       P.PRODUCCODE_NK
  FROM COM_MSC_STD_PIC P
  LEFT JOIN COM_PSC M
    ON P.PSC = M.PSC, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = P.STD_CODE_NK
   AND P.VALIDFLAG = '1'
   AND P.STD_CODE_NK = {0}
	     ]]>
	  </query>
	  <query id="ComMaterialStandard.getPurchaseAgreementPhy" desc="获取采购的理化从表">
        <![CDATA[
SELECT A.PIC,
       A.INDEX_SEQ,
       A.PHY_CODE_MAX,
       A.PHY_NAME_MAX,
       A.PHY_CODE_MIN,
       A.PHY_NAME_MIN,
       A.PHY_CODE,
       A.PHY_NAME,
       A.ITEM_CODE_F,
       A.ITEM_NAME_F,
       A.ITEM_CODE_W,
       A.ITEM_NAME_W,
       A.ITEM_CODE_S,
       A.ITEM_NAME_S,
       A.RESULT_COUNT,
       DECODE(A.ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
       DECODE(A.ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
       DECODE(A.ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
       A.GROUP_SEQ,
       DECODE(A.PHY_TYPE, '1', 'TRUE', 'FALSE') PHY_TYPE,
       A.PHY_FORMULA,
       A.STDMIN_SIGN,
       A.STDMIN,
       A.STDMAX_SIGN,
       A.STDMAX,
       DECODE(A.JUDGE_BASIS,
              'A',
              '最小值',
              'B',
              '最大值',
              'C',
              '平均值',
              'D',
              '逐项值判') JUDGE_BASIS,
       A.DELIVERYSTATE,
       A.MODEL_CODE,
       A.MODEL_DESC,
       --后来添加的7个字段
       DECODE(A.ADDCONDITION, '1', '符合标准时', '0', '不符合标准时', '') ADDCONDITION,
       A.ADDSTDCON_CODE,
       A.ADDSTD_MIN_SIGN,
       A.ADDSTD_MIN,
       A.ADDSTD_MAX_SIGN,
       A.ADDSTD_MAX,
       A.ADDPERCENT,
       --后来添加的5个字段
       
       A.STDMIN_SIGN2,
       A.STDMIN2,
       A.STDMAX_SIGN2,
       A.STDMAX2,
       A.STD_CHOOSE,
       
       GUID,
       A.STDMEMO,
       A.SIZE_CODE2,
       A.SIZE_NAME2,
       A.SIZE_MIN_SIGN2,
       A.SIZE_MIN2,
       A.SIZE_MAX_SIGN2,
       A.SIZE_MAX2,
       A.SIZE_CODE,
       A.SIZE_NAME,
       A.SIZE_MIN_SIGN,
       A.SIZE_MIN,
       A.SIZE_MAX_SIGN,
       A.SIZE_MAX,
       A.SPEC_JG,
       A.SPEC_JG_DESC,
       A.CREATE_NAME,
       TO_CHAR(A.CREATE_TIME, 'yyyy-mm-dd hh24:mi:ss') CREATE_TIME,
       A.UPDATE_NAME,
       TO_CHAR(A.UPDATE_TIME, 'yyyy-mm-dd hh24:mi:ss') UPDATE_TIME,
       A.DELETE_NAME,
       TO_CHAR(A.DELETE_TIME, 'yyyy-mm-dd hh24:mi:ss') DELETE_TIME,
       DECODE(A.VALIDFLAG, '1', '有效', '无效') VALIDFLAGNAME
  FROM COM_MSC_STD_PHY A, COM_MSC_STD_PIC B, COM_BASE_STD C
 WHERE C.PURCHASE_STD = '1'
   AND C.VALIDFLAG = '1'
   AND C.STD_CODE = B.STD_CODE_NK
   AND B.VALIDFLAG = '1'
   AND A.PIC = B.PIC
   AND A.VALIDFLAG = '1'
   AND B.STD_CODE_NK = {0}
 ORDER BY INDEX_SEQ
	     ]]>
	  </query>
	  
	   <query id="ComMaterialStandard.setPhyMinSeq" desc="获取试样组序号">
        <![CDATA[
DECLARE
  P_SEQ INTEGER;
BEGIN
  UPDATE COM_MSC_STD_PHY T
     SET T.PHY_MIN_SEQ = NULL
   WHERE T.PIC = {0};
  FOR V IN (SELECT PHY_CODE_MIN, ITEM_CODE_F, ITEM_CODE_W, ITEM_CODE_S
              FROM (SELECT T.PHY_CODE_MIN,
                           T.ITEM_CODE_F,
                           T.ITEM_CODE_W,
                           T.ITEM_CODE_S,
                           MIN(T.INDEX_SEQ) INDEX_SEQ
                      FROM COM_MSC_STD_PHY T
                     WHERE T.PIC = {0}
                       AND T.VALIDFLAG = '1'
                     GROUP BY PHY_CODE_MIN,
                              ITEM_CODE_F,
                              ITEM_CODE_W,
                              ITEM_CODE_S)
             ORDER BY INDEX_SEQ) LOOP
    SELECT NVL(MAX(T.PHY_MIN_SEQ) + 1, 0)
      INTO P_SEQ
      FROM COM_MSC_STD_PHY T
     WHERE T.PIC = {0}
       AND T.PHY_CODE_MIN = V.PHY_CODE_MIN
       AND T.VALIDFLAG = '1';
    UPDATE COM_MSC_STD_PHY T
       SET T.PHY_MIN_SEQ = P_SEQ
     WHERE T.PIC = {0}
       AND T.PHY_CODE_MIN = V.PHY_CODE_MIN
       AND NVL(T.ITEM_CODE_F, '1') = NVL(V.ITEM_CODE_F, '1')
       AND NVL(T.ITEM_CODE_W, '1') = NVL(V.ITEM_CODE_W, '1')
       AND NVL(T.ITEM_CODE_S, '1') = NVL(V.ITEM_CODE_S, '1')
       AND T.VALIDFLAG = '1';
  END LOOP;
END;
	     ]]>
	  </query>


	<query id="ComMaterialStandard.QUERYGTEMPLATE" desc="主表查询">
		<![CDATA[
			SELECT '#PIC#' PIC FROM DUAL
			]]>
	</query>

	<query id="ComMaterialStandard.QUERYGTEMPLATEC" desc="从表查询">
		<![CDATA[
			SELECT
			   ID,
			   '#PIC#' PIC,
			   INDEX_SEQ,
			   PHY_CODE_MAX,
			   PHY_NAME_MAX,
			   PHY_CODE_MIN,
			   PHY_NAME_MIN,
			   PHY_CODE,
			   PHY_NAME,
			   ITEM_CODE_F,
			   ITEM_NAME_F,
			   ITEM_CODE_W,
			   ITEM_NAME_W,
			   ITEM_CODE_S,
			   ITEM_NAME_S,
			   RESULT_COUNT,
			   DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
			   DECODE(ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
			   DECODE(ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
			   GROUP_SEQ,
			   DECODE(PHY_TYPE, '1', 'TRUE', 'FALSE') PHY_TYPE,
			   PHY_FORMULA,
			   STDMIN_SIGN,
			   STDMIN,
			   STDMAX_SIGN,
			   STDMAX,
			   DECODE(JUDGE_BASIS,
					  'A',
					  '最小值',
					  'B',
					  '最大值',
					  'C',
					  '平均值',
					  'D',
					  '逐项值判') JUDGE_BASIS,
			   DELIVERYSTATE,
			   MODEL_CODE,
			   MODEL_DESC,
			   --后来添加的7个字段
			   DECODE(ADDCONDITION, '1', '符合标准时', '0', '不符合标准时', '') ADDCONDITION,
			   ADDSTDCON_CODE,
			   ADDSTD_MIN_SIGN,
			   ADDSTD_MIN,
			   ADDSTD_MAX_SIGN,
			   ADDSTD_MAX,
			   ADDPERCENT,
			   --后来添加的5个字段

			   STDMIN_SIGN2,
			   STDMIN2,
			   STDMAX_SIGN2,
			   STDMAX2,
			   STD_CHOOSE,

			   GUID,
			   STDMEMO,
			   SIZE_CODE2,
			   SIZE_NAME2,
			   SIZE_MIN_SIGN2,
			   SIZE_MIN2,
			   SIZE_MAX_SIGN2,
			   SIZE_MAX2,
			   SIZE_CODE,
			   SIZE_NAME,
			   SIZE_MIN_SIGN,
			   SIZE_MIN,
			   SIZE_MAX_SIGN,
			   SIZE_MAX,
			   SPEC_JG,
			   SPEC_JG_DESC,
			   DECODE(BILLET_SAMPLE, '1', 'True', 'False') BILLET_SAMPLE,
			   FORMULA,
			   MIN_F,
			   MIN_F_SIGN,
			   MAX_F,
			   MAX_F_SIGN,
			   PHY_MIN_SEQ
		  FROM COM_MSC_STD_PHY_TEMPLATE
			]]>
	</query>

	<query id="ComMaterialStandard.getComMaterialNK" desc="主表查询">
		<![CDATA[
			SELECT
				*
			FROM
				COM_MSC_STD_PIC
			WHERE
				VALIDFLAG = '1' and
				PIC IN (
				SELECT
					TO_CHAR(REGEXP_SUBSTR( PIC, '[^,]+', 1, LEVEL )) PIC
				FROM
					( SELECT WM_CONCAT ( PIC ) PIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = '#MSC#' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( PIC, ',' ) + 1
					AND MSC = PRIOR MSC
					AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
			)
		]]>
	</query>

	<query id="ComMaterialStandard.getComMaterialNKC" desc="从表查询">
		<![CDATA[
			SELECT
			   PIC,
			   INDEX_SEQ,
			   PHY_CODE_MAX,
			   PHY_NAME_MAX,
			   PHY_CODE_MIN,
			   PHY_NAME_MIN,
			   PHY_CODE,
			   PHY_NAME,
			   ITEM_CODE_F,
			   ITEM_NAME_F,
			   ITEM_CODE_W,
			   ITEM_NAME_W,
			   ITEM_CODE_S,
			   ITEM_NAME_S,
			   RESULT_COUNT,
			   DECODE(ISCHECK, '1', 'TRUE', 'FALSE') ISCHECK,
			   DECODE(ISJUDGE, '1', 'TRUE', 'FALSE') ISJUDGE,
			   DECODE(ISQUOTE, '1', 'TRUE', 'FALSE') ISQUOTE,
			   GROUP_SEQ,
			   DECODE(PHY_TYPE, '1', 'TRUE', 'FALSE') PHY_TYPE,
			   PHY_FORMULA,
			   STDMIN_SIGN,
			   STDMIN,
			   STDMAX_SIGN,
			   STDMAX,
			   DECODE(JUDGE_BASIS,
					  'A',
					  '最小值',
					  'B',
					  '最大值',
					  'C',
					  '平均值',
					  'D',
					  '逐项值判') JUDGE_BASIS,
			   DELIVERYSTATE,
			   MODEL_CODE,
			   MODEL_DESC,
			   --后来添加的7个字段
			   DECODE(ADDCONDITION, '1', '符合标准时', '0', '不符合标准时', '') ADDCONDITION,
			   ADDSTDCON_CODE,
			   ADDSTD_MIN_SIGN,
			   ADDSTD_MIN,
			   ADDSTD_MAX_SIGN,
			   ADDSTD_MAX,
			   ADDPERCENT,
			   --后来添加的5个字段

			   STDMIN_SIGN2,
			   STDMIN2,
			   STDMAX_SIGN2,
			   STDMAX2,
			   STD_CHOOSE,

			   GUID,
			   STDMEMO,
			   SIZE_CODE2,
			   SIZE_NAME2,
			   SIZE_MIN_SIGN2,
			   SIZE_MIN2,
			   SIZE_MAX_SIGN2,
			   SIZE_MAX2,
			   SIZE_CODE,
			   SIZE_NAME,
			   SIZE_MIN_SIGN,
			   SIZE_MIN,
			   SIZE_MAX_SIGN,
			   SIZE_MAX,
			   SPEC_JG,
			   SPEC_JG_DESC,
			   DECODE(BILLET_SAMPLE, '1', 'True', 'False') BILLET_SAMPLE,
			   FORMULA,
			   MIN_F,
			   MIN_F_SIGN,
			   MAX_F,
			   MAX_F_SIGN,
			   PHY_MIN_SEQ
		  FROM COM_MSC_STD_PHY
		  WHERE
		  VALIDFLAG = '1' and
				PIC IN (
				SELECT
					TO_CHAR(REGEXP_SUBSTR( PIC, '[^,]+', 1, LEVEL )) PIC
				FROM
					( SELECT WM_CONCAT ( PIC ) PIC, MSC FROM COM_MSC_PROCESS B WHERE B.MSC = '#MSC#' GROUP BY MSC ) CONNECT BY LEVEL <= REGEXP_COUNT ( PIC, ',' ) + 1
					AND MSC = PRIOR MSC
					AND PRIOR DBMS_RANDOM.VALUE IS NOT NULL
			)
			]]>
	</query>

	<query id="ComMaterialStandard.ADD1" desc=" 从表增加 ">
		<![CDATA[
INSERT INTO COM_MSC_STD_PHY
  (PIC,
   INDEX_SEQ,
   PHY_CODE_MAX,
   PHY_NAME_MAX,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   PHY_CODE,
   PHY_NAME,
   ITEM_CODE_F,
   ITEM_NAME_F,
   ITEM_CODE_W,
   ITEM_NAME_W,
   ITEM_CODE_S,
   ITEM_NAME_S,
   ISCHECK,
   ISJUDGE,
   ISQUOTE,
   PHY_TYPE,
   PHY_FORMULA,
   STDMIN_SIGN,
   STDMIN,
   STDMAX_SIGN,
   STDMAX,
   JUDGE_BASIS,
   DELIVERYSTATE,
   MODEL_CODE,
   MODEL_DESC,
   STDMEMO,
   SIZE_CODE2,
   SIZE_NAME2,
   SIZE_MIN_SIGN2,
   SIZE_MIN2,
   SIZE_MAX_SIGN2,
   SIZE_MAX2,
   SIZE_CODE,
   SIZE_NAME,
   SIZE_MIN_SIGN,
   SIZE_MIN,
   SIZE_MAX_SIGN,
   SIZE_MAX,
   SPEC_JG,
   SPEC_JG_DESC,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   VALIDFLAG,
   RESULT_COUNT,
   ADDCONDITION,
   ADDSTDCON_CODE,
   ADDSTD_MIN_SIGN,
   ADDSTD_MIN,
   ADDSTD_MAX_SIGN,
   ADDSTD_MAX,
   ADDPERCENT,
   STDMIN_SIGN2,
   STDMIN2,
   STDMAX_SIGN2,
   STDMAX2,
   STD_CHOOSE,
   GUID,
   BILLET_SAMPLE,
   GROUP_SEQ,
   FORMULA,
   MIN_F,
   MIN_F_SIGN,
   MAX_F,
   MAX_F_SIGN,
   IS_PRODUCT_CHECK)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   SYSDATE,
   '',
   NULL,
   '',
   NULL,
   DEFAULT,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?)
	     ]]>
	</query>
</queryMap>