<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="备料物料调整">
	<query id="CorePlnBlReqOrd.queryBlOrder" desc="查询备料">
		SELECT T.ORD_LN_DLY_PK,
		       T.PLN_DIVIDE_ID,
		       T.ORDER_SOURCE,
		       T.ORDER_NO,
		       T.ORDER_SEQ,
		       T.DELIVERY_NO,
		       T.PSC,
		       T.CRAFT_FILE_NO,
		       T.CRAFT_FILE_MAN,
		       T.MSC,
		       T.INDEX_SEQ,
		       T.PROCESS_SEQ,
		       T.BOM,
		       T.GRADECODE_ALL,
		       (SELECT A.GRADENAME
		          FROM COM_BASE_GRADE A
		         WHERE A.GRADECODE = T.GRADECODE) GRADECODE,
		       T.GROUP_JGX,
		       T.GROUP_RCL,
		       T.GROUP_ROLL_ALL,
		       (SELECT A.PLINE_NAME
		          FROM COM_BASE_PLINE A
		         WHERE A.PLINE_CODE = T.GROUP_ROLL) GROUP_ROLL,
		       T.BJ_TYPE,
		       T.E_IN_MATERIAL_NO,
		       T.E_IN_MATERIAL_DESC,
		       T.DIMATER_YLG,
		       T.HEIGHT_YLG,
		       T.MATERIAL_NO,
		       T.MATERIAL_DESC,
		       T.STUFF_PROPERTY,
		       T.WEIGHT_PER_M,
		       T.PLAN_WT_D,
		       T.PLAN_NUM_D,
		       DECODE(T.PLANSTATUS,
		              '1',
		              '计划',
		              '2',
		              '已下发',
		              '3',
		              '生产中',
		              '4',
		              '生产完成',
		              '5',
		              '关闭',
		              '6',
		              '取消') PLANSTATUS,
		       TO_CHAR(T.ISSUED_TIME, 'YYYY-MM-DD HH24:MI:SS') ISSUED_TIME,
		       T.ISSUED_MAN,
		       DECODE(T.F_IS_OK, '0', '否', '1', '是', '2', '/') F_IS_OK,
		       DECODE(T.IF_ALLOW_ISSUE, '0', '否', '1', '是') IF_ALLOW_ISSUE,
		       DECODE(T.G_IS_OK, '0', '否', '1', '是', '2', '/') G_IS_OK,
		       DECODE(T.GRADECODE_IS_OK, '0', '否', '1', '是') GRADECODE_IS_OK,
		       DECODE(T.D_IS_OK, '0', '否', '1', '是', '2', '/') D_IS_OK,
		       DECODE(T.E_IS_OK, '0', '否', '1', '是', '2', '/') E_IS_OK,
		       T1.REQ_BL_ID,
		       T1.JG_ORDERNO,
		       T1.STEELCODE,
		       T1.STEELNAME,
		       T1.OUTDIAMETER,
		       T1.WALLTHICK,
		       T1.AIMWALLTHICK,
		       T1.LENGTHMAX,
		       T1.LENGTHMIN,
		       T1.AIMLENGTH,
		       T1.CODE_DJ_BL,
		       T1.CODE_JG_BL,
		       T1.STD_CODE,
		       T1.STD_NAME,
		       T1.SINGLEWEIGHT,
		       T1.JGBL_REQ_WEIGHT,
		       T1.JGBL_REQ_NUM,
		       T1.MATCHWEIGHT,
		       T1.MATCHNUM,
		       T1.CREATE_NAME,
		       TO_CHAR(T1.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
		       T1.UPDATE_NAME,
		       TO_CHAR(T1.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
		       DECODE(T1.SPEC_SAME_SALE, '1', '相同', '0', '不同')
		  FROM PLN_SALEORD_PROC T, PLN_PORDER_BL_REQ T1
		 WHERE T.ORD_LN_DLY_PK = T1.REQ_BL_ID
		   AND T.PLN_DIVIDE_ID = 
		       (SELECT MIN(B.PLN_DIVIDE_ID)
		          FROM PLN_SALEORD_PROC B
		         WHERE B.ORD_LN_DLY_PK = T1.REQ_BL_ID
		           AND B.ORDER_SOURCE = '销售合同')
		   AND T.ORD_LN_DLY_PK LIKE '%' || ? || '%'
		   AND T.PLANSTATUS LIKE '%' || ? || '%'
		   AND T1.BLTYPE LIKE '%' || ? || '%'
	</query>
</queryMap>
