<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="冶金规范备料规格">
	<query id="MscRBlSpec.getMscRBlSpec" desc="获取冶金规范备料规格">
		<![CDATA[ 
SELECT TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       VALIDFLAG,
       DECODE(VALIDFLAG, '1', '有效', '0', '无效', '未识别') VALIDFLAG_NAME,
       MEMO,
       MSC,
       GROUP_NUM,
       ROW_INDEX,
       SPEC_CODE,
       SPEC_NAME,
       MIN_H,
       MAX_H,
       MIN_D,
       MAX_D,
       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,
       DELETE_NAME,
       MODEL_CODE,
       MODEL_DESC
  FROM COM_MSC_R_BL_SPEC T
 WHERE T.MSC = '#MSC#'
   AND DECODE('#GROUP_NUM#', NULL, '1', T.GROUP_NUM) =
       DECODE('#GROUP_NUM#', NULL, '1', '#GROUP_NUM#')
   AND VALIDFLAG IN ('1', '#VALIDFLAG#')
		]]>
	</query>
	
	<query id="MscRBlSpec.insertMscRBlSpec" desc="新增冶金规范备料规格">
		<![CDATA[ 
INSERT INTO COM_MSC_R_BL_SPEC
  (MEMO,
   MSC,
   GROUP_NUM,
   ROW_INDEX,
   SPEC_CODE,
   SPEC_NAME,
   MIN_H,
   MAX_H,
   MIN_D,
   MAX_D,
   CREATE_NAME,
   CREATE_TIME,
   MODEL_CODE,
   MODEL_DESC)
VALUES
  ('#MEMO#',
   '#MSC#',
   '#GROUP_NUM#',
   '#ROW_INDEX#',
   '#SPEC_CODE#',
   '#SPEC_NAME#',
   '#MIN_H#',
   '#MAX_H#',
   '#MIN_D#',
   '#MAX_D#',
   '#CREATE_NAME#',
   SYSDATE,
   '#MODEL_CODE#',
   '#MODEL_DESC#')
		]]>
	</query>
	
	<query id="MscRBlSpec.updateMscRBlSpec" desc="修改冶金规范备料规格">
		<![CDATA[ 
UPDATE COM_MSC_R_BL_SPEC T
   SET MEMO        = '#MEMO#',
       SPEC_CODE   = '#SPEC_CODE#',
       SPEC_NAME   = '#SPEC_NAME#',
       MIN_H       = '#MIN_H#',
       MAX_H       = '#MAX_H#',
       MIN_D       = '#MIN_D#',
       MAX_D       = '#MAX_D#',
       UPDATE_NAME = '#UPDATE_NAME#',
       UPDATE_TIME = SYSDATE,
       MODEL_CODE = '#MODEL_CODE#',
       MODEL_DESC = '#MODEL_DESC#'
 WHERE T.MSC = '#MSC#'
   AND T.GROUP_NUM = '#GROUP_NUM#'
   AND T.ROW_INDEX = '#ROW_INDEX#'
		]]>
	</query>
	
	<query id="MscRBlSpec.getMscRBlSpecCnt" desc="获取冶金规范备料规格数目">
		<![CDATA[ 
SELECT COUNT(1) COUNT
  FROM COM_MSC_R_BL_SPEC T
 WHERE T.MSC = '#MSC#'
   AND T.GROUP_NUM = '#GROUP_NUM#'
   AND T.ROW_INDEX = '#ROW_INDEX#'
		]]>
	</query>
	
	<query id="MscRBlSpec.getMaxMscRBlSpecRowIndex" desc="获取冶金规范备料规格最大的流水号">
		<![CDATA[ 
SELECT NVL(MAX(T.ROW_INDEX), 0) MAX_VALUE
  FROM COM_MSC_R_BL_SPEC T
 WHERE T.MSC = '#MSC#'
   AND T.GROUP_NUM = '#GROUP_NUM#'
		]]>
	</query>
	
	<query id="MscRBlSpec.resume" desc="恢复冶金规范备料规格">
		<![CDATA[ 
UPDATE COM_MSC_R_BL_SPEC T
   SET T.VALIDFLAG = '1',
   T.UPDATE_NAME = '#UPDATE_NAME#',
   T.UPDATE_TIME = SYSDATE,
   T.DELETE_NAME = NULL,
   T.DELETE_TIME = NULL
 WHERE T.MSC = '#MSC#'
   AND T.GROUP_NUM = '#GROUP_NUM#'
   AND T.ROW_INDEX = '#ROW_INDEX#'
		]]>
	</query>
	
	<query id="MscRBlSpec.delete" desc="作废冶金规范备料规格">
		<![CDATA[ 
UPDATE COM_MSC_R_BL_SPEC T
   SET T.VALIDFLAG = '0',
   T.DELETE_NAME = '#DELETE_NAME#',
   T.DELETE_TIME = SYSDATE
 WHERE T.MSC = '#MSC#'
   AND T.GROUP_NUM = '#GROUP_NUM#'
   AND T.ROW_INDEX = '#ROW_INDEX#'
		]]>
	</query>
	
	<query id="MscRBlSpec.getBlSpecHead" desc="获取主表">
		<![CDATA[ 
SELECT T.MSC, T.GROUP_NUM
  FROM COM_MSC_R_JG T
 WHERE T.MSC = '#MSC#'
   AND T.STOCK_STYLE = 'B'
   AND T.VALIDFLAG = '1'
 GROUP BY T.MSC, T.GROUP_NUM
		]]>
	</query>
	
	<query id="MscRBlSpec.getGroupBl" desc="获取分组中的备料">
		<![CDATA[ 
SELECT T.CODE_JG PSC_BL
  FROM COM_MSC_R_JG T
 WHERE T.GROUP_NUM = {0}
   AND T.MSC = {1}
   AND T.STOCK_STYLE = 'B'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="MscRBlSpec.getGroupBlInfo" desc="获取分组中的备料信息">
		<![CDATA[ 
SELECT MEMO, SPEC_NAME, SPEC_CODE, MIN_H, MAX_H, MIN_D, MAX_D, MODEL_DESC, MODEL_CODE
  FROM COM_MSC_R_BL_SPEC T
 WHERE T.MSC = {0}
   AND T.GROUP_NUM = {1}
   AND T.VALIDFLAG = '1'
		]]>
	</query>
</queryMap>
