<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="工序合同">

	<query id="CoreProcessOrder.queryOrderInfo" desc="查询销售合同">
             <![CDATA[
                SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ ORDER_NO_SEQ,
				       T1.ORD_LN_DLY_PK,
				       T1.PLN_DIVIDE_ID,
				       T1.ORDER_SOURCE,
				       T1.ORDER_NO,
				       T1.ORDER_SEQ,
				       T1.DELIVERY_NO,
				       T1.R_NUM_ID,
				       T1.PSC,
				       T1.CRAFT_FILE_NO,
				       T1.CRAFT_FILE_MAN,
				       T1.MSC,
				       T1.INDEX_SEQ,
				       T1.PROCESS_SEQ,
				       T1.BOM,
				       T1.GRADECODE_ALL,
				       (SELECT B.GRADENAME
				          FROM COM_BASE_GRADE B
				         WHERE B.GRADECODE = T1.GRADECODE) GRADECODE,
				       DECODE(T1.G_IS_OK, '否', '1', '是', '无') G_IS_OK,
				       (SELECT B.BASENAME
				          FROM COM_BASE_INFO B
				         WHERE B.BASECODE = T1.GROUP_JGX) GROUP_JGX,
				       DECODE(T1.F_IS_OK, '否', '1', '是', '无') F_IS_OK,
				       (SELECT B.BASENAME
				          FROM COM_BASE_INFO B
				         WHERE B.BASECODE = T1.GROUP_RCL) GROUP_RCL,
				       T1.GROUP_ROLL_ALL,
				       (SELECT B.PLINE_NAME
				          FROM COM_BASE_PLINE B
				         WHERE B.PLINE_CODE = T1.GROUP_ROLL) GROUP_ROLL,
				       T1.BJ_TYPE,
				       T1.E_IN_MATERIAL_NO,
				       T1.E_IN_MATERIAL_DESC,
				       T1.DIMATER_YLG,
				       T1.HEIGHT_YLG,
				       T1.MATERIAL_NO,
				       T1.MATERIAL_DESC,
				       T1.STUFF_PROPERTY,
				       DECODE(T1.GRADECODE_IS_OK, '否', '1', '是', '无') GRADECODE_IS_OK,
				       DECODE(T1.D_IS_OK, '0', '否', '1', '是', '无') D_IS_OK,
				       DECODE(T1.E_IS_OK, '0', '否', '1', '是', '无') E_IS_OK,
				       T1.WEIGHT_PER_M,
				       T1.PLAN_WT_D,
				       T1.PLAN_NUM_D,
				       T1.FINISH_WT,
				       DECODE(T1.IF_CHANGE, '0', '否', '1', '是', '无') IF_CHANGE,
				       T1.PLAN_WT_BEGIN,
				       T1.PLAN_NUM_BEGIN,
				       DECODE(T1.PLANSTATUS,
				              '0',
				              '维护中',
				              '1',
				              '计划',
				              '2',
				              '已下发',
				              '3',
				              '生产中',
				              '4',
				              '生产完成',
				              '5',
				              '关闭',
				              '6',
				              '取消',
				              '无') PLANSTATUS,
				       DECODE(T1.IF_ALLOW_ISSUE, '0', '否', '1', '是', '无') IF_ALLOW_ISSUE,
				       TO_CHAR(T1.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
				       T1.ISSUED_MAN,
				       T1.HEIGHT_NK_MIN,
				       T1.HEIGHT_NK_MAX,
				       T1.ORDER_QTY_D,
				       T1.ORDER_UNIT,
				       T1.AIM_LEN_ROLL,
				       T1.AIM_LEN_END,
				       T1.PLAN_P_MAIN,
				       (SELECT 100 *
				               DECODE(SUM(A.ORDERWEIGHT),
				                      0,
				                      0,
				                      SUM(NVL(A.FINISHWEIGHT, 0)) / SUM(A.ORDERWEIGHT))
				          FROM PLN_ORDER_ZG A
				         WHERE A.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
				           AND A.PLN_DIVIDE_ID = T1.PLN_DIVIDE_ID) FINISH_PRECENT3,
				       (SELECT 100 *
				               DECODE(SUM(A.ORDERWEIGHT),
				                      0,
				                      0,
				                      SUM(NVL(A.FINISHWEIGHT, 0)) / SUM(A.ORDERWEIGHT))
				          FROM PLN_ORDER_DBK A
				         WHERE A.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
				           AND A.PLN_DIVIDE_ID = T1.PLN_DIVIDE_ID) FINISH_PRECENT4,
				       (SELECT 100 *
				               DECODE(SUM(A.ORDERWEIGHT),
				                      0,
				                      0,
				                      SUM(NVL(A.FINISHWEIGHT, 0)) / SUM(A.ORDERWEIGHT))
				          FROM PLN_ORDER_RCL A
				         WHERE A.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
				           AND A.PLN_DIVIDE_ID = T1.PLN_DIVIDE_ID) FINISH_PRECENT5,
				       (SELECT 100 *
				               DECODE(SUM(A.ORDERWEIGHT),
				                      0,
				                      0,
				                      SUM(NVL(A.FINISHWEIGHT, 0)) / SUM(A.ORDERWEIGHT))
				          FROM PLN_ORDER_JGX A
				         WHERE A.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
				           AND A.PLN_DIVIDE_ID = T1.PLN_DIVIDE_ID) FINISH_PRECENT6
				  FROM PLN_SALEORD_PROC T1
				 WHERE 1 = 1
                 ]]>
	</query>

	<query id="CoreProcessOrder.queryGP" desc="查询管坯工序">
             <![CDATA[
            SELECT T.GPREQ_ID,
       T.PLAN_GROUP_ID,
              T.FINISHWEIGHT,
       T.ISENDGX,
       T.NEXT_GX,
       DECODE(T.IS_EXTRA_ORD, '0', '否', '1', '是', '无') IS_EXTRA_ORD,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.BUYER_ID,
       T.BUYER_NAME,
       T.PSC,
       T.MSC,
       T.INDEX_SEQ,
       T.GPTYPE,
       T.CASTINGTYPE,
       T.PLINE_CODE_MAY,
       T.PLINE_NAME_MAY,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.DIAMETER_LZ,
       T.LENGTH_LZ,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.CRAFTCODE,
       T.CIC,
       T.STD_CODE_NK,
       T.STD_NAME_NK,
       T.IF_MONITOR_LG,
       T.PRDCR_NO,
       T.WT_CAST_ONE,
       T.CAST_WEIGHT,
       T.CAST_NUM,
       T.MATCH_WEIGHT,
       T.MATCH_NUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLANWEIGHT,
       T.PPC_LG_WEIGHT,
       T.PPC_LG_NUM,
       DECODE(T.REQ_STATUS,
              '1',
              '计划',
              '2',
              '排产',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '关闭',
              '6',
              '取消',
              '9',
              '封闭',
              '无') REQ_STATUS,
       T.MEMO,
       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
  FROM PLN_REQINF_GP T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
   AND T.ORDER_SOURCE=?
                 ]]>
	</query>

	<query id="CoreProcessOrder.queryZG" desc="查询轧管工序">
             <![CDATA[
          SELECT T.PRO_ORDER_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.INDEX_SEQ,
       T.BOM,
       T.BACKLOG_SEQ,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMWALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.AIMLENGTH,
       T.OUTWL_ID,
       T.ROLL_LENGTH,
       T.OUT_LENGTH,
       T.OUTNUM_SINGLE,
       T.DIAMETER_GP,
       T.LENGTH_GP,
       T.INWL_GP,
       T.WEIGHT_GP_ONE,
       T.GETRATE,
       T.PLINE_CODE_MAY,
       T.PLINE_NAME_MAY,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.ORDERWEIGHT,
       T.ORDERNUM,
       T.MATCH_WT,
       T.MATCH_NUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLAN_WT,
       T.REQ_PROD_WT,
       T.REQ_PROD_NUM,
       TO_CHAR(T.PROD_END_DATE, 'YYYY-MM-DD HH24:MI:SS') PROD_END_DATE,
       DECODE(T.ORDERSTATUS,
              '1',
              '计划',
              '2',
              '排产',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '关闭',
              '6',
              '取消',
              '9',
              '封闭',
              '无') ORDERSTATUS,
       DECODE(T.IS_EXTRA_ORD, '0', '否', '1', '是', '无') IS_EXTRA_ORD,
       DECODE(T.IS_PLANED, '0', '否', '1', '是', '无') IS_PLANED,
       T.PRO_PLAN_ID,
       T.FINISHWEIGHT,
       (100 * T.FINISHWEIGHT / T.ORDERWEIGHT) FINISH_PRECENT,
       DECODE(T.ISENDGX, '0', '否', '1', '是', '无') ISENDGX,
       T.NEXT_GX,
       DECODE(T.IF_MONITOR_ZG, '0', '否', '1', '是', '无') IF_MONITOR_ZG,
       T.PRDCR_NO,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       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
  FROM PLN_ORDER_ZG T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
   AND T.ORDER_SOURCE = ?
                 ]]>
	</query>


	<query id="CoreProcessOrder.queryDBK" desc="查询墩拔扩工序">
             <![CDATA[
           SELECT T.PRO_ORDER_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.INDEX_SEQ,
       T.BOM,
       T.BACKLOG_SEQ,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTWL_ID,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMWALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.AIMLENGTH,
       T.INWL_ID,
       T.OUTDIAMETER_IN,
       T.WALLTHICK_IN,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.GETRATE,
       T.BJ_TYPE,
       T.PLINE_CODE_MAY,
       T.PLINE_NAME_MAY,
       T.ORDERWEIGHT,
       T.ORDERNUM,
       T.MATCH_WT,
       T.MATCH_NUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLAN_WT,
       T.REQ_PROD_WT,
       T.REQ_PROD_NUM,
       TO_CHAR(T.PROD_END_DATE, 'YYYY-MM-DD HH24:MI:SS') PROD_END_DATE,
       DECODE(T.ORDERSTATUS,
              '1',
              '计划',
              '2',
              '排产',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '关闭',
              '6',
              '取消',
              '9',
              '封闭',
              '无') ORDERSTATUS,
       DECODE(T.IS_PLANED, '0', '否', '1', '是', '无') IS_PLANED,
       T.PRO_PLAN_ID,
       T.FINISHWEIGHT,
       (100 * T.FINISHWEIGHT / T.ORDERWEIGHT) FINISH_PRECENT,
       DECODE(T.ISENDGX, '0', '否', '1', '是', '无') ISENDGX,
       T.NEXT_GX,
       DECODE(T.IS_EXTRA_ORD, '0', '否', '1', '是', '无') IS_EXTRA_ORD,
       DECODE(T.IF_MONITOR_BJ, '0', '否', '1', '是', '无') IF_MONITOR_BJ,
       T.PRDCR_NO,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       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
  FROM PLN_ORDER_DBK T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
   AND T.ORDER_SOURCE = ?
                 ]]>
	</query>

	<query id="CoreProcessOrder.queryRCL" desc="查询热处理工序">
             <![CDATA[
            SELECT T.PRO_ORDER_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.INDEX_SEQ,
       T.BOM,
       T.BACKLOG_SEQ,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMWALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.AIMLENGTH,
       T.GETRATE,
       T.INWL_ID,
       T.OUTWL_ID,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.GROUP_RCL) GROUP_RCL,
       T.PLINE_CODE_MAY,
       T.PLINE_NAME_MAY,
       T.ORDERWEIGHT,
       T.ORDERNUM,
       T.MATCH_WT,
       T.MATCH_NUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLAN_WT,
       T.REQ_PROD_WT,
       T.REQ_PROD_NUM,
       TO_CHAR(T.PROD_END_DATE, 'YYYY-MM-DD HH24:MI:SS') PROD_END_DATE,
       DECODE(T.ORDERSTATUS,
              '1',
              '计划',
              '2',
              '排产',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '关闭',
              '6',
              '取消',
              '9',
              '封闭',
              '无') ORDERSTATUS,
       DECODE(T.IS_EXTRA_ORD, '0', '否', '1', '是', '无') IS_EXTRA_ORD,
       DECODE(T.IS_PLANED, '0', '否', '1', '是', '无') IS_PLANED,
       T.PRO_PLAN_ID,
       T.FINISHWEIGHT,
       (100 * T.FINISHWEIGHT / T.ORDERWEIGHT) FINISH_PRECENT,
       DECODE(T.ISENDGX, '0', '否', '1', '是', '无') ISENDGX,
       T.NEXT_GX,
       DECODE(T.IF_MONITOR_RCL, '0', '否', '1', '是', '无') IF_MONITOR_RCL,
       T.PRDCR_NO,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CREATE_NAME,
       T.PLINE_CODE,
       T.PLINE_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
  FROM PLN_ORDER_RCL T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
   AND T.ORDER_SOURCE = ?
                 ]]>
	</query>

	<query id="CoreProcessOrder.queryJG" desc="查询加工工序">
             <![CDATA[
            SELECT T.PRO_ORDER_NO,
       T.PLAN_GROUP_ID,
       T.ORDER_SOURCE,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T.ORDER_NO,
       T.ORDER_SEQ,
       T.DELIVERY_NO,
       T.REQ_BL_ID,
       T.INDEX_SEQ,
       T.BOM,
       T.BACKLOG_SEQ,
       T.STEELCODE,
       T.STEELNAME,
       T.OUTDIAMETER,
       T.WALLTHICK,
       T.AIMWALLTHICK,
       T.LENGTHMAX,
       T.LENGTHMIN,
       T.LENGTHDISC,
       T.AIMLENGTH,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.GETRATE,
       T.LENGTHMAX_IN,
       T.LENGTHMIN_IN,
       T.INWL_ID,
       T.OUTWL_ID,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T.GROUP_JGX) GROUP_JGX,
       T.PLINE_CODE_MAY,
       T.PLINE_NAME_MAY,
       T.ORDERWEIGHT,
       T.ORDERNUM,
       T.MATCH_WT,
       T.MATCH_NUM,
       T.IFBUYPLAN,
       T.BUYPLANID,
       T.BUYPLAN_WT,
       T.REQ_PROD_WT,
       T.REQ_PROD_NUM,
       TO_CHAR(T.PROD_END_DATE, 'YYYY-MM-DD HH24:MI:SS') PROD_END_DATE,
       DECODE(T.ORDERSTATUS,
              '1',
              '计划',
              '2',
              '排产',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '关闭',
              '6',
              '取消',
              '9',
              '封闭',
              '无') ORDERSTATUS,
       DECODE(T.IS_PLANED, '0', '否', '1', '是', '无') IS_PLANED,
       T.PRO_PLAN_ID,
       T.FINISHWEIGHT,
       (100 * T.FINISHWEIGHT / T.ORDERWEIGHT) FINISH_PRECENT,
       DECODE(T.ISENDGX, '0', '否', '1', '是', '无')  ISENDGX,
       T.NEXT_GX,
       DECODE(T.IF_MONITOR_JGX, '0', '否', '1', '是', '无') IF_MONITOR_JGX,
       T.PRDCR_NO,
       T.CRAFT_FILE_NO,
       T.CRAFT_FILE_MAN,
       T.CREATE_NAME,
       T.PLINE_CODE,
       T.PLINE_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
  FROM PLN_ORDER_JGX T
 WHERE T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
   AND T.ORDER_SOURCE = ?
                 ]]>
	</query>

	<query id="CoreProcessOrder.queryPlnProcOrd" desc="查询原记录合同">
		<![CDATA[
			SELECT T.PLAN_WT_D, T.PLAN_TOT_LEN_D
			  FROM PLN_SALEORD_PROC T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updateBeginProcOrd" desc="更新源合同记录">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.PLAN_WT_D      = '#PLAN_WT_D#',
			       T.PLAN_NUM_D     = CEIL(T.PLAN_NUM_D * #RATE#),
			       T.PLAN_TOT_LEN_D = T.PLAN_TOT_LEN_D * #RATE#,
			       T.IF_CHANGE      = '1',
			       T.ORDER_QTY_D    = T.ORDER_QTY_D * #RATE#,
			       T.PLAN_P_MAIN    = T.PLAN_P_MAIN * #RATE#
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnOrderZg" desc="更新工序合同">
		<![CDATA[
			UPDATE PLN_ORDER_ZG T
			   SET T.ORDERWEIGHT = DECODE(SIGN(T.ORDERWEIGHT * #RATE# - T.FINISHWEIGHT),
			                              -1,
			                              T.FINISHWEIGHT,
			                              T.ORDERWEIGHT * #RATE#),
			       T.ORDERNUM    = CEIL(DECODE(SIGN(T.ORDERWEIGHT * #RATE# -
			                                        T.FINISHWEIGHT),
			                                   -1,
			                                   T.ORDERNUM * T.FINISHWEIGHT /
			                                   T.ORDERWEIGHT,
			                                   T.ORDERNUM * #RATE#))
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnOrderDbk" desc="更新工序合同">
		<![CDATA[
			UPDATE PLN_ORDER_DBK T
			   SET T.ORDERWEIGHT = DECODE(SIGN(T.ORDERWEIGHT * #RATE# - T.FINISHWEIGHT),
			                              -1,
			                              T.FINISHWEIGHT,
			                              T.ORDERWEIGHT * #RATE#),
			       T.ORDERNUM    = CEIL(DECODE(SIGN(T.ORDERWEIGHT * #RATE# -
			                                        T.FINISHWEIGHT),
			                                   -1,
			                                   T.ORDERNUM * T.FINISHWEIGHT /
			                                   T.ORDERWEIGHT,
			                                   T.ORDERNUM * #RATE#))
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnOrderRcl" desc="更新工序合同">
		<![CDATA[
			UPDATE PLN_ORDER_RCL T
			   SET T.ORDERWEIGHT = DECODE(SIGN(T.ORDERWEIGHT * #RATE# - T.FINISHWEIGHT),
			                              -1,
			                              T.FINISHWEIGHT,
			                              T.ORDERWEIGHT * #RATE#),
			       T.ORDERNUM    = CEIL(DECODE(SIGN(T.ORDERWEIGHT * #RATE# -
			                                        T.FINISHWEIGHT),
			                                   -1,
			                                   T.ORDERNUM * T.FINISHWEIGHT /
			                                   T.ORDERWEIGHT,
			                                   T.ORDERNUM * #RATE#))
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnOrderJgx" desc="更新工序合同">
		<![CDATA[
			UPDATE PLN_ORDER_JGX T
			   SET T.ORDERWEIGHT = DECODE(SIGN(T.ORDERWEIGHT * #RATE# - T.FINISHWEIGHT),
			                              -1,
			                              T.FINISHWEIGHT,
			                              T.ORDERWEIGHT * #RATE#),
			       T.ORDERNUM    = CEIL(DECODE(SIGN(T.ORDERWEIGHT * #RATE# -
			                                        T.FINISHWEIGHT),
			                                   -1,
			                                   T.ORDERNUM * T.FINISHWEIGHT /
			                                   T.ORDERWEIGHT,
			                                   T.ORDERNUM * #RATE#))
			 WHERE T.PRO_ORDER_NO = ?
		]]>
	</query>

	<query id="CoreProcessOrder.selectPlnOrderZg" desc="查询轧管工序合同量">
		<![CDATA[
			SELECT T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.FINISHWEIGHT,
			       T.PRO_ORDER_NO,
			       T.PRO_PLAN_ID,
			       T.IN_WT,
			       T.IN_NUM
			  FROM PLN_ORDER_ZG T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.selectPlnOrderDbk" desc="查询镦拔扩工序合同量">
		<![CDATA[
			SELECT T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.FINISHWEIGHT,
			       T.PRO_ORDER_NO,
			       T.PRO_PLAN_ID,
			       T.IN_WEIGHT,
			       T.IN_NUM
			  FROM PLN_ORDER_DBK T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.selectPlnOrderRcl" desc="查询热处理工序合同量">
		<![CDATA[
			SELECT T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.FINISHWEIGHT,
			       T.PRO_ORDER_NO,
			       T.PRO_PLAN_ID,
			       T.IN_WEIGHT,
			       T.IN_NUM
			  FROM PLN_ORDER_RCL T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.selectPlnOrderJgx" desc="查询加工工序合同量">
		<![CDATA[
			SELECT T.ORDERWEIGHT,
			       T.ORDERNUM,
			       T.FINISHWEIGHT,
			       T.PRO_ORDER_NO,
			       T.PRO_PLAN_ID,
			       T.IN_WEIGHT,
			       T.IN_NUM
			  FROM PLN_ORDER_JGX T
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.deletePlnOrderZg" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_ZG T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.deletePlnOrderDbk" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_DBK T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.deletePlnOrderRcl" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_RCL T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.deletePlnOrderJgx" desc="删除工序合同">
		<![CDATA[
			DELETE FROM PLN_ORDER_JGX T WHERE T.ORD_LN_DLY_PK = ? AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.getProcMscPline" desc="查询制程工序">
		<![CDATA[
			SELECT M.DESGIN_KEY, P.PROCESS_CODE, P.PROCESS_DESC, P.WHOLE_BACKLOG
			  FROM PLN_SALEORD_PROC T
			  LEFT JOIN PLN_SALEORD T2
			    ON T2.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = t2.ord_ln_pk
			   AND M.CRAFT_SEQ = T.CRAFT_SEQ
			  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_PRC P
			    ON P.DESGIN_KEY = M.DESGIN_KEY
			   AND P.MSC_PLINE = T.INDEX_SEQ
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
			 ORDER BY P.BACKLOG_SEQ DESC
		]]>
	</query>

	<query id="CoreProcessOrder.getRateOfZgOrd" desc="查询轧管工序成材率">
		<![CDATA[
			SELECT T.GETRATE, T.ORDERWEIGHT, T.ORDERNUM
			  FROM PLN_ORDER_ZG T
			 WHERE T.PLAN_GROUP_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.getRateOfDbkOrd" desc="查询镦拔扩工序成材率">
		<![CDATA[
			SELECT T.GETRATE, T.ORDERWEIGHT, T.ORDERNUM
			  FROM PLN_ORDER_DBK T
			 WHERE T.PLAN_GROUP_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.getRateOfRclOrd" desc="查询热处理工序成材率">
		<![CDATA[
			SELECT T.GETRATE, T.ORDERWEIGHT, T.ORDERNUM
			  FROM PLN_ORDER_RCL T
			 WHERE T.PLAN_GROUP_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.queryOrdDesgin" desc="查询工艺">
		<![CDATA[
			SELECT T.OUTS_STL_PIPE_FL, M.DESGIN_KEY, M.CRAFT_NO, M.CRAFT_NO_V
			  FROM CRAFT_ORD_DESIGN M, PLN_SALEORD T
			 WHERE M.ORD_LN_PK = T.ORD_LN_PK
			   AND M.CRAFT_SEQ = ?
			   AND T.ORD_LN_DLY_PK = ?
		]]>
	</query>

	<query id="CoreProcessOrder.queryOrdDesginPl" desc="查询工艺制程工序">
		<![CDATA[
			SELECT T.WHOLE_BACKLOG,
       T.WHOLE_BACKLOG_DESC,
       T.PROCESS_CODE,
       T.PROCESS_CODE_C,
       T.PROCESS_DESC,
       T.PROCESS_DESC_C,
       (SELECT TO_CHAR(WM_CONCAT(B.GRADENAME))
          FROM CRAFT_ORD_DESIGN_MSC_PL_GZ B
         WHERE B.DESGIN_KEY = T.DESGIN_KEY
           AND B.MSC_PLINE = T.MSC_PLINE) GRADENAME
  FROM CRAFT_ORD_DESIGN_MSC_PL_PRC T
  LEFT JOIN CRAFT_ORD_DESIGN_MSC_PL_GZ G
    ON G.DESGIN_KEY = T.DESGIN_KEY
   AND G.MSC_PLINE = T.MSC_PLINE
 WHERE T.DESGIN_KEY = ?
   AND T.MSC_PLINE = ?
		]]>
	</query>

	<query id="CoreProcessOrder.qeuryDesginBom" desc="查询bom">
		<![CDATA[	
			SELECT T.GRADECODE,
			       T.GRADENAME,
			       T.A_IN_MATERIAL_NO,
			       T.A_OUT_MATERIAL_NO,
			       T.B_IN_MATERIAL_NO,
			       T.B_OUT_MATERIAL_NO,
			       T.C_IN_MATERIAL_NO,
			       T.C_OUT_MATERIAL_NO,
			       T.D_IN_MATERIAL_NO,
			       T.D_OUT_MATERIAL_NO,
			       T.E_IN_MATERIAL_NO,
			       T.E_IN_MATERIAL_DESC,
			       T.E_OUT_MATERIAL_NO,
			       T.E_OUT_MATERIAL_DESC,
			       T.F_IN_MATERIAL_NO,
			       T.F_OUT_MATERIAL_NO,
			       (SELECT TO_CHAR(WM_CONCAT(B.PLINE_NAME))
			          FROM SLM_BASE_MATERIAL_D_PL B
			         WHERE B.IN_MATERIAL_NO = T.D_IN_MATERIAL_NO
			           AND B.OUT_MATERIAL_NO = T.D_OUT_MATERIAL_NO
			           AND (B.DISABLE_FL != '1' OR B.DISABLE_FL IS NULL)) D_PLINE,
			       (SELECT B.DIMATER
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) DIMATER,
			       (SELECT B.HEIGHT
			          FROM COM_BASE_SPEC B
			         WHERE B.SPEC_CODE = T.SPEC_CODE_R) HEIGHT
			  FROM SLM_ORD_DESIGN_BOM T
			 WHERE T.BOM = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updateOrdCraftVersion" desc="更新排产合同工艺">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.CRAFT_SEQ = '#CRAFT_SEQ#',
			       (T.CRAFT_FILE_NO, T.CRAFT_NO_V) =
			       (SELECT M.CRAFT_NO, M.CRAFT_NO_V
			          FROM CRAFT_ORD_DESIGN M, pln_saleord t1
			         WHERE M.ORD_LN_PK = t1.ord_ln_pk
			           and t1.ord_ln_dly_pk = t.ord_ln_dly_pk
			           AND M.CRAFT_SEQ = '#CRAFT_SEQ#'),
			       T.INDEX_SEQ = '#INDEX_SEQ#',
			       T.PROCESS_SEQ = '#PROCESS_SEQ#',
			       T.GRADECODE_ALL = '#GRADECODE_ALL#',
			       T.BJ_TYPE = '#BJ_TYPE#',
			       T.BOM = '#BOM#',
			       T.GRADECODE = '#GRADECODE#',
			       T.ABC = '#ABC#',
			       T.E_IN_MATERIAL_NO = '#E_IN_MATERIAL_NO#',
			       T.E_IN_MATERIAL_DESC = '#E_IN_MATERIAL_DESC#',
			       T.DIMATER_YLG = '#DIMATER_YLG#',
			       T.HEIGHT_YLG = '#HEIGHT_YLG#',
			       T.STUFF_PROPERTY = '#STUFF_PROPERTY#',
			       T.GROUP_ROLL = '#GROUP_ROLL#',
			       T.GROUP_ROLL_NAME =
			       (SELECT B.PLINE_NAME
			          FROM COM_BASE_PLINE B
			         WHERE B.PLINE_CODE = '#GROUP_ROLL#')
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>


	<query id="CoreProcessOrder.updatePlnGxJgxM" desc="更新加工工序订单">
		<![CDATA[
			UPDATE PLN_GX_JGX_M T
			   SET T.PLANWEIGHT  = NVL(T.PLANWEIGHT, 0) + ?,
			       T.PLANNUM     = NVL(T.PLANNUM, 0) + ?,
			       T.IN_WEIGHT   = NVL(T.IN_WEIGHT, 0) + ?,
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + ?,
			       T.UPDATE_NAME = ?,
			       T.UPDATE_TIME = SYSDATE
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnGxRclM" desc="更新热处理工序订单">
		<![CDATA[
			UPDATE PLN_GX_RCL_M T
			   SET T.PLANWEIGHT  = NVL(T.PLANWEIGHT, 0) + ?,
			       T.PLANNUM     = NVL(T.PLANNUM, 0) + ?,
			       T.IN_WEIGHT   = NVL(T.IN_WEIGHT, 0) + ?,
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + ?,
			       T.UPDATE_NAME = ?,
			       T.UPDATE_TIME = SYSDATE
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnGxDbkM" desc="更新镦拔扩工序订单">
		<![CDATA[
			UPDATE PLN_GX_DBK_M T
			   SET T.PLANWEIGHT  = NVL(T.PLANWEIGHT, 0) + ?,
			       T.PLANNUM     = NVL(T.PLANNUM, 0) + ?,
			       T.IN_WEIGHT   = NVL(T.IN_WEIGHT, 0) + ?,
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + ?,
			       T.UPDATE_NAME = ?,
			       T.UPDATE_TIME = SYSDATE
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>

	<query id="CoreProcessOrder.updatePlnGxZgM" desc="更新轧管工序订单">
		<![CDATA[
			UPDATE PLN_GX_ZG_M T
			   SET T.PLAN_WT     = NVL(T.PLAN_WT, 0) + ?,
			       T.PLAN_NUM    = NVL(T.PLAN_NUM, 0) + ?,
			       T.IN_WT       = NVL(T.IN_WT, 0) + ?,
			       T.IN_NUM      = NVL(T.IN_NUM, 0) + ?,
			       T.UPDATE_NAME = ?,
			       T.UPDATE_TIME = SYSDATE
			 WHERE T.PRO_PLAN_ID = ?
		]]>
	</query>


</queryMap>