<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="生产接箍排产订单">
	<query id="CorePlnOrderJgS.QueryPlnOrderJg" desc="查询销售合同">
		<![CDATA[
SELECT T.*,
       T1.ALL_CODE_BL,
	   T1.CODE_JG_BL,
       T1.BL_WL_ID,
       T1.BL_WL_DESC,
       T1.PLINE_CODE,
       T1.PLINE_NAME,
       T1.MIN_H,
       T1.MIN_D,
       T1.LENGTH_MAX,
       T1.LENGTH_MIN,
       T2.AIMLENGTH_BL,
       T1.TAPER,
       NVL(T2.SINGLEWEIGHT2, 0) SINGLEWEIGHT2,
       NVL(T2.JGBL_REQ_WEIGHT, 0) JGBL_REQ_WEIGHT,
       NVL(T2.JGBL_REQ_NUM, 0) JGBL_REQ_NUM,
       NVL(T2.NUM_JG, 0) NUM_JG,
       NVL(T2.WEIGHT_JG, 0) WEIGHT_JG,
       NVL(T1.PLAN_NUM, 0) PLAN_NUM,
       T2.REQ_BL_ID,T1.MONITORDEMAND  MONITORDEMAND1
  FROM PLN_ORDER_JG T, PLN_GX_JG_M T1, PLN_JG_AND_BL T2
 WHERE T.PRO_PLAN_ID = T1.PRO_PLAN_ID
   AND T1.PRO_PLAN_ID = T2.PRO_PLAN_ID
   AND T2.REQ_BL_ID = ?
		]]>
	</query>
	<query id="CorePlnOrderJgS.selectProPlanIdMax" desc="查询接箍最大订单号">
		<![CDATA[
		SELECT 'JG_' || TO_CHAR(SYSDATE, 'YYYYMMDD') ||
       LPAD(NVL(MAX(TO_NUMBER(SUBSTR(T.PRO_PLAN_ID, 12)) + 1), '1'),
            4,
            '0') PRO_PLAN_ID
  FROM PLN_GX_JG_PROP_S T
 WHERE SUBSTR(T.PRO_PLAN_ID, 4, 8) = TO_CHAR(SYSDATE, 'YYYYMMDD')
			]]>
	</query>
	<query id="CorePlnOrderJgS.selectJgMaterialPl" desc="查询接箍投入产出产线能力">
		<![CDATA[
		SELECT T.PLINE_CODE,
       T.PLINE_NAME,
       T.IN_MATERIAL_NO,
       T.IN_MATERIAL_DESC,
       T.OUT_MATERIAL_NO,
       T.OUT_MATERIAL_DESC,
       NVL(T.WASTE_RATE, 0) WASTE_RATE,
       NVL(T.HR_CAPCTY, 0) HR_CAPCTY
  FROM SLM_BASE_MATERIAL_H_PL T
 WHERE (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
   AND T.IN_MATERIAL_NO = (SELECT T2.MATERIAL_NO
                             FROM CRAFT_ORD_DESIGN   TD,
                                  CRAFT_ORD_LINE_BOM T1,
                                  SLM_ORD_DESIGN_BOM T2
                            WHERE TD.DESGIN_KEY = T1.DESGIN_KEY
                              AND T1.BOM = T2.BOM
                              AND TD.ORD_LN_PK = ?
                              and td.VALIDFLAG<>'0'
                            GROUP BY T2.MATERIAL_NO)
   AND T.OUT_MATERIAL_NO = ?
   AND T.PLINE_CODE = ?
		]]>
	</query>
	<query id="CorePlnOrderJgS.selectJgMaterialPlA" desc="查询接箍投入产出产线能力">
		<![CDATA[
		SELECT T.PLINE_CODE,
       T.PLINE_NAME,
       T.IN_MATERIAL_NO,
       T.IN_MATERIAL_DESC,
       T.OUT_MATERIAL_NO,
       T.OUT_MATERIAL_DESC,
       NVL(T.WASTE_RATE, 0) WASTE_RATE,
       NVL(T.HR_CAPCTY, 0) HR_CAPCTY
  FROM SLM_BASE_MATERIAL_H_PL T
 WHERE (T.DISABLE_FL != '1' OR T.DISABLE_FL IS NULL)
   AND T.IN_MATERIAL_NO = ?
   AND T.PLINE_CODE = ?
		]]>
	</query>
	<query id="CorePlnOrderJgS.addPlnOrderJg" desc="新增接箍排产订单">
		<![CDATA[
		INSERT INTO PLN_GX_JG_PROP_S
  (PRO_PLAN_ID,
   JG_GROUP_ID,
   GX_PLAN_NO,
   PLINE_CODE,
   PLINE_NAME,
   GX_PRO_SEQ,
   CODE_JG,
   SPEC_JG_DESC,
   CODE_JG_BL,
   STEELCODE,
   STEELNAME,
   GRADECODE,
   GRADENAME,
   BL_WL_ID,
   BL_WL_DESC,
   MIN_D,
   MIN_H,
   AIMLENGTH_BL,
   AIM_CUT_LEN,
   LENGTH_MIN,
   LENGTH_MAX,
   TAPER,
   MODEL_CODE,
   MODEL_DESC,
   DEMAND_DETECTION,
   DEMAND_BONDERIZING,
   DEMAND_COPPER,
   DEMAND_BLAST,
   GROUP_NUM_S,
   SINGLE_CUT_NUN,
   GROUP_BL_NUM_S,
   GROUP_BL_WT_S,
   IS_PLAN_OK,
   MATCHNUM_JG,
   PRO_MONTH,
   PLAN_USETIME,
   PLAN_TIME_B,
   PLAN_TIME_E,
   MATCHWT_BL,
   MATCHNUM_BL,
   BATCHED_WT,
   BATCHED_NUM,
   BATCHED_NUM_OUT,
   REAL_BATCHED_WT,
   REAL_BATCHED_NUM,
   PRODUCED_NUM,
   EXE_STATUS,
   IS_REPAIR_PLN,
   IS_STOVE_ISSUED,
   PROCESSING_COST,
   TOTAL_COST,
   IF_MONITOR_JG,
   PRDCR_NO,
   CREATE_TIME,
   ORD_LN_DLY_PK,
   PLN_DIVIDE_ID,
   REQ_BL_ID,
   SPEC_JG,
   GROUP_WT_S,
   OUTWL_ID,
   OUTWL_DESC,
   MONITOR_POINT,
   CRAFT_FILE_NO,
   CRAFT_FILE_MAN,
   CRAFT_SEQ,
   STATION_ROAD,
   VERSION_NO,
   STYLE_JG,
   STD_CODE,
   STD_NAME,
   STD_STYLE,
   STD_STYLE_DESC,
   PRODUCCODE_JG,
   PRODUCCODE_JG_DESC,CODE_BL_ALL,ORDER_SOURCE,IF_MONITOR_BL,DECISION)
VALUES
  ('#PRO_PLAN_ID#',
   '#JG_GROUP_ID#',
   '#GX_PLAN_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#GX_PRO_SEQ#',
   '#CODE_JG#',
   '#SPEC_JG_DESC#',
   '#CODE_JG_BL#',
   '#STEELCODE#',
   '#STEELNAME#',
   '#GRADECODE#',
   '#GRADENAME#',
   '#BL_WL_ID#',
   '#BL_WL_DESC#',
   '#MIN_D#',
   '#MIN_H#',
   '#AIMLENGTH_BL#',
   '#AIM_CUT_LEN#',
   '#LENGTH_MIN#',
   '#LENGTH_MAX#',
   '#TAPER#',
   '#MODEL_CODE#',
   '#MODEL_DESC#',
   '#DEMAND_DETECTION#',
   '#DEMAND_BONDERIZING#',
   '#DEMAND_COPPER#',
   '#DEMAND_BLAST#',
   '#GROUP_NUM_S#',
   '#SINGLE_CUT_NUN#',
   '#GROUP_BL_NUM_S#',
   '#GROUP_BL_WT_S#',
   '0',
   '#MATCHNUM_JG#',
   '#PRO_MONTH#',
   '#PLAN_USETIME#',
   TO_DATE('#PLAN_TIME_B#', 'YYYY-MM-DD HH24:MI:SS'),
   TO_DATE('#PLAN_TIME_E#', 'YYYY-MM-DD HH24:MI:SS'),
   '#MATCHWT_BL#',
   '#MATCHNUM_BL#',
   '#BATCHED_WT#',
   '#BATCHED_NUM#',
   '#BATCHED_NUM_OUT#',
   '#REAL_BATCHED_WT#',
   '#REAL_BATCHED_NUM#',
   '#PRODUCED_NUM#',
   '0',
   '0',
   '0',
   '#PROCESSING_COST#',
   '#TOTAL_COST#',
   '#IF_MONITOR_JG#',
   '#PRDCR_NO#',
   SYSDATE,
   '#ORD_LN_DLY_PK#',
   '#PLN_DIVIDE_ID#',
   '#REQ_BL_ID#',
   '#SPEC_JG#',
   '#GROUP_WT_S#',
   '#OUTWL_ID#',
   '#OUTWL_DESC#',
   '#MONITOR_POINT#',
   '#CRAFT_FILE_NO#',
   '#CRAFT_FILE_MAN#',
   '#CRAFT_SEQ#',
   '#STATION_ROAD#',
   '#VERSION_NO#',
   '#STYLE_JG#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#STD_STYLE#',
   '#STD_STYLE_DESC#',
   '#PRODUCCODE_JG#',
   '#PRODUCCODE_JG_DESC#','#CODE_BL_ALL#','#ORDER_SOURCE#','#IF_MONITOR_BL#','#DECISION#')
			]]>
	</query>
	<query id="CorePlnOrderJgS.updatePlnOrderJg" desc="修改接箍订单量">
		<![CDATA[
		UPDATE PLN_GX_JG_PROP_S T
   SET T.GROUP_NUM_S    = TO_NUMBER(T.GROUP_NUM_S) + TO_NUMBER(?),
       T.GROUP_WT_S     = TO_NUMBER(T.GROUP_WT_S) + TO_NUMBER(?),
       T.GROUP_BL_NUM_S = TO_NUMBER(T.GROUP_BL_NUM_S) + TO_NUMBER(?),
       T.GROUP_BL_WT_S  = TO_NUMBER(T.GROUP_BL_WT_S) + TO_NUMBER(?)
 WHERE T.PRO_PLAN_ID = ?
		
			]]>
	</query>
	<query id="CorePlnOrderJgS.queryPlnSarCarft" desc="查询工艺文件,工艺路径">
		<![CDATA[
		SELECT T.INDEX_SEQ,
       T.CRAFT_FILE_MAN,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       (SELECT LISTAGG(S.STATION_DESC, ',') WITHIN GROUP(ORDER BY S.STATION_CODE)
          FROM CRAFT_ORD_DESIGN_MSC_PL_STI S
         WHERE S.DESGIN_KEY = ?
           AND S.MSC_PLINE = T.INDEX_SEQ
           AND S.PROCESS_CODE = 'H') STATION_ROAD,
           T.PROCESS_SEQ
  FROM PLN_SALEORD_PROC T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>
	<query id="CorePlnOrderJgS.queryProType" desc="查询品名类型">
		<![CDATA[
		SELECT (SELECT T1.PRODUC_TYPE
          FROM COM_BASE_PRODUCT T1
         WHERE T1.PRODUCCODE = T.PRODUCCODE
           AND T.VALIDFLAG = '1') PRODUC_TYPE
  FROM SLM_ORDER_LINE T, SLM_ORDER_LINE_DELIVERY S
 WHERE T.ORD_LN_PK = S.ORD_LN_PK
   AND S.ORD_LN_DLY_PK =
       (SELECT T.ORD_LN_DLY_PK
          FROM PLN_ORDER_JG T, PLN_JG_AND_BL S
         WHERE T.PRO_PLAN_ID = S.PRO_PLAN_ID
           AND S.REQ_BL_ID = ?
           AND ROWNUM = 1)
		]]>
	</query>
	<query id="CorePlnOrderJgS.addPlnOrderJgC" desc="新增接箍排产订单从表">
		<![CDATA[
		 INSERT INTO PLN_GX_JG_PROP_C(
        KEY,
        PRO_PLAN_ID,
        PLINE_CODE,
        PLINE_NAME,
        CODE_JG,
        DEMAND_DETECTION,
        DEMAND_BONDERIZING,
        DEMAND_COPPER,
        DEMAND_BLAST,
        GROUP_NUM_S,
        SINGLE_CUT_NUN,
        IF_MONITOR_JG,
        GROUP_WT_S,PLAN_NUM,
        PLAN_WT)
 VALUES( 
        '#KEY#',
        '#PRO_PLAN_ID#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#CODE_JG#',
        '#DEMAND_DETECTION#',
        '#DEMAND_BONDERIZING#',
        '#DEMAND_COPPER#',
        '#DEMAND_BLAST#',
        '#GROUP_NUM_S#',
        '#SINGLE_CUT_NUN#',
        '#IF_MONITOR_JG#',
        '#GROUP_WT_S#',
        '#PLAN_NUM#',
        '#PLAN_WT#')
			]]>
	</query>
	<query id="CorePlnOrderJgS.updatePlnOrderJgC" desc="修改箍排产订单从表">
		<![CDATA[
UPDATE PLN_GX_JG_PROP_C
   SET GROUP_NUM_S = TO_NUMBER(NVL(GROUP_NUM_S,0)) + TO_NUMBER(?),
       GROUP_WT_S  = TO_NUMBER(NVL(GROUP_WT_S,0)) + TO_NUMBER(?),
       PLAN_NUM = TO_NUMBER(NVL(PLAN_NUM,0)) + TO_NUMBER(?),
       PLAN_WT  = TO_NUMBER(NVL(PLAN_WT,0)) + TO_NUMBER(?)
 WHERE KEY = ?
 	]]>
	</query>
		<query id="CorePlnOrderJgS.QueryPlnJgPropS" desc="查询接箍订单信息">
		<![CDATA[
		 SELECT 
       T.PRO_PLAN_ID,
       T.JG_GROUP_ID,
       T.GX_PLAN_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.GX_PRO_SEQ,
       T.CODE_JG,
       T.SPEC_JG_DESC,
       T.CODE_JG_BL,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.MIN_D,
       T.MIN_H,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.TAPER,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.DEMAND_DETECTION,
       T.DEMAND_BONDERIZING,
       T.DEMAND_COPPER,
       T.DEMAND_BLAST,
       T.GROUP_NUM_S,
       T.SINGLE_CUT_NUN,
       T.GROUP_BL_NUM_S,
       T.GROUP_BL_WT_S,
       T.IS_PLAN_OK,
       T.MATCHNUM_JG,
       T.PRO_MONTH,
       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.MATCHWT_BL,
       T.MATCHNUM_BL,
       T.BATCHED_WT,
       T.BATCHED_NUM,
       T.BATCHED_NUM_OUT,
       T.REAL_BATCHED_WT,
       T.REAL_BATCHED_NUM,
       T.PRODUCED_NUM,
       T.EXE_STATUS,
       T.IS_REPAIR_PLN,
       T.REPAIR_TYPE,
       T.IS_STOVE_ISSUED,
       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.PROCESSING_COST,
       T.TOTAL_COST,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.STOVE_ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') STOVE_ISSUED_TIME,
       T.STOVE_ISSUED_MAN,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.SPEC_JG,
       T.GROUP_WT_S,
       T.REQ_BL_ID,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.MONITOR_POINT,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CRAFT_SEQ,
       T.STATION_ROAD,
       T.VERSION_NO,
       T.STYLE_JG,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRODUCCODE_JG,
       T.PRODUCCODE_JG_DESC,
       T.CODE_BL_ALL
 FROM PLN_GX_JG_PROP_S T
 WHERE T.ORD_LN_DLY_PK=?
   AND T.PLN_DIVIDE_ID=?
		]]>
	</query>
			<query id="CorePlnOrderJgS.queryPlnMonit" desc="查询接箍排产监制工序点">
		<![CDATA[
		SELECT (SELECT LISTAGG(PR.STATION_DESC, ',') WITHIN GROUP(ORDER BY PR.STATION_CODE ASC)
          FROM SLM_ORDER_LINE_PRDCR_LST PR
         WHERE PR.PRDCR_NO = P.PRDCR_NO
           AND PR.PRDCR_INDEX = P.PRDCR_INDEX
           AND PR.PRDCR_PRC_FL = '1'
           AND PR.PROCESS_CODE = 'H') MONITOR_POINT
  FROM PLN_SALEORD_PROC T, PLN_SALEORD T2, SLM_ORDER_LINE_PRDCR P
 WHERE T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND P.PRDCR_NO = T2.PRDCR_NO
   AND P.MSC_PLINE = T.INDEX_SEQ
   AND P.CODE_JG IS NOT NULL
   --AND P.CODE_BL IS NULL
   AND T.ORD_LN_DLY_PK = ?
		]]>
	</query>
</queryMap>