<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="合同法务评审界面查询">
  <query id="CoreOrderReviewLaw.CoreOrderReviewLawQuery" desc="合同法务评审信息">
        <![CDATA[
             SELECT B3.ORDER_NO,B3.CUSTM_ORDER_NO,B3.REVIEW_F_RS,B3.ORD_PK,
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.ORDER_TYP) ORDER_TYP,
            B3.SALE_AREA_DESC SALE_AREA_NO,
            B3.ORDER_YEAR,B3.SIGN_DATE,B3.SIGN_ADDRESS,
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.SUPPLY_UNIT) SUPPLY_UNIT,
            (SELECT CUSTOMER_NM FROM SLM_BASE_CUSTOMER  WHERE  CUSTOMER_NO = B3.STLMT_UNIT_NO) STLMT_UNIT_NO,
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.MNY_ASK_TYP) MNY_ASK_TYP,
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.CURRENCY) CURRENCY,
      (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.ORDER_STS) ORDER_STS,CLOSE_TIME,
      B3.EFFECT_TIME,B3.APPROVAL_TIME,B3.DELETE_TIME,B3.DELETE_NAME,B3.UPDATE_TIME,B3.UPDATE_NAME,
      B3.CREATE_TIME,B3.CREATE_NAME,
      decode(B3.VALIDFLAG,'1','有效','0','无效') VALIDFLAG,
      B3.ORDER_MODEL_DESC ORDER_MODEL_NO,
            B3.MNY_ASK_DESC,B3.MANAG_NO,
            B3.CUSTOMER_NM CUSTOMER_NO,
             B3.MEMO,
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.FST_DRAWEE_UNIT) FST_DRAWEE_UNIT,
            (SELECT BASENAME FROM COM_BASE_INFO WHERE BASECODE = B3.PRICE_FL) PRICE_FL,
            B3.CUSTOMER_MODEL_FL,B3.REVIEW_ITM,B3.REVIEW_STATUS
            FROM (SELECT B1.REVIEW_F_RS,B1.REVIEW_ITM, B1.REVIEW_STATUS, B.*
            FROM SLM_ORDER_HEAD B, SLM_ORDER_REVIEW_ITEM_LIST B1
           WHERE 1 = 1
             AND B.ord_pk = B1.LIST_PK_VAL
             AND B1.REVIEW_ITM = 'F'
             and b1.is_curt_review = '1') B3,
    (select t4.ord_pk from (select  t3.ord_pk from (SELECT t2.ord_pk, COUNT(*) COUNT1
        FROM SLM_ORDER_REVIEW_ITEM_LIST T1, SLM_ORDER_HEAD T2
       WHERE t2.ord_pk = t1.list_pk_val
         AND T1.Review_Status = 'S'
         AND T1.REVIEW_ITM = 'D' group by t2.ord_pk) t3 where t3.count1 > 0) t4,
         (select  t3.ord_pk from (SELECT t2.ord_pk, COUNT(*) COUNT1
        FROM SLM_ORDER_REVIEW_ITEM_LIST T1, SLM_ORDER_HEAD T2
       WHERE T1.LIST_PK_VAL = T2.ord_pk
         AND T1.Review_Status = 'S'
         AND T1.REVIEW_ITM = 'T' group by t2.ord_pk) t3 where t3.count1 > 0) t5 where t4.ord_pk = t5.ord_pk) B4
         where B3.ord_pk = B4.ord_pk

        ]]>
    </query>
    <query id="CoreOrderReviewLaw.appStatus" desc="评审状态信息">
        <![CDATA[
            SELECT BASENAME,BASECODE FROM COM_BASE_INFO WHERE BASECODE  in ('120211','120222','120223')
        ]]>
    </query>
     <query id="CoreOrderReviewLaw.ordermodelQuery" desc="合同条目信息">
        <![CDATA[
            select MODEL_SEQ,MODEL_ITM from SLM_ORDER_MODEL_ITEM WHERE order_model_no = (SELECT ORDER_MODEL_NO
          FROM SLM_ORDER_MODEL_HEAD
         WHERE  ORDER_MODEL_DESC = ?)
        ]]>
    </query>
    <query id="CoreOrderReviewLaw.appWorkAdd" desc="合同法务评审合同头信息">
        <![CDATA[
            update SLM_ORDER_HEAD set order_sts = '12020210',order_sts_desc = '评审通过',APPROVAL_MAN = ?,APPROVAL_TIME = sysdate,UPDATE_NAME= ? , UPDATE_TIME = sysdate where ORD_PK = ?
        ]]>
    </query>
     <query id="CoreOrderReviewLaw.appWorkAdd2" desc="合同法务评审评审主表">
        <![CDATA[
            update SLM_ORDER_REVIEW set REVIEW_STATUS = 'S',UPDATE_NAME = ?,UPDATE_TIME = sysdate where ORD_PK = ?
        ]]>
    </query>
    <query id="CoreOrderReviewLaw.appWorkAdd3" desc="合同法务评审评审项目表">
        <![CDATA[
            update SLM_ORDER_REVIEW_ITEM set REVIEW_STATUS = 'S',UPDATE_NAME= ?,CREATE_TIME = sysdate where REVIEW_NO = 
            (select t.REVIEW_NO from SLM_ORDER_REVIEW t where t.ORD_PK = ?) and REVIEW_ITM = 'F'
        ]]>
    </query>
     <query id="CoreOrderReviewLaw.appWorkAdd4" desc="合同法务评审评审项目明细表">
        <![CDATA[
            update SLM_ORDER_REVIEW_ITEM_LIST set REVIEW_STATUS = 'S',REVIEW_F_RS = '',REVIEW_MAN = ?,UPDATE_NAME = ?,UPDATE_TIME = sysdate where LIST_PK_VAL = ?
        ]]>
    </query>
    <query id="CoreOrderReviewLaw.appWorkUpdate" desc="合同法务评审不通过业务修改合同主表">
        <![CDATA[
            update SLM_ORDER_HEAD set order_sts = '12020211',order_sts_desc = '评审失败',APPROVAL_MAN = '',APPROVAL_TIME = '',UPDATE_NAME= '' , UPDATE_TIME = '' where ord_pk = ?
        ]]>
    </query>
    <query id="CoreOrderReviewLaw.appWorkUpdate2" desc="合同法务评审不通过业务填写不合格原因">
        <![CDATA[
            update SLM_ORDER_REVIEW_ITEM_LIST set REVIEW_F_RS = ?,review_status = 'F',REVIEW_MAN = '',UPDATE_NAME = '',UPDATE_TIME = ''  where list_pk_val = ? and review_itm = 'F'
        ]]>
    </query>
     <query id="CoreOrderReviewLaw.appWorkUpdate3" desc="合同法务评审不通过写评审主表">
        <![CDATA[
            update SLM_ORDER_REVIEW set REVIEW_STATUS = 'F',UPDATE_NAME = '',UPDATE_TIME = '' where ord_pk = ?
        ]]>
    </query>
     <query id="CoreOrderReviewLaw.appWorkUpdate4" desc="合同法务评审不通过写评审项目表">
        <![CDATA[
            update SLM_ORDER_REVIEW_ITEM set REVIEW_STATUS = 'F',UPDATE_NAME= '',CREATE_TIME = '' where REVIEW_NO = 
            (select t.REVIEW_NO from SLM_ORDER_REVIEW t where ord_pk = ?) and REVIEW_ITM = 'F'
        ]]>
    </query>
    <query id="CoreOrderReviewLaw.customerdbQuery" desc="根据客户名称显示客户信息">
        <![CDATA[
            select (select basename from com_base_info where basecode = t.CUSTM_CTGRY) CUSTM_CTGRY,
       (select basename from com_base_info where basecode = t.CUSTM_PRPTY) CUSTM_PRPTY,
       (select basename from com_base_info where basecode = t.CUSTM_LVL) CUSTM_LVL,
       t.MEMO,
       t.LEGAL_PSN,
       t.AGENT,
       t.TAX_ID,
       t.BIGAREA,
       (select region_nm from sel_admin_region where region_no = t.REGION_NO) REGION_NO,
       t.ADDRESS,
       t.BANK,
       t.ACCOUNT,
       t.SALE_ORG,
       t.ZIP_CODE,
       t.PHONE,
       t.FAX,
       t1.customer_nm,
       (select basename from com_base_info where basecode = t1.market_sys) market_sys
  from SLM_BASE_ORDER_UNIT t, SLM_BASE_CUSTOMER t1
 where t.customer_no = t1.customer_no
   and t1.customer_nm = ?

        ]]>
    </query>
</queryMap>