CheckJobMapper.xml 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196
  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.platform.dao.mapper.check.CheckJobMapper">
  4. <!-- 首先定义 resultMap -->
  5. <resultMap id="CheckJobVOMap" type="com.platform.dao.vo.query.check.CheckJobVO">
  6. <id column="id" property="id"/>
  7. <!-- 基础字段映射 -->
  8. <result column="name" property="name"/>
  9. <result column="type" property="type"/>
  10. <result column="hours" property="hours"/>
  11. <result column="miles" property="miles"/>
  12. <result column="plan_id" property="planId"/>
  13. <result column="sb_id" property="sbId"/>
  14. <result column="part_id" property="partId"/>
  15. <result column="standard_id" property="standardId"/>
  16. <result column="start_time" property="startTime"/>
  17. <result column="end_time" property="endTime"/>
  18. <result column="actual_start_time" property="actualStartTime"/>
  19. <result column="actual_end_time" property="actualEndTime"/>
  20. <result column="requirement" property="requirement"/>
  21. <result column="remark" property="remark"/>
  22. <result column="feedback" property="feedback"/>
  23. <result column="status" property="status"/>
  24. <result column="sb_status" property="sbStatus"/>
  25. <result column="check_user_id" property="checkUserId"/>
  26. <result column="check_dept_id" property="checkDeptId"/>
  27. <result column="created_user_id" property="createdUserId"/>
  28. <result column="update_user_id" property="updateUserId"/>
  29. <result column="created_user_name" property="createdUserName"/>
  30. <result column="update_user_name" property="updateUserName"/>
  31. <result column="created_time" property="createdTime"/>
  32. <result column="update_time" property="updateTime"/>
  33. <result column="standard_hours" property="standardHours"/>
  34. <result column="real_hours" property="realHours"/>
  35. <result column="actual_user" property="actualUser"/>
  36. <result column="receive_overtime" property="receiveOvertime"/>
  37. <result column="con_task" property="conTask"/>
  38. <!-- 关联字段映射 -->
  39. <result column="checkUserName" property="checkUserName"/>
  40. <result column="sbName" property="sbName"/>
  41. <result column="sbNo" property="sbNo"/>
  42. <result column="sbLevel" property="sbLevel"/>
  43. <result column="partName" property="partName"/>
  44. <result column="standardNo" property="standardNo"/>
  45. <result column="standardName" property="standardName"/>
  46. <result column="standardLevel" property="standardLevel"/>
  47. <result column="period" property="period"/>
  48. <result column="periodType" property="periodType"/>
  49. <result column="positionId" property="positionId"/>
  50. <result column="positionName" property="positionName"/>
  51. <result column="checkDeptName" property="checkDeptName"/>
  52. <collection property="requirementList" ofType="com.platform.dao.entity.check.CheckRequirement">
  53. <id column="requirement_id" property="id" />
  54. <result column="std_name" property="stdName" />
  55. <result column="scope" property="scope" />
  56. <result column="requirement_type" property="type" />
  57. <result column="requirement_remark" property="remark" />
  58. <result column="requirement_created_user_name" property="createdUserName" />
  59. <result column="requirement_created_time" property="createdTime" />
  60. <result column="requirement_update_user_name" property="updateUserName" />
  61. <result column="requirement_update_time" property="updateTime" />
  62. <result column="requirement_status" property="status" />
  63. <result column="requirement_method" property="method" />
  64. <result column="requirement_sb_type" property="sbType" />
  65. <result column="requirement_check_level" property="checkLevel" />
  66. <result column="requirement_manage_item" property="manageItem" />
  67. <result column="requirement_check_item" property="checkItem" />
  68. <result column="requirement_content" property="content" />
  69. <result column="requirement_period" property="period" />
  70. <result column="requirement_sb_type_name" property="sbTypeName" />
  71. </collection>
  72. </resultMap>
  73. <sql id="Base_Column_List">
  74. checkjob.id,
  75. checkjob.plan_id,
  76. checkstandard.standard_hours,
  77. checkstandard.real_hours,
  78. checkjob.start_time,
  79. checkjob.end_time,
  80. checkjob.actual_user,
  81. checkjob.type,
  82. checkjob.actual_start_time,
  83. checkjob.actual_end_time,
  84. checkjob.status,
  85. checkjob.sb_status,
  86. checkjob.receive_overtime,
  87. checkjob.check_user_id,
  88. checkjob.check_dept_id,
  89. checkjob.created_user_id,
  90. checkjob.update_user_id,
  91. checkjob.created_user_name,
  92. checkjob.update_user_name,checkjob.remark,
  93. checkjob.created_time,
  94. checkjob.update_time
  95. </sql>
  96. <sql id="Ref_Column_List">
  97. checkjob.plan_id,
  98. checkjob.actual_user,
  99. checkstandard.standard_hours,
  100. checkstandard.real_hours,
  101. checkjob.start_time,
  102. checkjob.type,
  103. checkjob.check_user_id,
  104. checkjob.check_dept_id,
  105. checkjob.end_time,
  106. checkjob.actual_start_time,
  107. checkjob.actual_end_time,
  108. checkjob.checked_num,
  109. checkjob.abnormal_num,
  110. checkjob.check_num,checkjob.remark,
  111. checkjob.status,
  112. checkjob.receive_overtime,
  113. checkjob.sb_status
  114. </sql>
  115. <sql id="List_Condition">
  116. <if test="id != null and id != ''">
  117. and checkjob.id = #{id}
  118. </if>
  119. <if test="receiveOvertime != null">
  120. and checkjob.receive_overtime = #{receiveOvertime}
  121. </if>
  122. <if test="planId != null and planId != ''">
  123. and checkjob.plan_id = #{planId}
  124. </if>
  125. <if test="sbId != null and sbId != ''">
  126. and checkjob.sb_id = #{sbId}
  127. </if>
  128. <if test="partId != null and partId != ''">
  129. and checkjob.part_id = #{partId}
  130. </if>
  131. <if test="standardId != null and standardId != ''">
  132. and checkjob.standard_id = #{standardId}
  133. </if>
  134. <if test="requirement != null and requirement != ''">
  135. and checkjob.requirement = #{requirement}
  136. </if>
  137. <if test="remark != null and remark != ''">
  138. and checkjob.remark = #{remark}
  139. </if>
  140. <if test="feedback != null and feedback != ''">
  141. and checkjob.feedback = #{feedback}
  142. </if>
  143. <if test="status ==null and startTimeStart != null ">
  144. and checkjob.start_time <![CDATA[>=]]>#{startTimeStart}
  145. </if>
  146. <if test="status ==null and startTimeEnd != null">
  147. and checkjob.start_time <![CDATA[<=]]> #{startTimeEnd}
  148. </if>
  149. <if test="startTime != null">
  150. and checkjob.start_time = #{startTime}
  151. </if>
  152. <if test="endTimeStart != null">
  153. and checkjob.end_time <![CDATA[>=]]>; #{endTimeStart}
  154. </if>
  155. <if test="endTimeEnd != null">
  156. and checkjob.end_time <![CDATA[<=]]> #{endTimeEnd}
  157. </if>
  158. <if test="endTime != null">
  159. and checkjob.end_time = #{endTime}
  160. </if>
  161. <if test="actualStartTimeStart != null">
  162. and checkjob.actual_start_time <![CDATA[>=]]>; #{actualStartTimeStart}
  163. </if>
  164. <if test="actualStartTimeEnd != null">
  165. and checkjob.actual_start_time <![CDATA[<=]]> #{actualStartTimeEnd}
  166. </if>
  167. <if test="actualStartTime != null">
  168. and checkjob.actual_start_time = #{actualStartTime}
  169. </if>
  170. <if test="actualEndTimeStart != null">
  171. and checkjob.actual_end_time <![CDATA[>=]]> #{actualEndTimeStart}
  172. </if>
  173. <if test="actualEndTimeEnd != null">
  174. and checkjob.actual_end_time <![CDATA[<=]]> #{actualEndTimeEnd}
  175. </if>
  176. <if test="actualEndTime != null">
  177. and checkjob.actual_end_time = #{actualEndTime}
  178. </if>
  179. <if test="status != null">
  180. and checkjob.status = #{status}
  181. </if>
  182. <if test="sbStatus != null">
  183. and checkjob.sb_status = #{sbStatus}
  184. </if>
  185. <if test="createdUserId != null and createdUserId != ''">
  186. and checkjob.created_user_id = #{createdUserId}
  187. </if>
  188. <if test="updateUserId != null and updateUserId != ''">
  189. and checkjob.update_user_id = #{updateUserId}
  190. </if>
  191. <if test="createdUserName != null and createdUserName != ''">
  192. and checkjob.created_user_name = #{createdUserName}
  193. </if>
  194. <if test="updateUserName != null and updateUserName != ''">
  195. and checkjob.update_user_name = #{updateUserName}
  196. </if>
  197. <if test="createdTimeStart != null">
  198. and checkjob.created_time <![CDATA[>=]]> #{createdTimeStart}
  199. </if>
  200. <if test="createdTimeEnd != null">
  201. and checkjob.created_time <![CDATA[<=]]> #{createdTimeEnd}
  202. </if>
  203. <if test="createdTime != null">
  204. and checkjob.created_time = #{createdTime}
  205. </if>
  206. <if test="updateTimeStart != null">
  207. and checkjob.update_time <![CDATA[>=]]> #{updateTimeStart}
  208. </if>
  209. <if test="updateTimeEnd != null">
  210. and checkjob.update_time <![CDATA[<=]]> #{updateTimeEnd}
  211. </if>
  212. <if test="updateTime != null">
  213. and checkjob.update_time = #{updateTime}
  214. </if>
  215. <if test="keyword != null and keyword != ''">
  216. and (
  217. standard.no like concat('%',#{keyword},'%') or
  218. sbinfo.name like concat('%',#{keyword},'%') or
  219. sbinfo.no like concat('%',#{keyword},'%') )
  220. </if>
  221. <if test="zbh != null and zbh != ''">
  222. and sbinfo.zbh = #{zbh}
  223. </if>
  224. <if test="sbLevel != null and sbLevel != ''">
  225. and sbinfo.level = #{sbLevel}
  226. </if>
  227. <if test="typeId != null and typeId != ''">
  228. and sbinfo.type_id = #{typeId}
  229. </if>
  230. <if test="periodType != null and periodType != ''">
  231. and standard.period_type = #{periodType}
  232. </if>
  233. <if test="standardLevel != null and standardLevel != ''">
  234. and standard.level = #{standardLevel}
  235. </if>
  236. <if test="standardLevelList != null and standardLevelList.size > 0">
  237. AND standard.level in
  238. <foreach item="item" index="index" collection="standardLevelList" open="(" close=")" separator=",">
  239. #{item}
  240. </foreach>
  241. </if>
  242. <if test="checkUserId != null and checkUserId != ''">
  243. and (
  244. checkjob.check_user_id = #{checkUserId}
  245. <if test="checkDeptIds != null and checkDeptIds.size() > 0">
  246. OR (checkjob.check_dept_id IS NOT NULL AND checkjob.check_dept_id IN
  247. <foreach item="deptId" collection="checkDeptIds" open="(" close=")" separator=",">
  248. #{deptId}
  249. </foreach>)
  250. </if>
  251. )
  252. </if>
  253. <if test="checkDeptId != null and checkDeptId != ''">
  254. and checkjob.check_dept_id = #{checkDeptId}
  255. </if>
  256. <if test="type != null and type != ''">
  257. and checkjob.type = #{type}
  258. </if>
  259. <if test="searchStartTime != null and ( status==null or status==1 or status==2)">
  260. and checkjob.start_time <![CDATA[ >= ]]> date_format(#{searchStartTime},'%Y-%m-%d')
  261. </if>
  262. <if test="searchEndTime != null and (status==null or status==1 or status==2)">
  263. and checkjob.start_time <![CDATA[ <= ]]> #{searchEndTime}
  264. </if>
  265. <if test="searchStartTime != null and status!=null and status==3">
  266. and checkjob.actual_start_time <![CDATA[ >= ]]> #{searchStartTime}
  267. </if>
  268. <if test="searchEndTime != null and status!=null and status==3">
  269. and checkjob.actual_start_time <![CDATA[ <= ]]> #{searchEndTime}
  270. </if>
  271. <if test="statusList != null and statusList.size > 0">
  272. AND checkjob.status in
  273. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  274. #{item}
  275. </foreach>
  276. </if>
  277. <if test="checkUserName != null and checkUserName != ''">
  278. and (
  279. u.real_name like concat('%',#{checkUserName},'%')
  280. OR (
  281. checkjob.check_dept_id IS NOT NULL
  282. AND EXISTS (
  283. SELECT 1
  284. FROM t_sys_user su
  285. INNER JOIN t_sys_user_dept sud ON sud.user_id = su.user_id
  286. INNER JOIN t_sys_dept_relation dr ON dr.descendant = sud.dept_id
  287. WHERE su.real_name like concat('%',#{checkUserName},'%')
  288. AND dr.ancestor = checkjob.check_dept_id
  289. )
  290. )
  291. )
  292. </if>
  293. <if test="actualUser != null and actualUser != ''">
  294. and checkjob.actual_user like concat('%',#{actualUser},'%')
  295. </if>
  296. <if test="positionId!=null and positionId!=''">
  297. and sbinfo.position_id = #{positionId}
  298. </if>
  299. <if test="periodTypeList != null and periodTypeList.size > 0">
  300. AND standard.period_type in
  301. <foreach item="item" index="index" collection="periodTypeList" open="(" close=")" separator=",">
  302. #{item}
  303. </foreach>
  304. </if>
  305. <if test="sbLevelList != null and sbLevelList.size > 0">
  306. AND sbinfo.level in
  307. <foreach item="item" index="index" collection="sbLevelList" open="(" close=")" separator=",">
  308. #{item}
  309. </foreach>
  310. </if>
  311. <if test="sbNotStatus!=null">
  312. and sbinfo.status !=#{sbNotStatus}
  313. </if>
  314. </sql>
  315. <!-- 子查询专用的条件片段,使用 checkjob_inner 等别名 -->
  316. <sql id="List_Condition_Inner">
  317. <if test="id != null and id != ''">
  318. and checkjob_inner.id = #{id}
  319. </if>
  320. <if test="receiveOvertime != null">
  321. and checkjob_inner.receive_overtime = #{receiveOvertime}
  322. </if>
  323. <if test="planId != null and planId != ''">
  324. and checkjob_inner.plan_id = #{planId}
  325. </if>
  326. <if test="sbId != null and sbId != ''">
  327. and checkjob_inner.sb_id = #{sbId}
  328. </if>
  329. <if test="partId != null and partId != ''">
  330. and checkjob_inner.part_id = #{partId}
  331. </if>
  332. <if test="standardId != null and standardId != ''">
  333. and checkjob_inner.standard_id = #{standardId}
  334. </if>
  335. <if test="requirement != null and requirement != ''">
  336. and checkjob_inner.requirement = #{requirement}
  337. </if>
  338. <if test="remark != null and remark != ''">
  339. and checkjob_inner.remark = #{remark}
  340. </if>
  341. <if test="feedback != null and feedback != ''">
  342. and checkjob_inner.feedback = #{feedback}
  343. </if>
  344. <if test="status ==null and startTimeStart != null ">
  345. and checkjob_inner.start_time <![CDATA[>=]]>#{startTimeStart}
  346. </if>
  347. <if test="status ==null and startTimeEnd != null">
  348. and checkjob_inner.start_time <![CDATA[<=]]> #{startTimeEnd}
  349. </if>
  350. <if test="startTime != null">
  351. and checkjob_inner.start_time = #{startTime}
  352. </if>
  353. <if test="endTimeStart != null">
  354. and checkjob_inner.end_time <![CDATA[>=]]>; #{endTimeStart}
  355. </if>
  356. <if test="endTimeEnd != null">
  357. and checkjob_inner.end_time <![CDATA[<=]]> #{endTimeEnd}
  358. </if>
  359. <if test="endTime != null">
  360. and checkjob_inner.end_time = #{endTime}
  361. </if>
  362. <if test="actualStartTimeStart != null">
  363. and checkjob_inner.actual_start_time <![CDATA[>=]]>; #{actualStartTimeStart}
  364. </if>
  365. <if test="actualStartTimeEnd != null">
  366. and checkjob_inner.actual_start_time <![CDATA[<=]]> #{actualStartTimeEnd}
  367. </if>
  368. <if test="actualStartTime != null">
  369. and checkjob_inner.actual_start_time = #{actualStartTime}
  370. </if>
  371. <if test="actualEndTimeStart != null">
  372. and checkjob_inner.actual_end_time <![CDATA[>=]]> #{actualEndTimeStart}
  373. </if>
  374. <if test="actualEndTimeEnd != null">
  375. and checkjob_inner.actual_end_time <![CDATA[<=]]> #{actualEndTimeEnd}
  376. </if>
  377. <if test="actualEndTime != null">
  378. and checkjob_inner.actual_end_time = #{actualEndTime}
  379. </if>
  380. <if test="status != null">
  381. and checkjob_inner.status = #{status}
  382. </if>
  383. <if test="sbStatus != null">
  384. and checkjob_inner.sb_status = #{sbStatus}
  385. </if>
  386. <if test="createdUserId != null and createdUserId != ''">
  387. and checkjob_inner.created_user_id = #{createdUserId}
  388. </if>
  389. <if test="updateUserId != null and updateUserId != ''">
  390. and checkjob_inner.update_user_id = #{updateUserId}
  391. </if>
  392. <if test="createdUserName != null and createdUserName != ''">
  393. and checkjob_inner.created_user_name = #{createdUserName}
  394. </if>
  395. <if test="updateUserName != null and updateUserName != ''">
  396. and checkjob_inner.update_user_name = #{updateUserName}
  397. </if>
  398. <if test="createdTimeStart != null">
  399. and checkjob_inner.created_time <![CDATA[>=]]> #{createdTimeStart}
  400. </if>
  401. <if test="createdTimeEnd != null">
  402. and checkjob_inner.created_time <![CDATA[<=]]> #{createdTimeEnd}
  403. </if>
  404. <if test="createdTime != null">
  405. and checkjob_inner.created_time = #{createdTime}
  406. </if>
  407. <if test="updateTimeStart != null">
  408. and checkjob_inner.update_time <![CDATA[>=]]> #{updateTimeStart}
  409. </if>
  410. <if test="updateTimeEnd != null">
  411. and checkjob_inner.update_time <![CDATA[<=]]> #{updateTimeEnd}
  412. </if>
  413. <if test="updateTime != null">
  414. and checkjob_inner.update_time = #{updateTime}
  415. </if>
  416. <if test="keyword != null and keyword != ''">
  417. and (
  418. standard_inner.no like concat('%',#{keyword},'%') or
  419. sbinfo_inner.name like concat('%',#{keyword},'%') or
  420. sbinfo_inner.no like concat('%',#{keyword},'%') )
  421. </if>
  422. <if test="zbh != null and zbh != ''">
  423. and sbinfo_inner.zbh = #{zbh}
  424. </if>
  425. <if test="sbLevel != null and sbLevel != ''">
  426. and sbinfo_inner.level = #{sbLevel}
  427. </if>
  428. <if test="typeId != null and typeId != ''">
  429. and sbinfo_inner.type_id = #{typeId}
  430. </if>
  431. <if test="periodType != null and periodType != ''">
  432. and standard_inner.period_type = #{periodType}
  433. </if>
  434. <if test="standardLevel != null and standardLevel != ''">
  435. and standard_inner.level = #{standardLevel}
  436. </if>
  437. <if test="standardLevelList != null and standardLevelList.size > 0">
  438. AND standard_inner.level in
  439. <foreach item="item" index="index" collection="standardLevelList" open="(" close=")" separator=",">
  440. #{item}
  441. </foreach>
  442. </if>
  443. <if test="checkUserId != null and checkUserId != ''">
  444. and (
  445. checkjob_inner.check_user_id = #{checkUserId}
  446. <if test="checkDeptIds != null and checkDeptIds.size() > 0">
  447. OR (checkjob_inner.check_dept_id IS NOT NULL AND checkjob_inner.check_dept_id IN
  448. <foreach item="deptId" collection="checkDeptIds" open="(" close=")" separator=",">
  449. #{deptId}
  450. </foreach>)
  451. </if>
  452. )
  453. </if>
  454. <if test="checkDeptId != null and checkDeptId != ''">
  455. and checkjob_inner.check_dept_id = #{checkDeptId}
  456. </if>
  457. <if test="type != null and type != ''">
  458. and checkjob_inner.type = #{type}
  459. </if>
  460. <if test="searchStartTime != null and ( status==null or status==1 or status==2)">
  461. and checkjob_inner.start_time <![CDATA[ >= ]]> date_format(#{searchStartTime},'%Y-%m-%d')
  462. </if>
  463. <if test="searchEndTime != null and (status==null or status==1 or status==2)">
  464. and checkjob_inner.start_time <![CDATA[ <= ]]> #{searchEndTime}
  465. </if>
  466. <if test="searchStartTime != null and status!=null and status==3">
  467. and checkjob_inner.actual_start_time <![CDATA[ >= ]]> #{searchStartTime}
  468. </if>
  469. <if test="searchEndTime != null and status!=null and status==3">
  470. and checkjob_inner.actual_start_time <![CDATA[ <= ]]> #{searchEndTime}
  471. </if>
  472. <if test="statusList != null and statusList.size > 0">
  473. AND checkjob_inner.status in
  474. <foreach item="item" index="index" collection="statusList" open="(" close=")" separator=",">
  475. #{item}
  476. </foreach>
  477. </if>
  478. <if test="checkUserName != null and checkUserName != ''">
  479. and (
  480. u.real_name like concat('%',#{checkUserName},'%')
  481. OR (
  482. checkjob_inner.check_dept_id IS NOT NULL
  483. AND EXISTS (
  484. SELECT 1
  485. FROM t_sys_user su
  486. INNER JOIN t_sys_user_dept sud ON sud.user_id = su.user_id
  487. INNER JOIN t_sys_dept_relation dr ON dr.descendant = sud.dept_id
  488. WHERE su.real_name like concat('%',#{checkUserName},'%')
  489. AND dr.ancestor = checkjob_inner.check_dept_id
  490. )
  491. )
  492. )
  493. </if>
  494. <if test="actualUser != null and actualUser != ''">
  495. and checkjob_inner.actual_user like concat('%',#{actualUser},'%')
  496. </if>
  497. <if test="positionId!=null and positionId!=''">
  498. and sbinfo_inner.position_id = #{positionId}
  499. </if>
  500. <if test="periodTypeList != null and periodTypeList.size > 0">
  501. AND standard_inner.period_type in
  502. <foreach item="item" index="index" collection="periodTypeList" open="(" close=")" separator=",">
  503. #{item}
  504. </foreach>
  505. </if>
  506. <if test="sbLevelList != null and sbLevelList.size > 0">
  507. AND sbinfo_inner.level in
  508. <foreach item="item" index="index" collection="sbLevelList" open="(" close=")" separator=",">
  509. #{item}
  510. </foreach>
  511. </if>
  512. <if test="sbNotStatus!=null">
  513. and sbinfo_inner.status !=#{sbNotStatus}
  514. </if>
  515. </sql>
  516. <select id="selectList" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  517. resultMap="CheckJobVOMap">
  518. select
  519. checkjob.id as id,
  520. checkjob.plan_id as plan_id,
  521. checkjob.name as name,
  522. checkjob.type as type,
  523. checkjob.hours as hours,
  524. checkjob.miles as miles,
  525. checkjob.sb_id as sb_id,
  526. checkjob.part_id as part_id,
  527. checkjob.standard_id as standard_id,
  528. checkjob.start_time as start_time,
  529. checkjob.end_time as end_time,
  530. checkjob.actual_start_time as actual_start_time,
  531. checkjob.actual_end_time as actual_end_time,
  532. checkjob.requirement as requirement,
  533. checkjob.remark as remark,
  534. checkjob.feedback as feedback,
  535. checkjob.status as status,
  536. checkjob.sb_status as sb_status,
  537. checkjob.check_user_id as check_user_id,
  538. checkjob.check_dept_id as check_dept_id,
  539. checkjob.created_user_id as created_user_id,
  540. checkjob.update_user_id as update_user_id,
  541. checkjob.created_user_name as created_user_name,
  542. checkjob.update_user_name as update_user_name,
  543. checkjob.created_time as created_time,
  544. checkjob.update_time as update_time,
  545. checkjob.standard_hours as standard_hours,
  546. checkjob.real_hours as real_hours,
  547. checkjob.actual_user as actual_user,
  548. checkjob.receive_overtime as receive_overtime,
  549. checkjob.con_task as con_task,
  550. u.real_name as checkUserName,
  551. dept.name as checkDeptName,
  552. sbinfo.name as sbName,
  553. sbinfo.no as sbNo,
  554. sbinfo.level as sbLevel,
  555. sbinfo.id as sbInfoId,
  556. partinfo.name as partName,
  557. standard.no as standardNo,
  558. standard.name as standardName,
  559. standard.level as standardLevel,
  560. standard.period as period,
  561. standard.period_type as periodType,
  562. position.id as positionId,
  563. position.name as positionName,
  564. cr.id as requirement_id,
  565. cr.std_name as std_name,
  566. cr.scope as scope,
  567. cr.type as requirement_type,
  568. cr.method as requirement_method,
  569. cr.sb_type as requirement_sb_type,
  570. cr.check_level as requirement_check_level,
  571. cr.manage_item as requirement_manage_item,
  572. cr.check_item as requirement_check_item,
  573. cr.content as requirement_content,
  574. cr.period as requirement_period,
  575. sbtype.name as requirement_sb_type_name,
  576. cr.remark as requirement_remark,
  577. cr.created_user_name as requirement_created_user_name,
  578. cr.created_time as requirement_created_time,
  579. cr.update_user_name as requirement_update_user_name,
  580. cr.update_time as requirement_update_time,
  581. cr.status as requirement_status
  582. from t_check_job as checkjob
  583. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  584. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  585. left join t_check_standard standard on standard.id = checkjob.standard_id
  586. left join t_sys_user u on checkjob.check_user_id = u.user_id
  587. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  588. left join t_sb_position position on position.id = sbinfo.position_id
  589. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  590. left join t_check_requirement cr on cr.id = csr.requirement_id
  591. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  592. WHERE checkjob.id IN (
  593. SELECT job_id FROM (
  594. SELECT checkjob_inner.id as job_id
  595. FROM t_check_job checkjob_inner
  596. LEFT JOIN t_sb_info sbinfo_inner ON sbinfo_inner.id = checkjob_inner.sb_id
  597. LEFT JOIN t_check_standard standard_inner ON standard_inner.id = checkjob_inner.standard_id
  598. LEFT JOIN t_sys_user u ON checkjob_inner.check_user_id = u.user_id
  599. <where>
  600. <include refid="List_Condition_Inner"/>
  601. </where>
  602. ORDER BY
  603. checkjob_inner.status asc,
  604. <if test="status==null or status==1 or status==2">
  605. checkjob_inner.start_time asc,
  606. </if>
  607. sbinfo_inner.level asc,
  608. sbinfo_inner.no asc,
  609. standard_inner.period_type asc,
  610. standard_inner.period asc
  611. ) as tmp
  612. )
  613. Order By
  614. checkjob.status asc,
  615. <if test="status==null or status==1 or status==2">
  616. checkjob.start_time asc,
  617. </if>
  618. sbinfo.level asc,
  619. sbinfo.no asc,
  620. standard.period_type asc,
  621. standard.period asc
  622. </select>
  623. <select id="selectList2" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  624. resultMap="CheckJobVOMap">
  625. select
  626. checkjob.id as id,
  627. checkjob.plan_id as plan_id,
  628. checkjob.name as name,
  629. checkjob.type as type,
  630. checkjob.hours as hours,
  631. checkjob.miles as miles,
  632. checkjob.sb_id as sb_id,
  633. checkjob.part_id as part_id,
  634. checkjob.standard_id as standard_id,
  635. checkjob.start_time as start_time,
  636. checkjob.end_time as end_time,
  637. checkjob.actual_start_time as actual_start_time,
  638. checkjob.actual_end_time as actual_end_time,
  639. checkjob.requirement as requirement,
  640. checkjob.remark as remark,
  641. checkjob.feedback as feedback,
  642. checkjob.status as status,
  643. checkjob.sb_status as sb_status,
  644. checkjob.check_user_id as check_user_id,
  645. checkjob.check_dept_id as check_dept_id,
  646. checkjob.created_user_id as created_user_id,
  647. checkjob.update_user_id as update_user_id,
  648. checkjob.created_user_name as created_user_name,
  649. checkjob.update_user_name as update_user_name,
  650. checkjob.created_time as created_time,
  651. checkjob.update_time as update_time,
  652. checkjob.standard_hours as standard_hours,
  653. checkjob.real_hours as real_hours,
  654. checkjob.actual_user as actual_user,
  655. checkjob.receive_overtime as receive_overtime,
  656. checkjob.con_task as con_task,
  657. u.real_name as checkUserName,
  658. dept.name as checkDeptName,
  659. sbinfo.name as sbName,
  660. sbinfo.no as sbNo,
  661. sbinfo.level as sbLevel,
  662. sbinfo.id as sbInfoId,
  663. partinfo.name as partName,
  664. standard.no as standardNo,
  665. standard.name as standardName,
  666. standard.level as standardLevel,
  667. standard.period as period,
  668. standard.period_type as periodType,
  669. position.id as positionId,
  670. position.name as positionName,
  671. <!-- 保养要求相关字段 -->
  672. cr.id as requirement_id,
  673. cr.std_name as std_name,
  674. cr.scope as scope,
  675. cr.type as requirement_type,
  676. cr.method as requirement_method,
  677. cr.sb_type as requirement_sb_type,
  678. cr.check_level as requirement_check_level,
  679. cr.manage_item as requirement_manage_item,
  680. cr.check_item as requirement_check_item,
  681. cr.content as requirement_content,
  682. cr.period as requirement_period,
  683. sbtype.name as requirement_sb_type_name,
  684. cr.remark as requirement_remark,
  685. cr.created_user_name as requirement_created_user_name,
  686. cr.created_time as requirement_created_time,
  687. cr.update_user_name as requirement_update_user_name,
  688. cr.update_time as requirement_update_time,
  689. cr.status as requirement_status
  690. from t_check_job as checkjob
  691. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  692. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  693. left join t_check_standard standard on standard.id = checkjob.standard_id
  694. left join t_sys_user u on checkjob.check_user_id = u.user_id
  695. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  696. left join t_sb_position position on position.id = sbinfo.position_id
  697. <!-- 关联保养要求表 -->
  698. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  699. left join t_check_requirement cr on cr.id = csr.requirement_id and cr.status = 1
  700. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  701. <where>
  702. <include refid="List_Condition"/>
  703. </where>
  704. </select>
  705. <select id="getScreenCountByTime" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  706. resultType="com.platform.dao.vo.query.check.CheckJobVO">
  707. select count(checkjob.id) as countNum
  708. from t_check_job as checkjob
  709. <where>
  710. <if test="searchStartTime != null">
  711. and checkjob.start_time <![CDATA[ >= ]]> #{searchStartTime}
  712. </if>
  713. <if test="searchEndTime != null">
  714. and checkjob.start_time <![CDATA[ <= ]]> #{searchEndTime}
  715. </if>
  716. <if test="status != null">
  717. and checkjob.status = #{status}
  718. </if>
  719. </where>
  720. </select>
  721. <select id="countByCondition" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  722. resultType="long">
  723. select count(DISTINCT checkjob.id)
  724. from t_check_job checkjob
  725. LEFT JOIN t_sb_info sbinfo ON sbinfo.id = checkjob.sb_id
  726. LEFT JOIN t_check_standard standard ON standard.id = checkjob.standard_id
  727. LEFT JOIN t_sys_user u ON checkjob.check_user_id = u.user_id
  728. <where>
  729. <include refid="List_Condition"/>
  730. </where>
  731. </select>
  732. <select id="selectDetail" resultType="com.platform.dao.vo.query.check.CheckJobVO">
  733. select checkjob.id as id,
  734. checkjob.plan_id as plan_id,
  735. checkjob.name as name,
  736. checkjob.type as type,
  737. checkjob.hours as hours,
  738. checkjob.miles as miles,
  739. checkjob.sb_id as sb_id,
  740. checkjob.part_id as part_id,
  741. checkjob.standard_id as standard_id,
  742. checkjob.start_time as start_time,
  743. checkjob.end_time as end_time,
  744. checkjob.actual_start_time as actual_start_time,
  745. checkjob.actual_end_time as actual_end_time,
  746. checkjob.requirement as requirement,
  747. checkjob.remark as remark,
  748. checkjob.feedback as feedback,
  749. checkjob.status as status,
  750. checkjob.sb_status as sb_status,
  751. checkjob.check_user_id as check_user_id,
  752. checkjob.check_dept_id as check_dept_id,
  753. checkjob.created_user_id as created_user_id,
  754. checkjob.update_user_id as update_user_id,
  755. checkjob.created_user_name as created_user_name,
  756. checkjob.update_user_name as update_user_name,
  757. checkjob.created_time as created_time,
  758. checkjob.update_time as update_time,
  759. checkjob.standard_hours as standard_hours,
  760. checkjob.real_hours as real_hours,
  761. checkjob.actual_user as actual_user,
  762. checkjob.receive_overtime as receive_overtime,
  763. checkjob.con_task as con_task,
  764. u.real_name as checkUserName,
  765. dept.name as checkDeptName,
  766. sbinfo.name sbName,
  767. sbinfo.no sbNo,
  768. sbinfo.level sbLevel,
  769. partinfo.name partName,
  770. standard.no standardNo,
  771. standard.name standardName,
  772. standard.level standardLevel,
  773. standard.period period,
  774. standard.next_date as nextDate,
  775. standard.period_type periodType
  776. from t_check_job as checkjob
  777. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  778. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  779. left join t_check_standard standard on standard.id = checkjob.standard_id
  780. left join t_sys_user u on checkjob.check_user_id = u.user_id
  781. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  782. where checkjob.id = #{id}
  783. </select>
  784. <select id="getNotFinishNumByDTO" resultType="java.lang.Integer">
  785. select count(checkjob.id)
  786. from t_check_job as checkjob
  787. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  788. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  789. left join t_check_standard standard on standard.id = checkjob.standard_id
  790. left join t_sys_user u on checkjob.check_user_id = u.user_id
  791. <where>
  792. <include refid="List_Condition"/>
  793. </where>
  794. </select>
  795. <select id="selectLastJob" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  796. resultType="com.platform.dao.vo.query.check.CheckJobVO">
  797. select checkjob.id as id,
  798. checkjob.plan_id as plan_id,
  799. checkjob.name as name,
  800. checkjob.type as type,
  801. checkjob.hours as hours,
  802. checkjob.miles as miles,
  803. checkjob.sb_id as sb_id,
  804. checkjob.part_id as part_id,
  805. checkjob.standard_id as standard_id,
  806. checkjob.start_time as start_time,
  807. checkjob.end_time as end_time,
  808. checkjob.actual_start_time as actual_start_time,
  809. checkjob.actual_end_time as actual_end_time,
  810. checkjob.requirement as requirement,
  811. checkjob.remark as remark,
  812. checkjob.feedback as feedback,
  813. checkjob.status as status,
  814. checkjob.sb_status as sb_status,
  815. checkjob.check_user_id as check_user_id,
  816. checkjob.check_dept_id as check_dept_id,
  817. checkjob.created_user_id as created_user_id,
  818. checkjob.update_user_id as update_user_id,
  819. checkjob.created_user_name as created_user_name,
  820. checkjob.update_user_name as update_user_name,
  821. checkjob.created_time as created_time,
  822. checkjob.update_time as update_time,
  823. checkjob.standard_hours as standard_hours,
  824. checkjob.real_hours as real_hours,
  825. checkjob.actual_user as actual_user,
  826. checkjob.receive_overtime as receive_overtime,
  827. checkjob.con_task as con_task
  828. from t_check_job as checkjob
  829. where checkjob.sb_id = #{sbId}
  830. and checkjob.standard_id = #{standardId}
  831. order by checkjob.created_time desc limit 1
  832. </select>
  833. <update id="updateBatch" parameterType="java.util.List">
  834. <foreach collection="list" item="item" index="index" open="" close="" separator=";">
  835. update t_check_job
  836. <set>
  837. <if test="item.receiveOvertime != null">
  838. receive_overtime = #{item.receiveOvertime}
  839. </if>
  840. <if test="item.startTime != null">
  841. start_time = #{item.startTime}
  842. </if>
  843. </set>
  844. where id = #{item.id}
  845. </foreach>
  846. </update>
  847. <update id="updateBatchByDelStandard" parameterType="com.platform.dao.entity.check.CheckJob">
  848. update t_check_job
  849. <set>
  850. status = 3,
  851. remark = #{remark}
  852. </set>
  853. where standard_id = #{standardId}
  854. and status != 3
  855. </update>
  856. <select id="selectListByDate" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  857. resultType="com.platform.dao.vo.query.check.CheckJobVO">
  858. select checkjob.id as id,
  859. checkjob.plan_id as plan_id,
  860. checkjob.name as name,
  861. checkjob.type as type,
  862. checkjob.hours as hours,
  863. checkjob.miles as miles,
  864. checkjob.sb_id as sb_id,
  865. checkjob.part_id as part_id,
  866. checkjob.standard_id as standard_id,
  867. checkjob.start_time as start_time,
  868. checkjob.end_time as end_time,
  869. checkjob.actual_start_time as actual_start_time,
  870. checkjob.actual_end_time as actual_end_time,
  871. checkjob.requirement as requirement,
  872. checkjob.remark as remark,
  873. checkjob.feedback as feedback,
  874. checkjob.status as status,
  875. checkjob.sb_status as sb_status,
  876. checkjob.check_user_id as check_user_id,
  877. checkjob.check_dept_id as check_dept_id,
  878. checkjob.created_user_id as created_user_id,
  879. checkjob.update_user_id as update_user_id,
  880. checkjob.created_user_name as created_user_name,
  881. checkjob.update_user_name as update_user_name,
  882. checkjob.created_time as created_time,
  883. checkjob.update_time as update_time,
  884. checkjob.standard_hours as standard_hours,
  885. checkjob.real_hours as real_hours,
  886. checkjob.actual_user as actual_user,
  887. checkjob.receive_overtime as receive_overtime,
  888. checkjob.con_task as con_task
  889. from t_check_job as checkjob
  890. <where>
  891. <if test="status != null">
  892. and checkjob.status = #{status}
  893. </if>
  894. <if test="startTimeEnd != null">
  895. and checkjob.start_time <![CDATA[ <= ]]> #{startTimeEnd}
  896. </if>
  897. </where>
  898. </select>
  899. <!-- 分页查询任务ID列表 -->
  900. <select id="selectJobIdPage" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  901. resultType="java.lang.String">
  902. SELECT checkjob_inner.id
  903. FROM t_check_job checkjob_inner
  904. LEFT JOIN t_sb_info sbinfo_inner ON sbinfo_inner.id = checkjob_inner.sb_id
  905. LEFT JOIN t_check_standard standard_inner ON standard_inner.id = checkjob_inner.standard_id
  906. LEFT JOIN t_sys_user u ON checkjob_inner.check_user_id = u.user_id
  907. <where>
  908. <include refid="List_Condition_Inner"/>
  909. </where>
  910. </select>
  911. <!-- 根据ID列表查询完整数据 -->
  912. <select id="selectListByIds" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  913. resultMap="CheckJobVOMap">
  914. select
  915. checkjob.id as id,
  916. checkjob.plan_id as plan_id,
  917. checkjob.name as name,
  918. checkjob.type as type,
  919. checkjob.hours as hours,
  920. checkjob.miles as miles,
  921. checkjob.sb_id as sb_id,
  922. checkjob.part_id as part_id,
  923. checkjob.standard_id as standard_id,
  924. checkjob.start_time as start_time,
  925. checkjob.end_time as end_time,
  926. checkjob.actual_start_time as actual_start_time,
  927. checkjob.actual_end_time as actual_end_time,
  928. checkjob.requirement as requirement,
  929. checkjob.remark as remark,
  930. checkjob.feedback as feedback,
  931. checkjob.status as status,
  932. checkjob.sb_status as sb_status,
  933. checkjob.check_user_id as check_user_id,
  934. checkjob.check_dept_id as check_dept_id,
  935. checkjob.created_user_id as created_user_id,
  936. checkjob.update_user_id as update_user_id,
  937. checkjob.created_user_name as created_user_name,
  938. checkjob.update_user_name as update_user_name,
  939. checkjob.created_time as created_time,
  940. checkjob.update_time as update_time,
  941. checkjob.standard_hours as standard_hours,
  942. checkjob.real_hours as real_hours,
  943. checkjob.actual_user as actual_user,
  944. checkjob.receive_overtime as receive_overtime,
  945. checkjob.con_task as con_task,
  946. u.real_name as checkUserName,
  947. dept.name as checkDeptName,
  948. sbinfo.name as sbName,
  949. sbinfo.no as sbNo,
  950. sbinfo.level as sbLevel,
  951. sbinfo.id as sbInfoId,
  952. partinfo.name as partName,
  953. standard.no as standardNo,
  954. standard.name as standardName,
  955. standard.level as standardLevel,
  956. standard.period as period,
  957. standard.period_type as periodType,
  958. position.id as positionId,
  959. position.name as positionName,
  960. cr.id as requirement_id,
  961. cr.std_name as std_name,
  962. cr.scope as scope,
  963. cr.type as requirement_type,
  964. cr.method as requirement_method,
  965. cr.sb_type as requirement_sb_type,
  966. cr.check_level as requirement_check_level,
  967. cr.manage_item as requirement_manage_item,
  968. cr.check_item as requirement_check_item,
  969. cr.content as requirement_content,
  970. cr.period as requirement_period,
  971. sbtype.name as requirement_sb_type_name,
  972. cr.remark as requirement_remark,
  973. cr.created_user_name as requirement_created_user_name,
  974. cr.created_time as requirement_created_time,
  975. cr.update_user_name as requirement_update_user_name,
  976. cr.update_time as requirement_update_time,
  977. cr.status as requirement_status
  978. from t_check_job as checkjob
  979. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  980. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  981. left join t_check_standard standard on standard.id = checkjob.standard_id
  982. left join t_sys_user u on checkjob.check_user_id = u.user_id
  983. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  984. left join t_sb_position position on position.id = sbinfo.position_id
  985. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  986. left join t_check_requirement cr on cr.id = csr.requirement_id
  987. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  988. WHERE checkjob.id IN
  989. <foreach item="item" index="index" collection="jobIdList" open="(" close=")" separator=",">
  990. #{item}
  991. </foreach>
  992. Order By
  993. checkjob.status asc,
  994. <if test="status==null or status==1 or status==2">
  995. checkjob.start_time asc,
  996. </if>
  997. sbinfo.level asc,
  998. sbinfo.no asc,
  999. standard.period_type asc,
  1000. standard.period asc
  1001. </select>
  1002. <!-- 根据ID列表查询完整数据2(record=1) -->
  1003. <select id="selectList2ByIds" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  1004. resultMap="CheckJobVOMap">
  1005. select
  1006. checkjob.id as id,
  1007. checkjob.plan_id as plan_id,
  1008. checkjob.name as name,
  1009. checkjob.type as type,
  1010. checkjob.hours as hours,
  1011. checkjob.miles as miles,
  1012. checkjob.sb_id as sb_id,
  1013. checkjob.part_id as part_id,
  1014. checkjob.standard_id as standard_id,
  1015. checkjob.start_time as start_time,
  1016. checkjob.end_time as end_time,
  1017. checkjob.actual_start_time as actual_start_time,
  1018. checkjob.actual_end_time as actual_end_time,
  1019. checkjob.requirement as requirement,
  1020. checkjob.remark as remark,
  1021. checkjob.feedback as feedback,
  1022. checkjob.status as status,
  1023. checkjob.sb_status as sb_status,
  1024. checkjob.check_user_id as check_user_id,
  1025. checkjob.check_dept_id as check_dept_id,
  1026. checkjob.created_user_id as created_user_id,
  1027. checkjob.update_user_id as update_user_id,
  1028. checkjob.created_user_name as created_user_name,
  1029. checkjob.update_user_name as update_user_name,
  1030. checkjob.created_time as created_time,
  1031. checkjob.update_time as update_time,
  1032. checkjob.standard_hours as standard_hours,
  1033. checkjob.real_hours as real_hours,
  1034. checkjob.actual_user as actual_user,
  1035. checkjob.receive_overtime as receive_overtime,
  1036. checkjob.con_task as con_task,
  1037. u.real_name as checkUserName,
  1038. dept.name as checkDeptName,
  1039. sbinfo.name as sbName,
  1040. sbinfo.no as sbNo,
  1041. sbinfo.level as sbLevel,
  1042. sbinfo.id as sbInfoId,
  1043. partinfo.name as partName,
  1044. standard.no as standardNo,
  1045. standard.name as standardName,
  1046. standard.level as standardLevel,
  1047. standard.period as period,
  1048. standard.period_type as periodType,
  1049. position.id as positionId,
  1050. position.name as positionName,
  1051. cr.id as requirement_id,
  1052. cr.std_name as std_name,
  1053. cr.scope as scope,
  1054. cr.type as requirement_type,
  1055. cr.method as requirement_method,
  1056. cr.sb_type as requirement_sb_type,
  1057. cr.check_level as requirement_check_level,
  1058. cr.manage_item as requirement_manage_item,
  1059. cr.check_item as requirement_check_item,
  1060. cr.content as requirement_content,
  1061. cr.period as requirement_period,
  1062. sbtype.name as requirement_sb_type_name,
  1063. cr.remark as requirement_remark,
  1064. cr.created_user_name as requirement_created_user_name,
  1065. cr.created_time as requirement_created_time,
  1066. cr.update_user_name as requirement_update_user_name,
  1067. cr.update_time as requirement_update_time,
  1068. cr.status as requirement_status
  1069. from t_check_job as checkjob
  1070. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  1071. left join t_part_info partinfo on partinfo.id = checkjob.part_id
  1072. left join t_check_standard standard on standard.id = checkjob.standard_id
  1073. left join t_sys_user u on checkjob.check_user_id = u.user_id
  1074. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  1075. left join t_sb_position position on position.id = sbinfo.position_id
  1076. left join t_check_standard_requirement csr on csr.standard_id = standard.id
  1077. left join t_check_requirement cr on cr.id = csr.requirement_id and cr.status = 1
  1078. left join t_sb_type sbtype on sbtype.id = cr.sb_type
  1079. WHERE checkjob.id IN
  1080. <foreach item="item" index="index" collection="jobIdList" open="(" close=")" separator=",">
  1081. #{item}
  1082. </foreach>
  1083. </select>
  1084. <!-- 查询执行方式为班组且未完成的保养任务,用于每日定时提醒班长 -->
  1085. <select id="selectUnfinishedTeamJobs" resultType="com.platform.dao.vo.query.check.CheckJobVO">
  1086. select
  1087. checkjob.id as id,
  1088. checkjob.name as name,
  1089. checkjob.sb_id as sbId,
  1090. checkjob.standard_id as standardId,
  1091. checkjob.status as status,
  1092. checkjob.check_dept_id as checkDeptId,
  1093. checkjob.start_time as startTime,
  1094. checkjob.end_time as endTime,
  1095. sbinfo.name as sbName,
  1096. sbinfo.no as sbNo,
  1097. dept.name as checkDeptName
  1098. from t_check_job as checkjob
  1099. inner join t_check_standard standard on standard.id = checkjob.standard_id
  1100. left join t_sb_info sbinfo on sbinfo.id = checkjob.sb_id
  1101. left join t_sys_dept dept on checkjob.check_dept_id = dept.dept_id
  1102. where checkjob.type = 2
  1103. and standard.check_user_type = 4
  1104. and checkjob.check_dept_id is not null
  1105. and checkjob.status != 3
  1106. order by checkjob.check_dept_id asc, sbinfo.no asc
  1107. </select>
  1108. <!-- 显式更新指定标准下某状态任务的执行人字段,允许将 check_user_id / check_dept_id 置空,
  1109. 用于执行人方式在“班组”与“具体人”之间切换时彻底移交任务归属 -->
  1110. <update id="updateJobExecutor">
  1111. update t_check_job
  1112. set check_user_id = #{checkUserId},
  1113. check_dept_id = #{checkDeptId}
  1114. where standard_id = #{standardId}
  1115. and status = #{status}
  1116. </update>
  1117. <!-- 年度保养计划表:以“保养标准(t_check_standard)”为行来源,排除按天(period_type=1)的保养,
  1118. 即使该标准尚未执行任何任务也会显示一行(月份不打勾);
  1119. 当年某设备每月只要有已完成(status=3)的保养任务则该月打勾√ -->
  1120. <select id="selectAnnualPlan" parameterType="com.platform.dao.dto.check.CheckJobDTO"
  1121. resultType="com.platform.dao.vo.query.check.CheckJobAnnualPlanVO">
  1122. select
  1123. sbtype.name as category,
  1124. sbinfo.name as sbName,
  1125. <!-- 保养负责人与任务生成逻辑保持一致:
  1126. 1-使用人取设备保管人(save_user),2-维修人取设备第一维修人(repair_user),
  1127. 3-指定取标准上已绑定的人(保存时=维修人),4-班组取部门 -->
  1128. case standard.check_user_type
  1129. when 1 then su_save.real_name
  1130. when 2 then su_repair.real_name
  1131. when 3 then coalesce(su.real_name, su_repair.real_name)
  1132. when 4 then sdept.name
  1133. else coalesce(su.real_name, sdept.name)
  1134. end as owner,
  1135. count(distinct sbinfo.id) as sbNum,
  1136. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 1 then '√' else '' end) as month1,
  1137. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 2 then '√' else '' end) as month2,
  1138. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 3 then '√' else '' end) as month3,
  1139. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 4 then '√' else '' end) as month4,
  1140. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 5 then '√' else '' end) as month5,
  1141. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 6 then '√' else '' end) as month6,
  1142. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 7 then '√' else '' end) as month7,
  1143. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 8 then '√' else '' end) as month8,
  1144. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 9 then '√' else '' end) as month9,
  1145. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 10 then '√' else '' end) as month10,
  1146. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 11 then '√' else '' end) as month11,
  1147. max(case when month(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = 12 then '√' else '' end) as month12
  1148. from t_check_standard standard
  1149. inner join t_sb_info sbinfo on sbinfo.id = standard.sb_id
  1150. left join t_sb_type sbtype on sbtype.id = sbinfo.type_id
  1151. left join t_sys_user su on standard.check_user_id = su.user_id
  1152. left join t_sys_dept sdept on standard.check_dept_id = sdept.dept_id
  1153. left join t_sys_user su_save on sbinfo.save_user = su_save.user_id
  1154. left join t_sys_user su_repair on sbinfo.repair_user = su_repair.user_id
  1155. left join t_check_job job on job.standard_id = standard.id
  1156. and job.status = 3
  1157. <if test="searchYear != null">
  1158. and year(coalesce(job.actual_end_time, job.actual_start_time, job.end_time)) = #{searchYear}
  1159. </if>
  1160. <where>
  1161. standard.period_type != 1
  1162. <if test="type != null">
  1163. and standard.type = #{type}
  1164. </if>
  1165. </where>
  1166. group by sbtype.name, sbinfo.name,
  1167. case standard.check_user_type
  1168. when 1 then su_save.real_name
  1169. when 2 then su_repair.real_name
  1170. when 3 then coalesce(su.real_name, su_repair.real_name)
  1171. when 4 then sdept.name
  1172. else coalesce(su.real_name, sdept.name)
  1173. end
  1174. order by sbtype.name asc, sbinfo.name asc
  1175. </select>
  1176. </mapper>