<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="委外审批管理">
	<query id="FrmMchSourcApp.doQueryOutSourc" desc="委外实绩查询">
	 <![CDATA[ 
SELECT T.SUBCONTRACT_NO,
       T.SUBCONTRACT_NO_SEQ,
       T.PLINE_CODE,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.HEAT_PLAN_NO,
       T.ZY_BATCH_ID,
       T.PRO_PLAN_ID,
       T.GX_PLAN_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_CODE,
       T.STD_NAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.CRAFT_FILE_NO,
       NVL(T.SUBCONTRACT_NUM,0) SUBCONTRACT_NUM,
       NVL(T.SUBCONTRACT_WT,0) SUBCONTRACT_WT,
       NVL(T.HB_COMPLETE_NUM,0) HB_COMPLETE_NUM,
       NVL(T.HB_COMPLETE_WT,0) HB_COMPLETE_WT,
       T.SUBCONTRACT_USER,
       DECODE(T.SUBCONTRACT_SHIFT, '1', '早', '2', '中', '3', '夜') SUBCONTRACT_SHIFT,
       DECODE(T.SUBCONTRACT_GROUP,
              '1',
              '甲',
              '2',
              '乙',
              '3',
              '丙',
              '4',
              '丁') SUBCONTRACT_GROUP,
       TO_CHAR(T.SUBCONTRACT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACT_TIME,
       T.SP_USER,
       TO_CHAR(T.SP_TIME, 'YYYY-MM-DD HH24:MI:SS') SP_TIME,
       DECODE(T.SUBCONTRACT_LOG,
              '00',
              '委外申请',
              '10',
              '审核通过',
              '20',
              '审核不通过',
              '30',
              '回报完毕') SUBCONTRACT_LOG,
       T.SUBCONTRACT_PLINE_CODE,
       T.SUBCONTRACT_PLINE_NAME,
       T.SUBCONTRACT_NOTE,
       NVL(T.HB_FP_NUM,0) HB_FP_NUM,
       NVL(T.HB_FP_WT,0) HB_FP_WT,
       T.SP_NOTE,
       T.RESULT_NO,
       T.SUBCONTRACT_TYPE
  FROM MCH_ENTRUSTED_BILL T
 WHERE  T.SUBCONTRACT_TYPE='2'
	  ]]>
	</query>
	<query id="FrmMchSourcApp.doQueryPlineCode" desc="查询产线">
	<![CDATA[
SELECT T.PLINE_CODE, T.PLINE_NAME
  FROM COM_BASE_PLINE T
 WHERE T.VALIDFLAG = '1'
	]]>
	</query>
	<query id="FrmMchSourcApp.QuerySubConStart" desc="查询委托状态">
	<![CDATA[
SELECT T.SUBCONTRACT_LOG
  FROM MCH_ENTRUSTED_BILL T
 WHERE T.SUBCONTRACT_NO = ?
   AND T.SUBCONTRACT_NO_SEQ = ?
	]]>
	</query>
	<query id="FrmMchSourcApp.UpdateOutSourc" desc="修改委托状态">
	<![CDATA[
UPDATE MCH_ENTRUSTED_BILL
   SET SP_USER                = ?,
       SP_TIME                = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       SUBCONTRACT_LOG        = ?,
       SUBCONTRACT_PLINE_CODE = ?,
       SUBCONTRACT_PLINE_NAME = ?,
       SP_NOTE                = ?
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
	]]>
	</query>
	<query id="FrmMchSourcApp.UpdateOff" desc="释放离线表委外支吨">
	<![CDATA[
 UPDATE MCH_OFFLINE_RESULT
   SET SUBCONTRACT_NUM      = ?,
       SUBCONTRACT_WT       = ?,
       SUBCONTRACT_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       SUBCONTRACT_NAME = ?
 WHERE RESULT_NO = ?
	]]>
	</query>
	<query id="FrmMchSourcApp.UpdateOutSourcNum" desc="修改委外回报量">
	<![CDATA[
UPDATE MCH_ENTRUSTED_BILL
   SET HB_COMPLETE_NUM = ?,
       HB_COMPLETE_WT  = ?,
       HB_FP_NUM       = ?,
       HB_FP_WT        = ?
 WHERE SUBCONTRACT_NO = ?
   AND SUBCONTRACT_NO_SEQ = ?
	]]>
	</query>
	<query id="FrmMchSourcApp.UpdateOffSourc" desc="修改离线表委外回报">
	<![CDATA[
UPDATE MCH_OFFLINE_RESULT
   SET SUBCONTRACTCOMPLETE_NUM = ?,
       SUBCONTRACTCOMPLETE_WT  = ?,
       HB_FP_NUM               = ?,
       HB_FP_WT                = ?
 WHERE RESULT_NO = ?

	]]>
	</query>
</queryMap>