<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc = "成品库存封锁">
<query id = "FrmManageBlock.queryInListData" desc = "成品库存">
<![CDATA[
SELECT T1.ORDER_NO || '/' || T1.ORDER_SEQ AS SORDER,
       T1.OLD_ORDER_NO || '/' || T1.OLD_ORDER_SEQ AS OLDORDER,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.LOCK_ID,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       T1.PRODUCNAME,
       T1.STD_STYLE_DESC,
       T1.STEELNAME,
       T1.SPEC_NAME,
       T1.MODEL_DESC,
       T1.STD_NAME,
       T1.JUDGE_STD_NAME,
       T1.GRADENAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       TO_CHAR(T1.ACT_LEN_MIN,'FM9990.00') ACT_LEN_MIN,
       TO_CHAR(T1.ACT_LEN_MAX,'FM9990.00') ACT_LEN_MAX,
       T1.BELONG_NAME,
       D.SALE_AREA_DESC,
       D.CREATE_NAME AS ORDERCREATENAME,
       T1.PLINE_NAME,
       S.STORAGE_NAME,
       S.STORAGE_NO,
       D.CUSTOMER_NM,
       G.RECEIV_NM,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=T1.PRODUCT_FLAG ) AS PRODUCT_FLAG,
       (SELECT B1.BASENAME FROM COM_BASE_INFO B1 WHERE B1.BASECODE=T1.MAT_STATUS ) AS MAT_STATUS,
       T1.MEMO,
       T1.PIPMEMO,
       MAX(TO_CHAR(T1.MNG_LOCK_TIME, 'YYYY-MM-DD HH24:MI:SS')) AS MNG_LOCK_TIME,
       T1.MNG_LOCK_MAKER,
       T1.MNG_LOCK_REMARK,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=T1.MNG_LOCK_RSN_CODE ) AS MNG_LOCK_RSN_CODE,      
       DECODE(T1.MNG_LOCK_FLAG, '0', '未封锁', '1', '已封锁') AS MNG_LOCK_FLAG,
       TO_CHAR(T1.INSTOCK_TIME, 'YYYY-MM-DD HH24:MI:SS') AS INSTOCK_TIME,
       SUM(T1.ACT_COUNT) AS ACT_COUNT,
       TO_CHAR(SUM(T1.ACT_WEIGHT),'FM9999990.000') AS ACT_WEIGHT
  FROM MAT_ZC_M T1
  LEFT JOIN YDM_ZC_BUTTRESS T2
    ON T1.MAT_NO = T2.MAT_NO
  LEFT JOIN YDM_BS_STORAGE S
    ON S.STORAGE_NO = T2.STORAGE_NO
  LEFT JOIN (SELECT E.SALE_AREA_DESC,
                    E.CREATE_NAME,
                    E.CUSTOMER_NM,
                    E.ORDER_NO
               FROM SLM_ORDER_HEAD E
              WHERE E.VALIDFLAG = '1') D
    ON SUBSTR(T1.OLD_ORDER_NO,
              1,
              DECODE(INSTR(T1.OLD_ORDER_NO, '/'),
                     0,
                     LENGTH(T1.OLD_ORDER_NO),
                     INSTR(T1.OLD_ORDER_NO, '/') - 1)) = D.ORDER_NO
  LEFT JOIN SLM_ORDER_LINE_DELIVERY G
    ON T1.ORD_LN_DLY_PK = G.ORD_LN_DLY_PK
 WHERE T1.JUDGE_STOVE_NO = T2.JUDGE_STOVE_NO
   AND T1.BATCH_NO = T2.BATCH_NO
   AND T1.MAT_STATUS <>'80150303' 
   AND T1.MAT_STATUS <>'80150302' 
   AND T1.MAT_STATUS<>'80150201'
]]>
</query>
<query id = "FrmManageBlock.checkMatWeight" desc = "查询支数对应重量">
<![CDATA[
SELECT NVL(SUM(P.ACT_WEIGHT), 0)  ACT_WEIGHT,
       NVL(SUM(P.ACT_COUNT), 0)  ACT_COUNT,
       NVL(SUM(P.ACT_LEN), 0)  ACT_LEN
  FROM (SELECT NVL(T1.ACT_WEIGHT, 0) AS ACT_WEIGHT,
               NVL(T1.ACT_COUNT, 0) AS ACT_COUNT,
               NVL(T1.ACT_LEN, 0) AS ACT_LEN,
               ROWNUM
          FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
         WHERE T1.MAT_NO = T2.MAT_NO
           AND T1.MNG_LOCK_FLAG='0'
           AND T2.STORAGE_NO = ?
           AND T1.JUDGE_STOVE_NO = ?
           AND T1.BATCH_NO = ?
           AND T1.BATCH_GROUD_NO = ?
         ORDER BY T1.MAT_NO) P
 WHERE ROWNUM < #RUNMBER#
]]>
</query>
<query id = "FrmManageBlock.lockReason" desc = "查询封锁原因">
<![CDATA[
SELECT B.BASECODE,B.BASENAME FROM COM_BASE_INFO B WHERE B.SORTCODE=? AND B.VALIDFLAG='1'
]]>
</query>

<query id = "FrmManageBlock.updateMatLock" desc = "修改材料表封锁标志">
<![CDATA[
UPDATE MAT_ZC_M T
   SET T.MNG_LOCK_RSN_CODE = ?,
       T.MNG_LOCK_TIME     = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       T.MNG_LOCK_MAKER    = ?,
       T.MNG_LOCK_REMARK   = ?,
       T.MNG_LOCK_FLAG     = '1',
       T.LOCK_ID           =?
 WHERE T.MAT_NO IN (SELECT M1.MAT_NO
                      FROM (SELECT M.MAT_NO
                              FROM MAT_ZC_M M
                             WHERE M.JUDGE_STOVE_NO = ?
                               AND M.BATCH_NO = ?
                               AND M.BATCH_GROUD_NO = ?
                               AND M.MNG_LOCK_FLAG = ?
                             ORDER BY M.MAT_NO) M1
                     WHERE ROWNUM < ?)
]]>
</query>
<query id = "FrmManageBlock.insterMatLock" desc = "新增封锁日志">
<![CDATA[
INSERT INTO QCM_ZG_LOCK_LOG (LOCK_ID, JUDGE_STOVE_NO, BATCH_NO, BATCH_GROUD_NO, 
MATERIAL_NO, MATERIAL_NAME, PRODUCCODE, PRODUCNAME, STEELCODE, STEELNAME, 
SPEC_CODE, SPEC_NAME, MODEL_CODE, MODEL_DESC, STD_STYLE, STD_STYLE_DESC, 
BELONG_CODE, BELONG_NAME, STD_CODE, STD_NAME, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, 
ACT_LEN_MIN, ACT_LEN_MAX, ACT_COUNT, ACT_WEIGHT, ACT_THEORY_WEIGHT, 
MNG_LOCK_FLAG, MNG_LOCK_RSN_CODE, MNG_LOCK_TIME, MNG_LOCK_MAKER, 
MNG_LOCK_REMARK) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
 ?, ?, TO_NUMBER(?), ?, ?, TO_NUMBER(?), TO_NUMBER(?), TO_NUMBER(?),
 ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?)
]]>
</query>
<query id = "FrmManageBlock.QUERYMATLOCK" desc = "查询库存成品记录">
<![CDATA[
SELECT T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       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_MIN,
       T.ACT_LEN_MAX,
       T.BELONG_CODE,
       T.BELONG_NAME,
       SUM(T.ACT_LEN) AS ACT_LEN,
       SUM(T.ACT_COUNT) AS ACT_COUNT,
       SUM(T.ACT_WEIGHT) AS ACT_WEIGHT,
       SUM(T.ACT_THEORY_WEIGHT) AS ACT_THEORY_WEIGHT
  FROM MAT_ZC_M T
 WHERE T.MAT_NO IN (SELECT M1.MAT_NO
                      FROM (SELECT M.MAT_NO
                              FROM MAT_ZC_M M
                             WHERE M.JUDGE_STOVE_NO = ?
                               AND M.BATCH_NO = ?
                               AND M.BATCH_GROUD_NO = ?
                               AND M.MNG_LOCK_FLAG = ?
                             ORDER BY M.MAT_NO) M1
                     WHERE ROWNUM <#count#)
GROUP BY T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.BATCH_GROUD_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.GRADECODE,
       T.GRADENAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       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_MIN,
       T.ACT_LEN_MAX,
       T.BELONG_CODE,
       T.BELONG_NAME
]]>
</query>
<query id = "FrmManageBlock.queryLockLog" desc = "查询封锁日志序号">
<![CDATA[
SELECT ? ||
       LPAD(SUBSTR(NVL(MAX(T.LOCK_ID), '00000'), -5, 5) + 1, 5, '0') AS OUTSTOCK_SQE
  FROM QCM_ZG_LOCK_LOG T
]]>
</query>
<query id = "FrmManageBlock.updateMatLockLog" desc = "修改封锁日志表解锁信息">
<![CDATA[
UPDATE QCM_ZG_LOCK_LOG T
   SET T.UNLOCK_TIME   = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'),
       T.UNLOCK_MAKER  = ?,
       T.UNLOCK_REMARK = ?,
       T.MNG_LOCK_FLAG = '0'
 WHERE T.LOCK_ID =?
]]>
</query>
<query id = "FrmManageBlock.updateMatLock1" desc = "修改材料表封锁标志">
<![CDATA[
UPDATE MAT_ZC_M T
   SET T.MNG_LOCK_RSN_CODE = '',
       T.MNG_LOCK_TIME     = '',
       T.MNG_LOCK_MAKER    = '',
       T.MNG_LOCK_REMARK   = '',
       T.MNG_LOCK_FLAG     = '0',
       T.LOCK_ID           =''
 WHERE T.MAT_NO IN (SELECT M1.MAT_NO
                      FROM (SELECT M.MAT_NO
                              FROM MAT_ZC_M M
                             WHERE  M.JUDGE_STOVE_NO = ?
                               AND M.BATCH_NO = ?
                               AND M.BATCH_GROUD_NO = ?
                               AND M.MNG_LOCK_FLAG = ?
                               AND M.LOCK_ID=?
                             ORDER BY M.MAT_NO) M1
 WHERE ROWNUM < ?)
]]>
</query>
<query id = "FrmManageBlock.queryLockLogMat" desc = "查询封锁日志">
<![CDATA[
SELECT LOCK_ID,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,  
       MATERIAL_NAME,      
       PRODUCNAME,     
       STEELNAME,      
       SPEC_NAME,     
       MODEL_DESC,     
       STD_STYLE_DESC,      
       BELONG_NAME,     
       STD_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       TO_CHAR(ACT_LEN_MIN,'FM9990.00') ACT_LEN_MIN,
       TO_CHAR(ACT_LEN_MAX,'FM9990.00') ACT_LEN_MAX,
       ACT_COUNT,
       TO_CHAR(ACT_WEIGHT,'FM9999990.000') ACT_WEIGHT,
       TO_CHAR(ACT_THEORY_WEIGHT,'FM9999990.000') ACT_THEORY_WEIGHT,
       (SELECT B.BASENAME FROM COM_BASE_INFO B WHERE B.BASECODE=MNG_LOCK_RSN_CODE ) AS MNG_LOCK_RSN_CODE, 
       TO_CHAR(MNG_LOCK_TIME,'YYYY-MM-DD HH24:MI:SS') MNG_LOCK_TIME,
       MNG_LOCK_MAKER,
       MNG_LOCK_REMARK,
       TO_CHAR(UNLOCK_TIME,'YYYY-MM-DD HH24:MI:SS') UNLOCK_TIME,
       UNLOCK_MAKER,
       UNLOCK_REMARK,
       DECODE(MNG_LOCK_FLAG,'0','未封锁','1','已封锁') AS MNG_LOCK_FLAG
  FROM QCM_ZG_LOCK_LOG 
  WHERE 1=1 
]]>
</query>
</queryMap>