TaskMapper.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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="cn.cslg.pas.mapper.TaskMapper">
  4. <select id="getPageList" parameterType="cn.cslg.pas.common.model.vo.TaskVO" resultType="cn.cslg.pas.domain.Task">
  5. select a.id, a.type, a.uid as create_by, a.ctime as start_time, a.tid as project_id,
  6. a.mfields as field_num, a.mun as total, a.endtime as end_time, a.status, a.filename as file_name,
  7. a.filesize as file_size, a.downexcel as url, c.name as project_name, a.old_name
  8. from os_task a
  9. left join os_thematic c on c.id = a.tid
  10. <where>
  11. <if test="params.status != null">
  12. and a.status = #{params.status}
  13. </if>
  14. <if test="params.type != null">
  15. and a.type = #{params.type}
  16. </if>
  17. <if test="params.projectId != null">
  18. and a.tid = #{params.projectId}
  19. </if>
  20. <if test="params.productId != null">
  21. and a.product_id = #{params.productId}
  22. </if>
  23. <if test="params.projectName != '' and params.projectName != null">
  24. and c.name like concat('%', #{params.projectName}, '%')
  25. </if>
  26. <if test="params.createPersonIds != null and params.createPersonIds.size > 0">
  27. and a.uid in
  28. <foreach collection="params.createPersonIds" item="n" separator="," open="(" close=")">
  29. #{n}
  30. </foreach>
  31. </if>
  32. </where>
  33. order by a.ctime ${params.order}
  34. </select>
  35. <!--根据条件查询任务列表-->
  36. <!--List<QueryTaskVO> queryTasks(QueryTaskDTO queryTaskDTO);-->
  37. <select id="queryTasks" resultMap="queryTasksMap">
  38. select tas.id tas_id, tas.type tas_type, tas.uid tas_uid, tas.ctime tas_ctime, tas.tid tas_tid,
  39. tas.report_id tas_report_id, tas.product_id tas_product_id, tas.mfields tas_mfields, tas.mun tas_mun, tas.onmun
  40. tas_onmun, tas.endtime
  41. tas_endtime,
  42. tas.status tas_status, tas.filename tas_filename, tas.filesize tas_filesize, tas.loadtime tas_loadtime, tas.main
  43. tas_main,
  44. tas.islook tas_islook, tas.downexcel tas_downexcel, tas.old_name tas_old_name, tas.product_id tas_product_id,
  45. tas.success_num tas_success_num,
  46. tas.true_success_num tas_true_success_num, tas.default_num tas_default_num, tas.pram_json tas_pram_json,
  47. tas.task_condition_id tas_task_condition_id, tas.create_time tas_create_time,
  48. tas.task_type tas_task_type, tas.downexcel tas_downexcel, tas.system_file_id tas_system_file_id,
  49. con.id, con.task_id, con.task_type, con.task_type2, con.conditions,
  50. con.crons, con.config_cells, con.config_id, con.task_name, con.total,
  51. con.orderby, con.orderby_type, con.db_type, con.start_number, con.end_number,
  52. con.isadd_patentnos, con.isdelete_patentnos, con.isadd_type
  53. from os_task tas
  54. left join os_task tas2 on tas.task_condition_id = tas2.task_condition_id and tas.ctime &lt; tas2.ctime
  55. left join task_condition con on tas.task_condition_id = con.id
  56. <where>
  57. <if test="projectId != null and projectId != 0">
  58. and tas.tid = #{projectId}
  59. </if>
  60. <if test="reportId != null and reportId != 0">
  61. and tas.report_id = #{reportId}
  62. </if>
  63. <if test="productId != null and productId != 0">
  64. and tas.product_id = #{productId}
  65. </if>
  66. <if test="projectId == 0 and reportId == null and productId == null">
  67. and tas.tid != 0
  68. </if>
  69. <if test="reportId == 0 and projectId == null and productId == null">
  70. and tas.report_id is not null
  71. </if>
  72. <if test="productId == 0 and projectId == null and reportId == null">
  73. and tas.product_id is not null
  74. </if>
  75. <if test="projectId == null and reportId == null">
  76. and tas.uid = #{createId}
  77. </if>
  78. <if test="personIds != null and personIds.size > 0">
  79. and tas.uid in
  80. <foreach collection="personIds" item="n" separator="," open="(" close=")">
  81. #{n}
  82. </foreach>
  83. </if>
  84. <if test="taskType != null">
  85. and tas.task_type = #{taskType}
  86. </if>
  87. <if test="taskType2 != null">
  88. and tas.type = #{taskType2}
  89. </if>
  90. <if test="taskStatus != null and taskStatus.size > 0">
  91. and tas.status in
  92. <foreach collection="taskStatus" item="n" separator="," open="(" close=")">
  93. #{n}
  94. </foreach>
  95. </if>
  96. <if test="true">
  97. and tas2.id is null
  98. </if>
  99. </where>
  100. order by
  101. <choose>
  102. <when test="orderBy != null">
  103. tas.${orderBy} ${orderType}
  104. </when>
  105. <otherwise>
  106. tas.id
  107. </otherwise>
  108. </choose>
  109. </select>
  110. <resultMap id="queryTasksMap" type="cn.cslg.pas.common.model.vo.QueryTaskVO">
  111. <id column="tas_id" property="id"/>
  112. <result column="tas_type" property="type"/>
  113. <result column="tas_uid" property="createBy"/>
  114. <result column="tas_ctime" property="startTime"/>
  115. <result column="tas_tid" property="projectId"/>
  116. <result column="tas_report_id" property="reportId"/>
  117. <result column="tas_product_id" property="productId"/>
  118. <result column="tas_mun" property="total"/>
  119. <result column="tas_endtime" property="endTime"/>
  120. <result column="tas_status" property="status"/>
  121. <result column="tas_filename" property="fileName"/>
  122. <result column="tas_filesize" property="fileSize"/>
  123. <result column="tas_success_num" property="successNum"/>
  124. <result column="tas_true_success_num" property="trueSuccessNum"/>
  125. <result column="tas_default_num" property="defaultNum"/>
  126. <result column="tas_old_name" property="oldName"/>
  127. <result column="tas_create_time" property="createTime"/>
  128. <result column="tas_task_condition_id" property="taskConditionId"/>
  129. <result column="tas_old_name" property="taskName"/>
  130. <result column="tas_task_type" property="taskType"/>
  131. <result column="tas_endtime" property="modifiedTime"/>
  132. <result column="tas_downexcel" property="url"/>
  133. <result column="tas_system_file_id" property="fileId"/>
  134. <result column="conditions" property="conditions"/>
  135. <result column="crons" property="crons"/>
  136. <result column="config_cells" property="configCells"/>
  137. <result column="orderby" property="orderBy"/>
  138. <result column="orderby_type" property="orderByType"/>
  139. <result column="db_type" property="DBType"/>
  140. <result column="start_number" property="startNumber"/>
  141. <result column="end_number" property="endNumber"/>
  142. <result column="isadd_patentnos" property="isAddPatentNos"/>
  143. <result column="isdelete_patentnos" property="isDeletePatentNos"/>
  144. <result column="isadd_type" property="isAddType"/>
  145. </resultMap>
  146. <select id="queryTask" resultMap="queryTasksMap">
  147. select tas.*
  148. from os_task tas
  149. left join task_condition ass on tas.task_condition_id = ass.id
  150. <where>
  151. (tas.task_condition_id is null
  152. or tas.id in (
  153. select a1
  154. .id from os_task a1 left join os_task a2 on a1.task_condition_id =a2.task_condition_id and
  155. a1.create_time &lt;= a2.create_time group by a1.task_condition_id having count(*)=1)
  156. )
  157. </where>
  158. </select>
  159. </mapper>