<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">

    <query id="CrmMatZc.insertCrmMatZc_Back" desc="新增">
        INSERT INTO CRM_MAT_ZC(
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        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,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        PLINE_CODE,
        PLINE_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        IN_MOLD,
        INSTOCK_TIME,
        STORAGE_NO,
        LOCATION_NO,
        STORAGE_NAME,
        LOCATION_NAME,
        DATA_STATUS,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT,
        CREATE_TIME)

        SELECT
        T.MAT_NO,
        (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.PRODUCT_FLAG),
        (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.MAT_STATUS),
        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.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.ORDER_NO,
        T.ORDER_SEQ,
        T.ORDER_SEQ_NO,
        T.ORD_PK,
        T.ORD_LN_PK,
        T.ORD_LN_DLY_PK,
        T.PLINE_CODE,
        T.PLINE_NAME,
        T.ACT_DIMATER,
        T.ACT_HEIGHT,
        T.ACT_LEN,
        T.ACT_LEN_MIN,
        T.ACT_LEN_MAX,
        T.ACT_COUNT,
        T.ACT_WEIGHT,
        (CASE WHEN T.BELONG_CODE = '100103'  THEN '100101'ELSE T.BELONG_CODE END),
        (SELECT T1.BASENAME FROM COM_BASE_INFO T1 WHERE T1.BASECODE=(CASE WHEN T.BELONG_CODE = '100103'  THEN '100101' ELSE T.BELONG_CODE END)),
        (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.IN_MOLD),
        T.INSTOCK_TIME,
        B.STORAGE_NO,
        B.LOCATION_NO,
        (SELECT STORAGE_NAME FROM YDM_BS_STORAGE WHERE STORAGE_NO = B.STORAGE_NO),
        (SELECT LOCATION_NAME FROM YDM_BS_LOCATION WHERE LOCATION_NO = B.LOCATION_NO),
        ?,
        T.SUPPLY_UNIT_CODE,
        T.SUPPLY_UNIT,
        to_date(?,'YYYY-MM-DD HH24:MI:SS')
        FROM MAT_ZC_BACKUP T
        LEFT JOIN YDM_ZC_BUTTRESS B ON B.MAT_NO = T.MAT_NO
        WHERE
        T.MAT_NO = ?
    </query>

    <query id="CrmMatZc.insertCrmMatZc_M" desc="新增">
    INSERT INTO CRM_MAT_ZC(
    MAT_NO,
    PRODUCT_FLAG,
    MAT_STATUS,
    LOT_NO,
    STOVE_NO,
    JUDGE_STOVE_NO,
    BATCH_NO,
    BATCH_GROUD_NO,
    MATERIAL_NO,
    MATERIAL_NAME,
    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,
    ORDER_NO,
    ORDER_SEQ,
    ORDER_SEQ_NO,
    ORD_PK,
    ORD_LN_PK,
    ORD_LN_DLY_PK,
    PLINE_CODE,
    PLINE_NAME,
    ACT_DIMATER,
    ACT_HEIGHT,
    ACT_LEN,
    ACT_LEN_MIN,
    ACT_LEN_MAX,
    ACT_COUNT,
    ACT_WEIGHT,
    BELONG_CODE,
    BELONG_NAME,
    IN_MOLD,
    INSTOCK_TIME,
    STORAGE_NO,
    LOCATION_NO,
    STORAGE_NAME,
    LOCATION_NAME,
    DATA_STATUS,
    SUPPLY_UNIT_CODE,
    SUPPLY_UNIT,
    CREATE_TIME)

    SELECT
    T.MAT_NO,
    (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.PRODUCT_FLAG),
    (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.MAT_STATUS),
    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.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.ORDER_NO,
    T.ORDER_SEQ,
    T.ORDER_SEQ_NO,
    T.ORD_PK,
    T.ORD_LN_PK,
    T.ORD_LN_DLY_PK,
    T.PLINE_CODE,
    T.PLINE_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.BELONG_CODE,
    T.BELONG_NAME,
    (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.IN_MOLD),
    T.INSTOCK_TIME,
    B.STORAGE_NO,
    B.LOCATION_NO,
    (SELECT STORAGE_NAME FROM YDM_BS_STORAGE WHERE STORAGE_NO = B.STORAGE_NO),
    (SELECT LOCATION_NAME FROM YDM_BS_LOCATION WHERE LOCATION_NO = B.LOCATION_NO),
    ?,
    T.SUPPLY_UNIT_CODE,
    T.SUPPLY_UNIT,
        to_date(?,'YYYY-MM-DD HH24:MI:SS')
    FROM MAT_ZC_M T
    LEFT JOIN YDM_ZC_BUTTRESS B ON B.MAT_NO = T.MAT_NO
    WHERE
    T.MAT_NO = ?
</query>

    <query id="CrmMatZc.insertCrmMatZc_GetM" desc="新增">
        INSERT INTO CRM_MAT_ZC(
        MAT_NO,
        PRODUCT_FLAG,
        MAT_STATUS,
        LOT_NO,
        STOVE_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BATCH_GROUD_NO,
        MATERIAL_NO,
        MATERIAL_NAME,
        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,
        ORDER_NO,
        ORDER_SEQ,
        ORDER_SEQ_NO,
        ORD_PK,
        ORD_LN_PK,
        ORD_LN_DLY_PK,
        PLINE_CODE,
        PLINE_NAME,
        ACT_DIMATER,
        ACT_HEIGHT,
        ACT_LEN,
        ACT_LEN_MIN,
        ACT_LEN_MAX,
        ACT_COUNT,
        ACT_WEIGHT,
        BELONG_CODE,
        BELONG_NAME,
        IN_MOLD,
        INSTOCK_TIME,
        STORAGE_NO,
        LOCATION_NO,
        STORAGE_NAME,
        LOCATION_NAME,
        DATA_STATUS,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT,
        CREATE_TIME)

        SELECT
        T.MAT_NO,
        (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.PRODUCT_FLAG),
        (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.MAT_STATUS),
        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.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.ORDER_NO,
        T.ORDER_SEQ,
        T.ORDER_SEQ_NO,
        T.ORD_PK,
        T.ORD_LN_PK,
        T.ORD_LN_DLY_PK,
        T.PLINE_CODE,
        T.PLINE_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.BELONG_CODE,
        T.BELONG_NAME,
        (SELECT F.BASENAME FROM COM_BASE_INFO F WHERE F.BASECODE = T.IN_MOLD),
        T.INSTOCK_TIME,
        B.STORAGE_NO,
        B.LOCATION_NO,
        (SELECT STORAGE_NAME FROM YDM_BS_STORAGE WHERE STORAGE_NO = B.STORAGE_NO),
        (SELECT LOCATION_NAME FROM YDM_BS_LOCATION WHERE LOCATION_NO = B.LOCATION_NO),
        ?,
        T.SUPPLY_UNIT_CODE,
        T.SUPPLY_UNIT,
        to_date(?,'YYYY-MM-DD HH24:MI:SS')
        FROM MAT_ZC_M T
        LEFT JOIN YDM_ZC_BUTTRESS B ON B.MAT_NO = T.MAT_NO
        WHERE T.MAT_NO  IN (SELECT L.MAT_NO
        FROM YDM_ZC_OUTLIST L
        WHERE L.M_BILL_NO = ?
        AND L.JUDGE_STOVE_NO = ?
        AND L.BATCH_NO = ?
        AND L.BATCH_GROUD_NO = ?
        AND NVL(L.ORD_LN_DLY_PK,'/')=NVL(?,'/')
        AND L.MAT_NO = MAT_NO
        AND L.OUTSTOCK_TYPE_CODE = '800806')
    </query>
</queryMap>