<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="合同综合信息">
	<query id="CoreOrdLinePrdcrLst.getOrdPrdcrNoMscPline" desc="查询排产合同监制编号和制程">
        <![CDATA[
        	SELECT T.PRDCR_NO, T2.INDEX_SEQ
			  FROM PLN_SALEORD T, PLN_SALEORD_PROC T2
			 WHERE T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			   AND T2.ORD_LN_DLY_PK = ?
			   AND T2.PLN_DIVIDE_ID = ?
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.updateOrdPrdcrPro" desc="更新监制工序">
        <![CDATA[
        	UPDATE PLN_SALEORD_PROC T
			   SET T.PRDCRPRO = ?
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
        ]]>
    </query>

    <query id="CoreOrdLinePrdcrLst.getOrdPrdcrproGt" desc="查询管体监制工序">
        <![CDATA[
        	 SELECT TO_CHAR(WM_CONCAT(X.PROCESS_DESC)) PRDCRPRO, MAX(B.BASENAME) PRDCR_DESC
	           FROM (SELECT B.PROCESS_DESC, B.PRDCR_NO, P.MSC_PLINE
	                   FROM SLM_ORDER_LINE_PRDCR_LST B, SLM_ORDER_LINE_PRDCR P
	                  WHERE P.PRDCR_NO = B.PRDCR_NO
	                    AND P.PRDCR_INDEX = B.PRDCR_INDEX
	                    AND P.CODE_JG IS NULL
	                    AND P.CODE_BL IS NULL
	                    AND B.PRDCR_PRC_FL = '1'
	                     AND P.PRDCR_NO = ?
	                    AND P.MSC_PLINE = ?
	                  GROUP BY B.PROCESS_DESC,
	                           B.PROCESS_CODE,
	                           B.PRDCR_NO,
	                           P.MSC_PLINE
	                 HAVING COUNT(*) >= 1
	                  ORDER BY B.PROCESS_CODE) X
	           LEFT JOIN SLM_ORDER_LINE_PRDCR P
			     ON P.PRDCR_NO = X.PRDCR_NO
			    AND P.MSC_PLINE = X.MSC_PLINE
			    AND P.CODE_JG IS NULL
			    AND P.CODE_BL IS NULL
			   LEFT JOIN COM_BASE_INFO B
			     ON B.BASECODE = P.PRDCR_DESC
	          WHERE X.PRDCR_NO = ?
	            AND X.MSC_PLINE = ?
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.getOrdPrdcrproJg" desc="查询接箍监制工序">
        <![CDATA[
        	 SELECT TO_CHAR(WM_CONCAT(X.PROCESS_DESC)) PRDCRPRO, MAX(B.BASENAME) PRDCR_DESC
	           FROM (SELECT B.PROCESS_DESC, B.PRDCR_NO, P.MSC_PLINE
	                   FROM SLM_ORDER_LINE_PRDCR_LST B, SLM_ORDER_LINE_PRDCR P
	                  WHERE P.PRDCR_NO = B.PRDCR_NO
	                    AND P.PRDCR_INDEX = B.PRDCR_INDEX
	                    AND P.CODE_JG IS NOT NULL
	                    AND P.CODE_BL IS NULL
	                    AND B.PRDCR_PRC_FL = '1'
	                     AND P.PRDCR_NO = ?
	                    AND P.MSC_PLINE = ?
	                  GROUP BY B.PROCESS_DESC,
	                           B.PROCESS_CODE,
	                           B.PRDCR_NO,
	                           P.MSC_PLINE
	                 HAVING COUNT(*) >= 1
	                  ORDER BY B.PROCESS_CODE) X
	           LEFT JOIN SLM_ORDER_LINE_PRDCR P
			     ON P.PRDCR_NO = X.PRDCR_NO
			    AND P.MSC_PLINE = X.MSC_PLINE
			    AND P.CODE_JG IS NOT NULL
			    AND P.CODE_BL IS NULL
			   LEFT JOIN COM_BASE_INFO B
			     ON B.BASECODE = P.PRDCR_DESC
	          WHERE X.PRDCR_NO = ?
	            AND X.MSC_PLINE = ?
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.getOrdPrdcrproBl" desc="查询备料监制工序">
        <![CDATA[
        	 SELECT TO_CHAR(WM_CONCAT(X.PROCESS_DESC)) PRDCRPRO, MAX(B.BASENAME) PRDCR_DESC
	           FROM (SELECT B.PROCESS_DESC, B.PRDCR_NO, P.MSC_PLINE
	                   FROM SLM_ORDER_LINE_PRDCR_LST B, SLM_ORDER_LINE_PRDCR P
	                  WHERE P.PRDCR_NO = B.PRDCR_NO
	                    AND P.PRDCR_INDEX = B.PRDCR_INDEX
	                    AND P.CODE_JG IS NOT NULL
	                    AND P.CODE_BL IS NOT NULL
	                    AND B.PRDCR_PRC_FL = '1'
	                    AND P.PRDCR_NO = ?
	                    AND P.MSC_PLINE = ?
	                  GROUP BY B.PROCESS_DESC,
	                           B.PROCESS_CODE,
	                           B.PRDCR_NO,
	                           P.MSC_PLINE
	                 HAVING COUNT(*) >= 1
	                  ORDER BY B.PROCESS_CODE) X
	           LEFT JOIN SLM_ORDER_LINE_PRDCR P
			     ON P.PRDCR_NO = X.PRDCR_NO
			    AND P.MSC_PLINE = X.MSC_PLINE
			    AND P.CODE_JG IS NOT NULL
			    AND P.CODE_BL IS NOT NULL
			   LEFT JOIN COM_BASE_INFO B
			     ON B.BASECODE = P.PRDCR_DESC
	          WHERE X.PRDCR_NO = ?
	            AND X.MSC_PLINE = ?
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.CoreOrderProducerPdeptBase" desc="合同产品生产监制要求监制从表信息单位绑定">
        <![CDATA[
        	SELECT T.PDEPT_NO, T.PDEPT_NAME FROM SLM_BASE_PRDCR_DEPT T  
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.CoreOrderProducerPrcBase" desc="合同产品生产监制要求监制从表信息监制类型绑定">
        <![CDATA[
        	SELECT BASECODE,BASENAME FROM COM_BASE_INFO WHERE BASECODE LIKE '1220%' AND BASECODE <> '1220'
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.SelectOrderLinePrdcr" desc="合同产品生产监制界面监制主表信息">
        <![CDATA[
		     SELECT T.PRDCR_NO,
			       (SELECT B.BASENAME
			          FROM COM_BASE_INFO B
			         WHERE B.BASECODE = T.PRDCR_DESC) PRDCR_DESC,
			       T.PSC,
			       DECODE(T.CODE_BL,
			              NULL,
			              DECODE(T.CODE_JG, NULL, '管体', '接箍'),
			              '备料') PRDCR_TYPE,
			       T.PSC_DESC,
			       T.STD_CODE,
			       T.STD_NAME,
			       T.MPS,
			       T.PRDCR_FILE_PATH,
			       DECODE(T.PRDCR_STS,
			              'L',
			              '监制待维护',
			              'M',
			              '监制已维护',
			              'W',
			              '监制待确认',
			              'S',
			              '监制已生效',
			              'F',
			              '监制退回') PRDCR_STS,
			       T.FAIL_MAN,
			       T.FINAL_USER,
			       T.FAIL_RSN,
			       T.MSC_PLINE,
			       T.CODE_JG,
			       T.CODE_BL,
			       T.MSC_PLINE_DESC,
			       T.PRDCR_INDEX
			  FROM SLM_ORDER_LINE_PRDCR T, PLN_SALEORD T1, PLN_SALEORD_PROC T2
			 WHERE T1.PRDCR_NO = T.PRDCR_NO
			   AND T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
			   AND ((T.CODE_JG IS NOT NULL OR T.CODE_BL IS NOT NULL) OR
                     T2.INDEX_SEQ = T.MSC_PLINE)
			   AND T.VALIDFLAG = '1'
			   AND T2.ORD_LN_DLY_PK = ?
			   AND T2.PLN_DIVIDE_ID = ?
			   ORDER BY T.CODE_JG DESC, T.CODE_BL DESC
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.SelectOrderLinePrdcrLst" desc="合同产品生产监制界面监制从表信息">
        <![CDATA[
		     SELECT ROWNUM, M.*
			  FROM (SELECT DECODE(T.PRDCR_PRC_FL, '1', 'TRUE', 'FALSE') XZ,
			               T.PRDCR_NO,
			               T.PROCESS_CODE,
			               T.PROCESS_DESC,
			               T.PROCESS_DESC_C,
			               T.STATION_DESC,
			               T.STATION_CODE,
			               T.PRDCR_PRC_FL,
			               T.PRDCR_PRC_DESC,
			               T.PRDCR_ADVC_DAY,
			               T.PDEPT_NO,
			               T.PDEPT_NAME,
			               T.PDEPT_NO2,
			               T.PDEPT_NAME2,
			               T.PDEPT_NO3,
			               T.PDEPT_NAME3,
			               T.PHONE,
			               T.PHONE2,
			               T.PHONE3,
			               T.PRDCR_MAN,
			               T.PRDCR_MAN_PHONE,
			               T.PRDCR_MAN2,
			               T.PRDCR_MAN_PHONE2,
			               T.PRDCR_MAN3,
			               T.PRDCR_MAN_PHONE3,
			               T.MEMO,
			               T.PRDCR_INDEX
			          FROM SLM_ORDER_LINE_PRDCR_LST T,
			               SLM_ORDER_LINE_PRDCR     T3,
			               PLN_SALEORD              T1,
			               PLN_SALEORD_PROC         T2
			         WHERE T1.PRDCR_NO = T3.PRDCR_NO
			           AND T1.ORD_LN_DLY_PK = T2.ORD_LN_DLY_PK
			           AND ((T3.CODE_JG IS NOT NULL OR T3.CODE_BL IS NOT NULL) OR
                           T2.INDEX_SEQ = T3.MSC_PLINE)
			           AND T3.PRDCR_INDEX = T.PRDCR_INDEX
			           AND T3.PRDCR_NO = T.PRDCR_NO
			           AND T3.VALIDFLAG = '1'
			           AND T.PRDCR_PRC_FL = '1'
			           AND T2.ORD_LN_DLY_PK = ?
			           AND T2.PLN_DIVIDE_ID = ?
			         ORDER BY T.STATION_CODE ASC) M
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.getGxJgMPrdcr" desc="合同产品生产监制界面监制从表信息">
        <![CDATA[
        	SELECT T.PRDCR_NO,
			       (SELECT B.BASENAME
			          FROM COM_BASE_INFO B
			         WHERE B.BASECODE = T.PRDCR_DESC) PRDCR_DESC,
			       T.PSC,
			       DECODE(T.CODE_BL,
			              NULL,
			              DECODE(T.CODE_JG, NULL, '管体', '接箍'),
			              '备料') PRDCR_TYPE,
			       T.PSC_DESC,
			       T.STD_CODE,
			       T.STD_NAME,
			       T.MPS,
			       T.PRDCR_FILE_PATH,
			       DECODE(T.PRDCR_STS,
			              'L',
			              '监制待维护',
			              'M',
			              '监制已维护',
			              'W',
			              '监制待确认',
			              'S',
			              '监制已生效',
			              'F',
			              '监制退回') PRDCR_STS,
			       T.FAIL_MAN,
			       T.FINAL_USER,
			       T.FAIL_RSN,
			       T.MSC_PLINE,
			       T.CODE_JG,
			       T.CODE_BL,
			       T.MSC_PLINE_DESC,
			       T.PRDCR_INDEX
			  FROM SLM_ORDER_LINE_PRDCR T
			 WHERE T.PRDCR_NO = ?
			   AND T.CODE_JG = ?
			   AND T.VALIDFLAG = '1'
        ]]>
    </query>
    
    <query id="CoreOrdLinePrdcrLst.getGxJgMPrdcrLst" desc="合同产品生产监制界面监制从表信息">
        <![CDATA[
		     SELECT ROWNUM, M.*
			  FROM (SELECT DECODE(T.PRDCR_PRC_FL, '1', 'TRUE', 'FALSE') XZ,
			               T.PRDCR_NO,
			               T.PROCESS_CODE,
			               T.PROCESS_DESC,
			               T.PROCESS_DESC_C,
			               T.STATION_DESC,
			               T.STATION_CODE,
			               T.PRDCR_PRC_FL,
			               T.PRDCR_PRC_DESC,
			               T.PRDCR_ADVC_DAY,
			               T.PDEPT_NO,
			               T.PDEPT_NAME,
			               T.PDEPT_NO2,
			               T.PDEPT_NAME2,
			               T.PDEPT_NO3,
			               T.PDEPT_NAME3,
			               T.PHONE,
			               T.PHONE2,
			               T.PHONE3,
			               T.PRDCR_MAN,
			               T.PRDCR_MAN_PHONE,
			               T.PRDCR_MAN2,
			               T.PRDCR_MAN_PHONE2,
			               T.PRDCR_MAN3,
			               T.PRDCR_MAN_PHONE3,
			               T.MEMO,
			               T.PRDCR_INDEX
			          FROM SLM_ORDER_LINE_PRDCR T1, SLM_ORDER_LINE_PRDCR_LST T
			         WHERE T.PRDCR_NO = T1.PRDCR_NO
			           AND T.PRDCR_INDEX = T1.PRDCR_INDEX
			           AND T1.VALIDFLAG = '1'
			           AND T.PRDCR_PRC_FL = '1'
			           AND T1.PRDCR_NO = ?
			           AND T1.CODE_JG = ?
			         ORDER BY T.STATION_CODE ASC) M
        ]]>
    </query>
</queryMap>