<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍上料实绩">
	<query id="CoupLoadingService.GetLoadResultByID" desc="上料实绩查询">
        <![CDATA[
        SELECT NVL(SUM(C.LOAD_PIECES),0) LOAD_PIECES,NVL(SUM(C.LOAD_WEIGHT),0) LOAD_WEIGHT
				FROM COUPLING_LOADING_RESULT C
		  WHERE C.ZY_PLAN_ID=? AND C.PLINE_CODE=? AND C.LOAD_SHIFT=? AND C.LOAD_GROUP=?
        ]]>
	</query>
	<query id="CoupLoadingService.doQueryPiece" desc="查询编辑区支数">
        <![CDATA[
        SELECT SUM(T.FAIL_NUM) FAIL FROM COUPLING_COM_INFO T WHERE 1 = 1
        ]]>
	</query>
	<query id="CoupLoadingService.AddLoadResult" desc="新增上料实绩">
        <![CDATA[
          INSERT INTO COUPLING_LOADING_RESULT
   (RESULT_NO,
    WO_ID,
    JUDGE_STOVE_NO,
    BATCH_NO,
    BATCH_GROUD_NO,
    LOAD_PIECES,
    LOAD_WEIGHT,
    LOAD_SHIFT,
    LOAD_GROUP,
    LOAD_USER,
    LOAD_TIME,
    PLINE_CODE,
    PLINE_NAME,
    CREATE_TIME,
    PRO_TIME,
    GRADECODE,
    GRADENAME,
    STEELCODE,
    STEELNAME,
    SPEC_JG_DESC,
    SPEC_JG,
    STYLE_JG,
    STD_CODE,
    STD_NAME,
    STD_STYLE,
    STD_STYLE_DESC,
    PRODUCCODE_JG,
    PRODUCCODE_JG_DESC,
    CODE_JG,
    CODE_JG_BL,
    MODEL_CODE,
    MODEL_DESC,
    IF_MONITOR_JG,
    PRDCR_NO,
    MEMO,
    CONFIRM,
    PLACE,
    MACHINE_NO)
 VALUES
   ('#RESULT_NO#',
    '#WO_ID#',
    '#JUDGE_STOVE_NO#',
    '#BATCH_NO#',
    '#BATCH_GROUD_NO#',
    '#LOAD_PIECES#',
    '#LOAD_WEIGHT#',
    '#LOAD_SHIFT#',
    '#LOAD_GROUP#',
    '#LOAD_USER#',
    TO_DATE('#LOAD_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
    '#PLINE_CODE#',
    '#PLINE_NAME#',
    TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
    TO_DATE('#PRO_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
    '#GRADECODE#',
    '#GRADENAME#',
    '#STEELCODE#',
    '#STEELNAME#',
    '#SPEC_JG_DESC#',
    '#SPEC_JG#',
    '#STYLE_JG#',
    '#STD_CODE#',
    '#STD_NAME#',
    '#STD_STYLE#',
    '#STD_STYLE_DESC#',
    '#PRODUCCODE_JG#',
    '#PRODUCCODE_JG_DESC#',
    '#CODE_JG#',
    '#CODE_JG_BL#',
    '#MODEL_CODE#',
    '#MODEL_DESC#',
    '#IF_MONITOR_JG#',
    '#PRDCR_NO#',
    '#MEMO#',
    '#CONFIRM#',
    '#PLACE#',
    '#MACHINE_NO#')
        ]]>
	</query>
	<query id="CoupLoadingService.getMatZcMById" desc="查询物料信息">
		<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN_MIN || '-' || T.ACT_LEN_MAX AS LENSCOPE,
       T.GRADENAME,
       T.GRADECODE,
       T.STEELNAME,
       T.STEELCODE,
       T.STD_NAME,
       T.STD_CODE,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       TO_CHAR(MIN(T.CREATE_TIME), 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       T.CREATE_NAME,
       SUM(T.ACT_COUNT) ACT_COUNT,
       SUM(T.ACT_WEIGHT) AS ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT) AS ACT_THEORY_WEIGHT,
       (select MAX(b.storage_name) storage_name from ydm_bs_storage b where b.validflag = '1' and b.storage_no=t2.storage_no)
  FROM MAT_BC_M T, YDM_BC_BUTTRESS T2
 WHERE T.MAT_NO = T2.MAT_NO
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
   AND T.MAT_STATUS = '80150103'
   AND T.QCM_STAUS = '00'
 GROUP BY T.JUDGE_STOVE_NO,
          T.BATCH_NO,
          T.BATCH_GROUD_NO,
          T.ACT_DIMATER,
          T.ACT_HEIGHT,
          T.ACT_LEN_MIN,
          T.ACT_LEN_MAX,
          T.GRADENAME,
          T.GRADECODE,
          T.STEELNAME,
          T.STEELCODE,
          T.STD_NAME,
          T.STD_CODE,
          T.STD_STYLE,
          T.STD_STYLE_DESC,
          T.PRODUCCODE,
          T.PRODUCNAME,
          T.MODEL_CODE,
          T.MODEL_DESC,
          T.SPEC_CODE,
          T.SPEC_NAME,
          --T.CREATE_TIME,
          T.CREATE_NAME,
          t2.storage_no
 ORDER BY T.JUDGE_STOVE_NO, T.BATCH_NO, T.BATCH_GROUD_NO ASC
		]]>
	</query>
	<query id="CoupLoadingService.getCoupLingById" desc="查询上料信息">
		<![CDATA[
 SELECT 
       T.RESULT_NO,
       T.WO_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.LOAD_PIECES,
       T.LOAD_WEIGHT,
       DECODE(LOAD_SHIFT,1,
                      '早',
                      2,
                      '中',
                      3,
                      '夜',
                      0,
                      '常白') LOAD_SHIFT,
       DECODE(LOAD_GROUP,1, '甲', 2, '乙', 3, '丙', 4, '丁') LOAD_GROUP,
       T.LOAD_USER,
       TO_CHAR(T.LOAD_TIME, 'YYYY-MM-DD HH24:MI:SS') LOAD_TIME,
       T.PLINE_CODE,
       T.PLINE_NAME,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       TO_CHAR(T.PRO_TIME, 'YYYY-MM-DD HH24:MI:SS') PRO_TIME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_JG_DESC,
       T.SPEC_JG,
       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_JG,
       T.CODE_JG_BL,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OFF_NUM,
       T.PLACE,
       DECODE(T.IF_MONITOR_JG,'1','是','/') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.MEMO,
       T.MACHINE_NO,
       T.CONFIRM
 FROM COUPLING_LOADING_RESULT T
 WHERE T.WO_ID = ?
		]]>
	</query>

	<query id="CoupLoadingService.updateMatZcPlan" desc="修改库存状态">
		<![CDATA[
        UPDATE MAT_BC_M T SET T.MAT_STATUS = ?,T.PRO_PLAN_ID_NEXT = '',T.GX_PLAN_NO_NEXT = '' WHERE T.MAT_NO = ?
		]]>
	</query>
	<query id="CoupLoadingService.deleteButter" desc="删除位置表记录">
		<![CDATA[
       DELETE YDM_BC_BUTTRESS WHERE MAT_NO = ?
		]]>
	</query>
	<query id="CoupLoadingService.DeteleBcOutlist" desc="删除红冲出库">
		<![CDATA[
       DELETE YDM_BC_OUTLIST WHERE  OUTSTOCK_PLAN_NO = ? and MAT_NO  = ?
       and OUTSTOCK_TYPE_CODE = '800806' 
		]]>
	</query>
	<query id="CoupLoadingService.AddOutList" desc="新增出库记录">
		<![CDATA[
 INSERT INTO YDM_BC_OUTLIST
  (OUTSTOCK_SQE,
   OUTSTOCK_PLAN_NO,
   OUTSTOCK_DOC,
   OUTSTOCK_TYPE_CODE,
   OUTSTOCK_TYPE_NAME,
   ICCAR_NO,
   VEHICLE_NO,
   MAT_NO,
   LOT_NO,
   STOVE_NO,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BATCH_GROUD_NO,
   MATERIAL_NO,
   MATERIAL_NAME,
   PRODUCCODE,
   PRODUCNAME,
   STD_CODE,
   STD_NAME,
   GRADECODE,
   GRADENAME,
   STEELCODE,
   STEELNAME,
   STD_STYLE,
   STD_STYLE_DESC,
   SPEC_CODE,
   SPEC_NAME,
   MODEL_CODE,
   MODEL_DESC,
   PRO_ORDER_NO,
   PLINE_CODE,
   PLINE_NAME,
   ACT_DIMATER,
   ACT_HEIGHT,
   ACT_LEN,
   ACT_LEN_MIN,
   ACT_LEN_MAX,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   BELONG_CODE,
   BELONG_NAME,
   BAR_CODE,
   STORAGE_NO,
   LOCATION_NO,
   LARY_NO,
   LOC_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   TAR_REC_FLAG,
   RPO_TIME,
   PRO_BC,
   PRO_BZ,
   INSTOCK_TIME,
   IN_BC,
   IN_BZ,
   OUTSTOCK_TIME,
   OUT_BC,
   OUT_BZ,
   MEMO,
   HAND_FLAG,
   VALIDFLAG,
   CREATE_NAME,
   CREATE_TIME,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK,
   DEPARTMENT_CODE,
   DEPARTMENT_DESC,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   PRODUCT_FLAG,
   MAT_STATUS,
   JUDGE_STD_NAME,
   JUDGE_STD_CODE,
   PONDER_NO,
   PONDER_GROSS_WT,
   BAL_YEAR_MONTH,
   LOAD_PLINE_CODE,
   LOAD_PLINE_NAME,
   PROCESS_CDOE,
   PROCESS_DESC)
VALUES
  ('#OUTSTOCK_SQE#',
   '#OUTSTOCK_PLAN_NO#',
   '#OUTSTOCK_DOC#',
   '#OUTSTOCK_TYPE_CODE#',
   '#OUTSTOCK_TYPE_NAME#',
   '#ICCAR_NO#',
   '#VEHICLE_NO#',
   '#MAT_NO#',
   '#LOT_NO#',
   '#STOVE_NO#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#BATCH_GROUD_NO#',
   '#MATERIAL_NO#',
   '#MATERIAL_NAME#',
   '#PRODUCCODE#',
   '#PRODUCNAME#',
   '#STD_CODE#',
   '#STD_NAME#',
   '#GRADECODE#',
   '#GRADENAME#',
   '#STEELCODE#',
   '#STEELNAME#',
   '#STD_STYLE#',
   '#STD_STYLE_DESC#',
   '#SPEC_CODE#',
   '#SPEC_NAME#',
   '#MODEL_CODE#',
   '#MODEL_DESC#',
   '#PRO_ORDER_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#ACT_DIMATER#',
   '#ACT_HEIGHT#',
   '#ACT_LEN#',
   '#ACT_LEN_MIN#',
   '#ACT_LEN_MAX#',
   '#ACT_COUNT#',
   '#ACT_WEIGHT#',
   '#ACT_THEORY_WEIGHT#',
   '#BELONG_CODE#',
   '#BELONG_NAME#',
   '#BAR_CODE#',
   '#STORAGE_NO#',
   '#LOCATION_NO#',
   '#LARY_NO#',
   '#LOC_NO#',
   '#STORAGE_ATTR#',
   '#STORAGE_ATTR_NAME#',
   '#STORAGE_TYPE_NO#',
   '#STORAGE_TYPE_NAME#',
   '#MANAGEMENT_NO#',
   '#MANAGEMENT_NAME#',
   '1',
   TO_DATE('#RPO_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#PRO_BC#',
   '#PRO_BZ#',
   TO_DATE('#INSTOCK_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#IN_BC#',
   '#IN_BZ#',
   TO_DATE('#OUTSTOCK_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#OUT_BC#',
   '#OUT_BZ#',
   '#MEMO#',
   '0',
   '1',
   '#CREATE_NAME#',
   TO_DATE('#CREATE_TIME#', 'YYYY-MM-DD HH24:MI:SS'),
   '#ORD_PK#',
   '#ORD_LN_PK#',
   '#ORD_LN_DLY_PK#',
   '#DEPARTMENT_CODE#',
   '#DEPARTMENT_DESC#',
   '#ORDER_NO#',
   '#ORDER_SEQ#',
   '#DELIVERY_NO#',
   '#PRODUCT_FLAG#',
   '#MAT_STATUS#',
   '#JUDGE_STD_NAME#',
   '#JUDGE_STD_CODE#',
   '#PONDER_NO#',
   '#PONDER_GROSS_WT#',
   --TO_CHAR(SYSDATE, 'YYYYMM'),
   '#BAL_YEAR_MONTH#',
   '#LOAD_PLINE_CODE#',
   '#LOAD_PLINE_NAME#',
   '#PROCESS_CDOE#',
   '#PROCESS_DESC#')
		]]>
	</query>
	<query id="CoupLoadingService.queryOutList" desc="查询出库单号">
	<![CDATA[
       SELECT (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
       OUTSTOCK_DOC OUTSTOCK_DOC
  FROM (SELECT TO_CHAR(SYSDATE, 'YYMMDD') ||
               LPAD(NVL(MAX(SUBSTR(T.OUTSTOCK_DOC, 9)), 0) + 1, 5, 0) OUTSTOCK_DOC
          FROM YDM_BC_OUTLIST T
         WHERE OUTSTOCK_SQE LIKE
               (SELECT S.MEMO FROM COM_BASE_INFO S WHERE S.BASECODE = ?) ||
               TO_CHAR(SYSDATE, 'YYMMDD') || '%')
	]]>
	</query>
	<query id="CoupLoadingService.queryOut" desc="查询出库流水号">
	<![CDATA[
          SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.OUTSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS OUTSTOCK_SQE
    FROM YDM_BC_OUTLIST T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') = TO_CHAR(SYSDATE, 'YYYY-MM-DD')
     AND T.OUTSTOCK_DOC = ?
	]]>
	</query>
	<query id="CoupLoadingService.queryLoadRESULT" desc="查询最大实绩编号 ">
	<![CDATA[
  SELECT ? || ? || TO_CHAR(SYSDATE, 'yyyyMMDD') ||
         LPAD(NVL(MAX(TO_NUMBER(SUBSTR(RESULT_NO, LENGTH(RESULT_NO) - 5))),
                  0) + 1,
              6,
              '0') RESULT_NO
    FROM  COUPLING_LOADING_RESULT
   WHERE RESULT_NO LIKE ? || TO_CHAR(SYSDATE, 'yyyyMMDD') || '______'
	]]>
	</query>
	<query id="CoupLoadingService.queryYdmOut" desc="查询出库信息">
	<![CDATA[
SELECT OUTSTOCK_SQE,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       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,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ACT_WEIGHT
  FROM (SELECT *
          FROM YDM_BC_OUTLIST
         WHERE OUTSTOCK_TYPE_CODE = '800801'
           AND JUDGE_STOVE_NO = ?
           AND BATCH_NO = ?
           AND OUTSTOCK_PLAN_NO = ?
           AND MAT_NO NOT IN (SELECT T.MAT_NO FROM YDM_BC_OUTLIST T WHERE T.OUTSTOCK_TYPE_CODE ='800806' AND OUTSTOCK_PLAN_NO = ?)
         ORDER BY MAT_NO DESC)
 WHERE ROWNUM < ? 
	]]>
	</query>
	
	<query id="CoupLoadingService.queryYdmOutList" desc="查询出库信息">
	<![CDATA[
SELECT OUTSTOCK_SQE,
       OUTSTOCK_PLAN_NO,
       OUTSTOCK_DOC,
       OUTSTOCK_TYPE_CODE,
       OUTSTOCK_TYPE_NAME,
       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,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       ACT_WEIGHT
  FROM (SELECT *
          FROM YDM_BC_OUTLIST
         WHERE OUTSTOCK_TYPE_CODE = '800806'
           AND JUDGE_STOVE_NO = ?
           AND BATCH_NO = ?
           AND OUTSTOCK_PLAN_NO = ?
         ORDER BY MAT_NO DESC)
 WHERE ROWNUM < ? 
	]]>
	</query>
	<query id="CoupLoadingService.DeleteLoadResult" desc="删除上料实绩">
	<![CDATA[
 DELETE COUPLING_LOADING_RESULT WHERE RESULT_NO = ?
	]]>
	</query>
	
	<query id="CoupLoadingService.getConfirm" desc="确认上料实绩">
	<![CDATA[
 UPDATE COUPLING_LOADING_RESULT T SET T.CONFIRM = '1',T.CONFIRM_NAME =?,T.CONFIRM_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
  WHERE T.RESULT_NO = ?
	]]>
	</query>
	
	<query id="CoupLoadingService.getCancelConfirm" desc="取消确认上料实绩">
	<![CDATA[
 UPDATE COUPLING_LOADING_RESULT T SET T.CONFIRM = '0',T.CONFIRM_NAME =?,T.CONFIRM_TIME = TO_DATE(?,'YYYY-MM-DD HH24:MI:SS')
  WHERE T.RESULT_NO = ?
	]]>
	</query>
	
	<query id="CoupLoadingService.updateLoadResult" desc="修改上料实绩">
	<![CDATA[
 UPDATE COUPLING_LOADING_RESULT T
   SET T.LOAD_PIECES = TO_NUMBER(NVL(T.LOAD_PIECES, 0)) + TO_NUMBER(?),
    T.LOAD_WEIGHT =  TO_NUMBER(NVL(T.LOAD_WEIGHT, 0)) + TO_NUMBER(?)
 WHERE T.RESULT_NO = ?
   AND T.WO_ID = ?
	]]>
	</query>
	<query id="CoupLoadingService.updatePlanStatus" desc="修改接箍计划表状态">
		<![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET ZY_BILL_STATUS = ?,IFSPLIT ='',
       REAL_BL_NUM    = TO_NUMBER(NVL(REAL_BL_NUM, 0)) + TO_NUMBER(?),
       REAL_BL_WT     = TO_NUMBER(NVL(REAL_BL_WT, 0)) + TO_NUMBER(?)
 WHERE WO_ID = ?
		]]>
	</query>
	
	<query id="CoupLoadingService.updatePlanStatusBack" desc="回库修改接箍计划表状态">
		<![CDATA[
      UPDATE PLN_ZY_JG_WORKBILL
   SET 
       REAL_BL_NUM    = TO_NUMBER(NVL(REAL_BL_NUM, 0)) + TO_NUMBER(?),
       REAL_BL_WT     = TO_NUMBER(NVL(REAL_BL_WT, 0)) + TO_NUMBER(?)
 WHERE WO_ID = ?
		]]>
	</query>
	<query id="CoupLoadingService.queryLodResult" desc="查询上料实绩回退是否同一班次班组">
		<![CDATA[
     SELECT LOAD_SHIFT||'/'||LOAD_GROUP  LOAD_SHIFT FROM COUPLING_LOADING_RESULT T WHERE T.RESULT_NO=?
		]]>
	</query>
	<query id="CoupLoadingService.AddButter" 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, create_name, 
create_time, department_code, department_desc) values(?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?, ?, to_date(?, 'YYYY-MM-DD HH24:MI:SS'), ?, ?)
		]]>
	</query>
	<query id="CoupLoadingService.deleteOutList" desc="删除出库记录">
		<![CDATA[
      DELETE YDM_BC_OUTLIST WHERE OUTSTOCK_SQE = ?  AND OUTSTOCK_TYPE_CODE = '800801'
		]]>
	</query>
	
	<query id="CoupLoadingService.queryPlanFALG" desc="查询工单状态">
		<![CDATA[
      SELECT T.ZY_BILL_STATUS
  FROM PLN_ZY_JG_WORKBILL T
 WHERE T.ZY_PLAN_ID = ?
   AND T.WO_ID = ?
		]]>
	</query>
	<query id="CoupLoadingService.queryLodResultCount" desc="查询上料支数">
		<![CDATA[
      SELECT T.LOAD_PIECES FROM COUPLING_LOADING_RESULT T WHERE T.RESULT_NO=?
		]]>
	</query>
	<query id="CoupLoadingService.AddPlnInfo" desc="新增接箍公共信息">
		<![CDATA[
     INSERT INTO COUPLING_COM_INFO(
        RESULT_NO,
        WO_ID,
        PRO_PLAN_ID,
        CODE_JG_BL,
        IF_OUT_RPO,
        PLINE_CODE,
        PLINE_NAME,
        STATION_CODE,
        STATION_DESC,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BL_WL_ID,
        BL_WL_DESC,
        MIN_D,
        MIN_H,
        AIMLENGTH_BL,
        AIM_CUT_LEN,
        LENGTH_MIN,
        LENGTH_MAX,
        TAPER,
        CODE_JG,
        GRADECODE,
        GRADENAME,
        STEELCODE,
        STEELNAME,
        MODEL_CODE,
        MODEL_DESC,
        OUTDIAMETER,
        WALLTHICK,
        SPEC_JG,
        SPEC_JG_DESC,
        STYLE_JG,
        DIAMETER,
        CHECK_J_VAL,
        AIMLENGTH,
        SINGLEWEIGHT,
        MONITORDEMAND,
        IF_MONITOR_JG,
        PRDCR_NO,
        PRODUCER,
        MACH_NO,
        MACH_NM,
        PRO_NUM,
        PRO_WT,
        FAIL_NUM,
        FAIL_WT,
        OFFLINE_NUM,
        OFFLINE_WT,
        STATION_STATUS,
        RRO_TIME,
        RRO_TIME_NU,
        PRO_USER,
        PRO_SHIFT,
        PRO_GROUP,
        IF_ALL_OUT_WORK,
        CREATE_TIME,
        COL_OPERATOR,
        COL_OPERATOR2,
        JG_ORDERNO,
        PRODUCCODE_JG,
        PRODUCCODE_JG_DESC,
        STD_CODE,
        STD_NAME,
        STD_STYLE,
        STD_STYLE_DESC,
        OUTWL_ID,
        OUTWL_DESC)
 VALUES( 
        '#RESULT_NO#',
        '#WO_ID#',
        '#PRO_PLAN_ID#',
        '#CODE_JG_BL#',
        '#IF_OUT_RPO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#STATION_CODE#',
        '#STATION_DESC#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#BL_WL_ID#',
        '#BL_WL_DESC#',
        '#MIN_D#',
        '#MIN_H#',
        '#AIMLENGTH_BL#',
        '#AIM_CUT_LEN#',
        '#LENGTH_MIN#',
        '#LENGTH_MAX#',
        '#TAPER#',
        '#CODE_JG#',
        '#GRADECODE#',
        '#GRADENAME#',
        '#STEELCODE#',
        '#STEELNAME#',
        '#MODEL_CODE#',
        '#MODEL_DESC#',
        '#OUTDIAMETER#',
        '#WALLTHICK#',
        '#SPEC_JG#',
        '#SPEC_JG_DESC#',
        '#STYLE_JG#',
        '#DIAMETER#',
        '#CHECK_J_VAL#',
        '#AIMLENGTH#',
        '#SINGLEWEIGHT#',
        '#MONITORDEMAND#',
        '#IF_MONITOR_JG#',
        '#PRDCR_NO#',
        '#PRODUCER#',
        '#MACH_NO#',
        '#MACH_NM#',
        '#PRO_NUM#',
        '#PRO_WT#',
        '#FAIL_NUM#',
        '#FAIL_WT#',
        '#OFFLINE_NUM#',
        '#OFFLINE_WT#',
        '#STATION_STATUS#',
        TO_DATE('#RRO_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#RRO_TIME_NU#',
        '#PRO_USER#',
        '#PRO_SHIFT#',
        '#PRO_GROUP#',
        '#IF_ALL_OUT_WORK#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#COL_OPERATOR#',
        '#COL_OPERATOR2#',
        '#JG_ORDERNO#',
        '#PRODUCCODE_JG#',
        '#PRODUCCODE_JG_DESC#',
        '#STD_CODE#',
        '#STD_NAME#',
        '#STD_STYLE#',
        '#STD_STYLE_DESC#',
        '#OUTWL_ID#',
        '#OUTWL_DESC#')
		]]>
	</query>
	<query id="CoupLoadingService.deletePlnInfo" desc="删除接箍公共信息">
		<![CDATA[
		DELETE COUPLING_COM_INFO  WHERE RESULT_NO = ? AND STATION_CODE=?   AND WO_ID=?
			]]>
	</query>
		<query id="CoupLoadingService.updatePlnInfo" desc="修改接箍公共信息">
		<![CDATA[
		update COUPLING_COM_INFO t
   set t.pro_num = TO_NUMBER(NVL(T.pro_num, 0)) + TO_NUMBER(?),
       T.PRO_WT  = TO_NUMBER(NVL(T.PRO_WT, 0)) + TO_NUMBER(?)
 WHERE RESULT_NO = ?
   AND STATION_CODE = ?
   AND WO_ID = ?
			]]>
	</query>
	<query id="CoupLoadingService.GetQuery1" desc="查询上料支数总和">
        <![CDATA[
   SELECT NVL(SUM(T.LOAD_PIECES), 0) PRO_NUM FROM COUPLING_LOADING_RESULT T
   WHERE T.WO_ID = ?
        ]]>
	</query>
	<query id="CoupLoadingService.getQueryOfflinePiece" desc="查询离线支数">
        <![CDATA[
    SELECT   
       SUM((TO_NUMBER(NVL(T.OFFLINE_NUM, 0)) - TO_NUMBER(NVL(T.RE_NUM, 0)) -
       TO_NUMBER(NVL(T.SUBCONTRACT_NUM, 0)) +
       TO_NUMBER(NVL(T.SUBCONTRACTCOMPLETE_NUM, 0)))) Offline_Num_Bj
 FROM COUPLING_OFFLINE_RESULT T
 WHERE 1=1 AND T.WO_ID = ?
        ]]>
	</query>
	<query id="CoupLoadingService.DeleteOffline" desc="清空离线实绩">
        <![CDATA[
   DELETE COUPLING_OFFLINE_RESULT T
 WHERE WO_ID = ?
   AND NOT EXISTS (SELECT 1
          FROM PORT_JG_BATCH_SAMPLE_RESULT
         WHERE WO_ID = T.WO_ID AND RESULT_NO= T.RESULT_NO)
        ]]>
	</query>
	<query id="CoupLoadingService.getCoupCountById" desc="查询是否有上料记录">
		<![CDATA[
		SELECT COUNT(*) COUNT
  FROM COUPLING_LOADING_RESULT T
 WHERE T.WO_ID = ?	
			]]>
	</query>
	<query id="CoupLoadingService.getCoupCountById1" desc="同班次是否有上料记录">
		<![CDATA[
		SELECT COUNT(*) COUNT
  FROM COUPLING_LOADING_RESULT T
 WHERE T.WO_ID = ?	
   AND T.LOAD_SHIFT=?
			]]>
	</query>
	<query id="CoupLoadingService.QueryCutLoading" desc="查询是否存在上料后的实绩">
		<![CDATA[
	  SELECT COUNT(*) COUNT
  FROM Coupling_Com_Info T
 WHERE T.WO_ID = ? and t.station_code!='700301'
			]]>
	</query>
	
	<query id="CoupLoadingService.QueryWoId" desc="查询工单信息">
		<![CDATA[
	SELECT T.WO_ID,
       T.HEAT_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.IF_ALL_OUT_WORK,
       T.IF_OUT_CUT,
       T.IF_OUT_CJG,
       T.IF_OUT_IMPRESS,
       T.IF_OUT_LATHE,
       T.IF_OUT_DETECT,
       T.IF_OUT_BLAST,
       T.IF_OUT_COAT,
       T.COAT_TYPE,
       T.IFSPLIT,
       NVL(T.PLAN_JG_NUM, 0) PLAN_JG_NUM,
       NVL(T.CS_JG_NUM, 0) CS_JG_NUM,
       NVL(T.XQ_JG_NUM, 0) XQ_JG_NUM,
       T.DEMAND_COPPER,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       T.DEMAND_DETECTION,
       T.DEMAND_BLAST,
       T.DEMAND_BONDERIZING,
       T.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,
       T.IF_OUT_COPPER,
       TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       NVL(T.PLAN_BL_NUM, 0) PLAN_BL_NUM,
       NVL(T.PLAN_BL_WT, 0) PLAN_BL_WT,
       T.IF_OUT_THREAD,
       NVL(T.REAL_BL_NUM, 0) REAL_BL_NUM,
       NVL(T.REAL_BL_WT, 0) REAL_BL_WT,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.OUT_NUM,
       T.OUT_WT,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_JG_DESC,
       T.SPEC_JG,
       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_JG,
       T.CODE_JG_BL,
       T.CODE_BL_ALL,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.IF_MONITOR_JG,
       T.PRDCR_NO,
       T.HEAT_PLAN_SQE,
       T.KEY,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       T.SINGLE_CUT_NUN,
       T.SINGLEWEIGHT,
       T.PER_STATUS,
       T.BESIDE_STATUS,
       T1.MIN_D,
       T1.MIN_H,
       T1.LENGTH_MAX,
       T1.LENGTH_MIN,
       T1.TAPER,
       T1.DIAMETER_JG,
       T1.HEIGHT_JG,
       T1.DIAMETER,
       T1.CHECK_J_VAL,
       T1.LENGTH_JG,
       T1.WEIGHT_JG,
       T.JG_ORDERNO_ALL,
       T.CRAFT_PATH,
       T.CRAFT_NO_JG2,
       T.CRAFT_SEQ2,
       T.ORD_LN_DLY_PK,
       T.LATHE_CUT_NM,
       T.DELIVERY_NO,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.IS_LOAD_FLAG,
       M.FEED_HEAT_NO,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO_SEQ,
       T.CRAFT_SEQ,
       T.CRAFT_FILE_NO,
       T.BUYER_NAME
  FROM PLN_ZY_JG_WORKBILL T, COM_MSC_JG T1, PLN_ZY_JG_M M
 WHERE T.CODE_JG = T1.CODE_JG(+)
   AND T.HEAT_PLAN_NO = M.HEAT_PLAN_NO(+)
   AND T.WO_ID = ?

		]]>
	</query>
		<query id="CoupLoadingService.QueryMatGp" desc="查询半成品库存信息">
		<![CDATA[
	Select *
  from (SELECT T.MAT_NO,
               T.PRODUCT_FLAG,
               T.MAT_STATUS,
               T.LOT_NO,
               T.STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.BATCH_GROUD_NO,
               CASE
         WHEN T.BELONG_CODE = CASE
                WHEN C.SUPPLY_UNIT_CODE = '120501' THEN
                 '002001001'
                WHEN C.SUPPLY_UNIT_CODE = '120504' THEN
                 '002023005'
              END THEN
          '1'
         ELSE
          '0'
       END staus,
               T.SAMPLE_FLAG,
               T.MATERIAL_NO,
               T.MATERIAL_NAME,
               T.INPUT_MATERIAL_NAME,
               T.INPUT_MATERIAL_NO,
               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.STD_CODE,
               T.STD_NAME,
               T.STD_STYLE,
               T.STD_STYLE_DESC,
               T.PRO_ORDER_NO,
               T.PRO_ORDER_ID,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.ORDER_SEQ_NO,
               T.CRAF_NO,
               T.PROCESS_CDOE,
               T.PROCESS_DESC,
               T.NEXT_PROCESS_CDOE,
               T.NEXT_PROCESS_DESC,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.MAT_ORIGIN_CODE,
               T.MAT_ORIGIN_NAME,
               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,
               T.MEASURE_FLAG,
               T.BELONG_CODE,
               T.BELONG_NAME,
               T.PACK_FLAG,
               T.MAT_GOWHERE_CODE,
               T.MAT_GOWHERE_NAME,
               T.MAT_RETURN_FLAG,
               T.LOCK_FLAG,
               T.MNG_LOCK_FLAG,
               T.INSTOCK_FLAG,
               TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
               T.BAR_CODE,
               T.MEMO,
               T.ORD_PK,
               T.ORD_LN_PK,
               SUBSTR(T.ORD_LN_DLY_PK, 0, INSTR(T.ORD_LN_DLY_PK, '-') - 1) ORD_LN_DLY_PK,
               T.BAL_YEAR_MONTH,
               T.JUDGE_STD_NAME,
               T.PIPMEMO,
               T.SOURE_CODE,
               T.SOURE_NAME,
               T.PONDER_NO,
               T.PONDER_GROSS_WT,
               T.JUDGE_ID,
               T.LOCK_LIKU,
               T.QCM_STAUS,
               T.OUTSTOCK_DOC,
               T.HEAT_PLAN_NO,
               T.ZG_STOVE_SQE,
               T.GX_PLAN_NO,
               T.ZG_MAT_NO,
               T.TARGET,
               T.PROCESS_STATUS,
               T.JUGDE_CONVICTED,
               T.FIXTYPE_CODE,
               T.QUALITY_GROUP_ZG,
               T.FLAG_STOVE_NO_ZG,
               T.JUDGE_STOVE_NO_UP,
               T.CRAFT_SEQ,
               T.PRO_PLAN_ID_NEXT,
               T.GX_PLAN_NO_NEXT,
               T.HANGING_FLAG,
               T.CUT_NUM,
               T.JUDGE_STD_DES,
               T.MNG_LOCK_REMARK,
               T.LOCK_REMARK,
               T.JUGDE_APPLY_SEQUENO,
               T.HEAT_PLAN_NO_NEXT,
               T.CODE_JG_BL,
               T.CIC,
               T1.STORAGE_ATTR,
               T1.STORAGE_ATTR_NAME,
               T1.STORAGE_TYPE_NO,
               T1.STORAGE_TYPE_NAME,
               T1.STORAGE_NO,
               T1.LOCATION_NO,
               T1.LARY_NO,
               T1.LOC_NO,
               T1.MANAGEMENT_NO,
               T1.MANAGEMENT_NAME
          FROM MAT_BC_M T, YDM_BC_BUTTRESS T1, COM_BASE_PLINE C
         WHERE T.MAT_NO = T1.MAT_NO(+)
         AND T.PLINE_CODE = C.PLINE_CODE(+)
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150103'
           AND T.QCM_STAUS = '00'
           AND T.HANGING_FLAG = '1' 
           AND T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
           AND T.NEXT_PROCESS_CDOE = 'H'
           	]]>
	</query>
	<query id="CoupLoadingService.QueryMatBcList" desc="查询半成品库存信息">
		<![CDATA[
	Select *
  from (SELECT T.MAT_NO,
               T.PRODUCT_FLAG,
               T.MAT_STATUS,
               T.LOT_NO,
               T.STOVE_NO,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,
               T.BATCH_GROUD_NO,
               T.SAMPLE_FLAG,
               T.MATERIAL_NO,
               T.MATERIAL_NAME,
               T.INPUT_MATERIAL_NAME,
               T.INPUT_MATERIAL_NO,
               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.STD_CODE,
               T.STD_NAME,
               T.STD_STYLE,
               T.STD_STYLE_DESC,
               T.PRO_ORDER_NO,
               T.PRO_ORDER_ID,
               T.ORDER_NO,
               T.ORDER_SEQ,
               T.ORDER_SEQ_NO,
               T.CRAF_NO,
               T.PROCESS_CDOE,
               T.PROCESS_DESC,
               T.NEXT_PROCESS_CDOE,
               T.NEXT_PROCESS_DESC,
               T.PLINE_CODE,
               T.PLINE_NAME,
               T.MAT_ORIGIN_CODE,
               T.MAT_ORIGIN_NAME,
               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,
               T.MEASURE_FLAG,
               T.BELONG_CODE,
               T.BELONG_NAME,
               T.PACK_FLAG,
               T.MAT_GOWHERE_CODE,
               T.MAT_GOWHERE_NAME,
               T.MAT_RETURN_FLAG,
               T.LOCK_FLAG,
               T.MNG_LOCK_FLAG,
               T.INSTOCK_FLAG,
               TO_CHAR(T.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
               T.BAR_CODE,
               T.MEMO,
               T.ORD_PK,
               T.ORD_LN_PK,
               SUBSTR(T.ORD_LN_DLY_PK, 0, INSTR(T.ORD_LN_DLY_PK, '-') - 1) ORD_LN_DLY_PK,
               T.BAL_YEAR_MONTH,
               T.JUDGE_STD_NAME,
               T.PIPMEMO,
               T.SOURE_CODE,
               T.SOURE_NAME,
               T.PONDER_NO,
               T.PONDER_GROSS_WT,
               T.JUDGE_ID,
               T.LOCK_LIKU,
               T.QCM_STAUS,
               T.OUTSTOCK_DOC,
               T.HEAT_PLAN_NO,
               T.ZG_STOVE_SQE,
               T.GX_PLAN_NO,
               T.ZG_MAT_NO,
               T.TARGET,
               T.PROCESS_STATUS,
               T.JUGDE_CONVICTED,
               T.FIXTYPE_CODE,
               T.QUALITY_GROUP_ZG,
               T.FLAG_STOVE_NO_ZG,
               T.JUDGE_STOVE_NO_UP,
               T.CRAFT_SEQ,
               T.PRO_PLAN_ID_NEXT,
               T.GX_PLAN_NO_NEXT,
               T.HANGING_FLAG,
               T.CUT_NUM,
               T.JUDGE_STD_DES,
               T.MNG_LOCK_REMARK,
               T.LOCK_REMARK,
               T.JUGDE_APPLY_SEQUENO,
               T.HEAT_PLAN_NO_NEXT,
               T.CODE_JG_BL,
               T.CIC,
               T1.STORAGE_ATTR,
               T1.STORAGE_ATTR_NAME,
               T1.STORAGE_TYPE_NO,
               T1.STORAGE_TYPE_NAME,
               T1.STORAGE_NO,
               T1.LOCATION_NO,
               T1.LARY_NO,
               T1.LOC_NO,
               T1.MANAGEMENT_NO,
               T1.MANAGEMENT_NAME
          FROM MAT_BC_BACKUP T, YDM_BC_BUTTRESS T1
         WHERE T.MAT_NO = T1.MAT_NO(+)
           AND T.PRODUCT_FLAG = '801401'
           AND T.MAT_STATUS = '80150103'
           AND T.QCM_STAUS = '00'
           AND T.HANGING_FLAG = '1' 
           AND T.JUDGE_STOVE_NO = ?
           AND T.BATCH_NO = ?
           AND NVL(T.BATCH_GROUD_NO, '/') = NVL(?, '/')
           AND T.NEXT_PROCESS_CDOE = 'H'
           	]]>
	</query>
		<query id="CoupLoadingService.CopyBcMat" desc="把物料主表复制到List表">
	<![CDATA[
   INSERT INTO MAT_BC_BACKUP SELECT * FROM MAT_BC_M T WHERE T.MAT_NO = ?
	]]>
	</query>

		<query id="CoupLoadingService.DeteleBcMat" desc="删除物料主表">
	<![CDATA[
   DELETE MAT_BC_M WHERE MAT_NO = ?
	]]>
	</query>
		<query id="CoupLoadingService.OutlistMonth" desc="查询出库表结算日期">
		<![CDATA[
      SELECT T.BAL_YEAR_MONTH FROM YDM_BC_OUTLIST T WHERE T.OUTSTOCK_SQE = ?
		]]>
	</query>
	<query id="CoupLoadingService.getCoupBackPiece" desc="查询工单下回库多少支">
		<![CDATA[
      select count(*) COUNT from YDM_BC_OUTLIST T where t.outstock_plan_no = ? and t.outstock_type_code = '800806'
		]]>
	</query>
		<query id="CoupLoadingService.DeleteOutListQuan" desc="删除出库记录产权出库">
		<![CDATA[
      DELETE YDM_BC_OUTLIST WHERE MAT_NO = ?  AND OUTSTOCK_TYPE_CODE = '800809' AND  OUTSTOCK_PLAN_NO = ?
		]]>
	</query>
	<query id="CoupLoadingService.CopyBackup" desc="复制MAT_BC_BACKUP表到物料主表">
        <![CDATA[
      INSERT INTO  MAT_BC_M SELECT * FROM MAT_BC_BACKUP T WHERE T.Mat_No= ? AND T.NEXT_PROCESS_CDOE = 'H'
        ]]>
	</query>
	<query id="CoupLoadingService.DeteleBackup" desc="删除MAT_BC_BACKUP表">
        <![CDATA[
      DELETE MAT_BC_BACKUP WHERE Mat_No= ? AND NEXT_PROCESS_CDOE = 'H'
        ]]>
	</query>
	
	<query id="CoupLoadingService.getQueryWoId" desc="根据条件查询工单信息">
		<![CDATA[
SELECT T.WO_ID,
       T.HEAT_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.CRAFT_PATH,
       T.CRAFT_NO_JG2,
       T.CRAFT_SEQ2,
       T.IFSPLIT,
       (SELECT SUM(T2.CUT_PIECES)
          FROM COUPLING_CUT_RESULT T2
         WHERE T2.WO_ID = T.WO_ID) CUT_PIECES,
       (SELECT SUM(T2.QUALIFIED_NUMBER)
          FROM COUPLING_CUT_RESULT T2
         WHERE T2.WO_ID = T.WO_ID) QUALIFIED_NUMBER,
       (SELECT SUM(T1.PRODUCED_PCS)
          FROM COUPLING_THREADING_RESULT T1
         WHERE T1.WO_ID = T.WO_ID) PRODUCED_PCS,
       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,
              '1',
              '镀铜',
              '2',
              '磷化',
              '3',
              '镀铜及磷化',
              '0',
              '/') COAT_TYPE,
       T.JG_ORDERNO_ALL,
       NVL(T.PLAN_JG_NUM, 0) PLAN_JG_NUM,
       NVL(T.CS_JG_NUM, 0) CS_JG_NUM,
       NVL(T.XQ_JG_NUM, 0) XQ_JG_NUM,
       T.LATHE_GRP_NO,
       T.LATHE_GRP_NM,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.DEMAND_DETECTION) DEMAND_DETECTION,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.DEMAND_BLAST) DEMAND_BLAST,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.DEMAND_BONDERIZING) DEMAND_BONDERIZING,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.DEMAND_COPPER) DEMAND_COPPER,
       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.IF_OUT_COPPER, '0', '否', '1', '是') IF_OUT_COPPER,
       TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
       NVL(T.PLAN_BL_NUM, 0) PLAN_BL_NUM,
       NVL(T.PLAN_BL_WT, 0) PLAN_BL_WT,
       DECODE(T.IF_OUT_THREAD, '0', '/', '1', '是') IF_OUT_THREAD,
       NVL(T.REAL_BL_NUM, 0) REAL_BL_NUM,
       NVL(T.REAL_BL_WT, 0) REAL_BL_WT,
       T.STOVE_NO,
       T.FLAG_STOVE_NO,
       T.OUT_NUM,
       T.OUT_WT,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_JG_DESC,
       T.SPEC_JG,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE = T.STYLE_JG) STYLE_JG,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.PRODUCCODE_JG,
       T.PRODUCCODE_JG_DESC,
       T.CODE_JG,
       T.CODE_JG_BL,
       T.CODE_BL_ALL,
       T.MODEL_CODE,
       T.MODEL_DESC,
       DECODE(T.IF_MONITOR_JG, '0', '/', '1', '是') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.HEAT_PLAN_SQE,
       T.KEY,
       T.BL_WL_ID,
       T.BL_WL_DESC,
       T.OUTWL_ID,
       T.OUTWL_DESC,
       T.AIMLENGTH_BL,
       T.AIM_CUT_LEN,
       NVL(T.SINGLE_CUT_NUN, 0) SINGLE_CUT_NUN,
       NVL(T.SINGLEWEIGHT, 0) SINGLEWEIGHT,
       T.JG_ORDERNO_ALL,
       T.CRAFT_PATH,
       T.CRAFT_NO_JG2,
       T.CRAFT_SEQ2,
       T.ORD_LN_DLY_PK,
       T.LATHE_CUT_NM,
       T.DELIVERY_NO,
       T.ORDER_NO || '/' || T.ORDER_SEQ ORDER_NO_SEQ,
       T.GX_PRO_SEQ,
       T1.FEED_HEAT_NO
  FROM PLN_ZY_JG_WORKBILL T, PLN_ZY_JG_M T1
 WHERE T.HEAT_PLAN_NO = T1.HEAT_PLAN_NO(+)

		]]>
	</query>
		<query id="CoupLoadingService.lixianThreadingResult"
		desc="离线上料实绩">
        <![CDATA[
   UPDATE COUPLING_LOADING_RESULT T SET T.OFF_NUM=TO_NUMBER(NVL(T.OFF_NUM,0))+TO_NUMBER(?)  WHERE T.RESULT_NO=? 
        ]]>
	</query>
	
		<query id="CoupLoadingService.deletePort"
		desc="删除接箍队列表">
        <![CDATA[
   DELETE PORT_JG_BATCH_SAMPLE_RESULT T
 WHERE T.MAT_NO = ?
   AND T.WO_ID = ?
        ]]>
	</query>
		<query id="CoupLoadingService.AddPortJg"
		desc="新增接箍对列表">
        <![CDATA[
  INSERT INTO PORT_JG_BATCH_SAMPLE_RESULT
  (WO_ID,
   MAT_NO,
   LOT_NO,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   GROUP_NO,
   STOVE_NO,
   FLAG_STOVE_NO,
   ACT_COUNT,
   ACT_WEIGHT,
   ACT_THEORY_WEIGHT,
   OP_PROCESS,
   MAT_STATUS,
   LEVE_LOG,
   INSTORE_FLAG,
   RETURN_PROCESS,
   PRO_USER,
   PRO_SHIFT,
   PRO_GROUP,
   PRO_TIME,
   REMARK,
   RESULT_NO,
   SINGLE_CUT_NUN)
SELECT 
   T.WO_ID,
   P.MAT_NO,
   P.LOT_NO,
   T.PLINE_CODE,
   T.PLINE_NAME,
   T.JUDGE_STOVE_NO,
   T.BATCH_NO,
   T.BATCH_GROUD_NO,
   T.STOVE_NO,
   T.FLAG_STOVE_NO,
   P.ACT_COUNT,
   P.ACT_WEIGHT,
   P.ACT_THEORY_WEIGHT,
   '#OP_PROCESS#',--工序点代码
   '00',
   '00',
   '0',
   '',
   '#PRO_USER#',--操作人
   '#PRO_SHIFT#',--班次
   '#PRO_GROUP#',--班组
   TO_DATE('#PRO_TIME#','YYYY-MM-DD HH24:MI:SS'),
   '',
   '',
   T.SINGLE_CUT_NUN
   FROM pln_zy_jg_workbill T LEFT JOIN MAT_BC_M P ON T.Judge_Stove_No = p.judge_stove_no and t.batch_no = p.batch_no 
   and t.batch_groud_no = p.batch_groud_no AND P.MAT_NO ='#MAT_NO#'
   WHERE T.WO_ID = '#WO_ID#'
        ]]>
	</query>
		<query id="CoupLoadingService.CopyBcOutlist" desc="复制产权出库">
	<![CDATA[
   INSERT INTO YDM_BC_OUTLIST (
   outstock_sqe,
   outstock_plan_no,
   outstock_doc,
   outstock_type_code,
   outstock_type_name,
   iccar_no,
   vehicle_no,
   mat_no,
   lot_no,
   stove_no,
   judge_stove_no,
   batch_no,
   batch_groud_no,
   material_no,
   material_name,
   produccode,
   producname,
   std_code,
   std_name,
   gradecode,
   gradename,
   steelcode,
   steelname,
   std_style,
   std_style_desc,
   spec_code,
   spec_name,
   model_code,
   model_desc,
   pro_order_no,
   pline_code,
   pline_name,
   act_dimater,
   act_height,
   act_len,
   act_len_min,
   act_len_max,
   act_count,
   act_weight,
   act_theory_weight,
   belong_code,
   belong_name,
   bar_code,
   storage_no,
   location_no,
   lary_no,
   loc_no,
   storage_attr,
   storage_attr_name,
   storage_type_no,
   storage_type_name,
   management_no,
   management_name,
   tar_storage_no,
   tar_location_no,
   tar_lary_no,
   tar_loc_no,
   tar_storage_attr,
   tar_storage_attr_name,
   tar_storage_type_no,
   tar_storage_type_name,
   tar_management_no,
   tar_management_name,
   tar_rec_flag,
   rpo_time,
   pro_bc,
   pro_bz,
   instock_time,
   in_bc,
   in_bz,
   outstock_time,
   out_bc,
   out_bz,
   memo,
   hand_flag,
   validflag,
   create_name,
   create_time,
   update_name,
   update_time,
   delete_name,
   delete_time,
   ord_pk,
   ord_ln_pk,
   ord_ln_dly_pk,
   department_code,
   department_desc,
   tar_department_code,
   tar_department_desc,
   order_no,
   order_seq,
   delivery_no,
   product_flag,
   mat_status,
   judge_std_name,
   judge_std_code,
   ponder_no,
   ponder_gross_wt,
   vstel,
   vstel_desc,
   bal_year_month,
   m_bill_no,
   send_num,
   receiv_no,
   receiv_nm,
   finishpro_mold,
   in_mold,
   load_pline_code,
   load_pline_name,
   belong_code_response,
   belong_name_response,
   data_suorce,
   qcm_staus,
   leave_factory_name,
   leave_factory_time,
   leave_factory_flag,
   scrap_reason,
   driver,
   leave_management_no,
   leave_management_name)  
   SELECT 
   'HC' || T.outstock_sqe,
   T.outstock_plan_no,
   T.outstock_doc,
   '800806',
   '出库红冲',
   T.iccar_no,
   T.vehicle_no,
   T.mat_no,
   T.lot_no,
   T.stove_no,
   T.judge_stove_no,
   T.batch_no,
   T.batch_groud_no,
   T.material_no,
   T.material_name,
   T.produccode,
   T.producname,
   T.std_code,
   T.std_name,
   T.gradecode,
   T.gradename,
   T.steelcode,
   T.steelname,
   T.std_style,
   T.std_style_desc,
   T.spec_code,
   T.spec_name,
   T.model_code,
   T.model_desc,
   T.pro_order_no,
   T.pline_code,
   T.pline_name,
   T.act_dimater,
   T.act_height,
   T.act_len,
   T.act_len_min,
   T.act_len_max,
   ?,
   ?,
   ?,
   T.belong_code,
   T.belong_name,
   T.bar_code,
   T.storage_no,
   T.location_no,
   T.lary_no,
   T.loc_no,
   T.storage_attr,
   T.storage_attr_name,
   T.storage_type_no,
   T.storage_type_name,
   T.management_no,
   T.management_name,
   T.tar_storage_no,
   T.tar_location_no,
   T.tar_lary_no,
   T.tar_loc_no,
   T.tar_storage_attr,
   T.tar_storage_attr_name,
   T.tar_storage_type_no,
   T.tar_storage_type_name,
   T.tar_management_no,
   T.tar_management_name,
   T.tar_rec_flag,
   T.rpo_time,
   T.pro_bc,
   T.pro_bz,
   T.instock_time,
   T.in_bc,
   T.in_bz,
   T.outstock_time,
   T.out_bc,
   T.out_bz,
   T.memo,
   T.hand_flag,
   T.validflag,
   T.create_name,
   T.create_time,
   T.update_name,
   T.update_time,
   T.delete_name,
   T.delete_time,
   T.ord_pk,
   T.ord_ln_pk,
   T.ord_ln_dly_pk,
   T.department_code,
   T.department_desc,
   T.tar_department_code,
   T.tar_department_desc,
   T.order_no,
   T.order_seq,
   T.delivery_no,
   T.product_flag,
   T.mat_status,
   T.judge_std_name,
   T.judge_std_code,
   T.ponder_no,
   T.ponder_gross_wt,
   T.vstel,
   T.vstel_desc,
   T.bal_year_month,
   T.m_bill_no,
   T.send_num,
   T.receiv_no,
   T.receiv_nm,
   T.finishpro_mold,
   T.in_mold,
   T.load_pline_code,
   T.load_pline_name,
   T.belong_code_response,
   T.belong_name_response,
   T.data_suorce,
   T.qcm_staus,
   T.leave_factory_name,
   T.leave_factory_time,
   T.leave_factory_flag,
   T.scrap_reason,
   T.driver,
   T.leave_management_no,
   T.leave_management_name
   FROM YDM_BC_OUTLIST T WHERE T.MAT_NO = ? AND T.OUTSTOCK_TYPE_CODE = '800801' AND T.OUTSTOCK_PLAN_NO = ?
	]]>
	</query>
</queryMap>