<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "对基础信息实绩操作">
	<query id = "ComBaseBatching.query" desc = "查询配料方案">
	<![CDATA[
  SELECT T.BATCHING_CODE,
       T.BATCHING_NAME,
       T.MATERIEL,
       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,
       DECODE(T.VALIDFLAG, '1', '有效', '0', '无效') VALIDFLAG,
       T.MEMO,
       T.PLINE_CODE,
       T.PLINE_NAME,
       DECODE(T.DEF_VAL, '1', '是', '0', '/') DEF_VAL
  FROM COST_BASE_BATCHING T
 WHERE 1 = 1
	]]>
	</query>
	
	<query id = "ComBaseBatching.queryNum" desc = "新增时，查询配料方案条数">
	<![CDATA[
  	SELECT COUNT(*) 
  	FROM COST_BASE_BATCHING  
  	WHERE 1 = 1
	]]>
	</query>
	
	<query id = "ComBaseBatching.queryNum1" desc = "新增时，查询配料方案条数">
	<![CDATA[
  	SELECT COUNT(*) 
  	FROM COST_BASE_BATCHING  
  	WHERE DEF_VAL = '1'
  	AND VALIDFLAG='1'
	]]>
	</query>
	
	<query id = "ComBaseBatching.queryNum2" desc = "新增时，查询配料方案条数">
	<![CDATA[
  	SELECT COUNT(*) 
  	FROM COST_BASE_BATCHING  
  	WHERE DEF_VAL = '1'
  	AND VALIDFLAG='1'
	]]>
	</query>
	
	<query id = "ComBaseBatching.querycodeNum" desc = "新增时，查询配料方案条数">
	<![CDATA[
  	SELECT BATCHING_CODE 
  	FROM COST_BASE_BATCHING  
  	WHERE 1 = 1
	]]>
	</query>
	
	<query id = "ComBaseBatching.insert" desc = "新增配料方案">
	<![CDATA[
 INSERT INTO COST_BASE_BATCHING(
        BATCHING_CODE,
        BATCHING_NAME,
        MATERIEL,
        CREATE_NAME,
        CREATE_TIME,
        MEMO,
        PLINE_CODE,
        PLINE_NAME,
        DEF_VAL)
 VALUES( 
        '#BATCHING_CODE#',
        '#BATCHING_NAME#',
        '#MATERIEL#',
        '#CREATE_NAME#',
        SYSDATE,
        '#MEMO#',
        '#PLINE_CODE#',
        '#PLINE_NAME#',
        '#DEF_VAL#')
	]]>
	</query>
	<query id = "ComBaseBatching.update" desc = "修改配料方案">
	<![CDATA[
 UPDATE COST_BASE_BATCHING T
   SET 
   		T.BATCHING_CODE = '#BATCHING_CODE#',
        T.BATCHING_NAME = '#BATCHING_NAME#',
        T.MATERIEL = '#MATERIEL#',
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.MEMO = '#MEMO#',
        T.PLINE_CODE = '#PLINE_CODE#',
        T.PLINE_NAME = '#PLINE_NAME#',
        T.DEF_VAL = '#DEF_VAL#'
 WHERE 1=1
	]]>
	</query>
	<query id = "ComBaseBatching.delete" desc = "删除配料方案">
	<![CDATA[
 UPDATE COST_BASE_BATCHING T
   SET 		
        T.DELETE_NAME = '#DELETE_NAME#',
        T.DELETE_TIME = SYSDATE,
        T.VALIDFLAG = '0'
 WHERE
T.BATCHING_CODE = '#BATCHING_CODE#'
AND T.PLINE_CODE = '#PLINE_CODE#'
	]]>
	</query>
	
	<query id = "ComBaseBatching.resume" desc = "恢复配料方案">
	<![CDATA[
 UPDATE COST_BASE_BATCHING T
   SET 		
        T.UPDATE_NAME = '#UPDATE_NAME#',
        T.UPDATE_TIME = SYSDATE,
        T.DELETE_NAME = '',
        T.DELETE_TIME = '',
        T.VALIDFLAG = '1'
 WHERE
T.BATCHING_CODE = '#BATCHING_CODE#'
AND T.PLINE_CODE = '#PLINE_CODE#'
	]]>
	</query>
	<query id = "ComBaseBatching.queryPlineNew" desc = "查询产线">
	<![CDATA[
SELECT T.PLINE_CODE,
       T.PLINE_NAME
FROM COM_BASE_PLINE T
WHERE T.PROCESS_CODE ='A' AND T.VALIDFLAG='1'
ORDER BY T.PLINE_CODE
	]]>
	</query>
	<query id = "ComBaseBatching.queryPk" desc = "获取标准类别基础信息">
	SELECT 'P' ||
       LPAD((NVL(SUBSTR(MAX(T.BATCHING_CODE), 2, 2), 0) + 1), 2, '0') VALUE
    FROM COST_BASE_BATCHING T
	</query>
</queryMap>