Mybatis的常用优化

193 阅读1分钟
<!-- mapped statement for BgtPmAnnualDAO.query -->
<!-- 根据输入条件分页查询数据 -->
<select id="search" resultMap="bgtPmAnnualDO">
   SELECT
   <include refid="bgtPmAnnual_Some_Columns" />
   FROM bgt_pm_annual bgtPmAnnual
   <where>
      <include refid="Ext_Search" />
      <if test="bgtPmAnnual.proCodes != null and bgtPmAnnual.proCodes.size() > 0">
          AND bgtPmAnnual.pro_code in
          <foreach collection="bgtPmAnnual.proCodes" item="item"
            open="(" close=")" separator=",">
            #{item}
         </foreach>
      </if>
      <if
         test="bgtPmAnnual.processInstanceIds != null and bgtPmAnnual.processInstanceIds.size() > 0">
         and bgtPmAnnual.pro_code in
         (
         select distinct bgtBill.pro_code from
         bgt_bill as bgtBill
         where bgtBill.is_deleted = '0'
         AND
         bgtBill.mof_div_code = #{bgtPmAnnual.mofDivCode,jdbcType=VARCHAR}
         AND bgtBill.fiscal_year = #{bgtPmAnnual.fiscalYear,jdbcType=VARCHAR}
         AND bgtBill.bgt_req_stage =
         #{bgtPmAnnual.applyLink,jdbcType=VARCHAR}
         AND
         bgtBill.process_instance_id in
         <foreach collection="bgtPmAnnual.processInstanceIds" item="item"
            open="(" close=")" separator=",">
            #{item}
         </foreach>
         <if
            test="bgtPmAnnual.billTypeCodes != null and bgtPmAnnual.billTypeCodes.size() > 0">
            and bgtBill.bill_type_code in
            <foreach collection="bgtPmAnnual.billTypeCodes" item="item"
               open="(" close=")" separator=",">
               #{item}
            </foreach>
         </if>
         )
      </if>
      <if test="ew != null">
         <include refid="Common.ew" />
      </if>
      AND is_deleted = '0'
   </where>
   <!-- 排序 -->
   <if test="orderBy !=null and orderBy !='' ">
      <include refid="Common.orderBy" />
   </if>
</select>

<!-- 特殊业务加载 -->
<select id="specialFlowLoad" resultMap="bgtPmAnnualDO">
   SELECT
   <include refid="bgtPmAnnual_Some_Columns" />
   FROM bgt_pm_annual bgtPmAnnual
   <where>
      <include refid="Ext_Search" />
      <if
         test="bgtPmAnnual.processInstanceIds != null and bgtPmAnnual.processInstanceIds.size() > 0">
         and bgtPmAnnual.pro_code in
         (
         select distinct bgtBill.pro_code from
         bgt_bill as bgtBill
         where bgtBill.is_deleted = '0'
         AND
         bgtBill.mof_div_code = #{bgtPmAnnual.mofDivCode,jdbcType=VARCHAR}
         AND bgtBill.fiscal_year = #{bgtPmAnnual.fiscalYear,jdbcType=VARCHAR}
         AND bgtBill.bgt_req_stage =
         #{bgtPmAnnual.applyLink,jdbcType=VARCHAR}
         and
         bgtBill.process_instance_id in
         <foreach collection="bgtPmAnnual.processInstanceIds" item="item"
            open="(" close=")" separator=",">
            #{item}
         </foreach>
         <if
            test="bgtPmAnnual.billTypeCodes != null and bgtPmAnnual.billTypeCodes.size() > 0">
            and bgtBill.bill_type_code in
            <foreach collection="bgtPmAnnual.billTypeCodes" item="item"
               open="(" close=")" separator=",">
               #{item}
            </foreach>
         </if>
         )
      </if>
      <if test="ew != null">
         <include refid="Common.ew" />
      </if>
      AND is_deleted = '0'
   </where>
   <!-- 排序 -->
   <if test="orderBy !=null and orderBy !='' ">
      <include refid="Common.orderBy" />
   </if>
</select>

<!-- 未发起流程数据加载 -->
<select id="endAuditFlowLoad" resultMap="bgtPmAnnualDO">
   SELECT
   <include refid="bgtPmAnnual_Some_Columns" />
   FROM bgt_pm_annual bgtPmAnnual
   <where>
      <include refid="Ext_Search" />
      And exists(
      select bgtBill.id from
      bgt_bill as bgtBill
      where
      bgtBill.is_deleted = '0'
      AND bgtBill.mof_div_code =
      bgtPmAnnual.mof_div_code
      AND bgtBill.fiscal_year =
      bgtPmAnnual.fiscal_year
      AND bgtBill.bgt_req_stage =
      bgtPmAnnual.apply_link
      AND bgtBill.pro_code = bgtPmAnnual.pro_code
      AND
      bgtBill.is_end = '1'
      <if
         test="bgtPmAnnual.billTypeCodes != null and bgtPmAnnual.billTypeCodes.size() > 0">
         and bgtBill.bill_type_code in
         <foreach collection="bgtPmAnnual.billTypeCodes" item="item"
            open="(" close=")" separator=",">
            #{item}
         </foreach>
      </if>
      )
      <if test="ew != null">
         <include refid="Common.ew" />
      </if>
      AND is_deleted = '0'
   </where>
   <!-- 排序 -->
   <if test="orderBy !=null and orderBy !='' ">
      <include refid="Common.orderBy" />
   </if>
</select>

<!-- 根据业务主键查询数据并以Map<业务主键,数据>格式返回 -->
<select id="queryDataMapByBids" resultMap="bgtPmAnnualDO">
   SELECT
   <include refid="bgtPmAnnual_Some_Columns" />
   FROM bgt_pm_annual bgtPmAnnual
   <where>
      bgtPmAnnual.is_deleted = '0'
      and bgtPmAnnual.bgt_pman_id in
      <foreach collection="list" item="item" open="(" close=")"
         separator=",">
         #{item}
      </foreach>
   </where>
</select>
<select id="selectByCodes" resultMap="bgtPmAnnualDO">
   SELECT
   <include refid="bgtPmAnnual_Some_Columns" />
   FROM bgt_pm_annual bgtPmAnnual
   <where>
      bgtPmAnnual.is_deleted = '0'
      and  bgtPmAnnual.apply_link='1'
      and bgtPmAnnual.pro_code in
      <foreach collection="list" item="item" open="(" close=")"
             separator=",">
         #{item}
      </foreach>
   </where>
</select>

<update id="deleteByDominateDetailIds">
   update bgt_pm_annual set is_deleted='1',update_time=CURRENT_TIMESTAMP
   where bgt_dominate_detail_id in
   <foreach collection="list" item="item" open="(" close=")"
      separator=",">
      #{item}
   </foreach>
</update>

<select id="selectByProCodes" resultMap="bgtPmAnnualDO">
   SELECT
   <include refid="bgtPmAnnual_Some_Columns"/>
   FROM bgt_pm_annual bgtPmAnnual
   <where>
      <!-- id mysql主键id -->
      <if test="bgtPmAnnual.id !=null " >
         AND id = #{bgtPmAnnual.id,jdbcType=BIGINT,javaType=java.lang.Long}
      </if>
      <!-- 创建人 -->
      <if test="bgtPmAnnual.createBy !=null  and bgtPmAnnual.createBy!='' " >
         AND create_by = #{bgtPmAnnual.createBy,jdbcType=VARCHAR}
      </if>
      <!-- 创建人id -->
      <if test="bgtPmAnnual.createById !=null  and bgtPmAnnual.createById!='' " >
         AND create_by_id = #{bgtPmAnnual.createById,jdbcType=VARCHAR}
      </if>
      <!-- 创建时间 -->
      <if test="bgtPmAnnual.createTime !=null " >
         AND create_time = #{bgtPmAnnual.createTime,jdbcType=TIMESTAMP,javaType=java.util.Date}
      </if>
      <!-- 更新人 -->
      <if test="bgtPmAnnual.updateBy !=null  and bgtPmAnnual.updateBy!='' " >
         AND update_by = #{bgtPmAnnual.updateBy,jdbcType=VARCHAR}
      </if>
      <!-- 更新人id -->
      <if test="bgtPmAnnual.updateById !=null  and bgtPmAnnual.updateById!='' " >
         AND update_by_id = #{bgtPmAnnual.updateById,jdbcType=VARCHAR}
      </if>
      <!-- 更新时间 -->
      <if test="bgtPmAnnual.updateTime !=null " >
         AND update_time = #{bgtPmAnnual.updateTime,jdbcType=TIMESTAMP,javaType=java.util.Date}
      </if>
      <!-- 是否删除 -->
      <if test="bgtPmAnnual.isDeleted !=null  and bgtPmAnnual.isDeleted!='' " >
         AND is_deleted = #{bgtPmAnnual.isDeleted,jdbcType=VARCHAR}
      </if>
      <!-- 记录版本号 -->
      <if test="bgtPmAnnual.ver !=null " >
         AND ver = #{bgtPmAnnual.ver,jdbcType=INTEGER,javaType=java.lang.Integer}
      </if>
      <!-- 财政区划代码 -->
      <if test="bgtPmAnnual.mofDivCode !=null  and bgtPmAnnual.mofDivCode!='' " >
         AND mof_div_code = #{bgtPmAnnual.mofDivCode,jdbcType=VARCHAR}
      </if>
      <!-- 预算年度 -->
      <if test="bgtPmAnnual.fiscalYear !=null  and bgtPmAnnual.fiscalYear!='' " >
         AND fiscal_year = #{bgtPmAnnual.fiscalYear,jdbcType=VARCHAR}
      </if>
      <!-- 要素版本号 -->
      <if test="bgtPmAnnual.eleVersion !=null  and bgtPmAnnual.eleVersion!='' " >
         AND ele_version = #{bgtPmAnnual.eleVersion,jdbcType=VARCHAR}
      </if>
      <!-- 业务版本号 -->
      <if test="bgtPmAnnual.version !=null  and bgtPmAnnual.version!='' " >
         AND version = #{bgtPmAnnual.version,jdbcType=VARCHAR}
      </if>
      <!-- 版本说明 -->
      <if test="bgtPmAnnual.versionName !=null  and bgtPmAnnual.versionName!='' " >
         AND version_name = #{bgtPmAnnual.versionName,jdbcType=VARCHAR}
      </if>
      <!-- 业务主管部门 -->
      <if test="bgtPmAnnual.mgtDeptCode !=null  and bgtPmAnnual.mgtDeptCode!='' " >
         AND mgt_dept_code = #{bgtPmAnnual.mgtDeptCode,jdbcType=VARCHAR}
      </if>
      <!-- 业务处室 -->
      <if test="bgtPmAnnual.mgtMofDepCode !=null  and bgtPmAnnual.mgtMofDepCode!='' " >
         AND mgt_mof_dep_code = #{bgtPmAnnual.mgtMofDepCode,jdbcType=VARCHAR}
      </if>
      <!-- 资金业务处室 -->
      <if test="bgtPmAnnual.mofDepCode !=null  and bgtPmAnnual.mofDepCode!='' " >
         AND mof_dep_code = #{bgtPmAnnual.mofDepCode,jdbcType=VARCHAR}
      </if>
      <!-- 资金主管部门 -->
      <if test="bgtPmAnnual.deptCode !=null  and bgtPmAnnual.deptCode!='' " >
         AND dept_code = #{bgtPmAnnual.deptCode,jdbcType=VARCHAR}
      </if>
      <!-- 单位代码 -->
      <if test="bgtPmAnnual.agencyCode !=null  and bgtPmAnnual.agencyCode!='' " >
         AND agency_code = #{bgtPmAnnual.agencyCode,jdbcType=VARCHAR}
      </if>
      <!-- 项目年度预算主键 -->
      <if test="bgtPmAnnual.bgtPmanId !=null  and bgtPmAnnual.bgtPmanId!='' " >
         AND bgt_pman_id = #{bgtPmAnnual.bgtPmanId,jdbcType=VARCHAR}
      </if>
      <!-- 项目类别代码 -->
      <if test="bgtPmAnnual.proKindCode !=null  and bgtPmAnnual.proKindCode!='' " >
         AND pro_kind_code = #{bgtPmAnnual.proKindCode,jdbcType=VARCHAR}
      </if>
      <!-- 项目ID -->
      <if test="bgtPmAnnual.proId !=null  and bgtPmAnnual.proId!='' " >
         AND pro_id = #{bgtPmAnnual.proId,jdbcType=VARCHAR}
      </if>
      <!-- 项目名称 -->
      <if test="bgtPmAnnual.proName !=null  and bgtPmAnnual.proName!='' " >
         AND pro_name = #{bgtPmAnnual.proName,jdbcType=VARCHAR}
      </if>
      <!-- 项目级次 -->
      <if test="bgtPmAnnual.proLevel !=null  and bgtPmAnnual.proLevel!='' " >
         AND pro_level = #{bgtPmAnnual.proLevel,jdbcType=VARCHAR}
      </if>
      <!-- 支出功能分类科目代码 -->
      <if test="bgtPmAnnual.expFuncCode !=null  and bgtPmAnnual.expFuncCode!='' " >
         AND exp_func_code = #{bgtPmAnnual.expFuncCode,jdbcType=VARCHAR}
      </if>
      <!-- 政府支出经济分类代码 -->
      <if test="bgtPmAnnual.govBgtEcoCode !=null  and bgtPmAnnual.govBgtEcoCode!='' " >
         AND gov_bgt_eco_code = #{bgtPmAnnual.govBgtEcoCode,jdbcType=VARCHAR}
      </if>
      <!-- 部门支出经济分类代码 -->
      <if test="bgtPmAnnual.depBgtEcoCode !=null  and bgtPmAnnual.depBgtEcoCode!='' " >
         AND dep_bgt_eco_code = #{bgtPmAnnual.depBgtEcoCode,jdbcType=VARCHAR}
      </if>
      <!-- 资金性质代码 -->
      <if test="bgtPmAnnual.fundTypeCode !=null  and bgtPmAnnual.fundTypeCode!='' " >
         AND fund_type_code = #{bgtPmAnnual.fundTypeCode,jdbcType=VARCHAR}
      </if>
      <!-- 申报数 -->
      <if test="bgtPmAnnual.applyUp !=null " >
         AND apply_up = #{bgtPmAnnual.applyUp,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 财政审核数 -->
      <if test="bgtPmAnnual.finAuditMoney !=null " >
         AND fin_audit_money = #{bgtPmAnnual.finAuditMoney,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 业务主管处室代码 -->
      <if test="bgtPmAnnual.manageMofDepCode !=null  and bgtPmAnnual.manageMofDepCode!='' " >
         AND manage_mof_dep_code = #{bgtPmAnnual.manageMofDepCode,jdbcType=VARCHAR}
      </if>
      <!-- 申报环节 -->
      <if test="bgtPmAnnual.applyLink !=null  and bgtPmAnnual.applyLink!='' " >
         AND apply_link = #{bgtPmAnnual.applyLink,jdbcType=VARCHAR}
      </if>
      <!-- 年初批复数 -->
      <if test="bgtPmAnnual.replyAmt !=null " >
         AND reply_amt = #{bgtPmAnnual.replyAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 调整金额 -->
      <if test="bgtPmAnnual.adjAmt !=null " >
         AND adj_amt = #{bgtPmAnnual.adjAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 调剂金额 -->
      <if test="bgtPmAnnual.disAmt !=null " >
         AND dis_amt = #{bgtPmAnnual.disAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 变动后预算数 -->
      <if test="bgtPmAnnual.curAmt !=null " >
         AND cur_amt = #{bgtPmAnnual.curAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 预算级次代码 -->
      <if test="bgtPmAnnual.budgetLevelCode !=null  and bgtPmAnnual.budgetLevelCode!='' " >
         AND budget_level_code = #{bgtPmAnnual.budgetLevelCode,jdbcType=VARCHAR}
      </if>
      <!-- 资金来源代码 -->
      <if test="bgtPmAnnual.foundTypeCode !=null  and bgtPmAnnual.foundTypeCode!='' " >
         AND found_type_code = #{bgtPmAnnual.foundTypeCode,jdbcType=VARCHAR}
      </if>
      <!-- 新增金额 -->
      <if test="bgtPmAnnual.addAmt !=null " >
         AND add_amt = #{bgtPmAnnual.addAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 收回金额 -->
      <if test="bgtPmAnnual.backAmt !=null " >
         AND back_amt = #{bgtPmAnnual.backAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 调剂目标预算主键 -->
      <if test="bgtPmAnnual.disPlanId !=null  and bgtPmAnnual.disPlanId!='' " >
         AND dis_plan_id = #{bgtPmAnnual.disPlanId,jdbcType=VARCHAR}
      </if>
      <!-- 是否包含政府采购 -->
      <if test="bgtPmAnnual.isGovpur !=null " >
         AND is_govpur = #{bgtPmAnnual.isGovpur,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否涉及政府购买服务 -->
      <if test="bgtPmAnnual.isGovserv !=null " >
         AND is_govserv = #{bgtPmAnnual.isGovserv,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否涉及增量资产 -->
      <if test="bgtPmAnnual.isAsset !=null " >
         AND is_asset = #{bgtPmAnnual.isAsset,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否涉农资金 -->
      <if test="bgtPmAnnual.isProAgricultureFund !=null " >
         AND is_pro_agriculture_fund = #{bgtPmAnnual.isProAgricultureFund,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 支出方向代码 -->
      <if test="bgtPmAnnual.proPayDicCode !=null  and bgtPmAnnual.proPayDicCode!='' " >
         AND pro_pay_dic_code = #{bgtPmAnnual.proPayDicCode,jdbcType=VARCHAR}
      </if>
      <!-- 父级项目编码 -->
      <if test="bgtPmAnnual.parentCode !=null  and bgtPmAnnual.parentCode!='' " >
         AND parent_code = #{bgtPmAnnual.parentCode,jdbcType=VARCHAR}
      </if>
      <!-- 父级项目名称 -->
      <if test="bgtPmAnnual.parentName !=null  and bgtPmAnnual.parentName!='' " >
         AND parent_name = #{bgtPmAnnual.parentName,jdbcType=VARCHAR}
      </if>
      <!-- 业务单据id -->
      <if test="bgtPmAnnual.bgtOrderId !=null  and bgtPmAnnual.bgtOrderId!='' " >
         AND bgt_order_id = #{bgtPmAnnual.bgtOrderId,jdbcType=VARCHAR}
      </if>
      <!-- 支付方式代码 -->
      <if test="bgtPmAnnual.payTypeCode !=null  and bgtPmAnnual.payTypeCode!='' " >
         AND pay_type_code = #{bgtPmAnnual.payTypeCode,jdbcType=VARCHAR}
      </if>
      <!-- 支出类型代码 -->
      <if test="bgtPmAnnual.payBizTypeCode !=null  and bgtPmAnnual.payBizTypeCode!='' " >
         AND pay_biz_type_code = #{bgtPmAnnual.payBizTypeCode,jdbcType=VARCHAR}
      </if>
      <!-- rcid -->
      <if test="bgtPmAnnual.rcid !=null  and bgtPmAnnual.rcid!='' " >
         AND rcid = #{bgtPmAnnual.rcid,jdbcType=VARCHAR}
      </if>
      <!-- 流程实例id -->
      <if test="bgtPmAnnual.processInstanceId !=null  and bgtPmAnnual.processInstanceId!='' " >
         AND process_instance_id = #{bgtPmAnnual.processInstanceId,jdbcType=VARCHAR}
      </if>
      <!-- 是否三保预算 -->
      <if test="bgtPmAnnual.isThrSec !=null " >
         AND is_thr_sec = #{bgtPmAnnual.isThrSec,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否提前下达 -->
      <if test="bgtPmAnnual.isAdvand !=null " >
         AND is_advand = #{bgtPmAnnual.isAdvand,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否终审 -->
      <if test="bgtPmAnnual.isEnd !=null " >
         AND is_end = #{bgtPmAnnual.isEnd,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 下级财政区划代码 -->
      <if test="bgtPmAnnual.subMofDivCode !=null  and bgtPmAnnual.subMofDivCode!='' " >
         AND sub_mof_div_code = #{bgtPmAnnual.subMofDivCode,jdbcType=VARCHAR}
      </if>
      <!-- 提前下达金额 -->
      <if test="bgtPmAnnual.advandAmt !=null " >
         AND advand_amt = #{bgtPmAnnual.advandAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 提前下达文号 -->
      <if test="bgtPmAnnual.supBgtDocNo !=null  and bgtPmAnnual.supBgtDocNo!='' " >
         AND sup_bgt_doc_no = #{bgtPmAnnual.supBgtDocNo,jdbcType=VARCHAR}
      </if>
      <!-- 是否扶贫资金 -->
      <if test="bgtPmAnnual.isPovery !=null " >
         AND is_povery = #{bgtPmAnnual.isPovery,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否纳入部门预算 -->
      <if test="bgtPmAnnual.isDepbgt !=null " >
         AND is_depbgt = #{bgtPmAnnual.isDepbgt,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否已批复 -->
      <if test="bgtPmAnnual.isApproval !=null " >
         AND is_approval = #{bgtPmAnnual.isApproval,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 是否已下达预算 -->
      <if test="bgtPmAnnual.isIssuebgt !=null " >
         AND is_issuebgt = #{bgtPmAnnual.isIssuebgt,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 业务单据类型代码 -->
      <if test="bgtPmAnnual.bizTypeCode !=null  and bgtPmAnnual.bizTypeCode!='' " >
         AND biz_type_code = #{bgtPmAnnual.bizTypeCode,jdbcType=VARCHAR}
      </if>
      <!-- 转移支付功能分类科目代码 -->
      <if test="bgtPmAnnual.tpFuncCode !=null  and bgtPmAnnual.tpFuncCode!='' " >
         AND tp_func_code = #{bgtPmAnnual.tpFuncCode,jdbcType=VARCHAR}
      </if>
      <!-- 预算金额 -->
      <if test="bgtPmAnnual.bgtAmt !=null " >
         AND bgt_amt = #{bgtPmAnnual.bgtAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 可下达金额 -->
      <if test="bgtPmAnnual.enableIssueAmt !=null " >
         AND enable_issue_amt = #{bgtPmAnnual.enableIssueAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 已批复金额 -->
      <if test="bgtPmAnnual.rescriptumAmt !=null " >
         AND rescriptum_amt = #{bgtPmAnnual.rescriptumAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- OA是否已获取 -->
      <if test="bgtPmAnnual.isObtain !=null " >
         AND is_obtain = #{bgtPmAnnual.isObtain,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 项目入库状态 -->
      <if test="bgtPmAnnual.publishStatus !=null " >
         AND publish_status = #{bgtPmAnnual.publishStatus,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 项目生效数 -->
      <if test="bgtPmAnnual.effectiveAmt !=null " >
         AND effective_amt = #{bgtPmAnnual.effectiveAmt,jdbcType=DECIMAL,javaType=java.math.BigDecimal}
      </if>
      <!-- 当业务单据类型代码=01本级项目支出预算表或02转移支付预算表时,该字段为对应一级项目支出预算的预算主键 -->
      <if test="bgtPmAnnual.bgtParentId !=null  and bgtPmAnnual.bgtParentId!='' " >
         AND bgt_parent_id = #{bgtPmAnnual.bgtParentId,jdbcType=VARCHAR}
      </if>
      <!-- 控制数明细业务主键ID(控制数下发时,会填写) -->
      <if test="bgtPmAnnual.bgtDominateDetailId !=null  and bgtPmAnnual.bgtDominateDetailId!='' " >
         AND bgt_dominate_detail_id = #{bgtPmAnnual.bgtDominateDetailId,jdbcType=VARCHAR}
      </if>
      <!-- 是否为重点项目 1:是 0:否 -->
      <if test="bgtPmAnnual.isEmphasisProject !=null " >
         AND is_emphasis_project = #{bgtPmAnnual.isEmphasisProject,jdbcType=SMALLINT,javaType=java.lang.Short}
      </if>
      <!-- 一级项目编码 -->
      <if test="bgtPmAnnual.proCodeLevelOne !=null  and bgtPmAnnual.proCodeLevelOne!='' " >
         AND pro_code_level_one = #{bgtPmAnnual.proCodeLevelOne,jdbcType=VARCHAR}
      </if>
      <!-- 二级项目编码 -->
      <if test="bgtPmAnnual.proCodeLevelTwo !=null  and bgtPmAnnual.proCodeLevelTwo!='' " >
         AND pro_code_level_two = #{bgtPmAnnual.proCodeLevelTwo,jdbcType=VARCHAR}
      </if>

      <!-- 项目代码 -->
      <if test="bgtPmAnnual.proCode !=null  and bgtPmAnnual.proCode!='' " >
         AND pro_code = #{bgtPmAnnual.proCode,jdbcType=VARCHAR}
      </if>

      <if test="list != null and list.size() > 0">
         and pro_code in
         <foreach collection="list" item="item" open="(" close=")" separator=",">
            #{item}
         </foreach>
      </if>
      and is_deleted = '0'
   </where>
</select>

<!-- 根据条件查询满足条件的数据条数 -->
<select id="queryCountByCondition" resultType="java.lang.Integer">
   select count(id)
   FROM bgt_bill
   where is_deleted='0' and fiscal_year=#{param.fiscalYear} and
   mof_div_code=#{param.mofDivCode}
   and bill_type_code=#{param.billTypeCode}
   <if test="param.mofDepCode != null and param.mofDepCode != ''">
      and mof_dep_code = #{param.mofDepCode}
   </if>
   <if test="param.mgtMofDepCode != null and param.mgtMofDepCode != ''">
      and mgt_mof_dep_code = #{param.mgtMofDepCode}
   </if>
   <if test="param.deptCode != null and param.deptCode != ''">
      and dept_code = #{param.deptCode}
   </if>
   <if test="param.mgtDeptCode != null and param.mgtDeptCode != ''">
      and mgt_dept_code = #{param.mgtDeptCode}
   </if>
   <if test="param.agencyCode != null and param.agencyCode != ''">
      and agency_code = #{param.agencyCode}
   </if>
   <if test="param.proCode != null and param.proCode != ''">
      and pro_code = #{param.proCode}
   </if>
   <if test="param.bgtReqStage != null and param.bgtReqStage != ''">
      and bgt_req_stage = #{param.bgtReqStage}
   </if>
   <if test="param.bgtReportCode != null and param.bgtReportCode != ''">
      and bgt_report_code = #{param.bgtReportCode}
   </if>
   <if
      test="param.processInstanceIds != null and param.processInstanceIds.size() > 0">
      and process_instance_id in
      <foreach collection="param.processInstanceIds" item="item"
         open="(" close=")" separator=",">
         #{item}
      </foreach>
   </if>
</select>