<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="试验标准">
	<query id="ComBaseSpline.Query" desc="查询试验标准">
		<![CDATA[
SELECT T.EIC,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       T.PHY_DIR,
       T.LENGTH,
       T.WIDTH,
       T.SIZE_DESC,
       T.SAMPLE_STYLE,
       T.FILE_POSITION,
       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.SPLINE_NO,
       T.SPLINE_STD,
       (SELECT REPLACE(WM_CONCAT(A.STD_CODE), ',', ';')
          FROM COM_BASE_SPLINE_R_STD A
         WHERE A.EIC = T.EIC
           AND A.VALIDFLAG = '1') STD_CODE_S,
       (SELECT xmlagg(xmlparse(content A.STD_NAME||';' wellformed) order by A.STD_CODE).getclobval()
          FROM COM_BASE_SPLINE_R_STD A
         WHERE A.EIC = T.EIC
           AND A.VALIDFLAG = '1') STD_NAME_S,
       T.ITEM_CODE_S,
       T.ITEM_NAME_S,
       T.ITEM_CODE_F,
       T.ITEM_NAME_F,
       T.SEAM_AREA
  FROM COM_BASE_SPLINE T
 WHERE T.VALIDFLAG IN ('1', '#VALIDFLAG#')
   AND NVL2('#PHY_NAME_MIN#', T.PHY_NAME_MIN, '1') LIKE
       NVL2('#PHY_NAME_MIN#', '%#PHY_NAME_MIN#%', '1')
   AND NVL2('#SAMPLE_STYLE#', T.SAMPLE_STYLE, '1') =
       NVL('#SAMPLE_STYLE#', '1')
    AND SEAM_AREA = DECODE('#SEAM_AREA#', '',SEAM_AREA,'#SEAM_AREA#')
		]]>
	</query>
	
	<query id="ComBaseSpline.Query2" desc="查询试验标准">
		<![CDATA[
SELECT T.EIC,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       T.PHY_DIR,
       T.LENGTH,
       T.WIDTH,
       T.SIZE_DESC,
       T.SAMPLE_STYLE,
       T.FILE_POSITION,
       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.SPLINE_NO,
       T.SPLINE_STD,
       (SELECT LISTAGG(E.STD_CODE, ';') WITHIN GROUP(ORDER BY E.STD_CODE)
          FROM COM_BASE_SPLINE_R_STD E
         WHERE E.EIC = T.EIC) STD_CODE_S,
       (SELECT xmlagg(xmlparse(content E.STD_NAME||';' wellformed) order by E.STD_CODE).getclobval()
          FROM COM_BASE_SPLINE_R_STD E
         WHERE E.EIC = T.EIC) STD_NAME_S,
       T.ITEM_CODE_S,
       T.ITEM_NAME_S,
       T.ITEM_CODE_F,
       T.ITEM_NAME_F,
       T.SEAM_AREA
  FROM COM_BASE_SPLINE T
 WHERE T.VALIDFLAG = '1'
   AND T.PHY_CODE_MIN = {0}
   AND DECODE({1}, NULL, '1', T.ITEM_CODE_F) = NVL({1}, '1')
   AND DECODE({2}, NULL, '1', T.ITEM_CODE_S) = NVL({2}, '1')
		]]>
	</query>
	
	<query id="ComBaseSpline.QueryNk" desc="查询试验标准(内控)">
		<![CDATA[
SELECT T.EIC,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       T.PHY_DIR,
       T.LENGTH,
       T.WIDTH,
       T.SIZE_DESC,
       T.SAMPLE_STYLE,
       T.FILE_POSITION,
       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.SPLINE_NO
  FROM COM_BASE_SPLINE T
 WHERE T.VALIDFLAG = '1'
   AND T.PHY_CODE_MIN = '#PHY_CODE_MIN#'
   AND DECODE('#PHY_DIR#', NULL, '1', T.PHY_DIR) = NVL('#PHY_DIR#', '1')
   AND EXISTS
 (SELECT 1
          FROM COM_BASE_SPLINE_R_STD A
         WHERE A.EIC = T.EIC
           AND A.VALIDFLAG = '1'
           AND A.STD_CODE = '#STD_CODE_TEST#')
   AND ('#STD_CODE#' IS NULL OR EXISTS (SELECT 1
                  FROM COM_BASE_SPLINE_C B
                 WHERE B.EIC = T.EIC
                   AND B.VALIDFLAG = '1'
                   AND B.STD_CODE = '#STD_CODE#') OR NOT EXISTS
        (SELECT 1
           FROM COM_BASE_SPLINE_C B
          WHERE B.EIC = T.EIC
            AND B.VALIDFLAG = '1'))
		]]>
	</query>
	
	<query id="ComBaseSpline.Insert" desc="新增试验标准">
		<![CDATA[
INSERT INTO COM_BASE_SPLINE
  (EIC,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   PHY_DIR,
   LENGTH,
   WIDTH,
   SIZE_DESC,
   SAMPLE_STYLE,
   FILE_POSITION,
   CREATE_NAME,
   CREATE_TIME,
   MEMO,
   SPLINE_NO,
   SPLINE_STD,
   ITEM_CODE_S,
   ITEM_NAME_S,
   ITEM_CODE_F,
   ITEM_NAME_F,
   SEAM_AREA)
VALUES
  ( '#EIC#',
   '#PHY_CODE_MIN#',
   '#PHY_NAME_MIN#',
   '#PHY_DIR#',
   '#LENGTH#',
   '#WIDTH#',
   '#SIZE_DESC#',
   '#SAMPLE_STYLE#',
   '#FILE_POSITION#',
   '#CREATE_NAME#',
   SYSDATE,
   '#MEMO#',
   '#SPLINE_NO#',
   '#SPLINE_STD#',
   '#ITEM_CODE_S#',
   '#ITEM_NAME_S#',
   '#ITEM_CODE_F#',
   '#ITEM_NAME_F#',
   '#SEAM_AREA#')
		]]>
	</query>
	
	<query id="ComBaseSpline.Update" desc="修改试验">
		<![CDATA[
UPDATE COM_BASE_SPLINE T
   SET T.EIC           = '#EIC#',
       T.PHY_CODE_MIN  = '#PHY_CODE_MIN#',
       T.PHY_NAME_MIN  = '#PHY_NAME_MIN#',
       T.PHY_DIR       = '#PHY_DIR#',
       T.LENGTH        = '#LENGTH#',
       T.WIDTH         = '#WIDTH#',
       T.SIZE_DESC     = '#SIZE_DESC#',
       T.SAMPLE_STYLE  = '#SAMPLE_STYLE#',
       T.FILE_POSITION = '#FILE_POSITION#',
       T.UPDATE_NAME   = '#UPDATE_NAME#',
       T.UPDATE_TIME   = SYSDATE,
       T.MEMO          = '#MEMO#',
       T.SPLINE_NO     = '#SPLINE_NO#',
       T.SPLINE_STD    = '#SPLINE_STD#',
       T.ITEM_CODE_S = '#ITEM_CODE_S#',
       T.ITEM_NAME_S = '#ITEM_NAME_S#',
       T.ITEM_CODE_F = '#ITEM_CODE_F#',
       T.ITEM_NAME_F = '#ITEM_NAME_F#',
       T.SEAM_AREA = '#SEAM_AREA#'
 WHERE T.EIC = '#EIC#'
		]]>
	</query>
	
	<query id="ComBaseSpline.UpdateSplineC" desc="修改试验">
		<![CDATA[

UPDATE COM_BASE_SPLINE_C T
   SET T.PHY_CODE_MIN = '#PHY_CODE_MIN#', T.PHY_NAME_MIN = '#PHY_NAME_MIN#'
 WHERE T.EIC = '#EIC#'
		]]>
	</query>
	
	<query id="ComBaseSpline.Delete" desc="更新有效标志">
		<![CDATA[
UPDATE COM_BASE_SPLINE T SET T.VALIDFLAG = '0', T.DELETE_TIME = SYSDATE,
 T.DELETE_NAME = '#DELETE_NAME#' WHERE T.EIC = '#EIC#'
		]]>
	</query>
	
	<query id="ComBaseSpline.Resume" desc="更新有效标志">
		<![CDATA[
UPDATE COM_BASE_SPLINE T SET T.VALIDFLAG = '1', T.UPDATE_TIME = SYSDATE,
 T.UPDATE_NAME = '#UPDATE_NAME#' WHERE T.EIC = '#EIC#'
		]]>
	</query>
	
	<query id="ComBaseSpline.GetMaxEic" desc="获取最大的索引号">
		<![CDATA[
SELECT LPAD(NVL(MAX(T.EIC), '00000') + 1, '5', '0') MAX_VALUE FROM COM_BASE_SPLINE T
		]]>
	</query>
	
	<query id="ComBaseSpline.GetComBasePhyC" desc="获取取样码基础数据">
		<![CDATA[
SELECT T.PHY_CODE, T.PHY_TYPE FROM COM_BASE_PHY_C T WHERE T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="ComBaseSpline.UpdateFilePosition" desc="更新文件路径">
		<![CDATA[
UPDATE COM_BASE_SPLINE T SET T.FILE_POSITION = '#FILE_POSITION#' WHERE T.EIC = '#EIC#'
		]]>
	</query>
	
	<query id="ComBaseSpline.GetComBaseStdS" desc="获取试验标准">
		<![CDATA[
SELECT T.STD_CODE, T.STD_NAME
  FROM COM_BASE_STD T
  LEFT JOIN COM_BASE_SPLINE_R_STD A
    ON A.STD_CODE = T.STD_CODE
   AND A.EIC = '#EIC#'
 WHERE T.STDSTYLE = 'S'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="ComBaseSpline.InsertSplineRStd" desc="新增试验标准">
		<![CDATA[
INSERT INTO COM_BASE_SPLINE_R_STD
  (EIC, STD_CODE, STD_NAME, CREATE_NAME, CREATE_TIME, MEMO)
VALUES
  ('#EIC#', '#STD_CODE#', '#STD_NAME#', '#CREATE_NAME#', SYSDATE, '#MEMO#')
		]]>
	</query>
	
	<query id="ComBaseSpline.DeleteSplineRStd" desc="删除试验标准">
		<![CDATA[
DELETE FROM COM_BASE_SPLINE_R_STD T WHERE T.EIC = '#EIC#'
		]]>
	</query>
	<query id="ComBaseSpline.IsRepeat" desc="是否重复">
		<![CDATA[
SELECT COUNT(1)
  FROM COM_BASE_SPLINE T
 WHERE T.PHY_CODE_MIN = {0}
   AND NVL(T.ITEM_CODE_F, '1') = NVL({1}, '1')
   AND NVL(T.ITEM_CODE_S, '1') = NVL({2}, '1')
   AND T.SIZE_DESC = {3}
   AND T.EIC <> {4}
		]]>
	</query>
	<query id="ComBaseSpline.QueryComMscBlByPk" desc="通过主键查询备料">
		<![CDATA[
SELECT * FROM COM_MSC_BL T WHERE T.PSC_BL = {0}
		]]>
	</query>
</queryMap>