ProjectTaskMapper.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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.ruoyi.project.mapper.ProjectTaskMapper">
  4. <resultMap id="BaseResultMap" type="com.ruoyi.project.domain.ProjectTask">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="aid" jdbcType="BIGINT" property="aid" />
  7. <result column="name" jdbcType="VARCHAR" property="name" />
  8. <result column="project_status" jdbcType="INTEGER" property="projectStatus" />
  9. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  10. <result column="remark" jdbcType="VARCHAR" property="remark" />
  11. <result column="admin_name" jdbcType="VARCHAR" property="adminName" />
  12. <result column="staff_name" jdbcType="VARCHAR" property="staffName" />
  13. <result column="project_number" jdbcType="VARCHAR" property="projectNumber" />
  14. <result column="project_year" jdbcType="OTHER" property="projectYear" />
  15. <result column="create_year" jdbcType="OTHER" property="createYear" />
  16. <result column="cross_year" jdbcType="INTEGER" property="crossYear" />
  17. <result column="duration" jdbcType="DOUBLE" property="duration" />
  18. </resultMap>
  19. <sql id="Base_Column_List">
  20. id, aid, `name`, project_status, create_time, remark, admin_name, staff_name, project_number,
  21. project_year, create_year, cross_year, duration
  22. </sql>
  23. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  24. select
  25. <include refid="Base_Column_List" />
  26. from project_task
  27. where id = #{id,jdbcType=BIGINT}
  28. </select>
  29. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  30. delete from project_task
  31. where id = #{id,jdbcType=BIGINT}
  32. </delete>
  33. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectTask" useGeneratedKeys="true">
  34. insert into project_task (aid, `name`, project_status,
  35. create_time, remark, admin_name,
  36. staff_name, project_number, project_year,
  37. create_year, cross_year, duration
  38. )
  39. values (#{aid,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{projectStatus,jdbcType=INTEGER},
  40. #{createTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}, #{adminName,jdbcType=VARCHAR},
  41. #{staffName,jdbcType=VARCHAR}, #{projectNumber,jdbcType=VARCHAR}, #{projectYear,jdbcType=OTHER},
  42. #{createYear,jdbcType=OTHER}, #{crossYear,jdbcType=INTEGER}, #{duration,jdbcType=DOUBLE}
  43. )
  44. </insert>
  45. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectTask" useGeneratedKeys="true">
  46. insert into project_task
  47. <trim prefix="(" suffix=")" suffixOverrides=",">
  48. <if test="aid != null">
  49. aid,
  50. </if>
  51. <if test="name != null">
  52. `name`,
  53. </if>
  54. <if test="projectStatus != null">
  55. project_status,
  56. </if>
  57. <if test="createTime != null">
  58. create_time,
  59. </if>
  60. <if test="remark != null">
  61. remark,
  62. </if>
  63. <if test="adminName != null">
  64. admin_name,
  65. </if>
  66. <if test="staffName != null">
  67. staff_name,
  68. </if>
  69. <if test="projectNumber != null">
  70. project_number,
  71. </if>
  72. <if test="projectYear != null">
  73. project_year,
  74. </if>
  75. <if test="createYear != null">
  76. create_year,
  77. </if>
  78. <if test="crossYear != null">
  79. cross_year,
  80. </if>
  81. <if test="duration != null">
  82. duration,
  83. </if>
  84. </trim>
  85. <trim prefix="values (" suffix=")" suffixOverrides=",">
  86. <if test="aid != null">
  87. #{aid,jdbcType=BIGINT},
  88. </if>
  89. <if test="name != null">
  90. #{name,jdbcType=VARCHAR},
  91. </if>
  92. <if test="projectStatus != null">
  93. #{projectStatus,jdbcType=INTEGER},
  94. </if>
  95. <if test="createTime != null">
  96. #{createTime,jdbcType=TIMESTAMP},
  97. </if>
  98. <if test="remark != null">
  99. #{remark,jdbcType=VARCHAR},
  100. </if>
  101. <if test="adminName != null">
  102. #{adminName,jdbcType=VARCHAR},
  103. </if>
  104. <if test="staffName != null">
  105. #{staffName,jdbcType=VARCHAR},
  106. </if>
  107. <if test="projectNumber != null">
  108. #{projectNumber,jdbcType=VARCHAR},
  109. </if>
  110. <if test="projectYear != null">
  111. #{projectYear,jdbcType=OTHER},
  112. </if>
  113. <if test="createYear != null">
  114. #{createYear,jdbcType=OTHER},
  115. </if>
  116. <if test="crossYear != null">
  117. #{crossYear,jdbcType=INTEGER},
  118. </if>
  119. <if test="duration != null">
  120. #{duration,jdbcType=DOUBLE},
  121. </if>
  122. </trim>
  123. </insert>
  124. <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.project.domain.ProjectTask">
  125. update project_task
  126. <set>
  127. <if test="aid != null">
  128. aid = #{aid,jdbcType=BIGINT},
  129. </if>
  130. <if test="name != null">
  131. `name` = #{name,jdbcType=VARCHAR},
  132. </if>
  133. <if test="projectStatus != null">
  134. project_status = #{projectStatus,jdbcType=INTEGER},
  135. </if>
  136. <if test="createTime != null">
  137. create_time = #{createTime,jdbcType=TIMESTAMP},
  138. </if>
  139. <if test="remark != null">
  140. remark = #{remark,jdbcType=VARCHAR},
  141. </if>
  142. <if test="adminName != null">
  143. admin_name = #{adminName,jdbcType=VARCHAR},
  144. </if>
  145. <if test="staffName != null">
  146. staff_name = #{staffName,jdbcType=VARCHAR},
  147. </if>
  148. <if test="projectNumber != null">
  149. project_number = #{projectNumber,jdbcType=VARCHAR},
  150. </if>
  151. <if test="projectYear != null">
  152. project_year = #{projectYear,jdbcType=OTHER},
  153. </if>
  154. <if test="createYear != null">
  155. create_year = #{createYear,jdbcType=OTHER},
  156. </if>
  157. <if test="crossYear != null">
  158. cross_year = #{crossYear,jdbcType=INTEGER},
  159. </if>
  160. <if test="duration != null">
  161. duration = #{duration,jdbcType=DOUBLE},
  162. </if>
  163. </set>
  164. where id = #{id,jdbcType=BIGINT}
  165. </update>
  166. <update id="updateByPrimaryKey" parameterType="com.ruoyi.project.domain.ProjectTask">
  167. update project_task
  168. set aid = #{aid,jdbcType=BIGINT},
  169. `name` = #{name,jdbcType=VARCHAR},
  170. project_status = #{projectStatus,jdbcType=INTEGER},
  171. create_time = #{createTime,jdbcType=TIMESTAMP},
  172. remark = #{remark,jdbcType=VARCHAR},
  173. admin_name = #{adminName,jdbcType=VARCHAR},
  174. staff_name = #{staffName,jdbcType=VARCHAR},
  175. project_number = #{projectNumber,jdbcType=VARCHAR},
  176. project_year = #{projectYear,jdbcType=OTHER},
  177. create_year = #{createYear,jdbcType=OTHER},
  178. cross_year = #{crossYear,jdbcType=INTEGER},
  179. duration = #{duration,jdbcType=DOUBLE}
  180. where id = #{id,jdbcType=BIGINT}
  181. </update>
  182. <update id="updateStaffName">
  183. update project_task a left join (select pid ,group_concat(name)name from project_staff
  184. where pid = #{pid} group by pid) b on a.id=b.pid set a.staff_name =b.name
  185. where a.id = #{pid}
  186. </update>
  187. <resultMap id="BaseResultOutMap" type="com.ruoyi.project.bo.ProjectTaskListOut">
  188. <id column="id" jdbcType="BIGINT" property="id" />
  189. <result column="aid" jdbcType="BIGINT" property="aid" />
  190. <result column="name" jdbcType="VARCHAR" property="name" />
  191. <result column="project_status" jdbcType="INTEGER" property="projectStatus" />
  192. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  193. <result column="remark" jdbcType="VARCHAR" property="remark" />
  194. <result column="admin_name" jdbcType="VARCHAR" property="adminName" />
  195. <result column="staff_name" jdbcType="VARCHAR" property="staffName" />
  196. <result column="project_number" jdbcType="VARCHAR" property="projectNumber" />
  197. <result column="project_year" jdbcType="OTHER" property="projectYear" />
  198. <result column="create_year" jdbcType="OTHER" property="createYear" />
  199. <result column="cross_year" jdbcType="INTEGER" property="crossYear" />
  200. </resultMap>
  201. <select id="selectList" resultMap="BaseResultOutMap">
  202. select
  203. a.id, a.aid, a.`name`, a.project_status , a.create_time, a.remark, a.admin_name, a.staff_name, a.project_number,
  204. a.project_year, a.create_year, a.cross_year
  205. from project_task a
  206. <if test="companyId !=null">
  207. left join sys_user c on a.aid=c.user_id
  208. left join sys_dept d on c.dept_id=d.dept_id
  209. </if>
  210. where 1=1
  211. <if test="roleType ==0">
  212. and (a.aid =#{uid} or a.id in (select pid from project_staff where aid= #{uid}))
  213. </if>
  214. <if test="headId !=null">
  215. and a.aid= #{headId}
  216. </if>
  217. <if test="staffId !=null">
  218. and a.id in (select pid from project_staff where aid= #{staffId})
  219. </if>
  220. <if test="name !=null">
  221. and a.name like concat('%',#{name},'%')
  222. </if>
  223. <if test="startTime !=null and endTime !=null">
  224. and a.create_time between #{startTime} and #{endTime}
  225. </if>
  226. <if test="projectNumber !=null ">
  227. and a.project_number like concat('%',#{projectNumber},'%')
  228. </if>
  229. <if test="projectYear !=null ">
  230. and a.project_year =#{projectYear}
  231. </if>
  232. <if test="crossYear !=null ">
  233. and a.cross_year =#{crossYear}
  234. </if>
  235. <if test="projectStatus !=null ">
  236. and a.project_status =#{projectStatus}
  237. </if>
  238. <if test="companyId !=null">
  239. and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
  240. </if>
  241. </select>
  242. <select id="projectAddDuration">
  243. update project_task
  244. set duration=duration+#{duration}
  245. where id =#{pid}
  246. </select>
  247. </mapper>