Files
nanguangszwlback/mhd-modules/mhd-system/src/main/resources/mapper/basic/ExpenseAccountMapper.xml
T

297 lines
15 KiB
XML

<?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.mhd.basic.domain.expenseAccount.repository.mapper.ExpenseAccountMapper">
<resultMap type="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO" id="ExpenseAccountResult">
<result property="expenseAccountId" column="expense_account_id" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="createByName" column="create_by_name" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
<result property="updateByName" column="update_by_name" />
<result property="delFlag" column="del_flag" />
<result property="topOrganizationId" column="top_organization_id" />
<result property="organizationId" column="organization_id" />
<result property="organizationName" column="organization_name" />
<result property="subjectCode" column="subject_code" />
<result property="subjectName" column="subject_name" />
<result property="billingAttributesCode" column="billing_attributes_code" />
<result property="billingAttributes" column="billing_attributes" />
<result property="belongModuleCode" column="belong_module_code" />
<result property="belongModule" column="belong_module" />
<result property="firstSubjectFlag" column="first_subject_flag" />
<result property="upperSubjectCode" column="upper_subject_code" />
<result property="upperSubject" column="upper_subject" />
<result property="status" column="status" />
<result property="remark" column="remark" />
<result property="serviceItemsManageId" column="service_items_manage_id" />
</resultMap>
<sql id="selectExpenseAccountPo">
select * from expense_account
</sql>
<sql id="selectExpenseAccountPo1">
<where>
<if test="createByName != null and createByName != ''">
and create_by_name like concat('%', #{createByName}, '%')
</if>
<if test="updateByName != null and updateByName != ''">
and update_by_name like concat('%', #{updateByName}, '%')
</if>
<if test="topOrganizationId != null ">
and top_organization_id = #{topOrganizationId}
</if>
<if test="organizationId != null ">
and organization_id = #{organizationId}
</if>
<if test="organizationName != null and organizationName != ''">
and organization_name like concat('%', #{organizationName}, '%')
</if>
<if test="subjectCode != null and subjectCode != ''">
and subject_code = #{subjectCode}
</if>
<if test="subjectName != null and subjectName != ''">
and subject_name like concat('%', #{subjectName}, '%')
</if>
<if test="billingAttributesCode != null and billingAttributesCode != ''">
and billing_attributes_code = #{billingAttributesCode}
</if>
<if test="billingAttributes != null and billingAttributes != ''">
and billing_attributes = #{billingAttributes}
</if>
<if test="belongModuleCode != null and belongModuleCode != ''">
and belong_module_code = #{belongModuleCode}
</if>
<if test="belongModule != null and belongModule != ''">
and belong_module = #{belongModule}
</if>
<if test="firstSubjectFlag != null ">
and first_subject_flag = #{firstSubjectFlag}
</if>
<if test="upperSubjectCode != null and upperSubjectCode != ''">
and upper_subject_code = #{upperSubjectCode}
</if>
<if test="upperSubject != null and upperSubject != ''">
and upper_subject = #{upperSubject}
</if>
<if test="status != null ">
and status = #{status}
</if>
<if test="serviceItemsManageId != null ">
and service_items_manage_id = #{serviceItemsManageId}
</if>
</where>
</sql>
<select id="queryList" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO"
resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO">
SELECT
a.* ,
b.tax_rate,
b.service_items_name,
b.service_items_code
FROM
expense_account a
LEFT JOIN service_items_manage b ON a.service_items_manage_id = b.service_items_manage_id
WHERE
a.del_flag = 1
<include refid="common_where"/>
order by a.create_time DESC
</select>
<select id="selectCostSubject" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO"
resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO">
select
*
from expense_account
where
del_flag = 1
and status = 1
and first_subject_flag = 1
<include refid="common_where_two"></include>
</select>
<select id="selectAllCostSubject"
resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO">
select
*
from expense_account
where
del_flag = 1
and status = 1
and first_subject_flag = 2
and upper_subject_code = #{subjectCode}
</select>
<select id="getInfoByCode" resultType="com.mhd.basic.domain.expenseAccount.repository.po.ExpenseAccountPO" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.ExpenseAccountDO">
SELECT
a.* ,
b.tax_rate,
b.service_items_name,
b.service_items_code
FROM
expense_account a
LEFT JOIN service_items_manage b ON a.service_items_manage_id = b.service_items_manage_id
WHERE
a.del_flag = 1
AND a.top_organization_id = #{expenseAccountDO.topOrganizationId}
AND a.subject_code = #{expenseAccountDO.subjectCode}
AND a.status = 1
</select>
<sql id="common_where_two">
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
<!-- 如果 organizationId 和 topOrganizationId 都为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
<if test="expenseAccountDO.organizationId != null">
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
and organization_id = #{expenseAccountDO.organizationId}
</if>
<if test="expenseAccountDO.topOrganizationId != null and expenseAccountDO.organizationId == null">
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
and top_organization_id = #{expenseAccountDO.topOrganizationId}
</if>
</sql>
<sql id="common_where">
<if test="expenseAccountDO.subjectName != null and expenseAccountDO.subjectName != ''">
and a.subject_name like concat('%', #{expenseAccountDO.subjectName}, '%')
</if>
<if test="expenseAccountDO.subjectCode != null and expenseAccountDO.subjectCode != ''">
and a.subject_code like concat('%', #{expenseAccountDO.subjectCode}, '%')
</if>
<if test="expenseAccountDO.belongModuleCode != null and expenseAccountDO.belongModuleCode != ''">
and a.belong_module_code = #{expenseAccountDO.belongModuleCode}
</if>
<if test="expenseAccountDO.upperSubjectCode != null and expenseAccountDO.upperSubjectCode != ''">
and a.upper_subject_code = #{expenseAccountDO.upperSubjectCode}
</if>
<if test="expenseAccountDO.upperSubject != null and expenseAccountDO.upperSubject != ''">
and a.upper_subject like concat('%', #{expenseAccountDO.upperSubject}, '%')
</if>
<if test="expenseAccountDO.status != null ">
and a.status = #{expenseAccountDO.status}
</if>
<if test="expenseAccountDO.remark != null and expenseAccountDO.remark != ''">
and a.remark like concat('%', #{expenseAccountDO.remark}, '%')
</if>
<if test="expenseAccountDO.createTimeStart != null and expenseAccountDO.createTimeStart != ''">
AND date_format(a.create_time,'%Y-%m-%d') <![CDATA[>=]]> #{expenseAccountDO.createTimeStart}
</if>
<if test="expenseAccountDO.createTimeEnd != null and expenseAccountDO.createTimeEnd != ''">
AND date_format(a.create_time,'%Y-%m-%d') <![CDATA[<=]]> #{expenseAccountDO.createTimeEnd}
</if>
<if test="expenseAccountDO.createByName != null and expenseAccountDO.createByName != ''">
and a.create_by_name like concat('%', #{expenseAccountDO.createByName}, '%')
</if>
<if test="expenseAccountDO.updateByName != null and expenseAccountDO.updateByName != ''">
and a.update_by_name like concat('%', #{expenseAccountDO.updateByName}, '%')
</if>
<if test="expenseAccountDO.updateTimeStart != null and expenseAccountDO.updateTimeStart != ''">
AND date_format(a.update_time,'%Y-%m-%d') <![CDATA[>=]]> #{expenseAccountDO.updateTimeStart}
</if>
<if test="expenseAccountDO.updateTimeEnd != null and expenseAccountDO.updateTimeEnd != ''">
AND date_format(a.update_time,'%Y-%m-%d') <![CDATA[<=]]> #{expenseAccountDO.updateTimeEnd}
</if>
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
<!-- 如果 organizationId 和 topOrganizationId 都为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
<if test="expenseAccountDO.organizationId != null">
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
and a.organization_id = #{expenseAccountDO.organizationId}
-- and a.organization_name IS NOT NULL
-- and a.organization_name != ''
-- and LENGTH(TRIM(a.organization_name)) > 0
</if>
<if test="expenseAccountDO.topOrganizationId != null and expenseAccountDO.organizationId == null">
<!-- 如果设置了 topOrganizationId 但没有设置 organizationId,添加 top_organization_id 条件 -->
and a.top_organization_id = #{expenseAccountDO.topOrganizationId}
-- and a.organization_name IS NOT NULL
-- and a.organization_name != ''
-- and LENGTH(TRIM(a.organization_name)) > 0
</if>
<if test="expenseAccountDO.organizationName != null and expenseAccountDO.organizationName != ''">
and a.organization_name like concat('%', #{expenseAccountDO.organizationName}, '%')
</if>
<if test="expenseAccountDO.serviceItemsCode != null and expenseAccountDO.serviceItemsCode != ''">
and b.service_items_code = #{expenseAccountDO.serviceItemsCode}
</if>
<if test="expenseAccountDO.fixedOrderDisplay != null ">
and a.fixed_order_display = #{expenseAccountDO.fixedOrderDisplay}
</if>
<if test="expenseAccountDO.inOrderDisplay != null ">
and a.in_order_display = #{expenseAccountDO.inOrderDisplay}
</if>
<if test="expenseAccountDO.outOrderDisplay != null ">
and a.out_order_display = #{expenseAccountDO.outOrderDisplay}
</if>
</sql>
<select id="selectExpenseAccount" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.SearchExpenseAccountDO" resultType="com.mhd.basic.domain.expenseAccount.repository.po.QueryExpenseAccountPO">
select
a.*
from
expense_account a
LEFT JOIN service_items_manage b ON a.service_items_manage_id = b.service_items_manage_id
where
b.service_items_code= #{searchExpenseAccountDO.serviceItemsCode}
and upper_subject_code=#{searchExpenseAccountDO.upperSubjectCode}
and a.account_type=1
<if test="searchExpenseAccountDO.ownStatus != null ">
and a.own_status = #{searchExpenseAccountDO.ownStatus}
</if>
<if test="searchExpenseAccountDO.societyStatus != null ">
and a.society_status = #{searchExpenseAccountDO.societyStatus}
</if>
and a.del_flag=1
order by show_seq
</select>
<select id="selectOtherExpenseAccount" parameterType="com.mhd.basic.domain.expenseAccount.repository.todo.SearchExpenseAccountDO" resultType="com.mhd.basic.domain.expenseAccount.repository.po.QueryExpenseAccountPO">
select
a.*
from
expense_account a
LEFT JOIN service_items_manage b ON a.service_items_manage_id = b.service_items_manage_id
where
a.account_type=2
<if test="searchExpenseAccountDO.serviceItemsCode != null ">
and a.service_items_code = #{searchExpenseAccountDO.serviceItemsCode}
</if>
<if test="searchExpenseAccountDO.upperSubjectCode != null ">
and a.upper_subject_code = #{searchExpenseAccountDO.upperSubjectCode}
</if>
<if test="searchExpenseAccountDO.ownStatus != null ">
and a.own_status = #{searchExpenseAccountDO.ownStatus}
</if>
<if test="searchExpenseAccountDO.societyStatus != null ">
and a.society_status = #{searchExpenseAccountDO.societyStatus}
</if>
<!-- 数据权限:南光组织(organizationId=2827)查全部,其他组织查自己 -->
<!-- 如果 organizationId 为 null,表示查询所有组织的数据(不添加组织过滤条件) -->
<if test="searchExpenseAccountDO.organizationId != null">
<!-- 如果设置了 organizationId,添加 organization_id 条件 -->
and a.organization_id = #{searchExpenseAccountDO.organizationId}
and a.organization_name IS NOT NULL
and a.organization_name != ''
and LENGTH(TRIM(a.organization_name)) > 0
</if>
and a.del_flag=1
order by show_seq
</select>
<select id="selectSocialVehicleExpenseAccount" resultType="com.mhd.basic.domain.expenseAccount.repository.po.QueryExpenseAccountPO">
select
a.*
from
expense_account a
LEFT JOIN service_items_manage b ON a.service_items_manage_id = b.service_items_manage_id
where
b.service_items_code= 'SHCL' and first_subject_flag =2
and a.del_flag=1
order by show_seq
</select>
</mapper>