<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="基础物料投入与产出">

	<query id="CorePlineSelected.getPlineByOrdLnPk" desc="查询产线">
		<![CDATA[
				SELECT 
       A.DESGIN_KEY,
       A.MSC_PLINE,
       A.BACKLOG_SEQ,
       A.PROCESS_CODE,
       (SELECT C.PROCESS_DESC
          FROM COM_BASE_PROCESS C
         WHERE C.PROCESS_CODE = A.PROCESS_CODE) PROCESS_DESC,
       A.PLINE_CODE,
       A.PLINE_NAME,
       DECODE((SELECT D.DEPARTMENT_CODE
                FROM COM_BASE_PLINE D
               WHERE D.PLINE_CODE = A.PLINE_CODE),
              '002001004',
              '外购',
              '自产') ALLOW_BUY,
       A.WELL_CODE,
       A.WELL_NAME,
       DECODE(A.WARN_FL,'1','是','否') WARN_FL,
       A.WARN_DESC,
       A.VALIDFLAG,
       DECODE(A.IDENT_FLAG,'1','是','否') IDENT_FLAG,
       DECODE(A.VALIDFLAG,'1','已选','未选') SELECTED
  FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL A
 WHERE A.DESGIN_KEY = (SELECT B.DESGIN_KEY
                         FROM SLM_ORD_DESIGN_MSC B
                        WHERE B.ORD_LN_PK = ?
                          AND B.VALIDFLAG = '1')
   AND A.PROCESS_CODE!='A'
   ORDER BY A.PROCESS_CODE ASC
		]]>
	</query>

	<query id="CorePlineSelected.getValigLine" desc="查询工序有效产线">
		<![CDATA[
			SELECT COUNT(1) COUNT
   FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
   AND T.BACKLOG_SEQ = '#BACKLOG_SEQ#'
   AND T.PROCESS_CODE = '#PROCESS_CODE#'
   AND T.PROCESS_CODE!='A'
   AND T.VALIDFLAG = '1'
		]]>
	</query>

	<query id="CorePlineSelected.operateLine" desc="操作产线">
		<![CDATA[
	UPDATE SLM_ORD_DESIGN_MSC_PL_GX_PRL
       SET VALIDFLAG = '#VALIDFLAG#'
     WHERE DESGIN_KEY = '#DESGIN_KEY#'
       AND MSC_PLINE = '#MSC_PLINE#'
       AND BACKLOG_SEQ = '#BACKLOG_SEQ#'
       AND PROCESS_CODE = '#PROCESS_CODE#'
       AND PLINE_CODE = '#PLINE_CODE#'
		]]>
	</query>

	<query id="CorePlineSelected.getLineValig" desc="查询产线状态">
		<![CDATA[
	      SELECT VALIDFLAG
  FROM SLM_ORD_DESIGN_MSC_PL_GX_PRL T
 WHERE T.DESGIN_KEY = '#DESGIN_KEY#'
   AND T.MSC_PLINE = '#MSC_PLINE#'
   AND T.PROCESS_CODE = '#PROCESS_CODE#'
   AND T.PLINE_CODE = '#PLINE_CODE#'	      
		]]>
	</query>
</queryMap>