ProjectStaffRecordMapper.xml 19 KB

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