ProjectStaffRecordMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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.ProjectStaffRecordMapper">
  6. <resultMap id="BaseResultMap" type="com.ruoyi.project.domain.ProjectStaffRecord">
  7. <id property="id" column="id" jdbcType="BIGINT"/>
  8. <result property="pid" column="pid" jdbcType="BIGINT"/>
  9. <result property="aid" column="aid" jdbcType="BIGINT"/>
  10. <result property="name" column="name" jdbcType="VARCHAR"/>
  11. <result property="projectStatus" column="project_status" jdbcType="INTEGER"/>
  12. <result property="content" column="content" jdbcType="VARCHAR"/>
  13. <result property="annexUrl" column="annex_url" jdbcType="VARCHAR"/>
  14. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  15. <result property="processStatus" column="process_status" jdbcType="INTEGER"/>
  16. <result property="duration" column="duration" jdbcType="DOUBLE"/>
  17. <result property="examineId" column="examine_id" jdbcType="BIGINT"/>
  18. <result property="examineTime" column="examine_time" jdbcType="TIMESTAMP"/>
  19. <result property="examineName" column="examine_name" jdbcType="VARCHAR"/>
  20. <result property="recordTime" column="record_time" jdbcType="TIMESTAMP"/>
  21. <result property="examineContent" column="examine_content" jdbcType="VARCHAR"/>
  22. <result property="initDuration" column="init_duration" jdbcType="DOUBLE"/>
  23. <result property="checkDuration" column="check_duration" jdbcType="DOUBLE"/>
  24. <result property="checkStatus" column="check_status" jdbcType="DOUBLE"/>
  25. </resultMap>
  26. <sql id="Base_Column_List">
  27. id,pid,aid,
  28. name,project_status,content,
  29. annex_url,create_time,process_status,
  30. duration,examine_id,examine_time,
  31. examine_name,record_time,examine_content,
  32. init_duration,check_duration,check_status
  33. </sql>
  34. <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  35. select
  36. <include refid="Base_Column_List" />
  37. from project_staff_record
  38. where id = #{id,jdbcType=BIGINT}
  39. </select>
  40. <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
  41. delete from project_staff_record
  42. where id = #{id,jdbcType=BIGINT}
  43. </delete>
  44. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectStaffRecord" useGeneratedKeys="true">
  45. insert into project_staff_record
  46. ( id,pid,aid
  47. ,name,project_status,content
  48. ,annex_url,create_time,process_status
  49. ,duration,examine_id,examine_time
  50. ,examine_name,record_time,examine_content
  51. ,init_duration,check_duration,check_status
  52. )
  53. values (#{id,jdbcType=BIGINT},#{pid,jdbcType=BIGINT},#{aid,jdbcType=BIGINT}
  54. ,#{name,jdbcType=VARCHAR},#{projectStatus,jdbcType=INTEGER},#{content,jdbcType=VARCHAR}
  55. ,#{annexUrl,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{processStatus,jdbcType=INTEGER}
  56. ,#{duration,jdbcType=DOUBLE},#{examineId,jdbcType=BIGINT},#{examineTime,jdbcType=TIMESTAMP}
  57. ,#{examineName,jdbcType=VARCHAR},#{recordTime,jdbcType=TIMESTAMP},#{examineContent,jdbcType=VARCHAR}
  58. ,#{initDuration,jdbcType=DOUBLE},#{checkDuration,jdbcType=DOUBLE},#{checkStatus,jdbcType=DOUBLE}
  59. )
  60. </insert>
  61. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.ruoyi.project.domain.ProjectStaffRecord" useGeneratedKeys="true">
  62. insert into project_staff_record
  63. <trim prefix="(" suffix=")" suffixOverrides=",">
  64. <if test="id != null">id,</if>
  65. <if test="pid != null">pid,</if>
  66. <if test="aid != null">aid,</if>
  67. <if test="name != null">name,</if>
  68. <if test="projectStatus != null">project_status,</if>
  69. <if test="content != null">content,</if>
  70. <if test="annexUrl != null">annex_url,</if>
  71. <if test="createTime != null">create_time,</if>
  72. <if test="processStatus != null">process_status,</if>
  73. <if test="duration != null">duration,</if>
  74. <if test="examineId != null">examine_id,</if>
  75. <if test="examineTime != null">examine_time,</if>
  76. <if test="examineName != null">examine_name,</if>
  77. <if test="recordTime != null">record_time,</if>
  78. <if test="examineContent != null">examine_content,</if>
  79. <if test="initDuration != null">init_duration,</if>
  80. <if test="checkDuration != null">check_duration,</if>
  81. <if test="checkStatus != null">check_status,</if>
  82. </trim>
  83. <trim prefix="values (" suffix=")" suffixOverrides=",">
  84. <if test="id != null">#{id,jdbcType=BIGINT},</if>
  85. <if test="pid != null">#{pid,jdbcType=BIGINT},</if>
  86. <if test="aid != null">#{aid,jdbcType=BIGINT},</if>
  87. <if test="name != null">#{name,jdbcType=VARCHAR},</if>
  88. <if test="projectStatus != null">#{projectStatus,jdbcType=INTEGER},</if>
  89. <if test="content != null">#{content,jdbcType=VARCHAR},</if>
  90. <if test="annexUrl != null">#{annexUrl,jdbcType=VARCHAR},</if>
  91. <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
  92. <if test="processStatus != null">#{processStatus,jdbcType=INTEGER},</if>
  93. <if test="duration != null">#{duration,jdbcType=DOUBLE},</if>
  94. <if test="examineId != null">#{examineId,jdbcType=BIGINT},</if>
  95. <if test="examineTime != null">#{examineTime,jdbcType=TIMESTAMP},</if>
  96. <if test="examineName != null">#{examineName,jdbcType=VARCHAR},</if>
  97. <if test="recordTime != null">#{recordTime,jdbcType=TIMESTAMP},</if>
  98. <if test="examineContent != null">#{examineContent,jdbcType=VARCHAR},</if>
  99. <if test="initDuration != null">#{initDuration,jdbcType=DOUBLE},</if>
  100. <if test="checkDuration != null">#{checkDuration,jdbcType=DOUBLE},</if>
  101. <if test="checkStatus != null">#{checkStatus,jdbcType=DOUBLE},</if>
  102. </trim>
  103. </insert>
  104. <update id="updateByPrimaryKeySelective" parameterType="com.ruoyi.project.domain.ProjectStaffRecord">
  105. update project_staff_record
  106. <set>
  107. <if test="pid != null">
  108. pid = #{pid,jdbcType=BIGINT},
  109. </if>
  110. <if test="aid != null">
  111. aid = #{aid,jdbcType=BIGINT},
  112. </if>
  113. <if test="name != null">
  114. name = #{name,jdbcType=VARCHAR},
  115. </if>
  116. <if test="projectStatus != null">
  117. project_status = #{projectStatus,jdbcType=INTEGER},
  118. </if>
  119. <if test="content != null">
  120. content = #{content,jdbcType=VARCHAR},
  121. </if>
  122. <if test="annexUrl != null">
  123. annex_url = #{annexUrl,jdbcType=VARCHAR},
  124. </if>
  125. <if test="createTime != null">
  126. create_time = #{createTime,jdbcType=TIMESTAMP},
  127. </if>
  128. <if test="processStatus != null">
  129. process_status = #{processStatus,jdbcType=INTEGER},
  130. </if>
  131. <if test="duration != null">
  132. duration = #{duration,jdbcType=DOUBLE},
  133. </if>
  134. <if test="examineId != null">
  135. examine_id = #{examineId,jdbcType=BIGINT},
  136. </if>
  137. <if test="examineTime != null">
  138. examine_time = #{examineTime,jdbcType=TIMESTAMP},
  139. </if>
  140. <if test="examineName != null">
  141. examine_name = #{examineName,jdbcType=VARCHAR},
  142. </if>
  143. <if test="recordTime != null">
  144. record_time = #{recordTime,jdbcType=TIMESTAMP},
  145. </if>
  146. <if test="examineContent != null">
  147. examine_content = #{examineContent,jdbcType=VARCHAR},
  148. </if>
  149. <if test="initDuration != null">
  150. init_duration = #{initDuration,jdbcType=DOUBLE},
  151. </if>
  152. <if test="checkDuration != null">
  153. check_duration = #{checkDuration,jdbcType=DOUBLE},
  154. </if>
  155. <if test="checkStatus != null">
  156. check_status = #{checkStatus,jdbcType=DOUBLE},
  157. </if>
  158. </set>
  159. where id = #{id,jdbcType=BIGINT}
  160. </update>
  161. <update id="updateByPrimaryKey" parameterType="com.ruoyi.project.domain.ProjectStaffRecord">
  162. update project_staff_record
  163. set
  164. pid = #{pid,jdbcType=BIGINT},
  165. aid = #{aid,jdbcType=BIGINT},
  166. name = #{name,jdbcType=VARCHAR},
  167. project_status = #{projectStatus,jdbcType=INTEGER},
  168. content = #{content,jdbcType=VARCHAR},
  169. annex_url = #{annexUrl,jdbcType=VARCHAR},
  170. create_time = #{createTime,jdbcType=TIMESTAMP},
  171. process_status = #{processStatus,jdbcType=INTEGER},
  172. duration = #{duration,jdbcType=DOUBLE},
  173. examine_id = #{examineId,jdbcType=BIGINT},
  174. examine_time = #{examineTime,jdbcType=TIMESTAMP},
  175. examine_name = #{examineName,jdbcType=VARCHAR},
  176. record_time = #{recordTime,jdbcType=TIMESTAMP},
  177. examine_content = #{examineContent,jdbcType=VARCHAR},
  178. init_duration = #{initDuration,jdbcType=DOUBLE},
  179. check_duration = #{checkDuration,jdbcType=DOUBLE},
  180. check_status = #{checkStatus,jdbcType=DOUBLE}
  181. where id = #{id,jdbcType=BIGINT}
  182. </update>
  183. <select id="selectList" resultType="com.ruoyi.project.bo.ProjectStaffRecordOut">
  184. select a.id,c.job_number jobNumber,a.name ,d.dept_id deptId ,d.dept_name deptName ,a.record_time createMonth,
  185. b.name projectName,b.admin_name adminName ,a.project_status projectStatus,a.content ,b.project_number projectNumber,
  186. a.pid ,a.aid ,a.examine_id examineId ,a.examine_name examineName ,a.examine_time examineTime,a.record_time recordTime,
  187. a.annex_url annexUrl,a.create_time createTime,a.process_status processStatus , a.duration,a.init_duration initDuration,
  188. a.check_duration checkDuration
  189. from project_staff_record a left join project_task b on a.pid=b.id
  190. left join sys_user c on a.aid=c.user_id left join sys_dept d on c.dept_id =d.dept_id
  191. where 1=1
  192. <if test="roleType==0">
  193. and a.aid =#{aid}
  194. </if>
  195. <if test="roleType==1">
  196. and c.superior_id= #{aid}
  197. </if>
  198. <if test="processStatus !=null">
  199. and a.process_status= #{processStatus}
  200. </if>
  201. <if test="companyId !=null">
  202. and (d.dept_id= #{companyId} or find_in_set(#{companyId},d.ancestors))
  203. </if>
  204. <if test="adminName != null"> and a.name like concat ('%',#{adminName},'%')</if>
  205. <if test="projectStatus != null"> and a.project_status =#{projectStatus}</if>
  206. <if test="projectNumber != null"> and b.project_number like concat ('%',#{projectNumber},'%')</if>
  207. <if test="projectName != null"> and b.name like concat ('%',#{projectName},'%')</if>
  208. <if test="clockStatus ==1">
  209. and a.check_duration is not null
  210. and a.duration = a.check_duration
  211. </if>
  212. <if test="clockStatus ==2">
  213. and a.check_duration is not null
  214. and a.duration != a.check_duration
  215. </if>
  216. <if test="researchStart != null and researchEnd != null">
  217. and( #{researchStart} between b.start_time and b.end_time or #{researchEnd} between b.start_time and b.end_time)
  218. </if>
  219. <if test="startTime != null and endTime != null">
  220. and a.record_time between #{startTime} and #{endTime}
  221. </if>
  222. <if test="fullJob != null">and c.full_job= #{fullJob}</if>
  223. <if test="deptId != null">and (d.dept_id= #{deptId} or find_in_set(#{deptId},d.ancestors)) </if>
  224. order by a.record_time desc
  225. </select>
  226. <select id="selectById" resultType="java.lang.Integer">
  227. select count(*)
  228. from project_staff_record a left join project_staff ps on a.aid = ps.aid
  229. where a.pid=ps.pid
  230. and ps.id = #{id}
  231. </select>
  232. <select id="selectByPidAndAid" resultMap="BaseResultMap">
  233. select
  234. <include refid="Base_Column_List" />
  235. from project_staff_record
  236. where 1=1
  237. <if test="pid !=null">
  238. and pid= #{pid}
  239. </if>
  240. <if test="aid != null">
  241. and aid = #{aid}
  242. </if>
  243. </select>
  244. <select id="myDurationMonth" resultType="com.ruoyi.project.bo.MyMonthDays">
  245. select x.dates dates,sum(x.duration)duration
  246. from (select a.duration ,date_format(a.record_time,'%Y-%m-%d')dates
  247. from project_staff_record a
  248. where a.pid = #{param1} and a.aid =#{param2}
  249. and a.record_time between #{param3} and #{param4}
  250. )x group by x.dates
  251. </select>
  252. <select id="selectDetailsById" resultType="com.ruoyi.project.bo.ProjectStaffRecordOut">
  253. select a.id,c.job_number jobNumber,a.name ,d.dept_id deptId ,d.dept_name deptName ,c.create_time createMonth,
  254. b.id projectId,b.name projectName,b.admin_name adminName ,a.project_status projectStatus,a.content ,
  255. a.pid ,a.aid ,a.examine_id examineId ,a.examine_name examineName ,a.examine_time examineTime,
  256. a.annex_url annexUrl,a.create_time createTime,a.process_status processStatus , a.duration,
  257. a.examine_content examineContent,a.record_time recordTime
  258. from project_staff_record a left join project_task b on a.pid=b.id
  259. left join sys_user c on a.aid=c.user_id left join sys_dept d on c.dept_id =d.dept_id
  260. where 1=1
  261. and a.id =#{id}
  262. </select>
  263. <select id="selectByAidAndTime" resultMap="BaseResultMap">
  264. select
  265. <include refid="Base_Column_List" />
  266. from project_staff_record
  267. where aid = #{uid}
  268. and record_time between #{startTime} and #{endTime}
  269. </select>
  270. <update id="updateNameByAid" parameterType="com.ruoyi.common.core.domain.entity.SysUser">
  271. update project_staff_record
  272. set name= #{nickName}
  273. where aid= #{userId}
  274. </update>
  275. <update id="updateSumDurationProject">
  276. update project_task x,(select pid ,sum(duration)duration
  277. from project_staff_record where pid =#{pid} group by pid )y
  278. set x.duration =y.duration
  279. where x.id =y.pid
  280. </update>
  281. <update id="updateSumDurationStaff">
  282. update sys_user x,(select aid ,sum(duration)duration
  283. from project_staff_record where pid = #{pid} group by aid)y
  284. set x.duration=y.duration
  285. where x.user_id =y.aid
  286. </update>
  287. <select id="selectByDDUidAndTime" resultType="com.ruoyi.project.domain.ProjectStaffRecord">
  288. select
  289. b.id,b.duration,b.aid,b.pid,
  290. date_format(b.record_time,'%Y-%m-%d')recordTime
  291. from sys_user a left join project_staff_record b on a.user_id=b.aid
  292. where a.dd_user_id= #{ddUserId}
  293. and b.record_time = #{clockDate}
  294. </select>
  295. <update id="mateUserRecord">
  296. update project_staff_record
  297. set duration =check_duration,check_status=2
  298. where check_status =1
  299. and id in
  300. <foreach collection="collect" open="(" close=")" separator="," item="e">
  301. #{e}
  302. </foreach>
  303. </update>
  304. </mapper>