<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="直接出库">
	<query id="FrmCasOutAutomatic.QueryBillC" desc="查询提单从表">
<![CDATA[
SELECT T.STORAGE_NO FROM YDM_ZC_BILL_C T WHERE T.BILL_NO=? GROUP BY T.STORAGE_NO
]]>
	</query>
	<query id="FrmCasOutAutomatic.queryOutList" desc="查询出库单号">
	<![CDATA[
    SELECT MAX(OUTSTOCK_DOC) AS OUTSTOCK_DOC
    FROM YMD_GP_OUTLIST
   WHERE OUTSTOCK_TYPE_CODE = ?
    AND TO_CHAR(CREATE_TIME,'YYYY-MM-DD') =?
	]]>
	</query>
	<query id="FrmCasOutAutomatic.queryOut" desc="查询出库流水号">
	<![CDATA[
	  SELECT ? ||
         LPAD(SUBSTR(NVL(MAX(T.OUTSTOCK_SQE), '0000'), -4, 4) + 1, 4, '0') AS OUTSTOCK_SQE
    FROM YMD_GP_OUTLIST T
   WHERE TO_CHAR(T.CREATE_TIME,'YYYY-MM-DD') =?
     AND T.OUTSTOCK_TYPE_CODE =?
     AND T.OUTSTOCK_DOC = ?
	]]>
	</query>
	<query id="FrmCasOutAutomatic.getqueryBillM" desc="查询提单主表">
<![CDATA[
SELECT T.BILL_NO,
       T.BILL_STATUS,
       T.LOADVEHICLE_TYPE,
       T.ISPRECLOSE,
       T.PLAN_TRANS_TYPE,
       T.SEND_PLAN_NO,
       SUM(T.PLAN_NUM) PLAN_NUM,
       SUM(T.PLAN_WT) PLAN_WT,
       SUM(T.PLAN_TOTL_LEN) PLAN_TOTL_LEN,
       T.CUSTOMER_NO,
       T.CUSTOMER_NM,
       T.RECEIV_NO,
       T.RECEIV_NM,
       T.STLMT_UNIT_NO,
       T.STLMT_UNIT_NM,
       T.SALE_ORG,
       T.SALE_ORG_DESC,
       T.DELVRY_ADDR,
       MAX(T.PRD_CLS) AS PRD_CLS,max(t.SUPPLY_UNIT) SUPPLY_UNIT
  FROM YDM_ZC_BILL_M T
 WHERE T.BILL_NO = ?
   AND T.SEND_PLAN_NO = ?
   AND T.VALIDFLAG='1'
 GROUP BY T.BILL_NO,
          T.BILL_STATUS,
          T.LOADVEHICLE_TYPE,
          T.ISPRECLOSE,
          T.PLAN_TRANS_TYPE,
          T.SEND_PLAN_NO,
          T.CUSTOMER_NO,
          T.CUSTOMER_NM,
          T.RECEIV_NO,
          T.RECEIV_NM,
          T.STLMT_UNIT_NO,
          T.STLMT_UNIT_NM,
          T.SALE_ORG,
          T.SALE_ORG_DESC,
          T.DELVRY_ADDR
	]]>
	</query>
	<query id="FrmCasOutAutomatic.AddButtress" desc="新增位置表">
	<![CDATA[
	INSERT INTO YDM_GP_BUTTRESS (MAT_NO, JUDGE_STOVE_NO, BATCH_NO, GROUD_NO, 
		STORAGE_NO, LOCATION_NO, LARY_NO, LOC_NO, STORAGE_ATTR, STORAGE_ATTR_NAME, 
		STORAGE_TYPE_NO, STORAGE_TYPE_NAME, MANAGEMENT_NO, MANAGEMENT_NAME, 
		DEPARTMENT_CODE, DEPARTMENT_DESC, CREATE_NAME, CREATE_TIME) VALUES (?, ?, ?, ?, 
		?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'))	
	 ]]>
	</query>
		<query id="FrmCasOutAutomatic.QueryAddSendMat" desc="查询提单从表信息">
<![CDATA[
SELECT T.ORDER_NO,
       T.ORDER_SEQ,
       T.MAT_NO,
       T.LOT_NO,
       T.JUDGE_STOVE_NO,
       T.BATCH_NO,
       T.GROUP_NO,
       T.STOVE_NO,
       T.MATERIAL_NO,
       T.MATERIAL_NAME,
       T.PRODUCCODE,
       T.PRODUCNAME,
       T.STD_CODE,
       T.STD_NAME,
       T.GRADECODE,
       T.GRADENAME,
       T.STEELCODE,
       T.STEELNAME,
       T.STD_STYLE,
       T.STD_STYLE_DESC,
       T.SPEC_CODE,
       T.SPEC_NAME,
       T.MODEL_CODE,
       T.MODEL_DESC,
       T.ACT_DIMATER,
       T.ACT_HEIGHT,
       T.ACT_LEN,
       T.ACT_LEN_MIN,
       T.ACT_LEN_MAX,
       T.ACT_COUNT,
       T.ACT_WEIGHT,
       T.ACT_THEORY_WEIGHT,
       T.JUDGE_RESULT_CODE,
       T.PRO_BC,
       T.PRO_BZ,
       T.RPO_TIME,
       T.STORAGE_NO,
       T.LOCATION_NO,
       T.DELIVERY_NO,
       T.ORD_PK,
       T.ORD_LN_PK,
       T.ORD_LN_DLY_PK,
       T.VSTEL,
       T.VSTEL_DESC,
       M1.PORT_NO,
       M1.PORT_DESC,
       M1.CREDIT_NO,
       T.PRT_FLAG,
       T.SEND_NUM,
       T.ACT_FIX_NUM,
       T.ACT_FIX_LEN
  FROM (SELECT M.ORD_LN_DLY_PK,
               M.BILL_NO,
               M.PORT_NO,
               M.PORT_DESC,
               M.CREDIT_NO
          FROM YDM_ZC_BILL_M M
         GROUP BY M.PORT_NO,
                  M.PORT_DESC,
                  M.CREDIT_NO,
                  M.ORD_LN_DLY_PK,
                  M.BILL_NO) M1,
       YDM_ZC_BILL_C T
 WHERE M1.BILL_NO = T.BILL_NO
   AND M1.ORD_LN_DLY_PK = T.ORD_LN_DLY_PK
   AND T.BILL_NO = ?
   AND T.VALIDFLAG = '1'
 ORDER BY T.MAT_NO ASC
]]>
	</query>
	<query id="FrmCasOutAutomatic.updateBillC" desc="修改提单材料表装车状态">
	<![CDATA[
UPDATE YDM_ZC_BILL_C SET LOADVEHICLE_FLAG='1' ,EDIT_FLAG='1'
  WHERE BILL_NO=?
	]]>
	</query>
	<query id="FrmCasOutAutomatic.updateBillM" desc="修改提单主表状态">
	<![CDATA[
UPDATE YDM_ZC_BILL_M
   SET ACT_NUM      = TO_NUMBER(NVL(ACT_NUM, '0')) + TO_NUMBER(?),
       ACT_WT       = TO_NUMBER(NVL(ACT_WT, '0')) + TO_NUMBER(?),
       ACT_TOTL_LEN = TO_NUMBER(NVL(ACT_TOTL_LEN, '0')) + TO_NUMBER(?),
       ZOUT_FLAG    = '1',
       BILL_STATUS  = '3'
 WHERE BILL_NO = ?
   AND ORD_LN_DLY_PK = ?
	]]>
	</query>
	<query id="FrmCasOutAutomatic.updateBillM1" desc="修改提单主表状态">
	<![CDATA[
UPDATE YDM_ZC_BILL_M
   SET ACT_NUM      = '',
       ACT_WT       ='',
       ACT_TOTL_LEN = '',
       ZOUT_FLAG    = '0',
       BILL_STATUS  = '1'
 WHERE BILL_NO = ?
	]]>
	</query>
		<query id="FrmCasOutAutomatic.updateBillC1" desc="修改提单材料表装车状态">
	<![CDATA[
UPDATE YDM_ZC_BILL_C SET LOADVEHICLE_FLAG='0' ,EDIT_FLAG='0'
  WHERE BILL_NO=?
	]]>
	</query>
		<query id="FrmCasOutAutomatic.QueryStorageNo" desc="查询仓库是否虚拟库">
	<![CDATA[
SELECT S.DUMMY_FLAG,S.STORAGE_NO FROM YDM_BS_STORAGE S WHERE S.STORAGE_NO=? AND S.VALIDFLAG='1'
	]]>
	</query>
		<query id="FrmCasOutAutomatic.deleteButtress" desc="删除位置表">
	<![CDATA[
DELETE YDM_GP_BUTTRESS C
 WHERE C.MAT_NO IN ((SELECT T.MAT_NO
                      FROM YDM_ZC_BILL_C T
                     WHERE T.BILL_NO = ?  
                       AND T.MAT_NO = C.MAT_NO))
	]]>
	</query>
	<query id="FrmCasOutAutomatic.deleteOut" desc="删除出库表销售出库对应记录">
	<![CDATA[
DELETE YMD_GP_OUTLIST C
 WHERE C.OUTSTOCK_TYPE_CODE = '800805'
   AND C.MAT_NO IN ((SELECT T.MAT_NO
                    FROM YDM_ZC_BILL_C T
                   WHERE T.BILL_NO = ? 
                     AND T.MAT_NO=C.MAT_NO))
	]]>
	</query>
	<query id="FrmCasOutAutomatic.updateMatNo" desc="修改材料表材料状态">
	<![CDATA[
UPDATE MAT_GP_M C SET C.MAT_STATUS='80150303' WHERE C.MAT_NO IN ((SELECT T.MAT_NO
                    FROM YDM_ZC_BILL_C T
                   WHERE T.BILL_NO = ? 
                     AND T.MAT_NO=C.MAT_NO))
	]]>
	</query>
	<query id="FrmCasOutAutomatic.updateMatNo1" desc="修改材料表材料状态">
	<![CDATA[
UPDATE MAT_GP_M C SET C.MAT_STATUS='80150302' WHERE C.MAT_NO IN ((SELECT T.MAT_NO
                    FROM YDM_ZC_BILL_C T
                   WHERE T.BILL_NO = ? 
                     AND T.MAT_NO=C.MAT_NO))
	]]>
	</query>
	<query id="FrmCasOutAutomatic.QueryBillMNo" desc="判断可撤销直接出库提单">
	<![CDATA[
SELECT T.BILL_STATUS,
       T.BILL_TICKET_STATUS,
       T.OUTSTOCK_TICKET_STATUS,
       T.TRANSMNY_TICKET_STATUS,
       T.ZOUT_FLAG
  FROM YDM_ZC_BILL_M T
  WHERE T.BILL_NO=?
 GROUP BY T.BILL_STATUS,
          T.BILL_TICKET_STATUS,
          T.OUTSTOCK_TICKET_STATUS,
          T.TRANSMNY_TICKET_STATUS,
          T.ZOUT_FLAG
	]]>
	</query>
	<query id="FrmCasOutAutomatic.insertOutList" desc="插入出库表">
	<![CDATA[
  INSERT INTO YMD_GP_OUTLIST (OUTSTOCK_SQE, OUTSTOCK_DOC, 
    OUTSTOCK_TYPE_CODE, OUTSTOCK_TYPE_NAME, VEHICLE_NO, MAT_NO, LOT_NO, STOVE_NO, 
    JUDGE_STOVE_NO, BATCH_NO, GROUD_NO, MATERIAL_NO, MATERIAL_NAME, 
    PRODUCCODE, PRODUCNAME, JUDGE_STD_CODE, JUDGE_STD_NAME, JUDGE_GRADECODE, JUDGE_GRADENAME,  SPEC_CODE, SPEC_NAME, 
    PLINE_CODE, PLINE_NAME, ACT_DIMATER, ACT_HEIGHT, 
    ACT_LEN, ACT_LEN_MIN, ACT_LEN_MAX, ACT_COUNT, ACT_WEIGHT, ACT_THEORY_WEIGHT, 
    STORAGE_NO, LOCATION_NO, LARY_NO, LOC_NO, 
    STORAGE_ATTR, STORAGE_ATTR_NAME, STORAGE_TYPE_NO, STORAGE_TYPE_NAME, 
    MANAGEMENT_NO, MANAGEMENT_NAME, RPO_TIME, PRO_BC, PRO_BZ, OUTSTOCK_TIME, OUT_BC, 
    OUT_BZ, CREATE_NAME, CREATE_TIME, ORD_PK, ORD_LN_PK, ORD_LN_DLY_PK,ORDER_NO,ORDER_SEQ,ORDER_SEQ_NO,DEPARTMENT_CODE,DEPARTMENT_DESC,
    BELONG_CODE,BELONG_NAME,BAL_YEAR_MONTH,ACT_FIX_NUM,ACT_FIX_LEN,SEND_NUM,VSTEL,VSTEL_DESC,PRODUCT_FLAG,MAT_STATUS) VALUES (?, 
    ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
    TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, 
    ?, ?, TO_DATE(?,'YYYY-MM-DD HH24:MI:SS'), ?, ?, ?,?,?,?,?,?,?,?,?,?,?,TO_NUMBER(?),?,?,'801403','80150303')
	]]>
	</query>
</queryMap>