<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="接箍委托单">
	<query id="FrmWeiTuo.geQueryEntrusted" desc="查询委托单信息">
        <![CDATA[  
   SELECT T.ENTRUSTED_NO,
       T.PLINE_CODE,
       T.WO_ID,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.ENTRUSTED_NUM1,
       T.ENTRUSTED_WT1,
       DECODE(T.ENTRUSTED_LOG,
              '1',
              '未申请',
              '2',
              '已申请',
              '3',
              '审批通过',
              '4',
              '审核不通过','5','回报完毕') ENTRUSTED_LOG,
       DECODE(T.HARSH_TYPE, '0', '扒皮', '1', '镗孔', '/') HARSH_TYPE,
       DECODE(T.COATING_TYPE,
              '1',
              '磷化',
              '2',
              '镀铜',
              '3',
              '磷化及镀铜',
              '/') COATING_TYPE,
       T.COL_MODE,
       TO_CHAR(T.COL_TIME, 'YYYY-MM-DD HH24:MI:SS') COL_TIME,
       T.COL_USER,
       DECODE(T.COL_SHIFT, '1', '早', '2', '中', '3', '夜', '0', '白') COL_SHIFT,
       DECODE(T.COL_GROUP, '1', '甲', '2', '乙', '3', '丙', '4', '丁') COL_GROUP,
       TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       NVL(T.SUBCONTRACTCOMPLETE_NUM,0) SUBCONTRACTCOMPLETE_NUM,
       NVL(T.SUBCONTRACTCOMPLETE_WT,0) SUBCONTRACTCOMPLETE_WT, 
       NVL(T.HB_FP_NUM,0) HB_FP_NUM,
       NVL(T.HB_FP_WT,0) HB_FP_WT,
       T.SUBCONTRACTCOMPLETE_NAME,
       TO_CHAR(T.SUBCONTRACTCOMPLETE_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBCONTRACTCOMPLETE_TIME,
       T.PLINE_NAME,
       T.STATION_CODE,
       T.STATION_DESC,
       T.MEMO,
       T.RESULT_NO,
       T.OFF_XH,
       T.AUDIT_NAME,
       TO_CHAR(T.AUDIT_TIME, 'YYYY-MM-DD HH24:MI:SS') AUDIT_TIME,
       T1.STEELNAME,
       T1.GRADENAME,
       T1.SPEC_JG_DESC,
       T1.STD_NAME,
       T1.STD_STYLE_DESC,
       T1.PRODUCCODE_JG_DESC,
       T1.CODE_JG,
       T1.CODE_JG_BL,
       T1.MODEL_DESC,
        (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.STYLE_JG
           AND B.VALIDFLAG = '1') STYLE_JG,
             (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_DETECTION
           AND B.VALIDFLAG = '1') DEMAND_DETECTION,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_BONDERIZING
           AND B.VALIDFLAG = '1') DEMAND_BONDERIZING,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_COPPER
           AND B.VALIDFLAG = '1') DEMAND_COPPER,
       (SELECT B.BASENAME
          FROM COM_BASE_INFO B
         WHERE B.BASECODE = T1.DEMAND_BLAST
           AND B.VALIDFLAG = '1') DEMAND_BLAST
  FROM COUPLING_OUTSOURC_RESULT T, PLN_ZY_JG_WORKBILL T1
 WHERE T.WO_ID = T1.WO_ID
           ]]>
	</query>
	
	<query id="FrmWeiTuo.QueryPlnBillStrat" desc="查询委托单状态">
        <![CDATA[
          SELECT ENTRUSTED_LOG FROM COUPLING_ENTRUSTED_RESULT WHERE ZY_PLAN_ID = ? AND WO_ID=? AND ENTRUSTED_NO=?
          ]]>
	</query>
	<query id="FrmWeiTuo.UpdateSubCount" desc="修改回报支吨">
        <![CDATA[
         UPDATE COUPLING_OUTSOURC_RESULT T
   SET T.SUBCONTRACTCOMPLETE_NUM  = ?,
       T.SUBCONTRACTCOMPLETE_WT   = ?,
       T.HB_FP_NUM                = ?,
       T.HB_FP_WT                 = ?,
       T.SUBCONTRACTCOMPLETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       T.SUBCONTRACTCOMPLETE_NAME = ?,
       T.ENTRUSTED_LOG            = ?
 WHERE T.ENTRUSTED_NO = ?
          ]]>
	</query>
	<query id="FrmWeiTuo.UpdateOffSubCount" desc="修改离线回报支吨">
        <![CDATA[
         UPDATE COUPLING_OFFLINE_RESULT T
   SET T.SUBCONTRACTCOMPLETE_NUM  = ?,
       T.SUBCONTRACTCOMPLETE_WT   = ?,
       T.HB_FP_NUM                = ?,
       T.HB_FP_WT                 = ?,
       T.SUBCONTRACTCOMPLETE_TIME = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       T.SUBCONTRACTCOMPLETE_NAME = ?
 WHERE T.RESULT_NO = ?
   AND T.OFF_XH = ?
   AND T.SUBCONTRACT_NO = ?

          ]]>
	</query>
</queryMap>