|
@@ -1,84 +1,185 @@
|
|
|
<?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.ym.mec.biz.dal.dao.InspectionItemDao">
|
|
|
- <resultMap id="InspectionItem" type="com.ym.mec.biz.dal.entity.InspectionItem">
|
|
|
- <!--@mbg.generated-->
|
|
|
- <!--@Table inspection_item-->
|
|
|
- <id column="id_" property="id" />
|
|
|
- <result column="inspection_id_" property="inspectionId" />
|
|
|
- <result column="organ_id_" property="organId" />
|
|
|
- <result column="user_id_" property="userId" />
|
|
|
- <result column="item_" property="item" />
|
|
|
- <result column="times_" property="times" />
|
|
|
- <result column="planned_times_" property="plannedTimes" />
|
|
|
- <result column="submitted_times" property="submittedTimes" />
|
|
|
- <result column="memo_" property="memo" />
|
|
|
- <result column="operation_" property="operation" />
|
|
|
- <result column="create_time_" property="createTime" />
|
|
|
- <result column="update_time_" property="updateTime" />
|
|
|
- </resultMap>
|
|
|
- <sql id="Base_Column_List">
|
|
|
- <!--@mbg.generated-->
|
|
|
- id_, inspection_id_, organ_id_, user_id_, item_, times_, planned_times_, submitted_times,
|
|
|
- memo_, operation_, create_time_, update_time_
|
|
|
- </sql>
|
|
|
- <select id="get" parameterType="java.lang.Long" resultMap="InspectionItem">
|
|
|
- <!--@mbg.generated-->
|
|
|
- select
|
|
|
- <include refid="Base_Column_List" />
|
|
|
- from inspection_item
|
|
|
- where id_ = #{id}
|
|
|
- </select>
|
|
|
- <delete id="delete" parameterType="java.lang.Long">
|
|
|
- <!--@mbg.generated-->
|
|
|
- delete from inspection_item
|
|
|
- where id_ = #{id}
|
|
|
- </delete>
|
|
|
- <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.InspectionItem" useGeneratedKeys="true">
|
|
|
- <!--@mbg.generated-->
|
|
|
- insert into inspection_item (inspection_id_, organ_id_, user_id_, item_, times_, planned_times_,
|
|
|
- submitted_times, memo_, operation_, create_time_, update_time_)
|
|
|
- values (#{inspectionId}, #{organId}, #{userId}, #{item}, #{times}, #{plannedTimes},
|
|
|
- #{submittedTimes}, #{memo}, #{operation}, #{createTime}, #{updateTime})
|
|
|
- </insert>
|
|
|
- <update id="update" parameterType="com.ym.mec.biz.dal.entity.InspectionItem">
|
|
|
- <!--@mbg.generated-->
|
|
|
- update inspection_item
|
|
|
- <set>
|
|
|
- <if test="inspectionId != null">
|
|
|
- inspection_id_ = #{inspectionId},
|
|
|
- </if>
|
|
|
- <if test="organId != null">
|
|
|
- organ_id_ = #{organId},
|
|
|
- </if>
|
|
|
- <if test="userId != null">
|
|
|
- user_id_ = #{userId},
|
|
|
- </if>
|
|
|
- <if test="item != null">
|
|
|
- item_ = #{item},
|
|
|
- </if>
|
|
|
- <if test="times != null">
|
|
|
- times_ = #{times},
|
|
|
- </if>
|
|
|
- <if test="plannedTimes != null">
|
|
|
- planned_times_ = #{plannedTimes},
|
|
|
- </if>
|
|
|
- <if test="submittedTimes != null">
|
|
|
- submitted_times = #{submittedTimes},
|
|
|
- </if>
|
|
|
- <if test="memo != null">
|
|
|
- memo_ = #{memo},
|
|
|
- </if>
|
|
|
- <if test="operation != null">
|
|
|
- operation_ = #{operation},
|
|
|
- </if>
|
|
|
- <if test="createTime != null">
|
|
|
- create_time_ = #{createTime},
|
|
|
- </if>
|
|
|
- <if test="updateTime != null">
|
|
|
- update_time_ = #{updateTime},
|
|
|
- </if>
|
|
|
- </set>
|
|
|
- where id_ = #{id}
|
|
|
- </update>
|
|
|
+ <resultMap id="InspectionItem" type="com.ym.mec.biz.dal.entity.InspectionItem">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ <!--@Table inspection_item-->
|
|
|
+ <id column="id_" property="id"/>
|
|
|
+ <result column="inspection_id_" property="inspectionId"/>
|
|
|
+ <result column="organ_id_" property="organId"/>
|
|
|
+ <result column="user_id_" property="userId"/>
|
|
|
+ <result column="item_" property="item" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
|
|
|
+ <result column="times_" property="times"/>
|
|
|
+ <result column="planned_times_" property="plannedTimes"/>
|
|
|
+ <result column="submitted_times" property="submittedTimes"/>
|
|
|
+ <result column="memo_" property="memo"/>
|
|
|
+ <result column="operation_" property="operation"/>
|
|
|
+ <result column="create_time_" property="createTime"/>
|
|
|
+ <result column="update_time_" property="updateTime"/>
|
|
|
+ <result column="month" property="month"/>
|
|
|
+ <result column="organName" property="organName"/>
|
|
|
+ <result column="userName" property="userName"/>
|
|
|
+ </resultMap>
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ id_, inspection_id_, organ_id_, user_id_, item_, times_, planned_times_, submitted_times,
|
|
|
+ memo_, operation_, create_time_, update_time_
|
|
|
+ </sql>
|
|
|
+ <select id="get" parameterType="java.lang.Long" resultMap="InspectionItem">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ select
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ from inspection_item
|
|
|
+ where id_ = #{id}
|
|
|
+ </select>
|
|
|
+ <delete id="delete" parameterType="java.lang.Long">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ delete from inspection_item
|
|
|
+ where id_ = #{id}
|
|
|
+ </delete>
|
|
|
+ <insert id="insert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.InspectionItem"
|
|
|
+ useGeneratedKeys="true">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ insert into inspection_item (inspection_id_, organ_id_, user_id_, item_, times_, planned_times_,
|
|
|
+ submitted_times, memo_, operation_, create_time_, update_time_)
|
|
|
+ values (#{inspectionId}, #{organId}, #{userId}, #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ #{times}, #{plannedTimes},
|
|
|
+ #{submittedTimes}, #{memo}, #{operation}, #{createTime}, #{updateTime})
|
|
|
+ </insert>
|
|
|
+ <update id="update" parameterType="com.ym.mec.biz.dal.entity.InspectionItem">
|
|
|
+ <!--@mbg.generated-->
|
|
|
+ update inspection_item
|
|
|
+ <set>
|
|
|
+ <if test="inspectionId != null">
|
|
|
+ inspection_id_ = #{inspectionId},
|
|
|
+ </if>
|
|
|
+ <if test="organId != null">
|
|
|
+ organ_id_ = #{organId},
|
|
|
+ </if>
|
|
|
+ <if test="userId != null">
|
|
|
+ user_id_ = #{userId},
|
|
|
+ </if>
|
|
|
+ <if test="item != null">
|
|
|
+ item_ = #{item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
|
|
|
+ </if>
|
|
|
+ <if test="times != null">
|
|
|
+ times_ = #{times},
|
|
|
+ </if>
|
|
|
+ <if test="plannedTimes != null">
|
|
|
+ planned_times_ = #{plannedTimes},
|
|
|
+ </if>
|
|
|
+ <if test="submittedTimes != null">
|
|
|
+ submitted_times = #{submittedTimes},
|
|
|
+ </if>
|
|
|
+ <if test="memo != null">
|
|
|
+ memo_ = #{memo},
|
|
|
+ </if>
|
|
|
+ <if test="operation != null">
|
|
|
+ operation_ = #{operation},
|
|
|
+ </if>
|
|
|
+ <if test="createTime != null">
|
|
|
+ create_time_ = #{createTime},
|
|
|
+ </if>
|
|
|
+ <if test="updateTime != null">
|
|
|
+ update_time_ = #{updateTime},
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id_ = #{id}
|
|
|
+ </update>
|
|
|
+ <!-- 获取任务项数目及总次数 -->
|
|
|
+ <select id="getItemCountAndTimes" resultMap="InspectionItem">
|
|
|
+ SELECT inspection_id_ ,IFNULL(COUNT(*),0) planned_times_,SUM(times_) times_ FROM inspection_item
|
|
|
+ WHERE inspection_id_ IN
|
|
|
+ <foreach collection="inspectionIds" item="inspectionId" open="(" close=")" separator=",">
|
|
|
+ #{inspectionId}
|
|
|
+ </foreach>
|
|
|
+ GROUP BY inspection_id_
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="batchInsert" keyColumn="id_" keyProperty="id" parameterType="com.ym.mec.biz.dal.entity.InspectionItem"
|
|
|
+ useGeneratedKeys="true">
|
|
|
+ INSERT INTO inspection_item (inspection_id_, organ_id_, user_id_, item_, times_,operation_, create_time_,
|
|
|
+ update_time_)
|
|
|
+ VALUE
|
|
|
+ <foreach collection="inspectionItems" item="inspectionItem" separator=",">
|
|
|
+ (#{inspectionItem.inspectionId}, #{inspectionItem.organId}, #{inspectionItem.userId},
|
|
|
+ #{inspectionItem.item,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{inspectionItem.times},
|
|
|
+ #{inspectionItem.operation},
|
|
|
+ #{inspectionItem.createTime}, #{inspectionItem.updateTime})
|
|
|
+ </foreach>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <select id="getItemByInspectionId" resultMap="InspectionItem">
|
|
|
+ SELECT *
|
|
|
+ FROM inspection_item
|
|
|
+ WHERE inspection_id_ = #{inspectionId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <delete id="deleteByIds">
|
|
|
+ DELETE FROM inspection_item WHERE id_ IN
|
|
|
+ <foreach collection="ids" item="id" open="(" close=")" separator=",">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 批量更新任务次数 -->
|
|
|
+ <update id="batchUpdate">
|
|
|
+ <foreach collection="inspectionItems" item="inspectionItem" index="index" open="" close="" separator=";">
|
|
|
+ update inspection_item
|
|
|
+ <set>
|
|
|
+ <if test="inspectionItem.times != null">
|
|
|
+ times_ = #{inspectionItem.times},
|
|
|
+ </if>
|
|
|
+ <if test="inspectionItem.operation != null">
|
|
|
+ operation_ = #{inspectionItem.operation},
|
|
|
+ </if>
|
|
|
+ <if test="inspectionItem.updateTime != null">
|
|
|
+ update_time_ = #{inspectionItem.updateTime}
|
|
|
+ </if>
|
|
|
+ </set>
|
|
|
+ where id_ = #{inspectionItem.id}
|
|
|
+ </foreach>
|
|
|
+ </update>
|
|
|
+ <delete id="deleteByInspectionId">
|
|
|
+ DELETE FROM inspection_item
|
|
|
+ WHERE inspection_id_ = #{InspectionId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 分页查询 -->
|
|
|
+ <select id="queryPage" resultMap="InspectionItem" parameterType="map">
|
|
|
+ SELECT ii.*,i.month_ month,o.name_ organName,su.real_name_ userName FROM inspection_item ii
|
|
|
+ LEFT JOIN inspection i ON i.id_ = ii.inspection_id_
|
|
|
+ LEFT JOIN organization o ON o.id_=ii.organ_id_
|
|
|
+ LEFT JOIN sys_user su ON su.id_ = ii.user_id_
|
|
|
+ <include refid="queryPageSql"/>
|
|
|
+ ORDER BY ii.id_
|
|
|
+ <include refid="global.limit"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 查询当前表的总记录数 -->
|
|
|
+ <select id="queryCount" resultType="int">
|
|
|
+ SELECT COUNT(*) FROM inspection_item ii
|
|
|
+ LEFT JOIN inspection i ON i.id_ = ii.inspection_id_
|
|
|
+ <include refid="queryPageSql"/>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <sql id="queryPageSql">
|
|
|
+ <where>
|
|
|
+ <if test="organId != null">
|
|
|
+ AND FIND_IN_SET(ii.organ_id_,#{organId})
|
|
|
+ </if>
|
|
|
+ <if test="userId != null">
|
|
|
+ AND ii.user_id_ = #{userId}
|
|
|
+ </if>
|
|
|
+ <if test="operation != null">
|
|
|
+ AND ii.operation_ = #{operation}
|
|
|
+ </if>
|
|
|
+ <if test="startTime != null">
|
|
|
+ AND i.month_ >= #{startTime}
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null">
|
|
|
+ <![CDATA[AND i.month_ <= #{endTime}]]>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </sql>
|
|
|
</mapper>
|