<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="轧管工序合同 工艺设计检验项目确认">

	<query id="FrmMilConfirmItems.QueryPln_Order_Zg" desc="查询轧管工序合同">
		<![CDATA[
			SELECT PRO_ORDER_NO,
                   PLAN_GROUP_ID,
                   ORDER_SOURCE,
                   ORD_LN_DLY_PK,
                   PLN_DIVIDE_ID,
                   ORDER_NO,
                   ORDER_SEQ,
                   ORDER_NO || '/' || ORDER_SEQ ORDER_NO_SEQ ,
                   DELIVERY_NO,
                   REQ_BL_ID,
                   INDEX_SEQ,
                   BOM,
                   BACKLOG_SEQ,
                   STEELCODE,
                   STEELNAME,
                   OUTDIAMETER,
                   WALLTHICK,
                   AIMWALLTHICK,
                   LENGTHMAX,
                   LENGTHMIN,
                   AIMLENGTH,
                   OUTWL_ID,
                   ROLL_LENGTH,
                   OUT_LENGTH,
                   OUTNUM_SINGLE,
                   DIAMETER_GP,
                   LENGTH_GP,
                   INWL_GP,
                   WEIGHT_GP_ONE,
                   GETRATE,
                   PLINE_CODE_MAY,
                   PLINE_NAME_MAY,
                   PLINE_CODE,
                   PLINE_NAME,
                   ORDERWEIGHT,
                   ORDERNUM,
                   MATCH_WT,
                   MATCH_NUM,
                   IFBUYPLAN,
                   BUYPLANID,
                   BUYPLAN_WT,
                   REQ_PROD_WT,
                   REQ_PROD_NUM,
                   PROD_END_DATE,
                   ORDERSTATUS,
                   IS_PLANED,
                   PRO_PLAN_ID,
                   FINISHWEIGHT,
                   ISENDGX,
                   NEXT_GX,
                   IS_EXTRA_ORD,
                   IF_MONITOR_ZG,
                   PRDCR_NO,
                   CRAFT_FILE_NO,
                   CRAFT_FILE_MAN,
                   CREATE_NAME,
                   CREATE_TIME,
                   UPDATE_NAME,
                   UPDATE_TIME,
                   CRAFT_SEQ,
                   PASS_CODE,
                   PASS_NAME,
                   GO_TYPE,
                   DECODE(GO_TYPE, 'A', '轧制成品', 'B', '轧制半成品','C','镦拔扩及热处理') AS GO_TYPE_DESC,
                   PROCESS_CODE_C,
                   PROCESS_DESC_C,
                   STATION_ROAD,
                   CRAFT_NO_V,
                   BUYER_NAME,
                   FINAL_USER_DESC,
                   ORDER_ADD_DESC,
                   IS_CORRECT FLAG,
                   DECODE(IS_CORRECT, '00', '未确认', '10', '不成立','成立') AS FLAG_DESC
			  FROM PLN_ORDER_ZG
			 WHERE INSTR(?, IS_CORRECT) > 0
			   AND (CREATE_TIME BETWEEN TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AND TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))
			   AND STEELNAME LIKE '%' || ? || '%'
			   AND ORDER_NO LIKE '%' || ? || '%'
		]]>
	</query>

	<query id="FrmMilConfirmItems.UpdatePln_Order_Zg" desc="检验确认项目">
		<![CDATA[
            UPDATE PLN_ORDER_ZG
               SET IS_CORRECT = ?
             WHERE IS_CORRECT = ?
               AND PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryGetSampleReq" desc="查询工艺设计取样要求">
		<![CDATA[
            SELECT A.PHY_CODE PHY_CODE_MAX,
                   A.PHY_TYPE PHY_NAME_MAX,
                   T4.DESGIN_KEY,
                   T4.PIC,
                   T4.SIC,
                   T4.PHY_CODE_MIN,
                   T4.PHY_NAME_MIN,
                   T4.STD_CODE,
                   T4.STD_NAME,
                   T4.SAMPLE_STYLE,
                   DECODE(T4.SAMPLE_STYLE, '408101', '片状', '408102', '环状') AS DESC_SAMPLE_STYLE,
                   T4.LENGTH,
                   T4.DESC_LENGTH,
                   T4.WIDTH,
                   T4.RATE,
                   T4.DESC_RATE,
                   T4.BATCH_CNT,
                   T4.POSITION,
                   T4.DESC_POSITION,
                   T4.DESC_COUNT,
                   T4.SAMPLE_COUNT,
                   T4.MEMO
              FROM PLN_ORDER_ZG T1,
                   SLM_ORDER_LINE_DELIVERY T2,
                   CRAFT_ORD_DESIGN T3,
                   CRAFT_ORD_DESIGN_STD_PIC_SMP T4,
                   COM_BASE_PHY_B A,
                   COM_BASE_PHY_C B    
             WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
               AND T1.CRAFT_SEQ = T3.CRAFT_SEQ
               AND T2.ORD_LN_PK = T3.ORD_LN_PK
               AND T3.DESGIN_KEY = T4.DESGIN_KEY
               AND T4.PHY_CODE_MIN = B.PHY_CODE
               AND A.PHY_CODE = B.PHY_TYPE_M
               AND T3.VALIDFLAG = '1'
               AND T1.CRAFT_SEQ = ?
               AND T1.ORD_LN_DLY_PK = ?
          ORDER BY PHY_CODE_MIN
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryGetSampleReq_" desc="查询备份表取样要求">
		<![CDATA[
            SELECT T4.DESGIN_KEY,
                   T4.PIC,
                   T4.SIC,
                   T4.PHY_CODE_MIN,
                   T4.PHY_NAME_MIN,
                   T4.STD_CODE,
                   T4.STD_NAME,
                   T4.SAMPLE_STYLE,
                   DECODE(T4.SAMPLE_STYLE, '408101', '片状', '408102', '环状') AS DESC_SAMPLE_STYLE,
                   T4.LENGTH,
                   T4.DESC_LENGTH,
                   T4.WIDTH,
                   T4.RATE,
                   T4.DESC_RATE,
                   T4.BATCH_CNT,
                   T4.POSITION,
                   T4.DESC_POSITION,
                   T4.DESC_COUNT,
                   T4.SAMPLE_COUNT,
                   T4.MEMO,
                   T4.ADD_TYPE,
                   DECODE(T4.ADD_TYPE, '0', '工艺', '1', '人工') AS ADD_TYPE_DESC,
                   T4.DATA_TYPE,
                   DECODE(T4.DATA_TYPE, '0', '产品样', '1', '生产加样', '2', '科研样') AS DATA_TYPE_DESC,
                   A.PHY_CODE PHY_CODE_MAX,
                   A.PHY_TYPE PHY_NAME_MAX                 
              FROM PLN_ORDER_ZG T1,
                   SLM_ORDER_LINE_DELIVERY T2,
                   CRAFT_ORD_DESIGN T3,
                   PORT_CRAFT_ORD_DESIGNSTDPICSMP T4,
                   COM_BASE_PHY_B A,
                   COM_BASE_PHY_C B    
             WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
               AND T1.CRAFT_SEQ = T3.CRAFT_SEQ
               AND T2.ORD_LN_PK = T3.ORD_LN_PK
               AND T3.DESGIN_KEY = T4.DESGIN_KEY
               AND T4.PHY_CODE_MIN = B.PHY_CODE
               AND A.PHY_CODE = B.PHY_TYPE_M
               AND T3.VALIDFLAG = '1'
               AND T1.CRAFT_SEQ = ?
               AND T1.ORD_LN_DLY_PK = ?
          ORDER BY DATA_TYPE,PHY_CODE_MIN
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryGetSampleReqDetail_Phy" desc="查询合同理化检验项目明细">
		<![CDATA[
            SELECT DISTINCT
                   T4.*
              FROM PLN_ORDER_ZG T1,
                   SLM_ORDER_LINE_DELIVERY  T2,
                   CRAFT_ORD_DESIGN T3,
                   (SELECT *FROM (SELECT T.*,ROW_NUMBER() OVER(PARTITION BY DESGIN_KEY, PHY_CODE_MAX, PHY_CODE_MIN, PHY_CODE, ITEM_CODE_F, ITEM_CODE_W, ITEM_CODE_S ORDER BY SPECL_FL DESC) RN 
                                  FROM CRAFT_ORD_DESIGN_STD_PIC T) WHERE RN = 1) T4 
             WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
               AND T1.CRAFT_SEQ = T3.CRAFT_SEQ
               AND T2.ORD_LN_PK = T3.ORD_LN_PK
               AND T3.DESGIN_KEY = T4.DESGIN_KEY
               AND T3.VALIDFLAG = '1'
               AND T1.CRAFT_SEQ = ?
               AND T1.ORD_LN_DLY_PK = ?
          ORDER BY PHY_CODE_MIN
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryGetSampleReqDetail_Phy_" desc="查询备份表理化检验项目明细">
		<![CDATA[
            SELECT DISTINCT
                   T4.*
              FROM PLN_ORDER_ZG T1,
                   SLM_ORDER_LINE_DELIVERY  T2,
                   CRAFT_ORD_DESIGN T3,
                   PORT_CRAFT_ORD_DESIGN_STD_PIC T4 
             WHERE T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
               AND T1.CRAFT_SEQ = T3.CRAFT_SEQ
               AND T2.ORD_LN_PK = T3.ORD_LN_PK
               AND T3.DESGIN_KEY = T4.DESGIN_KEY
               AND T1.CRAFT_SEQ = ?
               AND T1.ORD_LN_DLY_PK = ?
          ORDER BY PHY_CODE_MIN
		]]>
	</query>

	<query id="FrmMilConfirmItems.ConfirmPhy" desc="检验确认项目">
		<![CDATA[
            INSERT INTO PORT_MIL_ORDER_CONFIRM_LOG
           (ORDER_NO,
            ORDER_SEQ,
            CONFIRM_NAME,
            CONFIRM_TIME,
            IS_CORRECT,
            REMARK)
            VALUES
            (?,?,?,SYSDATE,?,?)
		]]>
	</query>

	<query id="FrmMilConfirmItems.AddPortCraftStdPicSmp" desc="插入取样码备份表">
		<![CDATA[
            INSERT INTO PORT_CRAFT_ORD_DESIGNSTDPICSMP
           (DESGIN_KEY,
            PIC,
            SIC,
            PHY_CODE_MIN,
            PHY_NAME_MIN,
            STD_CODE,
            STD_NAME,
            LENGTH,
            DESC_LENGTH,
            RATE,
            DESC_RATE,
            DESC_COUNT,
            POSITION,
            DESC_POSITION,
            SAMPLE_COUNT,
            MEMO,
            SAMPLE_STYLE,
            BATCH_CNT,
            WIDTH)

            SELECT DESGIN_KEY,
                   PIC,
                   SIC,
                   PHY_CODE_MIN,
                   PHY_NAME_MIN,
                   STD_CODE,
                   STD_NAME,
                   LENGTH,
                   DESC_LENGTH,
                   RATE,
                   DESC_RATE,
                   DESC_COUNT,
                   POSITION,
                   DESC_POSITION,
                   SAMPLE_COUNT,
                   MEMO,
                   SAMPLE_STYLE,
                   BATCH_CNT,
                   WIDTH
              FROM CRAFT_ORD_DESIGN_STD_PIC_SMP
             WHERE DESGIN_KEY = ?
		]]>
	</query>

	<query id="FrmMilConfirmItems.AddPortCraftStdPicSmpSelect" desc="人工选择插入取样码备份表">
		<![CDATA[
            INSERT INTO PORT_CRAFT_ORD_DESIGNSTDPICSMP
           (DESGIN_KEY,
            PHY_CODE_MIN,
            PHY_NAME_MIN,
            SAMPLE_STYLE,
            DESC_SAMPLE_STYLE,
            LENGTH,
            DESC_LENGTH,
            RATE,
            DESC_RATE,           
            POSITION,
            DESC_POSITION,
            BATCH_CNT,
            DESC_COUNT,
            SAMPLE_COUNT,
            ADD_TYPE,
            DATA_TYPE)
            VALUES
            (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
		]]>
	</query>

	<query id="FrmMilConfirmItems.AddPortCraftStdPicSelect" desc="人工选择插入取样明细备份表">
		<![CDATA[
            INSERT INTO PORT_CRAFT_ORD_DESIGN_STD_PIC
           (DESGIN_KEY,
            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,
            RESULT_COUNT,
            GROUP_SEQ,
            
            STDMIN_SIGN,
            STDMIN,
            STDMAX_SIGN,
            STDMAX,
            JUDGE_BASIS,
            
            STD_CHOOSE,
            STDMIN_SIGN2,
            STDMIN2,
            STDMAX_SIGN2,
            STDMAX2,
            
            SIZE_CODE,
            SIZE_NAME,           
            SIZE_MIN_SIGN,
            SIZE_MIN,
            SIZE_MAX_SIGN,
            SIZE_MAX,
            
            SIZE_CODE2,
            SIZE_NAME2,           
            SIZE_MIN_SIGN2,
            SIZE_MIN2,
            SIZE_MAX_SIGN2,
            SIZE_MAX2,
            
            ADDCONDITION,
            ADDSTDCON_CODE,
            ADDPERCENT,           
            ADDSTD_MIN_SIGN,
            ADDSTD_MIN,
            ADDSTD_MAX_SIGN,
            ADDSTD_MAX,
            
            MODEL_CODE,
            MODEL_DESC,
            SPEC_JG,           
            SPEC_JG_DESC,
            DELIVERYSTATE,
            STDMEMO,
            ADD_TYPE,
            DATA_TYPE)
            VALUES
            (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
		]]>
	</query>

	<query id="FrmMilConfirmItems.AddPortCraftStdPic" desc="插入取样明细备份表">
		<![CDATA[
            INSERT INTO PORT_CRAFT_ORD_DESIGN_STD_PIC
           (DESGIN_KEY,
            PIC,
            USE_CODE,
            USE_DESC,
            SPECL_FL,
            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,
            GROUP_SEQ,
            ISCHECK,
            ISQUOTE,
            RESULT_COUNT,
            ISJUDGE,
            PHY_TYPE,
            PHY_FORMULA,
            STDMIN_SIGN,
            STDMIN,
            STDMAX_SIGN,
            STDMAX,
            JUDGE_BASIS,
            DELIVERYSTATE,
            MODEL_CODE,
            MODEL_DESC,
            STDMEMO,
            SIZE_CODE,
            SIZE_NAME,
            SIZE_MIN_SIGN,
            SIZE_MIN,
            SIZE_MAX_SIGN,
            SIZE_MAX,
            SIZE_CODE2,
            SIZE_NAME2,
            SIZE_MIN_SIGN2,
            SIZE_MIN2,
            SIZE_MAX_SIGN2,
            SIZE_MAX2,
            SPEC_JG,
            SPEC_JG_DESC,
            ADDCONDITION,
            ADDSTDCON_CODE,
            ADDSTD_MIN_SIGN,
            ADDSTD_MIN,
            ADDSTD_MAX_SIGN,
            ADDSTD_MAX,
            ADDPERCENT,
            STDMIN_SIGN2,
            STDMIN2,
            STDMAX_SIGN2,
            STDMAX2,
            STD_CHOOSE)

            SELECT DESGIN_KEY,
                   PIC,
                   USE_CODE,
                   USE_DESC,
                   SPECL_FL,
                   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,
                   GROUP_SEQ,
                   ISCHECK,
                   ISQUOTE,
                   RESULT_COUNT,
                   ISJUDGE,
                   PHY_TYPE,
                   PHY_FORMULA,
                   STDMIN_SIGN,
                   STDMIN,
                   STDMAX_SIGN,
                   STDMAX,
                   JUDGE_BASIS,
                   DELIVERYSTATE,
                   MODEL_CODE,
                   MODEL_DESC,
                   STDMEMO,
                   SIZE_CODE,
                   SIZE_NAME,
                   SIZE_MIN_SIGN,
                   SIZE_MIN,
                   SIZE_MAX_SIGN,
                   SIZE_MAX,
                   SIZE_CODE2,
                   SIZE_NAME2,
                   SIZE_MIN_SIGN2,
                   SIZE_MIN2,
                   SIZE_MAX_SIGN2,
                   SIZE_MAX2,
                   SPEC_JG,
                   SPEC_JG_DESC,
                   ADDCONDITION,
                   ADDSTDCON_CODE,
                   ADDSTD_MIN_SIGN,
                   ADDSTD_MIN,
                   ADDSTD_MAX_SIGN,
                   ADDSTD_MAX,
                   ADDPERCENT,
                   STDMIN_SIGN2,
                   STDMIN2,
                   STDMAX_SIGN2,
                   STDMAX2,
                   STD_CHOOSE
              FROM (SELECT *FROM (SELECT T.*,ROW_NUMBER() OVER(PARTITION BY DESGIN_KEY, PHY_CODE_MAX, PHY_CODE_MIN, PHY_CODE, ITEM_CODE_F, ITEM_CODE_W, ITEM_CODE_S ORDER BY SPECL_FL DESC) RN 
                                  FROM CRAFT_ORD_DESIGN_STD_PIC T) WHERE RN = 1) 
             WHERE ISCHECK = '1'
               AND DESGIN_KEY = ?
		]]>
	</query>

	<query id="FrmMilConfirmItems.DeletePortCraftStdPicSmp" desc="删除取样码备份表">
		<![CDATA[
            DELETE PORT_CRAFT_ORD_DESIGNSTDPICSMP
			 WHERE DESGIN_KEY = ?
		]]>
	</query>

	<query id="FrmMilConfirmItems.DeletePortCraftStdPic" desc="删除取样明细备份表">
		<![CDATA[
            DELETE PORT_CRAFT_ORD_DESIGN_STD_PIC
			 WHERE DESGIN_KEY = ?
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryPhyMaxItems" desc="查询理化项目大类信息">
		<![CDATA[
			SELECT PHY_CODE PHY_CODE_MAX,
			       PHY_TYPE PHY_NAME_MAX,
			       'FALSE' CHK
			  FROM COM_BASE_PHY_B 
			 WHERE VALIDFLAG = '1'	
			 ORDER BY PHY_CODE	
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryPhySampleCode" desc="查询取样码">
		<![CDATA[
			SELECT PHY_TYPE_M PHY_CODE_MAX,
			       PHY_CODE PHY_CODE_MIN,
			       PHY_TYPE PHY_NAME_MIN,
			       'FALSE' CHK
			  FROM COM_BASE_PHY_C 
			 WHERE VALIDFLAG = '1'
		  ORDER BY PHY_CODE_MAX,PHY_CODE
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryPhyMinItems" desc="查询理化项目小类信息">
		<![CDATA[
			SELECT PHY_TYPE PHY_CODE_MAX,
			       PHY_CODE,
			       PHY_NAME,
			       PHY_UNIT,
			       'FALSE' CHK
			  FROM COM_BASE_PHY 
			 WHERE VALIDFLAG = '1'
		  ORDER BY PHY_TYPE,PHY_NAME
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryPhyRItems_All" desc="查询理化项目关联方向温度尺寸信息">
		<![CDATA[
			SELECT T.PHY_TYPE PHY_CODE_MAX,
			       T.PHY_CODE PHY_CODE,
			       T.PHY_NAME PHY_NAME,			
			       T.ITEM_CODE_F,
			       T.ITEM_CODE_F ITEM_NAME_F,
			       T.ITEM_CODE_W,
			       T.ITEM_CODE_W ITEM_NAME_W,
			       T.ITEM_CODE_C,
			       T.ITEM_CODE_C ITEM_NAME_C		
			  FROM COM_BASE_PHY_R_ITEM T
			 WHERE T.VALIDFLAG = '1'
		  ORDER BY PHY_TYPE,PHY_CODE
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryPhyRItems" desc="查询理化项目关联方向温度尺寸信息">
		<![CDATA[
			SELECT T.PHY_TYPE PHY_CODE_MAX,
			       T.PHY_CODE PHY_CODE,
			       T.PHY_NAME PHY_NAME,			
			       T.ITEM_CODE_F,
			       T.ITEM_CODE_F ITEM_NAME_F,
			       T.ITEM_CODE_W,
			       T.ITEM_CODE_W ITEM_NAME_W,
			       T.ITEM_CODE_C,
			       T.ITEM_CODE_C ITEM_NAME_C,
			       'FALSE' CHK			
			  FROM COM_BASE_PHY_R_ITEM T
			 WHERE T.VALIDFLAG = '1'
			   AND PHY_TYPE = ?
			   AND PHY_CODE = ?
		  ORDER BY PHY_TYPE,PHY_CODE
		]]>
	</query>

	<query id="FrmMilConfirmItems.QueryPhyItems" desc="查询理化项目检验补充项信息">
		<![CDATA[
			SELECT ITEM_CODE, 
			       ITEM_NAME 
			  FROM COM_BASE_PHY_ITEM T WHERE T.ITEM_STYLE = ?
		]]>
	</query>

	<query id="FrmMilConfirmItems.GetBaseData" desc="基础数据">
		<![CDATA[ 
		    SELECT T.BASENAME,T.BASECODE 
		      FROM COM_BASE_INFO T
		     WHERE T.VALIDFLAG = '1' 
		       AND T.SORTCODE = ?
		]]>
	</query>

</queryMap>