123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.imed.costaccount.mapper.CostCostingGroupMapper">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.imed.costaccount.model.CostCostingGroup" id="costCostingGroupMap">
- <result property="id" column="id"/>
- <result property="departmentCode" column="department_code"/>
- <result property="departmentName" column="department_name"/>
- <result property="responsibilityCode" column="responsibility_code"/>
- <result property="responsibilityName" column="responsibility_name"/>
- <result property="otherResponsibilityCode" column="other_responsibility_code"/>
- <result property="otherResponsibilityName" column="other_responsibility_name"/>
- <result property="productCode" column="product_code"/>
- <result property="productName" column="product_name"/>
- <result property="accountCode" column="account_code"/>
- <result property="accountName" column="account_name"/>
- <result property="amount" column="amount"/>
- <result property="hospId" column="hosp_id"/>
- <result property="fileId" column="file_id"/>
- <result property="afterCostGroup" column="after_cost_group"/>
- <result property="dateYear" column="date_year"/>
- <result property="dateMonth" column="date_month"/>
- <result property="createTime" column="create_time"/>
- <result property="deleteTime" column="delete_time"/>
- </resultMap>
- <select id="queryStartAllocation" resultType="com.imed.costaccount.model.vo.CostingGroupStartVO">
- select
- ccg.id as id,
- ccg.date_year as year,
- ccg.date_month as month,
- ccg.amount as amount,
- ccg.department_code as departCode,
- ccg.department_name as departName,
- ccg.responsibility_code as responsibilityCode,
- cr.responsibility_name as responsibilityName,
- ccg.account_code as accountCode,
- ccg.account_name as accountName,
- ccg.product_code as productCode,
- cp.product_name as productName,
- ccg.file_id as fileId
- from cost_costing_group ccg
- left join cost_responsibility cr
- on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
- left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
- left join cost_product cp
- on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
- where ccg.delete_time = 0
- and ccg.date_year = #{year}
- and ccg.date_month = #{month}
- and ccg.hosp_id = #{hospId}
- <if test="responsibilityCode != null and responsibilityCode != ''">
- and ccg.responsibility_code = #{responsibilityCode}
- </if>
- <if test="accountCode != null and accountCode != ''">
- and ccg.account_code = #{accountCode}
- </if>
- and cr.delete_time = 0
- and ca.delete_time = 0
- limit #{startIndex},#{pageSize}
- </select>
- <select id="queryStartAllocationCount" resultType="java.lang.Integer">
- select
- count(*)
- from cost_costing_group ccg
- left join cost_responsibility cr
- on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
- left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
- left join cost_product cp
- on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
- where ccg.delete_time = 0
- and ccg.date_year = #{year}
- and ccg.date_month = #{month}
- and ccg.hosp_id = #{hospId}
- <if test="responsibilityCode != null and responsibilityCode != ''">
- and ccg.responsibility_code = #{responsibilityCode}
- </if>
- <if test="accountCode != null and accountCode != ''">
- and ccg.account_code = #{accountCode}
- </if>
- and cr.delete_time = 0
- and ca.delete_time = 0
- </select>
- <select id="queryStartAllocationTotalAmount" resultType="java.math.BigDecimal">
- select
- sum(ccg.amount)
- from cost_costing_group ccg
- left join cost_responsibility cr
- on ccg.responsibility_code = cr.responsibility_code and ccg.hosp_id = cr.hosp_id
- left join cost_accounting ca on ccg.account_code = ca.accounting_code and ccg.hosp_id = ca.hosp_id
- left join cost_product cp
- on cp.delete_time = 0 and ccg.product_code = cp.product_code and ccg.hosp_id = cp.hosp_id
- where ccg.delete_time = 0
- and ccg.date_year = #{year}
- and ccg.date_month = #{month}
- and ccg.hosp_id = #{hospId}
- <if test="responsibilityCode != null and responsibilityCode != ''">
- and ccg.responsibility_code = #{responsibilityCode}
- </if>
- <if test="accountCode != null and accountCode != ''">
- and ccg.account_code = #{accountCode}
- </if>
- and cr.delete_time = 0
- and ca.delete_time = 0
- </select>
- <select id="queryAllocation" resultType="com.imed.costaccount.model.vo.AllocationVO">
- select date_year as year,date_month as month,IFNULL(sum(amount),0) as amount,false as isAllocation
- from cost_costing_group
- where delete_time = 0
- <if test="year != null">
- and date_year = #{year}
- and date_month = #{month}
- </if>
- and hosp_id = #{hospId} group by date_year,date_month
- limit #{startIndex},#{pageSize}
- </select>
- <select id="queryAllocationCount" resultType="java.lang.Integer">
- select count(*) from (select count(*)
- from cost_costing_group
- where delete_time = 0
- <if test="year != null">
- and date_year = #{year}
- and date_month = #{month}
- </if>
- and hosp_id = #{hospId} group by date_year,date_month) t
- </select>
- </mapper>
|