<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc=" 接箍合同综合信息">

	<query id="FrmJGInformation.queryJgInformation" desc="查询接箍合同综合信息">
          <![CDATA[
        select jg.ORD_LN_DLY_PK,jg.JG_ORDERNO,jg.ORDER_NO||'/'||JG.ORDER_SEQ ORDER_NO_SEQ,jg.SPEC_JG_DESC,jg.MODEL_DESC,jg.ORDERNUM NUM_JG,
  (SELECT A.ABRVITION FROM SLM_BASE_CUSTOMER A WHERE A.CUSTOMER_NO=jg.BUYER_ID) BUYER_NAME,(SELECT A.ABRVITION FROM SLM_BASE_CUSTOMER A WHERE A.CUSTOMER_NO=jg.FINAL_USER) FINAL_USER_DESC,
  decode(jg.JGORDERSTATUS,'0','待处理','1','已组订单','2','已完成') JGORDERSTATUS, JG.PRO_PLAN_ID,jg.PRDCR_NO,
  (select BASENAME from COM_BASE_INFO where BASECODE=(select max(PRDCR_DESC) from SLM_ORDER_LINE_PRDCR where PRDCR_NO=jg.PRDCR_NO and VALIDFLAG='1' and CODE_JG is null and CODE_BL is null)) PRDCR_DESC_ORD,
  (select BASENAME from COM_BASE_INFO where BASECODE=(select max(PRDCR_DESC) from SLM_ORDER_LINE_PRDCR where PRDCR_NO=jg.PRDCR_NO and VALIDFLAG='1' and CODE_JG is not null and CODE_BL is null)) PRDCR_DESC_JG,
  (select BASENAME from COM_BASE_INFO where BASECODE=(select max(PRDCR_DESC) from SLM_ORDER_LINE_PRDCR where PRDCR_NO=jg.PRDCR_NO and VALIDFLAG='1' and CODE_JG is not null and CODE_BL is not null)) PRDCR_DESC_JGL,
  d.BL_WL_DESC,d.MIN_D,d.MIN_H,d.AIMLENGTH_BL,d.PLAN_NUM,d.MATCHNUM,d.JGWT_BLREQ,decode(d.PLANSTATUS,'0','计划','1','下发','2','生产中','3','生产完成','4','取消') PLANSTATUS_GX_M,
  bl.REQ_BL_ID,bl.STEELCODE,bl.STEELNAME,bl.OUTDIAMETER,bl.WALLTHICK,bl.AIMLENGTH,bl.JGBL_REQ_WEIGHT,bl.JGBL_REQ_NUM,bl.CODE_JG_BL,
  decode(bl.PLANSTATUS,'0','待确认','1','已确认','2','下发','3','生产中','4','生产完成') PLANSTATUS_BL,JG.CODE_JG,
  t.PRODUCNAME,t.STD_NAME,t.STD_STYLE_DESC,t.STEELNAME AS ORD_STEELNAME,t.SPEC_NAME,t.MODEL_DESC AS ORD_MODEL_DESC,t.ORDER_QTY,t.ORDER_UNIT,t.ORDERWEIGHT,t.ORDERNUM,
  decode(T.PORDERSTATUS,'0','待接收','1','已接收','2','已下发','3','生产中','4','生产完成','5','缴库完成','6','发运完毕','7','结算完毕','8','合同关闭') PLANSTATUS_ORD,JG.PRO_PLAN_ID_S
 from PLN_ORDER_JG JG
 left join PLN_SALEORD t on t.ORD_LN_DLY_PK=jg.ORD_LN_DLY_PK
 left join PLN_GX_JG_M D on d.PRO_PLAN_ID=JG.PRO_PLAN_ID
 left join PLN_JG_AND_BL R on r.PRO_PLAN_ID=d.PRO_PLAN_ID
 left join PLN_PORDER_BL_REQ BL on bl.REQ_BL_ID=r.REQ_BL_ID
where 1=1  
            ]]>
	</query>

</queryMap>