<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍公共信息">
	<query id="FrmCollarInventory.queryOutPerfo" desc="查询盘库入库实绩">		
        <![CDATA[
        SELECT MACH_NM,
        DEAL_NUM,
        DEAL_WT,
        TO_CHAR(DEAL_TIME, 'YYYY-MM-DD HH24:MI:SS') DEAL_TIME,
        STORAGE_NO,
        LOCATION_NO,
        STORAGE_ATTR_NAME,
        STORAGE_TYPE_NAME,
        TAR_STORAGE_NO,
        TAR_LOCATION_NO,
        TAR_STORAGE_ATTR_NAME,
        TAR_STORAGE_TYPE_NAME,
        DECODE(TAR_REC_FLAG, '0', '未接收', '1', '已接收') TAR_REC_FLAG,
        DECODE(HAND_FLAG, '0', '自动', '1', '人工') HAND_FLAG,
        CREATE_NAME,
        TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
        UPDATE_NAME,
        TO_CHAR(UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
        DEAL_ORDE,
        DEAL_TYPE_CODE,
        DEAL_TYPE_NAME,
        SOURCE_CODE,
        SOURCE_NAME,
        TAR_CODE,
        TAR_NAME,
        KEP_NO,
        TAR_KEP_NO,
        MAT_NO,
        RESULT_NO,
        ZY_PLAN_ID,
        PRO_PLAN_ID,
        PLINE_CODE,
        PLINE_NAME,
        JUDGE_STOVE_NO,
        BATCH_NO,
        BL_WL_DESC,
        MIN_D,
        MIN_H,
        CODE_JG,
        GRADENAME,
        STEELNAME,
        MODEL_DESC,
        OUTDIAMETER,
        WALLTHICK,
        SPEC_JG_DESC,
        STYLE_JG,
        DIAMETER,
        CHECK_J_VAL,
        AIMLENGTH,
        SINGLEWEIGHT,
        MONITORDEMAND,
        IF_MONITOR_JG,
        PRDCR_NO,
        PRODUCER,
        TO_CHAR(PRODUCER_TIME, 'YYYY-MM-DD HH24:MI:SS') PRODUCER_TIME,
        TO_CHAR(F_IN_TIME, 'YYYY-MM-DD HH24:MI:SS') F_IN_TIME,
        BAL_YEAR_MONTH,
        DECODE(PRODUCT_FLAG,
               '801401',
               '在制品',
               '801402',
               '成品',
               '801403',
               '商品') PRODUCT_FLAG,
        (SELECT B.BASENAME
           FROM COM_BASE_INFO B
          WHERE B.VALIDFLAG = '1'
            AND B.BASECODE = MAT_STATUS) MAT_STATUS,
        DECODE(DETER_STATUS, '0', '未判定', '1', '申请判定', '2', '已判定') DETER_STATUS,
        DECODE(DETER_RESULTS,
               '40740701',
               '合格',
               '40740703',
               '待判',
               '40740704',
               '不合格',
               '40740705',
               '废品',
               '40740706',
               '质量放行通过',
               '40740707',
               '交付合格',
               '40740708',
               '交付不合格') DETER_RESULTS,
        DETER_NO,MAT_NO_XH
   FROM COUPLING_MAT_DEAL
  WHERE 1 = 1

       ]]>
	</query>
	<query id="FrmInformation.getQueryGX" desc="查询工序">
		<![CDATA[
		SELECT T.BASECODE,
       T.BASENAME
  FROM COM_BASE_INFO T
 WHERE T.SORTCODE = '7003'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	<query id="FrmCollarInventory.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 =?
  --AND LENGTH(T.MAT_NO) = 12
	]]>
	</query>
	<query id="FrmCollarInventory.QUERYMatButterResult" desc="查询接箍基础信息">
		<![CDATA[
		SELECT T.CODE_JG,
       T.SPEC_JG,
       T.SPEC_JG_DESC,
       T.PRODUCCODE_JG,
       T.PRODUCCODE_JG_DESC,
       T.STEELCODE_JG,
       T.STEELCODE_JG_DESC,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STYLE_JG,
       T.MIN_D,
       T.MIN_H,
       T.DIAMETER_JG,
       T.HEIGHT_JG,
       T.LENGTH_JG,
       T.WEIGHT_JG,
       T.DIAMETER,
       T.ALPHA,
       T.DIAMETER_PL,
       T.HEIGHT_PL,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.MIN_H_CP,
       T.MAX_H_CP,
       T.MIN_D_CP,
       T.MAX_D_CP,
       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.DELETE_NAME,
       TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       T.VALIDFLAG,
       T.MEMO,
       T.STD_CODE,
       T.STD_NAME,
       T.CHECK_J_VAL,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.TAPER,
       T.MIN_D_JG,
       T.MAX_D_JG
  FROM COM_MSC_JG T
 WHERE T.CODE_JG = ?
 AND T.VALIDFLAG='1'
		]]>
	</query>
	<query id="FrmCollarInventory.AddDealResult" desc="新增交易信息">
		<![CDATA[
INSERT INTO COUPLING_MAT_DEAL
  (DEAL_TYPE_CODE,
   DEAL_TYPE_NAME,
   SOURCE_CODE,
   SOURCE_NAME,
   KEP_NO,
   MAT_NO,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BL_WL_ID,
   BL_WL_DESC,
   MIN_D,
   MIN_H,
   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,
   DEAL_NUM,
   DEAL_WT,
   DEAL_TIME,
   STORAGE_NO,
   LOCATION_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   HAND_FLAG,
   MEMO,
   CREATE_NAME,
   CREATE_TIME,
   DEAL_ORDE,
   PRODUCT_FLAG,
   MAT_STATUS,
   DETER_RESULTS,
   DETER_STATUS,
   MAT_NO_XH,
   WO_ID,
   STOVE_NO,
   ORDER_NO,
   ORDER_SEQ,
   DELIVERY_NO,
   ORD_PK,
   ORD_LN_PK,
   ORD_LN_DLY_PK)
VALUES
  ('#DEAL_TYPE_CODE#',
   '#DEAL_TYPE_NAME#',
   '#SOURCE_CODE#',
   '#SOURCE_NAME#',
   '#KEP_NO#',
   '#MAT_NO#',
   '#PLINE_CODE#',
   '#PLINE_NAME#',
   '#JUDGE_STOVE_NO#',
   '#BATCH_NO#',
   '#BL_WL_ID#',
   '#BL_WL_DESC#',
   '#MIN_D#',
   '#MIN_H#',
   '#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#',
   '#DEAL_NUM#',
   '#DEAL_WT#',
   SYSDATE,
   '#STORAGE_NO#',
   '#STORAGE_NO#10101',
   '#STORAGE_ATTR#',
   '#STORAGE_ATTR_NAME#',
   '#STORAGE_TYPE_NO#',
   '#STORAGE_TYPE_NAME#',
   '1',
   '#MEMO#',
   '#CREATE_NAME#',
   SYSDATE,
   '#DEAL_ORDE#',
   '#PRODUCT_FLAG#',
   '#MAT_STATUS#',
   '#DETER_RESULTS#',
   '#DETER_STATUS#',
   '0001',
   '#WO_ID#',
   '#STOVE_NO#',
   '#ORDER_NO#',
   '#ORDER_SEQ#',
   '#DELIVERY_NO#',
   '#ORD_PK#',
   '#ORD_LN_PK#',
   '#ORD_LN_DLY_PK#')
 ]]>
	</query>
	<query id="FrmCollarInventory.AddButterResult" desc="新增位置表">
		<![CDATA[
 INSERT INTO COUPLING_MAT_BUTTRESS
  (KEP_NO,
   MAT_NO,
   PIECES,
   WEIGHT,
   STORAGE_NO,
   LOCATION_NO,
   STORAGE_ATTR,
   STORAGE_ATTR_NAME,
   STORAGE_TYPE_NO,
   STORAGE_TYPE_NAME,
   MANAGEMENT_NO,
   MANAGEMENT_NAME,
   MEMO,
   CREATE_NAME,
   PRODUCT_FLAG,
   MAT_STATUS,
   MAT_NO_XH,
   CREATE_TIME)
VALUES
  (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?, SYSDATE)
	]]>
	</query>
	<query id="FrmCollarInventory.AddMatJgResult" desc="新增材料表">
	<![CDATA[
 INSERT INTO COUPLING_MAT_M
  (MAT_NO,
   PLINE_CODE,
   PLINE_NAME,
   JUDGE_STOVE_NO,
   BATCH_NO,
   BL_WL_ID,
   BL_WL_DESC,
   MIN_D,
   MIN_H,
   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,
   PRO_NUM,
   PRO_WT,
   PRO_SHIFT,
   PRO_GROUP,
   CREATE_NAME,
   RRO_TIME,
   CREATE_TIME,
   COL_OPERATOR,
   F_IN_TIME,
   MEMO,
   DETER_STATUS,
   DETER_RESULTS,
   JUDGE_RESULT_CODE,
   WO_ID,
   STOVE_NO,
   CODE_JG_BL)
VALUES
  (?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   SYSDATE,
   SYSDATE,
   ?,
   SYSDATE,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?,
   ?)
	]]>
	</query>
	<query id="FrmCollarInventory.deleteDealResult" desc="删除交易信息">
		<![CDATA[
		DELETE COUPLING_MAT_DEAL WHERE DEAL_ORDE = ?
		]]>
	</query>
	<query id="FrmCollarInventory.deleteButterResult" desc="删除位置表">
		<![CDATA[
DELETE COUPLING_MAT_BUTTRESS
 WHERE MAT_NO = ?
	]]>
	</query>
	<query id="FrmCollarInventory.queryDealCount" desc="">
		<![CDATA[
SELECT COUNT(*) COUNT
  FROM COUPLING_MAT_BUTTRESS T
 WHERE  T.ZY_PLAN_ID = ?
   AND T.RESULT_NO = ?
   AND T.MAT_NO = ?
		]]>
	</query>
	<query id="FrmCollarInventory.deleteMatResult" desc="删除材料表">
		<![CDATA[
		DELETE COUPLING_MAT_M WHERE MAT_NO = ?
			]]>
	</query>
	<query id="FrmCollarInventory.getPscJg" desc="查询接箍基础信息所有">
		<![CDATA[
		SELECT CODE_JG,
       SPEC_JG,
       SPEC_JG_DESC,
       PRODUCCODE_JG,
       PRODUCCODE_JG_DESC,
       STEELCODE_JG,
       STEELCODE_JG_DESC,
       MODEL_CODE,
       MODEL_DESC,
       STYLE_JG,
       MIN_D,
       MIN_H,
       DIAMETER_JG,
       HEIGHT_JG,
       LENGTH_JG,
       WEIGHT_JG,
       DIAMETER,
       ALPHA,
       DIAMETER_PL,
       HEIGHT_PL,
       LENGTH_MIN,
       LENGTH_MAX,
       PRODUCCODE,
       PRODUCNAME,
       MIN_H_CP,
       MAX_H_CP,
       MIN_D_CP,
       MAX_D_CP,
       CREATE_NAME,
       CREATE_TIME,
       UPDATE_NAME,
       UPDATE_TIME,
       DELETE_NAME,
       DELETE_TIME,
       VALIDFLAG,
       MEMO,
       STD_CODE,
       STD_NAME,
       CHECK_J_VAL,
       STD_STYLE,
       STD_STYLE_DESC,
       TAPER,
       MIN_D_JG,
       MAX_D_JG
  FROM COM_MSC_JG 
  WHERE VALIDFLAG='1'
		]]>
	</query>
	<query id="FrmCollarInventory.getBlCode" desc="查询备料码">
		<![CDATA[
select SUBSTR(T.CRAF_NO, 1, 7) BL_CODE
  from QCM_ZG_JUGDE_APPLY t
 where T.CRAF_NO LIKE 'BL%'
   AND T.PROCESS_CODE = 'F'
   AND t.judge_stove_no = ?
	]]>
	</query>
	<query id="FrmCollarInventory.getCSOrderInfo" desc="查询车丝合同信息">
	<![CDATA[ 
SELECT h.order_no,l.order_seq,h.ord_pk,b.basecode,b.basename,
       t.ord_ln_pk,
       d.ord_ln_dly_pk,
       M1.CRAFT_NAME,
       T.DESGIN_KEY,
       T.CRAFT_SEQ,
       T.VALIDFLAG,
       mp.whole_backlog,
       mp.whole_backlog_desc
  from slm_order_line l
  LEFT JOIN com_base_info b
    ON b.basecode = l.order_ln_status
   and b.validflag = '1'
  left join slm_order_head h
    on h.ord_pk = l.ord_pk
  left join CRAFT_ORD_DESIGN T
    on l.ord_ln_pk = t.ord_ln_pk
  LEFT JOIN CRAFT_ORD_DESIGN_APPOINT M1
    ON M1.ORD_LN_PK = T.ORD_LN_PK
  LEFT JOIN CRAFT_ORD_DESIGN_STS_TKLG K
    ON K.DESGIN_KEY = T.DESGIN_KEY
   AND K.VALIDFLAG = '1'
  left join craft_ord_design_msc_pl mp
    on mp.desgin_key = t.desgin_key
    left join SLM_ORDER_LINE_DELIVERY d
    on l.ord_ln_pk = d.ord_ln_pk
 WHERE T.DESGIN_KEY IS NOT NULL
   AND T.VALIDFLAG != '0'
   AND K.DESIGN_STS = 'S'
   and l.validflag = '1'
   and h.validflag = '1'
   and instr(mp.whole_backlog_desc,'车丝')>0
   and l.order_ln_status >'120203' and l.order_ln_status <'120206'
   and h.order_no || '/' || l.order_seq = ?
   ]]>
	</query>

	<query id = "JgPurchasePlan.getGrade" desc = "获取钢种">
	SELECT T.GRADECODE,T.GRADENAME FROM COM_BASE_GRADE T WHERE T.VALIDFLAG = '1'
	</query>
	<query id = "JgPurchasePlan.getSpec" desc = "获取规格">
	SELECT T.SPEC_CODE,T.SPEC_NAME FROM COM_BASE_SPEC T WHERE T.VALIDFLAG = '1'
	</query>
	<query id = "JgPurchasePlan.getModel" desc= "获取扣型">
	SELECT T.MODEL_CODE,T.MODEL_DESC FROM COM_BASE_MODEL T WHERE T.VALIDFLAG = '1'
	</query>
	<query id = "JgPurchasePlan.getDimHeig" desc = "外径壁厚">
	SELECT T.DIMATER,T.HEIGHT FROM COM_BASE_SPEC T WHERE T.VALIDFLAG = '1' AND T.SPEC_CODE = ?
	</query>


	<query id="JgPurchasePlan.AddPurchasePlan" desc="新增接箍采购计划">
    <![CDATA[
		INSERT INTO JG_PURCHASE_PLAN
		  (ID,
		   QUANTITY,
		   OUTER_DIAMETER,
		   WALL_THICKNESS,
		   SG_SIGN,
		   SG_SIGN_CODE,
		   STEEL_TYPE,
		   SPEC,
		   SPEC_NO,
		   BUCKLE_TYPE,
		   BUCKLE_TYPE_CODE,
		   SG_STD,
		   SG_STD_CODE,
		   LENGTH,
		   PLANNO,
		   STATUS,
		   CONTRACT_NO,
		   CREATOR,
		   CREATE_TIME,
		   REMARK)
		VALUES
		  ('#ID#',
		   '#QUANTITY#',
		   #OUTER_DIAMETER#,
		   #WALL_THICKNESS#,
		   '#SG_SIGN#',
		   '#SG_SIGN_CODE#',
		   '#STEEL_TYPE#',
		   '#SPEC#',
		   '#SPEC_NO#',
		   '#BUCKLE_TYPE#',
		   '#BUCKLE_TYPE_CODE#',
		   '#SG_STD#',
		   '#SG_STD_CODE#',
		   #LENGTH#,
		   '#PLANNO#',
		   #STATUS#,
		   '#CONTRACT_NO#',
		   '#CREATOR#',
		   SYSDATE,
		   '#REMARK#')
		    ]]>
		</query>
		<query id="JgPurchasePlan.UpdatePurchasePlan" desc="修改接箍采购计划">
		<![CDATA[
		 UPDATE JG_PURCHASE_PLAN SET 
		        QUANTITY = #{quantity},
		        OUTER_DIAMETER = #{outerDiameter},
		        WALL_THICKNESS = #{wallThickness},
		        SG_SIGN = #{sgSign},
		        SG_SIGN_CODE = #{sgSignCode},
		        STEEL_TYPE = #{steelType},
		        SPEC = #{spec},
		        SPEC_NO = #{specNo},
		        BUCKLE_TYPE = #{buckleType},
		        BUCKLE_TYPE_CODE = #{buckleTypeCode},
		        SG_STD = #{sgStd},
		        SG_STD_CODE = #{sgStdCode},
		        LENGTH = #{length},
		        PLANNO = #{planno},
		        STATUS = #{status},
		        CONTRACT_NO = #{contractNo},
		        MODIFIER = #{modifier},
		        MODIFY_TIME = #{modifyTime},
		        REMARK = #{remark}
		    WHERE ID = #{id}
	]]>
	</query>


</queryMap>