PostDischargePatientManage/postdischarge-manage/src/main/resources/mapper/manage/labelfieldinfo/LabelFieldInfoMapper.xml
2024-07-03 16:29:47 +08:00

277 lines
11 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.xinelu.manage.mapper.labelfieldinfo.LabelFieldInfoMapper">
<resultMap type="LabelFieldInfo" id="LabelFieldInfoResult">
<result property="id" column="id"/>
<result property="fieldName" column="field_name"/>
<result property="fieldCode" column="field_code"/>
<result property="fieldType" column="field_type"/>
<result property="fieldSort" column="field_sort"/>
<result property="fieldRemark" column="field_remark"/>
<result property="taskPartitionDictId" column="task_partition_dict_id"/>
<result property="taskPartitionDictName" column="task_partition_dict_name"/>
<result property="taskTypeId" column="task_type_id"/>
<result property="taskTypeName" column="task_type_name"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectLabelFieldInfoVo">
select id, field_name, field_code, field_type, field_sort, field_remark, task_partition_dict_id, task_partition_dict_name, task_type_id, task_type_name, create_by, create_time, update_by, update_time from label_field_info
</sql>
<select id="selectLabelFieldInfoList" parameterType="LabelFieldInfo" resultMap="LabelFieldInfoResult">
<include refid="selectLabelFieldInfoVo"/>
<where>
<if test="fieldName != null and fieldName != ''">
and field_name like concat('%', #{fieldName}, '%')
</if>
<if test="fieldCode != null and fieldCode != ''">
and field_code = #{fieldCode}
</if>
<if test="fieldType != null and fieldType != ''">
and field_type = #{fieldType}
</if>
<if test="fieldSort != null ">
and field_sort = #{fieldSort}
</if>
<if test="fieldRemark != null and fieldRemark != ''">
and field_remark = #{fieldRemark}
</if>
<if test="taskPartitionDictId != null ">
and task_partition_dict_id = #{taskPartitionDictId}
</if>
<if test="taskPartitionDictName != null and taskPartitionDictName != ''">
and task_partition_dict_name like concat('%', #{taskPartitionDictName}, '%')
</if>
<if test="taskTypeId != null ">
and task_type_id = #{taskTypeId}
</if>
<if test="taskTypeName != null and taskTypeName != ''">
and task_type_name like concat('%', #{taskTypeName}, '%')
</if>
</where>
order by field_sort, create_time DESC
</select>
<select id="selectLabelFieldList" resultType="com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO">
select
lfi.task_partition_dict_id id,
lfi.task_partition_dict_id,
lfi.task_partition_dict_name,
lfi.task_partition_dict_name label
from label_field_info lfi
LEFT JOIN task_partition_dict tpd ON tpd.id = lfi.task_partition_dict_id
<where>
<if test="fieldType != null and fieldType != ''">
lfi.field_type = #{fieldType}
</if>
</where>
group by task_partition_dict_id
order by tpd.task_partition_sort
</select>
<select id="selectLabelFieldInfoById" parameterType="Long"
resultMap="LabelFieldInfoResult">
<include refid="selectLabelFieldInfoVo"/>
where id = #{id}
</select>
<select id="countDuplicateFieldNamesByType" resultType="java.lang.Integer">
select count(1)
from label_field_info
where field_type = #{fieldType} and field_name in
<foreach collection="fieldNames" item="fieldName" open="(" separator="," close=")">
#{fieldName}
</foreach>
</select>
<select id="countByFieldNameExcludingId" resultType="java.lang.Integer">
select count(1)
from label_field_info
where field_name = #{fieldName}
and field_type = #{fieldType}
and id != #{id}
</select>
<insert id="insertLabelFieldInfo" parameterType="LabelFieldInfo" useGeneratedKeys="true"
keyProperty="id">
insert into label_field_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="fieldName != null">field_name,
</if>
<if test="fieldCode != null">field_code,
</if>
<if test="fieldType != null">field_type,
</if>
<if test="fieldSort != null">field_sort,
</if>
<if test="fieldRemark != null">field_remark,
</if>
<if test="taskPartitionDictId != null">task_partition_dict_id,
</if>
<if test="taskPartitionDictName != null">task_partition_dict_name,
</if>
<if test="taskTypeId != null">task_type_id,
</if>
<if test="taskTypeName != null">task_type_name,
</if>
<if test="createBy != null">create_by,
</if>
<if test="createTime != null">create_time,
</if>
<if test="updateBy != null">update_by,
</if>
<if test="updateTime != null">update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="fieldName != null">#{fieldName},
</if>
<if test="fieldCode != null">#{fieldCode},
</if>
<if test="fieldType != null">#{fieldType},
</if>
<if test="fieldSort != null">#{fieldSort},
</if>
<if test="fieldRemark != null">#{fieldRemark},
</if>
<if test="taskPartitionDictId != null">#{taskPartitionDictId},
</if>
<if test="taskPartitionDictName != null">#{taskPartitionDictName},
</if>
<if test="taskTypeId != null">#{taskTypeId},
</if>
<if test="taskTypeName != null">#{taskTypeName},
</if>
<if test="createBy != null">#{createBy},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="updateBy != null">#{updateBy},
</if>
<if test="updateTime != null">#{updateTime},
</if>
</trim>
</insert>
<update id="updateLabelFieldInfo" parameterType="LabelFieldInfo">
update label_field_info
<trim prefix="SET" suffixOverrides=",">
<if test="fieldName != null">field_name =
#{fieldName},
</if>
<if test="fieldCode != null">field_code =
#{fieldCode},
</if>
<if test="fieldType != null">field_type =
#{fieldType},
</if>
<if test="fieldSort != null">field_sort =
#{fieldSort},
</if>
<if test="fieldRemark != null">field_remark =
#{fieldRemark},
</if>
<if test="taskPartitionDictId != null">task_partition_dict_id =
#{taskPartitionDictId},
</if>
<if test="taskPartitionDictName != null">task_partition_dict_name =
#{taskPartitionDictName},
</if>
<if test="taskTypeId != null">task_type_id =
#{taskTypeId},
</if>
<if test="taskTypeName != null">task_type_name =
#{taskTypeName},
</if>
<if test="createBy != null">create_by =
#{createBy},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="updateBy != null">update_by =
#{updateBy},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
</trim>
where id = #{id}
</update>
<delete id="deleteLabelFieldInfoById" parameterType="Long">
delete
from label_field_info
where id = #{id}
</delete>
<delete id="deleteLabelFieldInfoByIds" parameterType="String">
delete from label_field_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="taskPartitionDictIdList" resultType="com.xinelu.manage.domain.labelfieldinfo.LabelFieldInfo">
select tpd.id taskPartitionDictId,
tpd.task_partition_name taskPartitionDictName,
ttd.id taskTypeId,
ttd.task_type_name taskTypeName
from task_partition_dict tpd
LEFT JOIN task_type_dict ttd on tpd.task_type_id = ttd.id
ORDER BY ttd.task_type_sort, tpd.task_partition_sort
</select>
<select id="selectLabelFieldInfoByTaskPartitionDictId"
resultType="com.xinelu.manage.vo.labelfieldcontent.GroupingValue">
select lfi.id labelFieldInfoId,
lfi.field_name,
lfi.field_code,
lfi.field_type,
lfi.field_sort,
lfi.field_remark,
lfi.task_partition_dict_id,
lfi.task_partition_dict_name,
lfi.task_type_id,
lfi.task_type_name
from label_field_info lfi
LEFT JOIN task_partition_dict tpd on tpd.id = lfi.task_partition_dict_id
LEFT JOIN task_type_dict ttd on ttd.id = tpd.task_type_id
<where>
<if test="taskPartitionDictId != null and taskPartitionDictId != 0">
and task_partition_dict_id = #{taskPartitionDictId}
</if>
<if test="taskPartitionDictId == null">
and task_partition_dict_id is null
</if>
</where>
Order by ttd.task_type_sort,tpd.task_partition_sort,lfi.field_sort
</select>
<select id="selectLabelFieldNameByTaskPartitionDictIds"
resultType="com.xinelu.manage.vo.labelfieldinfo.LabelFieldVO">
select id,
field_name label,
field_code,
task_partition_dict_id,
task_partition_dict_name
from label_field_info
<where>
<if test="taskPartitionDictIds != null and taskPartitionDictIds.size() > 0">
task_partition_dict_id in
<foreach item="taskPartitionDictIds" collection="taskPartitionDictIds" open="(" separator="," close=")">
#{taskPartitionDictIds}
</foreach>
</if>
</where>
order by field_sort
</select>
</mapper>