<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="下拉框动态数据获取管理">
	 
	 

	 <query id="CoreLocationDefine.GetStorage" desc="获取仓库信息">
		<![CDATA[
	    SELECT STORAGE_NO,
        STORAGE_NAME,
        STORAGE_ATTR,
        STORAGE_TYPE_NO,
        STORAGE_TYPE_NAME,
        MANAGEMENT_NO,
        MANAGEMENT_NAME,
        DEPARTMENT_CODE,
        DEPARTMENT_DESC,
        DUMMY_FLAG
        FROM YDM_BS_STORAGE WHERE VALIDFLAG='1'
        AND DECODE(?,NULL,'1',MANAGEMENT_NO) = DECODE(?,NULL,'1',?)  
 
		]]>
	</query>
	<query id="CoreLocationDefine.GetStorage1" desc="获取仓库信息1">
		<![CDATA[
	    SELECT STORAGE_NO,
        STORAGE_NAME,
        STORAGE_ATTR,
        STORAGE_TYPE_NO,
        STORAGE_TYPE_NAME,
        MANAGEMENT_NO,
        MANAGEMENT_NAME,
        DUMMY_FLAG
        FROM YDM_BS_STORAGE WHERE VALIDFLAG='1'
        AND DECODE(?,NULL,'1',MANAGEMENT_NO) = DECODE(?,NULL,'1',?)  
        AND DEPARTMENT_DESC = ?
        ORDER BY STORAGE_NO
 
		]]>
	</query>
	<query id="CoreLocationDefine.IsExistCol" desc="获取仓库信息">
		<![CDATA[
	       SELECT  1
        FROM YDM_BS_LOCATION T
        WHERE T.STORAGE_NO=? AND T.AREA_NO=? 
        AND T.ROW_NO=?
		]]>
	</query>
	
	<query id="CoreLocationDefine.IsExistCol_Update" desc="获取仓库信息">
		<![CDATA[
	       SELECT  1
        FROM YDM_BS_LOCATION T
        WHERE T.STORAGE_NO=? AND T.AREA_NO=? 
        AND T.ROW_NO=? AND T.LOCATION_NO!=?
		]]>
	</query>

	<query id="CoreLocationDefine.Add" desc="新增">
		<![CDATA[
      INSERT INTO YDM_BS_LOCATION
     (
     STORAGE_NO,
     LOCATION_TYPE,
     AREA_NO,
     ROW_NO,
     COL_NO,
     LOCATION_LEN,
     LOCATION_WIDTH,
     LOCATION_HEIGHT,
     X_COORDINATE,
     Y_COORDINATE,
     LOCATION_STATE,
     LOCATION_ATTR_CODE,
     LOCATION_ATTR_NAME,
     DUMMY_FLAG,
     
     MANAGEMENT_NO,
     MANAGEMENT_NAME,
     DEPARTMENT_CODE,
     DEPARTMENT_DESC,
     CREATE_NAME,
     CREATE_TIME,
     MEMO,
     LOCATION_NAME,
     RACK_TYPE,
	 RACK_QUALITY,
     LOCATION_NO


     )
     VALUES
    (?,?,?,?,?,?,?,?,?,
     ?,?,?,?,?,?,?,?,?,?,SYSDATE,?,?,?,?,
     (SELECT ? ||
          LPAD(NVL(MAX(TO_NUMBER(SUBSTR(location_no,LENGTH(location_no) - 4))),0) + 1,5,'0')
     FROM ydm_bs_location
    WHERE location_no LIKE ?|| '_____'))
	 
		]]>
	</query>
	
	<query id="CoreLocationDefine.Query" desc="查询">
		<![CDATA[
       SELECT LOCATION_NO,
        LOCATION_NAME,
        STORAGE_NO,
        LOCATION_TYPE,
        AREA_NO,
        ROW_NO,
        COL_NO,
        RACK_NO,
        DECODE(LAY_MAX_NUM,'0','无限制',LAY_MAX_NUM) LAY_MAX_NUM,
        DECODE(COL_MAX_NUM,'0','无限制',COL_MAX_NUM) COL_MAX_NUM,
        LOCATION_LEN,
        LOCATION_WIDTH,
        LOCATION_HEIGHT,
        X_COORDINATE,
        Y_COORDINATE,
        DECODE(LOCATION_STATE,'1','FALSE','0','TRUE') LOCATION_STATE,
        LOCATION_ATTR_CODE,
        LOCATION_ATTR_NAME,
        DECODE(DUMMY_FLAG,'1','TRUE','0','FALSE') DUMMY_FLAG,
        MANAGEMENT_NO,
        MANAGEMENT_NAME,
        DEPARTMENT_CODE,
        DEPARTMENT_DESC,
        MEMO,
        DECODE(VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
        RACK_TYPE,
	 	RACK_QUALITY,
        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,
        TO_CHAR(DELETE_TIME,'YYYY-MM-DD HH24:MI:SS') DELETE_TIME
       FROM YDM_BS_LOCATION
       WHERE   VALIDFLAG IN('1',?)  AND  STORAGE_NO=? 
       --AND DECODE(?,NULL,'1',MANAGEMENT_NO) = DECODE(?,NULL,'1',?)  
       --AND DECODE(?,NULL,'1',LOCATION_NO) = DECODE(?,NULL,'1',?)  
       --AND DECODE(?,NULL,'1',RACK_NO) = DECODE(?,NULL,'1',?)
       ORDER BY LOCATION_NO ASC
		]]>
	</query>
	
	<query id="CoreLocationDefine.Update" desc="修改">
		<![CDATA[
	    UPDATE YDM_BS_LOCATION
        SET 
        STORAGE_NO         = ?,
        LOCATION_TYPE      = ?,
        AREA_NO            = ?,
        ROW_NO             = ?,
        COL_NO             = ?,
        LOCATION_LEN       = ?,
        LOCATION_WIDTH     = ?,
        LOCATION_HEIGHT    = ?,
        X_COORDINATE       = ?,
        Y_COORDINATE       = ?,
        LOCATION_STATE     = ?,
        LOCATION_ATTR_CODE = ?,
        LOCATION_ATTR_NAME = ?,
        DUMMY_FLAG         = ?,
        MANAGEMENT_NO      = ?,
        MANAGEMENT_NAME    = ?,
        DEPARTMENT_CODE    = ?,
        DEPARTMENT_DESC    = ?,
        UPDATE_NAME        = ?,
        UPDATE_TIME        = SYSDATE,
        MEMO               = ?,
        LOCATION_NAME      = ?,
        RACK_TYPE               = ?,
        RACK_QUALITY      = ?
        WHERE LOCATION_NO  = ? AND VALIDFLAG='1'
 
		]]>
	</query>
	 
	 <query id="CoreLocationDefine.Delete" desc="作废">
		<![CDATA[
	    DELETE FROM YDM_BS_LOCATION
       WHERE LOCATION_NO = ? AND VALIDFLAG='1'
 
		]]>
	</query>
	<!-- UPDATE YDM_BS_LOCATION
        SET  
        DELETE_NAME        = ?,
        DELETE_TIME        = SYSDATE,
        VALIDFLAG          ='0'
       WHERE LOCATION_NO = ? AND VALIDFLAG='1' -->
	 <query id="CoreLocationDefine.Resume" desc="恢复">
		<![CDATA[
	    UPDATE YDM_BS_LOCATION
        SET  
        DELETE_NAME        = '',
        UPDATE_TIME        = '',
        VALIDFLAG          ='1'
       WHERE LOCATION_NO = ? AND VALIDFLAG='0'
 
		]]>
	</query>
	
	 <query id="CoreLocationDefine.GetRack" desc="恢复">
		<![CDATA[
	    SELECT RACK_NO,
        BASE_WIDTH,
        BASE_HEIGHT,
        RACK_LEN
        FROM YDM_BS_RACK WHERE VALIDFLAG='1' AND USE_FLAG='0'

		]]>
	</query>
	
	<query id="CoreLocationDefine.SetRack" desc="设置料架">
		<![CDATA[
	      UPDATE YDM_BS_LOCATION
          SET 
           RACK_NO            = ?,
           LOCATION_LEN       = ?,
           LOCATION_WIDTH     = ?,
           LOCATION_HEIGHT    = ?     
         WHERE LOCATION_NO = ? AND VALIDFLAG='1'
    
		]]>
	</query>
	
	<query id="CoreLocationDefine.UpdateRack_Use" desc="更新料架状态">
		<![CDATA[
	     UPDATE YDM_BS_RACK
         SET     USE_FLAG   = '1'
         WHERE RACK_NO = ?
         AND VALIDFLAG='1'
		]]>
	</query>
	
	<query id="CoreLocationDefine.UpdateRack_Notuse" desc="更新料架状态">
		<![CDATA[
	     UPDATE YDM_BS_RACK
         SET     USE_FLAG   = '0'
         WHERE RACK_NO = ?
         AND VALIDFLAG='1'
		]]>
		
	</query> 	 
	<querey id  = "CoreLocationDefine.getDorJ" desc = "查询是垛位还是料架">
	SELECT T.LOCATION_TYPE
  FROM YDM_BS_LOCATION T
 WHERE T.ROW_NO = ?
   AND T.STORAGE_NO = ?
   AND T.AREA_NO = ?
   AND T.VALIDFLAG = '1'
 ORDER BY T.CREATE_TIME DESC
	</querey>
	<query id  = "CoreLocationDefine.getButessCount" desc = "查询此料位是否放置实物">
	select (select count(1)
          from YDM_ZC_BUTTRESS T
         WHERE T.LOCATION_NO = ?) +
       (select count(1) from ydm_gp_buttress where LOCATION_NO = ?)+(select count(1) from ydm_bc_buttress where LOCATION_NO = ?)
  from dual
	</query>

</queryMap>