<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="装车实绩管理sql">
	
	
	<query id="FrmPipeLoad.updateDelivery" desc="修改发货实绩表信息">
		<![CDATA[
		UPDATE YDM_ZC_LOADVEHICLE SET 
		  VEHICLE_NO=?,
		  INFACTORY_TIME=to_date(?,'YYYY-MM-DD HH24:MI:SS'),
		  DELIVY_TIME=to_date(?,'YYYY-MM-DD HH24:MI:SS'),
		  MEMO=?
		WHERE LOADVEHICLE_NO=?
		   AND VALIDFLAG='1'
     	]]>
	</query>
	<query id="FrmCasLoad.updateDelConfirm" desc="修改发货实绩表信息确认">
		<![CDATA[
		UPDATE YDM_ZC_LOADVEHICLE SET AFFIRM_FLAG='1' WHERE LOADVEHICLE_NO= ? AND VALIDFLAG='1'
     	]]>
	</query>
	<query id="FrmCasLoad.updateDelCancel" desc="修改发货实绩表信息取消确认">
		<![CDATA[
		UPDATE  ydm_zc_loadvehicle SET AFFIRM_FLAG='0' WHERE LOADVEHICLE_NO= ? AND VALIDFLAG='1'
     	]]>
	</query>
	<query id="FrmCasLoad.updateMatConfirm" desc="修改发货材料表信息确认标志">
		<![CDATA[
		UPDATE  ydm_zc_loadvehicle_mat SET VALIDFLAG='2' WHERE LOADVEHICLE_NO= ?
     	]]>
	</query>
	<query id="FrmCasLoad.updateMatCancel" desc="修改发货材料表信息取消确认标志">
		<![CDATA[
		UPDATE  ydm_zc_loadvehicle_mat SET VALIDFLAG='1' WHERE LOADVEHICLE_NO= ?
     	]]>
	</query>
	<query id="FrmCasLoad.queryAppFlag" desc="查询确认标志">
	<![CDATA[
    select T.AFFIRM_FLAG  from YDM_ZC_LOADVEHICLE t where T.LOADVEHICLE_NO=?
	]]>
	</query>
	<query id="FrmCasLoad.queryVelFalg" desc="查询结算标志">
	<![CDATA[
    SELECT T.VALIDFLAG,T.LOADVEHICLE_NO FROM YDM_ZC_LOADVEHICLE_MAT T WHERE T.LOADVEHICLE_NO=?
	]]>
	</query>
	
	<query id="FrmCasLoad.QueryBillType" desc="查询提单表状态">
	<![CDATA[
	SELECT T.BILL_STATUS FROM YDM_ZC_BILL_M T WHERE T.BILL_NO=? AND T.VALIDFLAG='1'
     ]]>
	</query>
	<query id="FrmCasLoad.queryTallPond" desc="确认查询是否输入过磅单号，过磅重量">
	<![CDATA[
SELECT T.PONDER_NO,T.LOADVEHICLE_NO
  FROM YDM_ZC_LOADVEHICLE_MAT T
 WHERE T.PONDER_NO = ?
   AND T.VALIDFLAG = '1'
   Group by T.PONDER_NO,T.LOADVEHICLE_NO
     ]]>
	</query>
	<query id="FrmCasLoad.queryTallPond1" desc="确认查询是否输入过磅单号，过磅重量">
	<![CDATA[
SELECT MIN(T.PONDER_NO) AS PONDER_NO, MIN(T.PONDER_GROSS_WT) AS PONDER_GROSS_WT
  FROM YDM_ZC_LOADVEHICLE_MAT T
 WHERE T.LOADVEHICLE_NO = ?
   AND T.BILL_NO = ?
   AND T.TALLYSHEET_NO = ?
   AND T.VEHICLE_NO = ?
     ]]>
	</query>
	<query id="FrmCasLoad.queryLoadMatNo" desc="查询装车单号向下材料号">
	<![CDATA[
	SELECT VEHICLE_NO,
       ORDER_NO,
       ORDER_SEQ,
       ORDER_SEQ_NO,
       MAT_NO,
       LOT_NO,
       JUDGE_STOVE_NO,
       BATCH_NO,
       GROUP_NO           AS BATCH_GROUD_NO,
       STOVE_NO,
       MATERIAL_NO,
       MATERIAL_NAME,
       PRODUCCODE,
       PRODUCNAME,
       STD_CODE,
       STD_NAME,
       GRADECODE,
       GRADENAME,
       STEELCODE,
       STEELNAME,
       STD_STYLE,
       STD_STYLE_DESC,
       SPEC_CODE,
       SPEC_NAME,
       MODEL_CODE,
       MODEL_DESC,
       PROCESS_CDOE,
       PROCESS_DESC,
       PLINE_CODE,
       PLINE_NAME,
       ACT_DIMATER,
       ACT_HEIGHT,
       ACT_LEN,
       ACT_LEN_MIN,
       ACT_LEN_MAX,
       ACT_COUNT,
       ACT_WEIGHT,
       ACT_THEORY_WEIGHT,
       PRO_BC,
       PRO_BZ,
       RPO_TIME,
       SALE_ORG           AS BELONG_CODE,
       SALE_ORG_DESC      AS BELONG_NAME,
       STORAGE_TYPE_NO,
       STORAGE_TYPE_NAME,
       MANAGEMENT_NO,
       MANAGEMENT_NAME,
       STORAGE_NO,
       LOCATION_NO,
       LARY_NO,
       LOC_NO,
       TRANS_TPE,
       RECEIV_NO,
       RECEIV_NM,
       STATION_NO,
       STATION_NM,
       SPCL_LN_NO,
       SPCL_LN_NM,
       PLANT,
       PLANT_DESC,
       VSTEL,
       VSTEL_DESC,
       CARRY_COMPANY_CODE,
       CARRY_COMPANY_NAME,
       OUT_STOCK_CODE,
       DELIVY_PLACE_CODE,
       DELIVY_PLACE_NAME,
       STLMT_UNIT_NO,
       STLMT_UNIT_NM,
       ORD_PK,
       ORD_LN_PK,
       ORD_LN_DLY_PK,
       DEPARTMENT_CODE,
       DEPARTMENT_DESC,
       PONDER_NO,
       PONDER_GROSS_WT,
       JUDGE_STD_NAME,
       JUDGE_STD_CODE,
       SEND_NUM,
       ACT_FIX_NUM,
       ACT_FIX_LEN
  FROM YDM_ZC_LOADVEHICLE_MAT
  WHERE LOADVEHICLE_NO = ?
  AND BILL_NO = ?
  AND TALLYSHEET_NO = ?
  AND VEHICLE_NO = ?
 ORDER BY MAT_NO ASC
     ]]>
	</query>
	<query id="FrmCasLoad.updateOutPondWt" desc="修改出库表过磅重量">
	<![CDATA[
UPDATE YMD_GP_OUTLIST T SET T.PONDER_NO=?, T.PONDER_GROSS_WT=TO_NUMBER(?) WHERE T.OUTSTOCK_TYPE_CODE=? AND T.MAT_NO=?
     ]]>
	</query>
	<query id="FrmCasLoad.updateMatZcNo" desc="修改材料表过磅重量">
	<![CDATA[
    UPDATE MAT_GP_M T SET T.MAT_STATUS='80150303', T.PONDER_NO=?, T.PONDER_GROSS_WT=TO_NUMBER(?) WHERE T.MAT_NO=?
     ]]>
	</query>
	<query id="FrmCasLoad.updateMatZcNo1" desc="修改材料表过磅重量">
	<![CDATA[
    UPDATE MAT_GP_M T SET T.MAT_STATUS='80150302', T.PONDER_NO=?, T.PONDER_GROSS_WT=TO_NUMBER(?) WHERE T.MAT_NO=?
     ]]>
	</query>
	<query id="FrmCasLoad.insertOutList" desc="插入出库表">
	<![CDATA[
	INSERT INTO YMD_GP_OUTLIST (OUTSTOCK_SQE,OUTSTOCK_DOC, 
OUTSTOCK_TYPE_CODE, OUTSTOCK_TYPE_NAME, VEHICLE_NO, MAT_NO, MAT_SQE_NO, 
PRODUCT_FLAG, MAT_STATUS, STOVE_NO, FLAG_STOVE_NO, LOT_NO, JUDGE_STOVE_NO, 
BATCH_NO, CAST_NO, CCMID, SAMPLE_FLAG, CUTTING_FLAG, CUTTING_NUM, MATERIAL_NO, 
MATERIAL_NAME, PRODUCCODE, PRODUCNAME, JUDGE_GRADECODE, JUDGE_GRADENAME, 
JUDGE_STD_CODE, JUDGE_STD_NAME, ACT_DIMATER, ACT_HEIGHT, ACT_LEN, ACT_LEN_MIN, 
ACT_LEN_MAX, ACT_FIX_NUM, ACT_FIX_LEN, ACT_COUNT, ACT_WEIGHT, ACT_THEORY_WEIGHT, 
PONDER_NO, PONDER_GROSS_WT, PLINE_CODE, PLINE_NAME, PRO_ORDER_NO, PRO_ORDER_NO1, 
PRO_ORDER_ID, PRO_ORDER_ID1, ORDER_NO, ORDER_SEQ, ORDER_SEQ_NO, ORD_PK, 
ORD_LN_PK, ORD_LN_DLY_PK, BELONG_CODE, BELONG_NAME, BAR_CODE, STORAGE_NO, 
LOCATION_NO, LARY_NO, LOC_NO, DEPARTMENT_CODE, DEPARTMENT_DESC, MANAGEMENT_NO, 
MANAGEMENT_NAME, VSTEL, VSTEL_DESC, RPO_TIME, PRO_BC, PRO_BZ, OUTSTOCK_TIME, 
OUT_BC, OUT_BZ, STORAGE_ATTR, STORAGE_ATTR_NAME, STORAGE_TYPE_NO, 
STORAGE_TYPE_NAME, CREATE_NAME, CREATE_TIME, GROUD_NO, SEND_NUM) 
 SELECT ?,?, ?, ?, ?, T.MAT_NO, T.MAT_SQE_NO, 
T.PRODUCT_FLAG, T.MAT_STATUS, T.STOVE_NO, T.FLAG_STOVE_NO, T.LOT_NO, 
T.JUDGE_STOVE_NO, T.BATCH_NO, T.CAST_NO, T.CCMID, T.SAMPLE_FLAG, T.CUTTING_FLAG, 
T.CUTTING_NUM, T.MATERIAL_NO, T.MATERIAL_NAME, T.PRODUCCODE, T.PRODUCNAME, 
T.JUDGE_GRADECODE, T.JUDGE_GRADENAME, T.JUDGE_STD_CODE, T.JUDGE_STD_NAME, 
T.ACT_DIMATER, T.ACT_HEIGHT, T.ACT_LEN, T.ACT_LEN_MIN, T.ACT_LEN_MAX, 
T.ACT_FIX_NUM, T.ACT_FIX_LEN, T.ACT_COUNT, T.ACT_WEIGHT, T.ACT_THEORY_WEIGHT, ?, 
TO_NUMBER(?), T.PLINE_CODE, T.PLINE_NAME, T.PRO_ORDER_NO, T.PRO_ORDER_NO1, 
T.PRO_ORDER_ID, T.PRO_ORDER_ID1, ?, ?, ?, T.ORD_PK, T.ORD_LN_PK, 
T.ORD_LN_DLY_PK, ?,?, T.BAR_CODE, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, T.RPO_TIME, T.PRO_BC, T.PRO_BZ, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), ?, 
?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS'), T.GROUD_NO, TO_NUMBER(?) FROM MAT_GP_M T WHERE T.MAT_NO=?
	]]>
	</query>
		<query id="FrmCasLoad.deleteButtress" desc="删除位置表">
	<![CDATA[
DELETE YDM_GP_BUTTRESS C
 WHERE C.MAT_NO IN ((SELECT T.MAT_NO
                      FROM YDM_ZC_LOADVEHICLE_MAT T
                     WHERE T.BILL_NO = ?
                       AND T.LOADVEHICLE_NO = ?
                       AND T.TALLYSHEET_NO = ?
                       AND T.VEHICLE_NO = ?
                       AND T.MAT_NO = C.MAT_NO))

	]]>
	</query>
	<query id="FrmCasLoad.queryBillCFlag" desc="查询提单是否过磅">
	<![CDATA[
  SELECT T.PRT_FLAG
  FROM YDM_ZC_BILL_C T
 WHERE T.BILL_NO = ?
   AND T.ORD_LN_DLY_PK = ?
 GROUP BY T.PRT_FLAG
     ]]>
	</query>
	<query id="FrmCasLoad.queryOutBill" desc="查询出库表是否有记录">
	<![CDATA[
SELECT T.MAT_NO
  FROM YMD_GP_OUTLIST T
 WHERE T.MAT_NO=?
   AND T.OUTSTOCK_TYPE_CODE = '800805'
     ]]>
	</query>
	<query id="FrmPipeEntruck.updateOut" desc="修改出库表过磅信息">
	<![CDATA[
UPDATE YDM_GP_OUTLIST T SET T.PONDER_NO=?,T.PONDER_GROSS_WT=TO_NUMBER(?)
 WHERE T.MAT_NO=?
   AND T.OUTSTOCK_TYPE_CODE = '800805'
     ]]>
	</query>
		<query id="FrmCasLoad.updatProOrd" desc="确认回写进程">
	<![CDATA[
UPDATE PROCESS_ORDER_M T
   SET T.OUT_NUM = NVL(TO_NUMBER(T.OUT_NUM), 0) + TO_NUMBER(?),
       T.OUT_WGT = NVL(TO_NUMBER(T.OUT_WGT), 0) + TO_NUMBER(?)
 WHERE ORD_LN_DLY_PK = ?
     ]]>
	</query>
		<query id="FrmCasLoad.deleteProOrd" desc="取消确认回写进程">
	<![CDATA[
UPDATE PROCESS_ORDER_M T
   SET T.OUT_NUM = NVL(TO_NUMBER(T.OUT_NUM), 0) - TO_NUMBER(?),
       T.OUT_WGT = NVL(TO_NUMBER(T.OUT_WGT), 0) - TO_NUMBER(?)
 WHERE ORD_LN_DLY_PK = ?
     ]]>
	</query>
	<query id="FrmCasLoad.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="FrmCasLoad.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_LOADVEHICLE_MAT T
                   WHERE T.BILL_NO = ?
                     AND T.LOADVEHICLE_NO = ?
                     AND T.TALLYSHEET_NO = ?
                     AND T.VEHICLE_NO = ?
                     AND T.MAT_NO=C.MAT_NO))
	]]>
	</query>
</queryMap>