<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="生产产线基础信息管理">


	<query id="ProductionLineInfo.GetProcess" desc="获取工序描述数据源">
		<![CDATA[
			select PROCESS_CODE,PROCESS_DESC from COM_BASE_PROCESS 
			WHERE VALIDFLAG='1'
			 order by PROCESS_CODE
		]]>
	</query>

	<query id="ProductionLineInfo.GetMaxCode" desc="获取代码最大值">
		<![CDATA[
			select max(PLINE_CODE) from COM_BASE_PLINE
		]]>
	</query>

	<query id="ProductionLineInfo.GetName" desc="判断描述是否存在">
		<![CDATA[
			select PLINE_NAME from COM_BASE_PLINE where PLINE_NAME=?
		]]>
	</query>

	<query id="ProductionLineInfo.QUERY" desc="产线基础信息查询">
		<![CDATA[
SELECT T.PLINE_CODE,
       T.PLINE_NAME,
       T.DEPARTMENT_CODE,
       T.DEPARTMENT_DESC,
       T.DEPARTMENT_CODE_P,
       T.DEPARTMENT_DESC_P,
       T.PROCESS_CODE,
       T.PROCESS_DESC,
       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,
       decode(T.VALIDFLAG, '1', '有效', '无效') VALIDFLAGNAME,
       T.MEMO,
       T.LENGTH_MIN,
       T.LENGTH_MAX,
       T.LENGTH_MIN_RING,
       T.LENGTH_MAX_RING,
       T.LENGTH_MIN_TUBE,
       T.LENGTH_MAX_TUBE,
       T.LENGTH_COLDBED,
       T.GROUP_PLAN,
       T.GROUP_PAY,
       A.BASENAME GROUP_PLAN_DESC,
       B.BASENAME GROUP_PAY_DESC,
       T.TOLERANCE_ZONE,
       T.BURNOUT_RATE,
       T.IN_MATERIAL_LEN_MIN,
       T.IN_MATERIAL_LEN_MAX,
       T.CHECK_NO_SHORT,
       T.SPLINE_DESC,
       T.FACTORY_CODE,
       T2.BASENAME FACTORY_DESC,
       T.CHECK_STATION,
       T3.BASENAME CHECK_STATION_DESC,
       T.IN_REPOSITORY,
       T4.STORAGE_NAME IN_REPOSITORY_NAME,
       T.OUT_REPOSITORY,
       T5.STORAGE_NAME OUT_REPOSITORY_NAME,
       T.VELOCITY_FLOW,
       T.SUPPLY_UNIT_CODE,
       T.SUPPLY_UNIT,
       (select BASENAME from COM_BASE_INFO where BASECODE = T.ACCOUNTING_CENTER) ACCOUNTING_CENTER
  FROM COM_BASE_PLINE T
  LEFT JOIN COM_BASE_INFO A
    ON A.BASECODE = T.GROUP_PLAN
  LEFT JOIN COM_BASE_INFO B
    ON B.BASECODE = T.GROUP_PAY
  LEFT JOIN COM_BASE_INFO T2
    ON T2.BASECODE = T.FACTORY_CODE
  LEFT JOIN COM_BASE_INFO T3
    ON T3.BASECODE = T.CHECK_STATION
  LEFT JOIN YDM_BS_STORAGE T4
    ON T4.STORAGE_NO = T.IN_REPOSITORY
  LEFT JOIN YDM_BS_STORAGE T5
    ON T5.STORAGE_NO = T.OUT_REPOSITORY
 WHERE t.VALIDFLAG in ('1', ?)
   AND lower(T.PLINE_NAME) || '&' LIKE '%' || lower(?) || '%'
 ORDER BY T.PLINE_CODE
		]]>
	</query>

	<query id="ProductionLineInfo.ADD" desc="产线基础信息新增">
        <![CDATA[
            INSERT INTO COM_BASE_PLINE
						  (PLINE_CODE,
						   PLINE_NAME,
						   DEPARTMENT_CODE_P,
						   DEPARTMENT_DESC_P,
						   DEPARTMENT_CODE,
						   DEPARTMENT_DESC,
						   PROCESS_CODE,
						   PROCESS_DESC,
						   CREATE_TIME,
						   VALIDFLAG,
						   MEMO,
						   CREATE_NAME,
						   LENGTH_MIN,
						   LENGTH_MAX,
						   LENGTH_MIN_RING,
						   LENGTH_MAX_RING,
						   LENGTH_MIN_TUBE,
						   LENGTH_MAX_TUBE,
						   LENGTH_COLDBED,
						   GROUP_PLAN,
						   GROUP_PAY,
						   TOLERANCE_ZONE,
						   BURNOUT_RATE,
						   IN_MATERIAL_LEN_MIN,
						   IN_MATERIAL_LEN_MAX,
						   CHECK_NO_SHORT,
						   SPLINE_DESC,
						   FACTORY_CODE,
						   CHECK_STATION,
						   IN_REPOSITORY,
						   OUT_REPOSITORY,
						   VELOCITY_FLOW,
						   SUPPLY_UNIT_CODE,
						   SUPPLY_UNIT,
						   ACCOUNTING_CENTER)
						VALUES
						  (?, ?, ?, ?, ?, ?,?, ?, SYSDATE, '1', ?,?,
						  ?,?,?,?,?,?,?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?)
        ]]>
	</query>
	<query id="ProductionLineInfo.UPDATE" desc="产线基础信息修改">
        <![CDATA[
            UPDATE COM_BASE_PLINE T
			   SET T.PLINE_NAME      = ?,
			       T.DEPARTMENT_CODE_P = ?,
			       T.DEPARTMENT_DESC_P = ?,
			       T.DEPARTMENT_CODE = ?,
			       T.DEPARTMENT_DESC = ?,
			       T.PROCESS_CODE    = ?,
			       T.PROCESS_DESC    = ?,
			       T.MEMO            = ?,
			       T.UPDATE_NAME     = ?,
			       T.UPDATE_TIME     = SYSDATE,
			        LENGTH_MIN       = ?,
					LENGTH_MAX       = ?,
					LENGTH_MIN_RING  = ?,
					LENGTH_MAX_RING  = ?,
					LENGTH_MIN_TUBE  = ?,
					LENGTH_MAX_TUBE  = ?,
					LENGTH_COLDBED   = ?,
					GROUP_PLAN = ?,
					GROUP_PAY = ?,
					TOLERANCE_ZONE=?,
					BURNOUT_RATE = ?,
					IN_MATERIAL_LEN_MIN = ?,
					IN_MATERIAL_LEN_MAX = ?,
					CHECK_NO_SHORT = ?,
					SPLINE_DESC = ?,
					FACTORY_CODE = ?,
					CHECK_STATION = ?,
					IN_REPOSITORY = ?,
					OUT_REPOSITORY = ?,
					VELOCITY_FLOW = ?,
					SUPPLY_UNIT_CODE= ?,
					SUPPLY_UNIT = ?,
					ACCOUNTING_CENTER = ?
			 WHERE T.PLINE_CODE      = ?
        ]]>
	</query>
	<query id="ProductionLineInfo.DELETE" desc="产线基础信息删除">
        <![CDATA[
            UPDATE COM_BASE_PLINE T
			   SET T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE, T.VALIDFLAG = '0'
			 WHERE T.PLINE_CODE = ?
        ]]>
	</query>
	<query id="ProductionLineInfo.RESUME" desc="产线基础信息恢复">
        <![CDATA[
            UPDATE COM_BASE_PLINE T
               SET T.DELETE_NAME = '', T.DELETE_TIME = '', T.VALIDFLAG = '1'
             WHERE T.PLINE_CODE = ?
        ]]>
	</query>

	<query id="ProductionLineInfo.queryDepartment" desc="查询部门">
        <![CDATA[
SELECT T.DEPARTID CODE, T.DEPARTNAME NAME, T.PID P_CODE FROM CORE_APP_DEPARTMENT T
        ]]>
	</query>
	
	<query id="ProductionLineInfo.QueryAll" desc="查询所有的产线">
        <![CDATA[
SELECT PLINE_CODE, PLINE_NAME, 'False' CHK FROM COM_BASE_PLINE
WHERE #PROCESS_CODE#
        ]]>
	</query>

	<query id="ProductionLineInfo.getStorageInfo" desc="查询厂库基础信息">
		<![CDATA[
SELECT T.STORAGE_NO, T.STORAGE_NAME
  FROM YDM_BS_STORAGE T
 WHERE T.VALIDFLAG = '1'
   ORDER BY T.STORAGE_NAME
        ]]>
	</query>

	<query id="ProductionLineInfo.getAccountingBaseInfo" desc="查询核算中心基础信息">
		<![CDATA[
			SELECT T.BASECODE, T.BASENAME
			  FROM COM_BASE_INFO T
			 WHERE T.VALIDFLAG = '1'
				AND T.SORTCODE IN ('200801','200802')
			   ORDER BY T.BASECODE
        ]]>
	</query>
</queryMap>