ProjectTaskMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ruoyi.project.mapper.ProjectTaskMapper">
  6. <resultMap id="BaseResultMap" type="com.ruoyi.project.domain.ProjectTask">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="aid" column="aid" jdbcType="BIGINT"/>
  9. <result property="name" column="name" jdbcType="VARCHAR"/>
  10. <result property="projectStatus" column="project_status" jdbcType="INTEGER"/>
  11. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  12. <result property="remark" column="remark" jdbcType="VARCHAR"/>
  13. <result property="adminName" column="admin_name" jdbcType="VARCHAR"/>
  14. <result property="staffName" column="staff_name" jdbcType="VARCHAR"/>
  15. <result property="projectNumber" column="project_number" jdbcType="VARCHAR"/>
  16. <result property="projectYear" column="project_year" jdbcType="OTHER"/>
  17. <result property="createYear" column="create_year" jdbcType="OTHER"/>
  18. <result property="crossYear" column="cross_year" jdbcType="INTEGER"/>
  19. <result property="duration" column="duration" jdbcType="DOUBLE"/>
  20. <result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
  21. <result property="endTime" column="end_time" jdbcType="TIMESTAMP"/>
  22. <result property="createAid" column="create_aid" jdbcType="BIGINT"/>
  23. <result property="tianheUrl" column="tianhe_url" jdbcType="VARCHAR"/>
  24. </resultMap>
  25. <sql id="Base_Column_List">
  26. id,aid,name,
  27. project_status,create_time,remark,
  28. admin_name,staff_name,project_number,
  29. project_year,create_year,cross_year,
  30. duration,start_time,end_time,
  31. create_aid,tianhe_url
  32. </sql>
  33. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  34. select
  35. <include refid="Base_Column_List" />
  36. from project_task
  37. where id = #{id,jdbcType=BIGINT}
  38. </select>
  39. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  40. delete from project_task
  41. where id = #{id,jdbcType=BIGINT}
  42. </delete>
  43. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectTask" useGeneratedKeys="true">
  44. insert into project_task
  45. ( id,aid,name
  46. ,project_status,create_time,remark
  47. ,admin_name,staff_name,project_number
  48. ,project_year,create_year,cross_year
  49. ,duration,start_time,end_time
  50. ,create_aid,tianhe_url)
  51. values (#{id,jdbcType=BIGINT},#{aid,jdbcType=BIGINT},#{name,jdbcType=VARCHAR}
  52. ,#{projectStatus,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{remark,jdbcType=VARCHAR}
  53. ,#{adminName,jdbcType=VARCHAR},#{staffName,jdbcType=VARCHAR},#{projectNumber,jdbcType=VARCHAR}
  54. ,#{projectYear,jdbcType=OTHER},#{createYear,jdbcType=OTHER},#{crossYear,jdbcType=INTEGER}
  55. ,#{duration,jdbcType=DOUBLE},#{startTime,jdbcType=TIMESTAMP},#{endTime,jdbcType=TIMESTAMP}
  56. ,#{createAid,jdbcType=BIGINT},#{tianheUrl,jdbcType=VARCHAR})
  57. </insert>
  58. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectTask" useGeneratedKeys="true">
  59. insert into project_task
  60. <trim prefix="(" suffix=")" suffixOverrides=",">
  61. <if test="id != null">id,</if>
  62. <if test="aid != null">aid,</if>
  63. <if test="name != null">name,</if>
  64. <if test="projectStatus != null">project_status,</if>
  65. <if test="createTime != null">create_time,</if>
  66. <if test="remark != null">remark,</if>
  67. <if test="adminName != null">admin_name,</if>
  68. <if test="staffName != null">staff_name,</if>
  69. <if test="projectNumber != null">project_number,</if>
  70. <if test="projectYear != null">project_year,</if>
  71. <if test="createYear != null">create_year,</if>
  72. <if test="crossYear != null">cross_year,</if>
  73. <if test="duration != null">duration,</if>
  74. <if test="startTime != null">start_time,</if>
  75. <if test="endTime != null">end_time,</if>
  76. <if test="createAid != null">create_aid,</if>
  77. <if test="tianheUrl != null">tianhe_url,</if>
  78. </trim>
  79. <trim prefix="values (" suffix=")" suffixOverrides=",">
  80. <if test="id != null">#{id,jdbcType=BIGINT},</if>
  81. <if test="aid != null">#{aid,jdbcType=BIGINT},</if>
  82. <if test="name != null">#{name,jdbcType=VARCHAR},</if>
  83. <if test="projectStatus != null">#{projectStatus,jdbcType=INTEGER},</if>
  84. <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
  85. <if test="remark != null">#{remark,jdbcType=VARCHAR},</if>
  86. <if test="adminName != null">#{adminName,jdbcType=VARCHAR},</if>
  87. <if test="staffName != null">#{staffName,jdbcType=VARCHAR},</if>
  88. <if test="projectNumber != null">#{projectNumber,jdbcType=VARCHAR},</if>
  89. <if test="projectYear != null">#{projectYear,jdbcType=OTHER},</if>
  90. <if test="createYear != null">#{createYear,jdbcType=OTHER},</if>
  91. <if test="crossYear != null">#{crossYear,jdbcType=INTEGER},</if>
  92. <if test="duration != null">#{duration,jdbcType=DOUBLE},</if>
  93. <if test="startTime != null">#{startTime,jdbcType=TIMESTAMP},</if>
  94. <if test="endTime != null">#{endTime,jdbcType=TIMESTAMP},</if>
  95. <if test="createAid != null">#{createAid,jdbcType=BIGINT},</if>
  96. <if test="tianheUrl != null">#{tianheUrl,jdbcType=VARCHAR},</if>
  97. </trim>
  98. </insert>
  99. <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.project.domain.ProjectTask">
  100. update project_task
  101. <set>
  102. <if test="aid != null">
  103. aid = #{aid,jdbcType=BIGINT},
  104. </if>
  105. <if test="name != null">
  106. name = #{name,jdbcType=VARCHAR},
  107. </if>
  108. <if test="projectStatus != null">
  109. project_status = #{projectStatus,jdbcType=INTEGER},
  110. </if>
  111. <if test="createTime != null">
  112. create_time = #{createTime,jdbcType=TIMESTAMP},
  113. </if>
  114. <if test="remark != null">
  115. remark = #{remark,jdbcType=VARCHAR},
  116. </if>
  117. <if test="adminName != null">
  118. admin_name = #{adminName,jdbcType=VARCHAR},
  119. </if>
  120. <if test="staffName != null">
  121. staff_name = #{staffName,jdbcType=VARCHAR},
  122. </if>
  123. <if test="projectNumber != null">
  124. project_number = #{projectNumber,jdbcType=VARCHAR},
  125. </if>
  126. <if test="projectYear != null">
  127. project_year = #{projectYear,jdbcType=OTHER},
  128. </if>
  129. <if test="createYear != null">
  130. create_year = #{createYear,jdbcType=OTHER},
  131. </if>
  132. <if test="crossYear != null">
  133. cross_year = #{crossYear,jdbcType=INTEGER},
  134. </if>
  135. <if test="duration != null">
  136. duration = #{duration,jdbcType=DOUBLE},
  137. </if>
  138. <if test="startTime != null">
  139. start_time = #{startTime,jdbcType=TIMESTAMP},
  140. </if>
  141. <if test="endTime != null">
  142. end_time = #{endTime,jdbcType=TIMESTAMP},
  143. </if>
  144. <if test="createAid != null">
  145. create_aid = #{createAid,jdbcType=BIGINT},
  146. </if>
  147. <if test="tianheUrl != null">
  148. tianhe_url = #{tianheUrl,jdbcType=VARCHAR},
  149. </if>
  150. </set>
  151. where id = #{id,jdbcType=BIGINT}
  152. </update>
  153. <update id="updateByPrimaryKey" parameterType="com.ruoyi.project.domain.ProjectTask">
  154. update project_task
  155. set
  156. aid = #{aid,jdbcType=BIGINT},
  157. name = #{name,jdbcType=VARCHAR},
  158. project_status = #{projectStatus,jdbcType=INTEGER},
  159. create_time = #{createTime,jdbcType=TIMESTAMP},
  160. remark = #{remark,jdbcType=VARCHAR},
  161. admin_name = #{adminName,jdbcType=VARCHAR},
  162. staff_name = #{staffName,jdbcType=VARCHAR},
  163. project_number = #{projectNumber,jdbcType=VARCHAR},
  164. project_year = #{projectYear,jdbcType=OTHER},
  165. create_year = #{createYear,jdbcType=OTHER},
  166. cross_year = #{crossYear,jdbcType=INTEGER},
  167. duration = #{duration,jdbcType=DOUBLE},
  168. start_time = #{startTime,jdbcType=TIMESTAMP},
  169. end_time = #{endTime,jdbcType=TIMESTAMP},
  170. create_aid = #{createAid,jdbcType=BIGINT},
  171. tianhe_url = #{tianheUrl,jdbcType=VARCHAR}
  172. where id = #{id,jdbcType=BIGINT}
  173. </update>
  174. <update id="updateDuration">
  175. update project_task
  176. set duration=(select sum(a.duration)
  177. from project_staff_record a
  178. where a.pid= #{pid})
  179. where id = #{pid}
  180. </update>
  181. <update id="updateAdminNameByAid" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
  182. update project_task
  183. set admin_name = #{nickName}
  184. where aid= #{userId}
  185. </update>
  186. <update id="batchUpdateProjectStatus" >
  187. update project_task
  188. set project_status = 1
  189. where id in
  190. <foreach collection="ids" item="id" open="(" close=")" separator=",">
  191. #{id}
  192. </foreach>
  193. </update>
  194. <resultMap id="BaseResultOutMap" type="com.ruoyi.project.bo.ProjectTaskListOut">
  195. <id column="id" jdbcType="BIGINT" property="id" />
  196. <result column="aid" jdbcType="BIGINT" property="aid" />
  197. <result column="name" jdbcType="VARCHAR" property="name" />
  198. <result column="project_status" jdbcType="INTEGER" property="projectStatus" />
  199. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  200. <result column="remark" jdbcType="VARCHAR" property="remark" />
  201. <result column="admin_name" jdbcType="VARCHAR" property="adminName" />
  202. <result column="staff_name" jdbcType="VARCHAR" property="staffName" />
  203. <result column="project_number" jdbcType="VARCHAR" property="projectNumber" />
  204. <result column="project_year" jdbcType="OTHER" property="projectYear" />
  205. <result column="create_year" jdbcType="OTHER" property="createYear" />
  206. <result column="cross_year" jdbcType="INTEGER" property="crossYear" />
  207. <result column="cross_year" jdbcType="INTEGER" property="crossYear" />
  208. <result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
  209. <result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
  210. <result column="tianhe_url" jdbcType="VARCHAR" property="tianheUrl" />
  211. </resultMap>
  212. <select id="selectList" resultMap="BaseResultOutMap">
  213. select
  214. a.id, a.aid, a.`name`, a.project_status , a.create_time, a.remark, a.admin_name, a.staff_name, a.project_number,
  215. a.project_year, a.create_year, a.cross_year,a.duration,a.start_time,a.end_time,a.tianhe_url
  216. from project_task a
  217. left join sys_user c on a.aid=c.user_id
  218. left join sys_dept d on c.dept_id=d.dept_id
  219. where project_status > 0
  220. <if test="roleType ==0">
  221. and (a.aid =#{uid} or a.id in (select pid from project_staff where aid= #{uid}))
  222. </if>
  223. <if test="headId !=null">
  224. and a.aid= #{headId}
  225. </if>
  226. <if test="headName !=null">
  227. and a.admin_name like concat('%',#{headName},'%')
  228. </if>
  229. <if test="staffId !=null">
  230. and a.id in (select pid from project_staff where aid= #{staffId})
  231. </if>
  232. <if test="staffName !=null">
  233. and a.id in (select pid from project_staff where name like concat('%',#{staffName},'%'))
  234. </if>
  235. <if test="createAid !=null">
  236. and a.create_aid= #{createAid}
  237. </if>
  238. <if test="name !=null">
  239. and a.name like concat('%',#{name},'%')
  240. </if>
  241. <!-- <if test="startTime !=null and endTime !=null">-->
  242. <!-- and a.create_time between #{startTime} and #{endTime}-->
  243. <!-- </if>-->
  244. <if test="startTime !=null and endTime !=null">
  245. and ( #{startTime} between a.start_time and a.end_time or #{endTime} between a.start_time and a.end_time)
  246. </if>
  247. <if test="projectNumber !=null ">
  248. and a.project_number like concat('%',#{projectNumber},'%')
  249. </if>
  250. <if test="projectYear !=null ">
  251. and a.project_year =#{projectYear}
  252. </if>
  253. <if test="crossYear !=null ">
  254. and a.cross_year =#{crossYear}
  255. </if>
  256. <if test="projectStatus !=null ">
  257. and a.project_status =#{projectStatus}
  258. </if>
  259. <if test="companyId !=null">
  260. and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
  261. </if>
  262. <if test="deptId !=null">
  263. and (d.dept_id= #{deptId} or find_in_set(#{deptId},d.ancestors))
  264. </if>
  265. </select>
  266. <select id="projectAddDuration">
  267. update project_task
  268. set duration=round(duration+#{duration},2)
  269. where id =#{pid}
  270. </select>
  271. <select id="selectProjectImg" resultType="com.ruoyi.project.domain.ProjectStaffRecord">
  272. select a.id,a.pid,a.name,a.annex_url annexUrl
  273. from project_staff_record a
  274. where a.pid=#{pid}
  275. </select>
  276. <select id="selectByProjectNumber" resultMap="BaseResultMap">
  277. select
  278. a.id, a.aid, a.`name`, a.project_status, a.create_time, a.remark, a.admin_name, a.staff_name, a.project_number,
  279. a.project_year, a.create_year, a.cross_year, a.duration, a.start_time, a.end_time
  280. FROM project_task a left join sys_user b on a.aid=b.user_id
  281. left join sys_dept d on b.dept_id=d.dept_id
  282. where project_number= #{projectNumber}
  283. <if test="companyId !=null">
  284. and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
  285. </if>
  286. </select>
  287. <select id="selectAll" resultMap="BaseResultMap">
  288. select
  289. <include refid="Base_Column_List" />
  290. from project_task
  291. where project_status =0
  292. </select>
  293. <resultMap id="AllProjectMonthMap" type="com.ruoyi.project.bo.ProjectTaskAllBo">
  294. <id property="id" column="id"/>
  295. <result property="name" column="name" />
  296. <collection property="months" ofType="String">
  297. <result column="recordTime" />
  298. </collection>
  299. </resultMap>
  300. <select id="getAllProjectMonth" resultMap="AllProjectMonthMap">
  301. select x.id,x.name,x.recordTime
  302. from (select a.id,a.name ,date_format(b.record_time,'%Y-%m')recordTime
  303. from project_task a left join project_staff_record b on a.id =b.pid
  304. left join sys_user c on b.aid=c.user_id left join sys_dept d on c.dept_id=d.dept_id
  305. <if test="companyId !=null">
  306. where d.company_id= #{companyId}
  307. </if>
  308. )x where x.recordTime is not null group by x.id,x.name,x.recordTime
  309. </select>
  310. <update id="updateStaffName" >
  311. update project_task
  312. set staff_name=(select group_concat(name)name from project_staff
  313. where pid = #{pid} group by pid)
  314. where id= #{pid}
  315. </update>
  316. </mapper>