ganzi-api/inventory-dao/src/main/resources/mapper/EntPostTaskMapper.xml

134 lines
5.4 KiB
XML
Raw Normal View History

<?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.rzyc.mapper.EntPostTaskMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.rzyc.model.EntPostTask">
<id column="task_id" property="taskId" />
<result column="post_id" property="postId" />
<result column="ent_user_id" property="entUserId" />
<result column="enterprise_id" property="enterpriseId" />
<result column="ent_list_id" property="entListId" />
<result column="list_id" property="listId" />
<result column="post_list_id" property="postListId" />
<result column="item_title" property="itemTitle" />
<result column="item_content" property="itemContent" />
<result column="start_time" property="startTime" />
<result column="ent_time" property="entTime" />
<result column="task_state" property="taskState" />
<result column="frequency" property="frequency" />
<result column="del_state" property="delState" />
<result column="create_time" property="createTime" />
<result column="create_by" property="createBy" />
<result column="modify_time" property="modifyTime" />
<result column="modify_by" property="modifyBy" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
task_id, post_id, ent_user_id, enterprise_id, ent_list_id, list_id, post_list_id, item_title, item_content, start_time, ent_time, task_state, frequency, del_state, create_time, create_by, modify_time, modify_by
</sql>
<select id="selectEntUserPostTask" resultMap="BaseResultMap">
select * from ent_post_task where enterprise_id = #{enterpriseId}
<if test="null != entUserId and '' != entUserId">
and ent_user_id = #{entUserId}
</if>
<if test="listId != null and '' != listId">
and list_id = #{listId}
</if>
<if test="null != postId and '' != postId">
and post_id = #{postId}
</if>
<if test="null != content and '' != content">
and item_content like concat('%',#{content},'%')
</if>
<if test="null != taskState and '' != taskState">
and task_state = #{taskState}
</if>
</select>
<select id="selectEntUserPostTaskByListId" resultMap="BaseResultMap">
select * from ent_post_task where enterprise_id = #{enterpriseId}
<if test="null != listId and '' != listId">
and list_id = #{listId}
</if>
<if test="null != content and '' != content">
and item_content like concat('%',#{content},'%')
</if>
limit #{page},#{pageSize}
</select>
<select id="selectEntPostTaskTotal" resultType="java.lang.Long">
select count(ept.task_id) from ent_post_task ept
left join ent_post_list epl on ept.ent_list_id = epl.post_list_id
where epl.enterprise_id = #{enterpriseId}
<if test="null != year">
and epl.year_num = #{year}
</if>
<if test="null != listId and '' != listId">
and epl.post_list_id = #{listId}
</if>
</select>
<resultMap id="entPostTaskByStateMap" type="com.rzyc.model.EntPostTaskStatistic">
<result column="haveInHand" property="haveInHand" />
<result column="finished" property="finished" />
<result column="overtime" property="overtime" />
</resultMap>
<select id="selectEntPostTaskByState" resultMap="entPostTaskByStateMap">
select sum(case when task_state = 1 then 1 else 0 end)as haveInHand,
sum(case when task_state = 2 then 1 else 0 end)as finished,
sum(case when task_state = 3 then 1 else 0 end)as overtime
from ent_post_task ept
left join ent_post_list epl on ept.ent_list_id = epl.post_list_id
where epl.enterprise_id = #{enterpriseId}
<if test="null != year">
and epl.year_num = #{year}
</if>
<if test="null != listId and '' != listId">
and epl.post_list_id = #{listId}
</if>
</select>
<insert id="insertList">
insert into ent_post_task (task_id, post_id,ent_user_id,enterprise_id,
ent_list_id,
list_id, post_list_id, item_title,
item_content, start_time,ent_time,task_state,
frequency,
del_state, create_time, create_by,
modify_time, modify_by
)
values
<foreach collection="entTasks" item="record" separator=",">
(#{record.taskId,jdbcType=VARCHAR},
#{record.postId,jdbcType=VARCHAR},
#{record.entUserId,jdbcType=VARCHAR},
#{record.enterpriseId,jdbcType=VARCHAR},
#{record.entListId,jdbcType=VARCHAR},
#{record.listId,jdbcType=VARCHAR},
#{record.postListId,jdbcType=VARCHAR},
#{record.itemTitle,jdbcType=VARCHAR},
#{record.itemContent,jdbcType=VARCHAR},
#{record.startTime},
#{record.entTime},
#{record.taskState,jdbcType=INTEGER},
#{record.frequency,jdbcType=INTEGER},
#{record.delState,jdbcType=INTEGER},
#{record.createTime},
#{record.createBy,jdbcType=VARCHAR},
#{record.modifyTime},
#{record.modifyBy,jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper>