<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="公共计划查询">
	<query id="PlanService.HeatTreatme.GetSingleRclPlan" desc="热处理计划简单查询">
        <![CDATA[
      SELECT T3.*,
       TO_NUMBER(T3.IN_NUM) - TO_NUMBER(T3.PRO_NUM) MATERIAL_COUNT,
       TO_NUMBER(T3.IN_WT) - TO_NUMBER(T3.PRO_WT) MATERIAL_WT　
  FROM (SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO ORDER_NO_SEQ,
               T.HEAT_PLAN_NO,
               T2.HEAT_PLAN_SQE,
               T.PROCESS_DESC_C,
               T.FEED_HEAT_NO,
               T.ZY_BATCH_ID,            
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.PLINE_CODE,
               T.OUTNUM_CUT,
               T.PLINE_NAME,
               T.UPPER_HEATPLAN_ID,
               T.JUDGE_STOVE_NO,
               T2.BATCH_NO,
               T2.BATCH_GROUD_NO,
               T2.JUGDE_APPLY_CODE,
               T.NEXT_PROCESS_CODE,
               DECODE(T.ISENDGX,'0','否','1','是','否') ISENDGX,
               T.ORDER_SOURCE,
               T.ORD_LN_DLY_PK,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.DELIVERY_NO,
               T.REQ_BL_ID,
               T.GRADECODE,
               T.GRADENAME,
               T.OUTDIAMETER_IN,
               T.WALLTHICK_IN,
               T.LENGTH_IN,
               T.LENGTHMAX_IN,
               T.LENGTHMIN_IN,
               --T.LENGTH_OUT,
               T.INWL_ID,
               T.INWL_DESC,
                t.PROCESS_SEQ,
               NVL(T2.PLAN_INDOUBLE_WT, 0) IN_WT,
               NVL(T2.PLAN_INDOUBLE_NUM, 0) IN_NUM,
               DECODE(T.IF_MATCH_ODD,'1','是','0','否','否') IF_WL_MATCHED,
               T.OUTWL_ID,
               T.OUTWL_DESC,
              -- NVL(T.OUT_WT, 0) OUT_WT,
             --  NVL(T.OUT_NUM, 0) OUT_NUM,
               DECODE(T.IF_MONITOR,'0','否','1','是','否') IF_MONITOR_RCL,
               T.MONITOR_POINT,
               T.CRAFT_FILE_MAN,
               T.CRAFT_SEQ,
               T.STATION_ROAD,
               NVL(T2.Real_Indouble_Wt, 0) IN_WT_REAL,
               NVL(T2.Real_Indouble_Num, 0) IN_NUM_REAL,
               --NVL(T2.Real_Outdouble_Wt, 0) OUT_WT_REAL,
               --NVL(T2.Real_Outdouble_Num, 0) OUT_NUM_REAL,
               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,
               DECODE(T.PLANSTATUS,
                      '00',
                      '计划',
                      '10',
                      '下发',
                      '20',
                      '生产中',
                      '30',
                      '生产完成',
                      '40',
                      '关闭') PLANSTATUS,
               T.CRAFT_FILE_NO,
                --DECODE(T2.IS_ONLOAD_LINE, '1', '是', '0', '否', '否') IS_ONLOAD_LINE,
               --T2.GX_PRO_SEQ,
               T.PRDCR_NO,
               NVL(T2.REAL_INDOUBLE_NUM,0) PRO_NUM,
               NVL(T2.REAL_INDOUBLE_WT,0) PRO_WT,
               T2.REAL_OUTDOUBLE_NUM OUT_NUM_REAL,
               T2.REAL_OUTDOUBLE_WT OUT_WT_REAL,
               --(SELECT NVL(SUM(T1.PRO_NUM), 0) FROM HTT_LOADING_RESULT T1
                -- WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_NUM,
              -- (SELECT NVL(SUM(T1.PRO_WT), 0)
                --  FROM HTT_LOADING_RESULT T1
               --  WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_WT,
               NVL((SELECT SUM(M.ACT_COUNT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                     AND nvl(M.JUGDE_APPLY_CODE,'/') = nvl(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
                     --     AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
   --AND STORAGE_ATTR = '800302'
    AND M.NEXT_PROCESS_CDOE = 'F'
     ),
                   0) ACT_COUNT,
               NVL((SELECT SUM(M.ACT_WEIGHT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                     AND nvl(M.JUGDE_APPLY_CODE,'/') = nvl(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
                    --      AND  B.MANAGEMENT_NO IN
    --   (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
 --  AND STORAGE_ATTR = '800302'
  AND M.NEXT_PROCESS_CDOE = 'F'
                     ),
                   0) ACT_WEIGHT,
                   DECODE(T.BESIDE_STATUS,
                      '00',
                      '上料结炉',
                      '10',
                      '高温结炉',
                      '20',
                      '淬火结炉',
                      '30',
                      '低温结炉',
                      '40',
                      '定径结炉',
                      '50',
                      '热矫结炉',
                      '60',
                      '冷矫结炉',
                      '70',
                      '检验结炉',
                      '80',
                      '探伤结炉',
                      '90',
                      '交库结炉') BESIDE_STATUS,
               DECODE(T.PER_STATUS,
                      '00',
                      '上料开始',
                      '10',
                      '高温开始',
                      '20',
                      '淬火开始',
                      '30',
                      '低温开始',
                      '40',
                      '定径开始',
                      '50',
                      '热矫开始',
                      '60',
                      '冷矫开始',
                      '70',
                      '检验开始',
                      '80',
                      '探伤开始',
                      '90',
                      '交库开始') PER_STATUS
          FROM PLN_ZY_RCL_M T,PLN_ZY_RCL_C T2
         WHERE  t.heat_plan_no=t2.heat_plan_no
           
        ]]>
	</query>

	

	<query id="PlanService.HeatTreatme.GetNewRclPla1" desc="热处理计划简单查询">
		<![CDATA[
          SELECT T.* ,  NVL(T.PLINE_CODE_W,T.PLINE_CODE) PLINE_CODE, NVL(T.PLINE_NAME_W,T.PLINE_NAME) PLINE_NAME,
           (SELECT TO_CHAR(SUBSTR(WM_CONCAT(DISTINCT PHY_BATCH_NO), 1, 1000)) CYCLE_BATCH
               FROM PORT_HTT_BATCH_SAMPLE_RESULT A
               LEFT JOIN QCM_ZC_CHECKCONSIGN B
                 ON B.CHECK_NO = A.CHECK_NO
                AND B.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
                AND B.BATCH_NO = A.PHY_BATCH_NO
              WHERE B.CYCLES_FLAG = '1'
              AND (A.MAT_STATUS = '00' OR A.MAT_STATUS = '20')
              AND HEAT_PLAN_NO =T.HEAT_PLAN_NO) Cycle_Batch,
             ( SELECT DESIGN.CRAFT_FILE_LV2_F
  FROM CRAFT_ORD_DESIGN DESIGN,  PLN_SALEORD ORD
 WHERE ORD.ORD_LN_PK = DESIGN.ORD_LN_PK
   AND ORD.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
   AND DESIGN.CRAFT_SEQ = S.CRAFT_SEQ) SEC_CRAFT_FILE_NO
          @Columns
          FROM PLN_ZY_RCL_M T
          LEFT JOIN PLN_ORDER_RCL_S  S ON T.PRO_PLAN_ID = S.PRO_PLAN_ID AND T.GX_PLAN_NO = S.GX_PLAN_NO
        ]]>
	</query>
	<query id="PlanService.HeatTreatme.GetNewRclPlan" desc="热处理计划简单查询">
		<![CDATA[
          SELECT T.*,T2.*, NVL(T.PLINE_CODE_W,T.PLINE_CODE) PLINE_CODE, NVL(T.PLINE_NAME_W,T.PLINE_NAME) PLINE_NAME,
          (SELECT SUM(PRO_NUM)  FROM HTT_LOADING_RESULT WHERE  HEAT_PLAN_NO = T.HEAT_PLAN_NO AND HEAT_PLAN_SQE= T2.HEAT_PLAN_SQE)   PRO_COUNT,
          (SELECT SUM(PRO_WT)  FROM HTT_LOADING_RESULT WHERE  HEAT_PLAN_NO = T.HEAT_PLAN_NO AND HEAT_PLAN_SQE = T2.HEAT_PLAN_SQE)   PRO_WEIGHT,
               NVL((SELECT SUM(M.ACT_COUNT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                      AND NVL(M.JUGDE_APPLY_CODE,'/') = DECODE(REAL_PROCESS_SEQ,1,NVL(T2.JUGDE_APPLY_CODE,'/'),'/')
                      AND M.JUDGE_STOVE_NO = DECODE(REAL_PROCESS_SEQ,1,T.FEED_HEAT_NO,T.JUDGE_STOVE_NO)
                      AND NVL(M.BATCH_NO, '/') =DECODE(REAL_PROCESS_SEQ,1, NVL(T2.BATCH_NO, '/'), NVL(M.BATCH_NO, '/'))
                      AND NVL(M.BATCH_GROUD_NO, '/') =DECODE(REAL_PROCESS_SEQ,1,NVL(T2.BATCH_GROUD_NO, '/'), NVL(M.BATCH_GROUD_NO, '/'))
                      AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO
                     --     AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
   --AND STORAGE_ATTR = '800302'
    AND M.NEXT_PROCESS_CDOE = 'F'
     ),
                   0) ACT_COUNT,
               NVL((SELECT SUM(M.ACT_WEIGHT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                      AND NVL(M.JUGDE_APPLY_CODE,'/') = DECODE(REAL_PROCESS_SEQ,1,NVL(T2.JUGDE_APPLY_CODE,'/'),'/')
                      AND M.JUDGE_STOVE_NO = DECODE(REAL_PROCESS_SEQ,1,T.FEED_HEAT_NO,T.JUDGE_STOVE_NO)
                      AND NVL(M.BATCH_NO, '/') =DECODE(REAL_PROCESS_SEQ,1, NVL(T2.BATCH_NO, '/'), NVL(M.BATCH_NO, '/'))
                      AND NVL(M.BATCH_GROUD_NO, '/') =DECODE(REAL_PROCESS_SEQ,1,NVL(T2.BATCH_GROUD_NO, '/'), NVL(M.BATCH_GROUD_NO, '/'))
                       AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO
                    --      AND  B.MANAGEMENT_NO IN
    --   (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
 --  AND STORAGE_ATTR = '800302'
  AND M.NEXT_PROCESS_CDOE = 'F'
                     ),
                   0) ACT_WEIGHT,

                  GETLOADMATLOCATION_F(DECODE(REAL_PROCESS_SEQ,1,NVL(T2.JUGDE_APPLY_CODE,'/'),'/'),
                   DECODE(REAL_PROCESS_SEQ,1,T.FEED_HEAT_NO,T.JUDGE_STOVE_NO),
                   DECODE(REAL_PROCESS_SEQ,1, NVL(T2.BATCH_NO, '/'), '/'),
                   DECODE(REAL_PROCESS_SEQ,1,NVL(T2.BATCH_GROUD_NO, '/'), '/'),
                   T.HEAT_PLAN_NO)  PER_STATUS,
                   DECODE((SELECT FACTORY_CODE FROM com_base_pline WHERE PLINE_CODE=T.PLINE_CODE AND ROWNUM =1),'410507',DECODE(T.MODEL_CODE,'C040','1','0'),'0') MAT_SOURCE,
                   NVL((SELECT SUM(1)
  FROM MAT_BC_M M
 WHERE M.JUDGE_STOVE_NO = T.FEED_HEAT_NO
   AND (NVL(M.PRO_PLAN_ID_NEXT, '/') <> NVL(T.PRO_PLAN_ID, '/') OR
       NVL(M.GX_PLAN_NO_NEXT, '/') <> NVL(T.GX_PLAN_NO, '/'))
        AND QCM_STAUS ='00'
        AND M.PROCESS_CDOE NOT IN ('G','H')
       ),0) CAN_COUNT,
          ( SELECT DESIGN.CRAFT_FILE_LV2_F
  FROM CRAFT_ORD_DESIGN DESIGN,  PLN_SALEORD ORD
 WHERE ORD.ORD_LN_PK = DESIGN.ORD_LN_PK
   AND ORD.ORD_LN_DLY_PK = S.ORD_LN_DLY_PK
   AND DESIGN.CRAFT_SEQ = S.CRAFT_SEQ) SEC_CRAFT_FILE_NO,
   (SELECT CASE
         WHEN B3.BASENAME IS NOT NULL THEN
          '镦拔扩' || B3.BASENAME || '(' || B2.MEMO || ')'
         ELSE
          ''
       END || CASE
         WHEN C3.BASENAME IS NOT NULL THEN
          '轧管' || C3.BASENAME || '(' || C2.MEMO || ')'
         ELSE
          ''
       END || CASE
         WHEN D3.BASENAME IS NOT NULL THEN
          '炼钢' || D3.BASENAME || '(' || D2.MEMO || ')'
         ELSE
          ''
       END
  FROM QCM_ZG_JUGDE_APPLY A
  LEFT JOIN QCM_BC_PASS_APPLY B2
    ON B2.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND B2.BATCH_NO = A.BATCH_NO
   AND B2.JUGDE_APPLY_CODE = A.JUGDE_APPLY_CODE
   AND B2.TYPE = '0'
   AND B2.VALIDFLAG = '1'
  LEFT JOIN COM_BASE_INFO B3
    ON B3.BASECODE = B2.AUDIT_RESULT
  LEFT JOIN QCM_ZG_JUGDE_APPLY C
    ON C.JUDGE_STOVE_NO = A.LOAD_JUDGE_STOVE_NO
   AND C.BATCH_NO = A.LOAD_BATCH_NO
   AND C.IS_FLAG = '0'
   AND C.IS_ALL_SCRAP IN ('0', '4', '5')
   AND C.PROCESS_CODE = 'D'
  LEFT JOIN QCM_BC_PASS_APPLY C2
    ON C2.JUDGE_STOVE_NO = C.JUDGE_STOVE_NO
   AND C2.BATCH_NO = C.BATCH_NO
   AND C2.JUGDE_APPLY_CODE = C.JUGDE_APPLY_CODE
   AND C2.TYPE = '0'
   AND C2.VALIDFLAG = '1'
  LEFT JOIN COM_BASE_INFO C3
    ON C3.BASECODE = C2.AUDIT_RESULT
  LEFT JOIN QCM_GP_JUDGE_APPLY D
    ON D.JUDGE_STOVE_NO = C.LOAD_JUDGE_STOVE_NO
   AND D.IS_FLAG = '0'
   AND D.IS_ALL_SCRAP = '0'
  LEFT JOIN QCM_GP_PASS_APPLY D2
    ON D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
   AND D2.JUGDE_APPLY_CODE = D.JUGDE_APPLY_CODE
   AND D2.VALIDFLAG = '1'
  LEFT JOIN COM_BASE_INFO D3
    ON D3.BASECODE = D2.AUDIT_RESULT2
 WHERE A.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND A.BATCH_NO =  T2.BATCH_NO
   AND A.JUGDE_APPLY_CODE = T2.JUGDE_APPLY_CODE
   AND A.IS_FLAG = '0'
   AND A.IS_ALL_SCRAP IN ('0', '4', '5')
   AND A.PROCESS_CODE = 'E'
   AND ROWNUM =1
UNION ALL
SELECT CASE
         WHEN C3.BASENAME IS NOT NULL THEN
          '轧管' || C3.BASENAME || '(' || C2.MEMO || ')'
         ELSE
          ''
       END || CASE
         WHEN D3.BASENAME IS NOT NULL THEN
          '炼钢' || D3.BASENAME || '(' || D2.MEMO || ')'
         ELSE
          ''
       END
  FROM QCM_ZG_JUGDE_APPLY A
  LEFT JOIN QCM_BC_PASS_APPLY C2
    ON C2.JUDGE_STOVE_NO = A.JUDGE_STOVE_NO
   AND C2.BATCH_NO = A.BATCH_NO
   AND C2.JUGDE_APPLY_CODE = A.JUGDE_APPLY_CODE
   AND C2.TYPE = '0'
   AND C2.VALIDFLAG = '1'
  LEFT JOIN COM_BASE_INFO C3
    ON C3.BASECODE = C2.AUDIT_RESULT
  LEFT JOIN QCM_GP_JUDGE_APPLY D
    ON D.JUDGE_STOVE_NO = A.LOAD_JUDGE_STOVE_NO
   AND D.IS_FLAG = '0'
   AND D.IS_ALL_SCRAP = '0'
  LEFT JOIN QCM_GP_PASS_APPLY D2
    ON D2.JUDGE_STOVE_NO = D.JUDGE_STOVE_NO
   AND D2.JUGDE_APPLY_CODE = D.JUGDE_APPLY_CODE
   AND D2.VALIDFLAG = '1'
  LEFT JOIN COM_BASE_INFO D3
    ON D3.BASECODE = D2.AUDIT_RESULT2
 WHERE A.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND A.BATCH_NO = T2.BATCH_NO
   AND A.JUGDE_APPLY_CODE = T2.JUGDE_APPLY_CODE
   AND A.IS_FLAG = '0'
   AND A.IS_ALL_SCRAP IN ('0', '4', '5')
   AND A.PROCESS_CODE = 'D'
   AND ROWNUM =1
)  PLANSTATUS_GX
          FROM PLN_ZY_RCL_M T
           LEFT JOIN PLN_ORDER_RCL_S  S ON T.PRO_PLAN_ID = S.PRO_PLAN_ID AND T.GX_PLAN_NO = S.GX_PLAN_NO
			,PLN_ZY_RCL_C T2
         WHERE  t.heat_plan_no=t2.heat_plan_no
        ]]>
	</query>


	<query id="PlanService.GetNewJGXPlanLoad" desc="加工线计划简单查询">
		<![CDATA[
     SELECT T.*,
        T.LENGTHDISC,
        (SELECT SUM(PRO_NUM)
           FROM MCH_LOADING_RESULT
          WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND BATCH_NO= T.BATCH_NO AND BATCH_GROUD_NO=T.BATCH_GROUD_NO) PRO_COUNT,
        (SELECT SUM(PRO_WT)
           FROM MCH_LOADING_RESULT
          WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND BATCH_NO= T.BATCH_NO AND BATCH_GROUD_NO =T.BATCH_GROUD_NO) PRO_WEIGHT,
            NVL((SELECT SUM(M.ACT_COUNT)
             FROM MAT_BC_M M, YDM_BC_BUTTRESS B
            WHERE M.MAT_NO = B.MAT_NO
              AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO
              AND M.PRODUCT_FLAG = '801401'
              AND M.MAT_STATUS = '80150103'
              AND (T.IF_MATCH_ODD = '5' OR(
               NVL(M.BATCH_NO, '/') =
                         NVL(T.BATCH_NO, '/')
              AND NVL(M.BATCH_GROUD_NO, '/') =
                         NVL(T.BATCH_GROUD_NO, '/')))),
           0) ACT_COUNT,
                NVL((SELECT SUM(M.ACT_WEIGHT)
             FROM MAT_BC_M M, YDM_BC_BUTTRESS B
            WHERE M.MAT_NO = B.MAT_NO
              AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO
              AND M.PRODUCT_FLAG = '801401'
              AND M.MAT_STATUS = '80150103'
              AND (T.IF_MATCH_ODD = '5' OR(
               NVL(M.BATCH_NO, '/') =
                         NVL(T.BATCH_NO, '/')
              AND NVL(M.BATCH_GROUD_NO, '/') =
                         NVL(T.BATCH_GROUD_NO, '/')))),
           0)  ACT_WEIGHT,
 GETLOADMATLOCATION_G('/','/',T.BATCH_NO,T.BATCH_GROUD_NO, T.HEAT_PLAN_NO,T.IF_MATCH_ODD)
               PER_STATUS,
             DECODE((SELECT C.FACTORY_CODE
             FROM MAT_BC_M M, YDM_BC_BUTTRESS B,COM_BASE_PLINE C
            WHERE M.MAT_NO = B.MAT_NO
              AND M.HEAT_PLAN_NO_NEXT = T.HEAT_PLAN_NO
              AND M.PLINE_CODE = C.PLINE_CODE
              AND M.PRODUCT_FLAG = '801401'
              AND M.MAT_STATUS = '80150103'
              AND  (T.IF_MATCH_ODD = '5' OR(
               NVL(M.BATCH_NO, '/') =
                         NVL(T.BATCH_NO, '/')
              AND NVL(M.BATCH_GROUD_NO, '/') =
                         NVL(T.BATCH_GROUD_NO, '/')))  AND ROWNUM =1)
                         ,'410505',
                          DECODE((SELECT FACTORY_CODE FROM com_base_pline WHERE PLINE_CODE=T.PLINE_CODE AND ROWNUM =1),'410507','1','2')
                        , '410506',
                                 DECODE((SELECT FACTORY_CODE FROM com_base_pline WHERE PLINE_CODE=T.PLINE_CODE AND ROWNUM =1),'410507','1','2')
                                 ,'410507','2' ,'0') MAT_SOURCE,
                                   T.FILE_PATH ,
       NVL((SELECT SUM(1)
             FROM MAT_BC_M M
            WHERE M.JUDGE_STOVE_NO = T.FEED_HEAT_NO
              AND (NVL(M.PRO_PLAN_ID_NEXT, '/') <> NVL(T.PRO_PLAN_ID, '/') OR
                  NVL(M.GX_PLAN_NO_NEXT, '/') <> NVL(T.GX_PLAN_NO, '/'))
                  AND M.PROCESS_CDOE NOT IN ('H')
              AND QCM_STAUS = '00'),
           0) CAN_COUNT
          @Columns
   FROM (SELECT T.HEAT_PLAN_NO HEAT_PLAN_NO,
                MAX(T.ZY_BATCH_ID) ZY_BATCH_ID,
                MAX(T.STOVE_NO) STOVE_NO,
                MAX(T.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
                T2.BATCH_NO,
                T2.BATCH_GROUD_NO,
                MAX(T.PLANSTATUS) PLANSTATUS,
                MAX(T2.PER_STATUS) PER_STATUS,
                MAX(T2.BESIDE_STATUS) BESIDE_STATUS,
                MAX(T.UPPER_HEATPLAN_ID) UPPER_HEATPLAN_ID,
                MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
                MAX(T.GX_PLAN_NO) GX_PLAN_NO,
                MAX(NVL(T2.PLINE_CODE_W,T2.PLINE_CODE)) PLINE_CODE,
                MAX(NVL(T2.PLINE_NAME_W,T2.PLINE_NAME)) PLINE_NAME,
                MAX(T.PROCESS_CODE_C) PROCESS_CODE_C,
                MAX(T.PROCESS_DESC_C) PROCESS_DESC_C,
                MAX(T.UPPER_PROCESS_CODE) UPPER_PROCESS_CODE,
                MAX(T.NEXT_PROCESS_CODE) NEXT_PROCESS_CODE,
                MAX(T.GOWHERE_CODE) GOWHERE_CODE,
                MAX(T.GOWHERE_NAME) GOWHERE_NAME,
                MAX(T.PROD_STANDARD) PROD_STANDARD,
                MAX(T.OUTPUT_STANDARD) OUTPUT_STANDARD,
                MAX(T.ISENDGX) ISENDGX,
                MAX(T.IF_MATCH_ODD) IF_MATCH_ODD,
                MAX(T.IF_DO_HEAT_PLAN) IF_DO_HEAT_PLAN,
                MAX(T.ORDER_SOURCE) ORDER_SOURCE,
                MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK,
                MAX(T.ORDER_NO) ORDER_NO,
                MAX(T.ORDER_SEQ) ORDER_SEQ,
                MAX(T.DELIVERY_NO) DELIVERY_NO,
                MAX(T.REQ_BL_ID) REQ_BL_ID,
                MAX(T.IF_EXPORT) IF_EXPORT,
                MAX(T.PRIORITY) PRIORITY,
                MAX(T.PRIORITY_MEMO) PRIORITY_MEMO,
                MAX(T.PRO_MONTH) PRO_MONTH,
                MAX(T.PRO_DAY) PRO_DAY,
                MAX(T.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
                MAX(T.IF_MONITOR) IF_MONITOR,
                MAX(T.PRDCR_NO) PRDCR_NO,
                MAX(T.MONITOR_POINT) MONITOR_POINT,
                MAX(T.MONITOR_MENT) MONITOR_MENT,
                MAX(T.MONITOR_MAN) MONITOR_MAN,
                MAX(T.BOM) BOM,
                MAX(T.WHOLE_BACKLOG) WHOLE_BACKLOG,
                MAX(T.WHOLE_BACKLOG_DESC) WHOLE_BACKLOG_DESC,
                MAX(T.STATION_ROAD) STATION_ROAD,
                MAX(T.CIC) CIC,
                MAX(T.PIC) PIC,
                MAX(T.SIC) SIC,
                MAX(T.DIC) DIC,
                MAX(T.WIC) WIC,
                MAX(T.GIC) GIC,
                MAX(T.CRAFT_FILE_NO) CRAFT_FILE_NO,
                MAX(T.CRAFT_SEQ) CRAFT_SEQ,
                MAX(T.CRAFT_FILE_MAN) CRAFT_FILE_MAN,
                MAX(T.SEC_CRAFT_FILE_NO) SEC_CRAFT_FILE_NO,
                MAX(T.INWL_ID) INWL_ID,
                MAX(T.INWL_DESC) INWL_DESC,
                MAX(T.OUTWL_ID) OUTWL_ID,
                MAX(T.OUTWL_DESC) OUTWL_DESC,
                MAX(T.STEELCODE) STEELCODE,
                MAX(T.STEELNAME) STEELNAME,
                MAX(T.GRADECODE) GRADECODE,
                MAX(T.GRADENAME) GRADENAME,
                MAX(T.PRODUCCODE) PRODUCCODE,
                MAX(T.PRODUCNAME) PRODUCNAME,
                MAX(T.MODEL_CODE) MODEL_CODE,
                MAX(T.MODEL_DESC) MODEL_DESC,
                MAX(T.OUTDIAMETER) OUTDIAMETER,
                MAX(T.WALLTHICK) WALLTHICK,
                MAX(T.LENGTHMIN) LENGTHMIN,
                MAX(T.LENGTHMAX) LENGTHMAX,
                MAX(T.OUTDIAMETER_IN) OUTDIAMETER_IN,
                MAX(T.WALLTHICK_IN) WALLTHICK_IN,
                MAX(T.OUTNUM_CUT) OUTNUM_CUT,
                MAX(T.LENGTH_IN) LENGTH_IN,
                MAX(T.LENGTHMAX_IN) LENGTHMAX_IN,
                MAX(T.LENGTHMIN_IN) LENGTHMIN_IN,
                MAX(T.PLN_INSINGLE_NUM) PLN_INSINGLE_NUM,
                MAX(T.PLN_INSINGLE_WT) PLN_INSINGLE_WT,
                MAX(T.PLN_INDOUBLE_NUM) PLN_INDOUBLE_NUM,
                MAX(T.PLN_INDOUBLE_WT) PLN_INDOUBLE_WT,
                MAX(T.PLN_OUTSINGLE_NUM) PLN_OUTSINGLE_NUM,
                MAX(T.PLN_OUTSINGLE_W) PLN_OUTSINGLE_W,
                MAX(T.PLN_OUTDOUBLE_NUM) PLN_OUTDOUBLE_NUM,
                MAX(T.PLN_OUTDOUBLE_W) PLN_OUTDOUBLE_W,
                MAX(T.CREATE_NAME) CREATE_NAME,
                MAX(T.CREATE_TIME) CREATE_TIME,
                MAX(T.UPDATE_NAME) UPDATE_NAME,
                MAX(T.UPDATE_TIME) UPDATE_TIME,
                MAX(T.DOWNMAN) DOWNMAN,
                MAX(T.DOWNTIME) DOWNTIME,
                MAX(T.INDEX_SEQ) INDEX_SEQ,
                MAX(T.GX_PRO_SEQ) GX_PRO_SEQ,
                MAX(T.SPEC_CODE) SPEC_CODE,
                MAX(T.SPEC_NAME) SPEC_NAME,
                MAX(T.STD_CODE) STD_CODE,
                MAX(T.STD_NAME) STD_NAME,
                MAX(T.STD_STYLE) STD_STYLE,
                MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
                MAX(T.DECISION) DECISION,
                MAX(T.FEED_HEAT_NO) FEED_HEAT_NO,
                MAX(T.FLAG_STOVE_NO) FLAG_STOVE_NO,
                MAX(T.MEMO) MEMO,
                MAX(T.ZY_BATCH_ID_ZG) ZY_BATCH_ID_ZG,
                MAX(T.HEAT_PLAN_NO_OLD) HEAT_PLAN_NO_OLD,
                MAX(T.IF_PRODUCT) IF_PRODUCT,
                MAX(S.GX_PRO_SEQ) GX_PRO_SEQ_ORDER,
                MAX(S.LENGTHDISC) LENGTHDISC,
                MAX(T.FILE_PATH)  FILE_PATH
           FROM PLN_ZY_JGX_M T
           LEFT JOIN PLN_ORDER_JGX_S S
             ON T.PRO_PLAN_ID = S.PRO_PLAN_ID
            AND T.GX_PLAN_NO = S.GX_PLAN_NO, PLN_ZY_JGX_C T2
          WHERE T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
         @Where
          GROUP BY T.HEAT_PLAN_NO, T2.BATCH_NO,T2.BATCH_GROUD_NO) T
  ORDER BY PLINE_CODE,
           TO_NUMBER(GX_PRO_SEQ_ORDER),
           JUDGE_STOVE_NO,
           BATCH_NO,
           BATCH_GROUD_NO
            ASC
        ]]>
	</query>

	<query id="PlanService.GetNewRclPlanOther" desc="加工线计划简单查询">
		<![CDATA[
  SELECT T.*,
         S.LENGTHDISC,
        (SELECT SUM(PRO_NUM)
           FROM MCH_LOADING_RESULT
          WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND BATCH_NO=T.BATCH_NO ) PRO_COUNT,
        (SELECT SUM(PRO_WT)
           FROM MCH_LOADING_RESULT
          WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND BATCH_NO=T.BATCH_NO) PRO_WEIGHT
          @Columns
   FROM (SELECT T.HEAT_PLAN_NO HEAT_PLAN_NO,
                MAX(T.ZY_BATCH_ID) ZY_BATCH_ID,
                MAX(T.STOVE_NO) STOVE_NO,
                MAX(T.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
                T2.BATCH_NO,
                MAX(T.PLANSTATUS) PLANSTATUS,
                MAX(T2.PER_STATUS) PER_STATUS,
                MAX(T2.BESIDE_STATUS) BESIDE_STATUS,
                MAX(T.UPPER_HEATPLAN_ID) UPPER_HEATPLAN_ID,
                MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
                MAX(T.GX_PLAN_NO) GX_PLAN_NO,
                MAX(NVL(T2.PLINE_CODE_W,T2.PLINE_CODE)) PLINE_CODE,
                MAX(NVL(T2.PLINE_NAME_W,T2.PLINE_NAME)) PLINE_NAME,
                MAX(T.PROCESS_CODE_C) PROCESS_CODE_C,
                MAX(T.PROCESS_DESC_C) PROCESS_DESC_C,
                MAX(T.UPPER_PROCESS_CODE) UPPER_PROCESS_CODE,
                MAX(T.NEXT_PROCESS_CODE) NEXT_PROCESS_CODE,
                MAX(T.GOWHERE_CODE) GOWHERE_CODE,
                MAX(T.GOWHERE_NAME) GOWHERE_NAME,
                MAX(T.PROD_STANDARD) PROD_STANDARD,
                MAX(T.OUTPUT_STANDARD) OUTPUT_STANDARD,
                MAX(T.ISENDGX) ISENDGX,
                MAX(T.IF_MATCH_ODD) IF_MATCH_ODD,
                MAX(T.IF_DO_HEAT_PLAN) IF_DO_HEAT_PLAN,
                MAX(T.ORDER_SOURCE) ORDER_SOURCE,
                MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK,
                MAX(T.ORDER_NO) ORDER_NO,
                MAX(T.ORDER_SEQ) ORDER_SEQ,
                MAX(T.DELIVERY_NO) DELIVERY_NO,
                MAX(T.REQ_BL_ID) REQ_BL_ID,
                MAX(T.IF_EXPORT) IF_EXPORT,
                MAX(T.PRIORITY) PRIORITY,
                MAX(T.PRIORITY_MEMO) PRIORITY_MEMO,
                MAX(T.PRO_MONTH) PRO_MONTH,
                MAX(T.PRO_DAY) PRO_DAY,
                MAX(T.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
                MAX(T.IF_MONITOR) IF_MONITOR,
                MAX(T.PRDCR_NO) PRDCR_NO,
                MAX(T.MONITOR_POINT) MONITOR_POINT,
                MAX(T.MONITOR_MENT) MONITOR_MENT,
                MAX(T.MONITOR_MAN) MONITOR_MAN,
                MAX(T.BOM) BOM,
                MAX(T.WHOLE_BACKLOG) WHOLE_BACKLOG,
                MAX(T.WHOLE_BACKLOG_DESC) WHOLE_BACKLOG_DESC,
                MAX(T.STATION_ROAD) STATION_ROAD,
                MAX(T.CIC) CIC,
                MAX(T.PIC) PIC,
                MAX(T.SIC) SIC,
                MAX(T.DIC) DIC,
                MAX(T.WIC) WIC,
                MAX(T.GIC) GIC,
                MAX(T.CRAFT_FILE_NO) CRAFT_FILE_NO,
                MAX(T.CRAFT_SEQ) CRAFT_SEQ,
                MAX(T.CRAFT_FILE_MAN) CRAFT_FILE_MAN,
                MAX(T.SEC_CRAFT_FILE_NO) SEC_CRAFT_FILE_NO,
                MAX(T.INWL_ID) INWL_ID,
                MAX(T.INWL_DESC) INWL_DESC,
                MAX(T.OUTWL_ID) OUTWL_ID,
                MAX(T.OUTWL_DESC) OUTWL_DESC,
                MAX(T.STEELCODE) STEELCODE,
                MAX(T.STEELNAME) STEELNAME,
                MAX(T.GRADECODE) GRADECODE,
                MAX(T.GRADENAME) GRADENAME,
                MAX(T.PRODUCCODE) PRODUCCODE,
                MAX(T.PRODUCNAME) PRODUCNAME,
                MAX(T.MODEL_CODE) MODEL_CODE,
                MAX(T.MODEL_DESC) MODEL_DESC,
                MAX(T.OUTDIAMETER) OUTDIAMETER,
                MAX(T.WALLTHICK) WALLTHICK,
                MAX(T.LENGTHMIN) LENGTHMIN,
                MAX(T.LENGTHMAX) LENGTHMAX,
                MAX(T.OUTDIAMETER_IN) OUTDIAMETER_IN,
                MAX(T.WALLTHICK_IN) WALLTHICK_IN,
                MAX(T.OUTNUM_CUT) OUTNUM_CUT,
                MAX(T.LENGTH_IN) LENGTH_IN,
                MAX(T.LENGTHMAX_IN) LENGTHMAX_IN,
                MAX(T.LENGTHMIN_IN) LENGTHMIN_IN,
                MAX(T.PLN_INSINGLE_NUM) PLN_INSINGLE_NUM,
                MAX(T.PLN_INSINGLE_WT) PLN_INSINGLE_WT,
                MAX(T.PLN_INDOUBLE_NUM) PLN_INDOUBLE_NUM,
                MAX(T.PLN_INDOUBLE_WT) PLN_INDOUBLE_WT,
                MAX(T.PLN_OUTSINGLE_NUM) PLN_OUTSINGLE_NUM,
                MAX(T.PLN_OUTSINGLE_W) PLN_OUTSINGLE_W,
                MAX(T.PLN_OUTDOUBLE_NUM) PLN_OUTDOUBLE_NUM,
                MAX(T.PLN_OUTDOUBLE_W) PLN_OUTDOUBLE_W,
                MAX(T.CREATE_NAME) CREATE_NAME,
                MAX(T.CREATE_TIME) CREATE_TIME,
                MAX(T.UPDATE_NAME) UPDATE_NAME,
                MAX(T.UPDATE_TIME) UPDATE_TIME,
                MAX(T.DOWNMAN) DOWNMAN,
                MAX(T.DOWNTIME) DOWNTIME,
                MAX(T.INDEX_SEQ) INDEX_SEQ,
                MAX(T.GX_PRO_SEQ) GX_PRO_SEQ,
                MAX(T.SPEC_CODE) SPEC_CODE,
                MAX(T.SPEC_NAME) SPEC_NAME,
                MAX(T.STD_CODE) STD_CODE,
                MAX(T.STD_NAME) STD_NAME,
                MAX(T.STD_STYLE) STD_STYLE,
                MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
                MAX(T.DECISION) DECISION,
                MAX(T.FEED_HEAT_NO) FEED_HEAT_NO,
                MAX(T.FLAG_STOVE_NO) FLAG_STOVE_NO,
                MAX(T.MEMO) MEMO,
                MAX(T.ZY_BATCH_ID_ZG) ZY_BATCH_ID_ZG,
                MAX(T.HEAT_PLAN_NO_OLD) HEAT_PLAN_NO_OLD,
                MAX(T.IF_PRODUCT) IF_PRODUCT,
                MAX(S.GX_PRO_SEQ) GX_PRO_SEQ_ORDER,
                MAX(t.FILE_PATH2) FILE_PATH2
           FROM PLN_ZY_JGX_M T
           LEFT JOIN PLN_ORDER_JGX_S S
             ON T.PRO_PLAN_ID = S.PRO_PLAN_ID
            AND T.GX_PLAN_NO = S.GX_PLAN_NO, PLN_ZY_JGX_C T2
          WHERE T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
          @Where
          GROUP BY T.HEAT_PLAN_NO, T2.BATCH_NO) T
             LEFT JOIN PLN_ORDER_JGX_S S
             ON T.PRO_PLAN_ID = S.PRO_PLAN_ID
            AND T.GX_PLAN_NO = S.GX_PLAN_NO
  ORDER BY
           DECODE(T.PLANSTATUS,'40',2,'30',1,0),T.PLINE_CODE,
           TO_NUMBER(T.GX_PRO_SEQ_ORDER),
           T.JUDGE_STOVE_NO,
           T.BATCH_NO ASC
        ]]>
	</query>

	<query id="PlanService.GetNewDbkPlanOther" desc="镦拔扩计划简单查询">
		<![CDATA[
  SELECT T.*,
         S.LENGTHDISC,
        (SELECT SUM(PRO_NUM)
           FROM VRP_LOADING_RESULT
          WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND BATCH_NO=T.BATCH_NO ) PRO_COUNT,
        (SELECT SUM(PRO_WT)
           FROM VRP_LOADING_RESULT
          WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO AND BATCH_NO=T.BATCH_NO) PRO_WEIGHT
          @Columns
   FROM (SELECT  T.HEAT_PLAN_NO HEAT_PLAN_NO,
                MAX(T.ZY_BATCH_ID) ZY_BATCH_ID,
                MAX(T.STOVE_NO) STOVE_NO,
                MAX(T.JUDGE_STOVE_NO) JUDGE_STOVE_NO,
                T2.BATCH_NO,
                MAX(T.PLANSTATUS) PLANSTATUS,
                MAX(T2.PER_STATUS) PER_STATUS,
                MAX(T2.BESIDE_STATUS) BESIDE_STATUS,
                MAX(T.UPPER_HEATPLAN_ID) UPPER_HEATPLAN_ID,
                MAX(T.PRO_PLAN_ID) PRO_PLAN_ID,
                MAX(T.GX_PLAN_NO) GX_PLAN_NO,
                MAX(NVL(T2.PLINE_CODE_W,T2.PLINE_CODE)) PLINE_CODE,
                MAX(NVL(T2.PLINE_NAME_W,T2.PLINE_NAME)) PLINE_NAME,
                MAX(T.PROCESS_CODE_C) PROCESS_CODE_C,
                MAX(T.PROCESS_DESC_C) PROCESS_DESC_C,
                MAX(T.UPPER_PROCESS_CODE) UPPER_PROCESS_CODE,
                MAX(T.NEXT_PROCESS_CODE) NEXT_PROCESS_CODE,
                MAX(T.GOWHERE_CODE) GOWHERE_CODE,
                MAX(T.GOWHERE_NAME) GOWHERE_NAME,
                MAX(T.PROD_STANDARD) PROD_STANDARD,
                MAX(T.OUTPUT_STANDARD) OUTPUT_STANDARD,
                MAX(T.ISENDGX) ISENDGX,
                MAX(T.IF_MATCH_ODD) IF_MATCH_ODD,
                MAX(T.IF_DO_HEAT_PLAN) IF_DO_HEAT_PLAN,
                MAX(T.ORDER_SOURCE) ORDER_SOURCE,
                MAX(T.ORD_LN_DLY_PK) ORD_LN_DLY_PK,
                MAX(T.ORDER_NO) ORDER_NO,
                MAX(T.ORDER_SEQ) ORDER_SEQ,
                MAX(T.DELIVERY_NO) DELIVERY_NO,
                MAX(T.REQ_BL_ID) REQ_BL_ID,
                MAX(T.IF_EXPORT) IF_EXPORT,
                MAX(T.PRIORITY) PRIORITY,
                MAX(T.PRIORITY_MEMO) PRIORITY_MEMO,
                MAX(T.PRO_MONTH) PRO_MONTH,
                MAX(T.PRO_DAY) PRO_DAY,
                MAX(T.BAL_YEAR_MONTH) BAL_YEAR_MONTH,
                MAX(T.IF_MONITOR) IF_MONITOR,
                MAX(T.PRDCR_NO) PRDCR_NO,
                MAX(T.MONITOR_POINT) MONITOR_POINT,
                MAX(T.MONITOR_MENT) MONITOR_MENT,
                MAX(T.MONITOR_MAN) MONITOR_MAN,
                MAX(T.BOM) BOM,
                MAX(T.WHOLE_BACKLOG) WHOLE_BACKLOG,
                MAX(T.WHOLE_BACKLOG_DESC) WHOLE_BACKLOG_DESC,
                MAX(T.STATION_ROAD) STATION_ROAD,
                MAX(T.CIC) CIC,
                MAX(T.PIC) PIC,
                MAX(T.SIC) SIC,
                MAX(T.DIC) DIC,
                MAX(T.WIC) WIC,
                MAX(T.GIC) GIC,
                MAX(T.CRAFT_FILE_NO) CRAFT_FILE_NO,
                MAX(T.CRAFT_SEQ) CRAFT_SEQ,
                MAX(T.CRAFT_FILE_MAN) CRAFT_FILE_MAN,
                MAX(T.SEC_CRAFT_FILE_NO) SEC_CRAFT_FILE_NO,
                MAX(T.INWL_ID) INWL_ID,
                MAX(T.INWL_DESC) INWL_DESC,
                MAX(T.OUTWL_ID) OUTWL_ID,
                MAX(T.OUTWL_DESC) OUTWL_DESC,
                MAX(T.STEELCODE) STEELCODE,
                MAX(T.STEELNAME) STEELNAME,
                MAX(T.GRADECODE) GRADECODE,
                MAX(T.GRADENAME) GRADENAME,
                MAX(T.PRODUCCODE) PRODUCCODE,
                MAX(T.PRODUCNAME) PRODUCNAME,
                MAX(T.MODEL_CODE) MODEL_CODE,
                MAX(T.MODEL_DESC) MODEL_DESC,
                MAX(T.OUTDIAMETER) OUTDIAMETER,
                MAX(T.WALLTHICK) WALLTHICK,
                MAX(T.LENGTHMIN) LENGTHMIN,
                MAX(T.LENGTHMAX) LENGTHMAX,
                MAX(T.OUTDIAMETER_IN) OUTDIAMETER_IN,
                MAX(T.WALLTHICK_IN) WALLTHICK_IN,
                MAX(T.OUTNUM_CUT) OUTNUM_CUT,
                MAX(T.LENGTH_IN) LENGTH_IN,
                MAX(T.LENGTHMAX_IN) LENGTHMAX_IN,
                MAX(T.LENGTHMIN_IN) LENGTHMIN_IN,
                MAX(T.PLN_INSINGLE_NUM) PLN_INSINGLE_NUM,
                MAX(T.PLN_INSINGLE_WT) PLN_INSINGLE_WT,
                MAX(T.PLN_INDOUBLE_NUM) PLN_INDOUBLE_NUM,
                MAX(T.PLN_INDOUBLE_WT) PLN_INDOUBLE_WT,
                MAX(T.PLN_OUTSINGLE_NUM) PLN_OUTSINGLE_NUM,
                MAX(T.PLN_OUTSINGLE_W) PLN_OUTSINGLE_W,
                MAX(T.PLN_OUTDOUBLE_NUM) PLN_OUTDOUBLE_NUM,
                MAX(T.PLN_OUTDOUBLE_W) PLN_OUTDOUBLE_W,
                MAX(T.CREATE_NAME) CREATE_NAME,
                MAX(T.CREATE_TIME) CREATE_TIME,
                MAX(T.UPDATE_NAME) UPDATE_NAME,
                MAX(T.UPDATE_TIME) UPDATE_TIME,
                MAX(T.DOWNMAN) DOWNMAN,
                MAX(T.DOWNTIME) DOWNTIME,
                MAX(T.INDEX_SEQ) INDEX_SEQ,
                MAX(T.GX_PRO_SEQ) GX_PRO_SEQ,
                MAX(T.SPEC_CODE) SPEC_CODE,
                MAX(T.SPEC_NAME) SPEC_NAME,
                MAX(T.STD_CODE) STD_CODE,
                MAX(T.STD_NAME) STD_NAME,
                MAX(T.STD_STYLE) STD_STYLE,
                MAX(T.STD_STYLE_DESC) STD_STYLE_DESC,
                MAX(T.DECISION) DECISION,
                MAX(T.FEED_HEAT_NO) FEED_HEAT_NO,
                MAX(T.FLAG_STOVE_NO) FLAG_STOVE_NO,
                MAX(T.MEMO) MEMO,
                MAX(T.ZY_BATCH_ID_ZG) ZY_BATCH_ID_ZG,
                MAX(T.HEAT_PLAN_NO_OLD) HEAT_PLAN_NO_OLD,
                MAX(T.IF_PRODUCT) IF_PRODUCT,
                MAX(S.GX_PRO_SEQ) GX_PRO_SEQ_ORDER
           FROM PLN_ZY_DBK_M T
           LEFT JOIN PLN_ORDER_DBK_S S
             ON T.PRO_PLAN_ID = S.PRO_PLAN_ID
            AND T.GX_PLAN_NO = S.GX_PLAN_NO, PLN_ZY_DBK_C T2
          WHERE T.HEAT_PLAN_NO = T2.HEAT_PLAN_NO
          @Where
          GROUP BY T.HEAT_PLAN_NO, T2.BATCH_NO) T
             LEFT JOIN PLN_ORDER_DBK_S S
             ON T.PRO_PLAN_ID = S.PRO_PLAN_ID
            AND T.GX_PLAN_NO = S.GX_PLAN_NO
  ORDER BY
           DECODE(T.PLANSTATUS,'40',2,'30',1,0),T.PLINE_CODE,
           TO_NUMBER(T.GX_PRO_SEQ_ORDER),
           T.JUDGE_STOVE_NO,
           T.BATCH_NO ASC
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetSingleJGPlan" desc="加工计划简单查询">
        <![CDATA[
      SELECT T3.*,
       TO_NUMBER(T3.IN_NUM) - TO_NUMBER(T3.PRO_NUM) MATERIAL_COUNT,
       TO_NUMBER(T3.IN_WT) - TO_NUMBER(T3.PRO_WT) MATERIAL_WT　
  FROM (SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO ORDER_NO_SEQ,
               T.HEAT_PLAN_NO,
               T.UPPER_HEATPLAN_ID,
               T.PROCESS_CODE_C,
               T.PROCESS_DESC_C,
               T.FEED_HEAT_NO,
               T.UPPER_PROCESS_CODE,
               T.NEXT_PROCESS_CODE,
               T.GOWHERE_CODE,
               T.GOWHERE_NAME,
               T.ZY_BATCH_ID,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.JUDGE_STOVE_NO,
               T.ORDER_SOURCE,
               T.ORD_LN_DLY_PK,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.DELIVERY_NO,
               T.REQ_BL_ID,
               T.LENGTHMAX_IN,
               T.LENGTHMIN_IN,
               T.INWL_ID,
               T.INWL_DESC,
               T.PROD_STANDARD,
               T.OUTPUT_STANDARD,
               T2.JUGDE_APPLY_CODE,         
               DECODE(T.ISENDGX,'0','否','1','是','否') ISENDGX,
               T.IF_EXPORT,
               T.PRIORITY,
               T.PRIORITY_MEMO,
               T.PRO_MONTH,
               T.PRO_DAY,
               T.BAL_YEAR_MONTH,
               T.MONITOR_MENT,
               T.MONITOR_MAN,
               T.PLN_OUTSINGLE_NUM,
               T.PLN_OUTSINGLE_W,
               DECODE(T.IF_MATCH_ODD,'0','否','1','是','否') IF_MATCH_ODD,
               NVL(T2.PLAN_INDOUBLE_WT, 0) IN_WT, 
               NVL(T2.PLAN_INDOUBLE_NUM, 0) IN_NUM,
               T.OUTWL_ID,
               T.OUTWL_DESC,
               DECODE(T.IF_MONITOR,'0','否','1','是','否') IF_MONITOR,
               T.MONITOR_POINT,
               T.CRAFT_FILE_MAN,
               T.CRAFT_SEQ,
               T.STATION_ROAD,
               T.OUTDIAMETER,
               T.WALLTHICK,
               T.STEELNAME,
               T.MODEL_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,
               DECODE(T.PLANSTATUS,
                      '00',
                      '计划',
                      '10',
                      '下发',
                      '20',
                      '生产中',
                      '30',
                      '生产完成',
                      '40',
                      '关闭') PLANSTATUS,
               T.CRAFT_FILE_NO,
               T.SEC_CRAFT_FILE_NO,
               T.PRDCR_NO,
              NVL(T2.REAL_INDOUBLE_NUM,0) PRO_NUM,
              NVL(T2.REAL_INDOUBLE_WT,0) PRO_WT,
              T2.REAL_INDOUBLE_NUM IN_NUM_REAL,
              T2.REAL_INDOUBLE_WT IN_WT_REAL,
              T2.REAL_OUTDOUBLE_NUM OUT_NUM_REAL,
              T2.REAL_OUTDOUBLE_WT OUT_WT_REAL,
               NVL((SELECT SUM(M.ACT_COUNT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                     AND nvl(M.JUGDE_APPLY_CODE,'/') = nvl(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
               --          AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
  -- AND STORAGE_ATTR = '800302'
     AND M.NEXT_PROCESS_CDOE = 'G'
   ),
                   0) ACT_COUNT, 
               NVL((SELECT SUM(M.ACT_WEIGHT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'     
                     AND nvl(M.JUGDE_APPLY_CODE,'/') = nvl(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
                     --     AND  B.MANAGEMENT_NO IN
    --   (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
  -- AND STORAGE_ATTR = '800302'
   AND M.NEXT_PROCESS_CDOE = 'G'
  ),
                   0) ACT_WEIGHT,
                   T2.BATCH_GROUD_NO,
                   T2.HEAT_PLAN_SQE,        
                   DECODE(T2.OUTNUM_CUT,'','1','0','1',T2.OUTNUM_CUT) OUTNUM_CUT,   
                   T2.LENGTH_IN,   
                   T2.LENGTHMAX_IN LENGTHMAXC,
                   T2.LENGTHMIN_IN LENGTHMINC, 
                   T2.BATCH_NO,           
                   DECODE(T.BESIDE_STATUS,
                      '00',
                      '上料结束',
                      '10',
                      '探伤结束',
                      '20',
                      '切管结束',
                      '30',
                      '车丝结束',
                      '40',
                      '螺纹检验结束',
                      '50',
                      '拧接结束',
                      '60',
                      '通径结束',
                      '70',
                      '水压结束',
                      '80',
                      '倒棱结束',
                      '90',
                      '测量点结束',
                      '11',
                      '交库结束') BESIDE_STATUS,
               DECODE(T.PER_STATUS,
                      '00',
                      '上料开始',
                      '10',
                      '探伤开始',
                      '20',
                      '切管开始',
                      '30',
                      '车丝开始',
                      '40',
                      '螺纹检验开始',
                      '50',
                      '拧接开始',
                      '60',
                      '通径开始',
                      '70',
                      '水压开始',
                      '80',
                      '倒棱开始',
                      '90',
                      '测量点开始',
                      '11',
                      '交库开始') PER_STATUS         
          FROM pln_zy_jgx_m T,pln_zy_jgx_c T2
         WHERE  t.heat_plan_no = t2.heat_plan_no
        ]]>
	</query>
	
	<query id="PlanService.HeatTreatme.GetSingleJGPlancut" desc="加工计划简单查询(分切后的 )">
        <![CDATA[
       SELECT T3.*,
       TO_NUMBER(T3.IN_NUM) - TO_NUMBER(T3.PRO_NUM) MATERIAL_COUNT,
       TO_NUMBER(T3.IN_WT) - TO_NUMBER(T3.PRO_WT) MATERIAL_WT　
  FROM (SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO ORDER_NO_SEQ,
               T.HEAT_PLAN_NO,
               T.UPPER_HEATPLAN_ID,
               T.PROCESS_CODE_C,
               T.PROCESS_DESC_C,
               T.FEED_HEAT_NO,
               T.UPPER_PROCESS_CODE,
               T.NEXT_PROCESS_CODE,
               T.GOWHERE_CODE,
               T.GOWHERE_NAME,
               T.ZY_BATCH_ID,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.JUDGE_STOVE_NO,
               T.ORDER_SOURCE,
               T.ORD_LN_DLY_PK,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.DELIVERY_NO,
               T.REQ_BL_ID,
               T.LENGTHMAX_IN,
               T.LENGTHMIN_IN,
               T.INWL_ID,
               T.INWL_DESC,
               T.PROD_STANDARD,
               T.OUTPUT_STANDARD,
               T2.JUGDE_APPLY_CODE,  
               DECODE(T.ISENDGX,'0','否','1','是','否') ISENDGX,
               T.IF_EXPORT,
               T.PRIORITY,
               T.PRIORITY_MEMO,
               T.PRO_MONTH,
               T.PRO_DAY,
               T.BAL_YEAR_MONTH,
               T.MONITOR_MENT,
               T.MONITOR_MAN,
               T.PLN_OUTSINGLE_NUM,
               T.PLN_OUTSINGLE_W,
               DECODE(T.IF_MATCH_ODD,'0','否','1','是','否') IF_MATCH_ODD,
               --NVL(T2.PLAN_INDOUBLE_WT, 0) IN_WT, --排产量
               --NVL(T2.PLAN_INDOUBLE_NUM, 0) IN_NUM,
               T.OUTWL_ID,
               T.OUTWL_DESC,
               DECODE(T.IF_MONITOR,'0','否','1','是','否') IF_MONITOR,
               T.MONITOR_POINT,
               T.CRAFT_FILE_MAN,
               T.CRAFT_SEQ,
               T.STATION_ROAD,
               T.OUTDIAMETER,
               T.WALLTHICK,
               T.STEELNAME,
               T.MODEL_DESC,
               T.CREATE_NAME,
               T2.BATCH_NO,
               T2.BATCH_GROUD_NO,
               T2.HEAT_PLAN_SQE,        
               T2.OUTNUM_CUT,  
               T2.LENGTH_IN,   
               T2.LENGTHMAX_IN LENGTHMAXC,
               T2.LENGTHMIN_IN LENGTHMINC, 
               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,
               DECODE(T.PLANSTATUS,
                      '00',
                      '计划',
                      '10',
                      '下发',
                      '20',
                      '生产中',
                      '30',
                      '生产完成',
                      '40',
                      '关闭') PLANSTATUS,
               T.CRAFT_FILE_NO,
               T.SEC_CRAFT_FILE_NO,
               T.PRDCR_NO,
               (select nvl(sum(t4.PLAN_INDOUBLE_NUM * t4.OUTNUM_CUT),0)
               from pln_zy_jgx_c t4 
               where t.heat_plan_no = t4.heat_plan_no) in_num,     --排产量
                 (select nvl(sum(t4.PLAN_INDOUBLE_WT * t4.OUTNUM_CUT),0)
               from pln_zy_jgx_c t4 
               where t.heat_plan_no = t4.heat_plan_no) in_wt,
               (SELECT NVL(SUM(T1.PRO_NUM), 0)
                  FROM MCH_CUT_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_NUM,--上料量
               (SELECT NVL(SUM(T1.PRO_WT), 0)
                  FROM MCH_CUT_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_WT,
                    (SELECT NVL(SUM(T1.PRO_NUM), 0)
                  FROM MCH_CUT_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) IN_NUM_REAL,--实绩投入
               (SELECT NVL(SUM(T1.PRO_WT), 0)
                  FROM MCH_CUT_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) IN_WT_REAL,
               NVL((SELECT SUM(M.ACT_COUNT)
                     FROM MAT_ZC_M M, YDM_ZC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                      AND NVL(M.JUGDE_APPLY_CODE,'/') =  NVL(T2.JUGDE_APPLY_CODE,'/')
                      AND M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                --       AND  B.MANAGEMENT_NO IN
      -- (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
   --AND STORAGE_ATTR = '800302'
      AND M.NEXT_PROCESS_CDOE = 'G'
   ),
                   0) ACT_COUNT, 
               NVL((SELECT SUM(M.ACT_WEIGHT)
                     FROM MAT_ZC_M M, YDM_ZC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                      AND NVL(M.JUGDE_APPLY_CODE,'/') =  NVL(T2.JUGDE_APPLY_CODE,'/')
                      AND M.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                    --   AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
  -- AND STORAGE_ATTR = '800302'
   AND M.NEXT_PROCESS_CDOE = 'G'
    ),
                   0) ACT_WEIGHT,
                   DECODE(T.BESIDE_STATUS,
                      '00',
                      '上料结束',
                      '10',
                      '探伤结束',
                      '20',
                      '切管结束',
                      '30',
                      '车丝结束',
                      '40',
                      '螺纹检验结束',
                      '50',
                      '拧接结束',
                      '60',
                      '通径结束',
                      '70',
                      '水压结束',
                      '80',
                      '倒棱结束',
                      '90',
                      '测量点结束',
                      '11',
                      '交库结束') BESIDE_STATUS,
               DECODE(T.PER_STATUS,
                      '00',
                      '上料开始',
                      '10',
                      '探伤开始',
                      '20',
                      '切管开始',
                      '30',
                      '车丝开始',
                      '40',
                      '螺纹检验开始',
                      '50',
                      '拧接开始',
                      '60',
                      '通径开始',
                      '70',
                      '水压开始',
                      '80',
                      '倒棱开始',
                      '90',
                      '测量点开始',
                      '11',
                      '交库开始') PER_STATUS         
          FROM pln_zy_jgx_m T,pln_zy_jgx_c t2
         WHERE 1=1 and t.heat_plan_no = t2.heat_plan_no
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetHttOrder" desc="热处理作业计划查询">
		<![CDATA[
   SELECT  *
  FROM PLN_ORDER_RCL_S T
 WHERE T.PRO_PLAN_ID = ? AND GX_PLAN_NO=?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetMchOrder" desc="热处理作业计划查询">
		<![CDATA[
   SELECT  *
  FROM PLN_ORDER_JGX_S T
 WHERE T.PRO_PLAN_ID = ? AND GX_PLAN_NO=?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetDBKOrder" desc="热处理作业计划查询">
		<![CDATA[
   SELECT  *
  FROM PLN_ORDER_DBK_S T
 WHERE T.PRO_PLAN_ID = ? AND GX_PLAN_NO=?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetRclPlan" desc="热处理作业计划查询">
        <![CDATA[
   SELECT  HEAT_PLAN_NO,
       GX_PRO_SEQ,
       ZY_BATCH_ID,
       STOVE_NO,
       JUDGE_STOVE_NO,
       PLANSTATUS,
       PER_STATUS,
       BESIDE_STATUS,
       UPPER_HEATPLAN_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       NVL(PLINE_CODE_W, PLINE_CODE) PLINE_CODE,
       NVL(PLINE_NAME_W,PLINE_NAME) PLINE_NAME,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       UPPER_PROCESS_CODE,
       NEXT_PROCESS_CODE,
       GOWHERE_CODE,
       GOWHERE_NAME,
       PROD_STANDARD,
       OUTPUT_STANDARD,
       ISENDGX,
       IF_MATCH_ODD,
       IF_DO_HEAT_PLAN,
       ORDER_SOURCE,
       ORD_LN_DLY_PK,
       ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       IF_EXPORT,
       PRIORITY,
       PRIORITY_MEMO,
       PRO_MONTH,
       PRO_DAY,
       BAL_YEAR_MONTH,
        DECODE(T.IF_MONITOR, '0', '否', '1', '是') IF_MONITOR_RCL,
       PRDCR_NO,
       MONITOR_POINT,
       BOM,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       STATION_ROAD,
       CIC,
       PIC,
       SIC,
       DIC,
       CRAFT_FILE_NO,
       CRAFT_FILE_MAN,
       CRAFT_SEQ,
       SEC_CRAFT_FILE_NO,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PRODUCCODE,
       PRODUCNAME,
       MODEL_CODE,
       MODEL_DESC,
       INWL_ID,
       INWL_DESC,
       OUTWL_ID,
       OUTWL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       LENGTHMIN,
       LENGTHMAX,
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       OUTNUM_CUT,
       LENGTH_IN,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       PLN_INSINGLE_NUM,
       PLN_INSINGLE_WT,
       PLN_INDOUBLE_NUM,
       PLN_INDOUBLE_WT,
       PLN_OUTSINGLE_NUM,
       PLN_OUTSINGLE_W,
       PLN_OUTDOUBLE_NUM,
       PLN_OUTDOUBLE_W,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       CREATE_TIME,
        TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       UPDATE_TIME,
       DOWNMAN,
       DOWNTIME,
       BATCH_NO,
       INDEX_SEQ,
       SPEC_CODE,
       SPEC_NAME,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       DECISION,
       NVL(PROCESS_SEQ,1) PROCESS_SEQ,
       FEED_HEAT_NO,
       FLAG_STOVE_NO,
       MEMO,
       ZY_BATCH_ID_ZG,
       NVL(REAL_PROCESS_SEQ,1) REAL_PROCESS_SEQ,
       HEAT_PLAN_NO_OLD,
       IF_PRODUCT,
       LOT_NO_GROUP,
       LOT_NO_SQE,
       IS_LOAD_FLAG
  FROM PLN_ZY_RCL_M T
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	
	<query id="PlanService.HeatTreatme.GetRclPlanC" desc="热处理作业计划从表查询">
        <![CDATA[
   SELECT *
  FROM PLN_ZY_RCL_C T
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetRclPlanC2" desc="热处理作业计划从表查询">
		<![CDATA[
   SELECT T.*,NVL(PLINE_CODE_W,PLINE_CODE) PLINE_CODE
  FROM PLN_ZY_RCL_C T
 WHERE T.HEAT_PLAN_NO = ?
    AND HEAT_PLAN_SQE =?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetRclPlan3Dbk" desc="dbk作业计划查询">
		<![CDATA[
   SELECT T.*,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       LENGTHMAX,
       T1.LENGTHDISC,
       T1.SHORTEST,
       T1.SIGL_LEN
  FROM pln_zy_dbk_m T LEFT JOIN (SELECT ORD_LN_DLY_PK,MAX(LENGTHDISC) LENGTHDISC,MAX(SHORTEST)  SHORTEST, MAX(SIGL_LEN) SIGL_LEN FROM PLN_SALEORD  GROUP BY ORD_LN_DLY_PK) T1 ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="PlanService.HeatTreatme.GetRclPlan3" desc="加工作业计划查询">
        <![CDATA[
   SELECT T.*,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
       LENGTHMAX,
       T1.LENGTHDISC,
       T1.SHORTEST,
       T1.SIGL_LEN
  FROM pln_zy_jgx_m T LEFT JOIN (SELECT ORD_LN_DLY_PK,MAX(LENGTHDISC) LENGTHDISC,MAX(SHORTEST)  SHORTEST, MAX(SIGL_LEN) SIGL_LEN FROM PLN_SALEORD  GROUP BY ORD_LN_DLY_PK) T1 ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="PlanService.HeatTreatme.GetRclPlan3NewDbk" desc="dbk作业计划查询">
		<![CDATA[
   SELECT T.HEAT_PLAN_NO,
       ZY_BATCH_ID,
       STOVE_NO,
       JUDGE_STOVE_NO,
       C.BATCH_NO,
       PLANSTATUS,
       PER_STATUS,
       BESIDE_STATUS,
       UPPER_HEATPLAN_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       NVL(C.PLINE_CODE_W, T.PLINE_CODE) PLINE_CODE,
       NVL(C.PLINE_NAME_W, T.PLINE_NAME) PLINE_NAME,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       UPPER_PROCESS_CODE,
       NEXT_PROCESS_CODE,
       GOWHERE_CODE,
       GOWHERE_NAME,
       PROD_STANDARD,
       OUTPUT_STANDARD,
       ISENDGX,
       IF_MATCH_ODD,
       IF_DO_HEAT_PLAN,
       ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       IF_EXPORT,
       PRIORITY,
       PRIORITY_MEMO,
       PRO_MONTH,
       PRO_DAY,
       BAL_YEAR_MONTH,
       IF_MONITOR,
       PRDCR_NO,
       MONITOR_POINT,
       MONITOR_MENT,
       MONITOR_MAN,
       BOM,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       STATION_ROAD,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       CRAFT_FILE_NO,
       CRAFT_SEQ,
       CRAFT_FILE_MAN,
       SEC_CRAFT_FILE_NO,
       INWL_ID,
       INWL_DESC,
       OUTWL_ID,
       OUTWL_DESC,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PRODUCCODE,
       PRODUCNAME,
       MODEL_CODE,
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       LENGTHMIN,
       LENGTHMAX,
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       OUTNUM_CUT,
       LENGTH_IN,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       PLN_INSINGLE_NUM,
       PLN_INSINGLE_WT,
       PLN_INDOUBLE_NUM,
       PLN_INDOUBLE_WT,
       PLN_OUTSINGLE_NUM,
       PLN_OUTSINGLE_W,
       PLN_OUTDOUBLE_NUM,
       PLN_OUTDOUBLE_W,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DOWNMAN,
       DOWNTIME,
       INDEX_SEQ,
       GX_PRO_SEQ,
       SPEC_CODE,
       SPEC_NAME,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       DECISION,
       FEED_HEAT_NO,
       FLAG_STOVE_NO,
       MEMO,
       ZY_BATCH_ID_ZG,
       HEAT_PLAN_NO_OLD,
       IF_PRODUCT,
       C.PLINE_CODE_W,
       C.PLINE_NAME_W,
       IS_BATCH,
       CHECK_NO,
       LOT_NO_GROUP,
       LOT_NO_SQE,
       IS_CLOSE,
       WAITING_DECISION_MEMO,
       IS_VISIBLE,
       LOADTIME, TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,

       LENGTHMAX,
       T1.LENGTHDISC,
       T1.SHORTEST,
       T1.SIGL_LEN
  FROM PLN_ZY_DBK_M T
  LEFT JOIN (SELECT HEAT_PLAN_NO,
                    BATCH_NO,
                    MAX(PLINE_CODE_W) PLINE_CODE_W,
                    MAX(PLINE_NAME_W) PLINE_NAME_W
               FROM PLN_ZY_DBK_C
              GROUP BY HEAT_PLAN_NO, BATCH_NO) C
    ON T.HEAT_PLAN_NO = C.HEAT_PLAN_NO
   AND C.BATCH_NO = ?
  LEFT JOIN (SELECT ORD_LN_DLY_PK,
                    MAX(LENGTHDISC) LENGTHDISC,
                    MAX(SHORTEST) SHORTEST,
                    MAX(SIGL_LEN) SIGL_LEN
               FROM PLN_SALEORD
              GROUP BY ORD_LN_DLY_PK) T1
    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	<query id="PlanService.HeatTreatme.GetRclPlan3New" desc="加工作业计划查询">
		<![CDATA[
   SELECT T.HEAT_PLAN_NO,
       ZY_BATCH_ID,
       STOVE_NO,
       JUDGE_STOVE_NO,
       C.BATCH_NO,
       PLANSTATUS,
       PER_STATUS,
       BESIDE_STATUS,
       UPPER_HEATPLAN_ID,
       PRO_PLAN_ID,
       GX_PLAN_NO,
       NVL(C.PLINE_CODE_W, T.PLINE_CODE) PLINE_CODE,
       NVL(C.PLINE_NAME_W, T.PLINE_NAME) PLINE_NAME,
       PROCESS_CODE_C,
       PROCESS_DESC_C,
       UPPER_PROCESS_CODE,
       NEXT_PROCESS_CODE,
       GOWHERE_CODE,
       GOWHERE_NAME,
       PROD_STANDARD,
       OUTPUT_STANDARD,
       ISENDGX,
       IF_MATCH_ODD,
       IF_DO_HEAT_PLAN,
       ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.ORDER_NO,
       ORDER_SEQ,
       DELIVERY_NO,
       REQ_BL_ID,
       IF_EXPORT,
       PRIORITY,
       PRIORITY_MEMO,
       PRO_MONTH,
       PRO_DAY,
       BAL_YEAR_MONTH,
       IF_MONITOR,
       PRDCR_NO,
       MONITOR_POINT,
       MONITOR_MENT,
       MONITOR_MAN,
       BOM,
       WHOLE_BACKLOG,
       WHOLE_BACKLOG_DESC,
       STATION_ROAD,
       CIC,
       PIC,
       SIC,
       DIC,
       WIC,
       GIC,
       CRAFT_FILE_NO,
       CRAFT_SEQ,
       CRAFT_FILE_MAN,
       SEC_CRAFT_FILE_NO,
       INWL_ID,
       INWL_DESC,
       OUTWL_ID,
       OUTWL_DESC,
       STEELCODE,
       STEELNAME,
       GRADECODE,
       GRADENAME,
       PRODUCCODE,
       PRODUCNAME,
       MODEL_CODE,
       MODEL_DESC,
       OUTDIAMETER,
       WALLTHICK,
       LENGTHMIN,
       LENGTHMAX,
       OUTDIAMETER_IN,
       WALLTHICK_IN,
       OUTNUM_CUT,
       LENGTH_IN,
       LENGTHMAX_IN,
       LENGTHMIN_IN,
       PLN_INSINGLE_NUM,
       PLN_INSINGLE_WT,
       PLN_INDOUBLE_NUM,
       PLN_INDOUBLE_WT,
       PLN_OUTSINGLE_NUM,
       PLN_OUTSINGLE_W,
       PLN_OUTDOUBLE_NUM,
       PLN_OUTDOUBLE_W,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DOWNMAN,
       DOWNTIME,
       INDEX_SEQ,
       GX_PRO_SEQ,
       SPEC_CODE,
       SPEC_NAME,
       STD_CODE,
       STD_NAME,
       STD_STYLE,
       STD_STYLE_DESC,
       DECISION,
       FEED_HEAT_NO,
       FLAG_STOVE_NO,
       MEMO,
       ZY_BATCH_ID_ZG,
       HEAT_PLAN_NO_OLD,
       IF_PRODUCT,
       C.PLINE_CODE_W,
       C.PLINE_NAME_W,
       IS_BATCH,
       CHECK_NO,
       LOT_NO_GROUP,
       LOT_NO_SQE,
       IS_CLOSE,
       WAITING_DECISION_MEMO,
       IS_VISIBLE,
       LOADTIME, TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,

       LENGTHMAX,
       T1.LENGTHDISC,
       T1.SHORTEST,
       T1.SIGL_LEN
  FROM PLN_ZY_JGX_M T
  LEFT JOIN (SELECT HEAT_PLAN_NO,
                    BATCH_NO,
                    MAX(PLINE_CODE_W) PLINE_CODE_W,
                    MAX(PLINE_NAME_W) PLINE_NAME_W
               FROM PLN_ZY_JGX_C
              GROUP BY HEAT_PLAN_NO, BATCH_NO) C
    ON T.HEAT_PLAN_NO = C.HEAT_PLAN_NO
   AND C.BATCH_NO = ?
  LEFT JOIN (SELECT ORD_LN_DLY_PK,
                    MAX(LENGTHDISC) LENGTHDISC,
                    MAX(SHORTEST) SHORTEST,
                    MAX(SIGL_LEN) SIGL_LEN
               FROM PLN_SALEORD
              GROUP BY ORD_LN_DLY_PK) T1
    ON T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>
	
	<query id="PlanService.HeatTreatme.GetRclPlan3C" desc="加工作业计划从表查询">
        <![CDATA[
   SELECT T.HEAT_PLAN_NO,
       T.STOVE_NO,
       T.ZY_BATCH_ID,
       T.BATCH_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.JUGDE_APPLY_CODE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN
  FROM PLN_ZY_JGX_C T
 WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetRclPlan3CNew" desc="加工作业计划从表查询">
		<![CDATA[
   SELECT T.HEAT_PLAN_NO,
       T.STOVE_NO,
       T.ZY_BATCH_ID,
       T.BATCH_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.JUGDE_APPLY_CODE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN
  FROM PLN_ZY_JGX_C T
 WHERE T.HEAT_PLAN_NO = ?
 AND HEAT_PLAN_SQE =?
        ]]>
	</query>

	<query id="PlanService.HeatTreatme.GetRclPlan3CNew1" desc="加工作业计划从表查询">
		<![CDATA[
   SELECT *
  FROM PLN_ZY_JGX_C T
 WHERE T.HEAT_PLAN_NO = ?
 AND T.BATCH_NO =?
 AND T.BATCH_GROUD_NO =?
        ]]>
	</query>

	<query id="PlanService.CutPlan.GetSingleJGCutPlan" desc="接箍切断计划简单查询">
        <![CDATA[
      SELECT T.ZY_PLAN_ID,
       T.BATCH_NO,
       T.JUDGE_STOVE_NO,
       DECODE(T.ZY_PLAN_STATUS,
              '0',
              '编辑',
              '1',
              '下发',
              '2',
              '生产中',
              '3',
              '生产完成',
              '4',
              '取消') ZY_PLAN_STATUS,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PRO_PLAN_ID,
       DECODE(T.IF_OUT_CUT, '0', '否', '1', '是') IF_OUT_CUT,
       DECODE(T.IF_NEED_CJG, '0', '否', '1', '是') IF_NEED_CJG,
       DECODE(T.IF_OUT_CJG, '0', '否', '1', '是') IF_OUT_CJG,
       DECODE(T.IF_IMPRESS, '0', '否', '1', '是') IF_IMPRESS,
       DECODE(T.IF_OUT_IMPRESS, '0', '否', '1', '是') IF_OUT_IMPRESS
  FROM PLN_ZY_JG T
 WHERE T.ZY_PLAN_STATUS IN ('1', '2')
   AND T.PLINE_CODE || '&' LIKE '%' || ? || '%'
   AND T.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND T.BATCH_NO || '&' LIKE '%' || ? || '%'
   AND T.ZY_PLAN_ID || '&' LIKE '%' || ? || '%'
        ]]>
	</query>

	<query id="PlanService.CutPlan.GetJGCutPlan" desc="接箍切断计划详细查询">
        <![CDATA[
     SELECT 
       T.ZY_PLAN_ID,
       T.PRO_PLAN_ID,
       T.JG_GROUP_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CODE_JG_BL,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MIN_D,
       T.MIN_H,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.CODE_JG,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.STYLE_JG,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.COAT_TYPE,
       T.PLAN_JG_NUM,
       T.PLAN_BL_NUM,
       T.PLAN_BL_WT,
       T.USE_BL_NUM,
       T.USE_BL_WT,
       T.MONITORDEMAND,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       T.CUT_MACH_GRP_NO,
       T.CUT_MACH_GRP_NM,
       T.PLAN_CUT_NUM,
       T.CUT_OK_NUM,
       T.CUT_FAIL_NUM,
       T.IF_NEED_CJG,
       T.CJG_DEPT,
       T.PLAN_CJG_NUM,
       T.CJG_OK_NUM,
       T.DEMAND_COPPER,
       T.IF_IMPRESS,
       T.IMPRESS_DEPT,
       T.PLAN_IMPRESS_NUM,
       T.IMPRESS_OK_NUM,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       T.PLAN_LATHE_NUM,
       T.PLAN_LTH_USETIME,
       T.LATHE_OK_NUM,
       T.LATHE_FAIL_NUM,
       T.THREAD_CHK_OK_NUM,
       T.THREAD_CHK_FAIL_NUM,
       T.DEMAND_DETECTION,
       T.DETECT_DEPT,
       T.PLAN_DETECT_NUM,
       T.DETECT_OK_NUM,
       T.DETECT_FAIL_NUM,
       T.IF_BLAST,
       T.DEMAND_BLAST,
       T.BLAST_DEPT,
       T.PLAN_BLAST_NUM,
       T.BLAST_OK_NUM,
       T.SPOT_CHK_OK_NUM,
       T.SPOT_CHK_FAIL_NUM,
       --T.SPOT_CHK_STATUS,
       T.DEMAND_BONDERIZING,
       T.IF_PLATE_CU,
       T.PLT_CU_DEPT,
       T.PLAN_PLTCU_NUM,
       T.PLT_CU_OK_NUM,
       T.IF_PHOSPHATING,
       T.PHOS_DEPT,
       T.PLAN_PHOS_NUM,
       T.PHOS_OK_NUM,
       T.IF_COPPER,
       T.COPPER_DEPT,
       T.PLAN_COPPER_NUM,
       T.COPPER_OK_NUM,
       T.JUDGE_OK_NUM,
       T.JUDGE_FAIL_NUM,
       T.JUDGE_STATUS,
       T.INSTORE_NUM,
       T.INSTORE_STATUS,
       T.ZY_PLAN_STATUS,
       T.MEMO,
       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.CUST_ALPHA_NO,
       T.ORDER_SPECIAL_DESC,
       T.ALPHA_CODE,
       T.BATCH_GROUD_NO
 FROM PLN_ZY_JG T
 WHERE T.ZY_PLAN_ID = ?
        ]]>
	</query>

	<query id="PlanService.ProcessPlan.SingleJGProcessPlan" desc="接箍加工计划简单查询">
        <![CDATA[
SELECT T.ZY_PLAN_ID,
       T.BATCH_NO,
       T.JUDGE_STOVE_NO,
       DECODE(T.ZY_PLAN_STATUS,
              '0',
              '编辑',
              '1',
              '下发',
              '2',
              '生产中',
              '3',
              '生产完成',
              '4',
              '取消') ZY_PLAN_STATUS,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.PRO_PLAN_ID,
       DECODE(T.COAT_TYPE,'','无',T.COAT_TYPE) COAT_TYPE,
       DECODE(T.THREAD_CHK_STATUS,'0','计划','1','检验中','2','检验完成') THREAD_CHK_STATUS,
       DECODE(T.IF_PLATE_CU,'0','否','1','是') IF_PLATE_CU,
       DECODE(T.IF_OUT_PLT_CU,'0','否','1','是') IF_OUT_PLT_CU,
       DECODE(T.IF_PHOSPHATING,'0','否','1','是') IF_PHOSPHATING,
       DECODE(T.IF_OUT_PHOS,'0','否','1','是') IF_OUT_PHOS,
       DECODE(T.IF_COPPER,'0','否','1','是') IF_COPPER,
       DECODE(T.PLT_CU_STATUS,'0','计划','1','生产中','2','生产完成','9','不需镀铜') PLT_CU_STATUS,
       DECODE(T.PHOS_STATUS,'0','计划','1','生产中','2','生产完成','9','不需磷化') PHOS_STATUS,
       DECODE(T.BLAST_STATUS,'0','计划','1','生产中','2','生产完成','9','不需喷砂') BLAST_STATUS,
       DECODE(T.DETECT_STATUS,'0','计划','1','生产中','2','生产完成','9','不需探伤') DETECT_STATUS,
       DECODE(T.IF_BLAST,'0','否','1','是') IF_BLAST,
        DECODE(T.LATHE_STATUS,'0','计划','1','生产中','2','生产完成') LATHE_STATUS,
       T.IF_ALL_OUT_WORK,
       T.LATHE_OK_NUM,
       NVL(T.PLAN_PHOS_NUM,0) PLAN_PHOS_NUM,
       NVL(T.PLAN_DETECT_NUM,0) PLAN_DETECT_NUM,
       NVL(T.PLAN_LATHE_NUM,0) PLAN_LATHE_NUM
  FROM PLN_ZY_JG T
 WHERE T.ZY_PLAN_STATUS IN ('1','2')
   AND T.PLINE_CODE || '&' LIKE '%' || ? || '%'
   AND T.ZY_PLAN_ID || '&' LIKE '%' || ? || '%'
   AND T.JUDGE_STOVE_NO || '&' LIKE '%' || ? || '%'
   AND T.BATCH_NO || '&' LIKE '%' || ? || '%'
        ]]>
	</query>
	<query id="PlanService.GetDbkPlan" desc="墩拔扩计划">
		<![CDATA[
SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO ORDER_NO_SEQ,
               T.HEAT_PLAN_NO,
               T2.HEAT_PLAN_SQE,
               T.ZY_BATCH_ID,
               --T.PROD_INDEX,
               t.GX_PRO_SEQ,
               T.PRO_PLAN_ID,
               T.GX_PLAN_NO,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.UPPER_HEATPLAN_ID,
               T.JUDGE_STOVE_NO,
               T.FEED_HEAT_NO,
               T2.BATCH_NO,
               T2.BATCH_GROUD_NO,
               DECODE(T.ISENDGX,'0','否','1','是','否') ISENDGX,
               T.ORDER_SOURCE,
               T.ORD_LN_DLY_PK,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.DELIVERY_NO,
               T.REQ_BL_ID,
               T.GRADECODE,
               T.GRADENAME,
               T.AIMOUTDIAMETER,
               T.AIMWALLTHICK,
               T.AIMLENGTH,
               T.OUTDIAMETER_IN,
               T.WALLTHICK_IN,
               T.LENGTH_IN,
               T.LENGTHMAX_IN,
               T.LENGTHMIN_IN,
               T.LEN_CUTHEAD,
               T.LEN_CUTEND,
               T.INWL_ID,
               T.INWL_DESC,
               T.NEXT_PROCESS_CODE,
               T2.JUGDE_APPLY_CODE,
               NVL(T2.PLAN_INDOUBLE_WT, 0) IN_WT,
               NVL(T2.PLAN_INDOUBLE_NUM, 0) IN_NUM,
               DECODE(T.IF_MATCH_ODD,'1','是','0','否','否') IF_WL_MATCHED,
               T.OUTWL_ID,
               T.OUTWL_DESC,
              -- NVL(T.OUT_WT, 0) OUT_WT,
             --  NVL(T.OUT_NUM, 0) OUT_NUM,
               DECODE(T.IF_MONITOR,'0','否','1','是','否') IF_MONITOR_DBK,
               T.MONITOR_POINT,
               T.CRAFT_FILE_MAN,
               T.CRAFT_SEQ,
               T.STATION_ROAD,
               NVL(T2.REAL_INDOUBLE_WT, 0) IN_WT_REAL,
               NVL(T2.REAL_INDOUBLE_NUM, 0) IN_NUM_REAL,
               NVL(T2.REAL_OUTDOUBLE_WT, 0) OUT_WT_REAL,
               NVL(T2.REAL_OUTDOUBLE_NUM, 0) OUT_NUM_REAL,
               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,
               DECODE(T.PLANSTATUS,
                      '00',
                      '计划',
                      '10',
                      '下发',
                      '20',
                      '生产中',
                      '30',
                      '生产完成',
                      '40',
                      '关闭') PLANSTATUS,
               T.CRAFT_FILE_NO,
               T.PRDCR_NO,
               (SELECT NVL(SUM(T1.PRO_NUM), 0)
                  FROM VRP_LOADING_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_NUM,
               (SELECT NVL(SUM(T1.PRO_WT), 0)
                  FROM VRP_LOADING_RESULT T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO) PRO_WT,
               NVL((SELECT SUM(M.ACT_COUNT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                     AND nvl(M.JUGDE_APPLY_CODE,'/') = nvl(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.FEED_HEAT_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
                   --       AND  B.MANAGEMENT_NO IN
     --  (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
 --  AND STORAGE_ATTR = '800302'
  AND M.NEXT_PROCESS_CDOE = 'E'
                      ),
                   0) ACT_COUNT,
               NVL((SELECT SUM(M.ACT_WEIGHT)
                     FROM MAT_BC_M M, YDM_BC_BUTTRESS B
                    WHERE M.MAT_NO = B.MAT_NO
                      AND M.PRODUCT_FLAG = '801401'
                      AND M.MAT_STATUS = '80150103'
                     AND nvl(M.JUGDE_APPLY_CODE,'/') = nvl(T2.Jugde_Apply_Code,'/')
                      AND M.JUDGE_STOVE_NO = T.FEED_HEAT_NO
                      AND NVL(M.BATCH_NO, '/') = NVL(T2.BATCH_NO, '/')
                      AND NVL(M.BATCH_GROUD_NO, '/') =
                          NVL(T2.BATCH_GROUD_NO, '/')
         --                 AND  B.MANAGEMENT_NO IN
      -- (SELECT DEPARTMENT_CODE FROM COM_BASE_PLINE WHERE PLINE_CODE = T.PLINE_CODE)
  -- AND STORAGE_ATTR = '800302'
         AND M.NEXT_PROCESS_CDOE = 'E'
              ),
                   0) ACT_WEIGHT,
               DECODE(T.BESIDE_STATUS,
                      '00',
                      '上料结炉',
                      '10',
                      '旋扩结炉',
                      '20',
                      '均整结炉',
                      '30',
                      '定径结炉',
                      '40',
                      '表检结炉',
                      '50',
                      '生产点结炉',
                      '60',
                      '交库结炉') BESIDE_STATUS,
               DECODE(T.PER_STATUS,
                      '00',
                      '上料开始',
                      '10',
                      '旋扩开始',
                      '20',
                      '均整开始',
                      '30',
                      '定径开始',
                      '40',
                      '表检开始',
                      '50',
                      '生产点开始',
                      '60',
                      '交库开始') PER_STATUS
          FROM PLN_ZY_DBK_M T,PLN_ZY_DBK_C T2
         WHERE  t.heat_plan_no = t2.heat_plan_no
			]]>
	</query>
	<query id="PlanService.HeatTreatme.GetDbkPlan" desc="墩拔扩详细计划">
		<![CDATA[
		SELECT *
  FROM PLN_ZY_DBK_M
 WHERE HEAT_PLAN_NO =?
			]]>
	</query>
	<query id="PlanService.HeatTreatme.GetDbkPlanC" desc="墩拔扩详细计划从表">
		<![CDATA[
	SELECT *
  FROM PLN_ZY_DBK_C
 WHERE HEAT_PLAN_NO = ?
			]]>
	</query>
	<query id="PlanService.HeatTreatme.GetDbkPlanC2" desc="墩拔扩详细计划从表">
		<![CDATA[
	SELECT *
  FROM PLN_ZY_DBK_C
 WHERE HEAT_PLAN_NO = ?
  AND HEAT_PLAN_SQE =?
			]]>
	</query>
	<query id="PlanService.ProcessPlan.getCraftPathById" desc="查询工艺文件路径">
		<![CDATA[
        SELECT DISTINCT T.CRAFT_PATH FROM CRAFT_ORD_DESIGN T WHERE T.CRAFT_NO=? AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="PlanService.ProcessPlan.getQueryPlineCode" desc="接箍生产产线">
		<![CDATA[
        SELECT T.PLINE_CODE, T.PLINE_NAME FROM COM_BASE_PLINE T WHERE T.VALIDFLAG = '1' 
		]]>
	</query>
	<query id="PlanService.ProcessPlan.getQueryGX" desc="查询工序">
		<![CDATA[
		SELECT T.BASECODE,
       T.BASENAME,
       T.MEMO
  FROM COM_BASE_INFO T
 WHERE T.BASECODE = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="PlanService.ProcessPlan.getQueryDepPlineCode" desc="根据部门获取产线">
		<![CDATA[
SELECT T.PLINE_CODE
  FROM COM_BASE_PLINE T
 WHERE T.DEPARTMENT_DESC = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="PlanService.ProcessPlan.getQueryCraftNo" desc="获取工艺文件">
		<![CDATA[
SELECT C.CRAFT_PATH
  FROM PLN_SALEORD T1, PLN_SALEORD_PROC T, PLN_ZY_JGX_M M,CRAFT_ORD_DESIGN C
 WHERE --T.PLN_DIVIDE_ID = M.PLN_DIVIDE_ID AND 
 	T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
   AND T1.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK
   AND C.ORD_LN_PK=T1.ORD_LN_PK
   AND C.CRAFT_SEQ=M.CRAFT_SEQ
   AND C.VALIDFLAG='1'
   AND M.CRAFT_FILE_NO = ?
   AND M.CRAFT_SEQ = ?
   		]]>
	</query>
	<query id="PlanService.ProcessPlan.getQueryCraftNoJG" desc="获取工艺文件接箍">
		<![CDATA[
SELECT C.CRAFT_PATH
  FROM PLN_SALEORD T1, PLN_SALEORD_PROC T, PLN_ZY_JG M,CRAFT_ORD_DESIGN C
 WHERE --T.PLN_DIVIDE_ID = M.PLN_DIVIDE_ID AND 
   T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
   AND T1.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK    
   AND C.ORD_LN_PK=T1.ORD_LN_PK
   AND C.CRAFT_SEQ=M.CRAFT_SEQ
   AND C.VALIDFLAG='1'
   AND M.CRAFT_FILE_NO = ?
   AND M.CRAFT_SEQ = ?
   		]]>
	</query>
		<query id="PlanService.ProcessPlan.getQueryCraftNoRCL" desc="获取工艺文件接箍热处理">
		<![CDATA[
SELECT C.CRAFT_PATH
  FROM PLN_SALEORD T1, PLN_SALEORD_PROC T, pln_zy_rcl_m M,CRAFT_ORD_DESIGN C
 WHERE --T.PLN_DIVIDE_ID = M.PLN_DIVIDE_ID AND 
   T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
   AND T1.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK    
   AND C.ORD_LN_PK=T1.ORD_LN_PK    
   AND C.CRAFT_SEQ=M.CRAFT_SEQ
   AND C.VALIDFLAG='1'
   AND M.CRAFT_FILE_NO = ?
   AND M.CRAFT_SEQ = ?
   		]]>
	</query>
			<query id="PlanService.ProcessPlan.getQueryCraftNoDBK" desc="获取工艺文件接箍镦拔扩">
		<![CDATA[
SELECT C.CRAFT_PATH
  FROM PLN_SALEORD T1, PLN_SALEORD_PROC T, pln_zy_dbk_m M,CRAFT_ORD_DESIGN C
 WHERE --T.PLN_DIVIDE_ID = M.PLN_DIVIDE_ID AND 
   T.ORD_LN_DLY_PK = M.ORD_LN_DLY_PK
   AND T1.ORD_LN_DLY_PK=T.ORD_LN_DLY_PK    
   AND C.ORD_LN_PK=T1.ORD_LN_PK    
   AND C.CRAFT_SEQ=M.CRAFT_SEQ   
   AND C.VALIDFLAG='1'
   AND M.CRAFT_FILE_NO = ?
   AND M.CRAFT_SEQ = ?
   		]]>
	</query>
	<query id="PlanService.ProcessPlan.getStorage" desc="获取仓库">
		<![CDATA[
SELECT T.STORAGE_NO
  FROM YDM_BS_STORAGE T
 WHERE T.MANAGEMENT_NO = ?
   AND T.DEPARTMENT_CODE = ?
   AND T.STORAGE_ATTR = ?
   AND T.STORAGE_TYPE_NO = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="PlanService.ProcessPlan.getStorage1" desc="镦拔扩获取仓库">
		<![CDATA[
SELECT T.STORAGE_NO
  FROM YDM_BS_STORAGE T
 WHERE T.MANAGEMENT_NO = ?
   AND T.DEPARTMENT_CODE = ?
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="PlanService.getQueryWoId" desc="根据条件查询工单信息">
		<![CDATA[
SELECT T.WO_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.IF_ALL_OUT_WORK, '0', '否', '1', '是') IF_ALL_OUT_WORK,
       DECODE(T.IF_OUT_CUT, '0', '否', '1', '是') IF_OUT_CUT,
       DECODE(T.IF_OUT_CJG, '0', '否', '1', '是') IF_OUT_CJG,
       DECODE(T.IF_OUT_IMPRESS, '0', '否', '1', '是') IF_OUT_IMPRESS,
       DECODE(T.IF_OUT_LATHE, '0', '否', '1', '是') IF_OUT_LATHE,
       DECODE(T.IF_OUT_DETECT, '0', '否', '1', '是') IF_OUT_DETECT,
       DECODE(T.IF_OUT_BLAST, '0', '否', '1', '是') IF_OUT_BLAST,
       DECODE(T.IF_OUT_COAT, '0', '否', '1', '是') IF_OUT_COAT,
       T.PLAN_JG_NUM,
       T.CS_JG_NUM,
       T.XQ_JG_NUM,
       T.CUT_MACH_GRP_NO,
       T.CUT_MACH_GRP_NM,
       T.CUT_OK_NUM,
       T.CUT_FAIL_NUM,
       DECODE(T.CUT_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') CUT_STATUS,
       T.CJG_DEPT,
       T.CJG_OK_NUM,
       DECODE(T.CJG_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') CJG_STATUS,
       T.DEMAND_COPPER,
       T.IMPRESS_DEPT,
       T.IMPRESS_OK_NUM,
       DECODE(T.IMPRESS_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') IMPRESS_STATUS,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       T.LATHE_OK_NUM,
       T.LATHE_FAIL_NUM,
       DECODE(T.LATHE_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') LATHE_STATUS,
       T.THREAD_CHK_OK_NUM,
       T.THREAD_CHK_FAIL_NUM,
       DECODE(T.THREAD_CHK_STATUS,
              '0',
              '计划',
              '1',
              '检验中',
              '2',
              '检验完成') THREAD_CHK_STATUS,
       T.DEMAND_DETECTION,
       T.DETECT_DEPT,
       T.DETECT_OK_NUM,
       T.DETECT_FAIL_NUM,
       DECODE(T.DETECT_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') DETECT_STATUS,
       DECODE(T.DEMAND_BLAST, '0', '计划', '1', '生产中', '2', '生产完成') DEMAND_BLAST,
       T.BLAST_DEPT,
       T.BLAST_OK_NUM,
       DECODE(T.BLAST_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') BLAST_STATUS,
       T.SPOT_CHK_OK_NUM,
       T.SPOT_CHK_FAIL_NUM,
       DECODE(T.SPOT_CHK_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '生产完成') SPOT_CHK_STATUS,
       T.DEMAND_BONDERIZING,
       T.PLT_CU_DEPT,
       T.PLT_CU_OK_NUM,
       DECODE(T.PLT_CU_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') PLT_CU_STATUS,
       T.PHOS_DEPT,
       T.PHOS_OK_NUM,
       DECODE(T.PHOS_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') PHOS_STATUS,
       T.COPPER_DEPT,
       T.COPPER_OK_NUM,
       DECODE(T.COPPER_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') COPPER_STATUS,
       T.JUDGE_OK_NUM,
       T.JUDGE_FAIL_NUM,
       DECODE(T.JUDGE_STATUS, '0', '待判', '1', '已判', '2', '待复判') JUDGE_STATUS,
       T.INSTORE_NUM,
       DECODE(T.INSTORE_STATUS,
              '0',
              '待交库',
              '1',
              '部分交库',
              '2',
              '交库完成') INSTORE_STATUS,
       DECODE(T.ZY_BILL_STATUS,
              '0',
              '编辑',
              '1',
              '下发',
              '2',
              '生产中',
              '3',
              '生产完成') ZY_BILL_STATUS,
       T.MEMO,
       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,
       DECODE(T.ZY_BILL_BC, '1', '早', '2', '中', '3', '夜') ZY_BILL_BC,
       DECODE(T.ZY_BILL_BZ, '1', '甲', '2', '乙', '3', '丙', '4', '丁') ZY_BILL_BZ,
       TO_CHAR(T.ZY_START_TIME, 'YYYY-MM-DD HH24:MI:SS') ZY_START_TIME,
       TO_CHAR(T.ZY_END_TIME, 'YYYY-MM-DD HH24:MI:SS') ZY_END_TIME,
       T1.IF_MONITOR_JG,
       T1.PRO_PLAN_ID,
       T1.STEELNAME,
       T1.GRADENAME,
       TO_CHAR(T1.MIN_D,'FM9990.00') || '*' || TO_CHAR(T1.MIN_H ,'FM9990.00') JGL_DESC,
       T1.CODE_JG,
       T1.MODEL_DESC,
       T1.SPEC_JG_DESC,
       T1.STYLE_JG,
       T1.BL_WL_DESC,
       (SELECT SUM(T2.LOAD_PIECES)
          FROM COUPLING_LOADING_RESULT T2
         WHERE T2.WO_ID = T.WO_ID) LOAD_PIECES,
       (SELECT SUM(T2.LOAD_WEIGHT)
          FROM COUPLING_LOADING_RESULT T2
         WHERE T2.WO_ID = T.WO_ID) LOAD_WEIGHT
  FROM PLN_ZY_JG_WORKBILL T, PLN_ZY_JG T1
 WHERE 1 = 1
 AND T.ZY_BILL_STATUS>'0'
		]]>
	</query>


	<query id="PlanService.ulgetQueryWoId" desc="查询所有未封闭的工单信息">
		<![CDATA[
SELECT T.WO_ID,
       T.ZY_PLAN_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.IF_ALL_OUT_WORK, '0', '否', '1', '是') IF_ALL_OUT_WORK,
       DECODE(T.IF_OUT_CUT, '0', '否', '1', '是') IF_OUT_CUT,
       DECODE(T.IF_OUT_CJG, '0', '否', '1', '是') IF_OUT_CJG,
       DECODE(T.IF_OUT_IMPRESS, '0', '否', '1', '是') IF_OUT_IMPRESS,
       DECODE(T.IF_OUT_LATHE, '0', '否', '1', '是') IF_OUT_LATHE,
       DECODE(T.IF_OUT_DETECT, '0', '否', '1', '是') IF_OUT_DETECT,
       DECODE(T.IF_OUT_BLAST, '0', '否', '1', '是') IF_OUT_BLAST,
       DECODE(T.IF_OUT_COAT, '0', '否', '1', '是') IF_OUT_COAT,
       DECODE(T.COAT_TYPE, '0', '镀铜', '1', '磷化','2','无') COAT_TYPE,
       DECODE(T.IF_OUT_COPPER, '0', '否', '1', '是') IF_OUT_COPPER,
       T.PLAN_JG_NUM,
       T.CS_JG_NUM,
       T.XQ_JG_NUM,
       T.CUT_MACH_GRP_NO,
       T.CUT_MACH_GRP_NM,
       T.CUT_OK_NUM,
       T.CUT_FAIL_NUM,
       DECODE(T.CUT_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') CUT_STATUS,
       T.CJG_DEPT,
       T.CJG_OK_NUM,
       DECODE(T.CJG_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') CJG_STATUS,
       T.DEMAND_COPPER,
       T.IMPRESS_DEPT,
       T.IMPRESS_OK_NUM,
       DECODE(T.IMPRESS_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') IMPRESS_STATUS,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       T.LATHE_OK_NUM,
       T.LATHE_FAIL_NUM,
       DECODE(T.LATHE_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') LATHE_STATUS,
       T.THREAD_CHK_OK_NUM,
       T.THREAD_CHK_FAIL_NUM,
       DECODE(T.THREAD_CHK_STATUS,
              '0',
              '计划',
              '1',
              '检验中',
              '2',
              '检验完成') THREAD_CHK_STATUS,
       T.DEMAND_DETECTION,
       T.DETECT_DEPT,
       T.DETECT_OK_NUM,
       T.DETECT_FAIL_NUM,
       DECODE(T.DETECT_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') DETECT_STATUS,
       DECODE(T.DEMAND_BLAST, '0', '计划', '1', '生产中', '2', '生产完成') DEMAND_BLAST,
       T.BLAST_DEPT,
       T.BLAST_OK_NUM,
       DECODE(T.BLAST_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') BLAST_STATUS,
       T.SPOT_CHK_OK_NUM,
       T.SPOT_CHK_FAIL_NUM,
       DECODE(T.SPOT_CHK_STATUS,
              '0',
              '计划',
              '1',
              '生产中',
              '2',
              '生产完成') SPOT_CHK_STATUS,
       T.DEMAND_BONDERIZING,
       T.PLT_CU_DEPT,
       T.PLT_CU_OK_NUM,
       DECODE(T.PLT_CU_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') PLT_CU_STATUS,
       T.PHOS_DEPT,
       T.PHOS_OK_NUM,
       DECODE(T.PHOS_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') PHOS_STATUS,
       T.COPPER_DEPT,
       T.COPPER_OK_NUM,
       DECODE(T.COPPER_STATUS, '0', '计划', '1', '生产中', '2', '生产完成') COPPER_STATUS,
       T.JUDGE_OK_NUM,
       T.JUDGE_FAIL_NUM,
       DECODE(T.JUDGE_STATUS, '0', '待判', '1', '已判', '2', '待复判') JUDGE_STATUS,
       T.INSTORE_NUM,
       DECODE(T.INSTORE_STATUS,
              '0',
              '待交库',
              '1',
              '部分交库',
              '2',
              '交库完成') INSTORE_STATUS,
       DECODE(T.ZY_BILL_STATUS,
              '0',
              '计划',
              '1',
              '下发',
              '2',
              '生产中',
              '3',
              '生产完成',
              '4',
              '生产关闭') ZY_BILL_STATUS,
       T.MEMO,
       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,
       DECODE(T.ZY_BILL_BC, '1', '早', '2', '中', '3', '夜') ZY_BILL_BC,
       DECODE(T.ZY_BILL_BZ, '1', '甲', '2', '乙', '3', '丙', '4', '丁') ZY_BILL_BZ,
       TO_CHAR(T.ZY_START_TIME, 'YYYY-MM-DD HH24:MI:SS') ZY_START_TIME,
       TO_CHAR(T.ZY_END_TIME, 'YYYY-MM-DD HH24:MI:SS') ZY_END_TIME,
       DECODE(T.IF_IMPRESS, '0', '否', '1', '是') IF_IMPRESS,
       NVL((SELECT sum(T1.LOAD_PIECES) FROM COUPLING_LOADING_RESULT T1 WHERE T1.WO_ID=T.WO_ID),0) LOAD_PIECES
  FROM PLN_ZY_JG_WORKBILL T
 WHERE T.ZY_BILL_STATUS<'4'
		]]>
	</query>
	
	
	<query id="PlanService.getQueryDbkPortVrp1" desc="查询镦拔扩管号队列合格的支、吨">
		<![CDATA[
	SELECT NVL(SUM(ACT_COUNT),0) ACT_COUNT, NVL(SUM(ACT_WEIGHT),0) ACT_WEIGHT,NVL(SUM(ACT_LEN),0) ACT_LEN
  FROM PORT_VRP_BATCH_SAMPLE_RESULT
 WHERE MAT_STATUS = '00'
   AND HEAT_PLAN_NO = ?
		]]>
	</query>
	
<query id="PlanService.selectOfflineCount" desc="查询接箍库存离线是否有数据">
		<![CDATA[
	SELECT T.Mat_No,nvl(t.SINGLEWEIGHT,0) SINGLEWEIGHT  FROM COUPLING_MAT_M T WHERE T.JUDGE_STOVE_NO= ? AND T.BATCH_NO=? AND T.WO_ID=? AND T.QCM_STAUS='11'
		]]>
	</query>
	<query id="PlanService.getQueryDbkPortVrp2" desc="">
		<![CDATA[
	SELECT *
  FROM PORT_VRP_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO =? AND MAT_NO =?
		]]>
	</query>
	
	<query id="PlanService.getQueryRclPortHtt2" desc="">
		<![CDATA[
	SELECT *
  FROM PORT_HTT_BATCH_SAMPLE_RESULT
 WHERE HEAT_PLAN_NO =? AND PROCESS_SEQ =? AND MAT_NO =?
		]]>
	</query>
	<query id="PlanService.getQueryJgxPortMch2dbk" desc="">
		<![CDATA[
SELECT T.*,
        G.GROUP_NO GROUP_NO_REAL,

    null  as ACT_LEN_MAX_REAL,

     null  as ACT_LEN_MIN_REAL
  FROM port_vrp_batch_sample_result T
  LEFT JOIN PLN_ZY_dbk_M M
    ON M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ORDER_dbk_S O
    ON M.PRO_PLAN_ID = O.PRO_PLAN_ID
   AND M.GX_PLAN_NO = O.GX_PLAN_NO
  LEFT JOIN MCH_GROUPNO G
    ON G.ORDER_NO = M.ORDER_NO || '/' || M.ORDER_SEQ
   AND T.ACT_LEN <
       NVL(DECODE(GROUP_MAX_SIGN, '<=', GROUP_MAX + 0.001, GROUP_MAX),
           T.ACT_LEN + 0.001)
   AND T.ACT_LEN >
       NVL(DECODE(GROUP_MIN_SIGN, '>=', GROUP_MIN - 0.001, GROUP_MIN),
           T.ACT_LEN - 0.001)
   AND ROWNUM = 1
  LEFT JOIN (SELECT ORDER_NO, MAX(GROUP_MAX) MAX_LEN, MIN(GROUP_MIN) MIN_LEN
               FROM MCH_GROUPNO
              WHERE FLAG = '1'
              GROUP BY ORDER_NO) P
    ON P.ORDER_NO = M.ORDER_NO || '/' || M.ORDER_SEQ
 WHERE T.HEAT_PLAN_NO = ?
   AND T.MAT_NO = ?
		]]>
	</query>
	
	<query id="PlanService.getQueryJgxPortMch2" desc="">
		<![CDATA[
SELECT T.*,
       G.GROUP_NO GROUP_NO_REAL,
       --- 大于合同范围  1M 1个范围
       CASE
         WHEN T.ACT_LEN > NVL(P.MAX_LEN, O.LENGTHMAX)  AND NVL(O.SIGL_LEN, 0) <=0 THEN
          CEIL(T.ACT_LEN - NVL(P.MAX_LEN, O.LENGTHMAX)) +
          NVL(P.MAX_LEN, O.LENGTHMAX)
       ---小于合同范围  1M 1个范围
         WHEN T.ACT_LEN < NVL(P.MIN_LEN, NVL(O.SHORTEST, 0)) THEN
          NVL(P.MIN_LEN, NVL(O.SHORTEST, 0)) -
          CEIL(NVL(P.MIN_LEN, NVL(O.SHORTEST, 0)) - T.ACT_LEN) + 1
         ELSE
         --- 有单倍尺
          CASE
            WHEN NVL(O.SIGL_LEN, 0) > 0 THEN
            --- 长度大于合同最小值
             CASE
               WHEN T.ACT_LEN >= O.LENGTHMIN THEN
               --长度不在 单倍尺的公差范围
                CASE
                  WHEN T.ACT_LEN -
                       (O.LENGTHMIN +
                       O.SIGL_LEN * (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN))) >
                       O.ENDLEN_SPECSTD THEN
                  -- 最大值超出合同最大值   取合同最大值
                   CASE
                     WHEN O.LENGTHMIN +
                          O.SIGL_LEN *
                          (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN) + 1) >
                          O.LENGTHMAX THEN
                       O.LENGTHMIN +
                      O.SIGL_LEN * (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN) + 1)
                     ELSE
                     O.LENGTHMAX
                   END
                --长度在单倍尺的公差范围
                  ELSE
                   (O.LENGTHMIN +
                   O.SIGL_LEN * (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN))) +
                   O.ENDLEN_SPECSTD
                END
               ELSE --- 长度大于合同最小值
               --长度不在 单倍尺的公差范围
                CASE
                  WHEN T.ACT_LEN -
                       (O.LENGTHMIN -
                       O.SIGL_LEN * (CEIL((O.LENGTHMIN - T.ACT_LEN) / O.SIGL_LEN))) >
                       O.ENDLEN_SPECSTD THEN
                   (O.LENGTHMIN -
                   O.SIGL_LEN * (CEIL((O.LENGTHMIN - T.ACT_LEN) / O.SIGL_LEN) - 1))
                --长度在单倍尺的公差范围
                  ELSE
                   (O.LENGTHMIN -
                   O.SIGL_LEN * (CEIL((O.LENGTHMIN - T.ACT_LEN) / O.SIGL_LEN))) +
                   O.ENDLEN_SPECSTD
                END
             END
          ----没单倍尺  取已经存储规则的最大值
            ELSE
             GROUP_MAX
          END
       END ACT_LEN_MAX_REAL,

       --- 大于合同范围  1M 1个范围
       CASE
         WHEN T.ACT_LEN > NVL(P.MAX_LEN, O.LENGTHMAX)  AND NVL(O.SIGL_LEN, 0) <=0 THEN
          CEIL(T.ACT_LEN - NVL(P.MAX_LEN, O.LENGTHMAX)) +
          NVL(P.MAX_LEN, O.LENGTHMAX) - 1
       ---小于合同范围  1M 1个范围
         WHEN T.ACT_LEN < NVL(P.MIN_LEN, NVL(O.SHORTEST, 0))  AND NVL(O.SIGL_LEN, 0) <=0 THEN
          NVL(P.MIN_LEN, NVL(O.SHORTEST, 0)) -
          CEIL(NVL(P.MIN_LEN, NVL(O.SHORTEST, 0)) - T.ACT_LEN)
         ELSE
         --- 有单倍尺
          CASE
            WHEN NVL(O.SIGL_LEN, 0) > 0 THEN
            --- 长度大于合同最小值
             CASE
               WHEN T.ACT_LEN >= O.LENGTHMIN THEN
               --长度不在 单倍尺的公差范围
                CASE
                  WHEN T.ACT_LEN -
                       (O.LENGTHMIN +
                       O.SIGL_LEN * (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN))) >
                       O.ENDLEN_SPECSTD THEN
                   O.LENGTHMIN +
                   O.SIGL_LEN * (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN)) +
                   ENDLEN_SPECSTD
                --长度在单倍尺的公差范围
                  ELSE
                   O.LENGTHMIN +
                   O.SIGL_LEN * (FLOOR((T.ACT_LEN - O.LENGTHMIN) / O.SIGL_LEN))
                END
               ELSE --- 长度大于合同最小值
               --长度不在 单倍尺的公差范围
                CASE
                  WHEN T.ACT_LEN -
                       (O.LENGTHMIN -
                       O.SIGL_LEN * (CEIL((O.LENGTHMIN - T.ACT_LEN) / O.SIGL_LEN))) >
                       O.ENDLEN_SPECSTD THEN
                   (O.LENGTHMIN -
                   O.SIGL_LEN * (CEIL((O.LENGTHMIN - T.ACT_LEN) / O.SIGL_LEN))) +
                   O.ENDLEN_SPECSTD
                --长度在单倍尺的公差范围
                  ELSE
                   (O.LENGTHMIN -
                   O.SIGL_LEN * (CEIL((O.LENGTHMIN - T.ACT_LEN) / O.SIGL_LEN)))
                END
             END
          ----没单倍尺  取已经存储规则的最大值
            ELSE
             GROUP_MIN
          END
       END ACT_LEN_MIN_REAL
  FROM PORT_MCH_BATCH_SAMPLE_RESULT T
  LEFT JOIN PLN_ZY_JGX_M M
    ON M.HEAT_PLAN_NO = T.HEAT_PLAN_NO
  LEFT JOIN PLN_ORDER_JGX_S O
    ON M.PRO_PLAN_ID = O.PRO_PLAN_ID
   AND M.GX_PLAN_NO = O.GX_PLAN_NO
  LEFT JOIN MCH_GROUPNO G
    ON G.ORDER_NO = M.ORDER_NO || '/' || M.ORDER_SEQ
   AND T.ACT_LEN <
       NVL(DECODE(GROUP_MAX_SIGN, '<=', GROUP_MAX + 0.001, GROUP_MAX),
           T.ACT_LEN + 0.001)
   AND T.ACT_LEN >
       NVL(DECODE(GROUP_MIN_SIGN, '>=', GROUP_MIN - 0.001, GROUP_MIN),
           T.ACT_LEN - 0.001)
   AND ROWNUM = 1
  LEFT JOIN (SELECT ORDER_NO, MAX(GROUP_MAX) MAX_LEN, MIN(GROUP_MIN) MIN_LEN
               FROM MCH_GROUPNO
              WHERE FLAG = '1'
              GROUP BY ORDER_NO) P
    ON P.ORDER_NO = M.ORDER_NO || '/' || M.ORDER_SEQ
 WHERE T.HEAT_PLAN_NO = ?
   AND T.MAT_NO = ?
		]]>
	</query>
	<query id="PlanService.getQueryCouplingcominfo" desc="">
		<![CDATA[
	SELECT T.STATION_STATUS
  FROM COUPLING_COM_INFO T
 WHERE 1 = 1
		]]>
	</query>
	<query id="PlanService.getQueryRCLPortVrp1" desc="查询热处理管号队列合格的支、吨">
		<![CDATA[
	SELECT NVL(SUM(ACT_COUNT),0) ACT_COUNT, NVL(SUM(ACT_WEIGHT),0) ACT_WEIGHT,NVL(SUM(ACT_LEN),0) ACT_LEN
  FROM PORT_HTT_BATCH_SAMPLE_RESULT
 WHERE MAT_STATUS = '00'
   AND HEAT_PLAN_NO = ?
		]]>
	</query>
	<query id="PlanService.getQueryJGPortVrp1" desc="查询加工管号队列合格的支、吨">
		<![CDATA[
	SELECT NVL(SUM(ACT_COUNT),0) ACT_COUNT, NVL(SUM(ACT_WEIGHT),0) ACT_WEIGHT,NVL(SUM(ACT_LEN),0) ACT_LEN
  FROM PORT_MCH_BATCH_SAMPLE_RESULT
 WHERE MAT_STATUS IN ('00','10')
   AND HEAT_PLAN_NO = ?
		]]>
	</query>
	
	<query id="PlanService.getQueryJGPortVrp2" desc="初始查询管号队列合格支吨">
		<![CDATA[
	SELECT NVL(SUM(ACT_COUNT),0) ACT_COUNT, NVL(SUM(ACT_WEIGHT),0) ACT_WEIGHT,NVL(SUM(ACT_LEN),0) ACT_LEN
  FROM PORT_MCH_BATCH_SAMPLE_RESULT
 WHERE MAT_STATUS in ('00','10')
   AND HEAT_PLAN_NO = ?
   AND OUTNUM_CUT = ?
		]]>
	</query>
	
		<query id="PlanService.getQueryplinename" desc="查询生产产线">
		<![CDATA[
	SELECT T.PLINE_NAME FROM COM_BASE_PLINE T WHERE 1=1
		]]>
	</query>

	
	<query id="PlanService.getQueryDbkPortVrp" desc="墩拔库管号队列查询">
		<![CDATA[
		SELECT T.HEAT_PLAN_NO,
       T.MAT_NO,
       T.M_MAT_NO,
       T.M_M_MAT_NO,
       T.LOT_NO,
       T.LOT_NO_SQE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       T.SAMPLE_PIPE_LEN,
       T.GET_SAMPLE_SHIFT,
       T.GET_SAMPLE_CLASS,
       T.GET_SAMPLE_NAME,
       TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
       T.OLD_JUDGE_STOVE_NO,
       DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.OP_PROCESS
           AND T1.VALIDFLAG = '1') OP_PROCESS,
       DECODE(T.MAT_STATUS, '00', '合格', '10', '剔除', '20', '待处理','30','另组炉','40','委外废品') MAT_STATUS,
       DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
       DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       T.PRO_USER,
       DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.REMARK,
      T.PRC_TECHNOLOGY_PATH
  FROM PORT_VRP_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?	
 ORDER BY T.MAT_NO ASC
			]]>
	</query>
	
	<query id="PlanService.getQueryDbkPortVrp3" desc="热处理管号队列查询">
		<![CDATA[
		SELECT T.HEAT_PLAN_NO,
       T.MAT_NO,
       T.M_MAT_NO,
       T.M_M_MAT_NO,
       T.LOT_NO,
       T.LOT_NO_SQE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       T.SAMPLE_PIPE_LEN,
       T.GET_SAMPLE_SHIFT,
       T.GET_SAMPLE_CLASS,
       T.GET_SAMPLE_NAME,
       TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
       T.OLD_JUDGE_STOVE_NO,
       DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.OP_PROCESS
           AND T1.VALIDFLAG = '1') OP_PROCESS,
        T.OP_PROCESS OP_PROCESS_CODE,
       DECODE(T.MAT_STATUS, '00', '合格', '10', '剔除', '20', '待处理','30','另组炉','40','委外废品') MAT_STATUS,
       DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
       DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       T.PRO_USER,
       DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.REMARK,
      T.PRC_TECHNOLOGY_PATH,
      NVL(T.PROCESS_SEQ,1) PROCESS_SEQ,
      T.PHY_BATCH_NO,
      BAR_CODE,
      T.ACT_LEN_U
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = ?
 ORDER BY T.MAT_NO ASC
			]]>
	</query>

	<query id="PlanService.getQueryOKHttPort" desc="热处理管号队列查询">
		<![CDATA[
		SELECT *
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = ?
 AND MAT_STATUS = '00'
 AND INSTORE_FLAG = '0'
 AND ROWNUM < ?
 ORDER BY T.MAT_NO ASC
			]]>
	</query>

	<query id="PlanService.getQueryOKHttPortDesc" desc="热处理管号队列查询">
		<![CDATA[
		SELECT *
  FROM PORT_HTT_BATCH_SAMPLE_RESULT T
 WHERE T.HEAT_PLAN_NO = ?
 AND PROCESS_SEQ = ?
 AND MAT_STATUS = '00'
 AND INSTORE_FLAG = '0'
 AND ROWNUM < ?
 ORDER BY T.MAT_NO DESC
			]]>
	</query>

	<query id="PlanService.getQueryJGPortVrp3" desc="加工管号队列查询">
	<![CDATA[
		SELECT T.HEAT_PLAN_NO,
       T.MAT_NO,
       T.M_MAT_NO,
       T.M_M_MAT_NO,
       T.LOT_NO,
       T.LOT_NO_SQE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       T.SAMPLE_PIPE_LEN,
       T.GET_SAMPLE_SHIFT,
       T.GET_SAMPLE_CLASS,
       T.GET_SAMPLE_NAME,
       TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
       T.OLD_JUDGE_STOVE_NO,
       DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.OP_PROCESS
           AND T1.VALIDFLAG = '1') OP_PROCESS,
       T.OP_PROCESS OP_PROCESS_CODE,
       DECODE(T.MAT_STATUS, '00', '合格', '10', '剔除','15','绝废', '20', '待处理','30','另组炉','40','委外废品') MAT_STATUS,
       DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
       DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       T.PRO_USER,
       DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.REMARK,
       T.OUTNUM_CUT,
      T.PRC_TECHNOLOGY_PATH,
      T.FEED_HEAT_NO,
      T.BAR_CODE,
      T.IS_FINALCHECK
  FROM port_mch_batch_sample_result T
 WHERE T.HEAT_PLAN_NO = ?
 ORDER BY T.MAT_NO ASC
			]]>
</query>

	<query id="PlanService.getQueryJGPortMchNew" desc="加工管号队列查询">
		<![CDATA[
		SELECT T.HEAT_PLAN_NO,
       T.MAT_NO,
       T.M_MAT_NO,
       T.M_M_MAT_NO,
       T.LOT_NO,
       T.LOT_NO_SQE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       T.SAMPLE_PIPE_LEN,
       T.GET_SAMPLE_SHIFT,
       T.GET_SAMPLE_CLASS,
       T.GET_SAMPLE_NAME,
       TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
       T.OLD_JUDGE_STOVE_NO,
       DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.OP_PROCESS
           AND T1.VALIDFLAG = '1') OP_PROCESS,
        T.OP_PROCESS OP_PROCESS_CODE,
       DECODE(T.MAT_STATUS, '00', '合格', '10', '剔除', '20', '待处理','30','另组炉','40','委外废品') MAT_STATUS,
       DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
       DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       T.PRO_USER,
       DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.REMARK,
       T.OUTNUM_CUT,
      T.PRC_TECHNOLOGY_PATH,
      T.FEED_HEAT_NO,
      T.BAR_CODE,
      T.VALIDFLAG,
      T.TR_FLAG,
      T.MEASURING_SEQ,
      T.RESULT_NO,
      T.PHY_BATCH_NO,
      (SELECT COUNT(1)
           FROM MCH_FINAL_CHECK_RESULT R, MCH_FINAL_CHECK_RESULT_MAT_NO R1
          WHERE R.RESULT_NO = R1.RESULT_NO
            AND R.HEAT_PLAN_NO = T.HEAT_PLAN_NO
            AND R.BATCH_NO = T.PHY_BATCH_NO
            AND T.MAT_NO = R1.MAT_NO) IS_FINALCHECK
  FROM port_mch_batch_sample_result T
 WHERE T.HEAT_PLAN_NO = ?
 AND T.PHY_BATCH_NO =?
 AND  VALIDFLAG='1'
			]]>
	</query>

	<query id="PlanService.getQueryDBPortMchNew" desc="镦拔管号队列查询">
		<![CDATA[
SELECT T.HEAT_PLAN_NO,
       T.MAT_NO,
       T.M_MAT_NO,
       T.M_M_MAT_NO,
       T.LOT_NO,
       T.LOT_NO_SQE,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
       T.SAMPLE_PIPE_LEN,
       T.GET_SAMPLE_SHIFT,
       T.GET_SAMPLE_CLASS,
       T.GET_SAMPLE_NAME,
       TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
       T.OLD_JUDGE_STOVE_NO,
       DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
       (SELECT T1.BASENAME
          FROM COM_BASE_INFO T1
         WHERE T1.BASECODE = T.OP_PROCESS
           AND T1.VALIDFLAG = '1') OP_PROCESS,
        T.OP_PROCESS OP_PROCESS_CODE,
       DECODE(T.MAT_STATUS, '00', '合格', '10', '剔除', '20', '待处理','30','另组炉','40','委外废品') MAT_STATUS,
       DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
       DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
       T.PRO_USER,
       DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
       DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.REMARK,
        null as OUTNUM_CUT,
      T.PRC_TECHNOLOGY_PATH,
      T.FEED_HEAT_NO,
     null as  BAR_CODE,
      T.VALIDFLAG,
      T.TR_FLAG,
     null as   MEASURING_SEQ,--
      T.RESULT_NO,
      T.PHY_BATCH_NO,
      (SELECT COUNT(1)
           FROM MCH_FINAL_CHECK_RESULT R, MCH_FINAL_CHECK_RESULT_MAT_NO R1
          WHERE R.RESULT_NO = R1.RESULT_NO
            AND R.HEAT_PLAN_NO = T.HEAT_PLAN_NO
            AND R.BATCH_NO = T.PHY_BATCH_NO
            AND T.MAT_NO = R1.MAT_NO) IS_FINALCHECK
  FROM port_vrp_batch_sample_result T
 WHERE T.HEAT_PLAN_NO = ?
 AND  VALIDFLAG='1'
			]]>
	</query>

	<query id="PlanService.getQueryJGPortMchNewAll" desc="加工管号队列查询">
		<![CDATA[
	 SELECT T.HEAT_PLAN_NO,
        T.MAT_NO,
        T.M_MAT_NO,
        T.M_M_MAT_NO,
        T.LOT_NO,
        T.LOT_NO_SQE,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.JUDGE_STOVE_NO,
        T.BATCH_NO,
        T.GROUP_NO,
        T.STOVE_NO,
        T.FLAG_STOVE_NO,
        T.ACT_DIMATER,
        T.ACT_HEIGHT,
        T.ACT_LEN,
        T.ACT_LEN_MIN,
        T.ACT_LEN_MAX,
        T.ACT_COUNT,
        T.ACT_WEIGHT,
        T.ACT_THEORY_WEIGHT,
        DECODE(T.IS_SAMPLE_PIPE, '0', '否', '1', '是') IS_SAMPLE_PIPE,
        T.SAMPLE_PIPE_LEN,
        T.GET_SAMPLE_SHIFT,
        T.GET_SAMPLE_CLASS,
        T.GET_SAMPLE_NAME,
        TO_CHAR(T.GET_SAMPLE_TIME, 'YYYY-MM-DD HH24:MI:SS') GET_SAMPLE_TIME,
        T.OLD_JUDGE_STOVE_NO,
        DECODE(T.GROUP_FLAG, '0', '未组炉', '1', '组炉') GROUP_FLAG,
        (SELECT T1.BASENAME
           FROM COM_BASE_INFO T1
          WHERE T1.BASECODE = T.OP_PROCESS
            AND T1.VALIDFLAG = '1') OP_PROCESS,
        T.OP_PROCESS OP_PROCESS_CODE,
        DECODE(T.MAT_STATUS,
               '00',
               '合格',
               '10',
               '剔除',
               '20',
               '待处理',
               '30',
               '另组炉',
               '40',
               '委外废品') MAT_STATUS,
        DECODE(T.LEVE_LOG, '00', '无', '10', '离线', '20', '返线') LEVE_LOG,
        DECODE(T.INSTORE_FLAG, '0', '未入库', '1', '已入库') INSTORE_FLAG,
        T.PRO_USER,
        DECODE(T.PRO_SHIFT, 1, '早', 2, '中', 3, '夜', 0, '常白') PRO_SHIFT,
        DECODE(T.PRO_GROUP, 1, '甲', 2, '乙', 3, '丙', 4, '丁') PRO_GROUP,
        TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
        T.REMARK,
        T.OUTNUM_CUT,
        T.FEED_HEAT_NO,
        T.BAR_CODE,
        T.VALIDFLAG,
        T.TR_FLAG,
        T1.MAT_NO MEASURING_SEQ,
        T.RESULT_NO,
        T.PHY_BATCH_NO,
            (SELECT COUNT(1)
           FROM MCH_FINAL_CHECK_RESULT R, MCH_FINAL_CHECK_RESULT_MAT_NO R1
          WHERE R.RESULT_NO = R1.RESULT_NO
            AND R.HEAT_PLAN_NO = T.HEAT_PLAN_NO
            AND R.BATCH_NO = T.PHY_BATCH_NO
            AND T1.MAT_NO = R1.MEASURING_SEQ) IS_FINALCHECK
   FROM PORT_MCH_BATCH_SAMPLE_RESULT T LEFT JOIN
        (SELECT T.JUDGE_STOVE_NO,
                T.BATCH_NO,
                T.MAT_NO_CX,
                MIN(TO_NUMBER(T.MAT_NO)) MAT_NO
           FROM RTD_MEASURE_POSDATA T
          GROUP BY T.JUDGE_STOVE_NO, T.BATCH_NO, T.MAT_NO_CX) T1 ON  T.MAT_NO = T1.MAT_NO_CX
    AND T.JUDGE_STOVE_NO = T1.JUDGE_STOVE_NO
    AND (T.PHY_BATCH_NO = T1.BATCH_NO)
  WHERE 1=1
    AND T.HEAT_PLAN_NO = ?
     AND T.PHY_BATCH_NO =?
    AND VALIDFLAG = '1'

			]]>
	</query>

	<query id="PlanService.QueryLoadMchPort" desc="查询加工管号队列查询">
		<![CDATA[
       SELECT T.MAT_NO,
              T.BAR_CODE,
              T.ACT_LEN,
              NVL(T.PONDER_GROSS_WT, T.ACT_WEIGHT) ACT_WEIGHT,
              '合格' MAT_STATUS,
              '未入库' INSTORE_FLAG
         FROM MAT_BC_M T, YDM_BC_BUTTRESS B
        WHERE T.MAT_NO = B.MAT_NO
          AND T.PRODUCT_FLAG = '801401'
          AND T.MAT_STATUS = '80150103'
          AND T.NEXT_PROCESS_CDOE = 'G'
          AND (EXISTS (SELECT 1 FROM PLN_ZY_JGX_M  WHERE HEAT_PLAN_NO = T.HEAT_PLAN_NO_NEXT AND IF_MATCH_ODD = '5') OR
          ( NVL(T.BATCH_NO, '/') =  NVL(?, '/')
          AND   NVL(T.BATCH_GROUD_NO, '/') =  NVL(?, '/')))
          AND T.HEAT_PLAN_NO_NEXT = ?
        ORDER BY T.MAT_NO ASC
	  ]]>
	</query>

	<query id="PlanService.getQueryJGPortVrp4" desc="加工管号队列查询">
		<![CDATA[
		   SELECT * FROM port_mch_batch_sample_result T WHERE T.HEAT_PLAN_NO = ? AND (MAT_STATUS = '00' or MAT_STATUS = '10')
			]]>
	</query>

	<query id="PlanService.getHeatPlanSeq" desc="获取上料行ID">
		<![CDATA[
   SELECT ? ||LPAD(SUBSTR(NVL(MAX(T.HEAT_PLAN_SQE),'00'),-2,2) + 1, 2, '0') AS HEAT_PLAN_SQE  ]]>
	</query>

	<query id="PlanService.SetPortLen" desc="修改管号队列长度">
		<![CDATA[

         UPDATE PORT_VRP_BATCH_SAMPLE_RESULT
            SET ACT_LEN = ?,
            ACT_WEIGHT = ? * ACT_WEIGHT
          WHERE HEAT_PLAN_NO = ?
            AND MAT_STATUS = '00'
            AND ACT_LEN = ?
            AND ROWNUM <= ?
]]>
	</query>

	<query id="PlanService.SelectPortActLenCount" desc="查询管号队列长度支数">
		<![CDATA[
           SELECT COUNT(1) COUNT FROM PORT_VRP_BATCH_SAMPLE_RESULT
             WHERE HEAT_PLAN_NO = ?
            AND MAT_STATUS = '00'
            AND ACT_LEN = ?
]]>
	</query>

	<query id="PlanService.queryPlnOrderDbk" desc="查询镦拔扩订单信息">
		<![CDATA[
       SELECT
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.AIMOUTDIAMETER,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTH_IN,
       NVL(T.LEN_CUTHEAD,0) LEN_CUTHEAD,
       NVL(T.LEN_CUTEND,0) LEN_CUTEND,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.ISENDGX,
       T.IF_MONITOR_DBK,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.GRADECODE,
       T.GRADENAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.REAL_BATCH_WT,
       T.REAL_BATCH_NUM,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       T.WHOLE_BACKLOG_DESC,
       T.IF_CRAFT_LOCKED,
       T.WEIGTH_S_MIN,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.VALIDFLAG,T.DECISION
 FROM PLN_ORDER_DBK_S T
 WHERE 1=1

      ]]>
	</query>


	<query id="PlanService.queryPlnOrdeRcl" desc="查询热处理订单信息">
		<![CDATA[
       SELECT
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.GRADECODE,
       T.GRADENAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHDISC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.AIMLENGTH,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.WEIGTH_S,
       T.NUM_S,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.IF_MONITOR_RCL,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.ZY_BATCH_ID,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.ISENDGX,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.IS_PLAN_OK,
       T.STEELCODE,
       T.STEELNAME,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       T.WHOLE_BACKLOG_DESC,
       T.IF_CRAFT_LOCKED,
       T.WEIGTH_S_MIN,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       T.VALIDFLAG,T.DECISION,T.PRDCR_ADVC_DAY,T.GROUP_RCL
 FROM PLN_ORDER_RCL_S T
 WHERE 1=1
      ]]>
	</query>

	<query id="PlanService.queryPlnOrderJgx" desc="查询加工线订单信息">
		<![CDATA[
       SELECT
       T.PRO_ORDER_NO,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.INWL_ID,
       T.INWL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.WEIGTH_S,
       T.NUM_S,
       T.GX_PRO_SEQ,
       T.PLAN_USETIME,
       TO_CHAR(T.PLAN_TIME_B, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_B,
       TO_CHAR(T.PLAN_TIME_E, 'YYYY-MM-DD HH24:MI:SS') PLAN_TIME_E,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMWALLTHICK,
       T.AIMLENGTH,
       T.SHRT_LEN_RATO,
       T.SHORTEST,
       T.LONG_LEN_RATO,
       T.LONGEST,
       T.SHRT_STOVE,
       T.AVG_LEN_MIN,
       T.DIFRNC_LEN_MAX,
       T.SIGL_LEN,
       T.ENDLEN_SPECSTD,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.LENGTH_IN,
       T.OUTNUM_CUT,
       T.IN_WEIGHT_S,
       T.IN_NUM_S,
       T.ADD_WT_IN,
       T.ADD_NUM_IN,
       T.MATCH_WT_IN,
       T.MATCH_NUM_IN,
       T.IF_MONITOR_JGX,
       T.PRDCR_NO,
       T.MONITOR_POINT,
       T.CIC,
       T.PIC,
       T.SIC,
       T.DIC,
       T.WIC,
       T.GIC,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.FINISHWEIGHT,
       T.FINISHNUM,
       T.IS_PLAN_OK,
       T.ZY_BATCH_ID,
       T.PRO_MONTH,
       T.PREVIOUS_GX,
       T.PREV_GXPLAN_ID,
       T.IF_EXPORT,
       T.FINAL_USER_DESC,
       T.PROCESS_DESC_C_ZG,
       T.GROUP_ROLL_NAME,
       TO_CHAR(T.BEGIN_TIME_ZG, 'YYYY-MM-DD HH24:MI:SS') BEGIN_TIME_ZG,
       T.PRDCR_ADVC_DAY,
       T.WHOLE_BACKLOG_DESC,
       T.PRIORITY,
       T.PRIORITY_MEMO,
       TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
       T.STATION_NM,
       T.OUTLINE_SITE_250,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.MEMO,
       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
       T.ISSUED_MAN,
       TO_CHAR(T.LAST_UNDOWN_TIME, 'YYYY-MM-DD HH24:MI:SS') LAST_UNDOWN_TIME,
       T.LAST_UNDOWN_MAN,
       T.VERSION_NO,
       T.PROCESSING_COST,
       T.TOTAL_COST,
       T.IF_STOVE_ISSUED,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.IS_ONLOAD_LINE,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC_C,
       T.MSC,
       T.INDEX_SEQ,
       T.BOM,
       T.IF_CRAFT_LOCKED,
       T.VALIDFLAG,T.DECISION
 FROM PLN_ORDER_JGX_S T
 WHERE 1=1
      ]]>
	</query>

	<query id="PlanService.getMaxGxPlnSeq" desc="查询最大炉次顺序号">
		<![CDATA[
            SELECT TO_NUMBER(NVL(MAX(T.GX_PRO_SEQ),0))+1 AS GX_PRO_SEQ
                 ]]>
	</query>

	<query id="PlanService.QueryDbkGroup" desc="查询镦拔扩去向">
		<![CDATA[
      SELECT DECODE(T.ISENDGX,
              '1',
              (CASE
                WHEN D.TRANSIT_TYP = '110501' THEN
                 '汽运' || '  ' ||
                 (SELECT D1.DELVRY_ADDR
                    FROM SLM_ORDER_LINE_DELIVERY D1
                   WHERE D1.VALIDFLAG = '1'
                     AND INSTR(D1.DELVRY_ADDR, '客户库') > 0
                     AND D1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
                WHEN D.TRANSIT_TYP = '110502' THEN
                 '铁运' || '  ' ||
                 (SELECT C.STATION_NM
                    FROM SLM_ORDER_DELIVERY_TRANSIT Y, SLM_BASE_STATION C
                   WHERE Y.VALIDFLAG = '1'
                     AND Y.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                     AND Y.STATION_NO = C.STATION_NO
                     AND C.VALIDFLAG = '1'
                     AND Y.INDEX_SEQ = '1')
                ELSE
                (SELECT M.PLINE_NAME
                    FROM PLN_GX_JG_M M, PLN_JG_AND_BL B
                   WHERE M.PRO_PLAN_ID = B.PRO_PLAN_ID
                     AND B.REQ_BL_ID = T.ORD_LN_DLY_PK)
              END),
              (CASE T2.NEXT_GX
                WHEN 'F' THEN
                 (SELECT MIN(S3.PLINE_NAME)
                    FROM PLN_ORDER_RCL S2, PLN_ORDER_RCL_S S3
                   WHERE T2.PLAN_GROUP_ID = S2.PLAN_GROUP_ID
                     AND S2.PRO_PLAN_ID = S3.PRO_PLAN_ID)
                WHEN 'G' THEN
                 (SELECT MIN(S3.PLINE_NAME)
                    FROM PLN_ORDER_JGX S2, PLN_ORDER_JGX_S S3
                   WHERE T2.PLAN_GROUP_ID = S2.PLAN_GROUP_ID
                     AND S2.PRO_PLAN_ID = S3.PRO_PLAN_ID)
                ELSE
                 ''
              END)) AF_INFO
  FROM PLN_ORDER_DBK_S T,
       (SELECT MIN(S.NEXT_GX) NEXT_GX,
               S.PRO_PLAN_ID,
               MIN(S.PLAN_GROUP_ID) PLAN_GROUP_ID
          FROM PLN_ORDER_DBK S
         GROUP BY S.PRO_PLAN_ID) T2,
       SLM_ORDER_LINE_DELIVERY D
 WHERE T.PRO_PLAN_ID = T2.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK(+)
   AND T.PLINE_CODE = ?
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
        ]]>
	</query>
	<query id="PlanService.QueryRclGroup" desc="查询热处理去向">
		<![CDATA[
      SELECT DECODE(T.ISENDGX,
              '1',
              (CASE
                WHEN D.TRANSIT_TYP = '110501' THEN
                 '汽运' || '  ' ||
                 (SELECT D1.DELVRY_ADDR
                    FROM SLM_ORDER_LINE_DELIVERY D1
                   WHERE D1.VALIDFLAG = '1'
                     AND INSTR(D1.DELVRY_ADDR, '客户库') > 0
                     AND D1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
                WHEN D.TRANSIT_TYP = '110502' THEN
                 '铁运' || '  ' ||
                 (SELECT C.STATION_NM
                    FROM SLM_ORDER_DELIVERY_TRANSIT Y, SLM_BASE_STATION C
                   WHERE Y.VALIDFLAG = '1'
                     AND Y.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
                     AND Y.STATION_NO = C.STATION_NO
                     AND C.VALIDFLAG = '1'
                     AND Y.INDEX_SEQ = '1')
                ELSE
                 (SELECT M.PLINE_NAME
                    FROM PLN_GX_JG_M M, PLN_JG_AND_BL B
                   WHERE M.PRO_PLAN_ID = B.PRO_PLAN_ID
                     AND B.REQ_BL_ID = T.ORD_LN_DLY_PK)
              END),
              (CASE T2.NEXT_GX
                WHEN 'G' THEN
                 (SELECT MIN(S3.PLINE_NAME)
                    FROM PLN_ORDER_JGX S2, PLN_ORDER_JGX_S S3
                   WHERE T2.PLAN_GROUP_ID = S2.PLAN_GROUP_ID
                     AND S2.PRO_PLAN_ID = S3.PRO_PLAN_ID)
                ELSE
                 ''
              END)) AF_INFO
  FROM PLN_ORDER_RCL_S T,
       (SELECT MIN(S.NEXT_GX) NEXT_GX,
               S.PRO_PLAN_ID,
               MIN(S.PLAN_GROUP_ID) PLAN_GROUP_ID
          FROM PLN_ORDER_RCL S
         GROUP BY S.PRO_PLAN_ID) T2,
       SLM_ORDER_LINE_DELIVERY D
 WHERE T.PRO_PLAN_ID = T2.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK(+)
   AND T.PLINE_CODE = ?
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
        ]]>
	</query>
	<query id="PlanService.QueryJgxGroup" desc="查询加工线去向">
		<![CDATA[
      SELECT CASE
         WHEN D.TRANSIT_TYP = '110501' THEN
          '汽运' || '  ' ||
          (SELECT D1.DELVRY_ADDR
             FROM SLM_ORDER_LINE_DELIVERY D1
            WHERE D1.VALIDFLAG = '1'
              AND INSTR(D1.DELVRY_ADDR, '客户库') > 0
              AND D1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK)
         WHEN D.TRANSIT_TYP = '110502' THEN
          '铁运' || '  ' ||
          (SELECT C.STATION_NM
             FROM SLM_ORDER_DELIVERY_TRANSIT Y, SLM_BASE_STATION C
            WHERE Y.VALIDFLAG = '1'
              AND Y.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
              AND Y.STATION_NO = C.STATION_NO
              AND C.VALIDFLAG = '1'
              AND Y.INDEX_SEQ = '1')
         ELSE
          (SELECT M.PLINE_NAME
                    FROM PLN_GX_JG_M M, PLN_JG_AND_BL B
                   WHERE M.PRO_PLAN_ID = B.PRO_PLAN_ID
                     AND B.REQ_BL_ID = T.ORD_LN_DLY_PK)
       END AF_INFO
  FROM PLN_ORDER_JGX_S T,
       (SELECT MIN(S.NEXT_GX) NEXT_GX,
               S.PRO_PLAN_ID,
               MIN(S.PLAN_GROUP_ID) PLAN_GROUP_ID
          FROM PLN_ORDER_JGX S
         GROUP BY S.PRO_PLAN_ID) T2,
       SLM_ORDER_LINE_DELIVERY D
 WHERE T.PRO_PLAN_ID = T2.PRO_PLAN_ID(+)
   AND T.ORD_LN_DLY_PK = D.ORD_LN_DLY_PK(+)
   AND T.PLINE_CODE = ?
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
        ]]>
	</query>

	<query id="PlanService.getTime" desc="获取服务器时间">
		<![CDATA[
   SELECT TO_CHAR(SYSDATE, 'yyyy-MM-dd hh:mm:ss') DATETIME FROM DUAL WHERE 1 = 1
        ]]>
	</query>



	<query id="PlanService.addPlnZyDbk" desc="新增镦拔扩虚拟炉计划">
		<![CDATA[
    INSERT INTO PLN_ZY_DBK_M
  (HEAT_PLAN_NO,
   GX_PRO_SEQ,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   PLANSTATUS,
   PER_STATUS,
   BESIDE_STATUS,
   UPPER_HEATPLAN_ID,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   PROCESS_CODE_C,
   PROCESS_DESC_C,
   UPPER_PROCESS_CODE,
   NEXT_PROCESS_CODE,
   GOWHERE_CODE,
   GOWHERE_NAME,
   PROD_STANDARD,
   OUTPUT_STANDARD,
   ISENDGX,
   IF_MATCH_ODD,
   IF_DO_HEAT_PLAN,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   REQ_BL_ID,
   IF_EXPORT,
   PRIORITY,
   PRIORITY_MEMO,
   PRO_MONTH,
   PRO_DAY,
   BAL_YEAR_MONTH,
   IF_MONITOR,
   PRDCR_NO,
   MONITOR_POINT,
   BOM,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   STATION_ROAD,
   CIC,
   PIC,
   SIC,
   DIC,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   SEC_CRAFT_FILE_NO,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   PRODUCCODE,
   PRODUCNAME,
   MODEL_CODE,
   MODEL_DESC,
   INWL_ID,
   INWL_DESC,
   OUTWL_ID,
   OUTWL_DESC,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   OUTNUM_CUT,
   AIMOUTDIAMETER,
   AIMWALLTHICK,
   AIMLENGTH,
   AIMLENGTH_MAX,
   AIMLENGTH_MIN,
   LEN_CUTHEAD,
   LEN_CUTEND,
   PLN_INSINGLE_NUM,
   PLN_INSINGLE_WT,
   PLN_INDOUBLE_NUM,
   PLN_INDOUBLE_WT,
   PLN_OUTSINGLE_NUM,
   PLN_OUTSINGLE_W,
   PLN_OUTDOUBLE_NUM,
   PLN_OUTDOUBLE_W,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DOWNMAN,
   DOWNTIME,
   INDEX_SEQ,
   SPEC_CODE,
   SPEC_NAME,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   FEED_HEAT_NO,
   MEMO,
   ZY_BATCH_ID_ZG,
   DECISION,
   IS_BATCH,
   PASS_CODE,
   PASS_NAME,
   CHECK_NO,
   FLAG_STOVE_NO,
   HEAT_PLAN_NO_OLD,
   IF_PRODUCT,
   WAITING_DECISION_MEMO,
   IS_CLOSE,
   IS_VISIBLE)

  SELECT '#HEAT_PLAN_NO#',
         GX_PRO_SEQ,
         ZY_BATCH_ID,
         STOVE_NO,
         '#JUDGE_STOVE_NO#',
         '#BATCH_NO#',
         '#PLANSTATUS#',
         '#PER_STATUS#',
         '#BESIDE_STATUS#',
         UPPER_HEATPLAN_ID,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         PROCESS_CODE_C,
         PROCESS_DESC_C,
         UPPER_PROCESS_CODE,
         NEXT_PROCESS_CODE,
         GOWHERE_CODE,
         GOWHERE_NAME,
         PROD_STANDARD,
         OUTPUT_STANDARD,
         ISENDGX,
         '2',
         IF_DO_HEAT_PLAN,
         ORDER_SOURCE,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         REQ_BL_ID,
         IF_EXPORT,
         PRIORITY,
         PRIORITY_MEMO,
         PRO_MONTH,
         PRO_DAY,
         BAL_YEAR_MONTH,
         IF_MONITOR,
         PRDCR_NO,
         MONITOR_POINT,
         BOM,
         WHOLE_BACKLOG,
         WHOLE_BACKLOG_DESC,
         STATION_ROAD,
         CIC,
         PIC,
         SIC,
         DIC,
         CRAFT_FILE_NO,
         CRAFT_FILE_MAN,
         CRAFT_SEQ,
         SEC_CRAFT_FILE_NO,
         GRADECODE,
         GRADENAME,
         STEELCODE,
         STEELNAME,
         PRODUCCODE,
         PRODUCNAME,
         MODEL_CODE,
         MODEL_DESC,
         INWL_ID,
         INWL_DESC,
         OUTWL_ID,
         OUTWL_DESC,
         OUTDIAMETER_IN,
         WALLTHICK_IN,
         LENGTH_IN,
         LENGTHMAX_IN,
         LENGTHMIN_IN,
         OUTNUM_CUT,
         AIMOUTDIAMETER,
         AIMWALLTHICK,
         AIMLENGTH,
         AIMLENGTH_MAX,
         AIMLENGTH_MIN,
         LEN_CUTHEAD,
         LEN_CUTEND,
         '#PLN_INSINGLE_NUM#',
         '#PLN_INSINGLE_WT#',
         '#PLN_INDOUBLE_NUM#',
         '#PLN_INDOUBLE_WT#',
         '#PLN_OUTSINGLE_NUM#',
         '#PLN_OUTSINGLE_W#',
         '#PLN_OUTDOUBLE_NUM#',
         '#PLN_OUTDOUBLE_W#',
         '#CREATE_NAME#',
         SYSDATE,
         NULL,
         NULL,
         '#DOWNMAN#',
         SYSDATE,
         INDEX_SEQ,
         SPEC_CODE,
         SPEC_NAME,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         FEED_HEAT_NO,
         MEMO,
         ZY_BATCH_ID_ZG,
         DECISION,
         IS_BATCH,
         PASS_CODE,
         PASS_NAME,
         CHECK_NO,
         FLAG_STOVE_NO,
         HEAT_PLAN_NO_OLD,
         IF_PRODUCT,
         WAITING_DECISION_MEMO,
         IS_CLOSE,
         IS_VISIBLE
    FROM PLN_ZY_DBK_M
   WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO_OLD#'

      ]]>
	</query>

	<query id="PlanService.addPlnZyDbkC" desc="查询镦拔扩实际炉计划">
		<![CDATA[
      INSERT INTO PLN_ZY_DBK_C
  (HEAT_PLAN_NO,
   HEAT_PLAN_SQE,
   JUGDE_APPLY_CODE,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   OUTNUM_CUT,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   PLAN_INDOUBLE_NUM,
   PLAN_INDOUBLE_WT,
   REAL_INDOUBLE_NUM,
   REAL_INDOUBLE_WT,
   FEED_HEAT_NO,
   FLAG_STOVE_NO)

  SELECT HEAT_PLAN_NO,
       '#HEAT_PLAN_SQE#',
         '',
         ZY_BATCH_ID,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         '001',
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         OUTDIAMETER_IN,
         WALLTHICK_IN,
         OUTNUM_CUT,
         LENGTH_IN,
         LENGTHMAX_IN,
         LENGTHMIN_IN,
      PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         FEED_HEAT_NO,
         FLAG_STOVE_NO
    FROM PLN_ZY_DBK_M WHERE HEAT_PLAN_NO= '#HEAT_PLAN_NO#'

       ]]>
	</query>

	<query id="PlanService.querySteOrdPln" desc="查询轧管炉计划信息">
		<![CDATA[
SELECT T.PROD_STANDARD, T.OUTPUT_STANDARD ,T1.PROCESS_SEQ WHOLE_BACKLOG,
       S.PRODUCCODE,
       S.PRODUCNAME,
       S.STD_CODE,
       S.STD_NAME,
       S.SPEC_CODE,
       S.SPEC_NAME,
       (SELECT B.STD_STYLE
          FROM COM_BASE_STD_STYLE B
         WHERE B.STD_STYLE_DESC = S.STD_STYLE_DESC
           AND B.VALIDFLAG = '1') STD_STYLE,
       S.STD_STYLE_DESC,
       S.MODEL_CODE,
       S.MODEL_DESC
  FROM PLN_ORDER_ZG_S T, PLN_SALEORD_PROC T1, PLN_SALEORD S
 WHERE T1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND T.PLN_DIVIDE_ID = T1.PLN_DIVIDE_ID
   AND S.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
   AND T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
       ]]>
	</query>

	<query id="PlanService.queryBaseMaterialFPl" desc="查询Bom投入物料热处理">
		<![CDATA[
		 SELECT T.F_IN_MATERIAL_DESC IN_MATERIAL_DESC,
		 T.F_OUT_MATERIAL_DESC OUT_MATERIAL_DESC,
		 T.F_OUT_MATERIAL_NO OUT_MATERIAL_NO,
		 T.MATERIAL_NO,
		 T.MATERIAL_DESC,T.SPEC_CODE_C,
		 T.SPEC_NAME_C,T.BOM,T.F_IN_MATERIAL_NO IN_MATERIAL_NO,
		 T.WHOLE_BACKLOG
   FROM SLM_ORD_DESIGN_BOM T,
        CRAFT_ORD_LINE_BOM T1,
        CRAFT_ORD_DESIGN   T2,
        PLN_SALEORD        T3
  WHERE T.BOM = T1.BOM
    AND T1.DESGIN_KEY = T2.DESGIN_KEY
    AND T2.ORD_LN_PK = T3.ORD_LN_PK
    AND T2.VALIDFLAG != '0'
    AND T3.ORD_LN_DLY_PK = ?
    AND T.MSC_PLINE=?
    AND T2.CRAFT_SEQ=?
		]]>
	</query>

	<query id="PlanService.addPlnZyRcl" desc="新增热处理虚拟炉计划">
		<![CDATA[
    INSERT INTO PLN_ZY_RCL_M
  (HEAT_PLAN_NO,
   GX_PRO_SEQ,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   PLANSTATUS,
   PER_STATUS,
   BESIDE_STATUS,
   UPPER_HEATPLAN_ID,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   PROCESS_CODE_C,
   PROCESS_DESC_C,
   UPPER_PROCESS_CODE,
   NEXT_PROCESS_CODE,
   GOWHERE_CODE,
   GOWHERE_NAME,
   PROD_STANDARD,
   OUTPUT_STANDARD,
   ISENDGX,
   IF_MATCH_ODD,
   IF_DO_HEAT_PLAN,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   REQ_BL_ID,
   IF_EXPORT,
   PRIORITY,
   PRIORITY_MEMO,
   PRO_MONTH,
   PRO_DAY,
   BAL_YEAR_MONTH,
   IF_MONITOR,
   PRDCR_NO,
   MONITOR_POINT,
   BOM,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   STATION_ROAD,
   CIC,
   PIC,
   SIC,
   DIC,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   SEC_CRAFT_FILE_NO,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   PRODUCCODE,
   PRODUCNAME,
   MODEL_CODE,
   MODEL_DESC,
   INWL_ID,
   INWL_DESC,
   OUTWL_ID,
   OUTWL_DESC,
   OUTDIAMETER,
   WALLTHICK,
   LENGTHMIN,
   LENGTHMAX,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   OUTNUM_CUT,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   PLN_INSINGLE_NUM,
   PLN_INSINGLE_WT,
   PLN_INDOUBLE_NUM,
   PLN_INDOUBLE_WT,
   PLN_OUTSINGLE_NUM,
   PLN_OUTSINGLE_W,
   PLN_OUTDOUBLE_NUM,
   PLN_OUTDOUBLE_W,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DOWNMAN,
   DOWNTIME,
   INDEX_SEQ,
   SPEC_CODE,
   SPEC_NAME,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   DECISION,
   PROCESS_SEQ,
   IS_BATCH,
   CHECK_NO,
   FEED_HEAT_NO,
   FLAG_STOVE_NO,
   MEMO,
   ZY_BATCH_ID_ZG,
   REAL_PROCESS_SEQ,
   HEAT_PLAN_NO_OLD,
   IF_PRODUCT,
   LOT_NO_GROUP,
   LOT_NO_SQE,
   PLINE_CODE_W,
   PLINE_NAME_W,
   PRINT_TIME,
   PRINT_NUMBER,
   IS_CLOSE,
   WAITING_DECISION_MEMO,IS_VISIBLE,LOADTIME)
  SELECT '#HEAT_PLAN_NO#',
         GX_PRO_SEQ,
         ZY_BATCH_ID,
         STOVE_NO,
         '#JUDGE_STOVE_NO#',
         '#BATCH_NO#',
         '#PLANSTATUS#',
         '#PER_STATUS#',
         '#BESIDE_STATUS#',
         UPPER_HEATPLAN_ID,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         PROCESS_CODE_C,
         PROCESS_DESC_C,
         UPPER_PROCESS_CODE,
         NEXT_PROCESS_CODE,
         GOWHERE_CODE,
         GOWHERE_NAME,
         PROD_STANDARD,
         OUTPUT_STANDARD,
         ISENDGX,
         '2',
         IF_DO_HEAT_PLAN,
         ORDER_SOURCE,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         REQ_BL_ID,
         IF_EXPORT,
         PRIORITY,
         PRIORITY_MEMO,
         PRO_MONTH,
         PRO_DAY,
         BAL_YEAR_MONTH,
         IF_MONITOR,
         PRDCR_NO,
         MONITOR_POINT,
         BOM,
         WHOLE_BACKLOG,
         WHOLE_BACKLOG_DESC,
         STATION_ROAD,
         CIC,
         PIC,
         SIC,
         DIC,
         CRAFT_FILE_NO,
         CRAFT_FILE_MAN,
         CRAFT_SEQ,
         SEC_CRAFT_FILE_NO,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         PRODUCCODE,
         PRODUCNAME,
         MODEL_CODE,
         MODEL_DESC,
         INWL_ID,
         INWL_DESC,
         OUTWL_ID,
         OUTWL_DESC,
         OUTDIAMETER,
         WALLTHICK,
         LENGTHMIN,
         LENGTHMAX,
         OUTDIAMETER_IN,
         WALLTHICK_IN,
         OUTNUM_CUT,
         LENGTH_IN,
         LENGTHMAX_IN,
         LENGTHMIN_IN,
          '#PLN_INSINGLE_NUM#',
          '#PLN_INSINGLE_WT#',
          '#PLN_INDOUBLE_NUM#',
          '#PLN_INDOUBLE_WT#',
          '#PLN_OUTSINGLE_NUM#',
          '#PLN_OUTSINGLE_W#',
          '#PLN_OUTDOUBLE_NUM#',
          '#PLN_OUTDOUBLE_W#',
          '#CREATE_NAME#',
         SYSDATE,
          '',
         '',
         '#DOWNMAN#',
         SYSDATE,
         INDEX_SEQ,
         SPEC_CODE,
         SPEC_NAME,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         DECISION,
         PROCESS_SEQ,
         IS_BATCH,
         CHECK_NO,
         FEED_HEAT_NO,
         FLAG_STOVE_NO,
         MEMO,
         ZY_BATCH_ID_ZG,
         REAL_PROCESS_SEQ,
         HEAT_PLAN_NO,
         IF_PRODUCT,
         LOT_NO_GROUP,
          (SELECT NVL(MAX(LOT_NO_SQE), 0) + 1
  FROM PLN_ZY_RCL_M
 WHERE PRO_PLAN_ID =T.PRO_PLAN_ID
   AND GX_PLAN_NO =T.GX_PLAN_NO),
         PLINE_CODE_W,
         PLINE_NAME_W,
         PRINT_TIME,
         PRINT_NUMBER,
         IS_CLOSE,
         WAITING_DECISION_MEMO,IS_VISIBLE,LOADTIME
    FROM PLN_ZY_RCL_M T
   WHERE  HEAT_PLAN_NO = '#HEAT_PLAN_NO_OLD#'
         ]]>
	</query>
	<query id="PlanService.addPlnZyJgx" desc="新增加工线虚拟炉计划">
		<![CDATA[
   INSERT INTO PLN_ZY_JGX_M
  (HEAT_PLAN_NO,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   PLANSTATUS,
   PER_STATUS,
   BESIDE_STATUS,
   UPPER_HEATPLAN_ID,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   PROCESS_CODE_C,
   PROCESS_DESC_C,
   UPPER_PROCESS_CODE,
   NEXT_PROCESS_CODE,
   GOWHERE_CODE,
   GOWHERE_NAME,
   PROD_STANDARD,
   OUTPUT_STANDARD,
   ISENDGX,
   IF_MATCH_ODD,
   IF_DO_HEAT_PLAN,
   ORDER_SOURCE,
   ORD_LN_DLY_PK,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   REQ_BL_ID,
   IF_EXPORT,
   PRIORITY,
   PRIORITY_MEMO,
   PRO_MONTH,
   PRO_DAY,
   BAL_YEAR_MONTH,
   IF_MONITOR,
   PRDCR_NO,
   MONITOR_POINT,
   MONITOR_MENT,
   MONITOR_MAN,
   BOM,
   WHOLE_BACKLOG,
   WHOLE_BACKLOG_DESC,
   STATION_ROAD,
   CIC,
   PIC,
   SIC,
   DIC,
   WIC,
   GIC,
   CRAFT_FILE_NO,
   CRAFT_SEQ,
   CRAFT_FILE_MAN,
   SEC_CRAFT_FILE_NO,
   INWL_ID,
   INWL_DESC,
   OUTWL_ID,
   OUTWL_DESC,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   PRODUCCODE,
   PRODUCNAME,
   MODEL_CODE,
   MODEL_DESC,
   OUTDIAMETER,
   WALLTHICK,
   LENGTHMIN,
   LENGTHMAX,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   OUTNUM_CUT,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   PLN_INSINGLE_NUM,
   PLN_INSINGLE_WT,
   PLN_INDOUBLE_NUM,
   PLN_INDOUBLE_WT,
   PLN_OUTSINGLE_NUM,
   PLN_OUTSINGLE_W,
   PLN_OUTDOUBLE_NUM,
   PLN_OUTDOUBLE_W,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DOWNMAN,
   DOWNTIME,
   INDEX_SEQ,
   GX_PRO_SEQ,
   SPEC_CODE,
   SPEC_NAME,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   DECISION,
   FEED_HEAT_NO,
   FLAG_STOVE_NO,
   MEMO,
   ZY_BATCH_ID_ZG,
   HEAT_PLAN_NO_OLD,
   IF_PRODUCT,
   PLINE_CODE_W,
   PLINE_NAME_W,
   IS_BATCH,
   CHECK_NO,
   LOT_NO_GROUP,
   LOT_NO_SQE,
   IS_CLOSE,
   WAITING_DECISION_MEMO,LOADTIME)
  SELECT '#HEAT_PLAN_NO#',
         ZY_BATCH_ID,
         STOVE_NO,
         '#JUDGE_STOVE_NO#',
         '#BATCH_NO#',
         '20',
         '00',
         '00',
         UPPER_HEATPLAN_ID,
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         PROCESS_CODE_C,
         PROCESS_DESC_C,
         UPPER_PROCESS_CODE,
         NEXT_PROCESS_CODE,
         GOWHERE_CODE,
         GOWHERE_NAME,
         PROD_STANDARD,
         OUTPUT_STANDARD,
         ISENDGX,
         '2',
         IF_DO_HEAT_PLAN,
         ORDER_SOURCE,
         ORD_LN_DLY_PK,
         ORDER_NO,
         ORDER_SEQ,
         DELIVERY_NO,
         REQ_BL_ID,
         IF_EXPORT,
         PRIORITY,
         PRIORITY_MEMO,
         PRO_MONTH,
         PRO_DAY,
         BAL_YEAR_MONTH,
         IF_MONITOR,
         PRDCR_NO,
         MONITOR_POINT,
         MONITOR_MENT,
         MONITOR_MAN,
         BOM,
         WHOLE_BACKLOG,
         WHOLE_BACKLOG_DESC,
         STATION_ROAD,
         CIC,
         PIC,
         SIC,
         DIC,
         WIC,
         GIC,
         CRAFT_FILE_NO,
         CRAFT_SEQ,
         CRAFT_FILE_MAN,
         SEC_CRAFT_FILE_NO,
         INWL_ID,
         INWL_DESC,
         OUTWL_ID,
         OUTWL_DESC,
         STEELCODE,
         STEELNAME,
         GRADECODE,
         GRADENAME,
         PRODUCCODE,
         PRODUCNAME,
         MODEL_CODE,
         MODEL_DESC,
         OUTDIAMETER,
         WALLTHICK,
         LENGTHMIN,
         LENGTHMAX,
         OUTDIAMETER_IN,
         WALLTHICK_IN,
         '#OUTNUM_CUT#',
         LENGTH_IN,
         LENGTHMAX_IN,
         LENGTHMIN_IN,
         '#PLN_INSINGLE_NUM#',
         '#PLN_INSINGLE_WT#',
         '#PLN_INDOUBLE_NUM#',
         '#PLN_INDOUBLE_WT#',
         '#PLN_OUTSINGLE_NUM#',
         '#PLN_OUTSINGLE_W#',
         '#PLN_OUTDOUBLE_NUM#',
         '#PLN_OUTDOUBLE_W#',
         '#CREATE_NAME#',
         SYSDATE,
         NULL,
         NULL,
         '#DOWNMAN#',
         SYSDATE,
         INDEX_SEQ,
         GX_PRO_SEQ,
         SPEC_CODE,
         SPEC_NAME,
         STD_CODE,
         STD_NAME,
         STD_STYLE,
         STD_STYLE_DESC,
         DECISION,
         FEED_HEAT_NO,
         '#FLAG_STOVE_NO#',
         MEMO,
         ZY_BATCH_ID_ZG,
         HEAT_PLAN_NO,
         IF_PRODUCT,
         NULL,
         NULL,
         IS_BATCH,
         CHECK_NO,
          (SELECT NVL(MAX(LOT_NO_SQE), 0) + 1
  FROM PLN_ZY_JGX_M
 WHERE PRO_PLAN_ID =T.PRO_PLAN_ID
   AND GX_PLAN_NO = T.GX_PLAN_NO),
         LOT_NO_SQE,
         IS_CLOSE,
         WAITING_DECISION_MEMO,LOADTIME
    FROM PLN_ZY_JGX_M T
    WHERE HEAT_PLAN_NO='#HEAT_PLAN_NO_OLD#'
         ]]>
	</query>

	<query id="PlanService.addPlnZyRclC" desc="查询热处理实际炉计划">
		<![CDATA[
      INSERT INTO PLN_ZY_RCL_C
  (HEAT_PLAN_NO,
   HEAT_PLAN_SQE,
   JUGDE_APPLY_CODE,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   OUTNUM_CUT,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   PLAN_INDOUBLE_NUM,
   PLAN_INDOUBLE_WT,
   REAL_INDOUBLE_NUM,
   REAL_INDOUBLE_WT,
   REAL_OUTDOUBLE_NUM,
   REAL_OUTDOUBLE_WT,
   FEED_HEAT_NO,
   FLAG_STOVE_NO,
   PLINE_CODE_W,
   PLINE_NAME_W,LOADTIME)
  SELECT HEAT_PLAN_NO,
         '#HEAT_PLAN_SQE#',
         '',
         ZY_BATCH_ID,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         '001',
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         OUTDIAMETER_IN,
         WALLTHICK_IN,
         OUTNUM_CUT,
         LENGTH_IN,
         LENGTHMAX_IN,
         LENGTHMIN_IN,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         FEED_HEAT_NO,
         JUDGE_STOVE_NO,
         PLINE_CODE_W,
         PLINE_NAME_W,LOADTIME
    FROM PLN_ZY_RCL_M
   WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'
       ]]>
	</query>

<query id="PlanService.addPlnZyJgxC" desc="查询加工线实际炉计划">
		<![CDATA[
   INSERT INTO PLN_ZY_JGX_C
  (HEAT_PLAN_NO,
   HEAT_PLAN_SQE,
   JUGDE_APPLY_CODE,
   ZY_BATCH_ID,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   PRO_PLAN_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   OUTDIAMETER_IN,
   WALLTHICK_IN,
   OUTNUM_CUT,
   LENGTH_IN,
   LENGTHMAX_IN,
   LENGTHMIN_IN,
   PLAN_INDOUBLE_NUM,
   PLAN_INDOUBLE_WT,
   REAL_INDOUBLE_NUM,
   REAL_INDOUBLE_WT,
   REAL_OUTDOUBLE_NUM,
   REAL_OUTDOUBLE_WT,
   FEED_HEAT_NO,
   FLAG_STOVE_NO,
   PER_STATUS,
   BESIDE_STATUS,LOADTIME)
  SELECT HEAT_PLAN_NO,
         '#HEAT_PLAN_SQE#',
         '',
         ZY_BATCH_ID,
         STOVE_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         '001',
         PRO_PLAN_ID,
         GX_PLAN_NO,
         PLINE_CODE,
         PLINE_NAME,
         OUTDIAMETER_IN,
         WALLTHICK_IN,
         OUTNUM_CUT,
         LENGTH_IN,
         LENGTHMAX_IN,
         LENGTHMIN_IN,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         PLN_INSINGLE_NUM,
         PLN_INSINGLE_WT,
         FEED_HEAT_NO,
         FLAG_STOVE_NO,
         '00',
         '00',LOADTIME
    FROM PLN_ZY_JGX_M
   WHERE HEAT_PLAN_NO = '#HEAT_PLAN_NO#'

       ]]>
	</query>

	<query id="PlanService.updateMatBcOffline" desc="修改材料表状态">
		<![CDATA[
	UPDATE MAT_BC_M T
	SET T.QCM_STAUS = ?,
	T.PRO_PLAN_ID_NEXT = '',
	T.GX_PLAN_NO_NEXT = '',
	(T.PROCESS_CDOE, T.PROCESS_DESC) =
	(SELECT PROCESS_CODE, PROCESS_DESC
	FROM COM_BASE_PROCESS
	WHERE PROCESS_CODE = ?),
	(T.JUDGE_RESULT_CODE, JUDGE_RESULT) =
	(SELECT BASECODE, BASENAME
	FROM COM_BASE_INFO
	WHERE BASECODE =?),
	(T.NEXT_PROCESS_CDOE, T.NEXT_PROCESS_DESC) =
	(SELECT PROCESS_CODE, PROCESS_DESC
	FROM COM_BASE_PROCESS
	WHERE PROCESS_CODE = ?),
	(PLINE_CODE, PLINE_NAME, BELONG_CODE, BELONG_NAME) =
	(SELECT PLINE_CODE, PLINE_NAME, DEPARTMENT_CODE, DEPARTMENT_DESC
	FROM COM_BASE_PLINE
	WHERE PLINE_CODE =?),
	CREATE_NAME  = ?,
	CREATE_TIME  = SYSDATE,
	INSTOCK_TIME = SYSDATE,
	FACE_RESULT_CODE='',
	SPEC_RESULT_CODE='',
	CHEM_RESULT_CODE='',
	PHY_RESULT_CODE='',
	DETECT_RESULT_CODE='',
	WPRESSURE_RESULT_CODE=''
	WHERE T.MAT_NO = ?
        ]]>
	</query>
	<query id="PlanService.AddJgOfflineMat" desc="增加材料表">
		<![CDATA[
         INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   FLAG_STOVE_NO_ZG,
   CUT_NUM,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   SCRAP_REASON,
   SCRAP_TYPE,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE)
SELECT distinct
   ?,
   '801401',
   '80150101',
   '',
   T.STOVE_NO,
   T.JUDGE_STOVE_NO,
   NVL(T.BATCH_NO,'F'),
   T.BATCH_GROUD_NO,
   '',
   P.MATERIAL_NO,
   P.MATERIAL_NAME,
   P.INPUT_MATERIAL_NAME,
   P.INPUT_MATERIAL_NO,
   P.PRODUCCODE,
   P.PRODUCNAME,
   T.STEELCODE,
   T.STEELNAME,
   T.GRADECODE,
   T.GRADENAME,
   P.SPEC_CODE,
   P.SPEC_NAME,
   T.MODEL_CODE,
   T.MODEL_DESC,
   '',
   '',
   T.STD_STYLE,
   T.STD_STYLE_DESC,
   SUBSTR(T.ORDER_NO, 1, INSTR(T.ORDER_NO, '/', 1, 2) - 1),
   '',
   p.order_no,
   p.order_seq,
   P.ORDER_SEQ_NO,
   P.CRAF_NO,
   A.PROCESS_CODE,
   A.PROCESS_DESC,
   A.PROCESS_CODE,
   A.PROCESS_DESC,
   T.PLINE_CODE,
   T.PLINE_NAME,
   '801302',
   T.PLINE_NAME,
   P.ACT_DIMATER,
   P.ACT_HEIGHT,
   P.ACT_LEN,
   P.ACT_LEN_MIN,
   P.ACT_LEN_MAX,
   '1',
   P.ACT_WEIGHT,
   P.ACT_THEORY_WEIGHT,
   '0',
   C.DEPARTMENT_CODE,
   C.DEPARTMENT_DESC,
   '0',
   --NVL(?,T.GOWHERE_CODE),
   --NVL(?,T.GOWHERE_NAME),
   NVL(?,''),
   NVL(?,''),
   '',
   '0',
   '0',
   '0',
   '1',
   SYSDATE,
   '',
   ?,
   ?,
   SYSDATE,
   '',
   NULL,
   '',
   '',
   T.ORD_LN_DLY_PK,
   TO_CHAR(SYSDATE,'YYYYMM'),
   '',
   '',
   D.BASECODE,
   D.BASENAME,
   '',
   '',
   '',
   '0',
   ?,
   '',
   P.HEAT_PLAN_NO,
   T.JUDGE_STOVE_NO,
   '',
   '',
   T.DECISION,
   NVL(?,T.FLAG_STOVE_NO),
   '1',
   E.BASECODE,
   E.BASENAME,
   ?,
   '0',
   C.DEPARTMENT_CODE_P,
   C.DEPARTMENT_DESC_P
   FROM PLN_ZY_JG_WORKBILL T 
   LEFT JOIN COM_BASE_PROCESS A ON A.PROCESS_CODE = 'H'
   LEFT JOIN COM_BASE_PLINE C ON C.PLINE_CODE = T.PLINE_CODE
   LEFT JOIN COM_BASE_INFO D  ON D.BASECODE =?
   LEFT JOIN COM_BASE_INFO E ON E.BASECODE = ?
   LEFT JOIN mat_bc_backup P ON /*P.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO AND*/  P.MAT_NO = ? AND P.NEXT_PROCESS_CDOE = 'H'
   LEFT JOIN PLN_ZY_JG_WORKBILL W ON W.JUDGE_STOVE_NO = T.JUDGE_STOVE_NO
   WHERE T.WO_ID = ?


        ]]>
	</query>
	


	<query id="PlanService.AddVrpOfflineMat" desc="增加材料表">
		<![CDATA[
      INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   FLAG_STOVE_NO_ZG,
   CUT_NUM,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   SCRAP_REASON,
   SCRAP_TYPE,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   OFFLINE_DOC,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ)
  SELECT p.mat_no,
         '801401',
         '80150101',
         T.ZY_BATCH_ID,
         T.STOVE_NO,
         T.JUDGE_STOVE_NO,
         NVL(p.PHY_BATCH_NO, 'F'),
         p.group_no,
         p.IS_SAMPLE_PIPE,
         T.OUTWL_ID,
         T.OUTWL_DESC,
         T.INWL_ID,
         T.INWL_DESC,
         T.produccode,
         T.PRODUCNAME,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.SPEC_CODE,
         T.SPEC_NAME,
         T.MODEL_CODE,
         T.MODEL_DESC,
         '',
         T.PROD_STANDARD,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.ORDER_NO || '/' || T.order_seq,
         T.PRO_PLAN_ID,
         t.order_no,
         t.order_seq,
         t.DELIVERY_NO,
         t.craft_file_no,
         A.PROCESS_CODE,
         A.PROCESS_DESC,
         B.PROCESS_CODE,
         B.PROCESS_DESC,
         T.PLINE_CODE,
         T.PLINE_NAME,
         '801302',
         T.PLINE_NAME,
         --P.ACT_DIMATER,
         NVL(T.AIMOUTDIAMETER, T.OUTDIAMETER),
         NVL(T.AIMWALLTHICK, T.WALLTHICK),
         P.ACT_LEN,
         P.ACT_LEN_MIN,
         P.ACT_LEN_MAX,
         P.ACT_COUNT,
         P.ACT_WEIGHT,
         P.ACT_THEORY_WEIGHT,
         '0',
         C.DEPARTMENT_CODE,
         C.DEPARTMENT_DESC,
         '0',
         NVL(?, T.GOWHERE_CODE),
         NVL(?, T.GOWHERE_NAME),
         '',
         '0',
         '0',
         '0',
         '1',
         SYSDATE,
         '',
         ?,
         ?,
         SYSDATE,
         '',
         NULL,
         (SELECT MAX(ORD_PK)
            FROM SLM_ORDER_LINE_DELIVERY
           WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
         (SELECT MAX(ORD_LN_PK)
            FROM SLM_ORDER_LINE_DELIVERY
           WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
         T.ORD_LN_DLY_PK,
         TO_CHAR(SYSDATE, 'YYYYMM'),
         '',
         '',
         D.BASECODE,
         D.BASENAME,
         '',
         '',
         '',
         '0',
         ?,
         '',
         T.HEAT_PLAN_NO,
         T.JUDGE_STOVE_NO,
         '',
         '',
         T.DECISION,
         NVL(?, P.JUDGE_STOVE_NO),
         T.OUTNUM_CUT,
         E.BASECODE,
         E.BASENAME,
         ?,
         '0',
         --改离线责任产线
         --C.DEPARTMENT_CODE_P,
         --C.DEPARTMENT_DESC_P,
         C.PLINE_CODE,
         C.PLINE_NAME,
         ?,
         O.SUBCONTRACT_NO,
         O.SUBCONTRACT_NO_SEQ
    FROM PLN_ZY_DBK_M T
    LEFT JOIN port_vrp_batch_sample_result P
      ON T.HEAT_PLAN_NO = P.HEAT_PLAN_NO
     AND P.MAT_NO = ?
    LEFT JOIN COM_BASE_PROCESS A
      ON A.PROCESS_CODE = 'E'
    LEFT JOIN COM_BASE_PROCESS B
      ON B.PROCESS_CODE = T.NEXT_PROCESS_CODE
    LEFT JOIN COM_BASE_PLINE C
      ON C.PLINE_CODE = T.PLINE_CODE
    LEFT JOIN COM_BASE_INFO D
      ON D.BASECODE = ?
    LEFT JOIN COM_BASE_INFO E
      ON E.BASECODE = ?
    LEFT JOIN VRP_OFFLINE_RESULT O
      ON O.RESULT_NO = ?
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="PlanService.AddHttOfflineMat" desc="增加材料表">
		<![CDATA[
         INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   FLAG_STOVE_NO_ZG,
   CUT_NUM,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   SCRAP_REASON,
   SCRAP_TYPE,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   OFFLINE_DOC,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ)
  SELECT p.mat_no,
         '801401',
         '80150101',
         T.ZY_BATCH_ID,
         T.STOVE_NO,
         T.JUDGE_STOVE_NO,
         NVL(p.PHY_BATCH_NO, 'F'),
         p.group_no,
         p.IS_SAMPLE_PIPE,
         T.OUTWL_ID,
         T.OUTWL_DESC,
         T.INWL_ID,
         T.INWL_DESC,
         T.produccode,
         T.PRODUCNAME,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.SPEC_CODE,
         T.SPEC_NAME,
         T.MODEL_CODE,
         T.MODEL_DESC,
         '',
   T.PROD_STANDARD,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.ORDER_NO || '/' || T.order_seq,
         T.PRO_PLAN_ID,
         t.order_no,
         t.order_seq,
         t.DELIVERY_NO,
         t.craft_file_no,
         A.PROCESS_CODE,
         A.PROCESS_DESC,
         B.PROCESS_CODE,
         B.PROCESS_DESC,
         T.PLINE_CODE,
         T.PLINE_NAME,
         '801302',
         T.PLINE_NAME,
         P.ACT_DIMATER,
         P.ACT_HEIGHT,
         P.ACT_LEN,
         P.ACT_LEN_MIN,
         P.ACT_LEN_MAX,
         P.ACT_COUNT,
         P.ACT_WEIGHT,
         P.ACT_THEORY_WEIGHT,
         '0',
         C.DEPARTMENT_CODE,
         C.DEPARTMENT_DESC,
         '0',
         NVL(?, T.GOWHERE_CODE),
         NVL(?, T.GOWHERE_NAME),
         '',
         '0',
         '0',
         '0',
         '1',
         SYSDATE,
         '',
         ?,
         ?,
         SYSDATE,
         '',
         NULL,
         (SELECT MAX(ORD_PK)
            FROM SLM_ORDER_LINE_DELIVERY
           WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
         (SELECT MAX(ORD_LN_PK)
            FROM SLM_ORDER_LINE_DELIVERY
           WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
         T.ORD_LN_DLY_PK,
         TO_CHAR(SYSDATE, 'YYYYMM'),
         '',
         '',
         D.BASECODE,
         D.BASENAME,
         '',
         '',
         '',
         '0',
         ?,
         '',
         T.HEAT_PLAN_NO,
         T.JUDGE_STOVE_NO,
         '',
         '',
         T.DECISION,
         NVL(?, P.JUDGE_STOVE_NO),
         T.OUTNUM_CUT,
         E.BASECODE,
         E.BASENAME,
         ?,
         '0',
         --改离线责任产线
         --C.DEPARTMENT_CODE_P,
         --C.DEPARTMENT_DESC_P,
         C.PLINE_CODE,
         C.PLINE_NAME,
         ?,
         O.SUBCONTRACT_NO,
         O.SUBCONTRACT_NO_SEQ
    FROM PLN_ZY_RCL_M T
    LEFT JOIN port_HTT_batch_sample_result P
      ON T.HEAT_PLAN_NO = P.HEAT_PLAN_NO
     AND P.PROCESS_SEQ = T.REAL_PROCESS_SEQ
     AND P.MAT_NO = ?
    LEFT JOIN COM_BASE_PROCESS A
      ON A.PROCESS_CODE = 'F'
    LEFT JOIN COM_BASE_PROCESS B
      ON B.PROCESS_CODE = T.NEXT_PROCESS_CODE
    LEFT JOIN COM_BASE_PLINE C
      ON C.PLINE_CODE = T.PLINE_CODE
    LEFT JOIN COM_BASE_INFO D
      ON D.BASECODE = ?
    LEFT JOIN COM_BASE_INFO E
      ON E.BASECODE = ?
    LEFT JOIN HTT_OFFLINE_RESULT O
      ON O.RESULT_NO = ?
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>

	<query id="PlanService.AddMchOfflineMat" desc="增加材料表">
		<![CDATA[
INSERT INTO MAT_BC_M
  (MAT_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   SAMPLE_FLAG,
   MATERIAL_NO,
   MATERIAL_NAME,
   INPUT_MATERIAL_NAME,
   INPUT_MATERIAL_NO,
   PRODUCCODE,
   PRODUCNAME,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRO_ORDER_NO,
   PRO_ORDER_ID,
   ORDER_NO,
   ORDER_SEQ,
   ORDER_SEQ_NO,
   CRAF_NO,
   PROCESS_CDOE,
   PROCESS_DESC,
   NEXT_PROCESS_CDOE,
   NEXT_PROCESS_DESC,
   PLINE_CODE,
   PLINE_NAME,
   MAT_ORIGIN_CODE,
   MAT_ORIGIN_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   MEASURE_FLAG,
   BELONG_CODE,
   BELONG_NAME,
   PACK_FLAG,
   MAT_GOWHERE_CODE,
   MAT_GOWHERE_NAME,
   MAT_RETURN_FLAG,
   LOCK_FLAG,
   MNG_LOCK_FLAG,
   JUGDE_APPLY_FLAG,
   INSTOCK_FLAG,
   INSTOCK_TIME,
   BAR_CODE,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   BAL_YEAR_MONTH,
   JUDGE_STD_NAME,
   PIPMEMO,
   SOURE_CODE,
   SOURE_NAME,
   PONDER_NO,
   PONDER_GROSS_WT,
   JUDGE_ID,
   LOCK_LIKU,
   QCM_STAUS,
   OUTSTOCK_DOC,
   HEAT_PLAN_NO,
   ZG_STOVE_SQE,
   GX_PLAN_NO,
   ZG_MAT_NO,
   TARGET,
   FLAG_STOVE_NO_ZG,
   CUT_NUM,
   JUDGE_RESULT_CODE,
   JUDGE_RESULT,
   SCRAP_REASON,
   SCRAP_TYPE,
   BELONG_CODE_RESPONSE,
   BELONG_NAME_RESPONSE,
   OFFLINE_DOC,
   MEASURING_SEQ,
   SUBCONTRACT_NO,
   SUBCONTRACT_NO_SEQ)
  SELECT P.MAT_NO,
         DECODE(T.DECISION, 'A', '801402', '801401'),
         '80150101',
         T.ZY_BATCH_ID,
         T.STOVE_NO,
         T.JUDGE_STOVE_NO,
         NVL(P.PHY_BATCH_NO, 'F'),
         NVL(G.GROUP_NO, '001'),
         P.IS_SAMPLE_PIPE,
         T.OUTWL_ID,
         T.OUTWL_DESC,
         T.INWL_ID,
         T.INWL_DESC,
         T.PRODUCCODE,
         T.PRODUCNAME,
         T.STEELCODE,
         T.STEELNAME,
         T.GRADECODE,
         T.GRADENAME,
         T.SPEC_CODE,
         T.SPEC_NAME,
         T.MODEL_CODE,
         T.MODEL_DESC,
         '',
   T.PROD_STANDARD,
         T.STD_STYLE,
         T.STD_STYLE_DESC,
         T.ORDER_NO || '/' || T.ORDER_SEQ,
         T.PRO_PLAN_ID,
         T.ORDER_NO,
         T.ORDER_SEQ,
         T.DELIVERY_NO,
         T.CRAFT_FILE_NO,
         A.PROCESS_CODE,
         A.PROCESS_DESC,
         B.PROCESS_CODE,
         B.PROCESS_DESC,
         T.PLINE_CODE,
         T.PLINE_NAME,
         '801302',
         T.PLINE_NAME,
         P.ACT_DIMATER,
         P.ACT_HEIGHT,
         P.ACT_LEN,
         G.GROUP_MIN,
         G.GROUP_MAX,
         P.ACT_COUNT,
         P.ACT_WEIGHT,
         P.ACT_THEORY_WEIGHT,
         '0',
         C.DEPARTMENT_CODE,
         C.DEPARTMENT_DESC,
         '0',
         NVL(?, T.GOWHERE_CODE),
         NVL(?, T.GOWHERE_NAME),
         '',
         '0',
         '0',
         '0',
         '1',
         SYSDATE,
         '',
         ?,
         ?,
         SYSDATE,
         '',
         NULL,
         (SELECT MAX(ORD_PK)
            FROM SLM_ORDER_LINE_DELIVERY
           WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
         (SELECT MAX(ORD_LN_PK)
            FROM SLM_ORDER_LINE_DELIVERY
           WHERE ORD_LN_DLY_PK = T.ORD_LN_DLY_PK),
         T.ORD_LN_DLY_PK,
         TO_CHAR(SYSDATE, 'YYYYMM'),
         '',
         '',
         D.BASECODE,
         D.BASENAME,
         '',
         '',
         '',
         '0',
         ?,
         '',
         T.HEAT_PLAN_NO,
         T.JUDGE_STOVE_NO,
         '',
         '',
         T.DECISION,
         NVL(?, P.JUDGE_STOVE_NO),
         T.OUTNUM_CUT,
         E.BASECODE,
         E.BASENAME,
         ?,
         '0',
         --改离线责任产线
         --C.DEPARTMENT_CODE_P,
         --C.DEPARTMENT_DESC_P,
         C.PLINE_CODE,
         C.PLINE_NAME,
         ?,
         P.MEASURING_SEQ,
         O.SUBCONTRACT_NO,
         O.SUBCONTRACT_NO_SEQ
    FROM PLN_ZY_JGX_M T
    LEFT JOIN PORT_MCH_BATCH_SAMPLE_RESULT P
      ON T.HEAT_PLAN_NO = P.HEAT_PLAN_NO
     AND P.MAT_NO = ?
    LEFT JOIN COM_BASE_PROCESS A
      ON A.PROCESS_CODE = 'G'
    LEFT JOIN COM_BASE_PROCESS B
      ON B.PROCESS_CODE = T.NEXT_PROCESS_CODE
    LEFT JOIN COM_BASE_PLINE C
      ON C.PLINE_CODE = T.PLINE_CODE
    LEFT JOIN COM_BASE_INFO D
      ON D.BASECODE = ?
    LEFT JOIN COM_BASE_INFO E
      ON E.BASECODE = ?
    LEFT JOIN MCH_GROUPNO G
      ON G.ORDER_NO = T.ORDER_NO || '/' || T.ORDER_SEQ
     AND P.ACT_LEN <
         NVL(DECODE(GROUP_MAX_SIGN, '<=', GROUP_MAX + 0.0001, GROUP_MAX),
             P.ACT_LEN + 0.0001)
     AND P.ACT_LEN >
         NVL(DECODE(GROUP_MIN_SIGN, '>=', GROUP_MIN - 0.0001, GROUP_MIN),
             P.ACT_LEN - 0.0001)
     AND ROWNUM = 1
    LEFT JOIN MCH_OFFLINE_RESULT O
      ON T.HEAT_PLAN_NO = O.HEAT_PLAN_NO
     AND O.RESULT_NO = ?
   WHERE T.HEAT_PLAN_NO = ?
        ]]>
	</query>

		<query id="PlanService.AddJgBut111111111111" desc="增加位置表">
		<![CDATA[
      INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC)
  SELECT ?,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.BATCH_GROUD_NO,
         Y.STORAGE_NO,
         Y.STORAGE_NO || '10101',
         '1',
         NULL,
         Y.STORAGE_ATTR,
         Y.STORAGE_ATTR_NAME,
         Y.STORAGE_TYPE_NO,
         Y.STORAGE_TYPE_NAME,
         Y.MANAGEMENT_NO,
         Y.MANAGEMENT_NAME,
         '',
         ?,
         SYSDATE,
         NULL,
         NULL,
         NULL,
         NULL,
         Y.DEPARTMENT_CODE,
         Y.DEPARTMENT_DESC
    FROM pln_zy_jg_workbill T
  LEFT JOIN (SELECT C.PLINE_CODE,C.PLINE_NAME,B.* FROM COM_BASE_PLINE C,Ydm_Bs_Storage B WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
      ON Y.PLINE_CODE = T.PLINE_CODE
     AND ROWNUM = 1
   WHERE T.WO_ID = ?
        ]]>
	</query>

	<query id="PlanService.AddVrpBut" desc="增加位置表">
		<![CDATA[
  DECLARE
  V_ICOUNT NUMBER := 0;
BEGIN
  SELECT COUNT(1)
    INTO V_ICOUNT
    FROM YDM_BC_BUTTRESS_BACK
   WHERE (MAT_NO, PLINE_CODE) IN
         (SELECT MAT_NO, PLINE_CODE
            FROM PORT_VRP_BATCH_SAMPLE_RESULT T
           WHERE T.HEAT_PLAN_NO = ?
             AND T.MAT_NO = ?);
  IF (V_ICOUNT = 0) THEN
    INSERT INTO YDM_BC_BUTTRESS
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PLINE_CODE)
      SELECT T.MAT_NO,
             T.JUDGE_STOVE_NO,
             T.BATCH_NO,
             T.GROUP_NO,
             Y.STORAGE_NO,
             Y.STORAGE_NO || '10101',
             '1',
             NULL,
             Y.STORAGE_ATTR,
             Y.STORAGE_ATTR_NAME,
             Y.STORAGE_TYPE_NO,
             Y.STORAGE_TYPE_NAME,
             Y.MANAGEMENT_NO,
             Y.MANAGEMENT_NAME,
             '',
             ?,
             SYSDATE,
             NULL,
             NULL,
             NULL,
             NULL,
             Y.DEPARTMENT_CODE,
             Y.DEPARTMENT_DESC,
             T.PLINE_CODE
        FROM PORT_VRP_BATCH_SAMPLE_RESULT T
        LEFT JOIN (SELECT C.PLINE_CODE,C.PLINE_NAME,B.* FROM COM_BASE_PLINE C,Ydm_Bs_Storage B WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
      ON Y.PLINE_CODE = T.PLINE_CODE
     AND ROWNUM = 1
       WHERE T.HEAT_PLAN_NO = ?
         AND T.MAT_NO = ?;
  ELSE
    INSERT INTO YDM_BC_BUTTRESS
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PLINE_CODE)
      SELECT MAT_NO,
             JUDGE_STOVE_NO,
             BATCH_NO,
             BATCH_GROUD_NO,
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             LOC_NO,
             STORAGE_ATTR,
             STORAGE_ATTR_NAME,
             STORAGE_TYPE_NO,
             STORAGE_TYPE_NAME,
             MANAGEMENT_NO,
             MANAGEMENT_NAME,
             MEMO,
             CREATE_NAME,
             CREATE_TIME,
             UPDATE_NAME,
             UPDATE_TIME,
             DELETE_NAME,
             DELETE_TIME,
             DEPARTMENT_CODE,
             DEPARTMENT_DESC,
             PLINE_CODE
        FROM YDM_BC_BUTTRESS_BACK
       WHERE (MAT_NO, PLINE_CODE) IN
             (SELECT MAT_NO, PLINE_CODE
                FROM PORT_VRP_BATCH_SAMPLE_RESULT T
               WHERE T.HEAT_PLAN_NO = ?
                 AND T.MAT_NO = ?);
  END IF;
END;
        ]]>
	</query>

	<query id="PlanService.AddHttBut" desc="增加位置表">
	<![CDATA[
      DECLARE
  V_ICOUNT NUMBER := 0;
BEGIN
  SELECT COUNT(1)
    INTO V_ICOUNT
    FROM YDM_BC_BUTTRESS_BACK
   WHERE (MAT_NO, PLINE_CODE) IN
         (SELECT T.MAT_NO, T.PLINE_CODE
              FROM  PLN_ZY_RCL_M M,PORT_HTT_BATCH_SAMPLE_RESULT T
   WHERE T.HEAT_PLAN_NO = M.HEAT_PLAN_NO
   AND T.PROCESS_SEQ = M.REAL_PROCESS_SEQ
   AND T.HEAT_PLAN_NO = ?
    AND T.MAT_NO = ?);
  IF (V_ICOUNT = 0) THEN
         INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   PLINE_CODE)
  SELECT T.MAT_NO,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.GROUP_NO,
         Y.STORAGE_NO,
         Y.STORAGE_NO || '10101',
         '1',
         NULL,
         Y.STORAGE_ATTR,
         Y.STORAGE_ATTR_NAME,
         Y.STORAGE_TYPE_NO,
         Y.STORAGE_TYPE_NAME,
         Y.MANAGEMENT_NO,
         Y.MANAGEMENT_NAME,
         '',
         ?,
         SYSDATE,
         NULL,
         NULL,
         NULL,
         NULL,
         Y.DEPARTMENT_CODE,
         Y.DEPARTMENT_DESC,
         T.PLINE_CODE
    FROM  PLN_ZY_RCL_M M,PORT_HTT_BATCH_SAMPLE_RESULT T
    LEFT JOIN (SELECT C.PLINE_CODE,C.PLINE_NAME,B.* FROM COM_BASE_PLINE C,Ydm_Bs_Storage B WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
      ON Y.PLINE_CODE = T.PLINE_CODE
     AND ROWNUM = 1
   WHERE T.HEAT_PLAN_NO = M.HEAT_PLAN_NO
   AND T.PROCESS_SEQ = M.REAL_PROCESS_SEQ
   AND T.HEAT_PLAN_NO = ?
    AND T.MAT_NO = ?;
  ELSE
    INSERT INTO YDM_BC_BUTTRESS
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PLINE_CODE)
      SELECT MAT_NO,
             JUDGE_STOVE_NO,
             BATCH_NO,
             BATCH_GROUD_NO,
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             LOC_NO,
             STORAGE_ATTR,
             STORAGE_ATTR_NAME,
             STORAGE_TYPE_NO,
             STORAGE_TYPE_NAME,
             MANAGEMENT_NO,
             MANAGEMENT_NAME,
             MEMO,
             CREATE_NAME,
             CREATE_TIME,
             UPDATE_NAME,
             UPDATE_TIME,
             DELETE_NAME,
             DELETE_TIME,
             DEPARTMENT_CODE,
             DEPARTMENT_DESC,
             PLINE_CODE
        FROM YDM_BC_BUTTRESS_BACK
       WHERE (MAT_NO, PLINE_CODE) IN
              (SELECT T.MAT_NO, T.PLINE_CODE
              FROM  PLN_ZY_RCL_M M,PORT_HTT_BATCH_SAMPLE_RESULT T
   WHERE T.HEAT_PLAN_NO = M.HEAT_PLAN_NO
   AND T.PROCESS_SEQ = M.REAL_PROCESS_SEQ
   AND T.HEAT_PLAN_NO = ?
    AND T.MAT_NO = ?);
  END IF;
END;
        ]]>
</query>

	<query id="PlanService.AddMchBut" desc="增加位置表">
		<![CDATA[
DECLARE
  V_ICOUNT NUMBER := 0;
BEGIN
  SELECT COUNT(1)
    INTO V_ICOUNT
    FROM YDM_BC_BUTTRESS_BACK
   WHERE (MAT_NO, PLINE_CODE) IN
         (SELECT T.MAT_NO, T.PLINE_CODE
              FROM  PORT_MCH_BATCH_SAMPLE_RESULT T
     WHERE T.HEAT_PLAN_NO = ?
     AND T.MAT_NO = ?);
  IF (V_ICOUNT = 0) THEN
           INSERT INTO YDM_BC_BUTTRESS
  (MAT_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   UPDATE_NAME,
   UPDATE_TIME,
   DELETE_NAME,
   DELETE_TIME,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   PLINE_CODE)
  SELECT T.MAT_NO,
         T.JUDGE_STOVE_NO,
         T.BATCH_NO,
         T.GROUP_NO,
         Y.STORAGE_NO,
         Y.STORAGE_NO || '10101',
         '1',
         NULL,
         Y.STORAGE_ATTR,
         Y.STORAGE_ATTR_NAME,
         Y.STORAGE_TYPE_NO,
         Y.STORAGE_TYPE_NAME,
         Y.MANAGEMENT_NO,
         Y.MANAGEMENT_NAME,
         '',
         ?,
         SYSDATE,
         NULL,
         NULL,
         NULL,
         NULL,
         Y.DEPARTMENT_CODE,
         Y.DEPARTMENT_DESC,
         T.PLINE_CODE
    FROM PORT_MCH_BATCH_SAMPLE_RESULT T
   LEFT JOIN (SELECT C.PLINE_CODE,C.PLINE_NAME,B.* FROM COM_BASE_PLINE C,Ydm_Bs_Storage B WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
      ON Y.PLINE_CODE = T.PLINE_CODE
     AND ROWNUM = 1
   WHERE T.HEAT_PLAN_NO = ?
     AND T.MAT_NO = ?;
  ELSE
    INSERT INTO YDM_BC_BUTTRESS
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PLINE_CODE)
      SELECT MAT_NO,
             JUDGE_STOVE_NO,
             BATCH_NO,
             BATCH_GROUD_NO,
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             LOC_NO,
             STORAGE_ATTR,
             STORAGE_ATTR_NAME,
             STORAGE_TYPE_NO,
             STORAGE_TYPE_NAME,
             MANAGEMENT_NO,
             MANAGEMENT_NAME,
             MEMO,
             CREATE_NAME,
             CREATE_TIME,
             UPDATE_NAME,
             UPDATE_TIME,
             DELETE_NAME,
             DELETE_TIME,
             DEPARTMENT_CODE,
             DEPARTMENT_DESC,
             PLINE_CODE
        FROM YDM_BC_BUTTRESS_BACK
       WHERE (MAT_NO, PLINE_CODE) IN
              (SELECT T.MAT_NO, T.PLINE_CODE
              FROM  PORT_MCH_BATCH_SAMPLE_RESULT T
     WHERE T.HEAT_PLAN_NO = ?
     AND T.MAT_NO = ?);
  END IF;
END;
        ]]>
	</query>
	
	<query id="PlanService.AddJgBut" desc="增加位置表">
		<![CDATA[
DECLARE
  V_ICOUNT         NUMBER := 0;
  V_JUDGE_STOVE_NO MAT_BC_M.JUDGE_STOVE_NO%type := ?;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M T
                 WHERE T.JUDGE_STOVE_NO = V_JUDGE_STOVE_NO
                   AND T.MAT_NO = ?
                   and t.PROCESS_CDOE = 'H'
                   AND ROWNUM = 1) LOOP
  
    SELECT COUNT(1)
      INTO V_ICOUNT
      FROM YDM_BC_BUTTRESS_BACK
     WHERE MAT_NO = MYROW.MAT_NO
       AND PLINE_CODE = MYROW.PLINE_CODE;
  
    IF (V_ICOUNT = 0) THEN
      INSERT INTO YDM_BC_BUTTRESS
        (MAT_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         PLINE_CODE)
        SELECT MYROW.MAT_NO,
               MYROW.JUDGE_STOVE_NO,
               MYROW.BATCH_NO,
               MYROW.BATCH_GROUD_NO,
               Y.STORAGE_NO,
               Y.STORAGE_NO || '10101',
               '1',
               NULL,
               Y.STORAGE_ATTR,
               Y.STORAGE_ATTR_NAME,
               Y.STORAGE_TYPE_NO,
               Y.STORAGE_TYPE_NAME,
               Y.MANAGEMENT_NO,
               Y.MANAGEMENT_NAME,
               '',
               ?,
               SYSDATE,
               NULL,
               NULL,
               NULL,
               NULL,
               Y.DEPARTMENT_CODE,
               Y.DEPARTMENT_DESC,
               MYROW.PLINE_CODE
          FROM DUAL
          LEFT JOIN (SELECT C.PLINE_CODE, C.PLINE_NAME, B.*
                       FROM COM_BASE_PLINE C, YDM_BS_STORAGE B
                      WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
            ON Y.PLINE_CODE = MYROW.PLINE_CODE
           AND ROWNUM = 1;
    
    ELSE
      INSERT INTO YDM_BC_BUTTRESS
        (MAT_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         PLINE_CODE)
        SELECT MAT_NO,
               V_JUDGE_STOVE_NO,
               BATCH_NO,
               BATCH_GROUD_NO,
               STORAGE_NO,
               LOCATION_NO,
               LARY_NO,
               LOC_NO,
               STORAGE_ATTR,
               STORAGE_ATTR_NAME,
               STORAGE_TYPE_NO,
               STORAGE_TYPE_NAME,
               MANAGEMENT_NO,
               MANAGEMENT_NAME,
               MEMO,
               CREATE_NAME,
               CREATE_TIME,
               UPDATE_NAME,
               UPDATE_TIME,
               DELETE_NAME,
               DELETE_TIME,
               DEPARTMENT_CODE,
               DEPARTMENT_DESC,
               PLINE_CODE
          FROM YDM_BC_BUTTRESS_BACK
         WHERE MAT_NO = MYROW.MAT_NO
           AND PLINE_CODE = MYROW.PLINE_CODE;
    
    END IF;
  END LOOP;
END;

        ]]>
	</query>

	<query id="PlanService.AddBut" desc="增加位置表">
		<![CDATA[
DECLARE
  V_ICOUNT NUMBER := 0;
BEGIN
  FOR MYROW IN (SELECT *
                  FROM MAT_BC_M T
                 WHERE T.HEAT_PLAN_NO = ?
                   AND MAT_NO =?
                   AND ROWNUM = 1) LOOP

    SELECT COUNT(1)
      INTO V_ICOUNT
      FROM YDM_BC_BUTTRESS_BACK
     WHERE MAT_NO = MYROW.MAT_NO
       AND PLINE_CODE = MYROW.PLINE_CODE;

    IF (V_ICOUNT = 0) THEN
      INSERT INTO YDM_BC_BUTTRESS
        (MAT_NO,
         JUDGE_STOVE_NO,
         BATCH_NO,
         BATCH_GROUD_NO,
         STORAGE_NO,
         LOCATION_NO,
         LARY_NO,
         LOC_NO,
         STORAGE_ATTR,
         STORAGE_ATTR_NAME,
         STORAGE_TYPE_NO,
         STORAGE_TYPE_NAME,
         MANAGEMENT_NO,
         MANAGEMENT_NAME,
         MEMO,
         CREATE_NAME,
         CREATE_TIME,
         UPDATE_NAME,
         UPDATE_TIME,
         DELETE_NAME,
         DELETE_TIME,
         DEPARTMENT_CODE,
         DEPARTMENT_DESC,
         PLINE_CODE)
        SELECT MYROW.MAT_NO,
               MYROW.JUDGE_STOVE_NO,
               MYROW.BATCH_NO,
               MYROW.BATCH_GROUD_NO,
               Y.STORAGE_NO,
               Y.STORAGE_NO || '10101',
               '1',
               NULL,
               Y.STORAGE_ATTR,
               Y.STORAGE_ATTR_NAME,
               Y.STORAGE_TYPE_NO,
               Y.STORAGE_TYPE_NAME,
               Y.MANAGEMENT_NO,
               Y.MANAGEMENT_NAME,
               '',
               ?,
               SYSDATE,
               NULL,
               NULL,
               NULL,
               NULL,
               Y.DEPARTMENT_CODE,
               Y.DEPARTMENT_DESC,
               MYROW.PLINE_CODE
          FROM DUAL
          LEFT JOIN (SELECT C.PLINE_CODE, C.PLINE_NAME, B.*
                       FROM COM_BASE_PLINE C, YDM_BS_STORAGE B
                      WHERE C.OUT_REPOSITORY = B.STORAGE_NO) Y
            ON Y.PLINE_CODE =MYROW.PLINE_CODE
           AND ROWNUM = 1;

         ELSE INSERT INTO YDM_BC_BUTTRESS(MAT_NO,
                               JUDGE_STOVE_NO,
                               BATCH_NO,
                               BATCH_GROUD_NO,
                               STORAGE_NO,
                               LOCATION_NO,
                               LARY_NO,
                               LOC_NO,
                               STORAGE_ATTR,
                               STORAGE_ATTR_NAME,
                               STORAGE_TYPE_NO,
                               STORAGE_TYPE_NAME,
                               MANAGEMENT_NO,
                               MANAGEMENT_NAME,
                               MEMO,
                               CREATE_NAME,
                               CREATE_TIME,
                               UPDATE_NAME,
                               UPDATE_TIME,
                               DELETE_NAME,
                               DELETE_TIME,
                               DEPARTMENT_CODE,
                               DEPARTMENT_DESC,
                               PLINE_CODE)
          SELECT MAT_NO,
                MYROW.JUDGE_STOVE_NO,
               MYROW.BATCH_NO,
               MYROW.BATCH_GROUD_NO,
                 STORAGE_NO,
                 LOCATION_NO,
                 LARY_NO,
                 LOC_NO,
                 STORAGE_ATTR,
                 STORAGE_ATTR_NAME,
                 STORAGE_TYPE_NO,
                 STORAGE_TYPE_NAME,
                 MANAGEMENT_NO,
                 MANAGEMENT_NAME,
                 MEMO,
                 CREATE_NAME,
                 CREATE_TIME,
                 UPDATE_NAME,
                 UPDATE_TIME,
                 DELETE_NAME,
                 DELETE_TIME,
                 DEPARTMENT_CODE,
                 DEPARTMENT_DESC,
                 PLINE_CODE
                  FROM YDM_BC_BUTTRESS_BACK
                 WHERE MAT_NO = MYROW.MAT_NO
                   AND PLINE_CODE = MYROW.PLINE_CODE;


    END IF;
  END LOOP;
END;
        ]]>
	</query>

	<query id="PlanService.deleteMatBc" desc="删除材料表废品新增数据">
		<![CDATA[
  DELETE MAT_BC_M T  WHERE T.MAT_NO = ?
        ]]>
	</query>

	<query id="PlanService.deleteMatZc" desc="删除材料表废品新增数据">
		<![CDATA[
  DELETE MAT_ZC_M T  WHERE T.MAT_NO = ?
        ]]>
	</query>

	<query id="PlanService.deleteMatBcJg" desc="删除材料表废品新增数据接箍">
		<![CDATA[
  DELETE coupling_mat_m T  WHERE T.WO_ID = ? and t.RESULT_NO = ?
        ]]>
	</query>
	<query id="PlanService.deleteMatButJg" desc="删除材料表废品新增数据接箍">
		<![CDATA[
  DELETE coupling_mat_buttress T  WHERE T.MAT_NO = ?
        ]]>
	</query>

	<query id="PlanService.deleteMatBut" desc="删除材料表废品新增数据">
		<![CDATA[
  DELETE YDM_BC_BUTTRESS T  WHERE T.MAT_NO = ?
        ]]>
	</query>

	<query id="PlanService.deleteMatZcBut" desc="删除材料表废品新增数据">
		<![CDATA[
  DELETE YDM_ZC_BUTTRESS T  WHERE T.MAT_NO = ?
        ]]>
	</query>

	<query id="PlanService.deleteMatButNew" desc="删除材料表废品新增数据">
		<![CDATA[

DECLARE
  V_ICOUNT NUMBER := 0;
BEGIN
  SELECT COUNT(1)
    INTO V_ICOUNT
    FROM YDM_BC_BUTTRESS_BACK
   WHERE MAT_NO = ?
     AND PLINE_CODE = ?;

  IF (V_ICOUNT =0) THEN
    INSERT INTO YDM_BC_BUTTRESS_BACK
      (MAT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       STORAGE_ATTR,
       STORAGE_ATTR_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       MEMO,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PLINE_CODE)
      SELECT MAT_NO,
             JUDGE_STOVE_NO,
             BATCH_NO,
             BATCH_GROUD_NO,
             STORAGE_NO,
             LOCATION_NO,
             LARY_NO,
             LOC_NO,
             STORAGE_ATTR,
             STORAGE_ATTR_NAME,
             STORAGE_TYPE_NO,
             STORAGE_TYPE_NAME,
             MANAGEMENT_NO,
             MANAGEMENT_NAME,
             MEMO,
             CREATE_NAME,
             CREATE_TIME,
             UPDATE_NAME,
             UPDATE_TIME,
             DELETE_NAME,
             DELETE_TIME,
             DEPARTMENT_CODE,
             DEPARTMENT_DESC,
             ?
        FROM YDM_BC_BUTTRESS
       WHERE MAT_NO = ?;

  ELSE
    UPDATE YDM_BC_BUTTRESS_BACK T
       SET (MAT_NO,
            JUDGE_STOVE_NO,
            BATCH_NO,
            BATCH_GROUD_NO,
            STORAGE_NO,
            LOCATION_NO,
            LARY_NO,
            LOC_NO,
            STORAGE_ATTR,
            STORAGE_ATTR_NAME,
            STORAGE_TYPE_NO,
            STORAGE_TYPE_NAME,
            MANAGEMENT_NO,
            MANAGEMENT_NAME,
            MEMO,
            CREATE_NAME,
            CREATE_TIME,
            UPDATE_NAME,
            UPDATE_TIME,
            DELETE_NAME,
            DELETE_TIME,
            DEPARTMENT_CODE,
            DEPARTMENT_DESC,
            PLINE_CODE) =
           (SELECT MAT_NO,
                   JUDGE_STOVE_NO,
                   BATCH_NO,
                   BATCH_GROUD_NO,
                   STORAGE_NO,
                   LOCATION_NO,
                   LARY_NO,
                   LOC_NO,
                   STORAGE_ATTR,
                   STORAGE_ATTR_NAME,
                   STORAGE_TYPE_NO,
                   STORAGE_TYPE_NAME,
                   MANAGEMENT_NO,
                   MANAGEMENT_NAME,
                   MEMO,
                   CREATE_NAME,
                   CREATE_TIME,
                   UPDATE_NAME,
                   UPDATE_TIME,
                   DELETE_NAME,
                   DELETE_TIME,
                   DEPARTMENT_CODE,
                   DEPARTMENT_DESC,
                   T.PLINE_CODE
              FROM YDM_BC_BUTTRESS
             WHERE MAT_NO = T.MAT_NO)
     WHERE MAT_NO = ?  AND PLINE_CODE = ?;
  END IF;


    DELETE FROM YDM_BC_BUTTRESS T  WHERE T.MAT_NO = ?;
END;
        ]]>
	</query>


<query id="PlanService.QueryMatNoJg" desc="">
		<![CDATA[
  SELECT T.MAT_NO MAT_NO FROM COUPLING_MAT_M T WHERE T.WO_ID = ? AND T.RESULT_NO = ? 
        ]]>
	</query>
	<query id="PlanService.getPlineCodeByProcess" desc="">
		<![CDATA[
  SELECT T.PLINE_CODE, T.PLINE_NAME
  FROM COM_BASE_PLINE T
 WHERE T.VALIDFLAG = '1'
        ]]>
	</query>

	<query id="PlanService.getPlineInfo" desc="">
		<![CDATA[
SELECT * FROM COM_BASE_PLINE WHERE PLINE_CODE = ?
        ]]>
	</query>

	<query id="PlanService.getStorage" desc="">
		<![CDATA[
 SELECT T.STORAGE_NO, T.STORAGE_NAME
   FROM YDM_BS_STORAGE T
  WHERE T.VALIDFLAG = '1'
  ORDER BY STORAGE_NO
        ]]>
	</query>


	<query id="PlanService.queryDesginKey" desc="查询热处理订单对应的DesginKey">
		<![CDATA[
		SELECT C.DESGIN_KEY, T.INDEX_SEQ
  FROM PLN_SALEORD S, PLN_ORDER_RCL_S T, CRAFT_ORD_DESIGN C
 WHERE S.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND C.ORD_LN_PK = S.ORD_LN_PK
   AND C.CRAFT_SEQ = T.CRAFT_SEQ
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
			]]>
	</query>

	<query id="PlanService.queryDesginKeyG" desc="查询热处理订单对应的DesginKey">
		<![CDATA[
		SELECT C.DESGIN_KEY, T.INDEX_SEQ
  FROM PLN_SALEORD S, PLN_ORDER_JGX_S T, CRAFT_ORD_DESIGN C
 WHERE S.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND C.ORD_LN_PK = S.ORD_LN_PK
   AND C.CRAFT_SEQ = T.CRAFT_SEQ
   AND T.PRO_PLAN_ID = ?
   AND T.GX_PLAN_NO = ?
			]]>
	</query>

	<query id="PlanService.querySqlPic" desc="询是否生产批,前几炉及循环值">
		<![CDATA[
		SELECT T.RATE,
       T.DESC_RATE,
       NVL(T.TOP_STOVE, 0) TOP_STOVE,
       NVL(T.LOOP_VALUE, 0) LOOP_VALUE
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T
 WHERE T.DESGIN_KEY = ?
   AND T.MSC_PLINE = ?
   AND T.PROCESS_CODE = 'F'
   AND T.PIC = ?
   AND T.RATE IN ('408601', '408608')
   AND (NVL(T.TOP_STOVE, 0) + NVL(T.LOOP_VALUE, 0)) =
       (SELECT MIN(NVL(T.TOP_STOVE, 0) + NVL(T.LOOP_VALUE, 0))
          FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T2
         WHERE T2.DESGIN_KEY = T.DESGIN_KEY
           AND T2.MSC_PLINE = T.MSC_PLINE
           AND T2.PROCESS_CODE = T.PROCESS_CODE
           AND T2.PIC = T.PIC
           AND T2.RATE = T.RATE)
			]]>
	</query>

	<query id="PlanService.querySqlPicG" desc="询是否生产批,前几炉及循环值">
		<![CDATA[
		SELECT T.RATE,
       T.DESC_RATE,
       NVL(T.TOP_STOVE, 0) TOP_STOVE,
       NVL(T.LOOP_VALUE, 0) LOOP_VALUE
  FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T
 WHERE T.DESGIN_KEY = ?
   AND T.MSC_PLINE = ?
   AND T.PROCESS_CODE = 'G'
   AND T.PIC = ?
   AND T.RATE IN ('408601', '408608')
   AND (NVL(T.TOP_STOVE, 0) + NVL(T.LOOP_VALUE, 0)) =
       (SELECT MIN(NVL(T.TOP_STOVE, 0) + NVL(T.LOOP_VALUE, 0))
          FROM CRAFT_ORD_DESIGN_STD_PIC_SMP T2
         WHERE T2.DESGIN_KEY = T.DESGIN_KEY
           AND T2.MSC_PLINE = T.MSC_PLINE
           AND T2.PROCESS_CODE = T.PROCESS_CODE
           AND T2.PIC = T.PIC
           AND T2.RATE = T.RATE)
			]]>
	</query>

	<query id="PlanService.queryHttM" desc="查询炉号是否重复">
		<![CDATA[
	SELECT COUNT(1) COUNT FROM pln_zy_rcl_m  WHERE judge_stove_no=?
			]]>
	</query>

	<query id="PlanService.queryVrpM" desc="查询炉号是否重复">
		<![CDATA[
	SELECT COUNT(1) COUNT FROM pln_zy_dbk_m  WHERE judge_stove_no=?
			]]>
	</query>

	<query id="PlanService.queryMchM" desc="查询炉号是否重复">
		<![CDATA[
	SELECT COUNT(1) COUNT FROM pln_zy_jgx_m  WHERE judge_stove_no=?
			]]>
	</query>

	<query id="PlanService.getBaseInfo1" desc="通用基础信息查询">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE,T.SORTCODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.BASECODE like ? || '%'
			   AND NOT EXISTS (SELECT 1 FROM  COM_BASE_INFO WHERE SORTCODE = T.BASECODE  AND VALIDFLAG = '1')
			    ORDER BY T.BASECODE
		]]>
	</query>

	<query id="PlanService.COMMQUERY" desc="通用基础信息查询">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE,T.SORTCODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.BASECODE like ? || '%'
			   AND NOT EXISTS (SELECT 1 FROM  COM_BASE_INFO WHERE SORTCODE = T.BASECODE  AND VALIDFLAG = '1')
			    ORDER BY T.BASECODE
		]]>
	</query>

	<query id="PlanService.COMMQUERY2" desc="通用基础信息查询">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE,T.SORTCODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.BASECODE like ? || '%'
			    ORDER BY T.BASECODE
		]]>
	</query>

	<query id="PlanService.COMMQUERY3" desc="通用基础信息查询">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE,T.SORTCODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.BASECODE like ? || '%'

		]]>
	</query>

	<query id="PlanService.COMMQUERY1" desc="通用基础信息查询">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.SORTCODE = ?
			   ORDER BY T.BASECODE
		]]>
	</query>


	<query id="PlanService.COMMQUERY3" desc="通用基础信息查询">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE,T.SORTCODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.BASECODE like ? || '%'
			   AND NOT EXISTS (SELECT 1 FROM  COM_BASE_INFO WHERE SORTCODE = T.BASECODE  AND VALIDFLAG = '1')
			     ORDER BY LPAD(MEMO,5,'0') ,T.BASECODE
		]]>
	</query>

	<query id="PlanService.TreeData" desc="获取树形结构数据。">
		<![CDATA[
      SELECT BASECODE, BASENAME, SORTCODE
        FROM COM_BASE_INFO
       WHERE 1 = 1
         AND VALIDFLAG = '1'
		]]>
	</query>


	<query id="PlanService.GetStorageIn" desc="获取投料库。">
		<![CDATA[
       SELECT Y.STORAGE_NO, Y.STORAGE_NAME
    FROM YDM_BS_STORAGE Y, COM_BASE_PLINE C
   WHERE C.IN_REPOSITORY = Y.STORAGE_NO
     AND C.PLINE_CODE = ?
     AND Y.VALIDFLAG = '1'
     AND C.VALIDFLAG = '1'
		]]>
	</query>

	<query id="PlanService.GetStorageOut" desc="获取投料库。">
		<![CDATA[
       SELECT Y.STORAGE_NO, Y.STORAGE_NAME
    FROM YDM_BS_STORAGE Y, COM_BASE_PLINE C
   WHERE C.OUT_REPOSITORY = Y.STORAGE_NO
     AND C.PLINE_CODE = ?
     AND Y.VALIDFLAG = '1'
     AND C.VALIDFLAG = '1'
		]]>
	</query>

	<query id="PlanService.SaveBarcode" desc="获取投料库。">
		<![CDATA[
UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
   SET BAR_CODE = ?
 WHERE HEAT_PLAN_NO = ?
   AND MAT_NO = ?

		]]>
	</query>


	<query id="PlanService.SaveRemark" desc="修改备注">
		<![CDATA[
		UPDATE PORT_MCH_BATCH_SAMPLE_RESULT
		   SET REMARK = ?
		 WHERE HEAT_PLAN_NO = ?
		   AND MAT_NO = ?

		]]>
	</query>
	
	<!-- 24.4.24 TZH 新增获取外委订单号 -->
	<query id="PlanService.QueryWwdd" desc="获取外围订单号">
		<![CDATA[
  		SELECT T.BASECODE, T.BASENAME, T.MNEMONIC_CODE,T.SORTCODE, T.SEQ, T.MEMO
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
			   AND T.BASECODE like ? || '%'
			   AND NOT EXISTS (SELECT 1 FROM  COM_BASE_INFO WHERE SORTCODE = T.BASECODE  AND VALIDFLAG = '1')
			    ORDER BY T.BASECODE
        ]]>
	</query>

</queryMap>