<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "对基础信息实绩操作">
	<query id = "ComBaseGradePrice.querygang" desc = "获取钢种信息">
	<![CDATA[
SELECT T.GRADECODE,T.GRADENAME 
FROM COM_BASE_GRADE T  
WHERE T.VALIDFLAG = '1'
	]]>
	</query>
	
	<query id = "ComBaseGradePrice.queryduan" desc = "获取断面信息">
	<![CDATA[
SELECT T.SPEC_CODE,T.SPEC_NAME 
FROM COM_BASE_SPEC T 
WHERE MSC_STYLE='B' AND T.VALIDFLAG = '1'
	]]>
	</query>
	<query id = "ComBaseGradePrice.query" desc = "获取物料采购价信息">
	<![CDATA[
SELECT B.GRADECODE,B.GRADENAME,B.SPEC_CODE,B.SPEC_NAME ,B.COST_PRICE,B.CREATE_NAME,B.CREATE_TIME,B.UPDATE_NAME,B.UPDATE_TIME,B.DELETE_NAME,B.DELETE_TIME,DECODE(B.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,B.MEMO,A.*,B.BAL_YEAR_MONTH
FROM 
(SELECT T.MATERIAL_NO AS WL_ID,T.MATERIAL_NAME AS WL_DESC FROM PLN_REQINF_GP T WHERE T.IFBUYPLAN ='0'
UNION ALL 
SELECT P.OUTWL_ID,P.OUTWL_DESC FROM PLN_ORDER_ZG_S P WHERE P.OUTWL_DESC IS NOT NULL) A
LEFT JOIN COST_BASE_GRADE_PRICE  B
ON B.WL_ID=A.WL_ID
	]]>
	</query>
	
	<query id = "ComBaseGradePrice.query2" desc = "获取钢种断面信息">
	<![CDATA[
select t.*,
       v.COST_PRICE,
       v.create_name,
       v.create_time,
       v.update_name,
       v.update_time,
       v.delete_name,
       v.delete_time,
       DECODE(v.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
       v.memo
  from (select distinct t.d_in_material_no WLBM,
                        t.d_in_material_desc WLMS,
                        t.YEAR_MONTH,
                        '管坯' LX
          from cost_calculation_d t
         where t.outs_billet_fl = '121801'
           and t.year_month = {0}
        union all (select distinct t.d_out_material_no WLBM,
                                  t.d_out_material_desc WLMS,
                                  t.YEAR_MONTH,
                                  '钢管' LX
                    from cost_calculation_d t
                   where t.OUTS_STL_PIPE_FL in ('121902', '121903')
                     and t.year_month = {0})) t,
       (select * from COST_BASE_GRADE_PRICE a) v
 where t.YEAR_MONTH = v.BAL_YEAR_MONTH(+)
   and t.WLBM = v.WL_ID(+)
 order by t.LX, t.WLBM

	]]>
	</query>
	<query id = "ComBaseGradePrice.isave" desc = "新增钢种采购价格信息">
	<![CDATA[
 INSERT INTO COST_BASE_GRADE_PRICE(
        GRADECODE,
        GRADENAME,
        SPEC_CODE,
        SPEC_NAME,
        COST_PRICE,
        CREATE_NAME,
        CREATE_TIME,
        MEMO,
        WL_ID,
        WL_DESC,
        BAL_YEAR_MONTH)
 VALUES( 
        '#GRADECODE#',
        '#GRADENAME#',
        '#SPEC_CODE#',
        '#SPEC_NAME#',
        '#COST_PRICE#',
        '#CREATE_NAME#',
        SYSDATE,
        '#MEMO#',
        '#WL_ID#',
        '#WL_DESC#',
        '#BAL_YEAR_MONTH#')
	]]>
	</query>
	<query id = "ComBaseGradePrice.usave" desc = "修改保存钢种采购信息">
	<![CDATA[
 UPDATE COST_BASE_GRADE_PRICE T
   SET 
        T.GRADECODE = '#GRADECODE#',
        T.GRADENAME = '#GRADENAME#',
        T.SPEC_CODE = '#SPEC_CODE#',
        T.SPEC_NAME = '#SPEC_NAME#',
        T.COST_PRICE = '#COST_PRICE#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.DELETE_NAME = '#DELETE_NAME#',
        T.DELETE_TIME = SYSDATE,
        T.MEMO = '#MEMO#', 
        T.WL_ID = '#WL_ID#',
        T.WL_DESC = '#WL_DESC#',
        T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
 WHERE
T.WL_ID = '#WL_ID#'
AND T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
	]]>
	</query>
	<query id = "ComBaseGradePrice.delete" desc = "作废保存钢种采购信息">
	<![CDATA[
  UPDATE COST_BASE_GRADE_PRICE T
   SET 
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.DELETE_NAME = '#DELETE_NAME#',
        T.DELETE_TIME = SYSDATE,
        T.VALIDFLAG = '0'
 WHERE
T.WL_ID = '#WL_ID#'
AND T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
	]]>
	</query>
	<query id = "ComBaseGradePrice.resume" desc = "作废保存钢种采购信息">
	<![CDATA[
  UPDATE COST_BASE_GRADE_PRICE T
   SET 
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.DELETE_NAME = '',
        T.DELETE_TIME = '',
        T.VALIDFLAG = '1'
 WHERE
T.WL_ID = '#WL_ID#'
AND T.BAL_YEAR_MONTH = '#BAL_YEAR_MONTH#'
	]]>
	</query>
	<query id = "ComBaseGradePrice.querynum" desc = "获取断面信息">
	<![CDATA[
SELECT COUNT(*) 
FROM COST_BASE_GRADE_PRICE T 
WHERE 1=1
	]]>
	</query>
</queryMap>