<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="试样基础从表">
	<query id="ComBaseSplineC.Query" desc="查询试验基础从表">
		<![CDATA[
SELECT T.TIC,
       T.EIC,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       (SELECT REPLACE(WM_CONCAT(A.STD_CODE), ',', ';')
          FROM COM_BASE_SPLINE_C_R_STD A
         WHERE A.TIC = T.TIC) STD_CODE,
       (SELECT xmlagg(xmlparse(content A.STD_NAME||';' wellformed) order by A.STD_CODE).getclobval()
          FROM COM_BASE_SPLINE_C_R_STD A
         WHERE A.TIC = T.TIC) STD_NAME,
       T.MIN_D,
       T.MAX_D,
       T.MIN_H,
       T.MAX_H,
       T.MIN_D_SIGN,
       T.MAX_D_SIGN,
       T.MIN_H_SIGN,
       T.MAX_H_SIGN,
       T.FORMULA,
       T.MIN_F,
       T.MIN_F_SIGN,
       T.MAX_F,
       T.MAX_F_SIGN,
       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,
       (SELECT REPLACE(WM_CONCAT(A.PRODUCCODE), ',', ';')
          FROM COM_BASE_SPLINE_C_R_PRODUCT A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') PRODUCT_CODES,
       (SELECT WM_CONCAT(A.PRODUCNAME)
          FROM COM_BASE_SPLINE_C_R_PRODUCT A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') PRODUCT_DESCS,
       (SELECT REPLACE(WM_CONCAT(A.STEELCODE), ',', ';')
          FROM COM_BASE_SPLINE_C_R_STEEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') STEEL_CODES,
       (SELECT WM_CONCAT(A.STEELNAME)
          FROM COM_BASE_SPLINE_C_R_STEEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') STEEL_DESCS,
       (SELECT REPLACE(WM_CONCAT(A.MODEL_CODE), ',', '|')
          FROM COM_BASE_SPLINE_C_R_MODEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') MODEL_CODES,
       (SELECT WM_CONCAT(A.MODEL_DESC)
          FROM COM_BASE_SPLINE_C_R_MODEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') MODEL_DESCS
  FROM COM_BASE_SPLINE_C T
 WHERE T.EIC = '#EIC#'
   AND T.VALIDFLAG IN ('1', '#VALIDFLAG#')
		]]>
	</query>
	
	<query id="ComBaseSplineC.Query2" desc="查询试验基础从表">
		<![CDATA[
SELECT T.TIC,
       T.EIC,
       T.PHY_CODE_MIN,
       T.PHY_NAME_MIN,
       (SELECT REPLACE(WM_CONCAT(A.STD_CODE), ',', ';')
          FROM COM_BASE_SPLINE_C_R_STD A
         WHERE A.TIC = T.TIC) STD_CODE,
       (SELECT xmlagg(xmlparse(content A.STD_NAME||';' wellformed) order by A.STD_CODE).getclobval()
          FROM COM_BASE_SPLINE_C_R_STD A
         WHERE A.TIC = T.TIC) STD_NAME,
       T.MIN_D,
       T.MAX_D,
       T.MIN_H,
       T.MAX_H,
       T.MIN_D_SIGN,
       T.MAX_D_SIGN,
       T.MIN_H_SIGN,
       T.MAX_H_SIGN,
       T.FORMULA,
       T.MIN_F,
       T.MIN_F_SIGN,
       T.MAX_F,
       T.MAX_F_SIGN,
       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,
       (SELECT  REPLACE(WM_CONCAT(A.PRODUCCODE), ',', ';')
          FROM COM_BASE_SPLINE_C_R_PRODUCT A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') PRODUCT_CODES,
       (SELECT WM_CONCAT(A.PRODUCNAME)
          FROM COM_BASE_SPLINE_C_R_PRODUCT A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') PRODUCT_DESCS,
       (SELECT REPLACE(WM_CONCAT(A.STEELCODE), ',', ';')
          FROM COM_BASE_SPLINE_C_R_STEEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') STEEL_CODES,
       (SELECT WM_CONCAT(A.STEELNAME)
          FROM COM_BASE_SPLINE_C_R_STEEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') STEEL_DESCS,
       (SELECT REPLACE(WM_CONCAT(A.MODEL_CODE), ',', '|')
          FROM COM_BASE_SPLINE_C_R_MODEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') MODEL_CODES,
       (SELECT WM_CONCAT(A.MODEL_DESC)
          FROM COM_BASE_SPLINE_C_R_MODEL A
         WHERE A.TIC = T.TIC
           AND A.VALIDFLAG = '1') MODEL_DESCS
  FROM COM_BASE_SPLINE_C T
 WHERE T.EIC = '#EIC#'
   AND T.VALIDFLAG = '1'
		]]>
	</query>
	
	<query id="ComBaseSplineC.Insert" desc="新增试验基础从表">
		<![CDATA[
INSERT INTO COM_BASE_SPLINE_C
  (TIC,
   EIC,
   PHY_CODE_MIN,
   PHY_NAME_MIN,
   MIN_D,
   MAX_D,
   MIN_H,
   MAX_H,
   MIN_D_SIGN,
   MAX_D_SIGN,
   MIN_H_SIGN,
   MAX_H_SIGN,
   CREATE_NAME,
   CREATE_TIME,
   MEMO,
   FORMULA,
   MIN_F,
   MIN_F_SIGN,
   MAX_F,
   MAX_F_SIGN)
VALUES
  ('#TIC#',
   '#EIC#',
   '#PHY_CODE_MIN#',
   '#PHY_NAME_MIN#',
   '#MIN_D#',
   '#MAX_D#',
   '#MIN_H#',
   '#MAX_H#',
   '#MIN_D_SIGN#',
   '#MAX_D_SIGN#',
   '#MIN_H_SIGN#',
   '#MAX_H_SIGN#',
   '#CREATE_NAME#',
   SYSDATE,
   '#MEMO#',
   '#FORMULA#',
   '#MIN_F#',
   '#MIN_F_SIGN#',
   '#MAX_F#',
   '#MAX_F_SIGN#')
		]]>
	</query>
	
	<query id="ComBaseSplineC.Update" desc="修改试验基础从表">
		<![CDATA[
UPDATE COM_BASE_SPLINE_C T
   SET T.TIC          = '#TIC#',
       T.EIC          = '#EIC#',
       T.PHY_CODE_MIN = '#PHY_CODE_MIN#',
       T.PHY_NAME_MIN = '#PHY_NAME_MIN#',
       T.MIN_D        = '#MIN_D#',
       T.MAX_D        = '#MAX_D#',
       T.MIN_H        = '#MIN_H#',
       T.MAX_H        = '#MAX_H#',
       T.MIN_D_SIGN   = '#MIN_D_SIGN#',
       T.MAX_D_SIGN   = '#MAX_D_SIGN#',
       T.MIN_H_SIGN   = '#MIN_H_SIGN#',
       T.MAX_H_SIGN   = '#MAX_H_SIGN#',
       T.UPDATE_NAME  = '#UPDATE_NAME#',
       T.UPDATE_TIME  = SYSDATE,
       T.MEMO         = '#MEMO#',
       T.FORMULA      = '#FORMULA#',
       T.MIN_F        = '#MIN_F#',
       T.MIN_F_SIGN   = '#MIN_F_SIGN#',
       T.MAX_F        = '#MAX_F#',
       T.MAX_F_SIGN   = '#MAX_F_SIGN#'
 WHERE T.TIC = '#TIC#'
		]]>
	</query>
	
	<query id="ComBaseSplineC.Delete" desc="作废试验基础从表">
		<![CDATA[
UPDATE COM_BASE_SPLINE_C T
   SET T.VALIDFLAG   = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
 WHERE T.TIC = '#TIC#'
		]]>
	</query>
	
	<query id="ComBaseSplineC.DeleteByEic" desc="作废试验基础从表通过eic">
		<![CDATA[
UPDATE COM_BASE_SPLINE_C T
   SET T.VALIDFLAG   = '0',
       T.DELETE_NAME = '#DELETE_NAME#',
       T.DELETE_TIME = SYSDATE
 WHERE T.EIC = '#EIC#'
		]]>
	</query>
	
	<query id="ComBaseSplineC.Resume" desc="恢复试验基础从表">
		<![CDATA[
UPDATE COM_BASE_SPLINE_C T
   SET T.VALIDFLAG   = '1',
       T.DELETE_NAME = NULL,
       T.DELETE_TIME = NULL,
       T.UPDATE_NAME = '#UPDATE_NAME#',
       T.UPDATE_TIME = SYSDATE
 WHERE T.TIC = '#TIC#'
		]]>
	</query>
	
	<query id="ComBaseSplineC.GetMaxTic" desc="恢复试验基础从表">
		<![CDATA[
SELECT LPAD(NVL(MAX(T.TIC), '00000') + 1, '5', '0') MAX_VALUE FROM COM_BASE_SPLINE_C T
		]]>
	</query>
	
	<query id="ComBaseSplineC.GetComBaseStd" desc="查询标准基础信息">
		<![CDATA[
SELECT T.STD_CODE, T.STD_NAME, DECODE(T.STDSTYLE, 'G', '国标', 'X', '协议', 'N', '内控') STDSTYLE
  FROM COM_BASE_STD T
 WHERE T.STDSTYLE IN ('G', 'X', 'N')
		]]>
	</query>
	
	<query id="ComBaseSplineC.InsertSplineCRSteel" desc="新增钢级集合">
		<![CDATA[
INSERT INTO COM_BASE_SPLINE_C_R_STEEL
  (TIC, STEELCODE, STEELNAME, CREATE_NAME, CREATE_TIME, MEMO)
VALUES
  ('#TIC#',
   '#STEELCODE#',
   (SELECT A.STEELNAME FROM COM_BASE_STEEL A WHERE A.STEELCODE = '#STEELCODE#'),
   '#CREATE_NAME#',
   SYSDATE,
   '#MEMO#')
		]]>
	</query>
	
	<query id="ComBaseSplineC.DeleteSplineCRSteel" desc="删除钢级集合">
		<![CDATA[
DELETE FROM COM_BASE_SPLINE_C_R_STEEL WHERE TIC = '#TIC#'
		]]>
	</query>
	
	<query id="ComBaseSplineC.InsertSplineCRProduct" desc="新增品名集合">
		<![CDATA[
INSERT INTO COM_BASE_SPLINE_C_R_PRODUCT
  (TIC, PRODUCCODE, PRODUCNAME, CREATE_NAME, CREATE_TIME, MEMO)
VALUES
  ('#TIC#',
   '#PRODUCCODE#',
   (SELECT A.PRODUCNAME
      FROM COM_BASE_PRODUCT A
     WHERE A.PRODUCCODE = '#PRODUCCODE#'),
   '#CREATE_NAME#',
   SYSDATE,
   '#MEMO#')
		]]>
	</query>
	
	<query id="ComBaseSplineC.DeleteSplineCRProduct" desc="删除品名集合">
		<![CDATA[
DELETE FROM COM_BASE_SPLINE_C_R_PRODUCT WHERE TIC = '#TIC#'
		]]>
	</query>
	
	<query id="ComBaseSplineC.DeleteSplineCRStd" desc="删除标准集合">
		<![CDATA[
DELETE FROM COM_BASE_SPLINE_C_R_STD WHERE TIC = {0}
		]]>
	</query>
	
	<query id="ComBaseSplineC.InsertSplineCRStd" desc="新增标准集合">
        <![CDATA[
INSERT INTO COM_BASE_SPLINE_C_R_STD
  (TIC, STD_CODE, STD_NAME)
VALUES
  ('#TIC#',
   '#STD_CODE#',
   (SELECT A.STD_NAME FROM COM_BASE_STD A WHERE A.STD_CODE = '#STD_CODE#'))
        ]]>
    </query>
    
    <query id="ComBaseSplineC.DeleteSplineCRModel" desc="删除扣型集合">
		<![CDATA[
DELETE FROM COM_BASE_SPLINE_C_R_MODEL WHERE TIC = {0}
		]]>
	</query>
	
	<query id="ComBaseSplineC.InsertSplineCRModel" desc="新增扣型集合">
        <![CDATA[
INSERT INTO COM_BASE_SPLINE_C_R_MODEL
  (TIC, MODEL_CODE, MODEL_DESC)
VALUES
  ('#TIC#',
   '#MODEL_CODE#',
   (SELECT A.MODEL_DESC
      FROM COM_BASE_MODEL A
     WHERE A.MODEL_CODE = '#MODEL_CODE#'))
        ]]>
    </query>

	<query id="ComBaseSplineC.CopyStd" desc="复制标准">
		<![CDATA[
DECLARE
  CNT NUMBER(5);
BEGIN
  FOR V IN (SELECT A.TIC
              FROM COM_BASE_SPLINE_C_R_STD A
             WHERE A.STD_CODE = {0}) LOOP
    SELECT COUNT(1)
      INTO CNT
      FROM COM_BASE_SPLINE_C_R_STD A
     WHERE A.TIC = V.TIC
       AND A.STD_CODE = {1};
    IF CNT = 0 THEN
      INSERT INTO COM_BASE_SPLINE_C_R_STD
        (TIC, STD_CODE, STD_NAME)
      VALUES
        (V.TIC, {1}, {2});
    END IF;
  END LOOP;
END;
		]]>
	</query>
</queryMap>