TaskMapper.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.management.platform.mapper.TaskMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.management.platform.entity.Task">
  6. <id column="id" property="id" />
  7. <result column="name" property="name" />
  8. <result column="task_desc" property="taskDesc" />
  9. <result column="creater_id" property="createrId" />
  10. <result column="creater_name" property="createrName" />
  11. <result column="creator_color" property="creatorColor" />
  12. <result column="executor_id" property="executorId" />
  13. <result column="executor_name" property="executorName" />
  14. <result column="executor_color" property="executorColor" />
  15. <result column="task_level" property="taskLevel" />
  16. <result column="task_status" property="taskStatus" />
  17. <result column="create_date" property="createDate" />
  18. <result column="end_date" property="endDate" />
  19. <result column="project_id" property="projectId" />
  20. <result column="stages_id" property="stagesId" />
  21. <result column="company_id" property="companyId" />
  22. <result column="indate" property="indate" />
  23. <result column="parent_tid" property="parentTid" />
  24. <result column="group_id" property="groupId" />
  25. <result column="seq" property="seq" />
  26. <result column="plan_hours" property="planHours" />
  27. <result column="task_type" property="taskType" />
  28. <result column="parent_tname" property="parentTname" />
  29. <result column="finish_date" property="finishDate" />
  30. </resultMap>
  31. <resultMap id="timeResultMap" type="com.management.platform.entity.TimeTask" >
  32. <id column="id" property="id" />
  33. <result column="name" property="name" />
  34. <result column="task_desc" property="taskDesc" />
  35. <result column="creater_id" property="createrId" />
  36. <result column="creater_name" property="createrName" />
  37. <result column="creator_color" property="creatorColor" />
  38. <result column="executor_id" property="executorId" />
  39. <result column="executor_name" property="executorName" />
  40. <result column="executor_color" property="executorColor" />
  41. <result column="task_level" property="taskLevel" />
  42. <result column="task_status" property="taskStatus" />
  43. <result column="create_date" property="createDate" />
  44. <result column="end_date" property="endDate" />
  45. <result column="project_id" property="projectId" />
  46. <result column="stages_id" property="stagesId" />
  47. <result column="company_id" property="companyId" />
  48. <result column="indate" property="indate" />
  49. <result column="parent_tid" property="parentTid" />
  50. <result column="group_id" property="groupId" />
  51. <result column="seq" property="seq" />
  52. <result column="plan_hours" property="planHours" />
  53. <result column="task_type" property="taskType" />
  54. <result column="parent_tname" property="parentTname" />
  55. <result column="finish_date" property="finishDate" />
  56. <result column="work_hours" property="workHours" />
  57. </resultMap>
  58. <!-- 通用查询结果列 -->
  59. <sql id="Base_Column_List">
  60. id, name, task_desc, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date
  61. </sql>
  62. <select id="simpleList" resultMap="BaseResultMap">
  63. select id, name, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date
  64. from task
  65. ${ew.customSqlSegment}
  66. </select>
  67. <!--计算执行人任务分布-->
  68. <select id="getExecutorPanel" resultType="java.util.Map">
  69. SELECT IFNULL(a.executor_id,0) as executorId,IFNULL( a.executor_name,'待认领') as executorName, count(1) AS taskCount
  70. FROM task a
  71. WHERE a.project_id = #{projectId}
  72. GROUP BY a.executor_id
  73. </select>
  74. <!--计算任务列表的任务分布-->
  75. <select id="getStagesPanel" resultType="java.util.Map">
  76. SELECT a.stages_id AS stagesId, stages.`stages_name` AS name, COUNT(1) AS value
  77. FROM task a
  78. LEFT JOIN stages ON stages.id = a.`stages_id`
  79. WHERE a.project_id = #{projectId}
  80. GROUP BY a.stages_id
  81. ORDER BY stages.`sequence`
  82. </select>
  83. <!--计算耗时排名前十的任务-->
  84. <select id="getTopCostTask" resultType="java.util.Map">
  85. SELECT task.id , task.name AS name, IFNULL(SUM(report.`working_time`),0) AS value FROM task
  86. LEFT JOIN report ON report.`task_id` = task.id
  87. WHERE task.project_id = #{projectId} and report.state = 1
  88. GROUP BY task.id ORDER BY SUM(report.`working_time`) DESC LIMIT 10
  89. </select>
  90. <!-- 查询任务实际工时和计划工时对比,仅查询有实际工时的数据 -->
  91. <select id="getTaskTimeCompare" resultType="java.util.Map">
  92. SELECT task.id , task.name AS name, task.plan_hours as planHours, IFNULL(SUM(report.`working_time`),0) AS workHours FROM report
  93. LEFT JOIN task ON report.`task_id` = task.id
  94. WHERE task.project_id = #{projectId} AND report.state = 1
  95. GROUP BY task.id ORDER BY SUM(report.`working_time`) DESC
  96. </select>
  97. <!--查询任务,带实际工时-->
  98. <select id="getTaskWithWorktime" resultMap="timeResultMap">
  99. SELECT task.* , IFNULL(SUM(report.`working_time`),0) AS work_hours FROM task
  100. LEFT JOIN report ON report.`task_id` = task.id
  101. WHERE task.project_id = #{projectId} and report.state = 1
  102. GROUP BY task.id ORDER BY SUM(report.`working_time`) DESC LIMIT 10
  103. </select>
  104. </mapper>