<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍库存导入">
	<query id="FrmImportSetMatJg.queryMaterial" desc="查询接箍库存信息">
            <![CDATA[
 SELECT 
       T.MAT_NO,
       T.RESULT_NO,
       T.WO_ID,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BL_WL_ID,
       T.MIN_D,
       T.MIN_H,
       T.CODE_JG,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.DIAMETER,
       T.CHECK_J_VAL,
       T.AIMLENGTH,
       T.SINGLEWEIGHT,
       T.MONITORDEMAND,
       DECODE(T.IF_MONITOR_JG,'1','是','/') IF_MONITOR_JG,
       T.PRDCR_NO,
       T.PRODUCER,
       T.PRO_NUM,
       T.PRO_WT,
       T.COL_OPERATOR,
       TO_CHAR(T.RRO_TIME, 'YYYY-MM-DD HH24:MI:SS') RRO_TIME,
       T.PRO_SHIFT,
       T.PRO_GROUP,
       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,
       TO_CHAR(T.F_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') FIN_TIME,
       T.BL_WL_DESC,
       T.MEMO,
      (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=T.DEMAND_COPPER) DEMAND_COPPER,
      (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.STYLE_JG) STYLE_JG,
       DECODE(T.COAT_TYPE,'0','无','1','镀铜','2','磷化','4','钝化') COAT_TYPE,
       T.BELONG_CODE,
       T.BELONG_NAME,
       T.CODE_JG_BL,
       T.CRAFT_FILE_NO,
       T.CRAFT_SEQ,
       T.JG_ORDERNO,
       DECODE(T.LOCK_FLAG,'0','未封锁','1','质量封锁') LOCK_FLAG,
        DECODE(T.MNG_LOCK_FLAG,'0','未封锁','1','管理封锁') MNG_LOCK_FLAG,
       T.MNG_LOCK_REMARK,
       T.LOCK_REMARK,
       DECODE(T.DETER_STATUS,'0','未申请','1','申请判定','2','已判定') DETER_STATUS,
       T.DETER_NO,
       T.DETER_RESULTS,
       T.FINAL_USER_DESC,
       T.MAT_ORIGIN_CODE,
       T.MAT_ORIGIN_NAME,
       T.SOURE_CODE,
       T.SOURE_NAME,T.JUDGE_STD_NAME
 FROM COUPLING_MAT_M T
 WHERE 1=1 AND T.WO_ID IS  NULL
              ]]>
	</query>
	
		<query id="FrmImportSetMatJg.getMaxMatNo" desc="查询最大物料编号">
	<![CDATA[ 
 SELECT  ? || 
        LPAD(SUBSTR(NVL(MAX(T.MAT_NO), '000'), -3, 3) + 1, 3, '0') MAT_NO
   FROM COUPLING_MAT_M T
  WHERE T.JUDGE_STOVE_NO =?
	]]>
	</query>
		<query id="FrmImportSetMatJg.getAddMatJgM" desc="新增接箍材料表">
	<![CDATA[ 
	 INSERT INTO COUPLING_MAT_M(
        MAT_NO,
        JUDGE_STOVE_NO,
        BATCH_NO,
        MIN_D,
        MIN_H,
        GRADENAME,
        STEELNAME,
        MODEL_DESC,
        OUTDIAMETER,
        WALLTHICK,
        SPEC_JG_DESC,
        SINGLEWEIGHT, 
        PRO_NUM,
        PRO_WT,
        CREATE_NAME,
        CREATE_TIME,
        F_IN_TIME,
        MEMO,
        DEMAND_BONDERIZING,
        COAT_TYPE,
        JG_ORDERNO,
        FINAL_USER_DESC,
        SOURE_NAME,JUDGE_STD_NAME,GRADECODE,STEELCODE,SPEC_JG,MODEL_CODE)
 VALUES( 
        '#MAT_NO#',
        '#JUDGE_STOVE_NO#',
        '#BATCH_NO#',
        '#MIN_D#',
        '#MIN_H#',
        '#GRADENAME#',
        '#STEELNAME#',
        '#MODEL_DESC#',
        '#OUTDIAMETER#',
        '#WALLTHICK#',
        '#SPEC_JG_DESC#',
        '#SINGLEWEIGHT#',
        '#PRO_NUM#',
        '#PRO_WT#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI:SS'),
        TO_DATE('#FIN_TIME#','YYYY-MM-DD HH24:MI:SS'),
        '#MEMO#',
        '#DEMAND_BONDERIZING#',
        '#COAT_TYPE#',
        '#JG_ORDERNO#',
        '#FINAL_USER_DESC#',
        '#SOURE_NAME#','#JUDGE_STD_NAME#','#GRADECODE#','#STEELCODE#','#SPEC_JG#','#MODEL_CODE#')
	]]>
	</query>
	<query id="FrmImportSetMatJg.getAddMatButt" desc="新增接箍库存位置表">
	<![CDATA[ 
	 INSERT INTO COUPLING_MAT_BUTTRESS(
        MAT_NO,
        mat_no_xh,
        PRODUCT_FLAG,
        MAT_STATUS,
        PRO_PLAN_ID,
        JG_GROUP_ID,
        MACH_NO,
        MACH_NM,
        MAT_ORIGIN_CODE,
        MAT_ORIGIN_NAME,
        SOURE_CODE,
        SOURE_NAME,
        PIECES,
        WEIGHT,
        KEP_NO,
        STORAGE_NO,
        LOCATION_NO,
        STORAGE_ATTR,
        STORAGE_ATTR_NAME,
        STORAGE_TYPE_NO,
        STORAGE_TYPE_NAME,
        MANAGEMENT_NO,
        MANAGEMENT_NAME,
        MEMO,
        CREATE_NAME,
        CREATE_TIME)
 VALUES( 
        '#MAT_NO#',
        '0001',
        '801402',
        '80150202',
        '#PRO_PLAN_ID#',
        '#JG_GROUP_ID#',
        '#MACH_NO#',
        '#MACH_NM#',
        '#MAT_ORIGIN_CODE#',
        '#MAT_ORIGIN_NAME#',
        '',
        '产线',
        '#PIECES#',
        '#WEIGHT#',
        'A00001',
        'TJG1',
        '#LOCATION_NO#',
        '800302',
        '投料库',
        '800202',
        '钢管',
        '002001002022',
        '接箍1（美国PMC1077）',
        '#MEMO#',
        '#CREATE_NAME#',
        TO_DATE('#CREATE_TIME#','YYYY-MM-DD HH24:MI;SS'))
		]]>
	</query>
</queryMap>