码迷,mamicode.com
首页 > 移动开发 > 详细

TaskMapper

时间:2016-07-04 20:22:02      阅读:191      评论:0      收藏:0      [点我收藏+]

标签:

<?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="TaskMapper">
    <sql id="taskColumns">TASK_ID,NUMBER,NAME,OWNER,TIME,DIR,DIR_URL,TYPE,STATUS</sql>

    <resultMap type="Task" id="taskResultMap" >
        <id column="TASK_ID" property="taskId"/>
        <result column="TASK_NUMBER" property="number"/>
        <result column="NAME" property="name"/>
        <result column="OWNER" property="owner"/>
        <result column="TIME" property="time"/>
        <result column="LOG_PATH" property="logPath"/>
        <result column="LOG_URL" property="logURL"/>
        <result column="TYPE" property="type"/>
        <result column="STATUS" property="status"/>
    </resultMap>
    
    <!-- 列表以分页形式  -->
    <select id="listTaskPage" parameterType="page" resultType="pd" >
        select * from PM_TASK t
        where owner =#{pd.userName} 
        <if test="pd.keyw != null and pd.keyw != ‘‘"><!-- 关键词检索 -->
            and
                (
                     t.NUMBER LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or 
                     t.NAME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘) 
                     or
                     t.OWNER LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     t.TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     t.DIR LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     t.TYPE LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     t.STATUS LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                )
            order by TIME DESC
        </if>
    </select>
    
    <select id="listTaskByUname" parameterType="String" resultMap="taskResultMap">
        select * from PM_TASK 
        where owner =#{userName} order by TIME DESC
    </select>
        
    <select id="getTaskByTaskId" parameterType="pd" resultType="pd">
        select  * from PM_TASK
         where TASK_ID=#{taskId} or number=#{number}
         order by TIME DESC
    </select>
    
    
    <insert id="insertTask" parameterType="Task">
        insert into PM_TASK (
            TASK_ID,
            TASK_NUMBER,
            NAME,
            OWNER,
            TIME,
            LOG_PATH,
            LOG_URL,
            TYPE,
            STATUS
        ) values (
            #{taskId},
            #{taskNumber},
            #{name},
            #{owner},
            #{time},
            #{logPath},
            #{logURL},
            #{type},
            #{status}
        )
    </insert>
    
    <insert id="saveLogInfo" parameterType="pd">
        insert into LOG_INFO (
            LOG_ID,
            TASK_NUMBER,
            USERNAME,
            FILE_NAME,
            FILE_PATH,
            CREATETIME,
            REMARKS
        ) values (
            #{logId},
            #{taskNumber},
            #{userName},
            #{fileName},
            #{filePath},
            #{createTime},
            #{remarks}
        )
    </insert>
    
    <update id="updateTask" parameterType="Task">
        update PM_TASK set 
            NAME =#{name}
        where 
            TASK_ID=#{taskId}
        or number=#{number}
    </update>
    
    <delete id="deleteByTaskId" parameterType="String">
        delete from PM_TASK 
        where TASK_ID=#{taskId} 
        or number=#{number}
    </delete>
    
    <select id="listPmResult" parameterType="page" resultType="pd" >
        select * from PM_RESULT r
        where TASK_ID =#{pd.taskId} 
        <if test="pd.keyw != null and pd.keyw != ‘‘"><!-- 关键词检索 -->
            and
                (
                     r.TASK_ID LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or 
                     r.NEID LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘) 
                     or
                     r.RECEIVE_REPORT_MSG_TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     r.PROCESS_GET_FILE_TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     r.PROCESS_STORE_TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     r.PROCESS_FINISH_TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     r.TOTAL_TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                )
            order by TIME DESC
        </if>
    </select>
    
    
    <select id="listPmResultForCharts" parameterType="page" resultType="pd" >
        select NEID,GROUP_CONCAT(TIME_SPAN) as CATEGORY,GROUP_CONCAT(TOTAL_TIME) as DATAS from PM_RESULT 
        where TASK_ID =#{pd.taskId} GROUP BY NEID  order by NEID DESC
    </select>
    <!-- 获取PO上报的详细信息 -->
    <select id="listPOResult" parameterType="page" resultType="pd" >
        select * from PM_PO_RESULT r
        where STEP_NAME =#{pd.stepName} 
        <if test="pd.keyw != null and pd.keyw != ‘‘"><!-- 关键词检索 -->
            and
                (
                     r.NEID LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘) 
                     or
                     r.PO_NAME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                     or
                     r.TOTAL_TIME LIKE CONCAT(CONCAT(‘%‘, #{pd.keyw}),‘%‘)
                )
            order by TIME DESC
        </if>
    </select>
</mapper>

 

TaskMapper

标签:

原文地址:http://www.cnblogs.com/onetwo/p/5641492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!