<?xml version="1.0" encoding="UTF-8"?>
<queryMap id = "FrmJudge.getMatData" desc = "查询库存信息">
<![CDATA[
	SELECT T1.BELONG_CODE,
       T1.BELONG_NAME,
       T1.JUDGE_STOVE_NO,
       T1.BATCH_NO,
       T1.BATCH_GROUD_NO,
       --(SELECT T3.BASENAME
          --FROM COM_BASE_INFO T3
         --WHERE T3.BASECODE = T1.PRODUCT_FLAG)
          T1.PRODUCT_FLAG,
       --(SELECT T3.BASENAME
         -- FROM COM_BASE_INFO T3
        -- WHERE T3.BASECODE = T1.MAT_STATUS)
        T1.MAT_STATUS,
       T1.SPEC_CODE,
       T1.SPEC_NAME,
       T1.ACT_DIMATER,
       T1.ACT_HEIGHT,
       T1.ACT_LEN_MIN,
       T1.ACT_LEN_MAX,
       T1.PRODUCCODE,
       T1.PRODUCNAME,
       T1.MATERIAL_NO,
       T1.MATERIAL_NAME,
       T1.STEELCODE,
       T1.STEELNAME,
       T1.STD_CODE,
       T1.STD_NAME,
       T1.ORDER_NO,
       T1.ORDER_SEQ,
       T1.ORDER_SEQ_NO,
       T1.ORD_PK,
       T1.ORD_LN_PK,
       T1.ORD_LN_DLY_PK,
       T1.PRO_ORDER_NO,
       T1.PRO_ORDER_ID,
       TO_CHAR(MIN(T1.INSTOCK_TIME), 'YYYY-MM-DD HH24:MI:SS') INSTOCK_TIME,
       (SELECT T4.STORAGE_NAME
          FROM YDM_BS_STORAGE T4
         WHERE T4.STORAGE_NO = T2.STORAGE_NO) STORAGE_NAME,
       T2.STORAGE_NO,
       T1.MODEL_CODE,
       T1.MODEL_DESC,
       T1.STD_STYLE,
       T1.STD_STYLE_DESC,
       T1.MEMO,
       T1.JUDGE_RESULT_CODE,
       T1.JUDGE_RESULT,
       SUM(NVL(T1.ACT_LEN, 0)) AS ACT_LEN,
       SUM(NVL(T1.ACT_COUNT, 0)) AS ACT_COUNT,
       SUM(NVL(T1.ACT_COUNT,0)) AS GPACT_COUNT,
       SUM(NVL(T1.ACT_WEIGHT, 0)) AS ACT_WEIGHT,
       SUM(NVL(T1.ACT_THEORY_WEIGHT, 0)) AS ACT_THEORY_WEIGHT,
       T1.JUDGE_STD_NAME,
       T1.LOCK_FLAG,
       T1.SUPPLY_UNIT_CODE,
       T1.SUPPLY_UNIT
  FROM MAT_ZC_M T1, YDM_ZC_BUTTRESS T2
 WHERE T1.MAT_NO = T2.MAT_NO
 AND T1.PRODUCT_FLAG = '801402'
 AND T1.LOCK_FLAG = '0'

  
	]]>
	<query id = "FrmJudge.getGpData" desc = "查询改判实绩">
	<![CDATA[
	SELECT 
       JUDGE_ID,
       JUDGE_STOVE_NO_OLD,
       BATCH_NO_OLD,
       BATCH_GROUD_NO_OLD,
       ACT_COUNT,
       ACT_WEIGHT,
       JUDGE_STOVE_NO,
       BATCH_NO,
       BATCH_GROUD_NO,
       MATERIAL_NO_OLD,
       MATERIAL_NAME_OLD,
       PRODUCCODE_OLD,
       PRODUCNAME_OLD,
       STEELCODE_OLD,
       STEELNAME_OLD,
       SPEC_CODE_OLD,
       SPEC_NAME_OLD,
       MODEL_CODE_OLD,
       MODEL_DESC_OLD,
       STD_STYLE_OLD,
       STD_STYLE_DESC_OLD,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STEELCODE,
       STEELNAME,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       STD_STYLE,
       STD_STYLE_DESC,
       CREATE_NAME,
       TO_CHAR(CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
       SUBMIT_NAME,
       TO_CHAR(SUBMIT_TIME, 'YYYY-MM-DD HH24:MI:SS') SUBMIT_TIME,
       AGREE_NAME,
       TO_CHAR(AGREE_TIME, 'YYYY-MM-DD HH24:MI:SS') AGREE_TIME,
       DECODE(AGREE_FLAG,'0','未提交审批','1','提交审批','2','审批通过','3','审批不通过')AGREE_FLAG,
       CREATE_MEMO,
       SUBMIT_MEMO,
       AGREE_MEMO,
       DECODE(VALID_FLAG,'0','无效','1','有效')VALID_FLAG,
       DELETE_NAME,
       TO_CHAR(DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
       BELONG_CODE,
       BELONG_NAME,
       SUPPLY_UNIT_CODE,
       SUPPLY_UNIT
 FROM QCM_ZG_JUDGE_CHANGE
 WHERE VALID_FLAG = '1'
 ]]>
	</query>
	<query id = "FrmJudge.queryJudgeMaxId" desc = "查询最大id号">
	SELECT T.JUDGE_ID
  FROM QCM_ZG_JUDGE_CHANGE T
 WHERE CREATE_TIME LIKE '%' || TO_DATE(?, 'YYYY/MM/DD') || '%'
 ORDER BY T.JUDGE_ID DESC
	</query>
	<query id = "GpData.SelectCount" desc = "查询支数是否满足">
	SELECT SUM(T.ACT_COUNT) ACOUNT
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.PRODUCT_FLAG = '801402'
   AND T.LOCK_FLAG = '0'
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
	</query>
	<query id = "GpData.SelectMatNo" desc = "查询改判支数材料号">
	<![CDATA[
	SELECT T.MAT_NO,
       T.ACT_WEIGHT,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME
        FROM (SELECT T.MAT_NO,
       T.ACT_WEIGHT,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STEELCODE,
       T.STEELNAME,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.BELONG_CODE,
       T.BELONG_NAME
  FROM MAT_ZC_M T, YDM_ZC_BUTTRESS S
 WHERE T.MAT_NO = S.MAT_NO
   AND T.PRODUCT_FLAG = '801402'
   AND T.LOCK_FLAG = '0'
   AND T.JUDGE_STOVE_NO = ?
   AND T.BATCH_NO = ?
   AND T.BATCH_GROUD_NO = ?
 ORDER BY T.MAT_NO DESC) T WHERE ROWNUM < ?
	]]>
	</query>
	<query id = "GpData.updateMat" desc = "锁定物料信息">
	UPDATE MAT_ZC_M T SET T.LOCK_FLAG = '2',T.JUDGE_ID = ? WHERE T.MAT_NO = ?
	</query>
	<query id = "GpData.insetJudgeData" desc = "插入改判表">
	 INSERT INTO QCM_ZG_JUDGE_CHANGE(
        JUDGE_ID,
        JUDGE_STOVE_NO_OLD,
        BATCH_NO_OLD,
        BATCH_GROUD_NO_OLD,
        ACT_COUNT,
        ACT_WEIGHT,
        MATERIAL_NO_OLD,
        MATERIAL_NAME_OLD,
        PRODUCCODE_OLD,
        PRODUCNAME_OLD,
        STEELCODE_OLD,
        STEELNAME_OLD,
        SPEC_CODE_OLD,
        SPEC_NAME_OLD,
        MODEL_CODE_OLD,
        MODEL_DESC_OLD,
        STD_STYLE_OLD,
        STD_STYLE_DESC_OLD,
        MATERIAL_NO,
        MATERIAL_NAME,
        PRODUCCODE,
        PRODUCNAME,
        STEELCODE,
        STEELNAME,
        SPEC_CODE,
        SPEC_NAME,
        MODEL_CODE,
        MODEL_DESC,
        STD_STYLE,
        STD_STYLE_DESC,
        CREATE_NAME,
        CREATE_TIME,
        CREATE_MEMO,
        BELONG_CODE,
        BELONG_NAME,
        SUPPLY_UNIT_CODE,
        SUPPLY_UNIT)
 VALUES( 
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        ?,
        SYSDATE,
        ?,
        ?,
        ?,
        ?,
        ?)
	</query>
	<query id = "cancelGpData.updateJudge" desc = "作废改判记录">
	UPDATE QCM_ZG_JUDGE_CHANGE T
   SET T.VALID_FLAG = '0', T.DELETE_NAME = ?, T.DELETE_TIME = SYSDATE
 WHERE T.JUDGE_ID = ?
	</query>
	<query id = "cancelGpData.updateMat" desc = "释放库存被锁定资源">
	UPDATE MAT_ZC_M T SET T.LOCK_FLAG = '0' WHERE T.JUDGE_ID = ?
	</query>
	<query id = "cancelGpData.SelectStaus" desc = "查询改判记录状态">
	SELECT T.AGREE_FLAG FROM QCM_ZG_JUDGE_CHANGE T WHERE T.JUDGE_ID = ?
	</query>
</queryMap>