<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="管加工离线去向维护">
	<query id="FrmOfficeDirect.doQuery" desc="工序离线情况查询">
	 <![CDATA[ 
SELECT T.ORDER_NO || '/' || T.ORDER_SEQ || '/' || T.DELIVERY_NO ORDER_NO_SEQ,
               T.HEAT_PLAN_NO,
               T.PLINE_NAME,
               T.JUDGE_STOVE_NO,
               T.BATCH_NO,       
               T.ORDER_NO,
               T.CREATE_NAME,
               T.PLINE_CODE,
               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,
               DECODE(T.PLANSTATUS,
                      '00',
                      '计划',
                      '10',
                      '下发',
                      '20',
                      '生产中',
                      '30',
                      '生产完成',
                      '40',
                      '关闭') PLANSTATUS,
  (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701302') TANSHANG_NUM,
                 (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701303') FENQIE_NUM,
                    (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701304') CHESI_NUM,
                   (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701305') LUOWEN_NUM,
                  (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701306') NINGJIE_NUM,
                 (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701307') TONGJING_NUM,
                 (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701308') SHUIYA_NUM,
                 (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701309') DAOLENG_NUM,
                 (SELECT NVL(SUM(T1.ACT_COUNT), 0)
                  FROM port_mch_batch_sample_result T1
                 WHERE T1.HEAT_PLAN_NO = T.HEAT_PLAN_NO and t1.MAT_STATUS='20' and t1.OP_PROCESS='701310') CELIANG_NUM,
                   DECODE(T.BESIDE_STATUS,
                      '00',
                      '上料结束',
                      '01',
                      '探伤结束',
                      '02',
                      '切管结束',
                      '03',
                      '车丝结束',
                      '04',
                      '螺纹检验结束',
                      '05',
                      '拧接结束',
                      '06',
                      '通径结束',
                      '07',
                      '水压结束',
                      '08',
                      '倒棱结束',
                      '09',
                      '测量点结束',
                      '10',
                      '交库结束') BESIDE_STATUS,
               DECODE(T.PER_STATUS,
                      '00',
                      '上料开始',
                      '01',
                      '探伤开始',
                      '02',
                      '切管开始',
                      '03',
                      '车丝开始',
                      '04',
                      '螺纹检验开始',
                      '05',
                      '拧接开始',
                      '06',
                      '通径开始',
                      '07',
                      '水压开始',
                      '08',
                      '倒棱开始',
                      '09',
                      '测量点开始',
                      '10',
                      '交库开始') PER_STATUS         
          FROM pln_zy_jgx_m T,MCH_offline_result_d D WHERE 1=1  AND T.HEAT_PLAN_NO=D.HEAT_PLAN_NO AND T.PLINE_CODE=D.PLINE_CODE
	  ]]>
	</query>
	<query id="FrmReason.addOfficeD" desc="废品原因新增">
	 <![CDATA[ 
INSERT INTO MCH_FAIL_REASON
  (HEAT_PLAN_NO,ZY_BATCH_ID,PLINE_NAME,OP_PROCESS,FAIL_REASON)
VALUES
  (?, ?, ?,?,?)
	  ]]>
	</query>
	
	<query id="FrmOfficeDirect.queryOfficeD" desc="查询离线去向">
	 <![CDATA[ 
select T.STATION_DESC,
t.GOWHERE_NAME,
t.OFFLINE_NUM from Mch_Offline_Result_d t
where 1 =1 
	  ]]>
	</query>
	
		<query id="FrmOfficeDirect.updatePerson" desc="修改人员">
	 <![CDATA[ 
 UPDATE MCH_PERSON T
   SET T.MAN_NAME = ?,T.PLINE_CODE = ?,T.PRO_BZ = ?
 WHERE T.MAN_NAME = ?
	  ]]>
	</query>
	
		<query id="FrmReason.delete" desc="删除废品原因">
	 <![CDATA[ 
 DELETE FROM MCH_FAIL_REASON T WHERE T.FAIL_REASON= ?
	  ]]>
	</query>
	

</queryMap>