<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="计算镦拔扩投入产出">
	<query id="CoreCalculateDbk.getOrdDbkInfo" desc="查询">
		<![CDATA[
			SELECT (T.ORDER_NO || '/' || T.ORDER_SEQ) ORDER_NO_SEQ,
       T.DELIVERY_NO,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       T1.OUTDIAMETER,
       T1.WALLTHICK,
       E.DIMATER,
       E.HEIGHT,
       Z.ROLL_LENGTH,
       Z.AIMLENGTH AIM_LEN_ROLL,
       Z.LEN_ROLL_MAX LEN_ZG_CAL_MAX,
       Z.LEN_ROLL_MIN LEN_ZG_CAL_MIN,
       T.AIM_LEN_END,
       NVL(C.INSPECTION_VALUE, 0) INSPECTION_VALUE,
       NVL(D.CHECK_J_VAL, 0) CHECK_J_VAL,
       NVL(C.ENDLEN_SPECSTD, 0) ENDLEN_SPECSTD,
       (T.AIM_LEN_END +
       ((-NVL(D.CHECK_J_VAL, 0) + NVL(C.ENDLEN_SPECSTD, 0)) / 1000)) AIM_LEN_DBK,
       (T1.LENGTHMIN +
       ((-NVL(D.CHECK_J_VAL, 0)) / 1000)) LEN_DBK_CAL_MIN,
       (T1.LENGTHMAX +
       ((-NVL(D.CHECK_J_VAL, 0)) / 1000)) LEN_DBK_CAL_MAX,
       T1.LEN_UNIT,
       T1.LENGTHMIN,
       T1.LENGTHMAX,
       T1.LENGTHDISC,
       T.PLAN_WT_D,
       T.PLAN_NUM_D,
       T.BJ_TYPE,
       DECODE(T.E_IS_OK, '1', '是', '0', '否', '/') E_IS_OK,
       B.E_IN_MATERIAL_NO,
       B.E_IN_MATERIAL_DESC,
       B.E_OUT_MATERIAL_NO,
       B.E_OUT_MATERIAL_DESC,
       B.WHOLE_BACKLOG_DESC,
       DECODE(T.PLANSTATUS,
              '0',
              '待接收',
              '1',
              '已接收',
              '2',
              '已下发',
              '3',
              '生产中',
              '4',
              '生产完成',
              '5',
              '缴库完成') PLANSTATUS,
       T.ORD_LN_DLY_PK,
       T.PLN_DIVIDE_ID,
       T1.HEIGHT_ORD_MIN,
       T1.HEIGHT_ORD_MAX,
       T.LEN_CUTHEAD_DBK,
       T.LEN_CUTEND_DBK,
       T.LEN_LONGER_DBK,
       T.RATIO_DBK,
       NVL(T.AIM_OUTDIAMETER,0) AIM_OUTDIAMETER,
       NVL(T.AIM_WALLTHICK,0) AIM_WALLTHICK,
       NVL(T.LEN_SCOPE,20) LEN_SCOPE
  FROM PLN_SALEORD_PROC T
  LEFT JOIN SLM_ORD_DESIGN_BOM B
    ON B.BOM = T.BOM
   AND B.MATERIAL_NO = T.MATERIAL_NO
  LEFT JOIN COM_BASE_SPEC E
    ON E.SPEC_CODE = B.SPEC_CODE_R
   AND E.VALIDFLAG = '1'
  LEFT JOIN PLN_SALEORD T1
    ON T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
  LEFT JOIN SLM_ORDER_LINE C
    ON C.VALIDFLAG = '1'
   AND C.ORD_LN_PK = T1.ORD_LN_PK
  LEFT JOIN COM_MSC_JG D
    ON D.CODE_JG = T1.CODE_JG
   AND D.VALIDFLAG = '1'
  LEFT JOIN PLN_ORDER_ZG_S Z
    ON Z.PLN_DIVIDE_ID = T.PLN_DIVIDE_ID
   AND Z.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
 WHERE T.E_IS_OK != '2'
   AND T.BJ_TYPE != '镦粗'
   AND T.ORD_LN_DLY_PK = ?
   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreCalculateDbk.selectBjPine" desc="查询变径类型对应产线">
		<![CDATA[
			SELECT B.PLINE_CODE, B.PLINE_NAME, B.DEPARTMENT_CODE, B.DEPARTMENT_DESC
			  FROM COM_BASE_PROCESS_GROUP G, COM_BASE_PLINE B
			 WHERE B.PLINE_CODE = G.PLINE_CODE
			   AND B.PROCESS_CODE = 'E'
			   AND G.VALIDFLAG = '1'
			   AND G.PROCESS_DESC_C = ?
		]]>
	</query>

	<query id="CoreCalculateDbk.queryPlnOrdInfo" desc="查询">
		<![CDATA[
			SELECT T.PLANSTATUS,
			       T.E_IS_OK,
			       T.BJ_TYPE,
			       T1.MSC,
			       T1.PSC,
			       T1.MATERIAL_NO,
			       T1.OUTDIAMETER,
			       T1.WALLTHICK,
			       T1.SPEC_CODE,
			       T1.SPEC_NAME,
			       T1.PRODUCCODE,
			       T1.FINAL_USER,
			       M.DESGIN_KEY
			  FROM PLN_SALEORD_PROC T
			  LEFT JOIN PLN_SALEORD T1
			    ON T.ORD_LN_DLY_PK = T1.ORD_LN_DLY_PK
			  LEFT JOIN CRAFT_ORD_DESIGN M
			    ON M.ORD_LN_PK = T1.ORD_LN_PK
			   AND M.CRAFT_SEQ = T.CRAFT_SEQ
			 WHERE T.ORD_LN_DLY_PK = ?
			   AND T.PLN_DIVIDE_ID = ?
		]]>
	</query>

	<query id="CoreCalculateDbk.saveLenRoll" desc="保存轧制转移长度,镦拔扩切头尾，镦粗加长">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.LEN_ROLL_MAX   	= '#LEN_ROLL_MAX#',
			       T.LEN_ROLL_MIN   	= '#LEN_ROLL_MIN#',
			       T.LEN_CUTHEAD_DBK='#LEN_CUTHEAD_DBK#',
			       T.LEN_CUTEND_DBK='#LEN_CUTEND_DBK#',
			       T.LEN_LONGER_DBK='#LEN_LONGER_DBK#',
			       T.LEN_SCOPE='#LEN_SCOPE#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>

	<query id="CoreCalculateDbk.setConfirmDbk" desc="镦拔扩确认">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.E_IS_OK = '#E_IS_OK#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>
	<query id="CoreCalculateDbk.updateDbkCut" desc="修改镦拔扩切头尾">
		<![CDATA[
			UPDATE PLN_SALEORD_PROC T
			   SET T.LEN_CUTHEAD_DBK ='#LEN_CUTHEAD_DBK#',
                   T.LEN_CUTEND_DBK='#LEN_CUTEND_DBK#',
                   T.LEN_LONGER_DBK='#LEN_LONGER_DBK#',
                   T.RATIO_DBK  ='#RATIO_DBK#',
			       T.LEN_SCOPE          ='#LEN_SCOPE#'
			 WHERE T.ORD_LN_DLY_PK = '#ORD_LN_DLY_PK#'
			   AND T.PLN_DIVIDE_ID = '#PLN_DIVIDE_ID#'
		]]>
	</query>
</queryMap>